サーバA(192.168.100.251)とB(192.168.100.253)に対して
Ansible playbookを実行すると下記のようなエラーが出ます。(Ansible操作端末も対象サーバもCentOS7です)
[root@hoge tmp]# ansible-playbook OracleJDK.yml -i hosts PLAY ***************************************************************************************************************************** TASK [create target dir.] ***************************************************************************************************************** Enter passphrase for key '/root/.ssh/id_rsa': Enter passphrase for key '/root/.ssh/id_rsa': ok: [192.168.100.251] fatal: [192.168.100.253]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).\r\n", "unreachable": true}
サーバAは成功しますが、Bは失敗します。上記エラーの解消方法をご教示頂けたらと思います。
また、下記サイトの通りにansible all -m ping -i hostsを
実行してみるとエラーが出たので、ssh-copy-idコマンドで対象サーバーに公開鍵を設置してみましたが
ansible all -m ping -i hostsの結果が都度変わるような状況です。(下のパターン⓵と⓶参照)
ansible で UNREACHABLE! Failed to connect to the host via ssh: Permission denied エラーで対象ホストにログインできない
#⓵ [root@hoge tmp]# ansible all -m ping -i hosts Enter passphrase for key '/root/.ssh/id_rsa': Enter passphrase for key '/root/.ssh/id_rsa': Enter passphrase for key '/root/.ssh/id_rsa': 192.168.100.251 | SUCCESS => { "changed": false, "ping": "pong" } 192.168.100.253 | UNREACHABLE! => { "changed": false, "msg": "Failed to connect to the host via ssh: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).\r\n", "unreachable": true #⓶ [root@hoge tmp]# ansible all -m ping -i hosts Enter passphrase for key '/root/.ssh/id_rsa': Enter passphrase for key '/root/.ssh/id_rsa': 192.168.100.253 | SUCCESS => { "changed": false, "ping": "pong" } 192.168.100.251 | UNREACHABLE! => { "changed": false, "msg": "Failed to connect to the host via ssh: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).\r\n", "unreachable": true }
端折って申し訳ございません。実行予定のplaybookは下記です。
YAML
1- hosts: tomcat 2 vars: 3 ansible_user: root 4 ansible_ssh_private_key_file: /root/.ssh/id_rsa 5 gather_facts: no 6 remote_user: root 7 become: true 8 tasks: 9 - name: create target dir. 10 file: path=/root/soft state=directory 11 - copy: 12 src=/tmp/jdk-8u202-linux-x64.rpm 13 dest=/root/soft/jdk-8u202-linux-x64.rpm 14 owner=root 15 group=root 16 mode=0644 17 - name: install JDK 14 from a local file 18 yum: name=/root/soft/jdk-8u202-linux-x64.rpm state=present
6/2時点エラー状況
[root@hoge tmp]# ansible-playbook OracleJDK.yml -i hosts PLAY [tomcat] ************************************************************************************************************************************ TASK [create target dir.] ************************************************************************************************************************ Enter passphrase for key '/root/.ssh/id_rsa': Enter passphrase for key '/root/.ssh/id_rsa': ok: [linux3] fatal: [linux1]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: Permission denied (publickey,gssapi-keyex,gssapi-with-mic,password).\r\n", "unreachable": true} TASK [copy] ************************************************************************************************************************************** ok: [linux3] TASK [install JDK 14 from a local file] ********************************************************************************************************** ok: [linux3] to retry, use: --limit @/tmp/OracleJDK.retry PLAY RECAP *************************************************************************************************************************************** linux1 : ok=0 changed=0 unreachable=1 failed=0 linux3 : ok=3 changed=0 unreachable=0 failed=0
宜しくお願い致します。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2020/06/01 10:15
2020/06/01 10:23
2020/06/01 11:37
2020/06/01 13:59
2020/06/02 00:08
2020/06/02 04:29 編集
2020/06/02 05:53
2020/06/02 06:10 編集
2020/06/02 06:25
2020/06/02 06:59 編集
2020/06/02 07:18
2020/06/02 08:49
2020/06/03 00:27
2020/06/03 03:43
2020/06/03 04:28
2020/06/03 04:29
2020/06/03 04:30
2020/06/03 04:30
2020/06/03 04:32
2020/06/03 04:33
2020/06/03 04:33
2020/06/03 05:35
2020/06/03 05:53
2020/06/03 05:55
2020/06/03 06:08
2020/06/03 07:13
2020/06/03 08:42