I am running an Ansible script on EC2 with Cloudformation. The ansible script runs when the instance is created and there's an autoscaling group waiting for cfn-signal from the instance.
I want Ansible to wait for few logs to appear. The logs can come in any particular order saying that a module has finished being deployed. After all logs have appeared, I would like to signal the CF stack that the application is healthy.
I have tried the following:
- name: Check if applications were deployed properly
wait_for:
path: "{{ LOGFILE }}"
search_regex: "{{ item }} has finished"
timeout: 120
delay: 3
loop:
- application1
- application2
- application3
- name: Send Cloudformation sucess signal
command: "/opt/aws/bin/cfn-signal --stack {{ stackname }} --resource AutoScalingGroup --region {{ region }} --success true"
However, this is not working and it seems like Ansible is waiting in order. How can I achieve this asynchronously?
you can use parameter async, e.g.
Source: https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_async.html
Edit: I've missed the unordered need so I've changed my answer accordingly