This Ansible role provides a quick way to push a configuration file to a juniper device.
You only specify the folder that contains the configuration files. This role will first search for a configuration file that matches the target device name (file name must end with hostname.conf). Then, it will load and commit (by default with the merge option) the configuration to the remote host.
Moreover, if pushing the configuration via SSH fails, the role automatically attempts to load and commit via Telnet, using different credentials that can be customized.
- Juniper.junos role. Already included in the meta, no need to import this role at the playbook level.
built_configs_dir
(default{{ inventory_dir }}/_built_configs
): Path to the directory where the configuration files you wish to load and commit are located;loading_option
(defaultmerge
): the junos loading method to use. Common options aremerge
,override
,update
,set
. Check juniper_junos_config documentation for more info;telnet_user
(defaultroot
) andtelnet_password
(default''
): the credential that will be used to attempt a telnet connection if the first SSH connection fails. Useful to push the initial default configuration to devices not configured with SSH yet (for example zeroized devices)prefix_filter_label
(defaultnull
): an optional string. If provided, only configuration files starting with this prefix will be looked up in the folder;commit_timeout
(default30
) Timeout value when the configuration is committed. Refer to thetimeout
option in the Junos_junos_config documentation for more details.
# my_playbook.yml
- name: Push device configurations
hosts: all
connection: local
gather_facts: no
tasks:
- name: Push device configurations
include_role:
name: dana_junos_push_config
public: yes
# Apply tags required to make role's tasks inherit the desired tags
apply:
tags:
- always
tags:
- always
BSD
Luigi Stammati