LoginSignup
2
0

More than 3 years have passed since last update.

Ansibleで複数ホストを同時にrebootする

Last updated at Posted at 2019-06-24

なんでやろうと思ったか

個人的に複数台の端末を管理することがあり、今まではスクリプトを書いて複数台rebootしていたがもっといい方法がないかと探していたとことAnsibleをつかえば簡単にできるのではと思い立ったから。

環境

Centos7
ansible 2.8.1

まず1台をrebootする

vi reboot.yml

- hosts: ipaddress
  gather_facts: no
  become: yes

  tasks:
    - name: reboot
      reboot:

参考:https://docs.ansible.com/ansible/latest/modules/reboot_module.html#reboot-module

グループを作成する

vi /etc/ansible/hosts

#追記
[グループ名]
ipaddress
ipaddress

グループを指定して実行する

- hosts: グループ名
  gather_facts: no
  become: yes

  tasks:
    - name: reboot
      reboot:

まとめ

予想以上に簡単にできて個人的には満足です。これを機にAnsibleの勉強をしてみようと思います。

注意

  • ansibleのバージョン2.7以上にしか対応してない
  • ネットワークを自動起動にしておかないと正常に終了したかわからない
2
0
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
2
0