public inbox for kdevops@lists.linux.dev
 help / color / mirror / Atom feed
From: cel@kernel.org
To: Luis Chamberlain <mcgrof@kernel.org>,
	Chandan Babu R <chandanbabu@kernel.org>,
	Jeff Layton <jlayton@kernel.org>
Cc: <kdevops@lists.linux.dev>, Chuck Lever <chuck.lever@oracle.com>
Subject: [PATCH v1 09/13] volume_group: Create volume group on terraform/AWS nodes
Date: Mon, 10 Mar 2025 10:18:09 -0400	[thread overview]
Message-ID: <20250310141813.969325-10-cel@kernel.org> (raw)
In-Reply-To: <20250310141813.969325-1-cel@kernel.org>

From: Chuck Lever <chuck.lever@oracle.com>

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---
 .../volume_group/tasks/terraform/aws.yml      | 54 +++++++++++++++++++
 1 file changed, 54 insertions(+)
 create mode 100644 playbooks/roles/volume_group/tasks/terraform/aws.yml

diff --git a/playbooks/roles/volume_group/tasks/terraform/aws.yml b/playbooks/roles/volume_group/tasks/terraform/aws.yml
new file mode 100644
index 000000000000..e7cca3e259b0
--- /dev/null
+++ b/playbooks/roles/volume_group/tasks/terraform/aws.yml
@@ -0,0 +1,54 @@
+---
+#
+# To guarantee idempotency, these steps have to generate the exact
+# same physical_volumes list every time they are run.
+#
+# Skip the block device on which the root filesystem resides, and
+# skip the device that is to be used for /data.
+#
+# On AWS, normally the root device is /dev/nvme0n1 and the data
+# device is /dev/nvme1n1. However, this is not always the case:
+# block volumes can be attached to an instance in any order, thus
+# may appear as any device named /dev/nvmeNn1.
+#
+# So, extract the block device names, which should remain fixed for
+# the lifetime of the instance and its block devices. Use these to
+# avoid using the root and data devices as LVM physical volumes.
+#
+
+- name: Gather AWS instance information about the target node
+  delegate_to: localhost
+  amazon.aws.ec2_instance_info:
+    region: "{{ terraform_aws_region }}"
+    filters:
+      "tag:Name": "{{ inventory_hostname }}"
+      instance-state-name: ["running"]
+  register: instance_info
+
+# bdm is a list of dictionaries -- one dictionary per block device
+- name: Extract the block device mappings dictionary
+  ansible.builtin.set_fact:
+    bdm: "{{ instance_info.instances[0].block_device_mappings }}"
+
+- name: Discover the root device
+  ansible.builtin.set_fact:
+    root_ebs_volume: "{{ bdm | selectattr('device_name', 'match', '/dev/sda1') | first }}"
+
+# FIXME: Stuff "/dev/sdf" into the data_device variable for AWS
+- name: Discover the data device
+  ansible.builtin.set_fact:
+    data_ebs_volume: "{{ bdm | selectattr('device_name', 'match', '/dev/sdf') | first }}"
+
+- name: Add unused EBS volumes to the volume list
+  vars:
+    root_volume_id: "{{ root_ebs_volume.ebs.volume_id | string | regex_replace('-', '') }}"
+    data_volume_id: "{{ data_ebs_volume.ebs.volume_id | string | regex_replace('-', '') }}"
+  ansible.builtin.set_fact:
+    physical_volumes: "{{ physical_volumes + ['/dev/' + item.key] }}"
+  when:
+    - item.value.model == "Amazon Elastic Block Store"
+    - item.value.serial != root_volume_id
+    - item.value.serial != data_volume_id
+  loop_control:
+    label: "Adding block device: /dev/{{ item.key }}"
+  with_dict: "{{ ansible_devices }}"
-- 
2.48.1


  parent reply	other threads:[~2025-03-10 14:18 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-10 14:18 [PATCH v1 00/13] Block device provisioning for storage nodes cel
2025-03-10 14:18 ` [PATCH v1 01/13] terraform/AWS: Upgrade the EBS volume type to "gp3" cel
2025-03-10 14:18 ` [PATCH v1 02/13] terraform/Azure: Remove managed_disk_type selection cel
2025-03-10 14:18 ` [PATCH v1 03/13] terraform/Azure: Create a set of multiple generic block devices cel
2025-03-10 14:18 ` [PATCH v1 04/13] terraform/OCI: " cel
2025-03-13  5:56   ` Chandan Babu R
2025-03-10 14:18 ` [PATCH v1 05/13] guestfs: Set storage options consistently cel
2025-03-10 14:18 ` [PATCH v1 06/13] playbooks: Add a role to create an LVM volume group cel
2025-03-10 14:18 ` [PATCH v1 07/13] volume_group: Detect the /data partition directly cel
2025-03-10 14:18 ` [PATCH v1 08/13] volume_group: Prepare to support cloud providers cel
2025-03-10 14:18 ` cel [this message]
2025-03-10 14:18 ` [PATCH v1 10/13] volume_group: Create a volume group on Azure nodes cel
2025-03-10 14:18 ` [PATCH v1 11/13] volume_group: Create a volume group on GCE nodes cel
2025-03-10 14:18 ` [PATCH v1 12/13] volume_group: Create a volume group on OCI nodes cel
2025-03-13  6:29   ` Chandan Babu R
2025-03-10 14:18 ` [PATCH v1 13/13] volume_group: Create a volume group on OpenStack public clouds cel
2025-03-11  3:29 ` [PATCH v1 00/13] Block device provisioning for storage nodes Luis Chamberlain

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250310141813.969325-10-cel@kernel.org \
    --to=cel@kernel.org \
    --cc=chandanbabu@kernel.org \
    --cc=chuck.lever@oracle.com \
    --cc=jlayton@kernel.org \
    --cc=kdevops@lists.linux.dev \
    --cc=mcgrof@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox