LoginSignup
3
2

More than 3 years have passed since last update.

Ansible AWXでSSHのフィンガープリントを無視する設定

Posted at

概要

AWX で SSH のフィンガープリントをチェックせずにplaybookを実行できるようにします。

問題

AWX でplaybookを実行したとき、対象のIPアドレスが同じだが ssh の
フィンガープリントが異なる場合に以下のエラーが発生し接続に失敗します。

スクリーンショット (25).png

実際のメッセージ

{
    "msg": "Failed to connect to the host via ssh: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\r\n@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @\r\n@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\r\nIT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!\r\nSomeone could be eavesdropping on you right now (man-in-the-middle attack)!\r\nIt is also possible that a host key has just been changed.\r\nThe fingerprint for the ECDSA key sent by the remote host is\nSHA256:fZvUoJgp8hxdmqRe7W5z08Y0gbo1jw3V3M8pdBoSH9E.\r\nPlease contact your system administrator.\r\nAdd correct host key in /root/.ssh/known_hosts to get rid of this message.\r\nOffending ECDSA key in /root/.ssh/known_hosts:1\r\nPassword authentication is disabled to avoid man-in-the-middle attacks.\r\nKeyboard-interactive authentication is disabled to avoid man-in-the-middle attacks.\r\nPermission denied (publickey,gssapi-keyex,gssapi-with-mic,password).",
    "unreachable": true,
    "changed": false
}

例えば、前回の記事で作成した環境を以下のようにリセットした場合、コンテナ起動時に SSH のフィンガープリントが再生成されるため、同様の現象が発生します。

dokcer-compose.yml があるディレクトリに移動
# cd centos7

コンテナをすべて停止、削除
# docker-compose down

コンテナを起動
# docker-compose up -d

問題を回避するための設定

AWX にログイン後、「設定」から「ジョブ」をクリックします。

スクリーンショット (26).png

画面下の「追加の環境変数」を追加の「環境変数(変更後)」以下のように変更します。

追加の環境変数(変更前)

{
 "HOME": "/var/lib/awx"
}

追加の環境変数(変更後)

{
 "HOME": "/var/lib/awx",
 "ANSIBLE_SSH_ARGS": "-C -o ControlMaster=auto -o ControlPersist=60s -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
}

「保存」をクリックして設定を反映させます。

スクリーンショット (28).png

以上です。

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