| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 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 |
|
| 38 |
- name: Add a new DNS provider |
| 39 |
cisco.aci.aci_dns_provider: |
| 40 |
<<: *aci_info |
| 41 |
dns_profile: ansible_dns_profile |
| 42 |
addr: 10.20.30.40 |
| 43 |
preferred: false |
| 44 |
state: present |
| 45 |
register: add_dns_provider |
| 46 |
|
| 47 |
- name: Verify DNS provider creation |
| 48 |
ansible.builtin.assert: |
| 49 |
that: |
| 50 |
- add_dns_provider is changed |
| 51 |
- add_dns_provider.current.0.dnsProv.attributes.annotation == 'orchestrator:ansible' |
| 52 |
- add_dns_provider.current.0.dnsProv.attributes.dn == "uni/fabric/dnsp-ansible_dns_profile/prov-[10.20.30.40]" |
| 53 |
- add_dns_provider.current.0.dnsProv.attributes.addr == "10.20.30.40" |
| 54 |
- add_dns_provider.current.0.dnsProv.attributes.preferred == "no" |
| 55 |
|
| 56 |
|
| 57 |
- name: Add a new DNS provider again |
| 58 |
cisco.aci.aci_dns_provider: |
| 59 |
<<: *aci_info |
| 60 |
dns_profile: ansible_dns_profile |
| 61 |
addr: 10.20.30.40 |
| 62 |
preferred: false |
| 63 |
state: present |
| 64 |
register: add_dns_provider_again |
| 65 |
|
| 66 |
- name: Verify DNS provider creation idempotence |
| 67 |
ansible.builtin.assert: |
| 68 |
that: |
| 69 |
- add_dns_provider_again is not changed |
| 70 |
- add_dns_provider_again.current.0.dnsProv.attributes.dn == "uni/fabric/dnsp-ansible_dns_profile/prov-[10.20.30.40]" |
| 71 |
- add_dns_provider_again.current.0.dnsProv.attributes.addr == "10.20.30.40" |
| 72 |
- add_dns_provider_again.current.0.dnsProv.attributes.preferred == "no" |
| 73 |
|
| 74 |
|
| 75 |
- name: Update DNS provider |
| 76 |
cisco.aci.aci_dns_provider: |
| 77 |
<<: *aci_info |
| 78 |
dns_profile: ansible_dns_profile |
| 79 |
addr: 10.20.30.40 |
| 80 |
preferred: true |
| 81 |
state: present |
| 82 |
register: update_dns_provider |
| 83 |
|
| 84 |
- name: Verify DNS provider update |
| 85 |
ansible.builtin.assert: |
| 86 |
that: |
| 87 |
- update_dns_provider is changed |
| 88 |
- update_dns_provider.current.0.dnsProv.attributes.dn == "uni/fabric/dnsp-ansible_dns_profile/prov-[10.20.30.40]" |
| 89 |
- update_dns_provider.current.0.dnsProv.attributes.addr == "10.20.30.40" |
| 90 |
- update_dns_provider.current.0.dnsProv.attributes.preferred == "yes" |
| 91 |
|
| 92 |
|
| 93 |
- name: Query DNS provider |
| 94 |
cisco.aci.aci_dns_provider: |
| 95 |
<<: *aci_info |
| 96 |
dns_profile: ansible_dns_profile |
| 97 |
addr: 10.20.30.40 |
| 98 |
state: query |
| 99 |
register: query_dns_provider |
| 100 |
|
| 101 |
- name: Verify DNS provider attributes |
| 102 |
ansible.builtin.assert: |
| 103 |
that: |
| 104 |
- query_dns_provider is not changed |
| 105 |
- query_dns_provider.current.0.dnsProv.attributes.dn == "uni/fabric/dnsp-ansible_dns_profile/prov-[10.20.30.40]" |
| 106 |
- query_dns_provider.current.0.dnsProv.attributes.addr == "10.20.30.40" |
| 107 |
- query_dns_provider.current.0.dnsProv.attributes.preferred == "yes" |
| 108 |
|
| 109 |
|
| 110 |
- name: Query all DNS providers within profile |
| 111 |
cisco.aci.aci_dns_provider: |
| 112 |
<<: *aci_info |
| 113 |
dns_profile: ansible_dns_profile |
| 114 |
state: query |
| 115 |
register: query_dns_provider_all |
| 116 |
|
| 117 |
- name: Verify DNS provider query idempotence |
| 118 |
ansible.builtin.assert: |
| 119 |
that: |
| 120 |
- query_dns_provider_all is not changed |
| 121 |
|
| 122 |
|
| 123 |
- name: Delete DNS provider |
| 124 |
cisco.aci.aci_dns_provider: |
| 125 |
<<: *aci_info |
| 126 |
dns_profile: ansible_dns_profile |
| 127 |
addr: 10.20.30.40 |
| 128 |
state: absent |
| 129 |
register: delete_dns_provider |
| 130 |
|
| 131 |
- name: Verify DNS provider deletion |
| 132 |
ansible.builtin.assert: |
| 133 |
that: |
| 134 |
- delete_dns_provider is changed |
| 135 |
- delete_dns_provider.current == [] |
| 136 |
- delete_dns_provider.previous.0.dnsProv.attributes.dn == "uni/fabric/dnsp-ansible_dns_profile/prov-[10.20.30.40]" |
| 137 |
- delete_dns_provider.previous.0.dnsProv.attributes.addr == "10.20.30.40" |
| 138 |
- delete_dns_provider.previous.0.dnsProv.attributes.preferred == "yes" |
| 139 |
|
| 140 |
|
| 141 |
- name: Delete DNS provider again |
| 142 |
cisco.aci.aci_dns_provider: |
| 143 |
<<: *aci_info |
| 144 |
dns_profile: ansible_dns_profile |
| 145 |
addr: 10.20.30.40 |
| 146 |
state: absent |
| 147 |
register: delete_dns_provider_again |
| 148 |
|
| 149 |
- name: Verify DNS provider deletion idempotence |
| 150 |
ansible.builtin.assert: |
| 151 |
that: |
| 152 |
- delete_dns_provider_again is not changed |
| 153 |
|
| 154 |
|
| 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 |