Debian Codegraph @

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

raw symbols SCIP
1 # Test code for the ACI modules
2 # Copyright: (c) 2021, Tim Cragg (@timcragg)
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 # GET Credentials from the inventory
12 - name: Set vars
13 ansible.builtin.set_fact:
14 aci_info: &aci_info
15 host: "{{ aci_hostname }}"
16 username: "{{ aci_username }}"
17 password: "{{ aci_password }}"
18 validate_certs: '{{ aci_validate_certs | default(false) }}'
19 use_ssl: '{{ aci_use_ssl | default(true) }}'
20 use_proxy: '{{ aci_use_proxy | default(true) }}'
21 output_level: debug
22
23 # CLEAN ENVIRONMENT
24 - name: Remove DNS profile if it already exists
25 cisco.aci.aci_dns_profile:
26 <<: *aci_info
27 profile_name: ansible_dns_profile
28 state: absent
29
30 # ADD DNS PROFILE
31 - name: Add DNS profile
32 cisco.aci.aci_dns_profile:
33 <<: *aci_info
34 profile_name: ansible_dns_profile
35 state: present
36
37 # ADD DNS DOMAIN
38 - name: Add a new DNS domain
39 cisco.aci.aci_dns_domain:
40 <<: *aci_info
41 dns_profile: ansible_dns_profile
42 domain: example.com
43 default: false
44 state: present
45 register: add_dns_domain
46
47 - name: Verify DNS domain creation
48 ansible.builtin.assert:
49 that:
50 - add_dns_domain is changed
51 - add_dns_domain.current.0.dnsDomain.attributes.annotation == 'orchestrator:ansible'
52 - add_dns_domain.current.0.dnsDomain.attributes.dn == "uni/fabric/dnsp-ansible_dns_profile/dom-example.com"
53 - add_dns_domain.current.0.dnsDomain.attributes.name == "example.com"
54 - add_dns_domain.current.0.dnsDomain.attributes.isDefault == "no"
55
56 # ADD DNS DOMAIN AGAIN TO TEST IDEMPOTENCE
57 - name: Add DNS domain again
58 cisco.aci.aci_dns_domain:
59 <<: *aci_info
60 dns_profile: ansible_dns_profile
61 domain: example.com
62 default: false
63 state: present
64 register: add_dns_domain_again
65
66 - name: Verify DNS domain creation idempotence
67 ansible.builtin.assert:
68 that:
69 - add_dns_domain_again is not changed
70 - add_dns_domain_again.current.0.dnsDomain.attributes.dn == "uni/fabric/dnsp-ansible_dns_profile/dom-example.com"
71 - add_dns_domain_again.current.0.dnsDomain.attributes.name == "example.com"
72 - add_dns_domain_again.current.0.dnsDomain.attributes.isDefault == "no"
73
74 # MODIFY DNS DOMAIN
75 - name: Update DNS domain
76 cisco.aci.aci_dns_domain:
77 <<: *aci_info
78 dns_profile: ansible_dns_profile
79 domain: example.com
80 default: true
81 state: present
82 register: update_dns_domain
83
84 - name: Verify DNS domain update
85 ansible.builtin.assert:
86 that:
87 - update_dns_domain is changed
88 - update_dns_domain.current.0.dnsDomain.attributes.dn == "uni/fabric/dnsp-ansible_dns_profile/dom-example.com"
89 - update_dns_domain.current.0.dnsDomain.attributes.name == "example.com"
90 - update_dns_domain.current.0.dnsDomain.attributes.isDefault == "yes"
91
92 # QUERY DNS DOMAIN
93 - name: Query DNS domain
94 cisco.aci.aci_dns_domain:
95 <<: *aci_info
96 dns_profile: ansible_dns_profile
97 domain: example.com
98 state: query
99 register: query_dns_domain
100
101 - name: Verify DNS domain attributes
102 ansible.builtin.assert:
103 that:
104 - query_dns_domain is not changed
105 - query_dns_domain.current.0.dnsDomain.attributes.dn == "uni/fabric/dnsp-ansible_dns_profile/dom-example.com"
106 - query_dns_domain.current.0.dnsDomain.attributes.name == "example.com"
107 - query_dns_domain.current.0.dnsDomain.attributes.isDefault == "yes"
108
109 # QUERY ALL DNS DOMAINS WITHIN THE PROFILE
110 - name: Query all DNS domains within the profile
111 cisco.aci.aci_dns_domain:
112 <<: *aci_info
113 dns_profile: ansible_dns_profile
114 state: query
115 register: query_dns_domain_all
116
117 - name: Verify DNS domain query idempotence
118 ansible.builtin.assert:
119 that:
120 - query_dns_domain_all is not changed
121
122 # DELETE DNS DOMAIN
123 - name: Remove DNS Domain
124 cisco.aci.aci_dns_domain:
125 <<: *aci_info
126 dns_profile: ansible_dns_profile
127 domain: example.com
128 state: absent
129 register: delete_dns_domain
130
131 - name: Verify DNS domain deletion
132 ansible.builtin.assert:
133 that:
134 - delete_dns_domain is changed
135 - delete_dns_domain.current == []
136 - delete_dns_domain.previous.0.dnsDomain.attributes.dn == "uni/fabric/dnsp-ansible_dns_profile/dom-example.com"
137 - delete_dns_domain.previous.0.dnsDomain.attributes.name == "example.com"
138 - delete_dns_domain.previous.0.dnsDomain.attributes.isDefault == "yes"
139
140 # DELETE DNS DOMAIN AGAIN TO TEST IDEMPOTENCE
141 - name: Remove DNS Domain
142 cisco.aci.aci_dns_domain:
143 <<: *aci_info
144 dns_profile: ansible_dns_profile
145 domain: example.com
146 state: absent
147 register: delete_dns_domain_again
148
149 - name: Verify DNS domain deletion idempotence
150 ansible.builtin.assert:
151 that:
152 - delete_dns_domain_again is not changed
153
154 # CLEAN ENVIRONMENT
155 - name: Remove DNS profile if it already exists
156 cisco.aci.aci_dns_profile:
157 <<: *aci_info
158 profile_name: ansible_dns_profile
159 state: absent