From 97cff8b2538b787678858e57eea026da0660f3f0 Mon Sep 17 00:00:00 2001 From: Shiva Shankar Vaddepally Date: Wed, 11 Dec 2024 07:19:56 +0000 Subject: [PATCH] shell variable, aiohttp changed --- examples/ssh_connections/echo_hello.yaml | 3 ++- examples/ssh_connections/multiple_plays.yaml | 3 ++- examples/ssh_connections/nscli_command.yaml | 3 ++- examples/ssh_connections/override_generic_tasks.yaml | 3 ++- examples/ssh_connections/override_netscaler_adc_tasks.yaml | 3 ++- examples/ssh_connections/show_tech_support.yaml | 4 +++- plugins/connection/ssh_netscaler_adc.py | 7 ++++--- requirements.txt | 2 +- 8 files changed, 18 insertions(+), 10 deletions(-) diff --git a/examples/ssh_connections/echo_hello.yaml b/examples/ssh_connections/echo_hello.yaml index 4e9bb3968..669ff2676 100644 --- a/examples/ssh_connections/echo_hello.yaml +++ b/examples/ssh_connections/echo_hello.yaml @@ -11,7 +11,8 @@ tasks: - name: Calling shell module register: echo_result - ansible.builtin.shell: "echo hello" + changed_when: false + ansible.builtin.command: "echo hello" - name: Show command output ansible.builtin.debug: diff --git a/examples/ssh_connections/multiple_plays.yaml b/examples/ssh_connections/multiple_plays.yaml index d6e8ed825..eb5d06391 100644 --- a/examples/ssh_connections/multiple_plays.yaml +++ b/examples/ssh_connections/multiple_plays.yaml @@ -10,7 +10,8 @@ tasks: - name: Calling shell module - ansible.builtin.shell: "echo hello" + ansible.builtin.command: "echo hello" + changed_when: false register: echo_result - name: Show command output diff --git a/examples/ssh_connections/nscli_command.yaml b/examples/ssh_connections/nscli_command.yaml index 8f64de993..97987e2d3 100644 --- a/examples/ssh_connections/nscli_command.yaml +++ b/examples/ssh_connections/nscli_command.yaml @@ -13,8 +13,9 @@ tasks: - name: Run nscli command - ansible.builtin.shell: "nscli -s -U :nsroot:{{ nitro_pass }} {{ nscli_command }}" + ansible.builtin.command: "nscli -s -U :nsroot:{{ nitro_pass }} {{ nscli_command }}" no_log: true + changed_when: false register: nscli_output # Actually insecure for production environments since it will show the nitro_pass variable value. diff --git a/examples/ssh_connections/override_generic_tasks.yaml b/examples/ssh_connections/override_generic_tasks.yaml index 84bcb5a68..6fa378e0a 100644 --- a/examples/ssh_connections/override_generic_tasks.yaml +++ b/examples/ssh_connections/override_generic_tasks.yaml @@ -8,7 +8,8 @@ remote_user: nsroot vars: ansible_python_interpreter: /var/python/bin/python - ansible.builtin.shell: "echo hello" + ansible.builtin.command: "echo hello" + changed_when: false register: echo_result - name: Show command output diff --git a/examples/ssh_connections/override_netscaler_adc_tasks.yaml b/examples/ssh_connections/override_netscaler_adc_tasks.yaml index c795be7bb..f550c446d 100644 --- a/examples/ssh_connections/override_netscaler_adc_tasks.yaml +++ b/examples/ssh_connections/override_netscaler_adc_tasks.yaml @@ -11,7 +11,8 @@ tasks: - name: Calling shell module - ansible.builtin.shell: "echo hello" + ansible.builtin.command: "echo hello" + changed_when: false register: echo_result - name: Show command output diff --git a/examples/ssh_connections/show_tech_support.yaml b/examples/ssh_connections/show_tech_support.yaml index db638d91a..834240472 100644 --- a/examples/ssh_connections/show_tech_support.yaml +++ b/examples/ssh_connections/show_tech_support.yaml @@ -13,7 +13,8 @@ tasks: - name: Generate technical support bundle - ansible.builtin.shell: "nscli -s -U :nsroot:{{ nitro_pass }} show techsupport" + changed_when: false + ansible.builtin.command: "nscli -s -U :nsroot:{{ nitro_pass }} show techsupport" register: sts_output no_log: true @@ -31,6 +32,7 @@ - name: Download STS Bundle locally + changed_when: false ansible.builtin.fetch: src: "{{ sts_bundle }}" dest: "my_ns_sts" diff --git a/plugins/connection/ssh_netscaler_adc.py b/plugins/connection/ssh_netscaler_adc.py index 61ac8c624..8bfd0ba26 100644 --- a/plugins/connection/ssh_netscaler_adc.py +++ b/plugins/connection/ssh_netscaler_adc.py @@ -32,7 +32,7 @@ - Sergios Lenis (sergios.lenis@citrix.com) - George Nikolopoulos (giorgos.nikolopoulos@citrix.com) - Shiva Shankar Vaddepally (shivashankar.vaddepally@cloud.com) - + version_added: "1.0.0" options: host: @@ -386,9 +386,10 @@ def wrapped(self, *args, **kwargs): # Ansible needs some data from return_tuple[1](or stdout). So, we are returning the same to ansible regex2 = r'{.*}' try: - return_tuple[1] = re.findall(regex2, str(return_tuple[1]))[0] + return_tuple[1] = re.findall(regex2, str(return_tuple[1]))[0] except IndexError: - pass # If no match, return the old `return_tuple[1]` (i.e., stdout) + pass + # If no match, return the old `return_tuple[1]` (i.e., stdout) return_tuple = tuple(return_tuple) return return_tuple diff --git a/requirements.txt b/requirements.txt index 6f2e2417c..5ae65c636 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ antsibull -aiohttp==3.9.4 +aiohttp==3.10.11 ansible-pygments sphinx-notfound-page sphinx_rtd_theme