Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationEventAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
9
Help us understand the problem. What are the problem?

More than 5 years have passed since last update.

@wanghm

Ansibleでサーバ一括再起動

Ansibleでサーバ一括起動し、SSHログインできるまで待つ

---
# reboot.yml

- name: reboot all hosts and wait it come back in port 22
  hosts: all
  remote_user: ec2-user
  sudo: yes


  tasks:
    - name: hostname
      command: uname -n
      register: hostname
    - debug: msg="{{hostname.stdout_lines}}"

    - name: Restart server
      command: shutdown -r now "Reboot triggered by Ansible"
      async: 0
      poll: 0
      ignore_errors: true
      notify: Wait for server to restart

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

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
9
Help us understand the problem. What are the problem?