15
13

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

AnsibleでcentOS7を再起動する

Last updated at Posted at 2016-03-23

今までは下記のように書いていたが、なんかうまくいかない

main.yml
- name: サーバ再起動
  shell: shutdown -r now
- name: OS再起動待ち
  pause: minutes=5 prompt="OS再起動待ち5分"

と思ったらここ↓にそのまま答えが書いてあった
http://connvoi.com/blog/tech/2016/03/03/reboot-ansible.html

ただ、今回は
~/roles/reboot/task/main.yml
に記述するので

main.yml
- name: restart machine
  shell: sleep 2 && shutdown -r now "Ansible updates triggered"
  async: 1
  poll: 0
  sudo: true
  ignore_errors: true

- name: waiting for server to come back
  local_action: wait_for host={{ inventory_hostname }} state=started delay=10 timeout=300
  sudo: false

ansible_hosts
[ansible-base]
ansible_base ansible_ssh_host=XXX.XXX.XXX.XXX
[all:vars]
inventory_hostname=XXX.XXX.XXX.XXX

と、こんな感じ

15
13
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
15
13

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?