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, 2019 in AWS by Vreddy
• 130 points
1,217 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 Nov 14, 2019 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, 2019 in AWS by Subhash
569 views
0 votes
1 answer
0 votes
1 answer

Attach EBS Volume from one region to an instance on another region

No @Nik, you cannot do this. The ...READ MORE

answered Apr 12, 2019 in AWS by Jayant
1,732 views
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP