Hello @vreddy, Have a look at this. It might help
---
- hosts: 127.0.0.1
remote_user: ec2-user
become: true
tasks:
- import_tasks: tasks/main.yaml
- name: get instance id
uri:
url: http://169.254.169.254/latest/meta-data/instance-id
return_content: yes
register: aws_instance_id
- name: search for existing volume
ec2_vol_facts:
filters:
"tag:app": "nexus"
region: us-west-2
register: existing_volume
- include_tasks: tasks/first_time_installation.yaml
when: not existing_volume.volumes
- include_tasks: tasks/existing_volume.yaml
when: existing_volume.volumes
handlers:
- import_tasks: handlers/main.yaml