Documentation

junos_template - Manage configuration on remote devices running Juniper JUNOS

New in version 2.1.

DEPRECATED

Deprecated in 2.2. Use junos_config instead.

Synopsis

  • This module will load a candidate configuration from a template file onto a remote device running Junos. The module will return the differences in configuration if the diff option is specified on the Ansible command line

Options

parameter required default choices comments
action
(added in 2.2)
no merge
  • merge
  • overwrite
  • replace
The action argument specifies how the module will apply changes.
backup
no
  • true
  • false
When this argument is configured true, the module will backup the configuration from the node prior to making any changes. The backup file will be written to backup_{{ hostname }} in the root of the playbook directory.
comment
no configured by junos_template
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.
config_format
no
  • text
  • xml
  • set
The format argument specifies the format of the configuration template specified in src. If the format argument is not specified, the module will attempt to infer the configuration format based of file extension. Files that end in xml will set the format to xml. Files that end in set will set the format to set and all other files will default the format to text.
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.
provider
no
A dict object containing connection details.
Dictionary object provider
parameter required default choices comments
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.
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.
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.
timeout
no 10
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.
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.
src
yes
The path to the config source. The source can be either a file with config or a template that will be merged during runtime. By default the task will search for the source file in role or playbook root folder in templates directory.

Examples

- junos_template:
    src: config.j2
    comment: update system config

- name: replace config hierarchy
  junos_template:
    src: config.j2
    action: replace

- name: overwrite the config
  junos_template:
    src: config.j2
    action: overwrite

Notes

Note

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

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