Re: [ansible-project] Re: cannot login to cisco switch using ansible

2018-08-16 Thread Ajay Kumar Manukonda
Hi Michael,

I am glad you found a solution. I see that you are only taking the output
of stdout[0] under copy task. Since your config will have the output of
multiple commands you might need config.stdout[1] and config.stdout[2] as
well.

You can use something like the following to capture all your output in one
file,

   - copy:
   content: "{{ config.stdout[0] }}"
   dest: "*your destination*"
   - blockinfile: |
   dest: "*your destination*"
   content= "{{ config.stdout[1] }}"
   - blockinfile: |
   dest: "*your destination*"
   content="{{ output.stdout[2] }}"

There might be a more efficient and better solution than this, but this is
what I found so far.

Regards,
Ajay


On Tue, Aug 14, 2018 at 7:13 PM Michael Ikram 
wrote:

> 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: *ansible-project@googlegroups.com
> *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 
> 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=0changed=0unreachable=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/

RE: [ansible-project] Re: cannot login to cisco switch using ansible

2018-08-14 Thread Michael Ikram
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: ansible-project@googlegroups.com
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  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, '', '60081064@10.11.32.100: Permission denied 
(publickey,keyboard-interactive,password).\r\n')
fatal: [10.11.32.100]: UNREACHABLE! => 

Re: [ansible-project] Re: cannot login to cisco switch using ansible

2018-08-09 Thread Michael Sawires
reate retry file '/etc/ansible/ios.retry'.
>> [Errno 13] Permission denied: u'/etc/ansible/ios.retry'
>>
>>
>>
>> PLAY RECAP
>> *
>>
>> 10.11.32.100   : ok=0changed=0unreachable=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, '', '60081064@10.11.32.100: 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: 60081064@10.11.32.100:
>> 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=0changed=0unreachable=1
>> failed=0
>>
>>
>>
>> netadmin@netadmin-Virtual-Machine:/etc/ansible$
>>
>>
>>
>> Sent from Mail <https://go.microsoft.com/fwlink/?LinkId=550986> for
>> Windows 10
>>
>>
>>
>> *From: *Ajay Kumar Manukonda 
>> *Sent: *Friday, 10 August 2018 9:59 AM
>> *To: *ansible-project@googlegroups.com
>> *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: 60081064@10.11.32.100 <60081064@10.11.32.100>: Permission
&

Re: [ansible-project] Re: cannot login to cisco switch using ansible

2018-08-09 Thread Ajay Kumar Manukonda
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  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=0changed=0unreachable=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, '', '60081064@10.11.32.100: 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: 60081064@10.11.32.100:
> 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
> *

RE: [ansible-project] Re: cannot login to cisco switch using ansible

2018-08-09 Thread Michael Ikram

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=0changed=0unreachable=1failed=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, '', '60081064@10.11.32.100: 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: 60081064@10.11.32.100: 
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=1failed=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: ansible-project@googlegroups.com
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: 60081064@10.11.32.100: Permission denied 
(publickey,keyboard-interactive,password)" ansible is using the correct 
username. Where are you defining your 

RE: [ansible-project] Re: cannot login to cisco switch using ansible

2018-08-09 Thread Michael Ikram
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=0changed=0unreachable=1failed=0   




Here is the output of -vvv



Sent from Mail for Windows 10

From: Ajay Kumar Manukonda
Sent: Friday, 10 August 2018 9:59 AM
To: ansible-project@googlegroups.com
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: 60081064@10.11.32.100: Permission denied 
(publickey,keyboard-interactive,password)" ansible is using the correct 
username. Where are you defining your password? In the hosts file? If that is 
the case, hash the password in the hosts file and use -k option instead ( 
ansible-playbook ios.yml -k ) and enter the password manually just to eliminate 
one source of the problem.

If that doesn't work, revert the changes and get the output of 
"ansible-playbook ios.yml - " command. It could help us find the source of 
the issue.

Regards,
Ajay

On Thu, Aug 9, 2018 at 1:35 PM Michael Sawires  wrote:
Hi Ajay,

If username is 60081064, it works, if root, it does not.

Thanks,
Michael 

On Fri, 10 Aug 2018 at 4:41 am, Ajay Kumar Manukonda 
 wrote:
Hi Michael,

By looking at this error : "msg": "Failed to connect to the host via ssh: 
60081064@10.11.32.100: Permission denied 
(publickey,keyboard-interactive,password).\r\n", "unreachable": true it seems 
like your ansible VM can not SSH to the cisco switch in the first place.

