Debian Codegraph @

ansible_collections/cisco/aci/tests/integration/targets/aci_firmware_group/tasks/main.yml

raw symbols SCIP
1 # Test code for the ACI modules
2 # Copyright: (c) 2023, Gaspard Micol (@gmicol) <[email protected]>
3
4 # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
5
6 - name: Test that we have an ACI APIC host, ACI username and ACI password
7 ansible.builtin.fail:
8 msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.'
9 when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined
10
11 - name: Set vars
12 ansible.builtin.set_fact:
13 aci_info: &aci_info
14 host: "{{ aci_hostname }}"
15 username: "{{ aci_username }}"
16 password: "{{ aci_password }}"
17 validate_certs: '{{ aci_validate_certs | default(false) }}'
18 use_ssl: '{{ aci_use_ssl | default(true) }}'
19 use_proxy: '{{ aci_use_proxy | default(true) }}'
20 output_level: debug
21
22 - name: Verify Cloud and Non-Cloud Sites in use.
23 ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml
24
25 - name: Execute tasks only for non-cloud sites
26 when: query_cloud.current == [] # This condition will execute only non-cloud sites
27 block: # block specifies execution of tasks within, based on conditions
28 # Clean Environment
29 - name: Create firmware policy
30 cisco.aci.aci_firmware_policy: &aci_firmware_policy_present
31 <<: *aci_info
32 name: anstest_policy
33 version: n9000-15.2(7)
34 state: present
35
36 - name: Ensure first firmware group does not exist
37 cisco.aci.aci_firmware_group: &aci_firmware_group_absent
38 <<: *aci_info
39 group: anstest_group
40 policy: anstest_policy
41 type_group: all
42 description: test firmware group
43 state: absent
44
45 - name: Ensure second firmware group does not exist
46 cisco.aci.aci_firmware_group: &aci_firmware_group_2_absent
47 <<: *aci_info
48 group: anstest_group_2
49 policy: anstest_policy
50 state: absent
51
52 - name: Create first firmware group (check_mode)
53 cisco.aci.aci_firmware_group: &aci_firmware_group_present
54 <<: *aci_firmware_group_absent
55 state: present
56 check_mode: true
57 register: cm_add_firmware_group_1
58
59 - name: Create first firmware group (normal_mode)
60 cisco.aci.aci_firmware_group:
61 <<: *aci_firmware_group_present
62 register: nm_add_firmware_group_1
63
64 - name: Create first firmware group again - testing idempotency
65 cisco.aci.aci_firmware_group:
66 <<: *aci_firmware_group_present
67 register: idempotency_add_firmware_group_1
68
69 - name: Create second firmware group
70 cisco.aci.aci_firmware_group: &aci_firmware_group_2_present
71 <<: *aci_firmware_group_2_absent
72 state: present
73 register: nm_add_firmware_group_2
74
75 - name: Asserts for creation tasks
76 ansible.builtin.assert:
77 that:
78 - cm_add_firmware_group_1 is changed
79 - cm_add_firmware_group_1.previous == []
80 - cm_add_firmware_group_1.current == []
81 - nm_add_firmware_group_1 is changed
82 - nm_add_firmware_group_1.current.0.firmwareFwGrp.attributes.name == "anstest_group"
83 - nm_add_firmware_group_1.current.0.firmwareFwGrp.attributes.type == "ALL"
84 - nm_add_firmware_group_1.current.0.firmwareFwGrp.children.0.firmwareRsFwgrpp.attributes.tnFirmwareFwPName == "anstest_policy"
85 - idempotency_add_firmware_group_1 is not changed
86 - nm_add_firmware_group_2 is changed
87
88 - name: Query all firmware groups
89 cisco.aci.aci_firmware_group:
90 <<: *aci_info
91 state: query
92 register: query_all_firmware_group
93
94 - name: Query first firmware group
95 cisco.aci.aci_firmware_group:
96 <<: *aci_firmware_group_present
97 state: query
98 register: query_first_firmware_group
99
100 - name: Asserts for query tasks
101 ansible.builtin.assert:
102 that:
103 - query_all_firmware_group is not changed
104 - query_all_firmware_group.current | length >= 2
105 - '"firmwareRsFwgrpp" in query_all_firmware_group.filter_string'
106 - '"class/firmwareFwGrp.json" in query_all_firmware_group.url'
107 - query_first_firmware_group is not changed
108 - query_first_firmware_group.current.0.firmwareFwGrp.attributes.name == "anstest_group"
109 - query_first_firmware_group.current.0.firmwareFwGrp.attributes.type == "ALL"
110 - query_first_firmware_group.current.0.firmwareFwGrp.children.0.firmwareRsFwgrpp.attributes.tnFirmwareFwPName == "anstest_policy"
111
112 - name: Delete first firmware group (check_mode)
113 cisco.aci.aci_firmware_group:
114 <<: *aci_firmware_group_present
115 state: absent
116 check_mode: true
117 register: cm_delete_firmware_group_1
118
119 - name: Delete first firmware group (normal_mode)
120 cisco.aci.aci_firmware_group:
121 <<: *aci_firmware_group_present
122 state: absent
123 register: nm_delete_firmware_group_1
124
125 - name: Delete first firmware group again - testing idempotency
126 cisco.aci.aci_firmware_group:
127 <<: *aci_firmware_group_present
128 state: absent
129 register: idempotency_delete_firmware_group_1
130
131 - name: Delete second firmware group (normal_mode)
132 cisco.aci.aci_firmware_group:
133 <<: *aci_firmware_group_2_present
134 state: absent
135 register: nm_delete_firmware_group_2
136
137 - name: Asserts for deletion tasks
138 ansible.builtin.assert:
139 that:
140 - cm_delete_firmware_group_1 is changed
141 - cm_delete_firmware_group_1.proposed == {}
142 - nm_delete_firmware_group_1 is changed
143 - nm_delete_firmware_group_1.previous != []
144 - nm_delete_firmware_group_1.current == []
145 - idempotency_delete_firmware_group_1 is not changed
146 - idempotency_delete_firmware_group_1.previous == []
147 - nm_delete_firmware_group_2 is changed
148 - nm_delete_firmware_group_2.previous != []
149 - nm_delete_firmware_group_2.current == []
150
151 - name: Delete firmware policy - clean up the environment
152 cisco.aci.aci_firmware_policy:
153 <<: *aci_firmware_policy_present
154 state: absent