Files
dc-deployments-automation/roles/bitbucket_mesh_config/tasks/meshvol_create.yml
2024-03-25 14:27:28 -05:00

49 lines
1.8 KiB
YAML

---
# hydrate mesh volume from snapshot or create empty one if no snapshot set
- name: create new ebs from snapshot for this mesh node with correct tags
amazon.aws.ec2_vol:
region: "{{ ansible_ec2_placement_region }}"
instance: "{{ ansible_ec2_instance_id }}"
volume_type: gp3
throughput: 250
device_name: /dev/xvdd
snapshot: "{{ mesh_snapshot }}"
tags:
service_name: "{{ atl_aws_stack_name }}"
Name: "{{ atl_aws_stack_name }} mesh volume {{ ansible_ec2_placement_availability_zone }}"
volume_type: "mesh"
register: mesh_vol_info
when: (mesh_snapshot is defined) and (mesh_snapshot|length > 0)
- name: set mesh_vol from info of vol created from snapshot
ansible.builtin.set_fact:
mesh_vol: "{{ mesh_vol_info.volume_id }}"
new_meshvol_from_snap: true
when: (mesh_snapshot is defined) and (mesh_snapshot|length > 0)
# if we still dont have mesh_vol, create new/empty one
- name: final choice - create empty mesh_vol
amazon.aws.ec2_vol:
region: "{{ ansible_ec2_placement_region }}"
instance: "{{ ansible_ec2_instance_id }}"
volume_size: "{{ atl_mesh_volume_size }}"
volume_type: gp3
throughput: 250
iops: 3072
device_name: /dev/xvdd
tags:
service_name: "{{ atl_aws_stack_name }}"
Name: "{{ atl_aws_stack_name }} mesh volume {{ ansible_ec2_placement_availability_zone }}"
volume_type: "mesh"
register: mesh_vol_info
when: (mesh_snapshot is not defined) or (mesh_snapshot|length == 0)
- name: set mesh_vol from info of created
ansible.builtin.set_fact:
mesh_vol: "{{ mesh_vol_info.volume_id }}"
when: (mesh_snapshot is not defined) or (mesh_snapshot|length == 0)
# we should always have mesh_vol by now, if not, Barf !
- name: we should always have mesh_vol by now
ansible.builtin.debug:
var: mesh_vol