W3cubDocs

/Ansible

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)

  • junos-eznc

Options

parameter required default choices comments
backup
(added in 2.2)
no
  • yes
  • 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.
host
yes
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.
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.
password
no
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 ANSIBLE_NET_PASSWORD will be used instead.
port
no 22
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 transport=cli) or port 830 (for transport=netconf) device.
provider
no
Convenience method that allows all ios arguments to be passed as a dict object. All constraints (required, choices, etc) must be met either by individual arguments or values in this dict.
replace
no
  • yes
  • 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.
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
  • xml
  • set
  • text
  • json
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.
ssh_keyfile
no
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 ANSIBLE_NET_SSH_KEYFILE will be used instead.
username
no
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 ANSIBLE_NET_USERNAME will be used instead.
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

# Note: examples below use the following provider dict to handle
#       transport and authentication to the node.
vars:
  netconf:
    host: "{{ inventory_hostname }}"
    username: ansible
    password: Ansible

- name: load configure file into device
  junos_config:
    src: srx.cfg
    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:
    provider: "{{ netconf }}"

Return Values

Common return values are documented here Common 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 path [email protected]:28:34

Notes

Note

This module requires the netconf system service be enabled on the remote device being managed.

This is a Core Module

For more information on what this means please read Core Modules

For help in developing on modules, should you be so inclined, please read Community Information & Contributing, developing_test_pr and Developing Modules.

© 2012–2016 Michael DeHaan
© 2016 Red Hat, Inc.
Licensed under the GNU General Public License version 3.
https://docs.ansible.com/ansible/junos_config_module.html