Hi,

I have a group of hosts (say 3 hosts) of which one becomes unresponsive 
(due to heavy load or sshd is not running etc reasons). So eventually 
Ansible Playbook would fail with unreachable host message for that host. I 
want to handle this error and run a script locally (where the playbook is 
running from) to shutdown the unreachable host (there is an API from VMware 
where I can use to shutdown the VM without having to ssh to the remote VM). 
I am trying to simulate this by running a dummy script however my command 
is not executing for the unreachable host or it is executing for the good 
hosts as well (the ones that i can reach) but I don't want to. This is my 
playbook,

--- 
- hosts: "{{src}}_{{shard}}_test" 
any_errors_fatal: true 
gather_facts: False 
max_fail_percentage: 0 
tags: 
- passivateSite 
tasks: 
- name: check SSH connection 
ping: 
register: result 
ignore_errors: True

- debug: msg="System {{ inventory_hostname }}"

- name: if ssh connection failed then run this 
command: /etc/ansible/test.sh red "@@@ Shutting down the VM @@@" 
when: result|failed 
ignore_errors: True


Any Clue? Or is there a way in ansible that I collect the failed hosts into 
another host group and only execute a command against these hosts?

-- 
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/eaaa909a-bc34-4608-999b-aaaa297e80b9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to