-
Notifications
You must be signed in to change notification settings - Fork 9
/
ios-tower-backup-surveys.yml
79 lines (69 loc) · 2.55 KB
/
ios-tower-backup-surveys.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
76
77
78
79
---
- name: Make Surveys based on backup directories
hosts: tower
gather_facts: no
vars_files:
- default_vars.yml
- ./credentials/tower-credentials.yml
tasks:
- name: Find /tmp/ios_backups/ all directories, exclude nginx and mysql
ansible.builtin.find:
paths: /tmp/ios_backups/
recurse: no
file_type: directory
register: find_output
# - debug:
# var: find_output
# - debug:
# msg: "{{ item.path }}"
# loop: "{{ find_output.files }}"
- name: Build survey_spec from template
ansible.builtin.template:
src: ./templates/drift_survey.j2
dest: /tmp/drift_survey.json
# delegate_to: localhost
- name: Build survey_spec from template
ansible.builtin.template:
src: ./templates/restore_survey.j2
dest: /tmp/restore_survey.json
- name: Build Ansible Tower Config Drift template with Survey
ansible.tower.tower_job_template:
name: "iosxe_check_for_configuration_drift"
job_type: "run"
inventory: "Cloud Cisco CSR 1000v Routers"
project: "Cisco IOS-XE Administration"
playbook: "ios-drift-detect.yml"
credential: "Cloud Cisco CSR 1000v Routers"
survey_enabled: true
survey_spec: "{{ lookup('template', '/tmp/drift_survey.json') }}"
tower_username: "{{ TOWER_USERNAME }}"
tower_password: "{{ TOWER_PASSWORD }}"
tower_host: "{{ TOWER_HOST }}"
validate_certs: no
diff_mode_enabled: yes
delegate_to: localhost
run_once: yes
- name: Build Ansible Tower Config Restore template with Survey
ansible.tower.tower_job_template:
name: "iosxe_restore_config_from_backup"
job_type: "run"
inventory: "Cloud Cisco CSR 1000v Routers"
project: "Cisco IOS-XE Administration"
playbook: "ios-restore-config.yml"
credential: "Cloud Cisco CSR 1000v Routers"
survey_enabled: true
survey_spec: "{{ lookup('template', '/tmp/restore_survey.json') }}"
tower_username: "{{ TOWER_USERNAME }}"
tower_password: "{{ TOWER_PASSWORD }}"
tower_host: "{{ TOWER_HOST }}"
validate_certs: no
delegate_to: localhost
run_once: yes
- name: Delete drift survey from /tmp directory
ansible.builtin.file:
state: absent
path: /tmp/drift_survey.json
- name: Delete restore survey from /tmp directory
ansible.builtin.file:
state: absent
path: /tmp/restore_survey.json