| 1 |
--- |
| 2 |
- name: Rds_instance / upgrade integration tests |
| 3 |
|
| 4 |
module_defaults: |
| 5 |
group/aws: |
| 6 |
access_key: "{{ aws_access_key }}" |
| 7 |
secret_key: "{{ aws_secret_key }}" |
| 8 |
session_token: "{{ security_token | default(omit) }}" |
| 9 |
region: "{{ aws_region }}" |
| 10 |
|
| 11 |
block: |
| 12 |
- name: Ensure the resource doesn't exist |
| 13 |
amazon.aws.rds_instance: |
| 14 |
id: "{{ instance_id }}" |
| 15 |
state: absent |
| 16 |
skip_final_snapshot: true |
| 17 |
register: result |
| 18 |
|
| 19 |
- ansible.builtin.assert: |
| 20 |
that: |
| 21 |
- not result.changed |
| 22 |
ignore_errors: true |
| 23 |
|
| 24 |
- name: Create a mariadb instance |
| 25 |
amazon.aws.rds_instance: |
| 26 |
id: "{{ instance_id }}" |
| 27 |
state: present |
| 28 |
engine: mariadb |
| 29 |
engine_version: "{{ mariadb_engine_version }}" |
| 30 |
allow_major_version_upgrade: true |
| 31 |
username: "{{ username }}" |
| 32 |
password: "{{ password }}" |
| 33 |
db_instance_class: "{{ db_instance_class }}" |
| 34 |
allocated_storage: "{{ allocated_storage }}" |
| 35 |
register: result |
| 36 |
|
| 37 |
- ansible.builtin.assert: |
| 38 |
that: |
| 39 |
- result.changed |
| 40 |
- result.db_instance_identifier == instance_id |
| 41 |
|
| 42 |
# Test upgrade of DB instance |
| 43 |
|
| 44 |
- name: Upgrade a mariadb instance - check_mode |
| 45 |
amazon.aws.rds_instance: |
| 46 |
id: "{{ instance_id }}" |
| 47 |
state: present |
| 48 |
engine: mariadb |
| 49 |
engine_version: "{{ mariadb_engine_version_2 }}" |
| 50 |
allow_major_version_upgrade: true |
| 51 |
username: "{{ username }}" |
| 52 |
password: "{{ password }}" |
| 53 |
db_instance_class: "{{ db_instance_class }}" |
| 54 |
allocated_storage: "{{ allocated_storage }}" |
| 55 |
apply_immediately: true |
| 56 |
register: result |
| 57 |
check_mode: true |
| 58 |
|
| 59 |
- ansible.builtin.assert: |
| 60 |
that: |
| 61 |
- result.changed |
| 62 |
|
| 63 |
- name: Upgrade a mariadb instance |
| 64 |
amazon.aws.rds_instance: |
| 65 |
id: "{{ instance_id }}" |
| 66 |
state: present |
| 67 |
engine: mariadb |
| 68 |
engine_version: "{{ mariadb_engine_version_2 }}" |
| 69 |
allow_major_version_upgrade: true |
| 70 |
username: "{{ username }}" |
| 71 |
password: "{{ password }}" |
| 72 |
db_instance_class: "{{ db_instance_class }}" |
| 73 |
allocated_storage: "{{ allocated_storage }}" |
| 74 |
apply_immediately: true |
| 75 |
register: result |
| 76 |
|
| 77 |
- ansible.builtin.assert: |
| 78 |
that: |
| 79 |
- result.changed |
| 80 |
- '"engine_version" in result.pending_modified_values or result.engine_version == mariadb_engine_version_2' |
| 81 |
|
| 82 |
- name: Idempotence upgrading a mariadb instance - check_mode |
| 83 |
amazon.aws.rds_instance: |
| 84 |
id: "{{ instance_id }}" |
| 85 |
state: present |
| 86 |
engine: mariadb |
| 87 |
engine_version: "{{ mariadb_engine_version_2 }}" |
| 88 |
allow_major_version_upgrade: true |
| 89 |
username: "{{ username }}" |
| 90 |
password: "{{ password }}" |
| 91 |
db_instance_class: "{{ db_instance_class }}" |
| 92 |
allocated_storage: "{{ allocated_storage }}" |
| 93 |
register: result |
| 94 |
check_mode: true |
| 95 |
|
| 96 |
### Specifying allow_major_version_upgrade with check_mode will always result in changed=True |
| 97 |
### since it's not returned in describe_db_instances api call |
| 98 |
# - assert: |
| 99 |
# that: |
| 100 |
# - not result.changed |
| 101 |
|
| 102 |
- name: Idempotence upgrading a mariadb instance |
| 103 |
amazon.aws.rds_instance: |
| 104 |
id: "{{ instance_id }}" |
| 105 |
state: present |
| 106 |
engine: mariadb |
| 107 |
engine_version: "{{ mariadb_engine_version_2 }}" |
| 108 |
allow_major_version_upgrade: true |
| 109 |
username: "{{ username }}" |
| 110 |
password: "{{ password }}" |
| 111 |
db_instance_class: "{{ db_instance_class }}" |
| 112 |
allocated_storage: "{{ allocated_storage }}" |
| 113 |
register: result |
| 114 |
|
| 115 |
- ansible.builtin.assert: |
| 116 |
that: |
| 117 |
- not result.changed |
| 118 |
- '"engine_version" in result.pending_modified_values or result.engine_version == mariadb_engine_version_2' |
| 119 |
|
| 120 |
always: |
| 121 |
- name: Delete the instance |
| 122 |
amazon.aws.rds_instance: |
| 123 |
id: "{{ instance_id }}" |
| 124 |
state: absent |
| 125 |
skip_final_snapshot: true |
| 126 |
wait: false |
| 127 |
ignore_errors: true |