Ansible SSH Error: data could not be sent to the remote host. Make sure this host can be reached over sshの解決方法

環境
Ansible
CentOS 9

エラーメッセージ
$ ansible foo -i ./hosts -u root -k -m ping
“msg": “ERROR! SSH Error: data could not be sent to the remote host. Make sure this host can be reached over ssh",

解決方法
方法1.環境変数ANSIBLE_SCP_IF_SSH=yを設定する
ANSIBLE_SCP_IF_SSH=y ansible foo -i ./hosts -u root -k -m ping

方法2
# vi /etc/ansible/ansible.cfg
下記を追記する
[ssh_connection]
scp_if_ssh = True

Ansible

Posted by arkgame