How to reboot CentOS 7 with Ansible?

前端 未结 11 1614
遥遥无期
遥遥无期 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:12

    if you're using Ansible version >=2.7, you can use reboot module as described here

    The synopsis of the reboot module itself:

    Reboot a machine, wait for it to go down, come back up, and respond to commands.

    In a simple way, you can define a simple task like this:

        - name: reboot server
          reboot:
    

    But you can add some params like test_command to test if your server is ready to take further tasks

        - name: reboot server
          reboot:
            test_command: whoami
    

    Hope this helps!

提交回复
热议问题