-
Notifications
You must be signed in to change notification settings - Fork 8
Initial Installation
noashadmon edited this page Sep 6, 2017
·
6 revisions
This module loads and commits a new configuration on a Junos device that does not have a configuration installed on it, which is why we connect to the device via console instead of ssh. This module has required and optional parameters that control exactly how the new configuration will be installed. These parameters are:
Required
- file: the configuration file path with extensions
- .conf if file is in text format
- .xml if file is in XML format
- .set if file is in set format
- host: the host name
Optional
- overwrite: if true the new configuration file will completely overwrite the old config file. if false, only a merge or replace will occur
- replace: if true, a load replace will occur, otherwise it will not
- diffs_file: the path of the file where the configuration file changes are saved
- savedir: the file path where device facts and inventory files are saved (only works with console option)
- timeout: the amount of time allotted to let the new configuration time to load
- comment: writes a comment to the commit
- confirm: a number of minutes to give the commit a confirmation of the configuration installed
- logfile: path to a file where progress of the command is saved
To execute the install_config command, enter the following line in the terminal
ansible-playbook install_conf.yaml -i all.inv
when all.inv is my inventory file and install_conf.yaml is the following playbook:
---
- name: install config
hosts: junos-tel
connection: local
gather_facts: no
roles:
- Juniper.junos
vars_prompt:
- name: ADMUSER
prompt: Username
private: no
- name: ADMPASS
prompt: Password
private: yes
vars:
- console_port: 7006
- console_server: core2
tasks:
- name: Install configuration on Junos device
junos_install_config:
host: "{{ console_server }}"
user: "{{ ADMUSER }}"
passwd: "{{ ADMPASS }}"
mode: "telnet"
port: "{{ console_port }}"
file: config.conf
- name: Commit changes
junos_commit:
host: "{{ console_server }}"
user: "{{ ADMUSER }}"
passwd: "{{ ADMPASS }}"
mode: "telnet"
port: "{{ console_port }}"
The output is shown below:
PLAY [install config] *********************************************************************************************
TASK [Install configuration on Junos device] **********************************************************************
ok: [core2]
TASK [Commit changes] *********************************************************************************************
changed: [core2]
PLAY RECAP ********************************************************************************************************
core2 : ok=2 changed=1 unreachable=0 failed=0
Resources:
- Ansible's website
- Automating Junos Administration by Jonathan Looney and Stacy Smith
- Juniper.junos Ansible Modules