There's more...

The junos_config module also supports the rollback feature supported by Junos OS, therefore we can add another task to roll back the configuration and control how it is run, as follows:

$ cat pb_jnpr_net_build.yml

<-- Output Trimmed for brevity ------>

- name: "Rollback config"
junos_config:
rollback: "{{ rollback | default('1') | int }}"
tags: rollback, never

In the preceding playbook, we roll back to the last version of the configuration. However, by changing the number in the rollback attribute, we can control the version of the configuration to which we want to roll back. Also, we are using the tags in order to only execute this task when we specify the rollback tag during the playbook run, as shown in the following code snippet:

$ Ansible-playbook pb_jnpr_net_build.yml --tags rollback -l mxpe01

We can specify another rollback point, as follows:

$ Ansible-playbook pb_jnpr_net_build.yml --tags rollback -l mxpe01 –e rollback=2