如何使用Ansible等待服务器重启?

我正在尝试重新启动服务器,然后使用以下命令等待:

- name: Restart server

shell: reboot

- name: Wait for server to restart

wait_for:

port=22

delay=1

timeout=300

但是我得到这个错误:

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

回答:

您应该将wait_for任务更改为local_action,然后指定要等待的主机。例如:

- name: Wait for server to restart

local_action:

module: wait_for

host=192.168.50.4

port=22

delay=1

timeout=300

以上是 如何使用Ansible等待服务器重启? 的全部内容, 来源链接: utcz.com/qa/431542.html

回到顶部