Playbook:
*---- hosts: all gather_facts: false become: yes become_user: root become_method: sudo tasks: - name: Get last yum update which includes "disablerepo" shell: 'history | grep -m 1 disablerepo' failed_when: out is failed and not out.rc == 1 register: out - debug: msg={{ 'out' ~ out }}* Output: *ansible-playbook [core 2.15.6] config file = /etc/ansible/ansible.cfg configured module search path = ['/home/deploy/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules'] ansible python module location = /usr/local/lib/python3.9/site-packages/ansible ansible collection location = /home/deploy/.ansible/collections:/usr/share/ansible/collections executable location = /usr/local/bin/ansible-playbook python version = 3.9.18 (main, Jan 4 2024, 00:00:00) [GCC 11.4.1 20230605 (Red Hat 11.4.1-2)] (/bin/python3) jinja version = 3.1.2 libyaml = TrueUsing /etc/ansible/ansible.cfg as config fileredirecting (type: inventory) ansible.builtin.vmware_vm_inventory to community.vmware.vmware_vm_inventoryhost_list declined parsing /etc/ansible/hosts as it did not pass its verify_file() methodscript declined parsing /etc/ansible/hosts as it did not pass its verify_file() methodauto declined parsing /etc/ansible/hosts as it did not pass its verify_file() method[WARNING]: Invalid characters were found in group names but not replaced, use -vvvv to see detailsParsed /etc/ansible/hosts inventory source with ini pluginredirecting (type: callback) ansible.builtin.yaml to community.general.yamlredirecting (type: callback) ansible.builtin.yaml to community.general.yamlSkipping callback 'default', as we already have a stdout callback.Skipping callback 'minimal', as we already have a stdout callback.Skipping callback 'oneline', as we already have a stdout callback.PLAYBOOK: patchinfo.yml *******************************************************************************************************************1 plays in patchinfo.ymlPLAY [all] ********************************************************************************************************************************TASK [Get last yum update which includes "disablerepo"] ***********************************************************************************task path: /etc/ansible/playbooks/patchinfo.yml:11Thursday 21 March 2024 13:27:29 -0400 (0:00:00.017) 0:00:00.017 ********Thursday 21 March 2024 13:27:29 -0400 (0:00:00.017) 0:00:00.017 ********<myhost> ESTABLISH SSH CONNECTION FOR USER: None< myhost > SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o 'ControlPath="/home/deploy/.ansible/cp/7caa706ba6"' myhost '/bin/sh -c '"'"'echo ~ && sleep 0'"'"''< myhost > (0, b'/home/deploy\n', b'')< myhost > ESTABLISH SSH CONNECTION FOR USER: None< myhost > SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o 'ControlPath="/home/deploy/.ansible/cp/7caa706ba6"' myhost '/bin/sh -c '"'"'( umask 77 && mkdir -p "` echo /home/deploy/.ansible/tmp `"&& mkdir "` echo /home/deploy/.ansible/tmp/ansible-tmp-1711042050.3964171-1907771-209611470269887 `" && echo ansible-tmp-1711042050.3964171-1907771-209611470269887="` echo /home/deploy/.ansible/tmp/ansible-tmp-1711042050.3964171-1907771-209611470269887 `" ) && sleep 0'"'"''< myhost > (0, b'ansible-tmp-1711042050.3964171-1907771-209611470269887=/home/deploy/.ansible/tmp/ansible-tmp-1711042050.3964171-1907771-209611470269887\n', b'')< myhost > Attempting python interpreter discovery< myhost > ESTABLISH SSH CONNECTION FOR USER: None< myhost > SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o 'ControlPath="/home/deploy/.ansible/cp/7caa706ba6"' myhost '/bin/sh -c '"'"'echo PLATFORM; uname; echo FOUND; command -v '"'"'"'"'"'"'"'"'python3.11'"'"'"'"'"'"'"'"'; command -v '"'"'"'"'"'"'"'"'python3.10'"'"'"'"'"'"'"'"'; command -v '"'"'"'"'"'"'"'"'python3.9'"'"'"'"'"'"'"'"'; command -v '"'"'"'"'"'"'"'"'python3.8'"'"'"'"'"'"'"'"'; command -v '"'"'"'"'"'"'"'"'python3.7'"'"'"'"'"'"'"'"'; command -v '"'"'"'"'"'"'"'"'python3.6'"'"'"'"'"'"'"'"'; command -v '"'"'"'"'"'"'"'"'python3.5'"'"'"'"'"'"'"'"'; command -v '"'"'"'"'"'"'"'"'/usr/bin/python3'"'"'"'"'"'"'"'"'; command -v '"'"'"'"'"'"'"'"'/usr/libexec/platform-python'"'"'"'"'"'"'"'"'; command -v '"'"'"'"'"'"'"'"'python2.7'"'"'"'"'"'"'"'"'; command -v '"'"'"'"'"'"'"'"'/usr/bin/python'"'"'"'"'"'"'"'"'; command -v '"'"'"'"'"'"'"'"'python'"'"'"'"'"'"'"'"'; echo ENDFOUND && sleep 0'"'"''< myhost > (0, b'PLATFORM\nLinux\nFOUND\n/usr/bin/python3.9\n/usr/bin/python3\n/usr/libexec/platform-python\n/usr/bin/python\n/usr/bin/python\nENDFOUND\n', b'')< myhost > ESTABLISH SSH CONNECTION FOR USER: None< myhost > SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o 'ControlPath="/home/deploy/.ansible/cp/7caa706ba6"' myhost '/bin/sh -c '"'"'/usr/bin/python3.9 && sleep 0'"'"''< myhost > (0, b'{"platform_dist_result": [], "osrelease_content": "NAME=\\"Red Hat Enterprise Linux\\"\\nVERSION=\\"9.3 (Plow)\\"\\nID=\\"rhel\\"\\nID_LIKE=\\"fedora\\"\\nVERSION_ID=\\"9.3\\"\\nPLATFORM_ID=\\"platform:el9\\"\\nPRETTY_NAME=\\"Red Hat Enterprise Linux 9.3 (Plow)\\"\\nANSI_COLOR=\\"0;31\\"\\nLOGO=\\"fedora-logo-icon\\"\\nCPE_NAME=\\"cpe:/o:redhat:enterprise_linux:9::baseos\\"\\nHOME_URL=\\"https://www.redhat.com/\\"\\nDOCUMENTATION_URL=\\"https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/9\\"\\nBUG_REPORT_URL=\\"https://bugzilla.redhat.com/\\"\\n\\nREDHAT_BUGZILLA_PRODUCT=\\"Red Hat Enterprise Linux 9\\"\\nREDHAT_BUGZILLA_PRODUCT_VERSION=9.3\\nREDHAT_SUPPORT_PRODUCT=\\"Red Hat Enterprise Linux\\"\\nREDHAT_SUPPORT_PRODUCT_VERSION=\\"9.3\\"\\n"}\n', b'')Using module file /usr/local/lib/python3.9/site-packages/ansible/modules/command.py< myhost > PUT /home/deploy/.ansible/tmp/ansible-local-1907766dv65hq7i/tmpywer5c4x TO /home/deploy/.ansible/tmp/ansible-tmp-1711042050.3964171-1907771-209611470269887/AnsiballZ_command.py< myhost > SSH: EXEC sftp -b - -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o 'ControlPath="/home/deploy/.ansible/cp/7caa706ba6"' '[ myhost ]'< myhost > (0, b'sftp> put /home/deploy/.ansible/tmp/ansible-local-1907766dv65hq7i/tmpywer5c4x /home/deploy/.ansible/tmp/ansible-tmp-1711042050.3964171-1907771-209611470269887/AnsiballZ_command.py\n', b'')< myhost > ESTABLISH SSH CONNECTION FOR USER: None< myhost > SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o 'ControlPath="/home/deploy/.ansible/cp/7caa706ba6"' myhost '/bin/sh -c '"'"'chmod u+x /home/deploy/.ansible/tmp/ansible-tmp-1711042050.3964171-1907771-209611470269887/ /home/deploy/.ansible/tmp/ansible-tmp-1711042050.3964171-1907771-209611470269887/AnsiballZ_command.py && sleep 0'"'"''< myhost > (0, b'', b'')< myhost > ESTABLISH SSH CONNECTION FOR USER: None< myhost > SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o 'ControlPath="/home/deploy/.ansible/cp/7caa706ba6"' -tt myhost '/bin/sh -c '"'"'sudo -H -S -n -u root /bin/sh -c '"'"'"'"'"'"'"'"'echo BECOME-SUCCESS-tbpakhcbvetvnsybvzpszpsloqswokel ; /usr/bin/python3 /home/deploy/.ansible/tmp/ansible-tmp-1711042050.3964171-1907771-209611470269887/AnsiballZ_command.py'"'"'"'"'"'"'"'"' && sleep 0'"'"''Escalation succeeded< myhost > (1, b'\r\n{"changed": true, "stdout": "", "stderr": "", "rc": 1, "cmd": "history | grep -m 1 disablerepo", "start": "2024-03-21 13:27:31.520120", "end": "2024-03-21 13:27:31.533996", "delta": "0:00:00.013876", "failed": true, "msg": "non-zero return code", "invocation": {"module_args": {"_raw_params": "history | grep -m 1 disablerepo", "_uses_shell": true, "stdin_add_newline": true, "strip_empty_ends": true, "argv": null, "chdir": null, "executable": null, "creates": null, "removes": null, "stdin": null}}}\r\n', b'Shared connection to myhost closed.\r\n')< myhost > Failed to connect to the host via ssh: Shared connection to myhost closed.< myhost > ESTABLISH SSH CONNECTION FOR USER: None< myhost > SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o StrictHostKeyChecking=no -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o ConnectTimeout=10 -o 'ControlPath="/home/deploy/.ansible/cp/7caa706ba6"' myhost '/bin/sh -c '"'"'rm -f -r /home/deploy/.ansible/tmp/ansible-tmp-1711042050.3964171-1907771-209611470269887/ > /dev/null 2>&1 && sleep 0'"'"''< myhost > (0, b'', b'')changed: [ myhost ] => changed=true ansible_facts: discovered_interpreter_python: /usr/bin/python3 cmd: history | grep -m 1 disablerepo delta: '0:00:00.013876' end: '2024-03-21 13:27:31.533996' failed_when_result: false invocation: module_args: _raw_params: history | grep -m 1 disablerepo _uses_shell: true argv: null chdir: null creates: null executable: null removes: null stdin: null stdin_add_newline: true strip_empty_ends: true msg: non-zero return code rc: 1 start: '2024-03-21 13:27:31.520120' stderr: '' stderr_lines: <omitted> stdout: '' stdout_lines: <omitted>TASK [debug] ******************************************************************************************************************************task path: /etc/ansible/playbooks/patchinfo.yml:16Thursday 21 March 2024 13:27:31 -0400 (0:00:02.060) 0:00:02.078 ********Thursday 21 March 2024 13:27:31 -0400 (0:00:02.060) 0:00:02.077 ********ok: [ myhost ] => msg: 'out{''changed'': True, ''stdout'': '''', ''stderr'': '''', ''rc'': 1, ''cmd'': ''history | grep -m 1 disablerepo'', ''start'': ''2024-03-21 13:27:31.520120'', ''end'': ''2024-03-21 13:27:31.533996'', ''delta'': ''0:00:00.013876'', ''failed'': False, ''msg'': ''non-zero return code'', ''stdout_lines'': [], ''stderr_lines'': [], ''ansible_facts'': {''discovered_interpreter_python'': ''/usr/bin/python3''}, ''failed_when_result'': False}'* On Thursday, March 21, 2024 at 1:16:01 PM UTC-4 Brian Coca wrote: > he, you'll need the same condition for debug (or use a block) since > debug the way you set it up returns `rc: 1` and fools it into thinking > there is an error. > You can also bypass the top level rc with msg={{ 'out: ' ~ out }} > > > -- > ---------- > Brian Coca (he/him/yo) > > -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/e46a3659-5455-45ce-8613-e63ef75cfd46n%40googlegroups.com.