O'Reilly logo

JUNOS Automation Cookbook by Adam Chappell

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How to do it...

We're going to update our inventory list to add a custom variable to each host record which defines its hardware type, and then we're going to run a playbook that selectively adds some firewall configuration, based on the value of this variable.

  1. Modify our inventory file in order to collect together all of the common variables under one INI-style group called [JUNOS-devices:vars].
      [JUNOS-devices:vars]      ansible_user=auto      ansible_ssh_private_key_file=/home/user/auto/JUNOS_auto_id_rsa      ansible_connection=local
  1. Then define the JUNOS devices themselves with the variables that actually vary per-host.
      [JUNOS-devices]      JUNOS1 ansible_host=10.0.201.201 hardware=vm      JUNOS2 ansible_host=10.0.201.202 hardware=mx960-mpc JUNOS3 ansible_host=10.0.201.203 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required