Hi All,
I have the following playbook which i want to create
---
- hosts: localhost
connection: local
gather_facts: False
vars_files:
- ebs-aws/external_vars.yml
tasks:
- name: stop service
- name: Connect to instance and unmount the vol
- name: Detach vol from each instances
ec2_vol:
region: "{{ item.region }}"
instance: "{{ item.instanceid }}"
id: "{{ item.old_vol }}"
aws_access_key: "{{ ec2_access_key }}"
aws_secret_key: "{{ ec2_secret_key }}"
instance: None
with_items:
- "{{ mappings }}"
- name: Attach vol to each instances
ec2_vol:
region: "{{ item.region }}"
instance: "{{ item.instanceid }}"
id: "{{ item.new_vol }}"
aws_access_key: "{{ ec2_access_key }}"
aws_secret_key: "{{ ec2_secret_key }}"
volume_type: gp2
device_name: /dev/xvdh
with_items:
- "{{ mappings }}"
- name: Connect to instance and mount the vol
- name: start service
ebs-aws/external_vars.yml
mappings:
- { publicip: '', old_vol: '', instanceid: '', new_vol: '', region: '', az: '' }
I have a requirement to connect to the public ip of the instance and stop the service and umount the volume and then detach the vol and reattach the volume and once done. Connect to the instance and remount the volume and start the service? The ec2 instances are not launched by ansible for it to register.
How do i accomplish this doing this per host basic?
Regards,
Kevin