HiveBrain v1.2.0
Get Started
← Back to all entries
patternMinor

Ansible: Test if multiple RDS instances are all stopped

Submitted by: @import:stackexchange-devops··
0
Viewed 0 times
instancesallarestoppedtestmultiplerdsansible

Problem

With Ansible, I'm stopping several RDS (it could be EC2) instances.

Then I want continue only when all of them are in the state stopped. I use the following task:

- name: Wait for RDS modify to finish
rds_instance_facts:
aws_access_key: "{{ assumed_role.sts_creds.access_key }}"
aws_secret_key: "{{ assumed_role.sts_creds.secret_key }}"
security_token: "{{ assumed_role.sts_creds.session_token }}"
db_instance_identifier: "{{ item }}"
region: "{{ region }}"
loop: "{{ vars[ 'list_rds_resources_ids1_' ] + vars[ 'list_rds_resources_ids2_' ] }}"
register: aws_rds_facts
until: aws_rds_facts[0].db_instance_status == "stopped"
retries: 90
delay: 10


Right now, my code is testing only the first element. How to make the test on all existing elements at the same time ?

Solution

If I understood you correctly, you need free strategy.
It will run all tasks ASAP, not waiting for anything.
https://docs.ansible.com/ansible/latest/plugins/strategy/free.html

Bear in mind, that logs will be a mess :)

Context

StackExchange DevOps Q#9456, answer score: 2

Revisions (0)

No revisions yet.