LoginSignup
1
2

More than 3 years have passed since last update.

ansible接続確認の方法

Posted at

ansible接続確認

ansibleはsshでホスト=>ターゲットにコマンドを送るのだが、それを確認する方法

inventory.iniはこのようになっている

inventory.ini
[app1s]
app1 ansible_host=192.168.33.10

[app2s]
app2first ansible_host=192.168.33.11
app2second ansible_host=192.168.33.12

単純にホストがあるかどうか確認

これはssh接続できていなくてもメッセージは表示される

$ ansible <inventory.iniにある調べたい対象> -i inventory.ini -m debug -a 'msg=hello'

ホストにsshで接続できるか確認

pingで疎通確認をするのだが、これはssh接続できていないと繋がらない
-uでユーザー名を指定し、--private-keyで公開鍵を指定してあげる

$ ansible <inventory.iniにある調べたい対象> -i inventory.ini -m ping -u username --private-key /Users/yourname/key.pem

*上記に記載する

「inventory.iniにある調べたい対象」は
・inventory.ini内の全て=>all
・inventory.ini内のapp2sの全て=>app2s
・inventory.ini内の特定のhost=>app1やapp2firstやapp2second
を指定する

1
2
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
1
2