Skip to content

Commit 8f85fa6

Browse files
committed
volume_groups: Fix tasks/terraform/aws.yml
Commit 9d6332c ("volume_group: Use cloud provider's default data disk") was incomplete. Take full advantage of the new mechanism to determine which EBS devices are available for use by kdevops. Fixes: 9d6332c ("volume_group: Use cloud provider's default data disk") Assisted-by: Claude AI Signed-off-by: Chuck Lever <[email protected]>
1 parent 6898a15 commit 8f85fa6

File tree

1 file changed

+12
-32
lines changed
  • playbooks/roles/volume_group/tasks/terraform

1 file changed

+12
-32
lines changed

playbooks/roles/volume_group/tasks/terraform/aws.yml

Lines changed: 12 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -10,39 +10,19 @@
1010
# are not fixed and cannot be depended upon to locate specific
1111
# devices or their content.
1212
#
13-
# The block device name attached to each volume is fixed by
14-
# terraform but not exposed to Ansible or the guest. It has to be
15-
# extracted from terraform state and matched to a volume ID, which
16-
# appears as the device serial number.
13+
# Instead, rely on a directory created by a udev rule to find the
14+
# EBS block devices attached on behalf of kdevops. The rule
15+
# guarantees the symlinks names always point to the same block
16+
# device.
1717
#
18-
# The root EBS device is not included in terraform's block device
19-
# map, so is easily avoided.
20-
#
21-
22-
- name: Retrieve the block_device_map from terraform
23-
delegate_to: localhost
24-
run_once: true
25-
ansible.builtin.command:
26-
chdir: "{{ topdir_path }}/terraform/aws/"
27-
cmd: "terraform output -json block_device_map"
28-
register: terraform_output
29-
changed_when: false
3018

31-
- name: Exclude the device that will house the /data file system
32-
vars:
33-
block_device_dict: "{{ terraform_output.stdout | from_json }}"
34-
local_map: "{{ block_device_dict[inventory_hostname] }}"
35-
ansible.builtin.set_fact:
36-
ebs_volume_ids: "{{ ebs_volume_ids + ['nvme-Amazon_Elastic_Block_Store_' + item.value | regex_replace('-', '')] }}"
37-
when:
38-
item.key != data_device
39-
with_dict: "{{ local_map }}"
19+
- name: Retrieve list of symlinks residing under /dev/disk/kdevops
20+
ansible.builtin.find:
21+
file_type: link
22+
paths: "/dev/disk/kdevops"
23+
excludes: "{{ data_device | basename }}"
24+
register: find_output
4025

41-
- name: Add unused EBS volumes to the volume list
26+
- name: Extract device paths from find output
4227
ansible.builtin.set_fact:
43-
physical_volumes: "{{ physical_volumes + ['/dev/' + item.key] }}"
44-
when:
45-
- item.value.links.ids | intersect(ebs_volume_ids) | list | count > 0
46-
loop_control:
47-
label: "Adding block device: /dev/{{ item.key }}"
48-
with_dict: "{{ ansible_devices }}"
28+
physical_volumes: "{{ find_output.files | map(attribute='path') | list }}"

0 commit comments

Comments
 (0)