Does normal SSH to the switch work? like if you do ssh username@10.11.32.100 . 
If it doesn't work, you have to fix that first. Maybe the switch is allowing 
connections only from particular IP addresses.

Regards,
Ajay



On Thu, Aug 9, 2018 at 8:02 AM Michael Sawires  wrote:
Hi Ajay,

I was able to build a new machine, still having same issue ansible & ssh 
permission issue:

netadmin@netadmin-Virtual-Machine:/etc/ansible/myplatform$ ansible --version
ansible 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
  python version = 2.7.15rc1 (default, Apr 15 2018, 21:51:34) [GCC 7.3.0]
netadmin@netadmin-Virtual-Machine:/etc/ansible/myplatform$ ls
ios.retry  ios.yml
netadmin@netadmin-Virtual-Machine:/etc/ansible/myplatform$ ansible --version
ansible 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
  python version = 2.7.15rc1 (default, Apr 15 2018, 21:51:34) [GCC 7.3.0]
netadmin@netadmin-Virtual-Machine:/etc/ansible/myplatform$ ansible-playbook 
ios.yml

PLAY [10.11.32.100] 
***

TASK [Gathering Facts] 

Re: [ansible-project] Re: cannot login to cisco switch using ansible

2018-08-09 Thread Ajay Kumar Manukonda
   : ok=0changed=0unreachable=1
>>> failed=0
>>>
>>> netadmin@netadmin-Virtual-Machine:/etc/ansible/myplatform$ cat ios.yml
>>> ---
>>> - hosts: 10.11.32.100
>>>   user: 60081064
>>>
>>>   tasks:
>>> - name: show version
>>>   ios_command:
>>> commands: show version
>>> ...
>>>
>>> also when I try: ansble all -m ping , it gives the same error
>>> Permission denied (publickey,keyboard-interactive,password).\
>>>
>>> On Fri, Aug 10, 2018 at 12:44 AM Ajay Kumar Manukonda <
>>> ajaykumarmanuko...@gmail.com> wrote:
>>>
>>>> Hi Michael,
>>>>
>>>> I don't know any straight forward fix.
>>>>
>>>> So, did chmod 700 on /etc/ansible work? Is the playbook still giving
>>>> the same error after the file permissions were changed?
>>>>
>>>> Regards,
>>>> Ajay
>>>>
>>>> On Wed, Aug 8, 2018, 8:48 PM Michael Ikram 
>>>> wrote:
>>>>
>>>>> I was able to fix the permission on Ubuntu, now back to the original
>>>>> error:
>>>>>
>>>>>
>>>>>
>>>>> ansible all -i , -c network_cli -u -m
>>>>> ios_command_1.yml
>>>>>
>>>>> [WARNING] Ansible is in a world writable directory (/etc/ansible),
>>>>> ignoring it as an ansible.cfg source.
>>>>>
>>>>> 10.11.32.100 | FAILED! => {
>>>>>
>>>>> "msg": " [WARNING] Ansible is in a world writable directory
>>>>> (/etc/ansible), ignoring it as an ansible.cfg source.\n{\"socket_path\":
>>>>> \"/home/test/.ansible/pc/c5b7c67eba\", \"exception\": \"Traceback (most
>>>>> recent call last):\\n  File \\\"/usr/bin/ansible-connection\\\", line 87,
>>>>> in start\\nself.connection._connect()\\n  File
>>>>> \\\"/usr/lib/python2.7/dist-packages/ansible/plugins/connection/network_cli.py\\\",
>>>>> line 302, in _connect\\nself._ssh_shell =
>>>>> ssh.ssh.invoke_shell()\\nNameError: global name 'ssh' is not defined\\n\",
>>>>> \"messages\": [\"local domain socket does not exist, starting it\",
>>>>> \"control socket path is /home/test/.ansible/pc/c5b7c67eba\", \"\"],
>>>>> \"error\": \"global name 'ssh' is not defined\"}"
>>>>>
>>>>> }
>>>>>
>>>>>
>>>>>
>>>>> Do you know any straight forward fix?
>>>>>
>>>>>
>>>>>
>>>>> Thanks,
>>>>>
>>>>> Michael
>>>>>
>>>>>
>>>>>
>>>>> *From: *Michael Ikram 
>>>>> *Sent: *Thursday, 9 August 2018 10:24 AM
>>>>> *To: *ansible-project@googlegroups.com
>>>>> *Subject: *RE: [ansible-project] Re: cannot login to cisco switch
>>>>> using ansible
>>>>>
>>>>>
>>>>>
>>>>> Hi Ajay,
>>>>>
>>>>>
>>>>>
>>>>>- Tried to chmod 700, it gave me the following error
>>>>>
>>>>>
>>>>>
>>>>> test@TESTVM:/etc$ sudo chmod 700 /etc/ansible
>>>>>
>>>>> sudo: /etc/sudoers is world writable
>>>>>
>>>>> sudo: no valid sudoers sources found, quitting
>>>>>
>>>>> sudo: unable to initialize policy plugin
>>>>>
>>>>>
>>>>>
>>>>>- I think I have bigger issue than Ansible now, it is a permission
>>>>>issue on Ubuntu box, any suggestions?
>>>>>
>>>>> Thanks,
>>>>>
>>>>> Michael
>>>>>
>>>>>
>>>>>
>>>>> *From: *Ajay 
>>>>> *Sent: *Thursday, 9 August 2018 10:13 AM
>>>>> *To: *Ansible Project 
>>>>> *Subject: *Re: [ansible-project] Re: cannot login to cisco switch
>>>>> using ansible
>>>>>
>>>>>
>>>>>
>>>>> First of all, try executing this command: "chmod 700 /etc/ansible" and
>>>>> run the playboo

