junipernetworks.junos.junos_config – Manage configuration on devices running Juniper JUNOS
Note
This plugin is part of the junipernetworks.junos collection (version 2.8.0).
You might already have this collection installed if you are using the ansible
package.
It is not included in ansible-core
.
To check whether it is installed, run ansible-galaxy collection list
.
To install it, use: ansible-galaxy collection install junipernetworks.junos
.
To use it in a playbook, specify: junipernetworks.junos.junos_config
.
New in version 1.0.0: of junipernetworks.junos
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.
Note
This module has a corresponding action plugin.
Requirements
The below requirements are needed on the host that executes this module.
ncclient (>=v0.5.2)
Parameters
Parameter |
Comments |
---|---|
This argument will cause the module to create a full backup of the current Choices:
|
|
This is a dict object containing configurable options related to backup file path. The value of this option is read only when |
|
This argument specifies the format of the configuration the backup file will be stored as. If the argument is not specified, the module will use the ‘set’ format. Choices:
|
|
This option provides the path ending with directory name in which the backup configuration file will be stored. If the directory does not exist it will be first created and the filename is either the value of |
|
The filename to be used to store the backup configuration. If the filename is not given it will be generated based on the hostname, current time and date in format defined by <hostname>_config.<current-date>@<current-time> |
|
This argument will check correctness of syntax; do not apply changes. Note that this argument can be used to confirm verified configuration done via commit confirmed operation Choices:
|
|
The Default: “configured by junos_config” |
|
The Default: 0 |
|
This argument will execute commit operation on remote device. It can be used to confirm a previous commit. Choices:
|
|
This argument takes a list of |
|
Deprecated Starting with Ansible 2.5 we recommend using For more information please see the Junos OS Platform Options guide. A dict object containing connection details. |
|
Specifies the DNS host name or address for connecting to the remote device over the specified transport. The value of host is used as the destination address for the transport. |
|
Specifies the password to use to authenticate the connection to the remote device. This value is used to authenticate the SSH session. If the value is not specified in the task, the value of environment variable |
|
Specifies the port to use when building the connection to the remote device. The port value will default to the well known SSH port of 22 (for |
|
Specifies the SSH key to use to authenticate the connection to the remote device. This value is the path to the key used to authenticate the SSH session. If the value is not specified in the task, the value of environment variable |
|
Specifies the timeout in seconds for communicating with the network device for either connecting or sending commands. If the timeout is exceeded before the operation is completed, the module will error. |
|
Configures the transport connection to use when connecting to the remote device. Choices:
|
|
Configures the username to use to authenticate the connection to the remote device. This value is used to authenticate the SSH session. If the value is not specified in the task, the value of environment variable |
|
The Note this argument should be considered deprecated. To achieve the equivalent, set the update argument to Choices:
|
|
The |
|
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. |
|
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. Choices:
|
|
This argument will decide how to load the configuration data particularly when the candidate configuration and loaded configuration contain conflicting statements. Following are accepted values. Choices:
|
|
The Choices:
|
Notes
Note
This module requires the netconf system service be enabled on the remote device being managed.
Abbreviated commands are NOT idempotent, see L(Network FAQ,../network/user_guide/faq.html
Loading JSON-formatted configuration json is supported starting in Junos OS Release 16.1 onwards.
Update
override
not currently compatible withset
notation.Tested against vSRX JUNOS version 15.1X49-D15.4, vqfx-10000 JUNOS Version 15.1X53-D60.4.
Recommended connection is
netconf
. See the Junos OS Platform Options.This module also works with
local
connections for legacy playbooks.For information on using CLI and netconf see the Junos OS Platform Options guide
For more information on using Ansible to manage network devices see the Ansible Network Guide
For more information on using Ansible to manage Juniper network devices see https://www.ansible.com/ansible-juniper.
Examples
- name: load configure file into device
junipernetworks.junos.junos_config:
src: srx.cfg
comment: update config
- name: load configure lines into device
junipernetworks.junos.junos_config:
lines:
- set interfaces ge-0/0/1 unit 0 description "Test interface"
- set vlans vlan01 description "Test vlan"
comment: update config
- name: Set routed VLAN interface (RVI) IPv4 address
junipernetworks.junos.junos_config:
lines:
- set vlans vlan01 vlan-id 1
- set interfaces irb unit 10 family inet address 10.0.0.1/24
- set vlans vlan01 l3-interface irb.10
- name: Check correctness of commit configuration
junipernetworks.junos.junos_config:
check_commit: yes
- name: rollback the configuration to id 10
junipernetworks.junos.junos_config:
rollback: 10
- name: zero out the current configuration
junipernetworks.junos.junos_config:
zeroize: yes
- name: Set VLAN access and trunking
junipernetworks.junos.junos_config:
lines:
- set vlans vlan02 vlan-id 6
- set interfaces ge-0/0/6.0 family ethernet-switching interface-mode access vlan
members vlan02
- set interfaces ge-0/0/6.0 family ethernet-switching interface-mode trunk vlan
members vlan02
- name: confirm a previous commit
junipernetworks.junos.junos_config:
confirm_commit: yes
- name: for idempotency, use full-form commands
junipernetworks.junos.junos_config:
lines:
# - set int ge-0/0/1 unit 0 desc "Test interface"
- set interfaces ge-0/0/1 unit 0 description "Test interface"
- name: configurable backup path
junipernetworks.junos.junos_config:
src: srx.cfg
backup: yes
backup_options:
filename: backup.cfg
dir_path: /home/user
Return Values
Common return values are documented here, the following are the fields unique to this module:
Key |
Description |
---|---|
The full path to the backup file Returned: when backup is yes Sample: “/playbooks/ansible/backup/config.2016-07-16@22:28:34” |
|
The date extracted from the backup file name Returned: when backup is yes Sample: “2016-07-16” |
|
The name of the backup file Returned: when backup is yes and filename is not specified in backup options Sample: “junos01_config.2016-07-16@22:28:34” |
|
The full path to the backup file excluding the timestamp Returned: when backup is yes and filename is not specified in backup options Sample: “/playbooks/ansible/backup/junos01_config” |
|
The time extracted from the backup file name Returned: when backup is yes Sample: “22:28:34” |
Authors
Peter Sprygada (@privateip)