0
votes

SSH Authentication problem

TASK [backup : Gather facts (ops)] *************************************************************************************

fatal: [10.X.X.X]: FAILED! => {"msg": " [WARNING] Ansible is being run in a world writable directory (/mnt/c/Users/AnirudhSomanchi/Desktop/KVM/Scripting/Ansible/network/backup), ignoring it as an ansible.cfg source. For more information see https://docs.ansible.com/ansible/devel/reference_appendices/config.html#cfg-in-world-writable-dir\n{\"socket_path\": (https://docs.ansible.com/ansible/devel/reference_appendices/config.html#cfg-in-world-writable-dir/n{/'socket_path/':) \"/home/SaiAnirudh/.ansible/pc/87fd82198c\", \"exception\": \"Traceback (most recent call last):\n File \\"/usr/bin/ansible-connection\\", line 104, in start\n
self.connection._connect()\n File \\"/usr/lib/python2.7/dist-packages/ansible/plugins/connection/network_cli.py\\", line 327, in _connect\n ssh = self.paramiko_conn._connect()\n File \\"/usr/lib/python2.7/dist-packages/ansible/plugins/connection/paramiko_ssh.py\\", line 245, in _connect\n self.ssh = SSH_CONNECTION_CACHE[cache_key] = self._connect_uncached()\n File \\"/usr/lib/python2.7/dist-packages/ansible/plugins/connection/paramiko_ssh.py\\", line 368, in _connect_uncached\n raise AnsibleConnectionFailure(msg)\nAnsibleConnectionFailure: paramiko: The authenticity of host '10.X.X.X' can't be established.\nThe ssh-rsa key fingerprint is 4b595d868720e28de57bef23c90546ad.\n\", \"messages\": [[\"vvvv\", \"local domain socket does not exist, starting it\"], [\"vvvv\", \"control socket path is /home/SaiAnirudh/.ansible/pc/87fd82198c\"], [\"vvvv\", \"loaded cliconf plugin for network_os vyos\"], [\"log\", \"network_os is set to vyos\"], [\"vvvv\", \"\"]], \"error\": \"paramiko: The authenticity of host '10.X.X.X' can't be established.\nThe ssh-rsa key fingerprint is 4b595d868720e28de57bef23c90546ad.\"}"}

Command used-- ansible-playbook playbook.yml -i hosts --ask-vault-pass

Tried changing host_key_checking = False in Ansible.cfg

Command used-- ansible-playbook playbook.yml -i hosts --ask-vault-pass

===================================================================== playbook.yml

---
-  hosts: all
   gather_facts: false
   roles:
   - backup

===============================================================

Main.yml

C:\Ansible\network\backup\roles\backup\tasks\main.yml

- name: Gather facts (ops)
  vyos_facts: 
    gather_subset: all

- name: execute Vyos run to initiate backup
  vyos_command:
    commands: 
      -  sh configuration commands | no-more 
  register: v_backup

- name: local_action
  local_action:
   module: copy
   dest: "C:/Users/Desktop/KVM/Scripting/Ansible/network/backup/RESULTS/Backup.out"
   content: "{{ v_backup.stdout[0] }}"

===============================================================

Ansible.cfg

[defaults]
host_key_checking = False

===============================================================

Hosts

[all]
10.X.X.X

[all:vars]
ansible_user=
ansible_ssh_pass=
ansible_connection=network_cli
ansible_network_os=vyos

We need the backup of the vyatta devices but getting the following error

Vault password:

PLAY [all] *************************************************************************************************************

TASK [backup : Gather facts (ops)] *************************************************************************************

fatal: [10.X.X.X]: FAILED! => {"msg": " [WARNING] Ansible is being run in a world writable directory (/mnt/c/Users/AnirudhSomanchi/Desktop/KVM/Scripting/Ansible/network/backup), ignoring it as an ansible.cfg source. For more information see https://docs.ansible.com/ansible/devel/reference_appendices/config.html#cfg-in-world-writable-dir\n{\"socket_path\": (https://docs.ansible.com/ansible/devel/reference_appendices/config.html#cfg-in-world-writable-dir/n{/'socket_path/':) \"/home/SaiAnirudh/.ansible/pc/87fd82198c\", \"exception\": \"Traceback (most recent call last):\n File \\"/usr/bin/ansible-connection\\", line 104, in start\n
self.connection._connect()\n File \\"/usr/lib/python2.7/dist-packages/ansible/plugins/connection/network_cli.py\\", line 327, in _connect\n ssh = self.paramiko_conn._connect()\n File \\"/usr/lib/python2.7/dist-packages/ansible/plugins/connection/paramiko_ssh.py\\", line 245, in _connect\n self.ssh = SSH_CONNECTION_CACHE[cache_key] = self._connect_uncached()\n File \\"/usr/lib/python2.7/dist-packages/ansible/plugins/connection/paramiko_ssh.py\\", line 368, in _connect_uncached\n raise AnsibleConnectionFailure(msg)\nAnsibleConnectionFailure: paramiko: The authenticity of host '10.X.X.X' can't be established.\nThe ssh-rsa key fingerprint is 4b595d868720e28de57bef23c90546ad.\n\", \"messages\": [[\"vvvv\", \"local domain socket does not exist, starting it\"], [\"vvvv\", \"control socket path is /home/SaiAnirudh/.ansible/pc/87fd82198c\"], [\"vvvv\", \"loaded cliconf plugin for network_os vyos\"], [\"log\", \"network_os is set to vyos\"], [\"vvvv\", \"\"]], \"error\": \"paramiko: The authenticity of host '10.X.X.X' can't be established.\nThe ssh-rsa key fingerprint is 4b595d868720e28de57bef23c90546ad.\"}"}

PLAY RECAP *************************************************************************************************************

10.X.X.X : ok=0 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0

1
Are you sure the correct ansible.cfg is getting picked up? You can run ansible --version in the same directory as you are running ansible-playbook to checkMatt P
Got it once I gave the defaults in ansible.cfg file it started working. Thank youSai Anirudh
@Sai Anirudh , can you elaborate how you solved thisAbhishek D K

1 Answers

-1
votes
[WARNING] Ansible is in a world writable directory , ignoring it as an ansible.cfg source.

I also got this warning but this won't lead you to the failure of your command execution in ansible. it is just a warning which means you have given full permission(i.e drwxrwxrwx or 777) to your directory which is not secure. you can remove this warning by changing permission with chmod command(like sudo chmod 755).