Debian Codegraph @

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

raw symbols SCIP
1 # Test code for the ACI modules
2 # Copyright: (c) 2021, Tim Cragg (@timcragg)
3 # Copyright: (c) 2024, Akini Ross (@akinross)
4
5 # GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
6
7 - name: Test that we have an ACI APIC host, ACI username and ACI password
8 ansible.builtin.fail:
9 msg: 'Please define the following variables: aci_hostname, aci_username and aci_password.'
10 when: aci_hostname is not defined or aci_username is not defined or aci_password is not defined
11
12 # GET Credentials from the inventory
13 - name: Set vars
14 ansible.builtin.set_fact:
15 aci_info: &aci_info
16 host: "{{ aci_hostname }}"
17 username: "{{ aci_username }}"
18 password: "{{ aci_password }}"
19 validate_certs: '{{ aci_validate_certs | default(false) }}'
20 use_ssl: '{{ aci_use_ssl | default(true) }}'
21 use_proxy: '{{ aci_use_proxy | default(true) }}'
22 output_level: debug
23
24 # CLEAN DNS PROFILES
25 - name: Remove DNS profiles before testing
26 cisco.aci.aci_dns_profile:
27 <<: *aci_info
28 profile_name: "{{ item }}"
29 state: absent
30 loop:
31 - ansible_dns_profile
32 - ansible_dns_profile_mamagement_epg
33
34 # ADD DNS PROFILE
35 - name: Add DNS profile
36 cisco.aci.aci_dns_profile:
37 <<: *aci_info
38 profile_name: ansible_dns_profile
39 state: present
40 register: add_dns_profile
41
42 - name: Verify that DNS profile has been created with correct attributes
43 ansible.builtin.assert:
44 that:
45 - add_dns_profile is changed
46 - add_dns_profile.current.0.dnsProfile.attributes.annotation == 'orchestrator:ansible'
47 - add_dns_profile.current.0.dnsProfile.attributes.dn == "uni/fabric/dnsp-ansible_dns_profile"
48 - add_dns_profile.current.0.dnsProfile.attributes.name == "ansible_dns_profile"
49
50 # ADD DNS PROFILE AGAIN TO TEST IDEMPOTENCE
51 - name: Add DNS profile again
52 cisco.aci.aci_dns_profile:
53 <<: *aci_info
54 profile_name: ansible_dns_profile
55 state: present
56 register: add_dns_profile_again
57
58 - name: Verify that DNS profile creation idempotence
59 ansible.builtin.assert:
60 that:
61 - add_dns_profile_again is not changed
62 - add_dns_profile_again.current.0.dnsProfile.attributes.dn == "uni/fabric/dnsp-ansible_dns_profile"
63 - add_dns_profile_again.current.0.dnsProfile.attributes.name == "ansible_dns_profile"
64
65 # ADD MGMT EPG TO DNS PROFILE
66
67 - name: Add ooband management EPG to DNS profile (check-mode)
68 cisco.aci.aci_dns_profile: &aci_dns_profile_ooband
69 <<: *aci_info
70 profile_name: ansible_dns_profile_mamagement_epg
71 management_epg: ansible_mgmt_epg_ooband
72 state: present
73 check_mode: yes
74 register: cm_add_ooband_mgmt_epg_to_dns_profile
75
76 - name: Add ooband management EPG to DNS profile
77 cisco.aci.aci_dns_profile:
78 <<: *aci_dns_profile_ooband
79 state: present
80 register: nm_add_ooband_mgmt_epg_to_dns_profile
81
82 - name: Add ooband management EPG to DNS profile again to test idempotence
83 cisco.aci.aci_dns_profile:
84 <<: *aci_dns_profile_ooband
85 state: present
86 register: nm_add_ooband_mgmt_epg_to_dns_profile_again
87
88 - name: Update ooband management EPG to inband management EPG
89 cisco.aci.aci_dns_profile:
90 <<: *aci_dns_profile_ooband
91 management_epg: ansible_mgmt_epg_inband
92 management_epg_type: inband
93 state: present
94 register: nm_update_ooband_mgmt_epg_to_inband_mgmt_epg
95
96 - name: Remove management EPG from DNS profile
97 cisco.aci.aci_dns_profile:
98 <<: *aci_dns_profile_ooband
99 management_epg: ""
100 state: present
101 register: nm_remove_inband_mgmt_epg_from_dns_profile
102
103 - name: Verify DNS profile with management EPGs
104 ansible.builtin.assert:
105 that:
106 - cm_add_ooband_mgmt_epg_to_dns_profile is changed
107 - cm_add_ooband_mgmt_epg_to_dns_profile.previous == []
108 - cm_add_ooband_mgmt_epg_to_dns_profile.proposed.dnsProfile.attributes.name == "ansible_dns_profile_mamagement_epg"
109 - cm_add_ooband_mgmt_epg_to_dns_profile.proposed.dnsProfile.children.0.dnsRsProfileToEpg.attributes.tDn == "uni/tn-mgmt/mgmtp-default/oob-ansible_mgmt_epg_ooband"
110 - nm_add_ooband_mgmt_epg_to_dns_profile is changed
111 - nm_add_ooband_mgmt_epg_to_dns_profile.previous == []
112 - nm_add_ooband_mgmt_epg_to_dns_profile.current.0.dnsProfile.attributes.name == "ansible_dns_profile_mamagement_epg"
113 - nm_add_ooband_mgmt_epg_to_dns_profile.current.0.dnsProfile.children.0.dnsRsProfileToEpg.attributes.tDn == "uni/tn-mgmt/mgmtp-default/oob-ansible_mgmt_epg_ooband"
114 - nm_add_ooband_mgmt_epg_to_dns_profile_again is not changed
115 - nm_add_ooband_mgmt_epg_to_dns_profile_again.previous.0.dnsProfile.attributes.name == "ansible_dns_profile_mamagement_epg"
116 - nm_add_ooband_mgmt_epg_to_dns_profile_again.previous.0.dnsProfile.children.0.dnsRsProfileToEpg.attributes.tDn == "uni/tn-mgmt/mgmtp-default/oob-ansible_mgmt_epg_ooband"
117 - nm_add_ooband_mgmt_epg_to_dns_profile_again.current.0.dnsProfile.attributes.name == "ansible_dns_profile_mamagement_epg"
118 - nm_add_ooband_mgmt_epg_to_dns_profile_again.current.0.dnsProfile.children.0.dnsRsProfileToEpg.attributes.tDn == "uni/tn-mgmt/mgmtp-default/oob-ansible_mgmt_epg_ooband"
119 - nm_update_ooband_mgmt_epg_to_inband_mgmt_epg is changed
120 - nm_update_ooband_mgmt_epg_to_inband_mgmt_epg.previous.0.dnsProfile.attributes.name == "ansible_dns_profile_mamagement_epg"
121 - nm_update_ooband_mgmt_epg_to_inband_mgmt_epg.previous.0.dnsProfile.children.0.dnsRsProfileToEpg.attributes.tDn == "uni/tn-mgmt/mgmtp-default/oob-ansible_mgmt_epg_ooband"
122 - nm_update_ooband_mgmt_epg_to_inband_mgmt_epg.current.0.dnsProfile.attributes.name == "ansible_dns_profile_mamagement_epg"
123 - nm_update_ooband_mgmt_epg_to_inband_mgmt_epg.current.0.dnsProfile.children.0.dnsRsProfileToEpg.attributes.tDn == "uni/tn-mgmt/mgmtp-default/inb-ansible_mgmt_epg_inband"
124 - nm_remove_inband_mgmt_epg_from_dns_profile is changed
125 - nm_remove_inband_mgmt_epg_from_dns_profile.previous.0.dnsProfile.attributes.name == "ansible_dns_profile_mamagement_epg"
126 - nm_remove_inband_mgmt_epg_from_dns_profile.previous.0.dnsProfile.children.0.dnsRsProfileToEpg.attributes.tDn == "uni/tn-mgmt/mgmtp-default/inb-ansible_mgmt_epg_inband"
127 - nm_remove_inband_mgmt_epg_from_dns_profile.current.0.dnsProfile.children.0.dnsRsProfileToEpg is not defined
128
129 # QUERY DNS PROFILE
130 - name: Query the DNS profile
131 cisco.aci.aci_dns_profile:
132 <<: *aci_info
133 profile_name: ansible_dns_profile
134 state: query
135 register: query_dns_profile
136
137 - name: Verify DNS profile
138 ansible.builtin.assert:
139 that:
140 - query_dns_profile is not changed
141 - query_dns_profile.current.0.dnsProfile.attributes.dn == "uni/fabric/dnsp-ansible_dns_profile"
142 - query_dns_profile.current.0.dnsProfile.attributes.name == "ansible_dns_profile"
143
144 - name: Query all DNS profiles
145 cisco.aci.aci_dns_profile:
146 <<: *aci_info
147 state: query
148 register: query_dns_profile_all
149
150 - name: Verify query idempotence
151 ansible.builtin.assert:
152 that:
153 - query_dns_profile_all is not changed
154
155 # DELETE DNS PROFILE
156 - name: Remove the DNS profile
157 cisco.aci.aci_dns_profile:
158 <<: *aci_info
159 name: ansible_dns_profile
160 state: absent
161 register: remove_dns_profile
162
163 - name: Verify DNS profile removal
164 ansible.builtin.assert:
165 that:
166 - remove_dns_profile is changed
167 - remove_dns_profile.current == []
168 - remove_dns_profile.previous.0.dnsProfile.attributes.dn == "uni/fabric/dnsp-ansible_dns_profile"
169 - remove_dns_profile.previous.0.dnsProfile.attributes.name == "ansible_dns_profile"
170
171 # DELETE DNS PROFILE AGAIN TO TEST IDEMPOTENCE
172 - name: Remove the DNS profile again
173 cisco.aci.aci_dns_profile:
174 <<: *aci_info
175 name: ansible_dns_profile
176 state: absent
177 register: remove_dns_profile_again
178
179 - name: Verify DNS profile removal idempotence
180 ansible.builtin.assert:
181 that:
182 - remove_dns_profile_again is not changed