Attaching exisiting EBS volume to a self-healing instances with Ansible ?

+1 vote
i have instances With ASG attached and according to that once instance is in bad state and brought down and new instance was spun up then the EBS volumes which are orphaned by previous volume should get reattached to newley created instances through playbook
Oct 31 in AWS by Vreddy
• 130 points
33 views

1 answer to this question.

+1 vote

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
answered 3 days ago by Eric

Related Questions In AWS

0 votes
1 answer

Attaching multiple instance with same EBS Volume

Attaching multiple instances to one volume is ...READ MORE

answered Jan 31 in AWS by Subhash
31 views
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer