Specify the connect fo the host as below:
ansible_connection: network_cli

https://docs.ansible.com/ansible/latest/plugins/connection/network_cli.html


On Monday, August 12, 2019 at 3:30:46 AM UTC-4, Ganesh Nalawade wrote:
>
>
> The module seems to use paramiko_ssh 
> <https://github.com/CaptTofu/comware_5_2/blob/master/comware_5_2.py#L93> 
> to connect to the remote host.
> Try changing the inventory entry as below since the module is expected to 
> run on the control node.
>
> [switch1]
> 192.168.xx.xx ansible_connection=local
>
> OR
>
> [switch1]
> localhost
>
> Also, this seems to be a very old module and not using the Ansible 
> persistent connection framework.
> You can add Ansible cliconf and terminal plugins for the network os to 
> make it work with connection=network_cli 
> <https://github.com/ansible/community/blob/master/group-network/network_dev_network_cli.rst>
> After adding the required plugins you use cli_command  
> <https://docs.ansible.com/ansible/latest/modules/cli_command_module.html>and 
> cli_config 
> <https://docs.ansible.com/ansible/latest/modules/cli_config_module.html> 
> modules 
> to manage the remote host.
>
> On Friday, 9 August 2019 19:11:17 UTC+5:30, Ugo Bellavance wrote:
>>
>> Hi,
>>
>> I'm new to Ansible.  I wanted to manage my network devices with Ansible 
>> so I did this:
>>
>>    - Found this documentation: 
>>    http://patg.net/ansible,comware,switches/2014/10/16/ansible-comware/
>>    - Created an account on my switch, tested that it can login via SSH 
>>    (password only, haven't configured an SSH key yet)
>>    - Installed ansible (from EPEL), on RHEL7 (see below for version 
>>    details)
>>    - Cloned the comware 5.2 module in $HOME/.ansible/plugins/modules (git 
>>    clone https://github.com/CaptTofu/comware_5_2.git)
>>    - Cloned the Github project to get playbook examples (git clone 
>>    https://github.com/CaptTofu/comware_5_2_playbooks.git)
>>    - Created an inventory file (see below)
>>    - Created a playbook (see below)
>>    - Ran ansible-playbook (ansible-playbook -i switch1 -u ansiblehpe 
>>    --ask-pass playbook1.yml)
>>    - Got this error message
>>       - fatal: [192.168.xx.xx]: FAILED! => {"msg": "module (setup) is 
>>       missing interpreter line"}
>>    - So I though I would add the shebang with the path of the python 
>>    interpeter on my server running ansible in the setup.py file
>>       - Got these errors: 
>>       -  [WARNING]: Unhandled error in Python interpreter discovery for 
>>          host 192.168.99.41: Failed to connect to the host via ssh:
>>          -  [WARNING]: sftp transfer mechanism failed on 
>>          [192.168.99.41]. Use ANSIBLE_DEBUG=1 to see detailed information
>>          -  [WARNING]: scp transfer mechanism failed on [192.168.99.41]. 
>>          Use ANSIBLE_DEBUG=1 to see detailed information
>>       - I realized ansible wanted to discover where could python be on 
>>    the remote target, but there isn't any interpreter there, it's a network 
>>    switch...
>>    - I set an empty shebang in the setup.py file and got this error
>>       - An exception occurred during task execution. To see the full 
>>       traceback, use -vvv. The error was: IndexError: list index out of range
>>       fatal: [192.168.99.41]: FAILED! => {"msg": "Unexpected failure 
>>       during module execution.", "stdout": ""}
>>    
>> How do I tell ansible that there isn't any interpreter on the target?
>>
>> Any help would be appreciated.
>> Thanks in advance.
>>
>> $ ansible --version
>> ansible 2.8.2
>>   config file = /etc/ansible/ansible.cfg
>>   configured module search path = 
>> [u'/home/ubellavance/.ansible/plugins/modules', 
>> u'/usr/share/ansible/plugins/modules']
>>   ansible python module location = 
>> /usr/lib/python2.7/site-packages/ansible
>>   executable location = /usr/bin/ansible
>>   python version = 2.7.5 (default, Jun 11 2019, 12:19:05) [GCC 4.8.5 
>> 20150623 (Red Hat 4.8.5-36)]
>>
>> Inventory file:
>>
>> [switch1]
>> 192.168.xx.xx
>>
>> [switch1:vars]
>> switch_host=192.168.xx.xx
>> switch_user=xxxxxxxx
>> switch_password=xxxxxxxx
>>
>> Playbook:
>>
>> - hosts: switch1
>>   tasks:
>>   - name: gather facts from switch
>>     comware_5_2:
>>       gather_facts=true
>>       host={{ switch_host }}
>>       username={{ switch_user }}
>>       password={{ switch_password }}
>>
>

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/b55e08b4-bd49-42b8-ad7e-0346aa439dd0%40googlegroups.com.

Reply via email to