1. Ansible: ease your config-job
Deploy same config on multiple boxes with just one shot!
Akhmad Zaimi β IP Netop Manager
Telekomunikasi Indonesia International (TELIN)
3. Lets learn YAML
β’ Start with --- end with β¦
β’ Member of list are lines beginning at the same indentation level starting with a "- " (a
dash and a space), example:
Fruits:
- apple
- orange
β’ Dictionary represented with simple key: value form
Martin:
name: Akhmad Zaimi
job: engineer
β’ List and Dictionary in other format:
---
martin: {name: Martin D'vloper, job: Developer, skill: Elite}
fruits: ['Apple', 'Orange', 'Strawberry', 'Mango']
4. Sample playbook
β’ Name file: junos-install-config.yml
---
- name: Load merge a configuration to a device running Junos OS
hosts: switches
roles:
- Juniper.junos
connection: local
gather_facts: yes
vars_prompt:
- name: USRNM
prompt: u
private: no
- name: PWOD
prompt: p
private: no
# - name: HOSTS
# prompt: h
# private: no
tasks:
- name: Checking NETCONF connectivity
wait_for: host={{ inventory_hostname }} port=830 timeout=5
- name: Retrieve info from Junos device
junos_install_config:
host: "{{ inventory_hostname }}"
# host: "{{ HOSTS }}"
user: "{{ USRNM }}"
passwd: "{{ PWOD }}"
logfile: junos-install-config.log
savedir : "/home/user1/ansible-pb/config/"
comment: "add remote backup to ssh server"
#confirm: 0
replace: 1
overwrite: 0
diffs_file: "/home/user1/ansible-pb/config/{{
inventory_hostname }}.diff"
file: /home/user1/ansible-pb/tmp_config/junos-sw-
archive-remote.conf
5. Sample: Junos config to be added
Recap:
- Open connection success β
authentication success
- Success