From 7b32ef0bcc8f40b6b0ef9c75067d2797d1f96762 Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Thu, 14 Apr 2022 14:53:56 +0000 Subject: [PATCH] ec2_asg: Change purge_tags default value to False (#1064) (#1069) [PR #1064/d0c9f1a6 backport][stable-3] ec2_asg: Change purge_tags default value to False This is a backport of PR #1064 as merged into main (d0c9f1a). SUMMARY Changed default value of purge_tags to False. With the addition of purge_tags to ec2_asg module #960, the default value was kept to True similar to many other modules in this collection and also as specified in ansible dev guide. With this addition, the issue was discovered that there is a possibility of this change breaking existing playbooks for users if they don't update their playbooks and specify purge_tags: false where required. This PR's change will prevent accidental breakage. ISSUE TYPE Bugfix Pull Request COMPONENT NAME ec2_asg Reviewed-by: Mark Chappell --- changelogs/fragments/1064-ec2_asg_change_purge_tags.yml | 2 ++ plugins/modules/ec2_asg.py | 4 ++-- .../targets/ec2_asg/roles/ec2_asg/tasks/tag_operations.yml | 7 ++++--- 3 files changed, 8 insertions(+), 5 deletions(-) create mode 100644 changelogs/fragments/1064-ec2_asg_change_purge_tags.yml diff --git a/changelogs/fragments/1064-ec2_asg_change_purge_tags.yml b/changelogs/fragments/1064-ec2_asg_change_purge_tags.yml new file mode 100644 index 00000000000..81324304b46 --- /dev/null +++ b/changelogs/fragments/1064-ec2_asg_change_purge_tags.yml @@ -0,0 +1,2 @@ +bugfixes: + - ec2_asg - Change the default value of ``purge_tags`` to ``false``. Restores previous behaviour (https://github.com/ansible-collections/community.aws/pull/1064). diff --git a/plugins/modules/ec2_asg.py b/plugins/modules/ec2_asg.py index fa91232cbe6..4ba2036e304 100644 --- a/plugins/modules/ec2_asg.py +++ b/plugins/modules/ec2_asg.py @@ -224,7 +224,7 @@ description: - If C(true), existing tags will be purged from the resource to match exactly what is defined by I(tags) parameter. - If the I(tags) parameter is not set then tags will not be modified. - default: true + default: false type: bool version_added: 3.2.0 health_check_period: @@ -1852,7 +1852,7 @@ def main(): wait_timeout=dict(type='int', default=300), state=dict(default='present', choices=['present', 'absent']), tags=dict(type='list', default=[], elements='dict'), - purge_tags=dict(type='bool', default=True), + purge_tags=dict(type='bool', default=False), health_check_period=dict(type='int', default=300), health_check_type=dict(default='EC2', choices=['EC2', 'ELB']), default_cooldown=dict(type='int', default=300), diff --git a/tests/integration/targets/ec2_asg/roles/ec2_asg/tasks/tag_operations.yml b/tests/integration/targets/ec2_asg/roles/ec2_asg/tasks/tag_operations.yml index 2f9cc118c4f..1a0874dbb47 100644 --- a/tests/integration/targets/ec2_asg/roles/ec2_asg/tasks/tag_operations.yml +++ b/tests/integration/targets/ec2_asg/roles/ec2_asg/tasks/tag_operations.yml @@ -85,6 +85,7 @@ tags: - tag_c: 'value 3' propagate_at_launch: no + purge_tags: true register: output - assert: @@ -109,6 +110,7 @@ ec2_asg: name: "{{ resource_prefix }}-asg-tag-test" tags: [] + purge_tags: true register: add_empty - name: Get asg info @@ -138,7 +140,6 @@ propagate_at_launch: yes - snake_case: "simple_snake_case" propagate_at_launch: no - purge_tags: false register: add_result - name: Get asg info @@ -171,7 +172,6 @@ propagate_at_launch: yes - snake_case: "simple_snake_case" propagate_at_launch: no - purge_tags: false register: add_result - name: Get asg info @@ -193,6 +193,7 @@ propagate_at_launch: no - tag_b: 'val_b' propagate_at_launch: yes + purge_tags: true register: add_purge_result - name: Get asg info @@ -258,7 +259,6 @@ propagate_at_launch: no - Title Case: "Hello Cruel World" propagate_at_launch: yes - purge_tags: false register: add_result - name: Get asg info @@ -308,6 +308,7 @@ ec2_asg: name: "{{ resource_prefix }}-asg-tag-test" tags: [] + purge_tags: true register: add_empty - name: Get asg info