Re: [ansible-project] Re: cannot login to cisco switch using ansible

2018-08-09 Thread Michael Sawires
s in a world writable directory (/etc/ansible),
>>>> ignoring it as an ansible.cfg source.
>>>>
>>>> 10.11.32.100 | FAILED! => {
>>>>
>>>> "msg": " [WARNING] Ansible is in a world writable directory
>>>> (/etc/ansible), ignoring it as an ansible.cfg source.\n{\"socket_path\":
>>>> \"/home/test/.ansible/pc/c5b7c67eba\", \"exception\": \"Traceback (most
>>>> recent call last):\\n  File \\\"/usr/bin/ansible-connection\\\", line 87,
>>>> in start\\nself.connection._connect()\\n  File
>>>> \\\"/usr/lib/python2.7/dist-packages/ansible/plugins/connection/network_cli.py\\\",
>>>> line 302, in _connect\\nself._ssh_shell =
>>>> ssh.ssh.invoke_shell()\\nNameError: global name 'ssh' is not defined\\n\",
>>>> \"messages\": [\"local domain socket does not exist, starting it\",
>>>> \"control socket path is /home/test/.ansible/pc/c5b7c67eba\", \"\"],
>>>> \"error\": \"global name 'ssh' is not defined\"}"
>>>>
>>>> }
>>>>
>>>>
>>>>
>>>> Do you know any straight forward fix?
>>>>
>>>>
>>>>
>>>> Thanks,
>>>>
>>>> Michael
>>>>
>>>>
>>>>
>>>> *From: *Michael Ikram 
>>>> *Sent: *Thursday, 9 August 2018 10:24 AM
>>>> *To: *ansible-project@googlegroups.com
>>>> *Subject: *RE: [ansible-project] Re: cannot login to cisco switch
>>>> using ansible
>>>>
>>>>
>>>>
>>>> Hi Ajay,
>>>>
>>>>
>>>>
>>>>- Tried to chmod 700, it gave me the following error
>>>>
>>>>
>>>>
>>>> test@TESTVM:/etc$ sudo chmod 700 /etc/ansible
>>>>
>>>> sudo: /etc/sudoers is world writable
>>>>
>>>> sudo: no valid sudoers sources found, quitting
>>>>
>>>> sudo: unable to initialize policy plugin
>>>>
>>>>
>>>>
>>>>- I think I have bigger issue than Ansible now, it is a permission
>>>>issue on Ubuntu box, any suggestions?
>>>>
>>>> Thanks,
>>>>
>>>> Michael
>>>>
>>>>
>>>>
>>>> *From: *Ajay 
>>>> *Sent: *Thursday, 9 August 2018 10:13 AM
>>>> *To: *Ansible Project 
>>>> *Subject: *Re: [ansible-project] Re: cannot login to cisco switch
>>>> using ansible
>>>>
>>>>
>>>>
>>>> First of all, try executing this command: "chmod 700 /etc/ansible" and
>>>> run the playbook again (since you are using network_cli as connection type,
>>>> I assume you also defined ansible_network_os as ios)
>>>>
>>>>
>>>>
>>>> Suggestions:
>>>>
>>>> 1. Don't use the default ansible.cfg file, it's too big to track all
>>>> the changes we made
>>>>
>>>> 2. "https://docs.ansible.com/ansible/latest/network/index.html"; is a
>>>> good place to start if you haven't checked already
>>>>
>>>>
>>>>
>>>> *"I think I have a problem with ssh but i do not understand how to fix
>>>> it" - *Can you directly ssh to the device from the VM you are using?
>>>>
>>>>
>>>>
>>>> Let me know if that works.
>>>>
>>>>
>>>>
>>>> Regards,
>>>>
>>>> Ajay
>>>>
>>>> On Wednesday, August 8, 2018 at 3:24:21 PM UTC-7, Michael Sawires wrote:
>>>>
>>>> I cannot understand what to do from the link you sent me, I am still
>>>> new in Ansible.
>>>>
>>>>
>>>>
>>>> Here is the permission and content of ansible.cfg file
>>>>
>>>>
>>>>
>>>> 1.Permission:
>>>>
>>>> ==
>>>>
>>>> -r-xrwxrwx 1 root root 19573 Aug  9 00:52 ansible.cfg
>>>>
>>>> -r-xrwxrwx 1 root root   251 Aug  8 12:15 ios_facts.yml
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> 2.Content
>>>>
>>>> 
>>>>
>>>> 2.1. ansible.cfg
>>&

