forked from scicore-unibas-ch/ansible-modules-guacamole
-
Notifications
You must be signed in to change notification settings - Fork 1
/
test-collection.yml
250 lines (221 loc) · 8.93 KB
/
test-collection.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
---
- name: Testing the Guacamole collection
hosts: localhost
vars:
local_guacamole_url: "http://localhost:8080/guacamole"
local_guacamole_user: "guacadmin"
local_guacamole_password: "guacadmin"
tasks:
- name: Add a new RDP connection
scicore.guacamole.guacamole_connection:
base_url: "{{ local_guacamole_url }}"
auth_username: "{{ local_guacamole_user }}"
auth_password: "{{ local_guacamole_password }}"
connection_name: test_connection_rdp
protocol: rdp
hostname: 192.168.33.43
port: 3389
username: rdp_user
password: rdp_pass
max_connections: 1
register: _add_connection
- name: Verify that the connection has been created
assert:
that:
- _add_connection.connection_info.name == 'test_connection_rdp'
- _add_connection.connection_info.parentIdentifier == 'ROOT'
success_msg: "Connection created"
fail_msg: "Failed creating a connection"
- name: Update a RDP connection
scicore.guacamole.guacamole_connection:
base_url: "{{ local_guacamole_url }}"
auth_username: "{{ local_guacamole_user }}"
auth_password: "{{ local_guacamole_password }}"
connection_name: test_connection_rdp
protocol: rdp
hostname: 192.168.33.43
port: 3389
username: rdp_user
password: rdp_pass
max_connections: 10
register: _update_connection
- name: Verify that the connection has been updated
assert:
that:
- _update_connection.changed
- _update_connection.connection_info.attributes.get('max-connections') == '10'
success_msg: "Connection updated"
fail_msg: "Failed updating a connection"
- name: Add a new guacamole user and grant access to 'test_connection_rdp'
scicore.guacamole.guacamole_user:
base_url: "{{ local_guacamole_url }}"
auth_username: "{{ local_guacamole_user }}"
auth_password: "{{ local_guacamole_password }}"
username: test_user_1
password: aaaaaaaa
full_name: "John"
email: "[email protected]"
organization: "scicore"
allowed_connections:
- test_connection_rdp
register: _add_user
- name: Verify that the user has been created
assert:
that:
- _add_user.user_info.username == 'test_user_1'
success_msg: "User created"
fail_msg: "Failed creating a user"
- name: Update existing user
scicore.guacamole.guacamole_user:
base_url: "{{ local_guacamole_url }}"
auth_username: "{{ local_guacamole_user }}"
auth_password: "{{ local_guacamole_password }}"
username: test_user_1
password: aaaaaaaa
full_name: "Bob"
email: "[email protected]"
organization: "scicore"
allowed_connections:
- test_connection_rdp
register: _update_user
- name: Verify that the user has been updated
assert:
that:
- _update_user.user_info.attributes.get('guac-full-name') == 'Bob'
success_msg: "User created"
fail_msg: "Failed creating a user"
- name: Add a new connections group
scicore.guacamole.guacamole_connections_group:
base_url: "{{ local_guacamole_url }}"
auth_username: "{{ local_guacamole_user }}"
auth_password: "{{ local_guacamole_password }}"
group_name: group_test
register: _add_group
- name: Verify that the connections group has been created
assert:
that:
- _add_group.connections_group_info.name == 'group_test'
- _add_group.connections_group_info.parentIdentifier == 'ROOT'
success_msg: "Connections group created"
fail_msg: "Failed creating a connections group"
- name: Update a connections group
scicore.guacamole.guacamole_connections_group:
base_url: "{{ local_guacamole_url }}"
auth_username: "{{ local_guacamole_user }}"
auth_password: "{{ local_guacamole_password }}"
group_name: group_test
max_connections: 10
register: _update_group
- name: Verify that the connections group has been updated
assert:
that:
- _update_group.changed
- _update_group.connections_group_info.attributes.get('max-connections') == '10'
success_msg: "Connections group updated"
fail_msg: "Failed updating a connections group"
- name: Add a child connections group
scicore.guacamole.guacamole_connections_group:
base_url: "{{ local_guacamole_url }}"
auth_username: "{{ local_guacamole_user }}"
auth_password: "{{ local_guacamole_password }}"
group_name: group_test_child
parent_group: group_test
register: _add_child_group
- name: Verify that the child connections group has been created
assert:
that:
- _add_child_group.connections_group_info.name == 'group_test_child'
- _add_child_group.connections_group_info.parentIdentifier == _add_group.connections_group_info.identifier
success_msg: "Child connections group created"
fail_msg: "Failed creating a child connections group"
- name: Add a connection in the child connections group
scicore.guacamole.guacamole_connection:
base_url: "{{ local_guacamole_url }}"
auth_username: "{{ local_guacamole_user }}"
auth_password: "{{ local_guacamole_password }}"
connection_name: test_connection_2
protocol: vnc
hostname: 192.168.33.44
port: 5901
username: vnc_user
password: vnc_pass
group_name: group_test
register: _add_child_connection
- name: Verify that the connection in the child connections group has been created
assert:
that:
- _add_child_connection.connection_info.name == 'test_connection_2'
- _add_child_connection.connection_info.parentIdentifier == _add_group.connections_group_info.identifier
success_msg: "Child connection created"
fail_msg: "Failed creating a child connection"
- name: Force deletion of group of connections
scicore.guacamole.guacamole_connections_group:
base_url: "{{ local_guacamole_url }}"
auth_username: "{{ local_guacamole_user }}"
auth_password: "{{ local_guacamole_password }}"
group_name: group_test_child
state: absent
force_deletion: true
register: _delete_group
- name: Verify that the child connections group has been deleted
assert:
that:
- _delete_group.changed
- _delete_group.connections_group_info.name == 'group_test_child'
success_msg: "Child connections group deleted"
fail_msg: "Failed deleting a child connections group"
- name: Delete a user
scicore.guacamole.guacamole_user:
base_url: "{{ local_guacamole_url }}"
auth_username: "{{ local_guacamole_user }}"
auth_password: "{{ local_guacamole_password }}"
username: test_user_1
state: absent
register: _delete_user
- name: Verify that the user has been deleted
assert:
that: _delete_user.changed
success_msg: "User deleted"
fail_msg: "Failed deleting a user"
- name: Delete a connection
scicore.guacamole.guacamole_connection:
base_url: "{{ local_guacamole_url }}"
auth_username: "{{ local_guacamole_user }}"
auth_password: "{{ local_guacamole_password }}"
connection_name: test_connection_2
state: absent
register: _delete_connection
- name: Verify that the connection has been deleted
assert:
that: _delete_connection.changed
success_msg: "Connection deleted"
fail_msg: "Failed deleting a connection"
- name: Delete a connections group
scicore.guacamole.guacamole_connections_group:
base_url: "{{ local_guacamole_url }}"
auth_username: "{{ local_guacamole_user }}"
auth_password: "{{ local_guacamole_password }}"
group_name: group_test
state: absent
register: _delete_group
- name: Verify that the connections group has been deleted
assert:
that:
- _delete_group.changed
- _delete_group.connections_group_info.name == 'group_test'
success_msg: "Connections group deleted"
fail_msg: "Failed deleting a connections group"
- name: Update password guacadmin user
scicore.guacamole.guacamole_user:
base_url: "{{ local_guacamole_url }}"
auth_username: "{{ local_guacamole_user }}"
auth_password: "{{ local_guacamole_password }}"
username: guacadmin
password: newpassword
- name: Update password guacadmin user again
scicore.guacamole.guacamole_user:
base_url: "{{ local_guacamole_url }}"
auth_username: "{{ local_guacamole_user }}"
auth_password: newpassword
username: guacadmin
password: "{{ local_guacamole_password }}"