Debian Codegraph @

ansible_collections/community/general/tests/integration/targets/one_vnet/tasks/main.yml

raw
1 ---
2 ####################################################################
3 # WARNING: These are designed specifically for Ansible tests #
4 # and should not be used as examples of how to write Ansible roles #
5 ####################################################################
6
7 # Copyright (c) Ansible Project
8 # GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
9 # SPDX-License-Identifier: GPL-3.0-or-later
10
11 # Create a new template
12 - name: Create a new network
13 one_vnet:
14 api_url: "{{ opennebula_url }}"
15 api_username: "{{ opennebula_username }}"
16 api_password: "{{ opennebula_password }}"
17 name: bridge-network
18 template: |
19 VN_MAD = "bridge"
20 BRIDGE = "br0"
21 BRIDGE_TYPE = "linux"
22 AR=[
23 TYPE = "IP4",
24 IP = "192.0.2.2",
25 SIZE = "20"
26 ]
27 DNS = "192.0.2.1"
28 GATEWAY = "192.0.2.1"
29 register: result
30
31 - name: Assert that network is created
32 assert:
33 that:
34 - result is changed
35
36
37 # Updating a network
38 - name: Update an existing network
39 one_vnet:
40 api_url: "{{ opennebula_url }}"
41 api_username: "{{ opennebula_username }}"
42 api_password: "{{ opennebula_password }}"
43 name: bridge-network
44 template: |
45 VN_MAD = "bridge"
46 BRIDGE = "br0"
47 BRIDGE_TYPE = "linux"
48 AR=[
49 TYPE = "IP4",
50 IP = "192.0.2.2",
51 SIZE = "20"
52 ]
53 DNS = "192.0.2.220"
54 GATEWAY = "192.0.2.1"
55 register: result
56
57 - name: Assert that network is changed
58 assert:
59 that:
60 - result is changed
61
62 # Testing idempotence using the same template as in previous task
63 - name: Update an existing network with the same changes again
64 one_vnet:
65 api_url: "{{ opennebula_url }}"
66 api_username: "{{ opennebula_username }}"
67 api_password: "{{ opennebula_password }}"
68 name: bridge-network
69 template: |
70 VN_MAD = "bridge"
71 BRIDGE = "br0"
72 BRIDGE_TYPE = "linux"
73 AR=[
74 TYPE = "IP4",
75 IP = "192.0.2.2",
76 SIZE = "20"
77 ]
78 DNS = "192.0.2.220"
79 GATEWAY = "192.0.2.1"
80 register: result
81
82 - name: Assert that network is not changed
83 assert:
84 that:
85 - result is not changed
86
87
88 # Deletion of networks
89 - name: Delete a nonexisting network
90 one_vnet:
91 api_url: "{{ opennebula_url }}"
92 api_username: "{{ opennebula_username }}"
93 api_password: "{{ opennebula_password }}"
94 name: i-do-not-exists
95 state: absent
96 register: result
97
98 - name: Assert that network is not changed
99 assert:
100 that:
101 - result is not changed
102
103 - name: Delete an existing network
104 one_vnet:
105 api_url: "{{ opennebula_url }}"
106 api_username: "{{ opennebula_username }}"
107 api_password: "{{ opennebula_password }}"
108 name: bridge-network
109 state: absent
110 register: result
111
112 - name: Assert that network was deleted
113 assert:
114 that:
115 - result is changed
116
117 # Trying to run with wrong arguments
118 - name: Try to create use network with state=present and without the template parameter
119 one_vnet:
120 api_url: "{{ opennebula_url }}"
121 api_username: "{{ opennebula_username }}"
122 api_password: "{{ opennebula_password }}"
123 name: bridge-network
124 state: present
125 register: result
126 ignore_errors: true
127
128 - name: Assert that it failed because network is missing
129 assert:
130 that:
131 - result is failed
132
133 - name: Try to create network with template but without specifying the name parameter
134 one_vnet:
135 api_url: "{{ opennebula_url }}"
136 api_username: "{{ opennebula_username }}"
137 api_password: "{{ opennebula_password }}"
138 id: 0
139 state: present
140 template: |
141 VN_MAD = "bridge"
142 BRIDGE = "br0"
143 BRIDGE_TYPE = "linux"
144 AR=[
145 TYPE = "IP4",
146 IP = "192.0.2.2",
147 SIZE = "20"
148 ]
149 DNS = "192.0.2.220"
150 GATEWAY = "192.0.2.1"
151 register: result
152 ignore_errors: true
153
154 - name: Assert that it failed because name is required for initial creation
155 assert:
156 that:
157 - result is failed
158
159 - name: Try to use both ID and name at the same time
160 one_vnet:
161 api_url: "{{ opennebula_url }}"
162 api_username: "{{ opennebula_username }}"
163 api_password: "{{ opennebula_password }}"
164 name:
165 id: 0
166 state: present
167 register: result
168 ignore_errors: true
169
170 - name: Assert that it failed because you can use only one at the time
171 assert:
172 that:
173 - result is failed