2018年4月28日土曜日

ansible で yum update を実行

ansible を使って CentOSのアップデートを実行します。
一台だけだと、ansibleでやる必要性は感じないけど、対象が沢山ある時には便利かも。

[root@centos7 ansible]# ansible -i production cent7-1 -m yum -a "name='*' update_cache=yes state=latest"
[root@centos7 ansible]# ansible -i production cent7-1 -m shell -a "shutdown -r now"
cent7-1 | UNREACHABLE! => {
    "changed": false,
    "msg": "Failed to connect to the host via ssh: Shared connection to 192.168.1.80 closed.\r\n",
    "unreachable": true
}
[root@centos7 ansible]# ansible -i production cent7-1 -m ping
cent7-1 | SUCCESS => {
    "changed": false,
    "ping": "pong"
}
[root@centos7 ansible]#

  • アップデートを実行
  • システム再起動
  • ansible pingで稼働を確認


0 件のコメント:

コメントを投稿