How to wait for server restart using Ansible?
ansible, deployment, linux, ssh
Solution
You should change the wait_for task to run as local_action, and specify the host you're waiting for. For example:
- name: Wait for server to restart
local_action:
module: wait_for
host=192.168.50.4
port=22
delay=1
timeout=300
Problem
I'm trying to restart the server and then wait, using this: ``` - name: Restart server shell: reboot - name: Wait for server to restart wait_for: port=22 delay=1 timeout=300 ``` But I get this error: ``` TASK: [iptables | Wait for server to restart] ********************************* fatal: [example.com] => failed to transfer file to /root/.ansible/tmp/ansible-tmp-1401138291.69-222045017562709/wait_for: sftp> put /tmp/tmpApPR8k /root/.ansible/tmp/ansible-tmp-1401138291.69-222045017562709/wait_for Connected to example.com. Connection closed ```