How to reboot CentOS 7 with Ansible?

前端 未结 11 1617
遥遥无期
遥遥无期 2020-12-24 07:46

I\'m trying to reboot server running CentOS 7 on VirtualBox. I use this task:

- name: Restart server
  command: /sbin/reboot
  async: 0
  poll:          


        
11条回答
  •  醉酒成梦
    2020-12-24 08:17

    Following solution works for me perfect:

    - name: Restart machine
      shell: "sleep 5 && sudo shutdown -r now"
      async: 1
      poll: 0
    
    - name: wait for ssh again available.
      wait_for_connection:
        connect_timeout: 20
        sleep: 5
        delay: 5
        timeout: 300
    

    Sleep is required because ansible requires few second's to wrap up connection. Excelent post about this problem was written here: https://www.jeffgeerling.com/blog/2018/reboot-and-wait-reboot-complete-ansible-playbook

提交回复
热议问题