Hi I’m getting below error during sw upgrade of a server using Ansible. Remote machine is BSD unix server. Note that the reboot is not initiated by Ansible. At the end of the sw upgrade the server reboot automatically (application initiated reboot). Can anybody help?
fatal: [192.168.1.131]: UNREACHABLE! => {“changed”: false, “msg”: “Failed to connect to the host via ssh: Shared connection to 192.168.1.131 closed.\r\n”, “unreachable”: true}
Script.
- hosts: remote_server
remote_user: ansible
become: yes
become_method: sudo
connection: ssh
gather_facts: yes
vars:
ansible_ssh_host: 192.168.1.131
ansible_ssh_port: 22
tasks:
- name: Install SW version xxx
....
....
- name: waiting for server to reboot
wait_for: host="{{ ansible_ssh_host | default(inventory_hostname) }}" port={{ ansible_ssh_port | default(22) }} search_regex=OpenSSH delay=60 timeout=300
connection: local
sudo: false
- shell: uptime
register: output
- debug: msg=" {{ output.stdout }} "