Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions playbooks/extra_volumes.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
- name: Set up udev rules for /dev/disk/kdevops/
gather_facts: false
hosts: baseline:dev:service
roles:
- role: extra_volumes
6 changes: 6 additions & 0 deletions playbooks/roles/extra_volumes/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
- name: Include provider-specific tasks
ansible.builtin.include_tasks:
file: "{{ role_path }}/tasks/providers/{{ kdevops_terraform_provider }}.yml"
when:
- kdevops_terraform_provider == "aws"
48 changes: 48 additions & 0 deletions playbooks/roles/extra_volumes/tasks/providers/aws.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
---
- name: Install tmpfiles.d configuration for /dev/disk/kdevops/
become: true
ansible.builtin.template:
src: "kdevops-disk.conf.j2"
dest: "/etc/tmpfiles.d/kdevops-disk.conf"
owner: "root"
group: "root"
mode: "u=rw,g=r,o=r"

- name: Create /dev/disk/kdevops/ directory using tmpfiles
become: true
ansible.builtin.command: "systemd-tmpfiles --create /etc/tmpfiles.d/kdevops-disk.conf"
changed_when: true

- name: Extract the "extra volumes" map
delegate_to: localhost
run_once: true
cloud.terraform.terraform_output:
format: json
name: "extra_volumes_map"
project_path: "{{ topdir_path }}/terraform/aws"
register: terraform_output

- name: Install the script that creates symlinks in /dev/disk/kdevops
become: true
vars:
volume_mapping: "{{ terraform_output.value[inventory_hostname] }}"
ansible.builtin.template:
src: "udev-ebs-tagger.j2"
dest: "/usr/local/bin/udev-ebs-tagger"
owner: "root"
group: "root"
mode: "u=rwx,g=rx,o=rx"

- name: Create the "extra volumes" udev rule
become: true
ansible.builtin.template:
src: 99-aws-ebs.rules.j2
dest: "/etc/udev/rules.d/99-aws-ebs.rules"
owner: "root"
group: "root"
mode: "u=rw,g=r,o=r"

- name: Force the target node to reload its udev ruleset and trigger block devices
become: true
ansible.builtin.shell: "udevadm control --reload && udevadm trigger --subsystem-match=block --action=add"
changed_when: true
1 change: 1 addition & 0 deletions playbooks/roles/extra_volumes/tasks/providers/azure.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
---
1 change: 1 addition & 0 deletions playbooks/roles/extra_volumes/tasks/providers/gce.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
---
1 change: 1 addition & 0 deletions playbooks/roles/extra_volumes/tasks/providers/oci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
---
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ACTION=="add|change", KERNEL=="nvme[0-9]*n[0-9]*", SUBSYSTEM=="block", PROGRAM="/usr/local/bin/udev-ebs-tagger %k", SYMLINK+="%c"
3 changes: 3 additions & 0 deletions playbooks/roles/extra_volumes/templates/kdevops-disk.conf.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# kdevops extra volumes directory
# This directory must exist before udev creates symlinks to extra volumes
d /dev/disk/kdevops 0755 root root - -
26 changes: 26 additions & 0 deletions playbooks/roles/extra_volumes/templates/udev-ebs-tagger.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash

DEVICE="$1"

# Ensure the target directory exists
mkdir -p /dev/disk/kdevops

# Get volume ID from device serial
VOLUME_ID=$(/usr/bin/lsblk -no SERIAL "/dev/$DEVICE" 2>/dev/null | head -1)
if [[ -z "$VOLUME_ID" || "$VOLUME_ID" == "null" ]]; then
exit 0
fi

# Static mapping from Terraform outputs
case "$VOLUME_ID" in
{% for tags, volume_id in volume_mapping.items() %}
"{{ volume_id.replace("-", "") }}")
SYMLINKS="disk/kdevops/{{ tags }} "
echo "$SYMLINKS" | sed 's/[[:space:]]*$//'
;;
{% endfor %}
*)
# Unknown volume
exit 0
;;
esac
4 changes: 2 additions & 2 deletions playbooks/roles/volume_group/tasks/terraform/aws.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@
register: terraform_output
changed_when: false

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

- name: Add unused EBS volumes to the volume list
Expand Down
3 changes: 3 additions & 0 deletions scripts/terraform.Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,9 @@ $(KDEVOPS_PROVISIONED_SSH):
baseline:dev:service \
-m wait_for_connection
$(Q)touch $(KDEVOPS_PROVISIONED_SSH)
$(Q)ansible-playbook $(ANSIBLE_VERBOSE) \
-i hosts playbooks/extra_volumes.yml \
--extra-vars=@./extra_vars.yaml

status_terraform:
$(Q)ansible-playbook $(ANSIBLE_VERBOSE) \
Expand Down
17 changes: 15 additions & 2 deletions terraform/aws/kconfigs/Kconfig.storage
Original file line number Diff line number Diff line change
Expand Up @@ -203,5 +203,18 @@ config TERRAFORM_AWS_EBS_VOLUME_SIZE
default 4096 if TERRAFORM_AWS_EBS_VOLUME_SIZE_4096G

config TERRAFORM_AWS_DATA_VOLUME_DEVICE_FILE_NAME
string
default "/dev/nvme1n1"
string "Data volume's device file name"
output yaml
default "/dev/disk/kdevops/extra-volume-00"
help
This option sets the name of the block device on each
target node that is to be used for the /data file system.

