junos_config - Manage configuration on devices running Juniper JUNOS
New in version 2.1.
Synopsis
- This module provides an implementation for working with the active configuration running on Juniper JUNOS devices. It provides a set of arguments for loading configuration, performing rollback operations and zeroing the active configuration on the device.
Requirements (on host that executes module)
- ncclient (>=v0.5.2)
Options
parameter | required | default | choices | comments | |||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
backup (added in 2.2)
| no |
| This argument will cause the module to create a full backup of the current running-config from the remote device before any changes are made. The backup file is written to the backup folder in the playbook root directory. If the directory does not exist, it is created. | ||||||||||||||||||||||||||||||||||||
comment | no | configured by junos_config | The comment argument specifies a text string to be used when committing the configuration. If the confirm argument is set to False, this argument is silently ignored. | ||||||||||||||||||||||||||||||||||||
confirm | no | The confirm argument will configure a time out value for the commit to be confirmed before it is automatically rolled back. If the confirm argument is set to False, this argument is silently ignored. If the value for this argument is set to 0, the commit is confirmed immediately. | |||||||||||||||||||||||||||||||||||||
confirm_commit (added in 2.4)
| no |
| This argument will execute commit operation on remote device. It can be used to confirm a previous commit. | ||||||||||||||||||||||||||||||||||||
lines | no | This argument takes a list of set or delete configuration lines to push into the remote device. Each line must start with either set or delete . This argument is mutually exclusive with the src argument. | |||||||||||||||||||||||||||||||||||||
provider | no | A dict object containing connection details. |
|||||||||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||||||||||
replace | no |
| The replace argument will instruct the remote device to replace the current configuration hierarchy with the one specified in the corresponding hierarchy of the source configuration loaded from this module.Note this argument should be considered deprecated. To achieve the equivalent, set the update argument to replace . This argument will be removed in a future release. The replace and update argument is mutually exclusive. | ||||||||||||||||||||||||||||||||||||
rollback | no | The rollback argument instructs the module to rollback the current configuration to the identifier specified in the argument. If the specified rollback identifier does not exist on the remote device, the module will fail. To rollback to the most recent commit, set the rollback argument to 0. | |||||||||||||||||||||||||||||||||||||
src (added in 2.2)
| no | The src argument provides a path to the configuration file to load into the remote system. The path can either be a full system path to the configuration file if the value starts with / or relative to the root of the implemented role or playbook. This argument is mutually exclusive with the lines argument. | |||||||||||||||||||||||||||||||||||||
src_format (added in 2.2)
| no |
| The src_format argument specifies the format of the configuration found int src. If the src_format argument is not provided, the module will attempt to determine the format of the configuration file specified in src. | ||||||||||||||||||||||||||||||||||||
update (added in 2.3)
| no | merge |
| This argument will decide how to load the configuration data particulary when the candidate configuration and loaded configuration contain conflicting statements. Following are accepted values. merge combines the data in the loaded configuration with the candidate configuration. If statements in the loaded configuration conflict with statements in the candidate configuration, the loaded statements replace the candidate ones. override discards the entire candidate configuration and replaces it with the loaded configuration. replace substitutes each hierarchy level in the loaded configuration for the corresponding level. | |||||||||||||||||||||||||||||||||||
zeroize | no | The zeroize argument is used to completely sanitize the remote device configuration back to initial defaults. This argument will effectively remove all current configuration statements on the remote device. |
Examples
- name: load configure file into device junos_config: src: srx.cfg comment: update config provider: "{{ netconf }}" - name: load configure lines into device junos_config: lines: - set interfaces ge-0/0/1 unit 0 description "Test interface" - set vlans vlan01 description "Test vlan" comment: update config provider: "{{ netconf }}" - name: rollback the configuration to id 10 junos_config: rollback: 10 provider: "{{ netconf }}" - name: zero out the current configuration junos_config: zeroize: yes provider: "{{ netconf }}" - name: confirm a previous commit junos_config: confirm_commit: yes provider: "{{ netconf }}"
Return Values
Common return values are documented here Return Values, the following are the fields unique to this module:
name | description | returned | type | sample |
---|---|---|---|---|
backup_path | The full path to the backup file | when backup is yes | string | /playbooks/ansible/backup/config.2016-07-16@22:28:34 |
Notes
Note
- This module requires the netconf system service be enabled on the remote device being managed.
- Loading JSON-formatted configuration json is supported starting in Junos OS Release 16.1 onwards.
- Tested against vSRX JUNOS version 15.1X49-D15.4, vqfx-10000 JUNOS Version 15.1X53-D60.4.
Status
This module is flagged as preview which means that it is not guaranteed to have a backwards compatible interface.
Maintenance Info
For more information about Red Hat’s this support of this module, please refer to this knowledge base article<https://access.redhat.com/articles/rhel-top-support-policies>
For help in developing on modules, should you be so inclined, please read Community Information & Contributing, Testing Ansible and Developing Modules.
© 2012–2018 Michael DeHaan
© 2018–2019 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/2.4/junos_config_module.html