(ansible 1.9.1, Vagrant 1.7.2)
問題 -- Authentication failed
この 『 Ansible チュートリアル』 の ping で疎通確認のところで Authentication failed. になった
$ ansible -i hosts 192.168.33.12 -m ping : 192.168.33.12 | FAILED => FAILED: Authentication failed.
原因 -- Vagrant 1.7 から仕様が変わってた
Vagrant 1.7からは、 insecure_private_keyが、 vagrant upする際に作られれるkeypairに置き換えられる仕様になったそうで、それに影響を受けていました。 http://mawatari.jp/archives/solution-of-vagrant-ssh-connection-error
対処 -- Vagrant 用の秘密鍵をコピーでパスを変更する
$ vagrant ssh-config node1 > ssh_config $ scp -F ssh_config .vagrant/machines/node2/virtualbox/private_key node1:.ssh/id_rsa
別の問題発生
ping はいけたが known_hosts が無いエラー
[vagrant@localhost ~]$ ansible -i hosts 192.168.33.12 -m ping
paramiko: The authenticity of host '192.168.33.12' can't be established.
The ssh-rsa key fingerprint is f03f045136b591c7fa475a49bcfdfe40.
Are you sure you want to continue connecting (yes/no)?
yes
Traceback (most recent call last):
File "/opt/python-2.7/lib/python2.7/site-packages/ansible/runner/connection_plugins/paramiko_ssh.py", line 395, in close
key_stat = os.stat(self.keyfile)
OSError: [Errno 2] No such file or directory: '/home/vagrant/.ssh/known_hosts'
192.168.33.12 | success >> {
"changed": false,
"ping": "pong"
}
空ファイル作成して疎通確認
$ touch ~/.ssh/known_hosts
[vagrant@localhost ~]$ ansible -i hosts 192.168.33.12 -m ping
paramiko: The authenticity of host '192.168.33.12' can't be established.
The ssh-rsa key fingerprint is f03f045136b591c7fa475a49bcfdfe40.
Are you sure you want to continue connecting (yes/no)?
yes
192.168.33.12 | success >> {
"changed": false,
"ping": "pong"
}
正常に ping で疎通確認できた。
メモ
このチュートリアルの ansible インストールの方法だと時間かかるので $ sudo yum install ansible -y した方が手っ取り早いかも。
試してないけど。