K
K
ksvdon2018-10-19 19:32:40
Ansible
ksvdon, 2018-10-19 19:32:40

Why doesn't ignore_errors help for ping?

In general, I am rebooting a remote virtual machine, I want to ping to check whether the host has woken up or not (I know about wait_for port, but I need to additionally check with another tool that I can execute a command on a remote host). There is a problem that the machine does not go into reboot, it pings, but you can't connect to it via ssh, do something on it, etc. but alas, ignore_errors does not work. How to be? Or is there another means besides ping to check the host, who knows?
doing a reboot:

- name: Rebooting the machine
  shell: sleep 2 && shutdown -r now
  async: 1
  poll: 0
  ignore_errors: yes

I sleep very little on purpose, so that I definitely don’t have time to boot
- name: tmp sleep
  local_action: shell sleep 5

now ping pong
- name: ping pong
  ping:
  register: data
  ignore_errors: yes

and that's it, I can't process anything, I'm flying out
TASK [reboot_vm : ping pong] ***************************************************
fatal: [default]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: ssh: connect to host 192.168.245.145 port 22: Connection refused\r\n", "unreachable": true}
  to retry, use: --limit @/etc/ansible/prepare.retry

PLAY RECAP *********************************************************************
default                    : ok=3    changed=2    unreachable=1    failed=0

I also tried to simply execute the whoami shell or something else - I break off on the same error and cannot ignore it.
ansible-2.4.2.0-2
in general thanks in advance for good advice...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Puma Thailand, 2018-10-20
@ksvdon

So you run this task on localhost

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question