Running arbitrary commands on Juniper devices
In this recipe, you will execute operational commands on Juniper devices. Although we just explored executing RPCs, which are similar, the goal of this section is to execute show commands and use the output to validate the state of the devices.
- Create a new playbook called
pb_get_ospf.ymland populate it to execute theshow ospf neighborcommand and store the output in a variable:root@cookbook-lab:~/cookbook-lab/chapters/ch05# vi pb_get_ospf.yml --- - name: “Collect and Validate OSPF” hosts: “juniper_crpd” tasks: - name: “Collect OSPF Neighbors” junipernetworks.junos.junos_command: commands: show ospf neighbor | display json (1) ...