forked from ksator/openconfig-demo-with-juniper-devices
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pb.backup.yml
76 lines (63 loc) · 2.17 KB
/
pb.backup.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
---
- name: create configuration_backup directories
hosts: localhost
gather_facts: no
tasks:
- name: create configuration directory
file:
path: "{{playbook_dir}}/backup"
state: directory
- name: create configuration subdirectories
file:
path: "{{playbook_dir}}/backup/{{ item }}"
state: directory
with_items:
- text
- xml
- json
- set
- name: Collect configuration from devices
hosts: [Openconfig_Routers]
connection: local
gather_facts: no
tasks:
- name: Collect configuration in text format from devices
junos_facts:
gather_subset: config
config_format: text
provider: "{{ credentials }}"
register: "result_text"
- name: copy collected configuration in configuration/text directory
copy:
content: "{{ result_text.ansible_facts.ansible_net_config }}"
dest: "{{ playbook_dir }}/backup/text/{{ inventory_hostname }}.conf"
- name: Collect configuration in set format from devices
junos_facts:
gather_subset: config
config_format: set
provider: "{{ credentials }}"
register: "result_set"
- name: copy collected configuration in configuration/set directory
copy:
content: "{{ result_set.ansible_facts.ansible_net_config }}"
dest: "{{ playbook_dir }}/backup/set/{{ inventory_hostname }}.set"
- name: Collect configuration in json format from devices
junos_facts:
gather_subset: config
config_format: json
provider: "{{ credentials }}"
register: "result_json"
- name: copy collected configuration in configuration/json directory
copy:
content: "{{ result_json.ansible_facts.ansible_net_config }}"
dest: "{{ playbook_dir }}/backup/json/{{ inventory_hostname }}.json"
- name: Collect configuration in xml format from devices
junos_facts:
gather_subset: config
config_format: xml
provider: "{{ credentials }}"
register: "result_xml"
- name: copy collected configuration in configuration/xml directory
copy:
content: "{{ result_xml.ansible_facts.ansible_net_config }}"
dest: "{{ playbook_dir }}/backup/xml/{{ inventory_hostname }}.xml"