Re: [ansible-project] Re: cannot login to cisco switch using ansible

2018-08-09 Thread Ajay Kumar Manukonda
ython2.7/dist-packages/ansible/plugins/connection/network_cli.py\\\",
>>> line 302, in _connect\\nself._ssh_shell =
>>> ssh.ssh.invoke_shell()\\nNameError: global name 'ssh' is not defined\\n\",
>>> \"messages\": [\"local domain socket does not exist, starting it\",
>>> \"control socket path is /home/test/.ansible/pc/c5b7c67eba\", \"\"],
>>> \"error\": \"global name 'ssh' is not defined\"}"
>>>
>>> }
>>>
>>>
>>>
>>> Do you know any straight forward fix?
>>>
>>>
>>>
>>> Thanks,
>>>
>>> Michael
>>>
>>>
>>>
>>> *From: *Michael Ikram 
>>> *Sent: *Thursday, 9 August 2018 10:24 AM
>>> *To: *ansible-project@googlegroups.com
>>> *Subject: *RE: [ansible-project] Re: cannot login to cisco switch using
>>> ansible
>>>
>>>
>>>
>>> Hi Ajay,
>>>
>>>
>>>
>>>- Tried to chmod 700, it gave me the following error
>>>
>>>
>>>
>>> test@TESTVM:/etc$ sudo chmod 700 /etc/ansible
>>>
>>> sudo: /etc/sudoers is world writable
>>>
>>> sudo: no valid sudoers sources found, quitting
>>>
>>> sudo: unable to initialize policy plugin
>>>
>>>
>>>
>>>- I think I have bigger issue than Ansible now, it is a permission
>>>issue on Ubuntu box, any suggestions?
>>>
>>> Thanks,
>>>
>>> Michael
>>>
>>>
>>>
>>> *From: *Ajay 
>>> *Sent: *Thursday, 9 August 2018 10:13 AM
>>> *To: *Ansible Project 
>>> *Subject: *Re: [ansible-project] Re: cannot login to cisco switch using
>>> ansible
>>>
>>>
>>>
>>> First of all, try executing this command: "chmod 700 /etc/ansible" and
>>> run the playbook again (since you are using network_cli as connection type,
>>> I assume you also defined ansible_network_os as ios)
>>>
>>>
>>>
>>> Suggestions:
>>>
>>> 1. Don't use the default ansible.cfg file, it's too big to track all the
>>> changes we made
>>>
>>> 2. "https://docs.ansible.com/ansible/latest/network/index.html"; is a
>>> good place to start if you haven't checked already
>>>
>>>
>>>
>>> *"I think I have a problem with ssh but i do not understand how to fix
>>> it" - *Can you directly ssh to the device from the VM you are using?
>>>
>>>
>>>
>>> Let me know if that works.
>>>
>>>
>>>
>>> Regards,
>>>
>>> Ajay
>>>
>>> On Wednesday, August 8, 2018 at 3:24:21 PM UTC-7, Michael Sawires wrote:
>>>
>>> I cannot understand what to do from the link you sent me, I am still new
>>> in Ansible.
>>>
>>>
>>>
>>> Here is the permission and content of ansible.cfg file
>>>
>>>
>>>
>>> 1.Permission:
>>>
>>> ==
>>>
>>> -r-xrwxrwx 1 root root 19573 Aug  9 00:52 ansible.cfg
>>>
>>> -r-xrwxrwx 1 root root   251 Aug  8 12:15 ios_facts.yml
>>>
>>>
>>>
>>>
>>>
>>> 2.Content
>>>
>>> 
>>>
>>> 2.1. ansible.cfg
>>>
>>> 
>>>
>>> test@TESTVM:/etc/ansible$ cat ansible.cfg
>>>
>>> # config file for ansible -- https://ansible.com/
>>>
>>> # ===
>>>
>>>
>>>
>>> # nearly all parameters can be overridden in ansible-playbook
>>>
>>> # or with command line flags. ansible will read ANSIBLE_CONFIG,
>>>
>>> # ansible.cfg in the current working directory, .ansible.cfg in
>>>
>>> # the home directory or /etc/ansible/ansible.cfg, whichever it
>>>
>>> # finds first
>>>
>>>
>>>
>>> [defaults]
>>>
>>> host_key_checking = false
>>>
>>>
>>>
>>> # some basic default values...
>>>
>>>
>>>
>>> #inventory  = /etc/ansible/hosts
>>>
>>> #library= /usr/share/my_modules/
>>>
>>> #module_utils   = /usr/share/my_module_utils/
>>>
>>> #remote_tmp = ~/.ansible/tmp
>>&g

