Skip to content

Commit e93004f

Browse files
authored
Merge pull request #50 from linux-kdevops/ci-testing/cel/aws-extra-volumes
Enable AWS to use fixed block device pathnames
2 parents e1ab612 + 9d6332c commit e93004f

File tree

19 files changed

+165
-15
lines changed

19 files changed

+165
-15
lines changed

playbooks/extra_volumes.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
- name: Set up udev rules for /dev/disk/kdevops/
3+
gather_facts: false
4+
hosts: baseline:dev:service
5+
roles:
6+
- role: extra_volumes
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
- name: Include provider-specific tasks
3+
ansible.builtin.include_tasks:
4+
file: "{{ role_path }}/tasks/providers/{{ kdevops_terraform_provider }}.yml"
5+
when:
6+
- kdevops_terraform_provider == "aws"
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
---
2+
- name: Install tmpfiles.d configuration for /dev/disk/kdevops/
3+
become: true
4+
ansible.builtin.template:
5+
src: "kdevops-disk.conf.j2"
6+
dest: "/etc/tmpfiles.d/kdevops-disk.conf"
7+
owner: "root"
8+
group: "root"
9+
mode: "u=rw,g=r,o=r"
10+
11+
- name: Create /dev/disk/kdevops/ directory using tmpfiles
12+
become: true
13+
ansible.builtin.command: "systemd-tmpfiles --create /etc/tmpfiles.d/kdevops-disk.conf"
14+
changed_when: true
15+
16+
- name: Extract the "extra volumes" map
17+
delegate_to: localhost
18+
run_once: true
19+
cloud.terraform.terraform_output:
20+
format: json
21+
name: "extra_volumes_map"
22+
project_path: "{{ topdir_path }}/terraform/aws"
23+
register: terraform_output
24+
25+
- name: Install the script that creates symlinks in /dev/disk/kdevops
26+
become: true
27+
vars:
28+
volume_mapping: "{{ terraform_output.value[inventory_hostname] }}"
29+
ansible.builtin.template:
30+
src: "udev-ebs-tagger.j2"
31+
dest: "/usr/local/bin/udev-ebs-tagger"
32+
owner: "root"
33+
group: "root"
34+
mode: "u=rwx,g=rx,o=rx"
35+
36+
- name: Create the "extra volumes" udev rule
37+
become: true
38+
ansible.builtin.template:
39+
src: 99-aws-ebs.rules.j2
40+
dest: "/etc/udev/rules.d/99-aws-ebs.rules"
41+
owner: "root"
42+
group: "root"
43+
mode: "u=rw,g=r,o=r"
44+
45+
- name: Force the target node to reload its udev ruleset and trigger block devices
46+
become: true
47+
ansible.builtin.shell: "udevadm control --reload && udevadm trigger --subsystem-match=block --action=add"
48+
changed_when: true
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
---
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
---
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
---
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ACTION=="add|change", KERNEL=="nvme[0-9]*n[0-9]*", SUBSYSTEM=="block", PROGRAM="/usr/local/bin/udev-ebs-tagger %k", SYMLINK+="%c"
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# kdevops extra volumes directory
2+
# This directory must exist before udev creates symlinks to extra volumes
3+
d /dev/disk/kdevops 0755 root root - -
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/bash
2+
3+
DEVICE="$1"
4+
5+
# Ensure the target directory exists
6+
mkdir -p /dev/disk/kdevops
7+
8+
# Get volume ID from device serial
9+
VOLUME_ID=$(/usr/bin/lsblk -no SERIAL "/dev/$DEVICE" 2>/dev/null | head -1)
10+
if [[ -z "$VOLUME_ID" || "$VOLUME_ID" == "null" ]]; then
11+
exit 0
12+
fi
13+
14+
# Static mapping from Terraform outputs
15+
case "$VOLUME_ID" in
16+
{% for tags, volume_id in volume_mapping.items() %}
17+
"{{ volume_id.replace("-", "") }}")
18+
SYMLINKS="disk/kdevops/{{ tags }} "
19+
echo "$SYMLINKS" | sed 's/[[:space:]]*$//'
20+
;;
21+
{% endfor %}
22+
*)
23+
# Unknown volume
24+
exit 0
25+
;;
26+
esac

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,14 @@
2828
register: terraform_output
2929
changed_when: false
3030

31-
# FIXME: Stuff "/dev/sdf" into the data_device variable for AWS
3231
- name: Exclude the device that will house the /data file system
3332
vars:
3433
block_device_dict: "{{ terraform_output.stdout | from_json }}"
3534
local_map: "{{ block_device_dict[inventory_hostname] }}"
3635
ansible.builtin.set_fact:
3736
ebs_volume_ids: "{{ ebs_volume_ids + ['nvme-Amazon_Elastic_Block_Store_' + item.value | regex_replace('-', '')] }}"
38-
when: item.key != "/dev/sdf"
37+
when:
38+
item.key != data_device
3939
with_dict: "{{ local_map }}"
4040

4141
- name: Add unused EBS volumes to the volume list

0 commit comments

Comments
 (0)