LoginSignup
8
7

More than 5 years have passed since last update.

ansibleでモジュール実行(簡易疎通確認)

Last updated at Posted at 2016-11-07

今日のお題:サーバ側とクライアント側に必要最低限の設定が出来たためモジュールを実行する

前提条件

手順

実行コマンド
ansible [クライアント側IP] -m ping
pingモジュール確認結果
openstack@Ubuntu16041Server:~/.ssh$ ansible 192.168.56.101 -m ping
192.168.56.101 | SUCCESS => {
    "changed": false,
    "ping": "pong"
}

明日のお題:playbookを作成して何か無害なパッケージをクライアントにインストールする

おまけ

色々設定しない場合のエラーパターンです。
てきとうにやった結果以下の順番でチェックしている?模様

  1. hostsファイルチェック(ここはconfigの参照先config設定依存。何もしてなければ/etc/ansible/hosts)
  2. sshの認証状況確認
  3. 実行後のチェック
「/etc/ansible/hosts」にクライアント側の情報を入れていない場合
openstack@Ubuntu16041Server:~$ ansible 192.168.56.101 -m ping
 [WARNING]: provided hosts list is empty, only localhost is available

 [WARNING]: No hosts matched, nothing to do
SSH鍵設定をしていない場合(hostsファイルは設定済)
openstack@Ubuntu16041Server:~$ ansible 192.168.56.101 -m ping
The authenticity of host '192.168.56.101 (192.168.56.101)' can't be established.
ECDSA key fingerprint is SHA256:0iR9bUQBi9xSFYsTvTkLDDaBdQ7jbsHwZJNhs2ZQ8KY.
Are you sure you want to continue connecting (yes/no)? yes
192.168.56.101 | UNREACHABLE! => {
    "changed": false,
    "msg": "Failed to connect to the host via ssh: Warning: Permanently added '192.168.56.101' (ECDSA) to the list of known hosts.\r\nPermission denied (publickey,password).\r\n",
    "unreachable": true
}
python2.7が入っていない場合
openstack@Ubuntu16041Server:~/.ssh$ ansible 192.168.56.101 -m ping
192.168.56.101 | FAILED! => {
    "changed": false,
    "failed": true,
    "module_stderr": "Shared connection to 192.168.56.101 closed.\r\n",
    "module_stdout": "/bin/sh: 1: /usr/bin/python: not found\r\n",
    "msg": "MODULE FAILURE"
}
8
7
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
8
7