-
Notifications
You must be signed in to change notification settings - Fork 3
/
project.yml
143 lines (128 loc) · 4.53 KB
/
project.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
- name: DNAC Compliance Demo
hosts: localhost
connection: local
gather_facts: false
vars_files:
- vault.yml
vars:
dnac_host: none
dnac_username: "{{username}}"
dnac_password: "{{password}}"
dnac_verify: False
dnac_version: 2.2.2.3
dnac_debug: False
dnac_port: 443
device_name: none
cli_template: ""
tasks:
- name: Get timestamp from the system
shell: "date +%Y-%m-%dT%H-%M-%S"
register: tstamp
delegate_to: localhost
- name: Get Compliance configuration template projects
cisco.dnac.configuration_template_project_info:
dnac_host: "{{dnac_host}}"
dnac_username: "{{dnac_username}}"
dnac_password: "{{dnac_password}}"
dnac_verify: "{{dnac_verify}}"
dnac_port: "{{dnac_port}}"
dnac_version: "{{dnac_version}}"
dnac_debug: "{{dnac_debug}}"
name: Compliance
register: compliance_projects
- name: Print compliance project id
ansible.builtin.debug:
msg: "Compliance Project ID is: {{compliance_projects.dnac_response[0].id}}"
- name: "Create compliance-{{device_name}}-{{ tstamp.stdout }} template"
cisco.dnac.configuration_template_create:
dnac_host: "{{dnac_host}}"
dnac_username: "{{dnac_username}}"
dnac_password: "{{dnac_password}}"
dnac_verify: "{{dnac_verify}}"
dnac_port: "{{dnac_port}}"
dnac_version: "{{dnac_version}}"
dnac_debug: "{{dnac_debug}}"
name: "compliance-{{device_name}}-{{ tstamp.stdout }}"
tags: []
author: Ansible
deviceTypes:
- productFamily: Routers
- productFamily: Switches and Hubs
softwareType: IOS-XE
softwareVariant: XE
templateContent: "{{cli_template}}"
rollbackTemplateContent:
rollbackTemplateParams: []
projectId: "{{compliance_projects.dnac_response[0].id}}"
language: JINJA
register: create_configuration_template_response
# - name: Print task information
# ansible.builtin.debug:
# msg: "{{create_configuration_template_response}}"
- name: Sleep for 30 seconds and continue with play
wait_for:
timeout: 30
delegate_to: localhost
- name: Get task information
cisco.dnac.task_info:
dnac_host: "{{dnac_host}}"
dnac_username: "{{dnac_username}}"
dnac_password: "{{dnac_password}}"
dnac_verify: "{{dnac_verify}}"
dnac_port: "{{dnac_port}}"
dnac_version: "{{dnac_version}}"
dnac_debug: "{{dnac_debug}}"
taskId: "{{create_configuration_template_response.dnac_response.response.taskId}}"
register: task_info
- name: Print template ID
ansible.builtin.debug:
msg: "Template ID is {{task_info.dnac_response.response.data}}"
- name: "Commit template compliance-{{device_name}}-{{ tstamp.stdout }} id"
cisco.dnac.configuration_template_version_create:
dnac_host: "{{dnac_host}}"
dnac_username: "{{dnac_username}}"
dnac_password: "{{dnac_password}}"
dnac_verify: "{{dnac_verify}}"
dnac_port: "{{dnac_port}}"
dnac_version: "{{dnac_version}}"
dnac_debug: "{{dnac_debug}}"
comments: "First commit"
templateId: "{{task_info.dnac_response.response.data}}"
- name: Sleep for 10 seconds and continue with play
wait_for:
timeout: 10
delegate_to: localhost
- name: "Deploy configuration to device {{ device_name }}"
cisco.dnac.configuration_template_deploy_v2:
dnac_host: "{{dnac_host}}"
dnac_username: "{{dnac_username}}"
dnac_password: "{{dnac_password}}"
dnac_verify: "{{dnac_verify}}"
dnac_port: "{{dnac_port}}"
dnac_version: "{{dnac_version}}"
dnac_debug: "{{dnac_debug}}"
forcePushTemplate: true
isComposite: false
templateId: "{{task_info.dnac_response.response.data}}"
targetInfo:
- id: "{{device_name}}"
type: "MANAGED_DEVICE_HOSTNAME"
register: template_deployment_task
- name: Sleep for 30 seconds and continue with play
wait_for:
timeout: 30
delegate_to: localhost
- name: Get template deployment task information
cisco.dnac.task_info:
dnac_host: "{{dnac_host}}"
dnac_username: "{{dnac_username}}"
dnac_password: "{{dnac_password}}"
dnac_verify: "{{dnac_verify}}"
dnac_port: "{{dnac_port}}"
dnac_version: "{{dnac_version}}"
dnac_debug: "{{dnac_debug}}"
taskId: "{{template_deployment_task.dnac_response.response.taskId}}"
register: task_info
- name: Print task information id
ansible.builtin.debug:
msg: "Deployment progress is {{task_info.dnac_response.response.progress}}"