Re: [ansible-project] Re: cannot login to cisco switch using ansible

2018-08-09 Thread Michael Sawires
Hi Ajay,

I was able to build a new machine, still having same issue ansible & ssh
permission issue:

netadmin@netadmin-Virtual-Machine:/etc/ansible/myplatform$ ansible --version
ansible 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
  python version = 2.7.15rc1 (default, Apr 15 2018, 21:51:34) [GCC 7.3.0]
netadmin@netadmin-Virtual-Machine:/etc/ansible/myplatform$ ls
ios.retry  ios.yml
netadmin@netadmin-Virtual-Machine:/etc/ansible/myplatform$ ansible --version
ansible 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
  python version = 2.7.15rc1 (default, Apr 15 2018, 21:51:34) [GCC 7.3.0]
netadmin@netadmin-Virtual-Machine:/etc/ansible/myplatform$ ansible-playbook
ios.yml

PLAY [10.11.32.100]
***

TASK [Gathering Facts]

fatal: [10.11.32.100]: UNREACHABLE! => {"changed": false, "msg": "Failed to
connect to the host via ssh: 60081064@10.11.32.100: Permission denied
(publickey,keyboard-interactive,password).\r\n", "unreachable": true}
 [WARNING]: Could not create retry file
'/etc/ansible/myplatform/ios.retry'. [Errno 13] Permission denied:
u'/etc/ansible/myplatform/ios.retry'

PLAY RECAP

10.11.32.100   : ok=0changed=0unreachable=1
failed=0

netadmin@netadmin-Virtual-Machine:/etc/ansible/myplatform$ cat ios.yml
---
- hosts: 10.11.32.100
  user: 60081064

  tasks:
- name: show version
  ios_command:
commands: show version
...

also when I try: ansble all -m ping , it gives the same error  Permission
denied (publickey,keyboard-interactive,password).\

On Fri, Aug 10, 2018 at 12:44 AM Ajay Kumar Manukonda <
ajaykumarmanuko...@gmail.com> wrote:

> Hi Michael,
>
> I don't know any straight forward fix.
>
> So, did chmod 700 on /etc/ansible work? Is the playbook still giving the
> same error after the file permissions were changed?
>
> Regards,
> Ajay
>
> On Wed, Aug 8, 2018, 8:48 PM Michael Ikram  wrote:
>
>> I was able to fix the permission on Ubuntu, now back to the original
>> error:
>>
>>
>>
>> ansible all -i , -c network_cli -u -m
>> ios_command_1.yml
>>
>> [WARNING] Ansible is in a world writable directory (/etc/ansible),
>> ignoring it as an ansible.cfg source.
>>
>> 10.11.32.100 | FAILED! => {
>>
>> "msg": " [WARNING] Ansible is in a world writable directory
>> (/etc/ansible), ignoring it as an ansible.cfg source.\n{\"socket_path\":
>> \"/home/test/.ansible/pc/c5b7c67eba\", \"exception\": \"Traceback (most
>> recent call last):\\n  File \\\"/usr/bin/ansible-connection\\\", line 87,
>> in start\\nself.connection._connect()\\n  File
>> \\\"/usr/lib/python2.7/dist-packages/ansible/plugins/connection/network_cli.py\\\",
>> line 302, in _connect\\nself._ssh_shell =
>> ssh.ssh.invoke_shell()\\nNameError: global name 'ssh' is not defined\\n\",
>> \"messages\": [\"local domain socket does not exist, starting it\",
>> \"control socket path is /home/test/.ansible/pc/c5b7c67eba\", \"\"],
>> \"error\": \"global name 'ssh' is not defined\"}"
>>
>> }
>>
>>
>>
>> Do you know any straight forward fix?
>>
>>
>>
>> Thanks,
>>
>> Michael
>>
>>
>>
>> *From: *Michael Ikram 
>> *Sent: *Thursday, 9 August 2018 10:24 AM
>> *To: *ansible-project@googlegroups.com
>> *Subject: *RE: [ansible-project] Re: cannot login to cisco switch using
>> ansible
>>
>>
>>
>> Hi Ajay,
>>
>>
>>
>>- Tried to chmod 700, it gave me the following err

Re: [ansible-project] Re: cannot login to cisco switch using ansible

2018-08-09 Thread Ajay Kumar Manukonda
Hi Michael,

I don't know any straight forward fix.

So, did chmod 700 on /etc/ansible work? Is the playbook still giving the
same error after the file permissions were changed?

Regards,
Ajay

On Wed, Aug 8, 2018, 8:48 PM Michael Ikram  wrote:

> I was able to fix the permission on Ubuntu, now back to the original error:
>
>
>
> ansible all -i , -c network_cli -u -m
> ios_command_1.yml
>
> [WARNING] Ansible is in a world writable directory (/etc/ansible),
> ignoring it as an ansible.cfg source.
>
> 10.11.32.100 | FAILED! => {
>
> "msg": " [WARNING] Ansible is in a world writable directory
> (/etc/ansible), ignoring it as an ansible.cfg source.\n{\"socket_path\":
> \"/home/test/.ansible/pc/c5b7c67eba\", \"exception\": \"Traceback (most
> recent call last):\\n  File \\\"/usr/bin/ansible-connection\\\", line 87,
> in start\\nself.connection._connect()\\n  File
> \\\"/usr/lib/python2.7/dist-packages/ansible/plugins/connection/network_cli.py\\\",
> line 302, in _connect\\nself._ssh_shell =
> ssh.ssh.invoke_shell()\\nNameError: global name 'ssh' is not defined\\n\",
> \"messages\": [\"local domain socket does not exist, starting it\",
> \"control socket path is /home/test/.ansible/pc/c5b7c67eba\", \"\"],
> \"error\": \"global name 'ssh' is not defined\"}"
>
> }
>
>
>
> Do you know any straight forward fix?
>
>
>
> Thanks,
>
> Michael
>
>
>
> *From: *Michael Ikram 
> *Sent: *Thursday, 9 August 2018 10:24 AM
> *To: *ansible-project@googlegroups.com
> *Subject: *RE: [ansible-project] Re: cannot login to cisco switch using
> ansible
>
>
>
> Hi Ajay,
>
>
>
>- Tried to chmod 700, it gave me the following error
>
>
>
> test@TESTVM:/etc$ sudo chmod 700 /etc/ansible
>
> sudo: /etc/sudoers is world writable
>
> sudo: no valid sudoers sources found, quitting
>
> sudo: unable to initialize policy plugin
>
>
>
>- I think I have bigger issue than Ansible now, it is a permission
>issue on Ubuntu box, any suggestions?
>
> Thanks,
>
> Michael
>
>
>
> *From: *Ajay 
> *Sent: *Thursday, 9 August 2018 10:13 AM
> *To: *Ansible Project 
> *Subject: *Re: [ansible-project] Re: cannot login to cisco switch using
> ansible
>
>
>
> First of all, try executing this command: "chmod 700 /etc/ansible" and run
> the playbook again (since you are using network_cli as connection type, I
> assume you also defined ansible_network_os as ios)
>
>
>
> Suggestions:
>
> 1. Don't use the default ansible.cfg file, it's too big to track all the
> changes we made
>
> 2. "https://docs.ansible.com/ansible/latest/network/index.html"; is a good
> place to start if you haven't checked already
>
>
>
> *"I think I have a problem with ssh but i do not understand how to fix it"
> - *Can you directly ssh to the device from the VM you are using?
>
>
>
> Let me know if that works.
>
>
>
> Regards,
>
> Ajay
>
> On Wednesday, August 8, 2018 at 3:24:21 PM UTC-7, Michael Sawires wrote:
>
> I cannot understand what to do from the link you sent me, I am still new
> in Ansible.
>
>
>
> Here is the permission and content of ansible.cfg file
>
>
>
> 1.Permission:
>
> ==
>
> -r-xrwxrwx 1 root root 19573 Aug  9 00:52 ansible.cfg
>
> -r-xrwxrwx 1 root root   251 Aug  8 12:15 ios_facts.yml
>
>
>
>
>
> 2.Content
>
> 
>
> 2.1. ansible.cfg
>
> 
>
> test@TESTVM:/etc/ansible$ cat ansible.cfg
>
> # config file for ansible -- https://ansible.com/
>
> # ===
>
>
>
> # nearly all parameters can be overridden in ansible-playbook
>
> # or with command line flags. ansible will read ANSIBLE_CONFIG,
>
> # ansible.cfg in the current working directory, .ansible.cfg in
>
> # the home directory or /etc/ansible/ansible.cfg, whichever it
>
> # finds first
>
>
>
> [defaults]
>
> host_key_checking = false
>
>
>
> # some basic default values...
>
>
>
> #inventory  = /etc/ansible/hosts
>
> #library= /usr/share/my_modules/
>
> #module_utils   = /usr/share/my_module_utils/
>
> #remote_tmp = ~/.ansible/tmp
>
> #local_tmp  = ~/.ansible/tmp
>
> #plugin_filters_cfg = /etc/ansible/plugin_filters.yml
>
> #forks  = 5
>
> #poll_interval  = 15
>
> #sudo_user  = root
>
> #ask_sudo_pass = True
>
> #ask_pass  =

RE: [ansible-project] Re: cannot login to cisco switch using ansible

2018-08-08 Thread Michael Ikram
I was able to fix the permission on Ubuntu, now back to the original error:

ansible all -i , -c network_cli -u -m ios_command_1.yml
 [WARNING] Ansible is in a world writable directory (/etc/ansible), ignoring it 
as an ansible.cfg source.
10.11.32.100 | FAILED! => {
"msg": " [WARNING] Ansible is in a world writable directory (/etc/ansible), 
ignoring it as an ansible.cfg source.\n{\"socket_path\": 
\"/home/test/.ansible/pc/c5b7c67eba\", \"exception\": \"Traceback (most recent 
call last):\\n  File \\\"/usr/bin/ansible-connection\\\", line 87, in start\\n  
  self.connection._connect()\\n  File 
\\\"/usr/lib/python2.7/dist-packages/ansible/plugins/connection/network_cli.py\\\",
 line 302, in _connect\\nself._ssh_shell = 
ssh.ssh.invoke_shell()\\nNameError: global name 'ssh' is not defined\\n\", 
\"messages\": [\"local domain socket does not exist, starting it\", \"control 
socket path is /home/test/.ansible/pc/c5b7c67eba\", \"\"], \"error\": \"global 
name 'ssh' is not defined\"}"
}

Do you know any straight forward fix?

Thanks,
Michael

From: Michael Ikram
Sent: Thursday, 9 August 2018 10:24 AM
To: ansible-project@googlegroups.com
Subject: RE: [ansible-project] Re: cannot login to cisco switch using ansible

Hi Ajay,

- Tried to chmod 700, it gave me the following error

test@TESTVM:/etc$ sudo chmod 700 /etc/ansible
sudo: /etc/sudoers is world writable
sudo: no valid sudoers sources found, quitting
sudo: unable to initialize policy plugin

- I think I have bigger issue than Ansible now, it is a permission issue on 
Ubuntu box, any suggestions?
Thanks,
Michael

From: Ajay
Sent: Thursday, 9 August 2018 10:13 AM
To: Ansible Project
Subject: Re: [ansible-project] Re: cannot login to cisco switch using ansible

First of all, try executing this command: "chmod 700 /etc/ansible" and run the 
playbook again (since you are using network_cli as connection type, I assume 
you also defined ansible_network_os as ios)

Suggestions:
1. Don't use the default ansible.cfg file, it's too big to track all the 
changes we made
2. "https://docs.ansible.com/ansible/latest/network/index.html"; is a good place 
to start if you haven't checked already

"I think I have a problem with ssh but i do not understand how to fix it" - Can 
you directly ssh to the device from the VM you are using?

Let me know if that works.

Regards,
Ajay

On Wednesday, August 8, 2018 at 3:24:21 PM UTC-7, Michael Sawires wrote:
I cannot understand what to do from the link you sent me, I am still new in 
Ansible.

Here is the permission and content of ansible.cfg file

1.Permission:
==
-r-xrwxrwx 1 root root 19573 Aug  9 00:52 ansible.cfg
-r-xrwxrwx 1 root root   251 Aug  8 12:15 ios_facts.yml


2.Content

2.1. ansible.cfg

test@TESTVM:/etc/ansible$ cat ansible.cfg
# config file for ansible -- https://ansible.com/
# ===

# nearly all parameters can be overridden in ansible-playbook
# or with command line flags. ansible will read ANSIBLE_CONFIG,
# ansible.cfg in the current working directory, .ansible.cfg in
# the home directory or /etc/ansible/ansible.cfg, whichever it
# finds first

[defaults]
host_key_checking = false

# some basic default values...

#inventory      = /etc/ansible/hosts
#library        = /usr/share/my_modules/
#module_utils   = /usr/share/my_module_utils/
#remote_tmp     = ~/.ansible/tmp
#local_tmp      = ~/.ansible/tmp
#plugin_filters_cfg = /etc/ansible/plugin_filters.yml
#forks          = 5
#poll_interval  = 15
#sudo_user      = root
#ask_sudo_pass = True
#ask_pass      = True
#transport      = smart
#remote_port    = 22
#module_lang    = C
#module_set_locale = False

# plays will gather facts by default, which contain information about
# the remote system.
#
# smart - gather by default, but don't reg

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/5b6bb990.1c69fb81.eaa12.efee%40mx.google.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Re: cannot login to cisco switch using ansible

2018-08-08 Thread Ajay
This might solve your 
issue: 
https://medium.com/@andrewhowdencom/the-curious-case-of-sudden-ansible-build-failures-eef1cf9ad1d0

If it doesn't, can you also post the file permissions and content of 
ansible.cfg and ios_facts.yml?

Regards,
Ajay

On Wednesday, August 8, 2018 at 8:32:19 AM UTC-7, Michael Sawires wrote:
>
> test@TESTVM:/etc/ansible$ ansible-playbook ios_facts.yml 
>  [WARNING] Ansible is in a world writable directory (/etc/ansible), 
> ignoring it as an ansible.cfg source.
>
> PLAY [Collect IOS Device Facts] 
> 
>
> TASK [Gathering Facts] 
> *
> fatal: [10.208.0.17]: FAILED! => {"msg": " [WARNING] Ansible is in a world 
> writable directory (/etc/ansible), ignoring it as an ansible.cfg 
> source.\n{\"socket_path\": \"/home/test/.ansible/pc/12ac842f48\", 
> \"exception\": \"Traceback (most recent call last):\\n  File 
> \\\"/usr/bin/ansible-connection\\\", line 87, in start\\n
> self.connection._connect()\\n  File 
> \\\"/usr/lib/python2.7/dist-packages/ansible/plugins/connection/network_cli.py\\\",
>  
> line 302, in _connect\\nself._ssh_shell = 
> ssh.ssh.invoke_shell()\\nNameError: global name 'ssh' is not defined\\n\", 
> \"messages\": [\"local domain socket does not exist, starting it\", 
> \"control socket path is /home/test/.ansible/pc/12ac842f48\", \"\"], 
> \"error\": \"global name 'ssh' is not defined\"}"}
> to retry, use: --limit @/etc/ansible/ios_facts.retry
>
> PLAY RECAP 
> *
> 10.208.0.17: ok=0changed=0unreachable=0
> failed=1   
>
> test@TESTVM:/etc/ansible$
>

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/460f28a4-dcca-448e-9036-a550ccae46c9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.