linux – ansible reboot 2.1.1.0失败

前端之家收集整理的这篇文章主要介绍了linux – ansible reboot 2.1.1.0失败前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我一直在尝试创建一个非常简单的Ansible playbook,它将重启服务器并等待它返回.

我在过去的Ansible 1.9上有一个有效,但我最近升级到2.1.1.0但它失败了.

我正在重启的主机名为idm,IP为192.168.200.23.

正在使用该命令从我的主机192.168.200.1运行该剧本

$ansible-playbook reboot.yml  -vvvv

这是我正在使用的剧本

---
- hosts: idm

  tasks:
    - name: Restart server
      become: yes
      shell: sleep 2 && /sbin/shutdown -r now "Ansible system package upgraded"


    - name: waiting 60 secs for server to come back
      local_action: wait_for host=192.168.200.23 port=22 delay=60 connect_timeout=200
      become: false

它重新启动机器,但几乎立即失败了

<192.168.200.23> ESTABLISH SSH CONNECTION FOR USER: root
<192.168.200.23> SSH: EXEC ssh -C -vvv -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=root -o ConnectTimeout=10 -o ControlPath=/home/myork/.ansible/cp/ansible-ssh-%h-%p-%r -tt 192.168.200.23 '/bin/sh -c '"'"'LANG=en_GB.UTF-8 LC_ALL=en_GB.UTF-8 LC_MESSAGES=en_GB.UTF-8 /usr/bin/python /root/.ansible/tmp/ansible-tmp-1472242630.58-176546106960362/command; rm -rf "/root/.ansible/tmp/ansible-tmp-1472242630.58-176546106960362/" > /dev/null 2>&1 && sleep 0'"'"''
fatal: [idm]: UNREACHABLE! => {"changed": false,"msg": "Failed to connect to the host via ssh.","unreachable": true}

知道我错过了什么吗?

谢谢!

解决方法

我使用async fire和forget模式重启服务器:
- name: Restart server
  become: yes
  shell: sleep 2 && /sbin/shutdown -r now "Ansible system package upgraded"
  async: 1
  poll: 0

猜你在找的Linux相关文章