-
Notifications
You must be signed in to change notification settings - Fork 0
/
playbook.yaml
98 lines (84 loc) · 2.7 KB
/
playbook.yaml
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
- hosts: all
gather_facts: no
tasks:
- name: Enable feature intersight
nxos_config:
lines:
- feature intersight
- name: Configure proxy
nxos_config:
lines:
- intersight proxy {{intersight_proxy_host}} port {{intersight_proxy_port}}
when:
- intersight_proxy_host is defined
- intersight_proxy_port is defined
- name: Unconfigure proxy
nxos_config:
lines:
- no intersight proxy
when:
- intersight_proxy_host is not defined or intersight_proxy_port is not defined
- name: Configure src interface
nxos_config:
lines:
- intersight source-interface {{intersight_src}}
when:
- intersight_src is defined
- name: Unconfigure src interface
nxos_config:
lines:
- no intersight source-interface
when:
- intersight_src is not defined
- name: Configure src vrf
nxos_config:
lines:
- intersight use-vrf {{ intersight_vrf }}
when:
- intersight_vrf is defined
- name: Unconfigure src vrf
nxos_config:
lines:
- no intersight use-vrf
when:
- intersight_vrf is not defined
- name: Await connection to Intersight
nxos_command:
commands:
- show system internal intersight info
register: intersightInfo
retries: 10
delay: 10
until: intersightInfo.stdout is search("Connecte")
# retrieve SerialNumber and SecurityToken, will create an ad-hoc dict
- name: Get show system device-connector claim-info
nxos_command:
commands:
- show system device-connector claim-info
register: claiminfo
- name: Set claiminfoDict
set_fact:
claiminfoDict: "{{ claiminfoDict | default({}) | combine ({ (item | replace(' ', '')|split(':')| first) : (item | replace(' ', '')|split(':')| last) }) }}"
loop: "{{ claiminfo.stdout_lines[0] }}"
#- name: show claiminfoDict
# debug:
# var: claiminfoDict
# let's claim
- name: claim device - PROXY
cisco.intersight.intersight_target_claim:
device_id: "{{ claiminfoDict.SerialNumber }}"
claim_code: "{{ claiminfoDict.SecurityToken }}"
state: present
api_key_id: "{{ api_key_id }}"
api_private_key: "{{ api_private_key }}"
environment:
https_proxy: "{{internet_proxy_https }}"
when: claiminfoDict.Claimstate == "NotClaimed" and internet_proxy_https is defined
- name: claim device - NO PROXY
cisco.intersight.intersight_target_claim:
device_id: "{{ claiminfoDict.SerialNumber }}"
claim_code: "{{ claiminfoDict.SecurityToken }}"
state: present
api_key_id: "{{ api_key_id }}"
api_private_key: "{{ api_private_key }}"
when: claiminfoDict.Claimstate == "NotClaimed" and internet_proxy_https is not defined