blob: ce9a38770580a7a8b66cd48fabde35b81ea79a96 (
plain)
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
|
---
- hosts: dnac_servers
vars:
globalCredentialIdList:
- "90acbab8-03d5-4726-9c19-e1e51a40b3cd"
- "f979d842-f6fd-456a-8137-2cb5113cd2e8"
vars_files:
- credentials.yml
gather_facts: false
tasks:
- name: Find discovery
cisco.dnac.discovery_range_info:
dnac_host: "{{ dnac_host }}"
dnac_username: "{{ dnac_username }}"
dnac_password: "{{ dnac_password }}"
dnac_verify: "{{ dnac_verify }}"
dnac_debug: "{{ dnac_debug }}"
startIndex: 1
recordsToReturn: 500
register: discovery_range_result
- name: Set fact of filtered discoveries
ansible.builtin.set_fact:
discoveries_filtered: "{{ discovery_range_result.dnac_response.response | selectattr('name', 'equalto', 'DMZ Lab 2')}}"
when:
- discovery_range_result is defined
- discovery_range_result.dnac_response is defined
- discovery_range_result.dnac_response.response is defined
register: discovery_filtered_results
- name: Set fact of filtered discovery
ansible.builtin.set_fact:
discovery_filtered: "{{ discovery_filtered_results.ansible_facts.discoveries_filtered|first }}"
when:
- discovery_filtered_results is defined
- discovery_filtered_results.ansible_facts is defined
- discovery_filtered_results.ansible_facts.discoveries_filtered is defined
- discovery_filtered_results.ansible_facts.discoveries_filtered|length > 0
register: discovery_filtered_result
- name: Set fact of filtered discovery id
ansible.builtin.set_fact:
discovery_filtered_id: "{{ discovery_filtered_result.ansible_facts.discovery_filtered.id }}"
when:
- discovery_filtered_result is defined
- discovery_filtered_result.ansible_facts is defined
- discovery_filtered_result.ansible_facts.discovery_filtered is defined
register: discovery_filtered_result_id
- name: Create a discovery
cisco.dnac.discovery:
dnac_host: "{{ dnac_host }}"
dnac_username: "{{ dnac_username }}"
dnac_password: "{{ dnac_password }}"
dnac_verify: "{{ dnac_verify }}"
dnac_debug: "{{ dnac_debug }}"
validate_response_schema: false
state: present
cdpLevel: 16
discoveryType: CDP
globalCredentialIdList: "{{globalCredentialIdList}}"
ipAddressList: 10.10.22.22
name: start_discovery_test2
protocolOrder: ssh
# id: "67"
# enablePasswordList: [""]
# userNameList: [""]
# passwordList: [""]
# ipFilterList: [""]
# httpReadCredential:
# port: 0
# secure: false
# deviceIds: " "
# discoveryCondition: "In Progress"
# discoveryStatus: "Active"
# isAutoCdp: true
# preferredMgmtIPMethod: "None"
# retry: 3
# timeout: 5
# httpWriteCredential:
# port: 0
# secure: false
register: discovery_result
when:
- discovery_filtered_result_id is not defined
- name: Update a discovery
cisco.dnac.discovery:
dnac_host: "{{ dnac_host }}"
dnac_username: "{{ dnac_username }}"
dnac_password: "{{ dnac_password }}"
dnac_verify: "{{ dnac_verify }}"
dnac_debug: "{{ dnac_debug }}"
validate_response_schema: false
state: present
cdpLevel: 16
discoveryType: CDP
globalCredentialIdList: "{{globalCredentialIdList}}"
ipAddressList: 10.10.22.22
name: start_discovery_test2
protocolOrder: ssh
id: "{{ discovery_filtered_result_id.ansible_facts.discovery_filtered_id }}"
# enablePasswordList: [""]
# userNameList: [""]
# passwordList: [""]
# ipFilterList: [""]
# httpReadCredential:
# port: 0
# secure: false
# deviceIds: " "
# discoveryCondition: "In Progress"
# discoveryStatus: "Active"
# isAutoCdp: true
# preferredMgmtIPMethod: "None"
# retry: 3
# timeout: 5
# httpWriteCredential:
# port: 0
# secure: false
register: discovery_result
when:
- discovery_filtered_result_id is defined
- name: Show discovery result
ansible.builtin.debug:
msg: "{{ discovery_result }}"
when:
- discovery_result is defined
|