Closed neilhwatson closed 7 years ago
Can you attempt running the following?
python -c 'import paramiko; from paramiko.ssh_exception import AuthenticationException;'
Also, as something I notice, it appears as though you are running the vyos_command
module against 192.168.1.1
without specifying local_action
or delegate_to: localhost
. As such, you would need to have paramiko
installed on 192.168.1.1
$ python -c 'import paramiko; from paramiko.ssh_exception import AuthenticationException;'
$ echo $?
0
You've lost me on the delegate_to attribute. The remote host is a vyos powered device and I do not wish to install custom software on it.
The way that ansible typically works, is that it builds out a python file that is then ships to the remote device where it is executed.
Currently with your provided playbook, you are targeting hosts: ubt
. ubt
seems to correlate to 192.168.1.1
which I am assuming is the vyos device. So currently it is trying to run python code on 192.168.1.1
which does not have paramiko installed.
Instead, your playbook should try 1 of a few things:
connection: local
at the play level, where remote_user
is specified, so that the vyos_command
module would be executed on the machine running ansible, instead of being copied to 192.168.1.1
.delegate_to: localhost
on each task, to say that the module should be executed locally, rather than on 192.168.1.1
I tried both but I get this error:
fatal: [192.168.1.1]: FAILED! =>
{"changed": false, "failed": true, "msg": "failed to connect to 192.168.1.1:22"}
Yet, ssh works:
$ !ssh
ssh 192.168.1.1
Welcome to EdgeOS
By logging in, accessing, or using the Ubiquiti product, you
acknowledge that you have read and understood the Ubiquiti
License Agreement (available in the Web UI at, by default,
http://192.168.1.1) and agree to be bound by its terms.
Enter passphrase for key '/home/neil/.ssh/id_rsa':
X11 forwarding request failed on channel 0
Linux ubnt 3.10.14-UBNT #1 SMP Fri Jan 29 20:03:40 PST 2016 mips
Welcome to EdgeOS
Last login: Wed Dec 7 14:42:25 2016 from 192.168.1.2
neil@ubnt:~$
playbook:
---
- hosts: ubt
vars:
cli:
host: 192.168.1.1
username: neil
transport: cli
tasks:
- name: Run test command and exit
connection: local
vyos_command:
commands:
- show version
provider: "{{ cli }}"
I believe that is a symptom of not providing the path to the SSH key that you need to use. The network modules do not utilize your ssh_config
, so all credentials need to be supplied. Additionally, since the network modules are utilizing paramiko for SSH, you will need to supply a password for your key file, since it appears to require a passphrase.
It may be useful to read over the Intro Networking document at https://docs.ansible.com/ansible/intro_networking.html
Too bad the network modules are so different. It reduced adoption of them, by making commands tasks the path of least resistance. Thanks for your insights.
ISSUE TYPE
COMPONENT NAME
vyos_command and vyos_config
ANSIBLE VERSION
Other info
CONFIGURATION
No changes
OS / ENVIRONMENT
Debian testing (stretch/sid)
SUMMARY
Attempts to run modules result a false error about the paramiko module not being installed.
STEPS TO REPRODUCE
EXPECTED RESULTS
The remote command show version should have been run and the output displayed.
ACTUAL RESULTS
The remote command did not run and ansible reported an error