Install juniper/pyez-ansible Docker image
Main page: 1- Ansible
https://hub.docker.com/r/juniper/pyez-ansible/
Configuration on the Device | vMX config for ansible + Netconfig
|
Local netconfig Test: | |
Remote netconfig test | ssh ansible@192.168.56.11 -p 830 -s netconf |
Install Docker | |
---|---|
Start by clicking on the docker icon ( windows ) | |
search for available container | docker search juniper |
pull the image ( optional) |
|
Check Ansible roles | |
|
ansible-galaxy list -p roles |
Create Ansible files and playbooks | |
Create an directory ( on the windows host ) + | mkdir facts_playbookscd facts_playbook/ |
and create the hosts | vi hosts |
and create playbook.yml | vi pbk_getfacts.yml new module /project # more pbk_getfacts.yml --- - name: Get facts hosts: All-srx connection: local gather_facts: no roles: - Juniper.junos tasks: - name: Get junos facts juniper_junos_facts: host: "{{ inventory_hostname }}" user: "Netbox" passwd: "Netbox" register: junos - name: Print facts debug: var: junos vi playbook.yml with OLD module |
Start and log back in : RUN & EXEC | |
Start the container: |
-it
|
log back in the container ( exec <container> ) | docker ps docker exec -it funny_kirch ash /playbooks # cd /project/ |
| |
basic playbook | |
Basic test with hosts & playbook.yml file: | cd project
|
Check connectivity | |
Basic check netconfig | ansible-playbook -i hosts chk_netconf.yml -k -u Netbox |
Basic jsnapy | |
check jsnapy | pip3 install -U jsnapy jsnapy --version |
default jsnapy folder | ls /etc/jsnapy/ -al more /etc/jsnapy/jsnapy.cfg more /etc/jsnapy/logging.yml |
config file | |
test file | |
Basic jsnapy command | |
config file | /project # more /project/jsnapy-demo/configfiles/config1.yml config file --- hosts: - device: 172.30.95.177 username : Netbox passwd: Netbox tests: - /project/jsnapy-demo/testfiles/show_bgp_summary.yml |
test file | /project # vi /project/jsnapy-demo/testfiles/show_bgp_summary.yml check bgp neigbor /project # vi /project/jsnapy-demo/testfiles/show_bgp_summary.yml tests_include: - test_command_bgp # - test_rpc_bgp test_command_bgp: - command: show bgp neighbor - iterate: xpath: '/bgp-information/bgp-peer' tests: - contains: peer-address, 192.168.100.2 # element in which test is performed err: "Test Failed!! peer-address got changed, it is now <{{post['peer-address']}}>" info: "Test succeeded!! peer-address is equal to <{{post['peer-address']}}>" - in-range: peer-as, 65100,65200 # element in which test is performed err: "Test Failed!! peer-as is not in range of 100-200, it is: <{{post['peer-as']}}>" info: "Test succeeded!! peer-as is in range of 100-200, it is now <{{post['peer-as']}}>" |
run jsnapy | jsnapy --snapcheck pre -f jsnapy-demo/configfiles/config1.yml |
snapshot output file | sudo apt-get install libxml2-utils xmllint --format ~/jsnapy/snapshots/172.30.95.177_pre_show_bgp_neighbor.xml |
snapshot database |