-
Notifications
You must be signed in to change notification settings - Fork 0
/
get_device_summary.yml
43 lines (39 loc) · 1.41 KB
/
get_device_summary.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
---
- name: Make API Call to Cisco DevNet Sandbox
hosts: device_roles_distribution, device_roles_access
gather_facts: no
vars:
username: "devnetuser"
password: "Cisco123!"
tasks:
- name: Set Custom Fields as Facts
set_fact:
cisco_catalyst_center: "{{ hostvars[inventory_hostname].custom_fields['cisco_catalyst_center'] }}"
ccc_device_id: "{{ hostvars[inventory_hostname].custom_fields['ccc_device_id'] }}"
- name: Get Auth Token from Cisco DevNet Sandbox
uri:
url: "https://{{ cisco_catalyst_center }}/dna/system/api/v1/auth/token"
method: POST
return_content: yes
validate_certs: no
headers:
Content-Type: "application/json"
Authorization: "Basic {{ ('%s:%s' | format(username, password)) | b64encode }}"
body_format: json
register: login_response
delegate_to: localhost
- name: Get Device Details from Cisco DevNet Sandbox
uri:
url: "https://{{ cisco_catalyst_center }}/dna/intent/api/v1/network-device/{{ ccc_device_id }}"
method: GET
return_content: yes
validate_certs: no
headers:
Content-Type: "application/json"
x-auth-token: "{{ login_response.json['Token'] }}"
register: device_details
delegate_to: localhost
- name: Print Device Details
debug:
var: device_details.json
delegate_to: localhost