config TERRAFORM_AWS_SPARSE_VOLUME_DEVICE_FILE_NAME
string "Sparse volume's device file name"
output yaml
default "/dev/disk/kdevops/extra-volume-01"
help
This option sets the name of the block device on each
target node that can be used for the fstests sparse device
tests.
4 changes: 4 additions & 0 deletions terraform/aws/kdevops_ebs_volumes/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ resource "aws_ebs_volume" "kdevops_volume" {
size = var.vol_size
throughput = var.vol_throughput
type = var.vol_type

tags = {
FixedName = format("extra-volume-%02d", count.index)
}
}

resource "aws_volume_attachment" "kdevops_attachment" {
Expand Down
6 changes: 6 additions & 0 deletions terraform/aws/kdevops_ebs_volumes/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,9 @@ output "ebs_volume_map" {
value = zipmap(aws_volume_attachment.kdevops_attachment[*].device_name,
aws_volume_attachment.kdevops_attachment[*].volume_id)
}

output "extra_volumes_tags" {
description = "Tag to volume ID mappings for udev configuration"
value = zipmap(aws_ebs_volume.kdevops_volume[*].tags["FixedName"],
aws_volume_attachment.kdevops_attachment[*].volume_id)
}
6 changes: 6 additions & 0 deletions terraform/aws/output.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,9 @@ output "block_device_map" {
value = zipmap(var.kdevops_nodes[*],
module.kdevops_ebs_volumes[*].ebs_volume_map)
}

output "extra_volumes_map" {
description = "Tag to volume ID mappings for udev configuration"
value = zipmap(var.kdevops_nodes[*],
module.kdevops_ebs_volumes[*].extra_volumes_tags)
}
16 changes: 13 additions & 3 deletions terraform/azure/kconfigs/Kconfig.storage
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,18 @@ config TERRAFORM_AZURE_MANAGED_DISKS_TIER
default "P50" if TERRAFORM_AZURE_MANAGED_DISKS_TIER_P50

config TERRAFORM_AZURE_DATA_VOLUME_DEVICE_FILE_NAME
string "Device name for the /data file system"
string "Data volume's device file name"
output yaml
default "/dev/disk/azure/scsi1/lun0"
help
This option sets the name of the block device on each target
node that is to be used for the /data file system.
This option sets the name of the block device on each
target node that is to be used for the /data file system.

config TERRAFORM_AZURE_SPARSE_VOLUME_DEVICE_FILE_NAME
string "Sparse volume's device file name"
output yaml
default "/dev/disk/azure/scsi1/lun1"
help
This option sets the name of the block device on each
target node that can be used for the fstests sparse device
tests.
14 changes: 13 additions & 1 deletion terraform/gce/kconfigs/Kconfig.storage
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,18 @@ config TERRAFORM_GCE_DISK_THROUGHPUT
depends on TERRAFORM_GCE_DISK_NEEDS_THROUGHPUT

config TERRAFORM_GCE_DATA_VOLUME_DEVICE_FILE_NAME
string
string "Data volume's device file name"
output yaml
default "/dev/disk/by-id/google-persistent-disk-1"
help
This option sets the name of the block device on each
target node that is to be used for the /data file system.

config TERRAFORM_GCE_SPARSE_VOLUME_DEVICE_FILE_NAME
string "Sparse volume's device file name"
output yaml
default "/dev/disk/by-id/google-persistent-disk-2"
help
This option sets the name of the block device on each
target node that can be used for the fstests sparse device
tests.
7 changes: 5 additions & 2 deletions terraform/oci/kconfigs/Kconfig.storage
Original file line number Diff line number Diff line change
Expand Up @@ -259,11 +259,14 @@ config TERRAFORM_OCI_DATA_VOLUME_DEVICE_FILE_NAME
output yaml
default "/dev/oracleoci/oraclevdb"
help
Data volume's device file name
This option sets the name of the block device on each
target node that is to be used for the /data file system.

config TERRAFORM_OCI_SPARSE_VOLUME_DEVICE_FILE_NAME
string "Sparse volume's device file name"
output yaml
default "/dev/oracleoci/oraclevdc"
help
Sparse volume's device file name
This option sets the name of the block device on each
target node that can be used for the fstests sparse device
tests.
10 changes: 5 additions & 5 deletions workflows/fstests/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -539,13 +539,13 @@ config FSTESTS_SPARSE_DEV
default "/dev/disk/by-id/virtio-kdevops1" if LIBVIRT && LIBVIRT_EXTRA_STORAGE_DRIVE_VIRTIO
default "/dev/disk/by-id/ata-QEMU_HARDDISK_kdevops1" if LIBVIRT && LIBVIRT_EXTRA_STORAGE_DRIVE_IDE
default "/dev/disk/by-id/scsi-0QEMU_QEMU_HARDDISK_kdevops1" if LIBVIRT && LIBVIRT_EXTRA_STORAGE_DRIVE_SCSI
default "/dev/nvme2n1" if TERRAFORM_AWS_INSTANCE_M5AD_4XLARGE
default "/dev/nvme1n1" if TERRAFORM_GCE
default "/dev/sdd" if TERRAFORM_AZURE
default TERRAFORM_AWS_SPARSE_VOLUME_DEVICE_FILE_NAME if TERRAFORM_AWS
default TERRAFORM_GCE_SPARSE_VOLUME_DEVICE_FILE_NAME if TERRAFORM_GCE
default TERRAFORM_AZURE_SPARSE_VOLUME_DEVICE_FILE_NAME if TERRAFORM_AZURE
default TERRAFORM_OCI_SPARSE_VOLUME_DEVICE_FILE_NAME if TERRAFORM_OCI
help
The device to use to create a filesystem on where we will place
sparse files.
The device pathname to use to create a filesystem where
fstests places sparse files.

choice
prompt "Filesystem to use where sparse files will live"
Expand Down
Loading