ecs_tag: remove state=list (#66811)

* ecs_tag: remove state=list

* adjust tests
This commit is contained in:
René Moser 2020-01-29 10:30:53 +01:00 committed by GitHub
parent 3c3cf50e7a
commit 4752547d35
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 44 deletions

View file

@ -15,7 +15,7 @@ short_description: create and remove tags on Amazon ECS resources
notes: notes:
- none - none
description: description:
- Creates, removes and lists tags for Amazon ECS resources. - Creates and removes tags for Amazon ECS resources.
- Resources are referenced by their cluster name. - Resources are referenced by their cluster name.
version_added: '2.10' version_added: '2.10'
author: author:
@ -41,9 +41,8 @@ options:
state: state:
description: description:
- Whether the tags should be present or absent on the resource. - Whether the tags should be present or absent on the resource.
- Use C(list) to interrogate the tags of an ECS resource.
default: present default: present
choices: ['present', 'absent', 'list'] choices: ['present', 'absent']
type: str type: str
tags: tags:
description: description:
@ -71,13 +70,6 @@ EXAMPLES = r'''
Name: ubervol Name: ubervol
env: prod env: prod
- name: Retrieve all tags on a cluster
ecs_tag:
cluster_name: mycluster
resource: http_task
resource_type: task
state: list
- name: Remove the Env tag - name: Remove the Env tag
ecs_tag: ecs_tag:
cluster_name: mycluster cluster_name: mycluster
@ -168,7 +160,7 @@ def main():
resource=dict(required=False), resource=dict(required=False),
tags=dict(type='dict'), tags=dict(type='dict'),
purge_tags=dict(type='bool', default=False), purge_tags=dict(type='bool', default=False),
state=dict(default='present', choices=['present', 'absent', 'list']), state=dict(default='present', choices=['present', 'absent']),
resource_type=dict(default='cluster', choices=['cluster', 'task', 'service', 'task_definition', 'container']) resource_type=dict(default='cluster', choices=['cluster', 'task', 'service', 'task_definition', 'container'])
) )
required_if = [('state', 'present', ['tags']), ('state', 'absent', ['tags'])] required_if = [('state', 'present', ['tags']), ('state', 'absent', ['tags'])]
@ -193,9 +185,6 @@ def main():
current_tags = get_tags(ecs, module, resource_arn) current_tags = get_tags(ecs, module, resource_arn)
if state == 'list':
module.exit_json(changed=False, tags=current_tags)
add_tags, remove = compare_aws_tags(current_tags, tags, purge_tags=purge_tags) add_tags, remove = compare_aws_tags(current_tags, tags, purge_tags=purge_tags)
remove_tags = {} remove_tags = {}

View file

@ -56,21 +56,6 @@
# Test tagging cluster resource # Test tagging cluster resource
- name: cluster tags - list when there are none
ecs_tag:
cluster_name: "{{ resource_prefix}}"
resource: "{{ resource_prefix}}"
resource_type: cluster
state: list
register: taglist
- name: cluster tags - Should be an empty list
assert:
that:
- taglist.tags|list|length == 0
- taglist.failed == false
- taglist.changed == false
- name: cluster tags - Add tags to cluster - name: cluster tags - Add tags to cluster
ecs_tag: ecs_tag:
cluster_name: "{{resource_prefix}}" cluster_name: "{{resource_prefix}}"
@ -209,21 +194,6 @@
- taglist.changed == false - taglist.changed == false
- taglist.tags.Name == "service-{{ resource_prefix }}" - taglist.tags.Name == "service-{{ resource_prefix }}"
- name: service tags - retrieve all tags on a service
ecs_tag:
cluster_name: "{{resource_prefix}}"
resource: "{{ecs_service_creation.service.serviceName}}"
resource_type: service
state: list
register: taglist
- name: services tags - should have 1 tag
assert:
that:
- taglist.tags|list|length == 1
- taglist.failed == false
- taglist.changed == false
- name: service tags - remove service tags - name: service tags - remove service tags
ecs_tag: ecs_tag:
cluster_name: "{{resource_prefix}}" cluster_name: "{{resource_prefix}}"