播放过程中出现SSH错误
我在Ansible上犯了一个奇怪的错误。首先,第一个角色工作正常,但是当Ansible尝试执行第二个角色时,由于ssh错误,它失败了 环境:播放过程中出现SSH错误,ssh,ansible,ansible-2.x,Ssh,Ansible,Ansible 2.x,我在Ansible上犯了一个奇怪的错误。首先,第一个角色工作正常,但是当Ansible尝试执行第二个角色时,由于ssh错误,它失败了 环境: ansible-playbook -vvvv -i inventory/dev playbook_update_system.yml --limit "db[0]" - name: "HUB Playbook | Updating system packages on {{ ansible_hostname }}" hosts: release_fi
ansible-playbook -vvvv -i inventory/dev playbook_update_system.yml --limit "db[0]"
- name: "HUB Playbook | Updating system packages on {{ ansible_hostname }}"
hosts: release_first_half
roles:
- upgrade_system_package
- reboot_server
- name: "upgrading CentOS system packages on {{ ansible_hostname }}"
shell: sudo puppet apply -e 'exec{"upgrade-package":command => "/usr/bin/yum clean all; /usr/bin/yum -y update;"}'
when: ansible_distribution == 'CentOS' and 'cassandra' not in group_names
- name: "reboot CentOS [{{ ansible_hostname }}] server"
shell: sudo puppet apply -e 'exec{"reboot-os":command => "/usr/sbin/reboot"}'
when: ansible_distribution == 'CentOS' and 'cassandra' not in group_names
- 操作系统:CentOS 7
- Ansible版本:2.2.1.0
- Python版本:2.7.5
- OpenSSH版本:OpenSSH_6.6.1p1、OpenSSL 1.0.1e-fips 2013年2月11日
ansible-playbook -vvvv -i inventory/dev playbook_update_system.yml --limit "db[0]"
- name: "HUB Playbook | Updating system packages on {{ ansible_hostname }}"
hosts: release_first_half
roles:
- upgrade_system_package
- reboot_server
- name: "upgrading CentOS system packages on {{ ansible_hostname }}"
shell: sudo puppet apply -e 'exec{"upgrade-package":command => "/usr/bin/yum clean all; /usr/bin/yum -y update;"}'
when: ansible_distribution == 'CentOS' and 'cassandra' not in group_names
- name: "reboot CentOS [{{ ansible_hostname }}] server"
shell: sudo puppet apply -e 'exec{"reboot-os":command => "/usr/sbin/reboot"}'
when: ansible_distribution == 'CentOS' and 'cassandra' not in group_names
剧本:
ansible-playbook -vvvv -i inventory/dev playbook_update_system.yml --limit "db[0]"
- name: "HUB Playbook | Updating system packages on {{ ansible_hostname }}"
hosts: release_first_half
roles:
- upgrade_system_package
- reboot_server
- name: "upgrading CentOS system packages on {{ ansible_hostname }}"
shell: sudo puppet apply -e 'exec{"upgrade-package":command => "/usr/bin/yum clean all; /usr/bin/yum -y update;"}'
when: ansible_distribution == 'CentOS' and 'cassandra' not in group_names
- name: "reboot CentOS [{{ ansible_hostname }}] server"
shell: sudo puppet apply -e 'exec{"reboot-os":command => "/usr/sbin/reboot"}'
when: ansible_distribution == 'CentOS' and 'cassandra' not in group_names
角色:升级系统软件包:
ansible-playbook -vvvv -i inventory/dev playbook_update_system.yml --limit "db[0]"
- name: "HUB Playbook | Updating system packages on {{ ansible_hostname }}"
hosts: release_first_half
roles:
- upgrade_system_package
- reboot_server
- name: "upgrading CentOS system packages on {{ ansible_hostname }}"
shell: sudo puppet apply -e 'exec{"upgrade-package":command => "/usr/bin/yum clean all; /usr/bin/yum -y update;"}'
when: ansible_distribution == 'CentOS' and 'cassandra' not in group_names
- name: "reboot CentOS [{{ ansible_hostname }}] server"
shell: sudo puppet apply -e 'exec{"reboot-os":command => "/usr/sbin/reboot"}'
when: ansible_distribution == 'CentOS' and 'cassandra' not in group_names
角色:重新启动服务器:
ansible-playbook -vvvv -i inventory/dev playbook_update_system.yml --limit "db[0]"
- name: "HUB Playbook | Updating system packages on {{ ansible_hostname }}"
hosts: release_first_half
roles:
- upgrade_system_package
- reboot_server
- name: "upgrading CentOS system packages on {{ ansible_hostname }}"
shell: sudo puppet apply -e 'exec{"upgrade-package":command => "/usr/bin/yum clean all; /usr/bin/yum -y update;"}'
when: ansible_distribution == 'CentOS' and 'cassandra' not in group_names
- name: "reboot CentOS [{{ ansible_hostname }}] server"
shell: sudo puppet apply -e 'exec{"reboot-os":command => "/usr/sbin/reboot"}'
when: ansible_distribution == 'CentOS' and 'cassandra' not in group_names
当前行为:
ansible-playbook -vvvv -i inventory/dev playbook_update_system.yml --limit "db[0]"
- name: "HUB Playbook | Updating system packages on {{ ansible_hostname }}"
hosts: release_first_half
roles:
- upgrade_system_package
- reboot_server
- name: "upgrading CentOS system packages on {{ ansible_hostname }}"
shell: sudo puppet apply -e 'exec{"upgrade-package":command => "/usr/bin/yum clean all; /usr/bin/yum -y update;"}'
when: ansible_distribution == 'CentOS' and 'cassandra' not in group_names
- name: "reboot CentOS [{{ ansible_hostname }}] server"
shell: sudo puppet apply -e 'exec{"reboot-os":command => "/usr/sbin/reboot"}'
when: ansible_distribution == 'CentOS' and 'cassandra' not in group_names
ansible-playbook -vvvv -i inventory/dev playbook_update_system.yml --limit "db[0]"
- name: "HUB Playbook | Updating system packages on {{ ansible_hostname }}"
hosts: release_first_half
roles:
- upgrade_system_package
- reboot_server
- name: "upgrading CentOS system packages on {{ ansible_hostname }}"
shell: sudo puppet apply -e 'exec{"upgrade-package":command => "/usr/bin/yum clean all; /usr/bin/yum -y update;"}'
when: ansible_distribution == 'CentOS' and 'cassandra' not in group_names
- name: "reboot CentOS [{{ ansible_hostname }}] server"
shell: sudo puppet apply -e 'exec{"reboot-os":command => "/usr/sbin/reboot"}'
when: ansible_distribution == 'CentOS' and 'cassandra' not in group_names
致命:[db1]:无法访问!=>{
“更改”:错误,
“味精”:"无法通过ssh连接到主机:OpenSSH_6.6.1,OpenSSL 1.0.1e-fips 2013年2月11日\r\ndebug1:读取配置数据/USR/newtprod/.ssh/config\r\ndebug1:读取配置数据/etc/ssh/ssh_-config\r\ndebug1:/etc/ssh/ssh-config第56行:应用*\r\ndebug1:自动mux:尝试现有主\r\ndebug2:fd 3设置O\r\n块\r\ndebug2:mux\u客户端\u hello\u交换:主版本4\r\ndebug3:mux\u客户端\u转发:请求转发:0本地,0远程\r\ndebug3:mux\u客户端\u请求\u会话:输入\r\ndebug3:mux\u客户端\u请求\u活动:完成pid=64994\r\ndebug3:mux\u客户端\u请求\u会话:发送的会话请求\r\ndebug1:mux_客户端\u请求\u会话:主会话id:2\r\n错误3:mux\u客户端\u读取\u数据包:读取头失败:管道断开\r\n错误2:Control master意外终止\r\n与db1的共享连接已关闭。\r\n“,
“遥不可及”:真实
}
我不明白,因为上一个角色已经在此节点上成功执行。此外,我们有很多playbook使用相同的清单文件,它们工作正常。我也在另一个节点上尝试过,但结果相同。这是一个简单且众所周知的问题:关闭过程会导致SSH守护进程退出,从而中断current SSH会话(出现“断管”错误)。服务器正确重新启动,但Ansible流中断 您需要向
shell
命令添加延迟,并使用async
选项运行它,以便Ansible的SSH会话可以在终止之前完成
shell: sleep 5; sudo puppet apply -e 'exec{"reboot-os":command => "/usr/sbin/reboot"}'
async: 0
poll: 0