How it works...

In the previous recipe, we generated different sections of the configuration for Juniper devices such as interfaces, OSPF, MPLS, and BGP. We have used the assemble module in order to group all these sections per each node in a single configuration file. This file is stored in the configs folder for each device.

We use the junos_config module in order to push this configuration file that we have generated to each device in our network inventory. We can use the update parameter in order to control how the configuration that we want to push will be merged with the existing configuration on the device. It supports the following options:

  • merge: This causes the configuration from our file to be merged with the configuration on the device (the candidate configuration). This option is the default option that is used.
  • Override/update: This causes the configuration from our file to override the complete configuration on the managed device.

We can use the check mode to run our playbook in dry-run mode. In this case, we will push the configuration to the devices without committing to the configuration. This enables us to check the changes that will be pushed to the devices. This can be accomplished as follows:

$ Ansible-playbook pb_jnpr_net_build.yml -l mxpe01 --check –diff

We use the –check option to run the playbook in check mode (dry-run), and the –diff option in order to output the changes that will be pushed to our devices.