Cant SSH / PING to Network Devices

I am a Newbie to Ansible , writing my first playbook.

I can not SSH / PING to network Devices.

`
leaf-1 | UNREACHABLE! => {
“changed”: false,
“msg”: “Authentication failure.”,
“unreachable”: true
}
leaf-2 | UNREACHABLE! => {
“changed”: false,
“msg”: “Authentication failure.”,
“unreachable”: true
}

i can PING / SSH to network devices from Ansible server but when i run the playbook , it fails.

No idea if i have to add something in playbook or ansible.cfg . Any Suggestion please ?

`

can you ssh without ansible into those hosts?

yes i can SSH from Ansible Server , via putty as well

show how you you ssh in with ansible and without ansible. Your plsybook and cfg file.

`
ansible.cfg :

[defaults]
inventory = ./inventories/

`

`
Inventories :

[leaf]

leaf-1
leaf-2

`

playbook :

- hosts: all
  remote_user: admin
  vars:
    authorized_key_list:
      - name: admin
        authorized_keys:
         - key: "{{ lookup('file', '~/.ssh/id_rsa.pub') }}"
           state: present
  roles:
    - { role: GROG.authorized-key }

First make sure ansible can actually sign in to the target hosts before trying to use roles. I’m guessing here but that role name indicates something related which might impact the connection.

So best to start here:

https://docs.ansible.com/ansible/latest/user_guide/intro_getting_started.html#connecting-to-remote-nodes

And then try something simple such as the a file or copy task.
Once that works move on to more complicated things like roles.

Dick

[root@ansible01 test]# ping leaf-1 PING leaf-1.lab.com (192.168.7.1) 56(84) bytes of data. 64 bytes from testing_1F.lab.com (192.168.7.1): icmp_seq=1 ttl=253 time=0.701 ms 64 bytes from testing_1F.lab.com (192.168.7.1): icmp_seq=2 ttl=253 time=0.623 ms 64 bytes from testing_1F.lab.com (192.168.7.1): icmp_seq=3 ttl=253 time=0.736 ms

[root@ansible01 test]# ansible leaf-1 -m ping /usr/lib/python2.7/site-packages/requests/__init__.py:80: RequestsDependencyWarning: urllib3 (1.22) or chardet (2.2.1) doesn't match a supported version! RequestsDependencyWarning) leaf-1 | UNREACHABLE! => { "changed": false, "msg": "Failed to connect to the host via ssh:

on more thing : i have logged in to ansible server as “root” but my username to log in to network device is “admin” … do i have to define that somewhere ?

on more thing : i have logged in to ansible server as "root" but my username to log in to network device is "admin" ...
do i have to define that somewhere ?

Use the ansible_user variable.

Further information:
https://docs.ansible.com/ansible/latest/user_guide/intro_inventory.html#connecting-to-hosts-behavioral-inventory-parameters

Regards
         Racke

i added below in INVENTORY file … no luck …

leaf-1 ansible_ssh_pass=XXXXX ansible_ssh_user=XXXX

Thanks
NIrmal