W3cubDocs

/Ansible

junos_template - Manage configuration on remote devices running 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

Requirements (on host that executes module)

  • junos-eznc

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.
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.
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.
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.
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.

Examples

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

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

- name: overwrite the config
    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, 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_template_module.html