How to wait for server restart using Ansible?

后端 未结 11 1172
半阙折子戏
半阙折子戏 2020-12-07 13:06

I\'m trying to restart the server and then wait, using this:

- name: Restart server
  shell: reboot

- name: Wait for server to restart
  wait_for:
    port=         


        
11条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-07 13:27

    I wanted to comment on Shahar post, that he is using a hardcoded host address better is to have it a variable to reference the current host ansible is configuring {{ inventory_hostname }}, so his code will be like that:

    - name: Wait for server to restart
      local_action:
        module: wait_for
         host={{ inventory_hostname }}
         port=22
         delay=1
         timeout=300
    

提交回复
热议问题