summaryrefslogtreecommitdiffstats
path: root/ansible_collections/azure/azcollection/tests/integration/targets/azure_rm_postgresqlflexibleserver/tasks/main.yml
blob: 2add54e1e00941302e650a69b4bcb7f3c798bcaf (plain)
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
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
- name: Prepare random number
  ansible.builtin.set_fact:
    rpfx: "{{ resource_group | hash('md5') | truncate(8, True, '') }}"
    new_resource_group: "{{ resource_group }}-02"
  run_once: true

- name: Create a new resource group
  azure_rm_resourcegroup:
    name: "{{ new_resource_group }}"
    location: southeastasia

- name: Create post gresql flexible server (check mode)
  azure_rm_postgresqlflexibleserver:
    resource_group: "{{ new_resource_group }}"
    name: postflexible{{ rpfx }}
    sku:
      name: Standard_B1ms
      tier: Burstable
    administrator_login: azureuser
    administrator_login_password: Fred@0329
    version: 12
    storage:
      storage_size_gb: 128
    fully_qualified_domain_name: st-private-dns-zone.postgres.database.azure.com
    backup:
      backup_retention_days: 7
      geo_redundant_backup: Disabled
    network:
      public_network_access: Disabled
    maintenance_window:
      custom_window: Enabled
      start_hour: 8
      start_minute: 4
      day_of_week: 3
    availability_zone: 2
    create_mode: Create
  check_mode: true

- name: Create post gresql flexible server
  azure_rm_postgresqlflexibleserver:
    resource_group: "{{ new_resource_group }}"
    name: postflexible{{ rpfx }}
    sku:
      name: Standard_B1ms
      tier: Burstable
    administrator_login: azureuser
    administrator_login_password: Fred@0329
    version: 12
    storage:
      storage_size_gb: 128
    fully_qualified_domain_name: st-private-dns-zone.postgres.database.azure.com
    backup:
      backup_retention_days: 7
      geo_redundant_backup: Disabled
    network:
      public_network_access: Disabled
    maintenance_window:
      custom_window: Enabled
      start_hour: 8
      start_minute: 4
      day_of_week: 3
    availability_zone: 2
    create_mode: Create
  register: output

- name: Assert the post grep sql server create success
  ansible.builtin.assert:
    that:
      - output.changed

- name: Create post gresql flexible server (Idempotent Test)
  azure_rm_postgresqlflexibleserver:
    resource_group: "{{ new_resource_group }}"
    name: postflexible{{ rpfx }}
    sku:
      name: Standard_B1ms
      tier: Burstable
    administrator_login: azureuser
    administrator_login_password: Fred@0329
    version: 12
    storage:
      storage_size_gb: 128
    fully_qualified_domain_name: st-private-dns-zone.postgres.database.azure.com
    backup:
      backup_retention_days: 7
      geo_redundant_backup: Disabled
    network:
      public_network_access: Disabled
    maintenance_window:
      custom_window: Enabled
      start_hour: 8
      start_minute: 4
      day_of_week: 3
    availability_zone: 2
    create_mode: Create
  register: output

- name: Assert the post grep sql server create success
  ansible.builtin.assert:
    that:
      - not output.changed

- name: Update post gresql flexible server with multiple parameters
  azure_rm_postgresqlflexibleserver:
    resource_group: "{{ new_resource_group }}"
    name: postflexible{{ rpfx }}
    sku:
      name: Standard_B1ms
      tier: Burstable
    administrator_login: azureuser
    administrator_login_password: Fred@0329
    version: 12
    storage:
      storage_size_gb: 256
    fully_qualified_domain_name: st-private-dns-zone.postgres.database.azure.com
    backup:
      backup_retention_days: 7
      geo_redundant_backup: Disabled
    network:
      public_network_access: Disabled
    maintenance_window:
      custom_window: Enabled
      start_hour: 10
      start_minute: 6
      day_of_week: 6
    availability_zone: 2
    create_mode: Create
    tags:
      key1: value1
      key2: value2
  register: output

- name: Assert the post grep sql server update success
  ansible.builtin.assert:
    that:
      - output.changed

- name: Gather facts postgresql flexible Server
  azure_rm_postgresqlflexibleserver_info:
    resource_group: "{{ new_resource_group }}"
    name: postflexible{{ rpfx }}
  register: output

- name: Assert the post gresql server is well created
  ansible.builtin.assert:
    that:
      - output.servers[0].tags | length == 2
      - output.servers[0].storage.storage_size_gb == 256
      - output.servers[0].maintenance_window.custom_window == 'Enabled'
      - output.servers[0].maintenance_window.day_of_week == 6
      - output.servers[0].maintenance_window.start_hour == 10
      - output.servers[0].maintenance_window.start_minute == 6

- name: Create a post gresql flexible database(check mode)
  azure_rm_postgresqlflexibledatabase:
    resource_group: "{{ new_resource_group }}"
    server_name: postflexible{{ rpfx }}
    name: database{{ rpfx }}
    collation: en_US.utf8
    charset: UTF8
  check_mode: true

- name: Create a post gresql flexible database
  azure_rm_postgresqlflexibledatabase:
    resource_group: "{{ new_resource_group }}"
    server_name: postflexible{{ rpfx }}
    name: database{{ rpfx }}
    collation: en_US.utf8
    charset: UTF8
  register: output

- name: Assert the post gresql flexible database created success
  ansible.builtin.assert:
    that:
      - output.changed

