From 771b4f0a5c545b3f0584d54f5d849599fa836f4e Mon Sep 17 00:00:00 2001 From: "Michael K. Haskell" Date: Thu, 27 Oct 2022 21:47:55 -0700 Subject: [PATCH 01/10] ssm_parameter: add support for tags (#1573) --- .../1574-ssm-parameter-support-for-tags.yml | 2 + plugins/modules/ssm_parameter.py | 133 +- .../targets/ssm_parameter/tasks/main.yml | 1146 +++++++++++++++++ 3 files changed, 1278 insertions(+), 3 deletions(-) create mode 100644 changelogs/fragments/1574-ssm-parameter-support-for-tags.yml diff --git a/changelogs/fragments/1574-ssm-parameter-support-for-tags.yml b/changelogs/fragments/1574-ssm-parameter-support-for-tags.yml new file mode 100644 index 00000000000..6340f821972 --- /dev/null +++ b/changelogs/fragments/1574-ssm-parameter-support-for-tags.yml @@ -0,0 +1,2 @@ +minor_changes: + - ssm_parameter - add support for tags in ssm parameters (https://github.com/ansible-collections/community.aws/issues/1573). \ No newline at end of file diff --git a/plugins/modules/ssm_parameter.py b/plugins/modules/ssm_parameter.py index 8647d9886be..9e287a07572 100644 --- a/plugins/modules/ssm_parameter.py +++ b/plugins/modules/ssm_parameter.py @@ -90,6 +90,7 @@ - amazon.aws.aws - amazon.aws.ec2 - amazon.aws.boto3 + - amazon.aws.tags ''' EXAMPLES = ''' @@ -137,6 +138,29 @@ - name: recommend to use with aws_ssm lookup plugin ansible.builtin.debug: msg: "{{ lookup('amazon.aws.aws_ssm', 'Hello') }}" + +- name: Create or update key/value pair in AWS SSM parameter store w/ tags + community.aws.ssm_paramater: + name: "Hello" + description: "This is your first key" + value: "World" + tags: + Environment: "dev" + Version: "1.0" + Confidentiality: "low" + Tag With Space: "foo bar" + +- name: Add or update a tag on an existing parameter w/o removing existing tags + community.aws.ssm_paramater: + name: "Hello" + purge_tags: false + tags: + Contact: "person1" + +- name: Delete all tags on an existing parameter + community.aws.ssm_paramater: + name: "Hello" + tags: {} ''' RETURN = ''' @@ -208,12 +232,35 @@ description: Parameter version number example: 3 returned: success + tags: + description: + - A list of dictionaries representing the tags associated with the parameter in the standard boto3 format. + returned: when the parameter has tags + type: list + elements: dict + contains: + key: + description: The name or key of the tag. + type: str + example: MyTag + returned: success + value: + description: The value of the tag. + type: str + example: Some value. + returned: success + tags_dict: + description: A dictionary representing the tags associated with the parameter. + type: dict + returned: when the parameter has tags + example: {'MyTagName': 'Some Value'} ''' import time try: import botocore + from botocore.exceptions import BotoCoreError, ClientError except ImportError: pass # Handled by AnsibleAWSModule @@ -223,6 +270,7 @@ from ansible_collections.amazon.aws.plugins.module_utils.core import is_boto3_error_code from ansible_collections.amazon.aws.plugins.module_utils.ec2 import AWSRetry from ansible_collections.community.aws.plugins.module_utils.base import BaseWaiterFactory +from ansible_collections.amazon.aws.plugins.module_utils.ec2 import boto3_tag_list_to_ansible_dict, compare_aws_tags, ansible_dict_to_boto3_tag_list class ParameterWaiterFactory(BaseWaiterFactory): @@ -301,6 +349,58 @@ def _wait_deleted(client, module, name): module.fail_json_aws(e, msg="Failed to describe parameter while waiting for deletion") +def tag_parameter(client, module, parameter_name, tags): + try: + return client.add_tags_to_resource(aws_retry=True, ResourceType='Parameter', + ResourceId=parameter_name, Tags=tags) + except (BotoCoreError, ClientError) as e: + module.fail_json_aws(e, msg="Failed to add tag(s) to parameter") + + +def untag_parameter(client, module, parameter_name, tag_keys): + try: + return client.remove_tags_from_resource(aws_retry=True, ResourceType='Parameter', + ResourceId=parameter_name, TagKeys=tag_keys) + except (BotoCoreError, ClientError) as e: + module.fail_json_aws(e, msg="Failed to remove tag(s) from parameter") + + +def get_parameter_tags(client, module, parameter_name): + try: + tags = client.list_tags_for_resource(aws_retry=True, ResourceType='Parameter', + ResourceId=parameter_name)['TagList'] + tags_dict = boto3_tag_list_to_ansible_dict(tags) + return tags_dict, tags + except (BotoCoreError, ClientError) as e: + module.fail_json_aws(e, msg="Unable to retrieve parameter tags") + + +def update_parameter_tags(client, module, parameter_name, supplied_tags): + changed = False + response = {} + + if supplied_tags is None: + return False, response + + current_tags = get_parameter_tags(client, module, parameter_name)[0] + tags_to_add, tags_to_remove = compare_aws_tags(current_tags, supplied_tags, + module.params.get('purge_tags')) + + if tags_to_add: + if module.check_mode: + return True, response + response = tag_parameter(client, module, parameter_name, + ansible_dict_to_boto3_tag_list(tags_to_add)) + changed = True + if tags_to_remove: + if module.check_mode: + return True, response + response = untag_parameter(client, module, parameter_name, tags_to_remove) + changed = True + + return changed, response + + def update_parameter(client, module, **args): changed = False response = {} @@ -310,8 +410,8 @@ def update_parameter(client, module, **args): try: response = client.put_parameter(aws_retry=True, **args) changed = True - except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e: - module.fail_json_aws(e, msg="setting parameter") + except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as exc: + module.fail_json_aws(exc, msg="setting parameter") return changed, response @@ -324,6 +424,10 @@ def describe_parameter(client, module, **args): if not existing_parameter['Parameters']: return None + tags_dict, tags = get_parameter_tags(client, module, module.params.get('name')) + existing_parameter['Parameters'][0]['tags'] = tags + existing_parameter['Parameters'][0]['tags_dict'] = tags_dict + return existing_parameter['Parameters'][0] @@ -387,7 +491,27 @@ def create_update_parameter(client, module): (changed, response) = update_parameter(client, module, **args) if changed: _wait_updated(client, module, module.params.get('name'), original_version) + # import time + # time.sleep(300) + + # Handle tag updates for existing parameters + if (module.params.get('overwrite_value') != 'never'): + tags_changed, tags_response = update_parameter_tags( + client, module, existing_parameter['Parameter']['Name'], + module.params.get('tags')) + + changed = changed or tags_changed + + if tags_response: + response['tag_updates'] = tags_response + else: + # Add tags in initial creation request + if module.params.get('tags'): + args.update(Tags=ansible_dict_to_boto3_tag_list(module.params.get('tags'))) + # Overwrite=True conflicts with tags and is not needed for new param + args.update(Overwrite=False) + (changed, response) = update_parameter(client, module, **args) _wait_exists(client, module, module.params.get('name')) @@ -444,6 +568,8 @@ def setup_module_object(): key_id=dict(default="alias/aws/ssm"), overwrite_value=dict(default='changed', choices=['never', 'changed', 'always']), tier=dict(default='Standard', choices=['Standard', 'Advanced', 'Intelligent-Tiering']), + tags=dict(type='dict', aliases=['resource_tags']), + purge_tags=dict(type='bool', default=True), ) return AnsibleAWSModule( @@ -474,7 +600,8 @@ def main(): except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e: module.fail_json_aws(e, msg="to describe parameter") if parameter_metadata: - result['parameter_metadata'] = camel_dict_to_snake_dict(parameter_metadata) + result['parameter_metadata'] = camel_dict_to_snake_dict(parameter_metadata, + ignore_list=['tags', 'tags_dict']) module.exit_json(changed=changed, **result) diff --git a/tests/integration/targets/ssm_parameter/tasks/main.yml b/tests/integration/targets/ssm_parameter/tasks/main.yml index 3d4fb643b30..07046ac84e5 100644 --- a/tests/integration/targets/ssm_parameter/tasks/main.yml +++ b/tests/integration/targets/ssm_parameter/tasks/main.yml @@ -23,6 +23,64 @@ simple_value: 'A simple VALue' updated_description: 'This is an updated example' updated_value: 'A simple VALue **UPDATED**' + simple_tag_param_name: '/{{ ssm_key_prefix }}/SimpleWithTags' + simple_tag_param_description: 'This is a simple example with tags' + simple_tag_param_updated_description: 'This is a simple example with tags (updated description)' + simple_tag_param_value: 'A simple VALue (w/ tags)' + single_tag: + Contact: "non-existent@ansible.com" + simple_tags_orig: + Contact: "non-existent@ansible.com" + Environment: "dev" + Version: "1.0" + Confidentiality: "low" + Tag With Space: "tag value with spaces" + simple_tags_add_owner: + Contact: "non-existent@ansible.com" + Environment: "dev" + Version: "1.0" + Confidentiality: "low" + Tag With Space: "foo" + Owner: "AWS" + simple_tags_change_environment: + Contact: "non-existent@ansible.com" + Environment: "test" + Version: "1.0" + Confidentiality: "low" + Tag With Space: "foo" + simple_tags_delete_version: + Contact: "non-existent@ansible.com" + Environment: "dev" + Confidentiality: "low" + Tag With Space: "foo" + simple_tags_delete_tag_with_space: + Contact: "non-existent@ansible.com" + Environment: "dev" + Version: "1.0" + Confidentiality: "low" + simple_tags_add_delete_change: + Contact: "non-existent@ansible.com" + Environment: "test" + Confidentiality: "low" + Tag With Space: "foo" + Owner: "AWS" + simple_tags_delete_all_tags: {} + simple_tags_purge_false_add_owner: + Owner: "AWS" + simple_tags_purge_false_add_multiple: + Contact1: "person1" + Contact2: "person2" + Contact3: "person3" + simple_tags_purge_false_change_environment: + Environment: "test" + simple_tags_purge_false_change_multiple: + Environment: "test" + Version: "2.0" + Confidentiality: "med" + Tag With Space: "tag value even more spaces" + simple_tags_purge_false_add_and_change: + Owner: "AWS" + Environment: "test" block: # ============================================================ @@ -438,6 +496,1093 @@ - result is changed - '"description" in result.parameter_metadata' - result.parameter_metadata.description == simple_description + # ============================================================ + # Test tags - Create parameter with tags case + + - name: Create parameter with tags case - Create parameter (CHECK) + aws_ssm_parameter_store: + name: '{{ simple_tag_param_name }}' + description: '{{ simple_tag_param_description }}' + value: '{{ simple_tag_param_value }}' + tags: '{{ simple_tags_orig }}' + register: result + check_mode: True + - assert: + that: + - result is changed + + - name: Create parameter with tags case - Create parameter + aws_ssm_parameter_store: + name: '{{ simple_tag_param_name }}' + description: '{{ simple_tag_param_description }}' + value: '{{ simple_tag_param_value }}' + tags: '{{ simple_tags_orig }}' + register: result + + - name: Create parameter with tags case - Ensure tags_dict is correct + assert: + that: + - result.parameter_metadata.tags_dict['{{ item.key }}'] == simple_tags_orig['{{ item.key }}'] + loop: "{{ simple_tags_orig | dict2items }}" + + - name: Create parameter with tags case - Ensure no missing or additional tags + assert: + that: + - result.parameter_metadata.tags_dict | length == simple_tags_orig | length + + - name: Create parameter with tags case - Ensure only tags have changed + set_fact: + lookup_value: "{{ lookup('amazon.aws.aws_ssm', simple_tag_param_name, **connection_args) }}" + - assert: + that: + - result is changed + - lookup_value == simple_tag_param_value + - '"parameter_metadata" in result' + - '"data_type" in result.parameter_metadata' + - '"description" in result.parameter_metadata' + - '"last_modified_date" in result.parameter_metadata' + - '"last_modified_user" in result.parameter_metadata' + - '"name" in result.parameter_metadata' + - '"policies" in result.parameter_metadata' + - '"tier" in result.parameter_metadata' + - '"type" in result.parameter_metadata' + - '"version" in result.parameter_metadata' + - '"tags" in result.parameter_metadata' + - result.parameter_metadata.data_type == 'text' + - result.parameter_metadata.description == simple_tag_param_description + - result.parameter_metadata.name == simple_tag_param_name + - result.parameter_metadata.policies | length == 0 + - result.parameter_metadata.tier == 'Standard' + - result.parameter_metadata.type == 'String' + + # ============================================================ + # Test tags - Update description only case + + - name: Update description only case - Update parameter (CHECK) + aws_ssm_parameter_store: + name: '{{ simple_tag_param_name }}' + description: '{{ simple_tag_param_updated_description }}' + register: result + check_mode: True + - assert: + that: + - result is changed + + - name: Update description only case - Update parameter + aws_ssm_parameter_store: + name: '{{ simple_tag_param_name }}' + description: '{{ simple_tag_param_updated_description }}' + register: result + + - name: Update description only case - Ensure expected tags_dict is correct + assert: + that: + - result.parameter_metadata.tags_dict['{{ item.key }}'] == simple_tags_orig['{{ item.key }}'] + loop: "{{ simple_tags_orig | dict2items }}" + + - name: Update description only case - Ensure no missing or additional tags + assert: + that: + - result.parameter_metadata.tags_dict | length == simple_tags_orig | length + + - name: Update description only case - Ensure only description changed + set_fact: + lookup_value: "{{ lookup('amazon.aws.aws_ssm', simple_tag_param_name, **connection_args) }}" + - assert: + that: + - result is changed + - lookup_value == simple_tag_param_value + - '"parameter_metadata" in result' + - '"data_type" in result.parameter_metadata' + - '"description" in result.parameter_metadata' + - '"last_modified_date" in result.parameter_metadata' + - '"last_modified_user" in result.parameter_metadata' + - '"name" in result.parameter_metadata' + - '"policies" in result.parameter_metadata' + - '"tier" in result.parameter_metadata' + - '"type" in result.parameter_metadata' + - '"version" in result.parameter_metadata' + - '"tags" in result.parameter_metadata' + - result.parameter_metadata.data_type == 'text' + - result.parameter_metadata.description == simple_tag_param_updated_description + - result.parameter_metadata.name == simple_tag_param_name + - result.parameter_metadata.policies | length == 0 + - result.parameter_metadata.tier == 'Standard' + - result.parameter_metadata.type == 'String' + + # ============================================================ + # Test tags - Add tag to existing parameter case + + - name: Add tag to existing parameter case - Update parameter (CHECK) + aws_ssm_parameter_store: + name: '{{ simple_tag_param_name }}' + tags: '{{ simple_tags_add_owner }}' + register: result + check_mode: True + - assert: + that: + - result is changed + + - name: Add tag to existing parameter case - Update parameter + aws_ssm_parameter_store: + name: '{{ simple_tag_param_name }}' + tags: '{{ simple_tags_add_owner }}' + register: result + + - name: Add tag to existing parameter case - Ensure tags_dict correct + assert: + that: + - result.parameter_metadata.tags_dict['{{ item.key }}'] == simple_tags_add_owner['{{ item.key }}'] + loop: "{{ simple_tags_add_owner | dict2items }}" + + - name: Add tag to existing parameter case - Ensure no missing or additional tags + assert: + that: + - result.parameter_metadata.tags_dict | length == simple_tags_add_owner | length + + - name: Add tag to existing parameter case - Ensure only tags changed + set_fact: + lookup_value: "{{ lookup('amazon.aws.aws_ssm', simple_tag_param_name, **connection_args) }}" + - assert: + that: + - result is changed + - lookup_value == simple_tag_param_value + - '"parameter_metadata" in result' + - '"data_type" in result.parameter_metadata' + - '"description" in result.parameter_metadata' + - '"last_modified_date" in result.parameter_metadata' + - '"last_modified_user" in result.parameter_metadata' + - '"name" in result.parameter_metadata' + - '"policies" in result.parameter_metadata' + - '"tier" in result.parameter_metadata' + - '"type" in result.parameter_metadata' + - '"version" in result.parameter_metadata' + - '"tags" in result.parameter_metadata' + - result.parameter_metadata.data_type == 'text' + - result.parameter_metadata.description == simple_tag_param_updated_description + - result.parameter_metadata.name == simple_tag_param_name + - result.parameter_metadata.policies | length == 0 + - result.parameter_metadata.tier == 'Standard' + - result.parameter_metadata.type == 'String' + + - name: Add tag to existing parameter case - Delete parameter + aws_ssm_parameter_store: + name: "{{item}}" + state: absent + ignore_errors: True + with_items: + - '{{ simple_tag_param_name }}' + + # ============================================================ + # Test tags - update tags only - change tag + + - name: Change single tag case - Create parameter + aws_ssm_parameter_store: + name: '{{ simple_tag_param_name }}' + description: '{{ simple_tag_param_description }}' + value: '{{ simple_tag_param_value }}' + tags: '{{ simple_tags_orig }}' + register: result + + - name: Change single tag case - Update tag (CHECK) + aws_ssm_parameter_store: + name: '{{ simple_tag_param_name }}' + tags: '{{ simple_tags_change_environment }}' + register: result + check_mode: True + - assert: + that: + - result is changed + + - name: Change single tag case - Update tag + aws_ssm_parameter_store: + name: '{{ simple_tag_param_name }}' + tags: '{{ simple_tags_change_environment }}' + register: result + + - name: Change single tag case - Ensure expected tags_dict is correct + assert: + that: + - result.parameter_metadata.tags_dict['{{ item.key }}'] == simple_tags_change_environment['{{ item.key }}'] + loop: "{{ simple_tags_change_environment | dict2items }}" + + - name: Change single tag case - Ensure no missing or additional tags + assert: + that: + - result.parameter_metadata.tags_dict | length == simple_tags_change_environment | length + + - name: Change single tag case - Lookup a tagged parameter + set_fact: + lookup_value: "{{ lookup('amazon.aws.aws_ssm', simple_tag_param_name, **connection_args) }}" + - assert: + that: + - result is changed + - lookup_value == simple_tag_param_value + - '"parameter_metadata" in result' + - '"data_type" in result.parameter_metadata' + - '"description" in result.parameter_metadata' + - '"last_modified_date" in result.parameter_metadata' + - '"last_modified_user" in result.parameter_metadata' + - '"name" in result.parameter_metadata' + - '"policies" in result.parameter_metadata' + - '"tier" in result.parameter_metadata' + - '"type" in result.parameter_metadata' + - '"version" in result.parameter_metadata' + - '"tags" in result.parameter_metadata' + - result.parameter_metadata.data_type == 'text' + - result.parameter_metadata.description == simple_tag_param_description + - result.parameter_metadata.name == simple_tag_param_name + - result.parameter_metadata.policies | length == 0 + - result.parameter_metadata.tier == 'Standard' + - result.parameter_metadata.type == 'String' + + - name: Change single tag case - Delete parameter + aws_ssm_parameter_store: + name: "{{item}}" + state: absent + ignore_errors: True + with_items: + - '{{ simple_tag_param_name }}' + + # ============================================================ + # Test tags - delete tag case + + - name: Delete single tag case - Create parameter + aws_ssm_parameter_store: + name: '{{ simple_tag_param_name }}' + description: '{{ simple_tag_param_description }}' + value: '{{ simple_tag_param_value }}' + tags: '{{ simple_tags_orig }}' + register: result + + - name: Delete single tag case - Update tag (CHECK) + aws_ssm_parameter_store: + name: '{{ simple_tag_param_name }}' + tags: '{{ simple_tags_delete_version }}' + register: result + check_mode: True + - assert: + that: + - result is changed + + - name: Delete single tag case - Update tag + aws_ssm_parameter_store: + name: '{{ simple_tag_param_name }}' + tags: '{{ simple_tags_delete_version }}' + register: result + + - name: Delete single tag case - Ensure expected tags_dict is correct + assert: + that: + - result.parameter_metadata.tags_dict['{{ item.key }}'] == simple_tags_delete_version['{{ item.key }}'] + loop: "{{ simple_tags_delete_version | dict2items }}" + + - name: Delete single tag case - Ensure no missing or additional tags + assert: + that: + - result.parameter_metadata.tags_dict | length == simple_tags_delete_version | length + + - name: Delete single tag case - Lookup a tagged parameter + set_fact: + lookup_value: "{{ lookup('amazon.aws.aws_ssm', simple_tag_param_name, **connection_args) }}" + - assert: + that: + - result is changed + - lookup_value == simple_tag_param_value + - '"parameter_metadata" in result' + - '"data_type" in result.parameter_metadata' + - '"description" in result.parameter_metadata' + - '"last_modified_date" in result.parameter_metadata' + - '"last_modified_user" in result.parameter_metadata' + - '"name" in result.parameter_metadata' + - '"policies" in result.parameter_metadata' + - '"tier" in result.parameter_metadata' + - '"type" in result.parameter_metadata' + - '"version" in result.parameter_metadata' + - '"tags" in result.parameter_metadata' + - result.parameter_metadata.data_type == 'text' + - result.parameter_metadata.description == simple_tag_param_description + - result.parameter_metadata.name == simple_tag_param_name + - result.parameter_metadata.policies | length == 0 + - result.parameter_metadata.tier == 'Standard' + - result.parameter_metadata.type == 'String' + + - name: Delete single tag case - Delete parameter + aws_ssm_parameter_store: + name: "{{item}}" + state: absent + ignore_errors: True + with_items: + - '{{ simple_tag_param_name }}' + + # ============================================================ + # Test tags - delete tag w/ spaces case + + - name: Delete single tag w/ spaces case - Create parameter + aws_ssm_parameter_store: + name: '{{ simple_tag_param_name }}' + description: '{{ simple_tag_param_description }}' + value: '{{ simple_tag_param_value }}' + tags: '{{ simple_tags_orig }}' + register: result + + - name: Delete single tag w/ spaces case - Update tag (CHECK) + aws_ssm_parameter_store: + name: '{{ simple_tag_param_name }}' + tags: '{{ simple_tags_delete_tag_with_space }}' + register: result + check_mode: True + - assert: + that: + - result is changed + + - name: Delete single tag w/ spaces case - Update tag + aws_ssm_parameter_store: + name: '{{ simple_tag_param_name }}' + tags: '{{ simple_tags_delete_tag_with_space }}' + register: result + + - name: Delete single tag w/ spaces case - Ensure expected tags_dict is correct + assert: + that: + - result.parameter_metadata.tags_dict['{{ item.key }}'] == simple_tags_delete_tag_with_space['{{ item.key }}'] + loop: "{{ simple_tags_delete_tag_with_space | dict2items }}" + + - name: Delete single tag w/ spaces case - Ensure no missing or additional tags + assert: + that: + - result.parameter_metadata.tags_dict | length == simple_tags_delete_tag_with_space | length + + - name: Delete single tag w/ spaces case - Lookup a tagged parameter + set_fact: + lookup_value: "{{ lookup('amazon.aws.aws_ssm', simple_tag_param_name, **connection_args) }}" + - assert: + that: + - result is changed + - lookup_value == simple_tag_param_value + - '"parameter_metadata" in result' + - '"data_type" in result.parameter_metadata' + - '"description" in result.parameter_metadata' + - '"last_modified_date" in result.parameter_metadata' + - '"last_modified_user" in result.parameter_metadata' + - '"name" in result.parameter_metadata' + - '"policies" in result.parameter_metadata' + - '"tier" in result.parameter_metadata' + - '"type" in result.parameter_metadata' + - '"version" in result.parameter_metadata' + - '"tags" in result.parameter_metadata' + - result.parameter_metadata.data_type == 'text' + - result.parameter_metadata.description == simple_tag_param_description + - result.parameter_metadata.name == simple_tag_param_name + - result.parameter_metadata.policies | length == 0 + - result.parameter_metadata.tier == 'Standard' + - result.parameter_metadata.type == 'String' + + - name: Delete single tag w/ spaces case - Delete parameter + aws_ssm_parameter_store: + name: "{{item}}" + state: absent + ignore_errors: True + with_items: + - '{{ simple_tag_param_name }}' + + # ============================================================ + # Test tags - Add/delete/change tags case + + - name: Add/delete/change tags case - Create parameter + aws_ssm_parameter_store: + name: '{{ simple_tag_param_name }}' + description: '{{ simple_tag_param_description }}' + value: '{{ simple_tag_param_value }}' + tags: '{{ simple_tags_orig }}' + register: result + + - name: Add/delete/change tags case - Update tag (CHECK) + aws_ssm_parameter_store: + name: '{{ simple_tag_param_name }}' + tags: '{{ simple_tags_add_delete_change }}' + register: result + check_mode: True + - assert: + that: + - result is changed + + - name: Add/delete/change tags case - Update tag + aws_ssm_parameter_store: + name: '{{ simple_tag_param_name }}' + tags: '{{ simple_tags_add_delete_change }}' + register: result + + - name: Add/delete/change tags case - Ensure expected tags_dict is correct + assert: + that: + - result.parameter_metadata.tags_dict['{{ item.key }}'] == simple_tags_add_delete_change['{{ item.key }}'] + loop: "{{ simple_tags_add_delete_change | dict2items }}" + + - name: Add/delete/change tags case - Ensure no missing or additional tags + assert: + that: + - result.parameter_metadata.tags_dict | length == simple_tags_add_delete_change | length + + - name: Add/delete/change tags case - Lookup a tagged parameter + set_fact: + lookup_value: "{{ lookup('amazon.aws.aws_ssm', simple_tag_param_name, **connection_args) }}" + - assert: + that: + - result is changed + - lookup_value == simple_tag_param_value + - '"parameter_metadata" in result' + - '"data_type" in result.parameter_metadata' + - '"description" in result.parameter_metadata' + - '"last_modified_date" in result.parameter_metadata' + - '"last_modified_user" in result.parameter_metadata' + - '"name" in result.parameter_metadata' + - '"policies" in result.parameter_metadata' + - '"tier" in result.parameter_metadata' + - '"type" in result.parameter_metadata' + - '"version" in result.parameter_metadata' + - '"tags" in result.parameter_metadata' + - result.parameter_metadata.data_type == 'text' + - result.parameter_metadata.description == simple_tag_param_description + - result.parameter_metadata.name == simple_tag_param_name + - result.parameter_metadata.policies | length == 0 + - result.parameter_metadata.tier == 'Standard' + - result.parameter_metadata.type == 'String' + + - name: Add/delete/change tags case - Delete parameter + aws_ssm_parameter_store: + name: "{{item}}" + state: absent + ignore_errors: True + with_items: + - '{{ simple_tag_param_name }}' + + # ============================================================ + # Test tags - Delete all tags case + + - name: Delete all tags case - Create parameter + aws_ssm_parameter_store: + name: '{{ simple_tag_param_name }}' + description: '{{ simple_tag_param_description }}' + value: '{{ simple_tag_param_value }}' + tags: '{{ simple_tags_orig }}' + register: result + + - name: Delete all tags case - Update tag (CHECK) + aws_ssm_parameter_store: + name: '{{ simple_tag_param_name }}' + tags: '{{ simple_tags_delete_all_tags }}' + register: result + check_mode: True + - assert: + that: + - result is changed + + - name: Delete all tags case - Update tag + aws_ssm_parameter_store: + name: '{{ simple_tag_param_name }}' + tags: '{{ simple_tags_delete_all_tags }}' + register: result + + - name: Delete all tags case - Ensure expected tags_dict is correct + assert: + that: + - result.parameter_metadata.tags_dict['{{ item.key }}'] == simple_tags_delete_all_tags['{{ item.key }}'] + loop: "{{ simple_tags_delete_all_tags | dict2items }}" + + - name: Delete all tags case - Ensure no missing or additional tags + assert: + that: + - result.parameter_metadata.tags_dict | length == simple_tags_delete_all_tags | length + + - name: Delete all tags case - Lookup a tagged parameter + set_fact: + lookup_value: "{{ lookup('amazon.aws.aws_ssm', simple_tag_param_name, **connection_args) }}" + - assert: + that: + - result is changed + - lookup_value == simple_tag_param_value + - '"parameter_metadata" in result' + - '"data_type" in result.parameter_metadata' + - '"description" in result.parameter_metadata' + - '"last_modified_date" in result.parameter_metadata' + - '"last_modified_user" in result.parameter_metadata' + - '"name" in result.parameter_metadata' + - '"policies" in result.parameter_metadata' + - '"tier" in result.parameter_metadata' + - '"type" in result.parameter_metadata' + - '"version" in result.parameter_metadata' + - '"tags" in result.parameter_metadata' + - result.parameter_metadata.data_type == 'text' + - result.parameter_metadata.description == simple_tag_param_description + - result.parameter_metadata.name == simple_tag_param_name + - result.parameter_metadata.policies | length == 0 + - result.parameter_metadata.tier == 'Standard' + - result.parameter_metadata.type == 'String' + + - name: Delete all tags case - Delete parameter + aws_ssm_parameter_store: + name: "{{item}}" + state: absent + ignore_errors: True + with_items: + - '{{ simple_tag_param_name }}' + + # ============================================================ + # Test tags - Add tag case (purge_tags=false) + + - name: Add tag case (purge_tags=false) - Create parameter + aws_ssm_parameter_store: + name: '{{ simple_tag_param_name }}' + description: '{{ simple_tag_param_description }}' + value: '{{ simple_tag_param_value }}' + tags: '{{ simple_tags_orig }}' + register: result + + - name: Add tag case (purge_tags=false) - Add tag (CHECK) + aws_ssm_parameter_store: + name: '{{ simple_tag_param_name }}' + tags: '{{ simple_tags_purge_false_add_owner }}' + purge_tags: False + register: result + check_mode: True + - assert: + that: + - result is changed + + - name: Add tag case (purge_tags=false) - Add tag + aws_ssm_parameter_store: + name: '{{ simple_tag_param_name }}' + tags: '{{ simple_tags_purge_false_add_owner }}' + purge_tags: False + register: result + + - name: Add tag case (purge_tags=false) - Ensure expected tags_dict is correct + assert: + that: + - > + result.parameter_metadata.tags_dict['{{ item.key }}'] == + (simple_tags_orig | combine(simple_tags_purge_false_add_owner))['{{ item.key }}'] + loop: > + {{ simple_tags_orig | combine(simple_tags_purge_false_add_owner) | dict2items }} + + - name: Add tag case (purge_tags=false) - Ensure no missing or additional tags + assert: + that: + - > + result.parameter_metadata.tags_dict | length == {{ simple_tags_orig | + combine(simple_tags_purge_false_add_owner) | dict2items }} | length + + - name: Add tag case (purge_tags=false) - Lookup a tagged parameter + set_fact: + lookup_value: "{{ lookup('amazon.aws.aws_ssm', simple_tag_param_name, **connection_args) }}" + - assert: + that: + - result is changed + - lookup_value == simple_tag_param_value + - '"parameter_metadata" in result' + - '"data_type" in result.parameter_metadata' + - '"description" in result.parameter_metadata' + - '"last_modified_date" in result.parameter_metadata' + - '"last_modified_user" in result.parameter_metadata' + - '"name" in result.parameter_metadata' + - '"policies" in result.parameter_metadata' + - '"tier" in result.parameter_metadata' + - '"type" in result.parameter_metadata' + - '"version" in result.parameter_metadata' + - '"tags" in result.parameter_metadata' + - result.parameter_metadata.data_type == 'text' + - result.parameter_metadata.description == simple_tag_param_description + - result.parameter_metadata.name == simple_tag_param_name + - result.parameter_metadata.policies | length == 0 + - result.parameter_metadata.tier == 'Standard' + - result.parameter_metadata.type == 'String' + + - name: Add tag case (purge_tags=false) - Delete parameter + aws_ssm_parameter_store: + name: "{{item}}" + state: absent + ignore_errors: True + with_items: + - '{{ simple_tag_param_name }}' + + # ============================================================ + # Test tags - Add multiple tags case (purge_tags=false) + + - name: Add multiple tags case (purge_tags=false) - Create parameter + aws_ssm_parameter_store: + name: '{{ simple_tag_param_name }}' + description: '{{ simple_tag_param_description }}' + value: '{{ simple_tag_param_value }}' + tags: '{{ simple_tags_orig }}' + register: result + + - name: Add multiple tags case (purge_tags=false) - Add tag (CHECK) + aws_ssm_parameter_store: + name: '{{ simple_tag_param_name }}' + tags: '{{ simple_tags_purge_false_add_multiple }}' + purge_tags: False + register: result + check_mode: True + - assert: + that: + - result is changed + + - name: Add multiple tags case (purge_tags=false) - Add tag + aws_ssm_parameter_store: + name: '{{ simple_tag_param_name }}' + tags: '{{ simple_tags_purge_false_add_multiple }}' + purge_tags: False + register: result + + - name: Add multiple tags case (purge_tags=false) - Ensure expected tags_dict is correct + assert: + that: + - > + result.parameter_metadata.tags_dict['{{ item.key }}'] == + (simple_tags_orig | combine(simple_tags_purge_false_add_multiple))['{{ item.key }}'] + loop: > + {{ simple_tags_orig | combine(simple_tags_purge_false_add_multiple) | dict2items }} + + - name: Add multiple tags case (purge_tags=false) - Ensure no missing or additional tags + assert: + that: + - > + result.parameter_metadata.tags_dict | length == {{ simple_tags_orig | + combine(simple_tags_purge_false_add_multiple) | dict2items }} | length + + - name: Add multiple tags case (purge_tags=false) - Lookup a tagged parameter + set_fact: + lookup_value: "{{ lookup('amazon.aws.aws_ssm', simple_tag_param_name, **connection_args) }}" + - assert: + that: + - result is changed + - lookup_value == simple_tag_param_value + - '"parameter_metadata" in result' + - '"data_type" in result.parameter_metadata' + - '"description" in result.parameter_metadata' + - '"last_modified_date" in result.parameter_metadata' + - '"last_modified_user" in result.parameter_metadata' + - '"name" in result.parameter_metadata' + - '"policies" in result.parameter_metadata' + - '"tier" in result.parameter_metadata' + - '"type" in result.parameter_metadata' + - '"version" in result.parameter_metadata' + - '"tags" in result.parameter_metadata' + - result.parameter_metadata.data_type == 'text' + - result.parameter_metadata.description == simple_tag_param_description + - result.parameter_metadata.name == simple_tag_param_name + - result.parameter_metadata.policies | length == 0 + - result.parameter_metadata.tier == 'Standard' + - result.parameter_metadata.type == 'String' + + - name: Add multiple tags case (purge_tags=false) - Delete parameter + aws_ssm_parameter_store: + name: "{{item}}" + state: absent + ignore_errors: True + with_items: + - '{{ simple_tag_param_name }}' + + # ============================================================ + # Test tags - Change tag case (purge_tags=false) + + - name: Change tag case (purge_tags=false) - Create parameter + aws_ssm_parameter_store: + name: '{{ simple_tag_param_name }}' + description: '{{ simple_tag_param_description }}' + value: '{{ simple_tag_param_value }}' + tags: '{{ simple_tags_orig }}' + register: result + + - name: Change tag case (purge_tags=false) - Change tag (CHECK) + aws_ssm_parameter_store: + name: '{{ simple_tag_param_name }}' + tags: '{{ simple_tags_purge_false_change_environment}}' + purge_tags: False + register: result + check_mode: True + - assert: + that: + - result is changed + + - name: Change tag case (purge_tags=false) - Change tag + aws_ssm_parameter_store: + name: '{{ simple_tag_param_name }}' + tags: '{{ simple_tags_purge_false_change_environment }}' + purge_tags: False + register: result + + - name: Change tag case (purge_tags=false) - Ensure expected tags_dict is correct + assert: + that: + - > + result.parameter_metadata.tags_dict['{{ item.key }}'] == + (simple_tags_orig | combine(simple_tags_purge_false_change_environment))['{{ item.key }}'] + loop: > + {{ simple_tags_orig | combine(simple_tags_purge_false_change_environment) | dict2items }} + loop_control: + extended: yes + + + - name: Change tag case (purge_tags=false) - Ensure no missing or additional tags + assert: + that: + - > + result.parameter_metadata.tags_dict | length == {{ simple_tags_orig | + combine(simple_tags_purge_false_change_environment) | dict2items }} | length + + - name: Change tag case (purge_tags=false) - Lookup a tagged parameter + set_fact: + lookup_value: "{{ lookup('amazon.aws.aws_ssm', simple_tag_param_name, **connection_args) }}" + - assert: + that: + - result is changed + - lookup_value == simple_tag_param_value + - '"parameter_metadata" in result' + - '"data_type" in result.parameter_metadata' + - '"description" in result.parameter_metadata' + - '"last_modified_date" in result.parameter_metadata' + - '"last_modified_user" in result.parameter_metadata' + - '"name" in result.parameter_metadata' + - '"policies" in result.parameter_metadata' + - '"tier" in result.parameter_metadata' + - '"type" in result.parameter_metadata' + - '"version" in result.parameter_metadata' + - '"tags" in result.parameter_metadata' + - result.parameter_metadata.data_type == 'text' + - result.parameter_metadata.description == simple_tag_param_description + - result.parameter_metadata.name == simple_tag_param_name + - result.parameter_metadata.policies | length == 0 + - result.parameter_metadata.tier == 'Standard' + - result.parameter_metadata.type == 'String' + + - name: Change tag case (purge_tags=false) - Delete parameter + aws_ssm_parameter_store: + name: "{{item}}" + state: absent + ignore_errors: True + with_items: + - '{{ simple_tag_param_name }}' + + # ============================================================ + # Test tags - Change multiple tags case (purge_tags=false) + + - name: Change multiple tags (purge_tags=false) - Create parameter + aws_ssm_parameter_store: + name: '{{ simple_tag_param_name }}' + description: '{{ simple_tag_param_description }}' + value: '{{ simple_tag_param_value }}' + tags: '{{ simple_tags_orig }}' + register: result + + - name: Change multiple tags (purge_tags=false) - Change tag (CHECK) + aws_ssm_parameter_store: + name: '{{ simple_tag_param_name }}' + tags: '{{ simple_tags_purge_false_change_multiple}}' + purge_tags: False + register: result + check_mode: True + - assert: + that: + - result is changed + + - name: Change multiple tags (purge_tags=false) - Change tag + aws_ssm_parameter_store: + name: '{{ simple_tag_param_name }}' + tags: '{{ simple_tags_purge_false_change_multiple }}' + purge_tags: False + register: result + + - name: Change multiple tags (purge_tags=false) - Ensure expected tags_dict is correct + assert: + that: + - > + result.parameter_metadata.tags_dict['{{ item.key }}'] == + (simple_tags_orig | combine(simple_tags_purge_false_change_multiple))['{{ item.key }}'] + loop: > + {{ simple_tags_orig | combine(simple_tags_purge_false_change_multiple) | dict2items }} + loop_control: + extended: yes + + + - name: Change multiple tags (purge_tags=false) - Ensure no missing or additional tags + assert: + that: + - > + result.parameter_metadata.tags_dict | length == {{ simple_tags_orig | + combine(simple_tags_purge_false_change_multiple) | dict2items }} | length + + - name: Change multiple tags (purge_tags=false) - Lookup a tagged parameter + set_fact: + lookup_value: "{{ lookup('amazon.aws.aws_ssm', simple_tag_param_name, **connection_args) }}" + - assert: + that: + - result is changed + - lookup_value == simple_tag_param_value + - '"parameter_metadata" in result' + - '"data_type" in result.parameter_metadata' + - '"description" in result.parameter_metadata' + - '"last_modified_date" in result.parameter_metadata' + - '"last_modified_user" in result.parameter_metadata' + - '"name" in result.parameter_metadata' + - '"policies" in result.parameter_metadata' + - '"tier" in result.parameter_metadata' + - '"type" in result.parameter_metadata' + - '"version" in result.parameter_metadata' + - '"tags" in result.parameter_metadata' + - result.parameter_metadata.data_type == 'text' + - result.parameter_metadata.description == simple_tag_param_description + - result.parameter_metadata.name == simple_tag_param_name + - result.parameter_metadata.policies | length == 0 + - result.parameter_metadata.tier == 'Standard' + - result.parameter_metadata.type == 'String' + + - name: Change multiple tags (purge_tags=false) - Delete parameter + aws_ssm_parameter_store: + name: "{{item}}" + state: absent + ignore_errors: True + with_items: + - '{{ simple_tag_param_name }}' + + # ============================================================ + # Test tags - Add/Change multiple tags case (purge_tags=false) + + - name: Add/Change multiple tags (purge_tags=false) - Create parameter + aws_ssm_parameter_store: + name: '{{ simple_tag_param_name }}' + description: '{{ simple_tag_param_description }}' + value: '{{ simple_tag_param_value }}' + tags: '{{ simple_tags_orig }}' + register: result + + - name: Add/Change multiple tags (purge_tags=false) - Change tag (CHECK) + aws_ssm_parameter_store: + name: '{{ simple_tag_param_name }}' + tags: '{{ simple_tags_purge_false_add_and_change}}' + purge_tags: False + register: result + check_mode: True + - assert: + that: + - result is changed + + - name: Add/Change multiple tags (purge_tags=false) - Change tag + aws_ssm_parameter_store: + name: '{{ simple_tag_param_name }}' + tags: '{{ simple_tags_purge_false_add_and_change }}' + purge_tags: False + register: result + + - name: Add/Change multiple tags (purge_tags=false) - Ensure expected tags_dict is correct + assert: + that: + - > + result.parameter_metadata.tags_dict['{{ item.key }}'] == + (simple_tags_orig | combine(simple_tags_purge_false_add_and_change))['{{ item.key }}'] + loop: > + {{ simple_tags_orig | combine(simple_tags_purge_false_add_and_change) | dict2items }} + loop_control: + extended: yes + + + - name: Add/Change multiple tags (purge_tags=false) - Ensure no missing or additional tags + assert: + that: + - > + result.parameter_metadata.tags_dict | length == {{ simple_tags_orig | + combine(simple_tags_purge_false_add_and_change) | dict2items }} | length + + - name: Add/Change multiple tags (purge_tags=false) - Lookup a tagged parameter + set_fact: + lookup_value: "{{ lookup('amazon.aws.aws_ssm', simple_tag_param_name, **connection_args) }}" + - assert: + that: + - result is changed + - lookup_value == simple_tag_param_value + - '"parameter_metadata" in result' + - '"data_type" in result.parameter_metadata' + - '"description" in result.parameter_metadata' + - '"last_modified_date" in result.parameter_metadata' + - '"last_modified_user" in result.parameter_metadata' + - '"name" in result.parameter_metadata' + - '"policies" in result.parameter_metadata' + - '"tier" in result.parameter_metadata' + - '"type" in result.parameter_metadata' + - '"version" in result.parameter_metadata' + - '"tags" in result.parameter_metadata' + - result.parameter_metadata.data_type == 'text' + - result.parameter_metadata.description == simple_tag_param_description + - result.parameter_metadata.name == simple_tag_param_name + - result.parameter_metadata.policies | length == 0 + - result.parameter_metadata.tier == 'Standard' + - result.parameter_metadata.type == 'String' + + - name: Add/Change multiple tags (purge_tags=false) - Delete parameter + aws_ssm_parameter_store: + name: "{{item}}" + state: absent + ignore_errors: True + with_items: + - '{{ simple_tag_param_name }}' + + # ============================================================ + # Test tags - Empty tags dict case (purge_tags=false) # should be no change + + - name: Empty tags dict (purge_tags=false) - Create parameter + aws_ssm_parameter_store: + name: '{{ simple_tag_param_name }}' + description: '{{ simple_tag_param_description }}' + value: '{{ simple_tag_param_value }}' + tags: '{{ simple_tags_orig }}' + register: result + + - name: Empty tags dict (purge_tags=false) - Change tag (CHECK) + aws_ssm_parameter_store: + name: '{{ simple_tag_param_name }}' + tags: {} + purge_tags: False + register: result + check_mode: True + - assert: + that: + - result != 'changed' + + - name: Empty tags dict (purge_tags=false) - Change tag + aws_ssm_parameter_store: + name: '{{ simple_tag_param_name }}' + tags: {} + purge_tags: False + register: result + + - name: Empty tags dict (purge_tags=false) - Ensure expected tags_dict is correct + assert: + that: + - > + result.parameter_metadata.tags_dict['{{ item.key }}'] == simple_tags_orig['{{ item.key }}'] + loop: > + {{ simple_tags_orig | dict2items }} + loop_control: + extended: yes + + - name: Empty tags dict (purge_tags=false) - Ensure no missing or additional tags + assert: + that: + - > + result.parameter_metadata.tags_dict | length + == {{ simple_tags_orig | dict2items }} | length + + - name: Empty tags dict (purge_tags=false) - Lookup a tagged parameter + set_fact: + lookup_value: "{{ lookup('amazon.aws.aws_ssm', simple_tag_param_name, **connection_args) }}" + - assert: + that: + - result != 'changed' + - lookup_value == simple_tag_param_value + - '"parameter_metadata" in result' + - '"data_type" in result.parameter_metadata' + - '"description" in result.parameter_metadata' + - '"last_modified_date" in result.parameter_metadata' + - '"last_modified_user" in result.parameter_metadata' + - '"name" in result.parameter_metadata' + - '"policies" in result.parameter_metadata' + - '"tier" in result.parameter_metadata' + - '"type" in result.parameter_metadata' + - '"version" in result.parameter_metadata' + - '"tags" in result.parameter_metadata' + - result.parameter_metadata.data_type == 'text' + - result.parameter_metadata.description == simple_tag_param_description + - result.parameter_metadata.name == simple_tag_param_name + - result.parameter_metadata.policies | length == 0 + - result.parameter_metadata.tier == 'Standard' + - result.parameter_metadata.type == 'String' + + - name: Empty tags dict (purge_tags=false) - Delete parameter + aws_ssm_parameter_store: + name: "{{item}}" + state: absent + ignore_errors: True + with_items: + - '{{ simple_tag_param_name }}' + + # ============================================================ + # Test tags - No tags parameter (purge_tags=true) case # should be no change + + - name: No tags parameter (purge_tags=true) - Create parameter + aws_ssm_parameter_store: + name: '{{ simple_tag_param_name }}' + description: '{{ simple_tag_param_description }}' + value: '{{ simple_tag_param_value }}' + tags: '{{ simple_tags_orig }}' + register: result + + - name: No tags parameter (purge_tags=true) - Change tag (CHECK) + aws_ssm_parameter_store: + name: '{{ simple_tag_param_name }}' + description: '{{ simple_tag_param_updated_description }}' + register: result + check_mode: True + - assert: + that: + - result is changed + + - name: No tags parameter (purge_tags=true) - Change tag + aws_ssm_parameter_store: + name: '{{ simple_tag_param_name }}' + description: '{{ simple_tag_param_updated_description }}' + register: result + + - name: No tags parameter (purge_tags=true) - Ensure expected tags_dict is correct + assert: + that: + - > + result.parameter_metadata.tags_dict['{{ item.key }}'] + == simple_tags_orig['{{ item.key }}'] + loop: > + {{ simple_tags_orig | dict2items }} + loop_control: + extended: true + + - name: No tags parameter (purge_tags=true) - Ensure no missing or additional tags + assert: + that: + - > + result.parameter_metadata.tags_dict | length + == {{ simple_tags_orig | dict2items }} | length + + - name: No tags parameter (purge_tags=true) - Lookup a tagged parameter + set_fact: + lookup_value: "{{ lookup('amazon.aws.aws_ssm', simple_tag_param_name, **connection_args) }}" + - assert: + that: + - result is changed + - lookup_value == simple_tag_param_value + - '"parameter_metadata" in result' + - '"data_type" in result.parameter_metadata' + - '"description" in result.parameter_metadata' + - '"last_modified_date" in result.parameter_metadata' + - '"last_modified_user" in result.parameter_metadata' + - '"name" in result.parameter_metadata' + - '"policies" in result.parameter_metadata' + - '"tier" in result.parameter_metadata' + - '"type" in result.parameter_metadata' + - '"version" in result.parameter_metadata' + - '"tags" in result.parameter_metadata' + - result.parameter_metadata.data_type == 'text' + - result.parameter_metadata.description == simple_tag_param_updated_description + - result.parameter_metadata.name == simple_tag_param_name + - result.parameter_metadata.policies | length == 0 + - result.parameter_metadata.tier == 'Standard' + - result.parameter_metadata.type == 'String' + + - name: No tags parameter (purge_tags=true) - Delete parameter + aws_ssm_parameter_store: + name: "{{item}}" + state: absent + ignore_errors: true + with_items: + - '{{ simple_tag_param_name }}' always: # ============================================================ @@ -448,3 +1593,4 @@ ignore_errors: True with_items: - '{{ simple_name }}' + - '{{ simple_tag_param_name }}' From cd609e1f5f72d198ea9940542e181089453af407 Mon Sep 17 00:00:00 2001 From: "Michael K. Haskell" Date: Fri, 28 Oct 2022 16:29:34 -0700 Subject: [PATCH 02/10] ssm_parameter: add support for tags - add version_added parameter (#1573) --- plugins/modules/ssm_parameter.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/modules/ssm_parameter.py b/plugins/modules/ssm_parameter.py index 9e287a07572..2cc273b7591 100644 --- a/plugins/modules/ssm_parameter.py +++ b/plugins/modules/ssm_parameter.py @@ -249,11 +249,13 @@ type: str example: Some value. returned: success + version_added: 5.1.0 tags_dict: description: A dictionary representing the tags associated with the parameter. type: dict returned: when the parameter has tags example: {'MyTagName': 'Some Value'} + version_added: 5.1.0 ''' import time From 474aa60f4632f5dd6408b63b032e6b1df88aacf3 Mon Sep 17 00:00:00 2001 From: "Michael K. Haskell" Date: Thu, 10 Nov 2022 15:49:24 -0800 Subject: [PATCH 03/10] ssm_parameter: add support for tags - remove unneeded parens and commented code (#1573) --- plugins/modules/ssm_parameter.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/plugins/modules/ssm_parameter.py b/plugins/modules/ssm_parameter.py index 2cc273b7591..cbcc39e7584 100644 --- a/plugins/modules/ssm_parameter.py +++ b/plugins/modules/ssm_parameter.py @@ -493,11 +493,9 @@ def create_update_parameter(client, module): (changed, response) = update_parameter(client, module, **args) if changed: _wait_updated(client, module, module.params.get('name'), original_version) - # import time - # time.sleep(300) # Handle tag updates for existing parameters - if (module.params.get('overwrite_value') != 'never'): + if module.params.get('overwrite_value') != 'never': tags_changed, tags_response = update_parameter_tags( client, module, existing_parameter['Parameter']['Name'], module.params.get('tags')) From 9274796687b9375896792be683ed2707405acc8b Mon Sep 17 00:00:00 2001 From: "Michael K. Haskell" Date: Thu, 10 Nov 2022 15:59:00 -0800 Subject: [PATCH 04/10] ssm_parameter: add support for tags - updated docs to reflect version added (#1573) --- plugins/modules/ssm_parameter.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plugins/modules/ssm_parameter.py b/plugins/modules/ssm_parameter.py index cbcc39e7584..391aab127eb 100644 --- a/plugins/modules/ssm_parameter.py +++ b/plugins/modules/ssm_parameter.py @@ -91,6 +91,10 @@ - amazon.aws.ec2 - amazon.aws.boto3 - amazon.aws.tags + +notes: + - Support for I(tags) and I(purge_tags) was added in release 5.1.0. + ''' EXAMPLES = ''' From 12a6142ac54277b5214016009a46d5199acfbc63 Mon Sep 17 00:00:00 2001 From: "Michael K. Haskell" Date: Wed, 16 Nov 2022 10:35:32 -0800 Subject: [PATCH 05/10] ssm_parameter: add support for tags - retrigger build From 458fc252738efeac8acf04c998415921acce45d5 Mon Sep 17 00:00:00 2001 From: Markus Bergholz Date: Wed, 21 Dec 2022 18:25:43 +0100 Subject: [PATCH 06/10] Update plugins/modules/ssm_parameter.py --- plugins/modules/ssm_parameter.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/modules/ssm_parameter.py b/plugins/modules/ssm_parameter.py index 391aab127eb..ccbc6de59fb 100644 --- a/plugins/modules/ssm_parameter.py +++ b/plugins/modules/ssm_parameter.py @@ -93,7 +93,7 @@ - amazon.aws.tags notes: - - Support for I(tags) and I(purge_tags) was added in release 5.1.0. + - Support for I(tags) and I(purge_tags) was added in release 5.2.0. ''' From 479002319757d0d9fb637f2908ea8c4ae476f1f1 Mon Sep 17 00:00:00 2001 From: Markus Bergholz Date: Wed, 21 Dec 2022 18:26:13 +0100 Subject: [PATCH 07/10] Update plugins/modules/ssm_parameter.py --- plugins/modules/ssm_parameter.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/modules/ssm_parameter.py b/plugins/modules/ssm_parameter.py index ccbc6de59fb..57347b8c5e7 100644 --- a/plugins/modules/ssm_parameter.py +++ b/plugins/modules/ssm_parameter.py @@ -253,7 +253,7 @@ type: str example: Some value. returned: success - version_added: 5.1.0 + version_added: 5.2.0 tags_dict: description: A dictionary representing the tags associated with the parameter. type: dict From 82c86c0046d948e8d1753fc3b741c27ec027e209 Mon Sep 17 00:00:00 2001 From: "Michael K. Haskell" Date: Tue, 17 Jan 2023 15:56:25 -0800 Subject: [PATCH 08/10] ssm_parameter: add support for tags - fix parameter typos --- plugins/modules/ssm_parameter.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plugins/modules/ssm_parameter.py b/plugins/modules/ssm_parameter.py index 57347b8c5e7..03c6ec84d11 100644 --- a/plugins/modules/ssm_parameter.py +++ b/plugins/modules/ssm_parameter.py @@ -144,7 +144,7 @@ msg: "{{ lookup('amazon.aws.aws_ssm', 'Hello') }}" - name: Create or update key/value pair in AWS SSM parameter store w/ tags - community.aws.ssm_paramater: + community.aws.ssm_parameter: name: "Hello" description: "This is your first key" value: "World" @@ -155,14 +155,14 @@ Tag With Space: "foo bar" - name: Add or update a tag on an existing parameter w/o removing existing tags - community.aws.ssm_paramater: + community.aws.ssm_parameter: name: "Hello" purge_tags: false tags: Contact: "person1" - name: Delete all tags on an existing parameter - community.aws.ssm_paramater: + community.aws.ssm_parameter: name: "Hello" tags: {} ''' From 96ed2850c13885d2766126447a7dfa9576e1a583 Mon Sep 17 00:00:00 2001 From: "Michael K. Haskell" Date: Tue, 17 Jan 2023 16:14:45 -0800 Subject: [PATCH 09/10] ssm_parameter: add support for tags - update version_added to 5.2.0 --- plugins/modules/ssm_parameter.py | 2 +- tests/integration/targets/ssm_parameter/tasks/main.yml | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/plugins/modules/ssm_parameter.py b/plugins/modules/ssm_parameter.py index 03c6ec84d11..051f6c13bed 100644 --- a/plugins/modules/ssm_parameter.py +++ b/plugins/modules/ssm_parameter.py @@ -259,7 +259,7 @@ type: dict returned: when the parameter has tags example: {'MyTagName': 'Some Value'} - version_added: 5.1.0 + version_added: 5.2.0 ''' import time diff --git a/tests/integration/targets/ssm_parameter/tasks/main.yml b/tests/integration/targets/ssm_parameter/tasks/main.yml index 07046ac84e5..3b894f74bf8 100644 --- a/tests/integration/targets/ssm_parameter/tasks/main.yml +++ b/tests/integration/targets/ssm_parameter/tasks/main.yml @@ -496,6 +496,7 @@ - result is changed - '"description" in result.parameter_metadata' - result.parameter_metadata.description == simple_description + # ============================================================ # Test tags - Create parameter with tags case From 7642cee44fb8e4022b407f3b90308160824d6d51 Mon Sep 17 00:00:00 2001 From: Mark Chappell Date: Thu, 2 Feb 2023 09:54:14 +0100 Subject: [PATCH 10/10] Drop boto3-style tags --- plugins/modules/ssm_parameter.py | 37 ++--- .../targets/ssm_parameter/tasks/main.yml | 126 +++++++++--------- 2 files changed, 73 insertions(+), 90 deletions(-) diff --git a/plugins/modules/ssm_parameter.py b/plugins/modules/ssm_parameter.py index 051f6c13bed..d654d45ecf5 100644 --- a/plugins/modules/ssm_parameter.py +++ b/plugins/modules/ssm_parameter.py @@ -93,7 +93,7 @@ - amazon.aws.tags notes: - - Support for I(tags) and I(purge_tags) was added in release 5.2.0. + - Support for I(tags) and I(purge_tags) was added in release 5.3.0. ''' @@ -237,29 +237,11 @@ example: 3 returned: success tags: - description: - - A list of dictionaries representing the tags associated with the parameter in the standard boto3 format. - returned: when the parameter has tags - type: list - elements: dict - contains: - key: - description: The name or key of the tag. - type: str - example: MyTag - returned: success - value: - description: The value of the tag. - type: str - example: Some value. - returned: success - version_added: 5.2.0 - tags_dict: description: A dictionary representing the tags associated with the parameter. type: dict returned: when the parameter has tags example: {'MyTagName': 'Some Value'} - version_added: 5.2.0 + version_added: 5.3.0 ''' import time @@ -276,7 +258,9 @@ from ansible_collections.amazon.aws.plugins.module_utils.core import is_boto3_error_code from ansible_collections.amazon.aws.plugins.module_utils.ec2 import AWSRetry from ansible_collections.community.aws.plugins.module_utils.base import BaseWaiterFactory -from ansible_collections.amazon.aws.plugins.module_utils.ec2 import boto3_tag_list_to_ansible_dict, compare_aws_tags, ansible_dict_to_boto3_tag_list +from ansible_collections.amazon.aws.plugins.module_utils.tagging import ansible_dict_to_boto3_tag_list +from ansible_collections.amazon.aws.plugins.module_utils.tagging import boto3_tag_list_to_ansible_dict +from ansible_collections.amazon.aws.plugins.module_utils.tagging import compare_aws_tags class ParameterWaiterFactory(BaseWaiterFactory): @@ -376,7 +360,7 @@ def get_parameter_tags(client, module, parameter_name): tags = client.list_tags_for_resource(aws_retry=True, ResourceType='Parameter', ResourceId=parameter_name)['TagList'] tags_dict = boto3_tag_list_to_ansible_dict(tags) - return tags_dict, tags + return tags_dict except (BotoCoreError, ClientError) as e: module.fail_json_aws(e, msg="Unable to retrieve parameter tags") @@ -388,7 +372,7 @@ def update_parameter_tags(client, module, parameter_name, supplied_tags): if supplied_tags is None: return False, response - current_tags = get_parameter_tags(client, module, parameter_name)[0] + current_tags = get_parameter_tags(client, module, parameter_name) tags_to_add, tags_to_remove = compare_aws_tags(current_tags, supplied_tags, module.params.get('purge_tags')) @@ -430,9 +414,8 @@ def describe_parameter(client, module, **args): if not existing_parameter['Parameters']: return None - tags_dict, tags = get_parameter_tags(client, module, module.params.get('name')) - existing_parameter['Parameters'][0]['tags'] = tags - existing_parameter['Parameters'][0]['tags_dict'] = tags_dict + tags_dict = get_parameter_tags(client, module, module.params.get('name')) + existing_parameter['Parameters'][0]['tags'] = tags_dict return existing_parameter['Parameters'][0] @@ -605,7 +588,7 @@ def main(): module.fail_json_aws(e, msg="to describe parameter") if parameter_metadata: result['parameter_metadata'] = camel_dict_to_snake_dict(parameter_metadata, - ignore_list=['tags', 'tags_dict']) + ignore_list=['tags']) module.exit_json(changed=changed, **result) diff --git a/tests/integration/targets/ssm_parameter/tasks/main.yml b/tests/integration/targets/ssm_parameter/tasks/main.yml index 3b894f74bf8..ac461392a96 100644 --- a/tests/integration/targets/ssm_parameter/tasks/main.yml +++ b/tests/integration/targets/ssm_parameter/tasks/main.yml @@ -58,7 +58,7 @@ Environment: "dev" Version: "1.0" Confidentiality: "low" - simple_tags_add_delete_change: + simple_tags_add_delete_change: Contact: "non-existent@ansible.com" Environment: "test" Confidentiality: "low" @@ -520,16 +520,16 @@ tags: '{{ simple_tags_orig }}' register: result - - name: Create parameter with tags case - Ensure tags_dict is correct + - name: Create parameter with tags case - Ensure tags is correct assert: that: - - result.parameter_metadata.tags_dict['{{ item.key }}'] == simple_tags_orig['{{ item.key }}'] + - result.parameter_metadata.tags['{{ item.key }}'] == simple_tags_orig['{{ item.key }}'] loop: "{{ simple_tags_orig | dict2items }}" - + - name: Create parameter with tags case - Ensure no missing or additional tags assert: that: - - result.parameter_metadata.tags_dict | length == simple_tags_orig | length + - result.parameter_metadata.tags | length == simple_tags_orig | length - name: Create parameter with tags case - Ensure only tags have changed set_fact: @@ -575,16 +575,16 @@ description: '{{ simple_tag_param_updated_description }}' register: result - - name: Update description only case - Ensure expected tags_dict is correct + - name: Update description only case - Ensure expected tags is correct assert: that: - - result.parameter_metadata.tags_dict['{{ item.key }}'] == simple_tags_orig['{{ item.key }}'] + - result.parameter_metadata.tags['{{ item.key }}'] == simple_tags_orig['{{ item.key }}'] loop: "{{ simple_tags_orig | dict2items }}" - + - name: Update description only case - Ensure no missing or additional tags assert: that: - - result.parameter_metadata.tags_dict | length == simple_tags_orig | length + - result.parameter_metadata.tags | length == simple_tags_orig | length - name: Update description only case - Ensure only description changed set_fact: @@ -610,7 +610,7 @@ - result.parameter_metadata.policies | length == 0 - result.parameter_metadata.tier == 'Standard' - result.parameter_metadata.type == 'String' - + # ============================================================ # Test tags - Add tag to existing parameter case @@ -630,16 +630,16 @@ tags: '{{ simple_tags_add_owner }}' register: result - - name: Add tag to existing parameter case - Ensure tags_dict correct + - name: Add tag to existing parameter case - Ensure tags correct assert: that: - - result.parameter_metadata.tags_dict['{{ item.key }}'] == simple_tags_add_owner['{{ item.key }}'] + - result.parameter_metadata.tags['{{ item.key }}'] == simple_tags_add_owner['{{ item.key }}'] loop: "{{ simple_tags_add_owner | dict2items }}" - + - name: Add tag to existing parameter case - Ensure no missing or additional tags assert: that: - - result.parameter_metadata.tags_dict | length == simple_tags_add_owner | length + - result.parameter_metadata.tags | length == simple_tags_add_owner | length - name: Add tag to existing parameter case - Ensure only tags changed set_fact: @@ -673,7 +673,7 @@ ignore_errors: True with_items: - '{{ simple_tag_param_name }}' - + # ============================================================ # Test tags - update tags only - change tag @@ -694,23 +694,23 @@ - assert: that: - result is changed - + - name: Change single tag case - Update tag aws_ssm_parameter_store: name: '{{ simple_tag_param_name }}' tags: '{{ simple_tags_change_environment }}' register: result - - name: Change single tag case - Ensure expected tags_dict is correct + - name: Change single tag case - Ensure expected tags is correct assert: that: - - result.parameter_metadata.tags_dict['{{ item.key }}'] == simple_tags_change_environment['{{ item.key }}'] + - result.parameter_metadata.tags['{{ item.key }}'] == simple_tags_change_environment['{{ item.key }}'] loop: "{{ simple_tags_change_environment | dict2items }}" - + - name: Change single tag case - Ensure no missing or additional tags assert: that: - - result.parameter_metadata.tags_dict | length == simple_tags_change_environment | length + - result.parameter_metadata.tags | length == simple_tags_change_environment | length - name: Change single tag case - Lookup a tagged parameter set_fact: @@ -772,16 +772,16 @@ tags: '{{ simple_tags_delete_version }}' register: result - - name: Delete single tag case - Ensure expected tags_dict is correct + - name: Delete single tag case - Ensure expected tags is correct assert: that: - - result.parameter_metadata.tags_dict['{{ item.key }}'] == simple_tags_delete_version['{{ item.key }}'] + - result.parameter_metadata.tags['{{ item.key }}'] == simple_tags_delete_version['{{ item.key }}'] loop: "{{ simple_tags_delete_version | dict2items }}" - + - name: Delete single tag case - Ensure no missing or additional tags assert: that: - - result.parameter_metadata.tags_dict | length == simple_tags_delete_version | length + - result.parameter_metadata.tags | length == simple_tags_delete_version | length - name: Delete single tag case - Lookup a tagged parameter set_fact: @@ -843,16 +843,16 @@ tags: '{{ simple_tags_delete_tag_with_space }}' register: result - - name: Delete single tag w/ spaces case - Ensure expected tags_dict is correct + - name: Delete single tag w/ spaces case - Ensure expected tags is correct assert: that: - - result.parameter_metadata.tags_dict['{{ item.key }}'] == simple_tags_delete_tag_with_space['{{ item.key }}'] + - result.parameter_metadata.tags['{{ item.key }}'] == simple_tags_delete_tag_with_space['{{ item.key }}'] loop: "{{ simple_tags_delete_tag_with_space | dict2items }}" - + - name: Delete single tag w/ spaces case - Ensure no missing or additional tags assert: that: - - result.parameter_metadata.tags_dict | length == simple_tags_delete_tag_with_space | length + - result.parameter_metadata.tags | length == simple_tags_delete_tag_with_space | length - name: Delete single tag w/ spaces case - Lookup a tagged parameter set_fact: @@ -914,16 +914,16 @@ tags: '{{ simple_tags_add_delete_change }}' register: result - - name: Add/delete/change tags case - Ensure expected tags_dict is correct + - name: Add/delete/change tags case - Ensure expected tags is correct assert: that: - - result.parameter_metadata.tags_dict['{{ item.key }}'] == simple_tags_add_delete_change['{{ item.key }}'] + - result.parameter_metadata.tags['{{ item.key }}'] == simple_tags_add_delete_change['{{ item.key }}'] loop: "{{ simple_tags_add_delete_change | dict2items }}" - + - name: Add/delete/change tags case - Ensure no missing or additional tags assert: that: - - result.parameter_metadata.tags_dict | length == simple_tags_add_delete_change | length + - result.parameter_metadata.tags | length == simple_tags_add_delete_change | length - name: Add/delete/change tags case - Lookup a tagged parameter set_fact: @@ -985,16 +985,16 @@ tags: '{{ simple_tags_delete_all_tags }}' register: result - - name: Delete all tags case - Ensure expected tags_dict is correct + - name: Delete all tags case - Ensure expected tags is correct assert: that: - - result.parameter_metadata.tags_dict['{{ item.key }}'] == simple_tags_delete_all_tags['{{ item.key }}'] + - result.parameter_metadata.tags['{{ item.key }}'] == simple_tags_delete_all_tags['{{ item.key }}'] loop: "{{ simple_tags_delete_all_tags | dict2items }}" - + - name: Delete all tags case - Ensure no missing or additional tags assert: that: - - result.parameter_metadata.tags_dict | length == simple_tags_delete_all_tags | length + - result.parameter_metadata.tags | length == simple_tags_delete_all_tags | length - name: Delete all tags case - Lookup a tagged parameter set_fact: @@ -1058,20 +1058,20 @@ purge_tags: False register: result - - name: Add tag case (purge_tags=false) - Ensure expected tags_dict is correct + - name: Add tag case (purge_tags=false) - Ensure expected tags is correct assert: that: - > - result.parameter_metadata.tags_dict['{{ item.key }}'] == + result.parameter_metadata.tags['{{ item.key }}'] == (simple_tags_orig | combine(simple_tags_purge_false_add_owner))['{{ item.key }}'] loop: > {{ simple_tags_orig | combine(simple_tags_purge_false_add_owner) | dict2items }} - + - name: Add tag case (purge_tags=false) - Ensure no missing or additional tags assert: that: - > - result.parameter_metadata.tags_dict | length == {{ simple_tags_orig | + result.parameter_metadata.tags | length == {{ simple_tags_orig | combine(simple_tags_purge_false_add_owner) | dict2items }} | length - name: Add tag case (purge_tags=false) - Lookup a tagged parameter @@ -1136,20 +1136,20 @@ purge_tags: False register: result - - name: Add multiple tags case (purge_tags=false) - Ensure expected tags_dict is correct + - name: Add multiple tags case (purge_tags=false) - Ensure expected tags is correct assert: that: - > - result.parameter_metadata.tags_dict['{{ item.key }}'] == + result.parameter_metadata.tags['{{ item.key }}'] == (simple_tags_orig | combine(simple_tags_purge_false_add_multiple))['{{ item.key }}'] loop: > {{ simple_tags_orig | combine(simple_tags_purge_false_add_multiple) | dict2items }} - + - name: Add multiple tags case (purge_tags=false) - Ensure no missing or additional tags assert: that: - > - result.parameter_metadata.tags_dict | length == {{ simple_tags_orig | + result.parameter_metadata.tags | length == {{ simple_tags_orig | combine(simple_tags_purge_false_add_multiple) | dict2items }} | length - name: Add multiple tags case (purge_tags=false) - Lookup a tagged parameter @@ -1214,23 +1214,23 @@ purge_tags: False register: result - - name: Change tag case (purge_tags=false) - Ensure expected tags_dict is correct + - name: Change tag case (purge_tags=false) - Ensure expected tags is correct assert: that: - > - result.parameter_metadata.tags_dict['{{ item.key }}'] == + result.parameter_metadata.tags['{{ item.key }}'] == (simple_tags_orig | combine(simple_tags_purge_false_change_environment))['{{ item.key }}'] loop: > {{ simple_tags_orig | combine(simple_tags_purge_false_change_environment) | dict2items }} loop_control: extended: yes - + - name: Change tag case (purge_tags=false) - Ensure no missing or additional tags assert: that: - > - result.parameter_metadata.tags_dict | length == {{ simple_tags_orig | + result.parameter_metadata.tags | length == {{ simple_tags_orig | combine(simple_tags_purge_false_change_environment) | dict2items }} | length - name: Change tag case (purge_tags=false) - Lookup a tagged parameter @@ -1295,23 +1295,23 @@ purge_tags: False register: result - - name: Change multiple tags (purge_tags=false) - Ensure expected tags_dict is correct + - name: Change multiple tags (purge_tags=false) - Ensure expected tags is correct assert: that: - > - result.parameter_metadata.tags_dict['{{ item.key }}'] == + result.parameter_metadata.tags['{{ item.key }}'] == (simple_tags_orig | combine(simple_tags_purge_false_change_multiple))['{{ item.key }}'] loop: > {{ simple_tags_orig | combine(simple_tags_purge_false_change_multiple) | dict2items }} loop_control: extended: yes - + - name: Change multiple tags (purge_tags=false) - Ensure no missing or additional tags assert: that: - > - result.parameter_metadata.tags_dict | length == {{ simple_tags_orig | + result.parameter_metadata.tags | length == {{ simple_tags_orig | combine(simple_tags_purge_false_change_multiple) | dict2items }} | length - name: Change multiple tags (purge_tags=false) - Lookup a tagged parameter @@ -1376,23 +1376,23 @@ purge_tags: False register: result - - name: Add/Change multiple tags (purge_tags=false) - Ensure expected tags_dict is correct + - name: Add/Change multiple tags (purge_tags=false) - Ensure expected tags is correct assert: that: - > - result.parameter_metadata.tags_dict['{{ item.key }}'] == + result.parameter_metadata.tags['{{ item.key }}'] == (simple_tags_orig | combine(simple_tags_purge_false_add_and_change))['{{ item.key }}'] loop: > {{ simple_tags_orig | combine(simple_tags_purge_false_add_and_change) | dict2items }} loop_control: extended: yes - + - name: Add/Change multiple tags (purge_tags=false) - Ensure no missing or additional tags assert: that: - > - result.parameter_metadata.tags_dict | length == {{ simple_tags_orig | + result.parameter_metadata.tags | length == {{ simple_tags_orig | combine(simple_tags_purge_false_add_and_change) | dict2items }} | length - name: Add/Change multiple tags (purge_tags=false) - Lookup a tagged parameter @@ -1457,21 +1457,21 @@ purge_tags: False register: result - - name: Empty tags dict (purge_tags=false) - Ensure expected tags_dict is correct + - name: Empty tags dict (purge_tags=false) - Ensure expected tags is correct assert: that: - > - result.parameter_metadata.tags_dict['{{ item.key }}'] == simple_tags_orig['{{ item.key }}'] + result.parameter_metadata.tags['{{ item.key }}'] == simple_tags_orig['{{ item.key }}'] loop: > {{ simple_tags_orig | dict2items }} loop_control: extended: yes - + - name: Empty tags dict (purge_tags=false) - Ensure no missing or additional tags assert: that: - > - result.parameter_metadata.tags_dict | length + result.parameter_metadata.tags | length == {{ simple_tags_orig | dict2items }} | length - name: Empty tags dict (purge_tags=false) - Lookup a tagged parameter @@ -1534,11 +1534,11 @@ description: '{{ simple_tag_param_updated_description }}' register: result - - name: No tags parameter (purge_tags=true) - Ensure expected tags_dict is correct + - name: No tags parameter (purge_tags=true) - Ensure expected tags is correct assert: that: - > - result.parameter_metadata.tags_dict['{{ item.key }}'] + result.parameter_metadata.tags['{{ item.key }}'] == simple_tags_orig['{{ item.key }}'] loop: > {{ simple_tags_orig | dict2items }} @@ -1549,7 +1549,7 @@ assert: that: - > - result.parameter_metadata.tags_dict | length + result.parameter_metadata.tags | length == {{ simple_tags_orig | dict2items }} | length - name: No tags parameter (purge_tags=true) - Lookup a tagged parameter