Ansible - Failed to add the host to the list of known hosts

Hi

i’m trying to run may first playbook with become_user : cftadmin and i got this error msg :

fatal: [ANS_IAWGAP01]: FAILED! => {“changed”: false, “module_stderr”: “Failed to add the host to the list of known hosts (/tmp/$USER/ansible/configuration/known_hosts).\r\nSorry, user C405372 is not allowed to execute ‘/bin/sh -c echo BECOME-SUCCESS-yzuuugnflqcoylvtkjanapdugeokgrat; /usr/bin/python’ as cftadmin on iawgap01.\n”, “module_stdout”: “”, “msg”: “MODULE FAILURE”, “rc”: 1}

i tried pipeline = True in ssh section :

ssh_args = -o GSSAPIAuthentication=yes -o UserKnownHostsFile=/tmp/$USER/ansible/configuration/known_hosts
scp_if_ssh=True
pipelining = true

but i still have the problem …

can someone help me please ?

Hi,

  • Is cftadmin user present in both master and node ?- Have you generated ssh key for cftadmin on master and did ssh-copy-id to node system ?
  • Have you set “PasswordAuthentication yes” in /etc/sshd/sshd_config file and restarted sshd service ?
  • Is “ansible all -m ping” returning pong for the node you are are trying to connect ?

I followed the below youtube link to run my first Ansible playbook and it went through smooth.
https://www.youtube.com/watch?v=79xFyOc_eEY

Hope this helps.

Looks like the youtube link is not displayed properly in the post because the admin might have removed it. In youtube, you can search for “Ansible Installation & Configuration on AWS | Ansible basics | install & configure Ansible on EC2” topic by Valaxy Technologies.