Dynamic Inventoryを用いたプロジェクトでansible-consoleを使う
[toc]
概要
ansibleでDynamic Inventoryを用いてec2を管理している際に
ansible-console
をどのように使うのかメモ。
複数台のサーバに対して、簡単に調査したいときなど使えそう。
起動
-i
の引数に、ec2.pyを渡せばOK。
$ cd /path/to/your/ansible $ ansible-console -i ./inventories/ec2.py
console操作
グルーピング
user@all (19)[f:100]$ list groups all ec2 tag_Group_api tag_Group_web tag_Group_elasticsearch ・・・・・
- リストした時に出力されるのは、./ec2.pyの
tag_xxx
が全てのようだ。
./ec2.py --list "tag_Group_api": [ "api01_dev" ], ・・・・・
(試し)elasticseachクラスタに対して設定ファイルgrepする
(グループ移動) user@all (19)[f:100]$ cd tag_Group_elasticsearch (対象ホスト確認) user@tag_Group_elasticsearch (2)[f:100]$ list es01_dev es02_dev (grepする) user@tag_Group_elasticsearch (2)[f:100]$ grep "discovery.type" /etc/elasticsearch/elasticsearch.yml es01_dev | SUCCESS | rc=0 >> discovery.type: ec2 es02_dev | SUCCESS | rc=0 >> discovery.type: ec2