微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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

原文地址:https://www.jb51.cc/linux/394576.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