ansible / ansible

Ansible is a radically simple IT automation platform that makes your applications and systems easier to deploy and maintain. Automate everything from code deployment to network configuration to cloud management, in a language that approaches plain English, using SSH, with no agents to install on remote systems. https://docs.ansible.com.
https://www.ansible.com/
GNU General Public License v3.0
62.64k stars 23.86k forks source link

ecs_task module support listing running tasks #28554

Closed JoshuaSeidel closed 4 years ago

JoshuaSeidel commented 7 years ago
ANSIBLE VERSION

2.3.0

OS / ENVIRONMENT

N/A

SUMMARY

module should support the list function aws ecs list-tasks --cluster default

this will enable us to gather current running tasks in a cluster and then act upon them.

looks like the framework is already there to list the tasks, just need a option rather then run, start and stop to list the array of returned tasks.

ansibot commented 7 years ago

cc @simplesteph click here for bot help

simplesteph commented 7 years ago

can you please elaborate on use cases?

JoshuaSeidel commented 7 years ago

@simplesteph we're using ansbile for the CD process into ECS. right now when i mark a task as inactive create a new revision and update the service, it can take between 5-20min for 2 containers to swap out. for some environments we need it to move faster, so being able to query with ansible for the current running tasks, having them match up to the old task revision and stopping. this will speed up the swap out process.

simplesteph commented 7 years ago

that's odd. make sure you're not using a load balance with a graceful timeout of 300 seconds, or that your containers have graceful stops. This definitely shouldn't be the behaviour. Also look into min and max percent for the ecs service to tweak how many containers can go down together.

But this alone doesn't warrant a module IMO. This looks like just some AWS config you need to tweak

nrwahl2 commented 7 years ago

@simplesteph As @JoshuaSeidel mentioned, there is already a function built for this.

    def list_tasks(self, cluster_name, service_name, status):
        response = self.ecs.list_tasks(
            cluster=cluster_name,
            family=service_name,
            desiredStatus=status
        )
        if len(response['taskArns'])>0:
            for c in response['taskArns']:
                if c.endswith(service_name):
                    return c
        return None

There's just no module parameter to call it directly. Am I understanding this right?

simplesteph commented 7 years ago

no worries you can do a PR and add a Param if that helps then!

willthames commented 7 years ago

needs_contributor

This should probably be a new module ecs_task_facts rather than a new parameter for existing ecs_task module

ansibot commented 7 years ago

cc @dharmabumstead click here for bot help

ansibot commented 7 years ago

cc @Java1Guy click here for bot help

ansibot commented 4 years ago

cc @jillr @s-hertel @tremble click here for bot help

ansibot commented 4 years ago

Thank you very much for your interest in Ansible. Ansible has migrated much of the content into separate repositories to allow for more rapid, independent development. We are closing this issue/PR because this content has been moved to one or more collection repositories.

For further information, please see: https://github.com/ansible/ansibullbot/blob/master/docs/collection_migration.md