ansible重新启动2.1.1.0失败 [英] ansible reboot 2.1.1.0 fails

查看:118
本文介绍了ansible重新启动2.1.1.0失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试创建一个非常简单的Ansible剧本,该剧本将重新启动服务器并等待其返回.

I've been trying to create a really simple Ansible playbook that will reboot a server and wait for it to come back.

过去我曾经在Ansible 1.9上运行过,但是我最近升级到2.1.1.0,但失败了.

I've had one in the past on Ansible 1.9 that worked, but i've recently upgraded to 2.1.1.0 and it fails.

我要重新启动的主机称为idm,其IP为192.168.200.23.

The host i'm rebooting is called idm and has an IP of 192.168.200.23.

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

the playbook is being run from my host 192.168.200.1 with the command

$ 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

它可以很好地重新启动计算机,但几乎立即失败并显示

It reboots the machine fine, but almost immediately fails with

<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}

知道我在这里错过了什么吗?

Any idea what i've missed here ?

谢谢!

推荐答案

我使用async触发并忘记模式重新启动服务器:

I reboot servers with async fire and forget mode:

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

这篇关于ansible重新启动2.1.1.0失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