Hi Ajay,

I managed to fix my script as below:
---
- name: show version
  hosts: "switches"
  gather_facts: false
  connection: local

  vars:
    backup_root: /etc/ansible/backups
    cli:
      host: "{{ inventory_hostname }}"
      username: msawires
      password: Irukandji.=

  tasks:
    - name: GATHERING INFO
      ios_command:
        commands:
         - command: sh run | i hostname
         - command: sh ip int brief | i 10.11.64
         - command: sh ver | i Model Number|System Serial
        provider: "{{ cli }}"
      register: config

    - copy:
        content: "{{ config.stdout[0] }}"
        dest: "{{ backup_root }}/{{ inventory_hostname }}/running-config_{{ timestamp.stdout }}"
...

My problem now is I can save only first command, cannot save the other two in file, do you have any suggestion how to save all commands output in one file?

Thank you,
Michael

From: Ajay Kumar Manukonda
Sent: Friday, 10 August 2018 10:23 AM
To: [EMAIL PROTECTED]
Subject: Re: [ansible-project] Re: cannot login to cisco switch using ansible

At this point, I am almost out of ideas. I am sorry, I couldn't be of much help.

One last thing you might want to try is turning of "gathering facts". Some devices have issues with that. You can do that by entering "gathering = explicit" in the ansible.cfg file.

Regards,
Ajay

On Thu, Aug 9, 2018 at 5:04 PM Michael Ikram <[EMAIL PROTECTED]> wrote:
 
Hi Ajay,
 
I tried with -k, it does not work
 
netadmin@netadmin-Virtual-Machine:/etc/ansible$ ansible-playbook ios.yml -k
SSH password:
 
PLAY [10.11.32.100] ********************************************************************************************************************************************************************************
 
TASK [Gathering Facts] *****************************************************************************************************************************************************************************
[WARNING]: sftp transfer mechanism failed on [10.11.32.100]. Use ANSIBLE_DEBUG=1 to see detailed information
[WARNING]: scp transfer mechanism failed on [10.11.32.100]. Use ANSIBLE_DEBUG=1 to see detailed information
fatal: [10.11.32.100]: UNREACHABLE! => {"changed": false, "msg": "SSH Error: data could not be sent to remote host \"10.11.32.100\". Make sure this host can be reached over ssh", "unreachable": true}
[WARNING]: Could not create retry file '/etc/ansible/ios.retry'.         [Errno 13] Permission denied: u'/etc/ansible/ios.retry'
 
PLAY RECAP *****************************************************************************************************************************************************************************************
10.11.32.100               : ok=0    changed=0    unreachable=1    failed=0  
 
 
 
Here is the output of -vvv
 
 
netadmin@netadmin-Virtual-Machine:/etc/ansible$ ansible-playbook ios.yml -vvv
ansible-playbook 2.5.7
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/home/netadmin/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/lib/python2.7/dist-packages/ansible
  executable location = /usr/bin/ansible-playbook
  python version = 2.7.15rc1 (default, Apr 15 2018, 21:51:34) [GCC 7.3.0]
Using /etc/ansible/ansible.cfg as config file
Parsed /etc/ansible/hosts inventory source with ini plugin
 
PLAYBOOK: ios.yml **********************************************************************************************************************************************************************************
1 plays in ios.yml
 
PLAY [10.11.32.100] ********************************************************************************************************************************************************************************
 
TASK [Gathering Facts] *****************************************************************************************************************************************************************************
task path: /etc/ansible/ios.yml:2
Using module file /usr/lib/python2.7/dist-packages/ansible/modules/system/setup.py
<10.11.32.100> ESTABLISH SSH CONNECTION FOR USER: 60081064
<10.11.32.100> SSH: EXEC ssh -C -o ControlMaster=auto -o ControlPersist=60s -o KbdInteractiveAuthentication=no -o PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o PasswordAuthentication=no -o User=60081064 -o ConnectTimeout=10 -o ControlPath=/home/netadmin/.ansible/cp/e0e6fa081f 10.11.32.100 '/bin/sh -c '"'"'echo ~60081064 && sleep 0'"'"''
<10.11.32.100> (255, '', '[EMAIL PROTECTED]: Permission denied (publickey,keyboard-interactive,password).\r\n')
fatal: [10.11.32.100]: UNREACHABLE! => {
    "changed": false,
    "msg": "Failed to connect to the host via ssh: [EMAIL PROTECTED]: Permission denied (publickey,keyboard-interactive,password).\r\n",
    "unreachable": true
}
[WARNING]: Could not create retry file '/etc/ansible/ios.retry'.         [Errno 13] Permission denied: u'/etc/ansible/ios.retry'
 
PLAY RECAP *****************************************************************************************************************************************************************************************
10.11.32.100               : ok=0    changed=0    unreachable=1    failed=0  
 
netadmin@netadmin-Virtual-Machine:/etc/ansible$
 
Sent from Mail for Windows 10
 
From: Ajay Kumar Manukonda
Sent: Friday, 10 August 2018 9:59 AM
To: [EMAIL PROTECTED]
Subject: Re: [ansible-project] Re: cannot login to cisco switch using ansible
 
Hi Michael,
 
"ansble all -m ping , it gives the same error  Permission denied (publickey,keyboard-interactive,password)"  doesn't work because ansible ping module requires the remote node to run python. You can find more about it here: https://docs.ansible.com/ansible/latest/modules/ping_module.html#ping-module
 
So, it works for your username, and based on "Failed to connect to the host via ssh: [EMAIL PROTECTED]