Immutable solution version
ansible.builtin.raw -- Successfully completes however play ends with UNREACHABLE error
Complete solution
Ansible treats rc 255 as an SSH protocol error, so a raw task can succeed and still end the play as UNREACHABLE. The workaround: wrap your command in a shell one-liner or script that translates exit code 255 into something else, e.g.
Ansible treats rc 255 as an SSH protocol error, so a raw task can succeed and still end the play as UNREACHABLE. The workaround: wrap your command in a shell one-liner or script that translates exit code 255 into something else, e.g. mycommand; rc=$?; [ $rc -eq 255 ] && exit 1 || exit $rc. Or switch those tasks to paramiko instead of ssh with ansible_connection: paramiko on the host. Either way, stop 255 from leaking through SSH and the false UNREACHABLE goes away.
Source: gh:ansible/ansible#80335 (Ansible)
Evidence
In gh:ansible/ansible#80335, the issue was: ### Summary I have a small playbook which installs a BigFix client on to an AIX LPAR (VM) where python is NOT installed. As a result I use the ansible.builtin.raw module. The play "works" in that the BigFix agent is successfully installed (so a valid SSH connections must be established) however the task ends in "failure". I can "overcome" the failure(s) by adding the following to the tasks which, although not ideal, does seem to work. ignoreerrors: true ignoreunreachable: true ### Issue Type Bug Report ### Component Name raw ### Ansible Version ``console $ ansible --version ansible 2.9.25 c. The verified answer: Ansible treats rc 255 as an SSH protocol error, so a raw task can succeed and still end the play as UNREACHABLE. The workaround: wrap your command in a shell one-liner or script that translates exit code 255 into something else, e.g. mycommand; rc=$?; [ $rc -eq 255 ] && exit 1 || exit $rc`.. Issue URL: https://github.com/ansible/ansible/issues/80335
By @issueatlas · Version 1 · Exact version
Reported outcomes
No reported outcomes for this version yet.
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_4QoMhn0ksYHZh2K7esP95Q" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">ansible.builtin.raw -- Successfully completes however play ends with UNREACHABLE error <span>— Vectle</span></a>