-
Notifications
You must be signed in to change notification settings - Fork 4
06. junos_jsnapy ansible module
You can execute JSNAPy tests from Ansible with the Ansible module junos_jsnapy.
It is hosted on the Ansible Galaxy website (https://galaxy.ansible.com/Juniper/junos/).
Documentation: http://junos-ansible-modules.readthedocs.io/
Source code: https://github.com/Juniper/ansible-junos-stdlib
Requirements on the devices: Netconf
Requirements on the server: Install PyEZ, JSNAPy, jxmlease python libraries. Install ansible.
junos_jsnapy module installation:
sudo ansible-galaxy install Juniper.junos
Network Automation using Ansible & JSNAPy: https://www.youtube.com/watch?v=lv7lh3kwKns
You can use this module with or without jsnapy configuration files (i.e you can skip the jsnapy configuration file and use only a jsnapy test file)
The playbook is pb.jsnapy.yml at the root of the repository. I did not hardcode the jsnapy configuration file name, it is a variable. I did not define the value of this variable:
$ ansible-playbook pb.jsnapy.yml --extra-vars jsnapy_conf_file=/etc/jsnapy/cfg_file_snapcheck_cfg.yml
$ ansible-playbook pb.jsnapy.yml --extra-vars jsnapy_conf_file=/etc/jsnapy/cfg_file_snapcheck_bgp_states.yml
$ ansible-playbook pb.jsnapy.yml --extra-vars jsnapy_conf_file=/etc/jsnapy/cfg_file_snapcheck_lldp_cfg.yml
$ ansible-playbook pb.jsnapy.yml --extra-vars jsnapy_conf_file=/etc/jsnapy/cfg_file_snapcheck_alarms.yml
The playbook is pb.jsnapy.test_file_only.yml at the root of the repository.
$ ansible-playbook pb.jsnapy.test_file_only.yml
The playbook is pb.jsnapy.snap.snap.check.yml at the root of the repository.
$ ansible-playbook pb.jsnapy.snap.snap.check.yml
- Use jinja2 templates to create a testfile template
- Define variables in YAML:
- device specific variables (host_vars)
- group specific variables (group_vars)
- Generate testfiles based on the Jinja2 template and variables substitutions (using the Ansible template module)
- Refer to the rendered template in the test_files parameter of junos_jsnapy module