Welcome Guest, Not a member yet? Create Account  




Ansible network_cli becomes top level connection method for vyos

#1
(This post was last modified: 13/02/2018, 17:26 by ipvsean.)

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

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

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

Code:
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)

Code:
---
- 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: https://github.com/IPvSean/ansible-netwo...ing-course

To read more information on Ansible 2.5 release, check out my blog post here: https://www.ansible.com/blog/coming-soon...nsible-2.5
Reply





Users browsing this thread:
1 Guest(s)