Debian Codegraph @

ansible_collections/cisco/intersight/tests/integration/targets/intersight_ntp_policy/tasks/tests.yml

raw symbols SCIP
1 ---
2 - block:
3 - name: Define anchor for Intersight API login info
4 ansible.builtin.set_fact:
5 api_info: &api_info
6 api_private_key: "{{ api_private_key }}"
7 api_key_id: "{{ api_key_id }}"
8 api_uri: "{{ api_uri | default(omit) }}"
9 validate_certs: "{{ validate_certs | default(omit) }}"
10 organization: "{{ organization }}"
11
12 - name: Make sure Env is clean
13 cisco.intersight.intersight_ntp_policy:
14 <<: *api_info
15 name: "{{ item }}"
16 state: absent
17 loop:
18 - test_ntp_policy_basic
19 - test_ntp_policy_disabled
20 - test_ntp_policy_with_servers
21 - test_ntp_policy_updated
22
23 - name: Create basic NTP policy - check-mode
24 cisco.intersight.intersight_ntp_policy:
25 <<: *api_info
26 name: test_ntp_policy_basic
27 ntp_servers:
28 - pool.ntp.org
29 description: "Test basic NTP policy"
30 enable: true
31 tags:
32 - Key: Site
33 Value: Test
34 check_mode: true
35 register: basic_creation_check_mode
36
37 - name: Verify basic NTP policy was not created - check-mode
38 ansible.builtin.assert:
39 that:
40 - basic_creation_check_mode is changed
41 - basic_creation_check_mode.api_response == {}
42
43 - name: Create basic NTP policy
44 cisco.intersight.intersight_ntp_policy:
45 <<: *api_info
46 name: test_ntp_policy_basic
47 ntp_servers:
48 - pool.ntp.org
49 - time.google.com
50 description: "Test basic NTP policy"
51 enable: true
52 tags:
53 - Key: Site
54 Value: Test
55 register: basic_creation
56
57 - name: Verify basic NTP policy creation
58 ansible.builtin.assert:
59 that:
60 - basic_creation.changed
61
62 - name: Create basic NTP policy (idempotency check)
63 cisco.intersight.intersight_ntp_policy:
64 <<: *api_info
65 name: test_ntp_policy_basic
66 ntp_servers:
67 - pool.ntp.org
68 - time.google.com
69 description: "Test basic NTP policy"
70 enable: true
71 tags:
72 - Key: Site
73 Value: Test
74 register: basic_creation_ide
75
76 - name: Verify basic NTP policy creation (idempotency check)
77 ansible.builtin.assert:
78 that:
79 - not basic_creation_ide.changed
80
81 - name: Create disabled NTP policy
82 cisco.intersight.intersight_ntp_policy:
83 <<: *api_info
84 name: test_ntp_policy_disabled
85 description: "Test disabled NTP policy"
86 enable: false
87 tags:
88 - Key: Environment
89 Value: Test
90 register: disabled_creation
91
92 - name: Verify disabled NTP policy creation
93 ansible.builtin.assert:
94 that:
95 - disabled_creation.changed
96
97 - name: Create disabled NTP policy (idempotency check)
98 cisco.intersight.intersight_ntp_policy:
99 <<: *api_info
100 name: test_ntp_policy_disabled
101 description: "Test disabled NTP policy"
102 enable: false
103 tags:
104 - Key: Environment
105 Value: Test
106 register: disabled_creation_ide
107
108 - name: Verify disabled NTP policy creation (idempotency check)
109 ansible.builtin.assert:
110 that:
111 - not disabled_creation_ide.changed
112
113 - name: Create NTP policy with servers and timezone
114 cisco.intersight.intersight_ntp_policy:
115 <<: *api_info
116 name: test_ntp_policy_with_servers
117 description: "Test NTP policy with servers and timezone"
118 enable: true
119 ntp_servers:
120 - pool.ntp.org
121 - time.google.com
122 - time.cloudflare.com
123 timezone: "America/New_York"
124 tags:
125 - Key: Configuration
126 Value: Complete
127 register: servers_creation
128
129 - name: Verify NTP policy with servers creation
130 ansible.builtin.assert:
131 that:
132 - servers_creation.changed
133
134 - name: Create NTP policy with servers (idempotency check)
135 cisco.intersight.intersight_ntp_policy:
136 <<: *api_info
137 name: test_ntp_policy_with_servers
138 description: "Test NTP policy with servers and timezone"
139 enable: true
140 ntp_servers:
141 - pool.ntp.org
142 - time.google.com
143 - time.cloudflare.com
144 timezone: "America/New_York"
145 tags:
146 - Key: Configuration
147 Value: Complete
148 register: servers_creation_ide
149
150 - name: Verify NTP policy with servers (idempotency check)
151 ansible.builtin.assert:
152 that:
153 - not servers_creation_ide.changed
154
155 - name: Update basic NTP policy description
156 cisco.intersight.intersight_ntp_policy:
157 <<: *api_info
158 name: test_ntp_policy_basic
159 description: "Updated test basic NTP policy"
160 enable: true
161 ntp_servers:
162 - pool.ntp.org
163 - time.google.com
164 - time.cloudflare.com
165 tags:
166 - Key: Site
167 Value: Test
168 - Key: Updated
169 Value: "true"
170 register: basic_update
171
172 - name: Verify basic NTP policy update
173 ansible.builtin.assert:
174 that:
175 - basic_update.changed
176
177 - name: Update NTP policy servers and timezone
178 cisco.intersight.intersight_ntp_policy:
179 <<: *api_info
180 name: test_ntp_policy_with_servers
181 description: "Updated NTP policy with modified servers"
182 enable: true
183 ntp_servers:
184 - 0.pool.ntp.org
185 - 1.pool.ntp.org
186 - ntp.ubuntu.com
187 timezone: "America/Chicago"
188 tags:
189 - Key: Configuration
190 Value: Updated
191 register: servers_update
192
193 - name: Verify NTP policy servers update
194 ansible.builtin.assert:
195 that:
196 - servers_update.changed
197
198 - name: Disable NTP policy
199 cisco.intersight.intersight_ntp_policy:
200 <<: *api_info
201 name: test_ntp_policy_disabled
202 description: "Updated disabled NTP policy"
203 enable: false
204 ntp_servers:
205 - disabled.ntp.server
206 timezone: "UTC"
207 tags:
208 - Key: Environment
209 Value: Disabled
210 register: disabled_update
211
212 - name: Verify disabled NTP policy update
213 ansible.builtin.assert:
214 that:
215 - disabled_update.changed
216
217 always:
218 - name: Remove all test NTP policies
219 cisco.intersight.intersight_ntp_policy:
220 <<: *api_info
221 name: "{{ item }}"
222 state: absent
223 loop:
224 - test_ntp_policy_basic
225 - test_ntp_policy_disabled
226 - test_ntp_policy_with_servers
227 - test_ntp_policy_updated