- name: Create a post gresql flexible database(Idempotent test)
  azure_rm_postgresqlflexibledatabase:
    resource_group: "{{ new_resource_group }}"
    server_name: postflexible{{ rpfx }}
    name: database{{ rpfx }}
    collation: en_US.utf8
    charset: UTF8
  register: output

- name: Assert the post gresql flexible database no changed
  ansible.builtin.assert:
    that:
      - not output.changed

- name: Get the post gresql flexibe database facts
  azure_rm_postgresqlflexibledatabase_info:
    resource_group: "{{ new_resource_group }}"
    server_name: postflexible{{ rpfx }}
    name: database{{ rpfx }}
  register: output

- name: Assert the post gresql flexible database facts
  ansible.builtin.assert:
    that:
      - output.databases[0].collation == 'en_US.utf8'
      - output.databases[0].charset == 'UTF8'

- name: Delete the post gresql flexibe database
  azure_rm_postgresqlflexibledatabase:
    resource_group: "{{ new_resource_group }}"
    server_name: postflexible{{ rpfx }}
    name: database{{ rpfx }}
    state: absent
  register: output

- name: Assert the post gresql flexible database deleted
  ansible.builtin.assert:
    that:
      - output.changed

- name: Create a post gresql flexible firwall rule (Check mode)
  azure_rm_postgresqlflexiblefirewallrule:
    resource_group: "{{ new_resource_group }}"
    server_name: postflexible{{ rpfx }}
    name: firewall{{ rpfx }}
    start_ip_address: 10.0.0.15
    end_ip_address: 10.0.0.20
  check_mode: true

- name: Create the post gresql flexible firwall rule
  azure_rm_postgresqlflexiblefirewallrule:
    resource_group: "{{ new_resource_group }}"
    server_name: postflexible{{ rpfx }}
    name: firewall{{ rpfx }}
    start_ip_address: 10.0.0.15
    end_ip_address: 10.0.0.20
  register: output

- name: Assert the post grepsql flexible firewall rule created well
  ansible.builtin.assert:
    that:
      - output.changed

- name: Create the post gresql flexible firwall rule (Idempotent test)
  azure_rm_postgresqlflexiblefirewallrule:
    resource_group: "{{ new_resource_group }}"
    server_name: postflexible{{ rpfx }}
    name: firewall{{ rpfx }}
    start_ip_address: 10.0.0.15
    end_ip_address: 10.0.0.20
  register: output

- name: Assert the post grepsql flexible firewall rule support idempotent test
  ansible.builtin.assert:
    that:
      - not output.changed

- name: Update the post gresql flexible firwall rule
  azure_rm_postgresqlflexiblefirewallrule:
    resource_group: "{{ new_resource_group }}"
    server_name: postflexible{{ rpfx }}
    name: firewall{{ rpfx }}
    start_ip_address: 10.0.0.16
    end_ip_address: 10.0.0.18
  register: output

- name: Assert the post grepsql flexible server update well
  ansible.builtin.assert:
    that:
      - output.changed

- name: Get the post gresql flexible firwall rule facts
  azure_rm_postgresqlflexiblefirewallrule_info:
    resource_group: "{{ new_resource_group }}"
    server_name: postflexible{{ rpfx }}
    name: firewall{{ rpfx }}
  register: output

- name: Assert the post gresql flexible firewall rule facts
  ansible.builtin.assert:
    that:
      - output.firewall_rules[0].start_ip_address == '10.0.0.16'
      - output.firewall_rules[0].end_ip_address == '10.0.0.18'

- name: Delete the post gresql flexible firwall rule
  azure_rm_postgresqlflexiblefirewallrule:
    resource_group: "{{ new_resource_group }}"
    server_name: postflexible{{ rpfx }}
    name: firewall{{ rpfx }}
    state: absent
  register: output

- name: Assert the post grepsql flexible server delete well
  ansible.builtin.assert:
    that:
      - output.changed

- name: List the post gresql flexible config facts
  azure_rm_postgresqlflexibleconfiguration_info:
    resource_group: "{{ new_resource_group }}"
    server_name: postflexible{{ rpfx }}
  register: output

- name: Assert the post gresql flexible server configuration
  ansible.builtin.assert:
    that:
      - output.settings | length > 0

- name: Stop the post gresql flexible server
  azure_rm_postgresqlflexibleserver:
    resource_group: "{{ new_resource_group }}"
    name: postflexible{{ rpfx }}
    is_stop: true
  register: output

- name: Assert the post grep sql server stop success
  ansible.builtin.assert:
    that:
      - output.changed

- name: Pause for 10 mimutes
  ansible.builtin.pause:
    minutes: 10
  changed_when: true

- name: Restart post gresql flexible server
  azure_rm_postgresqlflexibleserver:
    resource_group: "{{ new_resource_group }}"
    name: postflexible{{ rpfx }}
    is_restart: true
  register: output

- name: Assert the post grep sql server restart success
  ansible.builtin.assert:
    that:
      - output.changed

- name: Delete post gresql flexible server
  azure_rm_postgresqlflexibleserver:
    resource_group: "{{ new_resource_group }}"
    name: postflexible{{ rpfx }}
    state: absent
  register: output

- name: Assert the post gresql server is well deleted
  ansible.builtin.assert:
    that:
      - output.changed

- name: Delete the new resource group
  azure_rm_resourcegroup:
    name: "{{ new_resource_group }}"
    force_delete_nonempty: true
    state: absent
  register: output

- name: Assert the resource group is well deleted
  ansible.builtin.assert:
    that:
      - output.changed