Ansible network_cli becomes top level connection method for vyos

With Ansible playbooks for networking platforms, historically most of the networking modules require a provider argument per task (which supplied the connection type, username, password, etc).

With Ansible 2.5 (which you can install now, via the latest dev release) allows connection: network_cli as a top level connection which is supported by all the all the major networking vendors including vyos. The deprecation for provider won’t begin with Ansible 2.5, and will take considerable time, so there will not be any rush to update playbooks.

The network_cli connection plugins will allow playbooks to look, feel and operate just like they do on Linux hosts. Also the error reporting is significantly improved, which will help a lot of people who were frustrated with changes to Ansible in 2.3.

Here is a quick example of doing configuration backup with vyos

- hosts: network
  connection: network_cli
  tasks:
    - vyos_config:
        backup: yes

To run the playbook above (which I tested with vagrant), I did this->

ansible-playbook backup.yml -u vagrant -k

Here is a quick configuration example of doing fact gathering on vyos (keep in mind you can also do fact gathering on the linux OS itself with the setup module (default fact gathering for *nix hosts), since vyos is a bit different from other networking platforms as it runs on top of linux)

- hosts: network
  connection: network_cli
  tasks:
    - name: gather facts for vyos
      vyos_facts:
        gather_subset: all
      register: vyos_debug

    - name: look at config
      debug: var=vyos_debug

To view more examples, check out my github repo here: ansible-networking-vagrant-demo/training-course at master · IPvSean/ansible-networking-vagrant-demo · GitHub

To read more information on Ansible 2.5 release, check out my blog post here: Coming Soon: Networking Features in Ansible 2.5

1 Like

Very nice! I use Ansible and I am just starting to use VyOS. What did you use to make this diagram? https://github.com/tracphil/ansible-networking-vagrant-demo/blob/master/images/diagram.png

I am spoiled and I sent off a diagram I made in Google slides to a graphics person who usually works in Adobe illustrator. Although I am trying to make sure all the icons are for use for everyone: GitHub - network-automation/networking-icons: Repo containing various networking icons including routers, switches, servers, firewalls, load balancers and more. Icons are provided in png and svg formats.

1 Like

Thanks for sharing that!
Definitely good work.

1 Like

Has something changed since your original post?

I am using vyos-1.2.0-rc10 and ansible-2.7.5 versions.

ansible-playbook backup.yml -u adminuser -k -i network.inventory

PLAY [network] *****************************************************************

TASK [Gathering Facts] *********************************************************
ok: [vyos]

TASK [vyos_config] *************************************************************
fatal: [vyos]: FAILED! => {“msg”: “Could not find imported module support code for vyos_config. Looked for either NetworkError.py or vyos.py”}
to retry, use: --limit @/Users/david/projects/summersoft-network/backup.retry

PLAY RECAP *********************************************************************
vyos : ok=1 changed=0 unreachable=0 failed=1

Any suggestions?

Thanks.