vyos_config question

424 views
Skip to first unread message

Carl Betts

unread,
Nov 8, 2016, 8:18:39 AM11/8/16
to Ansible Project
Have been trying to get the vyos_config module to work (https://docs.ansible.com/ansible/vyos_config_module.html).

However always getting this error: fatal: [localhost]: FAILED! => {"changed": false, "commands": ["show configuration commands"], "failed": true, "msg": "timeout trying to send command: show configuration commands\r"}

Playbook looks like this
---
 - hosts: localhost
   connection: local
   vars:
       cli:
           host: 111.111.111.111
           username: vyos
           password: vyos
           transport: cli
   tasks:
     - name: configure the remote device
       vyos_config:
         lines:
         - set service snmp community testing authorization ro
         provider: "{{ cli }}"


I searched for more examples on vyos_config but couldn't find anything. Does any one have experience with vies_config?

Thanks,
Carl

Carl Betts

unread,
Nov 17, 2016, 10:17:23 AM11/17/16
to Ansible Project
Just to update this. When it ssh's in from the playbook it appears to only run this command.

1001     10471 10449  0 15:16 pts/1    00:00:00 -vbash

1001     10472 10449  1 15:16 pts/1    00:00:00 less --buffers=64 --auto-buffers --no-lessopen --QUIT-AT-EOF --quit-if-one-screen --RAW-CONTROL-CHARS --squeeze-blank-lines --no-init

1001     10473 10471 95 15:16 pts/1    00:00:00 cli-shell-api showConfig --show-active-only --show-commands


The cli-shell-api command does print the output when run manually.

Alexander H. Laughlin

unread,
Nov 18, 2016, 10:08:07 PM11/18/16
to Ansible Project

    - name: Configure remote device.

      vyos_config:

       lines:

         - set service snmp community testing authorization ro

       provider: "{{ cli }}"



This works exactly as intended when I try it running Ansible 2.2 from a CentOS control machine to a VyOS 1.1.17 node that was installed with the live cd downloaded from the VyOS website on to a Debian Jessie VM running in VirtualBox. 

It's not clear from your post, but are you running ansible on the VyOS machine itself?  It seems like that's the case since the connection is being set to local and the hosts lists is localhost.  If that is the case, while I am far too ignorant to know exactly *why* it wouldn't work, it *feels* like something that would be dodgy at best if not explicitly prohibited.  Possibly because VyOS is based on mostly deprecated by this point packages on a distribution (Debian Squeeze) that is known for being rock solid stable but extremely slow to release software updates.

Is there a reason that you'd be running Ansible locally as opposed to from a control machine?  If so, would you be so kind as to let us know what version of Ansible you're running along with the full output of the current VyOS config ('show configuration')?

Thanks!

Carl Betts

unread,
Nov 21, 2016, 5:34:27 PM11/21/16
to Ansible Project
Thanks for the reply. I am running Ansible 2.2 from an Ubuntu machine. Maybe I am just not understanding the vyos_config correctly.

If I change the localhost (ubuntu machine) to the hostname of the vyos machine I get this error:
"msg": "paramiko is required but does not appear to be installed.  It can be installed using  `pip install paramiko`

I assumed it had to be run with localhost so the vyos_config parameters would be the remote hostname/ip of the vyos machine.

Could you post your playbook that you used that worked for you?

Thank you.

Alexander H. Laughlin

unread,
Nov 21, 2016, 11:40:08 PM11/21/16
to Ansible Project
You're quite welcome.  You have run into an error which I also had while setting up vms I used to test this for you.

The playbook in its entirety is pasted below:

---

- name: Testing vyos module.

 hosts: vyos

  tasks:

   - include_vars: var.yml

   - name: Try vyos module.

     vyos_command:

       commands:

         - show version

         - show hardware cpu

         - show interfaces

        provider: "{{ cli }}"

   - name: Configure remote device.

      vyos_config:

       lines:

         - set service snmp community testing authorization ro

       provider: "{{ cli }}"

     register: result

   - name: Output result.

     debug:

       msg: "The result is: {{ result }}"

...

# vim: set ft=ansible:


I moved the contents of {{ cli }} to a vars file as you can see with the include. But none of this helps you very much. You'll be much more interested in my other discoveries, the most important of which is that paramiko is not missing from the control machine, but from the VyOS machine. 

And. . . Getting it installed is kind of a pain. The FAQ has some useful information under the usage heading: http://wiki.vyos.net/wiki/FAQ#How_do_I_upgrade_my_installation.3F.  But, for the sake of brevity and saving you the trouble of having to do all the trial and error and documentation searching I did, here is a rough guide for the process:

[user@control-machine:~] cd /tmp
[user@control-machine:tmp] wget https://bootstrap.pypa.io/get-pip.py
[user@control-machine:tmp] scp /tmp/get-pip.py vyos@vyos:/tmp
[user@control-machine:tmp] ssh vyos@vyos
vyos@vyos:~$ cd /
tmp
vyos@vyos
:/tmp$ sudo python get-pip.py
vyos@vyos:/
tmp$ configure
vyos@vyos
#
set system package repository squeeze components 'main contrib non-free'
vyos@vyos# set system package repository squeeze distribution 'squeeze'

vyos@vyos# set system package repository squeeze url 'http://archive.debian.org/debian'

vyos@vyos# set system package repository squeeze-lts components 'main contrib non-free'
vyos@vyos
#
set system package repository squeeze-lts distribution 'squeeze-lts'
vyos@vyos
#
set system package repository squeeze-lts url 'http://archive.debian.org/debian'
vyos@vyos
# commit; save; exit
vyos@vyos
:/tmp$
sudo apt-get -o Acquire::Check-Valid-Until=false update
vyos@vyos:/tmp$ sudo apt-get -y install python-paramiko

If you're fortunate enough to have that last one be successful, you'll find yourself with either a working vyos_config module, or a new error.  In either case, congratulations!

Best of luck.

Alex
Reply all
Reply to author
Forward
0 new messages