Debian Codegraph @

ansible_collections/amazon/aws/tests/integration/targets/rds_cluster_modify/tasks/main.yaml

raw
1 ---
2 - module_defaults:
3 group/aws:
4 region: "{{ aws_region }}"
5 access_key: "{{ aws_access_key }}"
6 secret_key: "{{ aws_secret_key }}"
7 session_token: "{{ security_token | default(omit) }}"
8 block:
9 # Disabled: Below tests require use of more than 1 region, not supported by CI at the moment
10 # Tests have been ran, tested, and verified locally on us-west-2 (primary), eu-north-1 (replica)
11 # - name: Run tests for testing remove cluster from global db
12 # import_tasks: remove_from_global_db.yaml
13
14 - name: Run tests for testing serverless v2 scaling configuration
15 ansible.builtin.import_tasks: create_update_cluster_serverless_v2_scaling_configuration.yaml
16 - name: Ensure the resource doesn't exist
17 amazon.aws.rds_cluster:
18 id: "{{ cluster_id }}"
19 state: absent
20 engine: "{{ engine }}"
21 username: "{{ username }}"
22 password: "{{ password }}"
23 skip_final_snapshot: true
24 register: _result_delete_db_cluster
25
26 - ansible.builtin.assert:
27 that:
28 - not _result_delete_db_cluster.changed
29 ignore_errors: true
30
31 # Follow up to Aurora Serverless V2 release, we use an aurora-mysql to
32 # avoid the following error when we try to adjust the port:
33 # You currently can't modify EndpointPort with Aurora Serverless.
34 - name: Create an Aurora-MySQL DB cluster
35 amazon.aws.rds_cluster:
36 id: "{{ cluster_id }}"
37 state: present
38 engine: aurora-mysql
39 engine_mode: provisioned
40 username: "{{ username }}"
41 password: "{{ password }}"
42 register: _result_create_source_db_cluster
43
44 - ansible.builtin.assert:
45 that:
46 - _result_create_source_db_cluster.changed
47 - _result_create_source_db_cluster.changed
48 - "'allocated_storage' in _result_create_source_db_cluster"
49 - _result_create_source_db_cluster.allocated_storage == 1
50 - "'cluster_create_time' in _result_create_source_db_cluster"
51 - _result_create_source_db_cluster.copy_tags_to_snapshot == false
52 - "'db_cluster_arn' in _result_create_source_db_cluster"
53 - _result_create_source_db_cluster.db_cluster_identifier == cluster_id
54 - "'db_cluster_parameter_group' in _result_create_source_db_cluster"
55 - "'db_cluster_resource_id' in _result_create_source_db_cluster"
56 - "'endpoint' in _result_create_source_db_cluster"
57 - "'engine' in _result_create_source_db_cluster"
58 - _result_create_source_db_cluster.engine == "aurora-mysql"
59 - "'engine_mode' in _result_create_source_db_cluster"
60 - _result_create_source_db_cluster.engine_mode == "provisioned"
61 - "'engine_version' in _result_create_source_db_cluster"
62 - "'master_username' in _result_create_source_db_cluster"
63 - _result_create_source_db_cluster.master_username == username
64 - "'port' in _result_create_source_db_cluster"
65 - _result_create_source_db_cluster.port == db_port
66 - "'status' in _result_create_source_db_cluster"
67 - _result_create_source_db_cluster.status == "available"
68 - "'tags' in _result_create_source_db_cluster"
69 - "'vpc_security_groups' in _result_create_source_db_cluster"
70
71 - name: Modify DB cluster password
72 amazon.aws.rds_cluster:
73 id: "{{ cluster_id }}"
74 state: present
75 password: "{{ new_password }}"
76 force_update_password: true
77 apply_immediately: true
78 register: _result_modify_password
79
80 - ansible.builtin.assert:
81 that:
82 - _result_modify_password.changed
83 - "'allocated_storage' in _result_modify_password"
84 - _result_modify_password.allocated_storage == 1
85 - "'cluster_create_time' in _result_modify_password"
86 - _result_modify_password.copy_tags_to_snapshot == false
87 - "'db_cluster_arn' in _result_modify_password"
88 - _result_modify_password.db_cluster_identifier == cluster_id
89 - "'db_cluster_parameter_group' in _result_modify_password"
90 - "'db_cluster_resource_id' in _result_modify_password"
91 - "'endpoint' in _result_modify_password"
92 - "'engine' in _result_modify_password"
93 - _result_modify_password.engine == "aurora-mysql"
94 - "'engine_mode' in _result_modify_password"
95 - _result_modify_password.engine_mode == "provisioned"
96 - "'engine_version' in _result_modify_password"
97 - "'master_username' in _result_modify_password"
98 - _result_modify_password.master_username == username
99 - "'port' in _result_create_source_db_cluster"
100 - _result_modify_password.port == db_port
101 - "'status' in _result_modify_password"
102 - _result_modify_password.status == "available"
103 - "'tags' in _result_modify_password"
104 - "'vpc_security_groups' in _result_modify_password"
105
106 - name: Modify DB cluster port
107 amazon.aws.rds_cluster:
108 id: "{{ cluster_id }}"
109 state: present
110 port: "{{ new_port }}"
111 register: _result_modify_port
112
113 - ansible.builtin.assert:
114 that:
115 - _result_modify_port.changed
116 - "'allocated_storage' in _result_modify_port"
117 - _result_modify_port.allocated_storage == 1
118 - "'cluster_create_time' in _result_modify_port"
119 - _result_modify_port.copy_tags_to_snapshot == false
120 - "'db_cluster_arn' in _result_modify_port"
121 - _result_modify_port.db_cluster_identifier == cluster_id
122 - "'db_cluster_parameter_group' in _result_modify_port"
123 - "'db_cluster_resource_id' in _result_modify_port"
124 - "'endpoint' in _result_modify_port"
125 - "'engine' in _result_modify_port"
126 - _result_modify_port.engine == "aurora-mysql"
127 - "'engine_mode' in _result_modify_port"
128 - _result_modify_port.engine_mode == "provisioned"
129 - "'engine_version' in _result_modify_port"
130 - "'master_username' in _result_modify_port"
131 - _result_modify_port.master_username == username
132 - "'port' in _result_modify_port"
133 - _result_modify_port.port == new_port
134 - "'status' in _result_modify_port"
135 - _result_modify_port.status == "available"
136 - "'tags' in _result_modify_port"
137 - "'vpc_security_groups' in _result_modify_port"
138
139 - name: Modify DB cluster identifier
140 amazon.aws.rds_cluster:
141 id: "{{ cluster_id }}"
142 state: present
143 purge_tags: false
144 new_cluster_id: "{{ new_cluster_id }}"
145 apply_immediately: true
146 register: _result_modify_id
147
148 - ansible.builtin.assert:
149 that:
150 - _result_modify_id.changed
151 - "'allocated_storage' in _result_modify_id"
152 - _result_modify_id.allocated_storage == 1
153 - "'cluster_create_time' in _result_modify_id"
154 - _result_modify_id.copy_tags_to_snapshot == false
155 - "'db_cluster_arn' in _result_modify_id"
156 - _result_modify_id.db_cluster_identifier == new_cluster_id
157 - "'db_cluster_parameter_group' in _result_modify_id"
158 - "'db_cluster_resource_id' in _result_modify_id"
159 - "'endpoint' in _result_modify_id"
160 - "'engine' in _result_modify_id"
161 - _result_modify_id.engine == "aurora-mysql"
162 - "'engine_mode' in _result_modify_id"
163 - _result_modify_id.engine_mode == "provisioned"
164 - "'engine_version' in _result_modify_id"
165 - "'master_username' in _result_modify_id"
166 - _result_modify_id.master_username == username
167 - "'port' in _result_modify_id"
168 - _result_modify_id.port == new_port
169 - "'status' in _result_modify_id"
170 - _result_modify_id.status == "available"
171 - "'tags' in _result_modify_id"
172 - "'vpc_security_groups' in _result_modify_id"
173
174 - name: Create DB cluster parameter group if not exists
175 amazon.aws.rds_cluster_param_group:
176 name: "{{ new_db_parameter_group_name }}"
177 state: present
178 db_parameter_group_family: aurora-mysql8.0
179 description: "Test DB cluster parameter group"
180 register: _result_create_db_parameter_group
181
182 - name: Check param group was successfully created
183 ansible.builtin.assert:
184 that:
185 - _result_create_db_parameter_group is changed
186
187 - name: Modify DB cluster parameter group
188 amazon.aws.rds_cluster:
189 id: "{{ new_cluster_id }}"
190 state: present
191 db_cluster_parameter_group_name: "{{ new_db_parameter_group_name }}"
192 apply_immediately: true
193 register: _result_modify_db_parameter_group_name
194
195 - ansible.builtin.assert:
196 that:
197 - _result_modify_db_parameter_group_name.changed
198 - "'allocated_storage' in _result_modify_db_parameter_group_name"
199 - _result_modify_db_parameter_group_name.allocated_storage == 1
200 - "'cluster_create_time' in _result_modify_db_parameter_group_name"
201 - _result_modify_db_parameter_group_name.copy_tags_to_snapshot == false
202 - "'db_cluster_arn' in _result_modify_db_parameter_group_name"
203 - _result_modify_db_parameter_group_name.db_cluster_identifier == new_cluster_id
204 - "'db_cluster_parameter_group' in _result_modify_db_parameter_group_name"
205 - "'db_cluster_resource_id' in _result_modify_db_parameter_group_name"
206 - "'endpoint' in _result_modify_db_parameter_group_name"
207 - "'engine' in _result_modify_db_parameter_group_name"
208 - _result_modify_db_parameter_group_name.engine == "aurora-mysql"
209 - "'engine_mode' in _result_modify_db_parameter_group_name"
210 - _result_modify_db_parameter_group_name.engine_mode == "provisioned"
211 - "'engine_version' in _result_modify_db_parameter_group_name"
212 - "'master_username' in _result_modify_db_parameter_group_name"
213 - _result_modify_db_parameter_group_name.master_username == username
214 - "'port' in _result_modify_db_parameter_group_name"
215 - _result_modify_db_parameter_group_name.db_cluster_parameter_group == new_db_parameter_group_name
216 - "'status' in _result_modify_db_parameter_group_name"
217 - _result_modify_db_parameter_group_name.status == "available"
218 - "'tags' in _result_modify_db_parameter_group_name"
219 - "'vpc_security_groups' in _result_modify_db_parameter_group_name"
220
221 - name: Delete DB cluster without creating a final snapshot (CHECK MODE)
222 amazon.aws.rds_cluster:
223 state: absent
224 cluster_id: "{{ new_cluster_id }}"
225 skip_final_snapshot: true
226 register: _result_delete_cluster
227 check_mode: true
228
229 - ansible.builtin.assert:
230 that:
231 - _result_delete_cluster.changed
232
233 - name: Delete DB cluster without creating a final snapshot
234 amazon.aws.rds_cluster:
235 state: absent
236 cluster_id: "{{ new_cluster_id }}"
237 skip_final_snapshot: true
238 register: _result_delete_cluster
239
240 - ansible.builtin.assert:
241 that:
242 - _result_delete_cluster.changed
243
244 - name: Delete DB cluster without creating a final snapshot (idempotence)
245 amazon.aws.rds_cluster:
246 state: absent
247 cluster_id: "{{ new_cluster_id }}"
248 skip_final_snapshot: true
249 register: _result_delete_cluster
250
251 - ansible.builtin.assert:
252 that:
253 - not _result_delete_cluster.changed
254
255 always:
256 - name: Delete DB cluster without creating a final snapshot
257 amazon.aws.rds_cluster:
258 state: absent
259 cluster_id: "{{ cluster_id }}"
260 skip_final_snapshot: true
261 ignore_errors: true
262
263 - name: Create DB cluster parameter group if not exists
264 amazon.aws.rds_cluster_param_group:
265 name: "{{ new_db_parameter_group_name }}"
266 state: absent
267 ignore_errors: true # noqa: ignore-errors