Debian Codegraph @

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

raw symbols SCIP
1 # Test code for the ACI modules
2 # Copyright: (c) 2020, Shreyas Srish (@shrsr)
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 # CLEAN ENVIRONMENT
23 - name: Remove the ansible_tenant
24 cisco.aci.aci_tenant:
25 <<: *aci_info
26 tenant: ansible_tenant
27 state: absent
28
29 - name: Verify Cloud and Non-Cloud Sites in use.
30 ansible.builtin.include_tasks: ../../../../../../integration/targets/aci_cloud_provider/tasks/main.yml
31
32 - name: Execute tasks only for non-cloud sites
33 when: query_cloud.current == [] # This condition will execute only non-cloud sites
34 block: # block specifies execution of tasks within, based on conditions
35 - name: Add a new tenant
36 cisco.aci.aci_tenant:
37 <<: *aci_info
38 tenant: ansible_tenant
39 description: Ansible tenant
40 state: present
41
42 - name: Add a new L2Out
43 cisco.aci.aci_l2out:
44 <<: *aci_info
45 tenant: ansible_tenant
46 l2out: ansible_l2out
47 description: Test deployment
48 bd: ansible_bd
49 domain: l2Dom
50 vlan: 3200
51 state: present
52 register: add_l2out
53
54 - name: Verify add_l2out
55 ansible.builtin.assert:
56 that:
57 - add_l2out.current.0.l2extOut.attributes.dn == "uni/tn-ansible_tenant/l2out-ansible_l2out"
58 - add_l2out.current.0.l2extOut.attributes.name == "ansible_l2out"
59 - add_l2out.current.0.l2extOut.attributes.annotation == 'orchestrator:ansible'
60
61 - name: Add the L2Out again
62 cisco.aci.aci_l2out:
63 <<: *aci_info
64 tenant: ansible_tenant
65 l2out: ansible_l2out
66 description: Test deployment
67 bd: ansible_bd
68 domain: l2Dom
69 vlan: 3200
70 state: present
71 register: add_l2out_again
72
73 - name: Verify add_l2out_again
74 ansible.builtin.assert:
75 that:
76 - add_l2out_again is not changed
77
78 - name: Add a new L2Out
79 cisco.aci.aci_l2out:
80 <<: *aci_info
81 tenant: ansible_tenant
82 l2out: ansible_l2out_2
83 description: Test deployment
84 bd: ansible_bd
85 domain: l2Dom
86 vlan: 3200
87 state: present
88 register: add_l2out_2
89
90 - name: Verify add_l2out_2
91 ansible.builtin.assert:
92 that:
93 - add_l2out_2.current.0.l2extOut.attributes.dn == "uni/tn-ansible_tenant/l2out-ansible_l2out_2"
94 - add_l2out_2.current.0.l2extOut.attributes.name == "ansible_l2out_2"
95
96 - name: Query the L2Out
97 cisco.aci.aci_l2out:
98 <<: *aci_info
99 tenant: ansible_tenant
100 l2out: ansible_l2out
101 state: query
102 register: query_l2out
103
104 - name: Verify query_l2out
105 ansible.builtin.assert:
106 that:
107 - query_l2out is not changed
108 - query_l2out.current.0.l2extOut.attributes.dn == "uni/tn-ansible_tenant/l2out-ansible_l2out"
109 - query_l2out.current.0.l2extOut.attributes.name == "ansible_l2out"
110
111 - name: Query all l2outs under a specific tenant
112 cisco.aci.aci_l2out:
113 <<: *aci_info
114 tenant: ansible_tenant
115 state: query
116 register: query_l2out_all
117
118 - name: Verify query_l2out_all
119 ansible.builtin.assert:
120 that:
121 - query_l2out_all is not changed
122
123 - name: Remove the L2Out
124 cisco.aci.aci_l2out:
125 <<: *aci_info
126 tenant: ansible_tenant
127 l2out: ansible_l2out
128 state: absent
129 register: remove_l2out
130
131 - name: Verify remove_l2out
132 ansible.builtin.assert:
133 that:
134 - remove_l2out is changed
135 - remove_l2out.previous.0.l2extOut.attributes.dn == "uni/tn-ansible_tenant/l2out-ansible_l2out"
136 - remove_l2out.previous.0.l2extOut.attributes.name == "ansible_l2out"