hi Brian, I was wondering if there is anything else you can suggest to me.  
 I want to report a successful ansible run when the only thing that failed 
were unreachable hosts so that it returns success back to AWX.    

Is there a callback plugin or some local customization that I can write in 
the meantime and then contribute back to Ansible core?

Or perhaps some sort of preprocessor that runs through the inventory and 
removes unreachable/down hosts?

I am interested in two things:
1. any type of quick workaround.   I tried the suggestion you mentioned 
with regards to the meta_clear_host_errors, but this didn't work.  I posted 
the output below.  Even if it did work, I would be concerned that it would 
clear other errors other than unreachable.
2. What is the correct long term solution (enhancement to ansible) to this 
problem, if you agree this would be useful and can provide some guidance of 
a solution you support and I can also work on a PR to add to the the core 
if it's not too complex.  I think this would be useful.


$ ansible-playbook  -i inventories.unreachable/ unreachable2.yml ; echo "return 
code from run is: $?"


PLAY [unreachable test] ********************************


TASK [Gathering Facts] *******************************
ok: [host_online]
fatal: [host_unreachable]: UNREACHABLE! => {"changed": false, "msg": "Failed 
to connect to the host via ssh: ssh: connect to host 10.20.3.21 port 22: 
Connection timed out\r\n", "unreachable": true}


TASK [success1] *****************************
changed: [host_online]


TASK [success1] **************************
fatal: [host_unreachable]: UNREACHABLE! => {"changed": false, "msg": "Failed 
to connect to the host via ssh: ssh: connect to host 10.20.3.21 port 22: 
Connection timed out\r\n", "unreachable": true}
 to retry, use: --limit @/homenfs/aedwards/unreachable2.retry


PLAY RECAP ******************
host_online                : ok=2    changed=1    unreachable=0    failed=0
host_unreachable           : ok=0    changed=0    unreachable=2    failed=0


return code from run is: 4


playbook:
$ cat unreachable2.
$ cat unreachable2.yml
---


- name: "unreachable test"
  hosts: "*"
  become: no


  tasks:


  - name: "success1"
    copy:
      content: "my stuff"
      dest: /tmp/file.success1


  - meta: clear_host_errors



On Wednesday, January 16, 2019 at 3:21:24 PM UTC-8, Brian Coca wrote:
>
> So what you are asking would be the 'default' way ansible operates, it 
> removes 'unreachable' hosts from the rest of the play and then 
> continues with the rest of the hosts. 
> > - any future tasks in the play against that host will not be run (no 
> point as they will all fail as host unreachable). 
>   this is the default 
> > - the playbook will continue run all tasks against the other hosts that 
> are reachable 
>    also the default 
> > - the playbook run will report success (return code = 0) 
>   this is not the default, but you can have a `meta: 
> clear_host_errors` as your last task .. but this might be too big of a 
> hammer. 
>
> There are some cases in which the above is not true, for example, 
> using serial, if all hosts in a 'serial batch' fail (unreachable 
> counts) then the whole play fails, you also have max_fail_percentage 
> to manage how many failures you tolerate. 
>
>
> ---------- 
> Brian Coca 
>

-- 
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/71feebc9-5050-4f7c-8f8f-b14eae9365c2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to