public inbox for kdevops@lists.linux.dev
 help / color / mirror / Atom feed
From: Luis Chamberlain <mcgrof@kernel.org>
To: Chuck Lever <cel@kernel.org>, Daniel Gomez <da.gomez@kruces.com>,
	kdevops@lists.linux.dev
Cc: hui81.qi@samsung.com, kundan.kumar@samsung.com,
	Luis Chamberlain <mcgrof@kernel.org>
Subject: [PATCH v2 2/4] declared_hosts: add support for pre-existing infrastructure
Date: Sat, 30 Aug 2025 21:11:58 -0700	[thread overview]
Message-ID: <20250831041202.2172115-3-mcgrof@kernel.org> (raw)
In-Reply-To: <20250831041202.2172115-1-mcgrof@kernel.org>

This adds comprehensive support for using pre-existing infrastructure
(bare metal servers, pre-provisioned VMs, cloud instances) that users
already have SSH access to, bypassing the kdevops bringup process.

The declared hosts feature allows kdevops to work with systems that are
already provisioned and accessible, which is essential for:
- Bare metal testing environments
- Pre-existing cloud instances
- Systems managed by other infrastructure tools
- Development environments where bringup isn't needed

Key implementation details:

1. Configuration (Kconfig):
   - New KDEVOPS_USE_DECLARED_HOSTS option that can be enabled via
     SKIP_BRINGUP or DECLARED_HOSTS CLI variable
   - KDEVOPS_DECLARED_HOSTS accepts space or comma-separated host lists
   - Automatically selects WORKFLOW_INFER_USER_AND_GROUP for proper
     user/group detection on target systems
   - Python interpreter path configuration for declared hosts

2. Template system integration:
   - Seamlessly integrates with the simplified gen_hosts template system
   - Uses dedicated declared-hosts.j2 template when declared hosts are enabled
   - Properly handles host parsing for both string and list formats
   - Maintains compatibility with A/B testing configurations

3. Data partition handling:
   - Disables data partition creation for declared hosts (assumes
     pre-configured storage)
   - Adds DATA_PATH CLI override support for custom data paths
   - Ensures data directory exists with proper permissions when using
     declared hosts

4. Workflow restrictions:
   - All workflows are restricted when using declared hosts pending
     individual review and testing
   - Each workflow needs verification for declared hosts compatibility
   - This ensures stability while the feature is gradually rolled out

5. CLI variable support:
   - DECLARED_HOSTS environment variable for specifying hosts
   - DATA_PATH environment variable for custom data paths
   - Follows kdevops pattern of CLI overrides for configuration

The implementation maintains backward compatibility while providing a
clean path for using kdevops with existing infrastructure. Future work
will involve reviewing and enabling individual workflows for declared
hosts support after proper testing.

Note: Currently no workflows are fully supported with declared hosts.
Each workflow requires individual review and testing to ensure proper
operation with pre-existing infrastructure before being enabled.

Generated-by: Claude AI
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
---
 Makefile                                      |   8 +
 defconfigs/xfs_reflink_16k_4ks_declared       |  19 ++
 kconfigs/Kconfig.bringup                      |   9 +-
 kconfigs/Kconfig.declared_hosts               |  81 ++++++
 kconfigs/workflows/Kconfig                    |  23 ++
 kconfigs/workflows/Kconfig.data_partition     |  11 +
 .../create_data_partition/tasks/main.yml      |  23 ++
 playbooks/roles/devconfig/defaults/main.yml   |   2 +
 playbooks/roles/devconfig/tasks/main.yml      |  25 ++
 playbooks/roles/gen_hosts/defaults/main.yml   |   1 +
 playbooks/roles/gen_hosts/tasks/main.yml      |  17 ++
 playbooks/roles/gen_hosts/templates/hosts.j2  |   6 +
 .../templates/workflows/declared-hosts.j2     | 239 ++++++++++++++++++
 playbooks/roles/gen_nodes/defaults/main.yml   |   1 +
 playbooks/roles/gen_nodes/tasks/main.yml      |   4 +-
 15 files changed, 467 insertions(+), 2 deletions(-)
 create mode 100644 defconfigs/xfs_reflink_16k_4ks_declared
 create mode 100644 kconfigs/Kconfig.declared_hosts
 create mode 100644 playbooks/roles/gen_hosts/templates/workflows/declared-hosts.j2

diff --git a/Makefile b/Makefile
index 83c6734..625d775 100644
--- a/Makefile
+++ b/Makefile
@@ -19,6 +19,14 @@ export KDEVOPS_NODES :=
 export PYTHONUNBUFFERED=1
 export TOPDIR=./
 export TOPDIR_PATH = $(shell readlink -f $(TOPDIR))
+
+# Export CLI override variables for Kconfig to detect them
+# Note: We accept DECLARE_HOSTS but export as DECLARED_HOSTS for consistency
+ifdef DECLARE_HOSTS
+export DECLARED_HOSTS := $(DECLARE_HOSTS)
+endif
+export DATA_PATH
+
 include scripts/refs.Makefile
 
 KDEVOPS_NODES_ROLE_TEMPLATE_DIR :=		$(KDEVOPS_PLAYBOOKS_DIR)/roles/gen_nodes/templates
diff --git a/defconfigs/xfs_reflink_16k_4ks_declared b/defconfigs/xfs_reflink_16k_4ks_declared
new file mode 100644
index 0000000..e35a32f
--- /dev/null
+++ b/defconfigs/xfs_reflink_16k_4ks_declared
@@ -0,0 +1,19 @@
+CONFIG_WORKFLOWS=y
+CONFIG_WORKFLOW_LINUX_CUSTOM=y
+
+CONFIG_BOOTLINUX=y
+CONFIG_BOOTLINUX_9P=y
+
+CONFIG_WORKFLOWS_TESTS=y
+CONFIG_WORKFLOWS_LINUX_TESTS=y
+CONFIG_WORKFLOWS_DEDICATED_WORKFLOW=n
+CONFIG_KDEVOPS_WORKFLOW_NOT_DEDICATED_ENABLE_FSTESTS=y
+
+CONFIG_FSTESTS_XFS=y
+CONFIG_FSTESTS_FSTYP="xfs"
+CONFIG_FSTESTS_XFS_MANUAL_COVERAGE=y
+CONFIG_FSTESTS_XFS_ENABLE_LBS=y
+CONFIG_FSTESTS_XFS_ENABLE_LBS_4KS=y
+CONFIG_FSTESTS_XFS_SECTION_REFLINK_ENABLED=y
+
+CONFIG_FSTESTS_XFS_SECTION_REFLINK_16K_4KS=y
diff --git a/kconfigs/Kconfig.bringup b/kconfigs/Kconfig.bringup
index b64ba50..26b6479 100644
--- a/kconfigs/Kconfig.bringup
+++ b/kconfigs/Kconfig.bringup
@@ -13,10 +13,16 @@ config CLOUD_INITIALIZED
 	bool
 	default $(shell, test -f .cloud.initialized && echo y || echo n) = "y"
 
+# CLI override detection for DECLARED_HOSTS which should enable SKIP_BRINGUP
+config SKIP_BRINGUP_SET_BY_CLI
+	bool
+	default $(shell, scripts/check-cli-set-var.sh DECLARED_HOSTS)
+	select SKIP_BRINGUP
+
 choice
 	prompt "Node bring up method"
 	default TERRAFORM if CLOUD_INITIALIZED
-	default GUESTFS
+	default GUESTFS if !CLOUD_INITIALIZED
 
 config GUESTFS
 	bool "Use guestfs-tools for local virtualization via KVM and libvirt"
@@ -85,6 +91,7 @@ config LIBVIRT
 source "kconfigs/Kconfig.guestfs"
 source "kconfigs/Kconfig.nixos"
 source "terraform/Kconfig"
+source "kconfigs/Kconfig.declared_hosts"
 if LIBVIRT
 source "kconfigs/Kconfig.libvirt"
 endif
diff --git a/kconfigs/Kconfig.declared_hosts b/kconfigs/Kconfig.declared_hosts
new file mode 100644
index 0000000..e1300e1
--- /dev/null
+++ b/kconfigs/Kconfig.declared_hosts
@@ -0,0 +1,81 @@
+# Configuration for declared hosts that skip bringup process
+
+# CLI override support for DECLARED_HOSTS
+config KDEVOPS_DECLARED_HOSTS_SET_BY_CLI
+	bool
+	output yaml
+	default $(shell, scripts/check-cli-set-var.sh DECLARED_HOSTS)
+
+config KDEVOPS_USE_DECLARED_HOSTS
+	bool "Use declared hosts (skip bringup process)"
+	depends on SKIP_BRINGUP || KDEVOPS_DECLARED_HOSTS_SET_BY_CLI
+	select WORKFLOW_INFER_USER_AND_GROUP
+	output yaml
+	default y if SKIP_BRINGUP
+	default y if KDEVOPS_DECLARED_HOSTS_SET_BY_CLI
+	help
+	  Enable this option to use pre-existing hosts that you have already
+	  configured with SSH access. This is useful for:
+
+	  * Bare metal systems
+	  * Pre-provisioned VMs or cloud instances
+	  * Systems managed by other infrastructure tools
+
+	  When this option is enabled:
+	  - SSH keys will not be generated (assumes you already have access)
+	  - Bringup and teardown operations will be skipped
+	  - User and group settings will be inferred from the target hosts
+	  - You must provide the list of hosts in KDEVOPS_DECLARED_HOSTS
+
+	  This option automatically:
+	  - Selects WORKFLOW_INFER_USER_AND_GROUP to detect the correct
+	    user and group on the target systems
+	  - Assumes SSH access is already configured
+
+config KDEVOPS_DECLARED_HOSTS
+	string "List of declared hosts"
+	depends on KDEVOPS_USE_DECLARED_HOSTS
+	output yaml
+	default "$(shell, echo ${DECLARED_HOSTS})" if KDEVOPS_DECLARED_HOSTS_SET_BY_CLI
+	default ""
+	help
+	  Provide a list of hostnames or IP addresses for the pre-existing
+	  systems you want to use. These hosts must already be accessible
+	  via SSH with the appropriate keys configured.
+
+	  Format: Space or comma-separated list
+	  Example: "host1 host2 host3" or "host1,host2,host3"
+
+	  These hosts will be used directly without any bringup process.
+	  Make sure you have:
+	  - SSH access configured
+	  - Required packages installed
+	  - Appropriate user permissions
+
+if KDEVOPS_USE_DECLARED_HOSTS
+
+config KDEVOPS_DECLARED_HOSTS_PYTHON_INTERPRETER
+	string "Python interpreter path on declared hosts"
+	default "/usr/bin/python3"
+	output yaml
+	help
+	  Specify the path to the Python interpreter on the declared hosts.
+	  This is required for Ansible to function properly.
+
+	  Common values:
+	  - /usr/bin/python3 (most modern systems)
+	  - /usr/bin/python (older systems)
+	  - /usr/local/bin/python3 (custom installations)
+
+config KDEVOPS_DECLARED_HOSTS_GROUP_VARS
+	bool "Apply group variables to declared hosts"
+	default y
+	output yaml
+	help
+	  When enabled, kdevops will apply the appropriate group variables
+	  to the declared hosts based on the selected workflow.
+
+	  This ensures that declared hosts receive the same configuration
+	  variables as dynamically provisioned hosts would.
+
+endif # KDEVOPS_USE_DECLARED_HOSTS
diff --git a/kconfigs/workflows/Kconfig b/kconfigs/workflows/Kconfig
index 0c09394..cca0b70 100644
--- a/kconfigs/workflows/Kconfig
+++ b/kconfigs/workflows/Kconfig
@@ -124,6 +124,7 @@ choice
 config KDEVOPS_WORKFLOW_DEDICATE_FSTESTS
 	bool "fstests"
 	select KDEVOPS_WORKFLOW_ENABLE_FSTESTS
+	depends on !KDEVOPS_USE_DECLARED_HOSTS
 	help
 	  This will dedicate your configuration only to fstests.
 
@@ -139,12 +140,14 @@ config KDEVOPS_WORKFLOW_DEDICATE_FSTESTS
 
 config KDEVOPS_WORKFLOW_DEDICATE_BLKTESTS
 	bool "blktests"
+	depends on !KDEVOPS_USE_DECLARED_HOSTS
 	select KDEVOPS_WORKFLOW_ENABLE_BLKTESTS
 	help
 	  This will dedicate your configuration only to blktests.
 
 config KDEVOPS_WORKFLOW_DEDICATE_CXL
 	bool "cxl"
+	depends on !KDEVOPS_USE_DECLARED_HOSTS
 	select KDEVOPS_WORKFLOW_ENABLE_CXL
 	help
 	  This will dedicate your configuration only to cxl work.
@@ -159,6 +162,7 @@ config KDEVOPS_WORKFLOW_DEDICATE_CXL
 
 config KDEVOPS_WORKFLOW_DEDICATE_PYNFS
 	bool "pynfs"
+	depends on !KDEVOPS_USE_DECLARED_HOSTS
 	select KDEVOPS_WORKFLOW_ENABLE_PYNFS
 	help
 	  This will dedicate your configuration only to running pynfs
@@ -166,6 +170,7 @@ config KDEVOPS_WORKFLOW_DEDICATE_PYNFS
 
 config KDEVOPS_WORKFLOW_DEDICATE_SELFTESTS
 	bool "Linux kernel selftests"
+	depends on !KDEVOPS_USE_DECLARED_HOSTS
 	select KDEVOPS_WORKFLOW_ENABLE_SELFTESTS
 	help
 	  This will dedicate your configuration only to Linux kernel
@@ -174,6 +179,7 @@ config KDEVOPS_WORKFLOW_DEDICATE_SELFTESTS
 
 config KDEVOPS_WORKFLOW_DEDICATE_GITR
 	bool "gitr"
+	depends on !KDEVOPS_USE_DECLARED_HOSTS
 	select KDEVOPS_WORKFLOW_ENABLE_GITR
 	help
 	  This will dedicate your configuration to running only the
@@ -181,6 +187,7 @@ config KDEVOPS_WORKFLOW_DEDICATE_GITR
 
 config KDEVOPS_WORKFLOW_DEDICATE_LTP
 	bool "ltp"
+	depends on !KDEVOPS_USE_DECLARED_HOSTS
 	select KDEVOPS_WORKFLOW_ENABLE_LTP
 	help
 	  This will dedicate your configuration to running only the
@@ -188,6 +195,7 @@ config KDEVOPS_WORKFLOW_DEDICATE_LTP
 
 config KDEVOPS_WORKFLOW_DEDICATE_NFSTEST
 	bool "nfstest"
+	depends on !KDEVOPS_USE_DECLARED_HOSTS
 	select KDEVOPS_WORKFLOW_ENABLE_NFSTEST
 	help
 	  This will dedicate your configuration to running only the
@@ -195,6 +203,7 @@ config KDEVOPS_WORKFLOW_DEDICATE_NFSTEST
 
 config KDEVOPS_WORKFLOW_DEDICATE_SYSBENCH
 	bool "sysbench"
+	depends on !KDEVOPS_USE_DECLARED_HOSTS
 	select KDEVOPS_WORKFLOW_ENABLE_SYSBENCH
 	help
 	  This will dedicate your configuration to running only the
@@ -202,6 +211,7 @@ config KDEVOPS_WORKFLOW_DEDICATE_SYSBENCH
 
 config KDEVOPS_WORKFLOW_DEDICATE_MMTESTS
 	bool "mmtests"
+	depends on !KDEVOPS_USE_DECLARED_HOSTS
 	select KDEVOPS_WORKFLOW_ENABLE_MMTESTS
 	help
 	  This will dedicate your configuration to running only the
@@ -209,6 +219,7 @@ config KDEVOPS_WORKFLOW_DEDICATE_MMTESTS
 
 config KDEVOPS_WORKFLOW_DEDICATE_FIO_TESTS
 	bool "fio-tests"
+	depends on !KDEVOPS_USE_DECLARED_HOSTS
 	select KDEVOPS_WORKFLOW_ENABLE_FIO_TESTS
 	help
 	  This will dedicate your configuration to running only the
@@ -216,6 +227,7 @@ config KDEVOPS_WORKFLOW_DEDICATE_FIO_TESTS
 
 config KDEVOPS_WORKFLOW_DEDICATE_AI
 	bool "ai"
+	depends on !KDEVOPS_USE_DECLARED_HOSTS
 	select KDEVOPS_WORKFLOW_ENABLE_AI
 	help
 	  This will dedicate your configuration to running only the
@@ -264,6 +276,7 @@ config KDEVOPS_WORKFLOW_NOT_DEDICATED_ENABLE_FSTESTS
 
 config KDEVOPS_WORKFLOW_NOT_DEDICATED_ENABLE_BLKTESTS
 	bool "blktests"
+	depends on !KDEVOPS_USE_DECLARED_HOSTS
 	select KDEVOPS_WORKFLOW_ENABLE_BLKTESTS
 	help
 	  Select this option if you are doing block layer development and want
@@ -272,6 +285,7 @@ config KDEVOPS_WORKFLOW_NOT_DEDICATED_ENABLE_BLKTESTS
 
 config KDEVOPS_WORKFLOW_NOT_DEDICATED_ENABLE_CXL
 	bool "cxl"
+	depends on !KDEVOPS_USE_DECLARED_HOSTS
 	select KDEVOPS_WORKFLOW_ENABLE_CXL
 	help
 	  Select this option if you are doing cxl development and testing.
@@ -285,6 +299,7 @@ config KDEVOPS_WORKFLOW_NOT_DEDICATED_ENABLE_CXL
 
 config KDEVOPS_WORKFLOW_NOT_DEDICATED_ENABLE_PYNFS
 	bool "pynfs"
+	depends on !KDEVOPS_USE_DECLARED_HOSTS
 	select KDEVOPS_WORKFLOW_ENABLE_PYNFS
 	depends on LIBVIRT || TERRAFORM_PRIVATE_NET
 	help
@@ -294,6 +309,7 @@ config KDEVOPS_WORKFLOW_NOT_DEDICATED_ENABLE_PYNFS
 
 config KDEVOPS_WORKFLOW_NOT_DEDICATED_ENABLE_SELFTESTS
 	bool "Linux kernel selftest"
+	depends on !KDEVOPS_USE_DECLARED_HOSTS
 	select KDEVOPS_WORKFLOW_ENABLE_SELFTESTS
 	help
 	  Select this option if you are doing Linux kernel developent and
@@ -301,6 +317,7 @@ config KDEVOPS_WORKFLOW_NOT_DEDICATED_ENABLE_SELFTESTS
 
 config KDEVOPS_WORKFLOW_NOT_DEDICATED_ENABLE_GITR
 	bool "gitr"
+	depends on !KDEVOPS_USE_DECLARED_HOSTS
 	select KDEVOPS_WORKFLOW_ENABLE_GITR
 	depends on LIBVIRT || TERRAFORM_PRIVATE_NET
 	help
@@ -309,6 +326,7 @@ config KDEVOPS_WORKFLOW_NOT_DEDICATED_ENABLE_GITR
 
 config KDEVOPS_WORKFLOW_NOT_DEDICATED_ENABLE_LTP
 	bool "ltp"
+	depends on !KDEVOPS_USE_DECLARED_HOSTS
 	select KDEVOPS_WORKFLOW_ENABLE_LTP
 	depends on LIBVIRT || TERRAFORM_PRIVATE_NET
 	help
@@ -317,6 +335,7 @@ config KDEVOPS_WORKFLOW_NOT_DEDICATED_ENABLE_LTP
 
 config KDEVOPS_WORKFLOW_NOT_DEDICATED_ENABLE_NFSTEST
 	bool "nfstest"
+	depends on !KDEVOPS_USE_DECLARED_HOSTS
 	select KDEVOPS_WORKFLOW_ENABLE_NFSTEST
 	depends on LIBVIRT || TERRAFORM_PRIVATE_NET
 	help
@@ -325,6 +344,7 @@ config KDEVOPS_WORKFLOW_NOT_DEDICATED_ENABLE_NFSTEST
 
 config KDEVOPS_WORKFLOW_NOT_DEDICATED_ENABLE_SYSBENCH
 	bool "sysbench"
+	depends on !KDEVOPS_USE_DECLARED_HOSTS
 	select KDEVOPS_WORKFLOW_ENABLE_SYSBENCH
 	depends on LIBVIRT || TERRAFORM_PRIVATE_NET
 	help
@@ -333,6 +353,7 @@ config KDEVOPS_WORKFLOW_NOT_DEDICATED_ENABLE_SYSBENCH
 
 config KDEVOPS_WORKFLOW_NOT_DEDICATED_ENABLE_MMTESTS
 	bool "mmtests"
+	depends on !KDEVOPS_USE_DECLARED_HOSTS
 	select KDEVOPS_WORKFLOW_ENABLE_MMTESTS
 	depends on LIBVIRT || TERRAFORM_PRIVATE_NET
 	help
@@ -341,6 +362,7 @@ config KDEVOPS_WORKFLOW_NOT_DEDICATED_ENABLE_MMTESTS
 
 config KDEVOPS_WORKFLOW_NOT_DEDICATED_ENABLE_FIO_TESTS
 	bool "fio-tests"
+	depends on !KDEVOPS_USE_DECLARED_HOSTS
 	select KDEVOPS_WORKFLOW_ENABLE_FIO_TESTS
 	depends on LIBVIRT || TERRAFORM_PRIVATE_NET
 	help
@@ -349,6 +371,7 @@ config KDEVOPS_WORKFLOW_NOT_DEDICATED_ENABLE_FIO_TESTS
 
 config KDEVOPS_WORKFLOW_NOT_DEDICATED_ENABLE_AI
 	bool "ai"
+	depends on !KDEVOPS_USE_DECLARED_HOSTS
 	select KDEVOPS_WORKFLOW_ENABLE_AI
 	depends on LIBVIRT || TERRAFORM_PRIVATE_NET
 	help
diff --git a/kconfigs/workflows/Kconfig.data_partition b/kconfigs/workflows/Kconfig.data_partition
index 6b17cdd..8c51664 100644
--- a/kconfigs/workflows/Kconfig.data_partition
+++ b/kconfigs/workflows/Kconfig.data_partition
@@ -1,5 +1,10 @@
+config WORKFLOW_DATA_PATH_SET_BY_CLI
+	bool
+	default $(shell, scripts/check-cli-set-var.sh DATA_PATH)
+
 config WORKFLOW_DATA_DEVICE_ENABLE_CUSTOM
 	bool "Enable custom device to use to create the workflow data parition"
+	depends on !KDEVOPS_USE_DECLARED_HOSTS
 	help
 	  Enable this if you want to override the default data device.
 	  Typically we have enough heuristics with kconfig to get this right
@@ -29,6 +34,7 @@ config WORKFLOW_DATA_DEVICE_CUSTOM
 
 config WORKFLOW_DATA_DEVICE
 	string
+	depends on !KDEVOPS_USE_DECLARED_HOSTS
 	default "/dev/disk/by-id/nvme-QEMU_NVMe_Ctrl_kdevops0" if LIBVIRT && LIBVIRT_EXTRA_STORAGE_DRIVE_NVME
 	default "/dev/disk/by-id/virtio-kdevops0" if LIBVIRT && LIBVIRT_EXTRA_STORAGE_DRIVE_VIRTIO
 	default "/dev/disk/by-id/ata-QEMU_HARDDISK_kdevops0" if LIBVIRT && LIBVIRT_EXTRA_STORAGE_DRIVE_IDE
@@ -37,9 +43,11 @@ config WORKFLOW_DATA_DEVICE
 	default TERRAFORM_AWS_DATA_VOLUME_DEVICE_FILE_NAME if TERRAFORM_AWS
 	default TERRAFORM_OCI_DATA_VOLUME_DEVICE_FILE_NAME if TERRAFORM_OCI
 	default WORKFLOW_DATA_DEVICE_CUSTOM if WORKFLOW_DATA_DEVICE_ENABLE_CUSTOM
+	default "" if KDEVOPS_USE_DECLARED_HOSTS
 
 config WORKFLOW_DATA_PATH
 	string "Directory path to place data for workflows"
+	default "$(shell, echo ${DATA_PATH})" if WORKFLOW_DATA_PATH_SET_BY_CLI
 	default "/data"
 	help
 	  The data workflow is kept then in a location other than your default
@@ -47,6 +55,9 @@ config WORKFLOW_DATA_PATH
 	  will use to place your workflow data. This will be the mount point
 	  for the new worfklow data partition created.
 
+	  When using declared hosts, this path should already exist on the
+	  target systems.
+
 config WORKFLOW_INFER_USER_AND_GROUP
 	bool "Infer user and group to use for the workflow data partition"
 	default y
diff --git a/playbooks/roles/create_data_partition/tasks/main.yml b/playbooks/roles/create_data_partition/tasks/main.yml
index f02de09..a2d3e96 100644
--- a/playbooks/roles/create_data_partition/tasks/main.yml
+++ b/playbooks/roles/create_data_partition/tasks/main.yml
@@ -1,15 +1,23 @@
 ---
+- name: Skip data partition creation for declared hosts
+  ansible.builtin.debug:
+    msg: "Skipping data partition creation - using declared hosts with pre-existing infrastructure"
+  when:
+    - kdevops_use_declared_hosts|default(false)|bool
+
 - name: Include common role
   ansible.builtin.include_role:
     name: common
   when:
     - infer_uid_and_group|bool
+    - not kdevops_use_declared_hosts|default(false)|bool
 
 - name: Establish the fixed device name of the data device
   tags: ["data_partition"]
   when:
     - kdevops_enable_terraform|bool
     - kdevops_terraform_provider == "aws"
+    - not kdevops_use_declared_hosts|default(false)|bool
   block:
     - name: Retrieve the block_device_map from terraform
       delegate_to: localhost
@@ -52,3 +60,18 @@
     disk_setup_user: "{{ data_user }}"
     disk_setup_group: "{{ data_group }}"
   tags: ["data_partition"]
+  when:
+    - not kdevops_use_declared_hosts|default(false)|bool
+
+- name: Ensure data path exists and has correct permissions for declared hosts
+  ansible.builtin.file:
+    path: "{{ data_path }}"
+    state: directory
+    owner: "{{ data_user }}"
+    group: "{{ data_group }}"
+    mode: "0755"
+  become: true
+  become_method: sudo
+  when:
+    - kdevops_use_declared_hosts|default(false)|bool
+  tags: ["data_partition"]
diff --git a/playbooks/roles/devconfig/defaults/main.yml b/playbooks/roles/devconfig/defaults/main.yml
index 98dce31..c5c06e0 100644
--- a/playbooks/roles/devconfig/defaults/main.yml
+++ b/playbooks/roles/devconfig/defaults/main.yml
@@ -57,3 +57,5 @@ kdevops_enable_guestfs: false
 guestfs_copy_sources_from_host_to_guest: false
 distro_debian_has_hop1_sources: false
 unattended_upgrades_installed: false
+workflow_infer_user_and_group: false
+kdevops_use_declared_hosts: false
diff --git a/playbooks/roles/devconfig/tasks/main.yml b/playbooks/roles/devconfig/tasks/main.yml
index fccd1fc..ae16a69 100644
--- a/playbooks/roles/devconfig/tasks/main.yml
+++ b/playbooks/roles/devconfig/tasks/main.yml
@@ -17,6 +17,31 @@
   ansible.builtin.setup:
   tags: always
 
+# For declared hosts, infer user and group from the target systems
+- name: Infer user on declared hosts
+  ansible.builtin.command: "whoami"
+  register: declared_host_user
+  when:
+    - kdevops_use_declared_hosts
+    - workflow_infer_user_and_group
+  changed_when: false
+
+- name: Infer group on declared hosts
+  ansible.builtin.command: "id -g -n"
+  register: declared_host_group
+  when:
+    - kdevops_use_declared_hosts
+    - workflow_infer_user_and_group
+  changed_when: false
+
+- name: Set inferred user and group for declared hosts
+  set_fact:
+    data_user: "{{ declared_host_user.stdout | default(data_user) }}"
+    data_group: "{{ declared_host_group.stdout | default(data_group) }}"
+  when:
+    - kdevops_use_declared_hosts
+    - workflow_infer_user_and_group
+
 # Update /etc/hostname first so the change gets picked up by the reboot
 # that occurs during the distro-specific tasks
 
diff --git a/playbooks/roles/gen_hosts/defaults/main.yml b/playbooks/roles/gen_hosts/defaults/main.yml
index 4a7515f..b0b5954 100644
--- a/playbooks/roles/gen_hosts/defaults/main.yml
+++ b/playbooks/roles/gen_hosts/defaults/main.yml
@@ -31,6 +31,7 @@ kdevops_workflow_enable_fio_tests: false
 kdevops_workflow_enable_mmtests: false
 kdevops_workflow_enable_ai: false
 workflows_reboot_limit: false
+kdevops_use_declared_hosts: false
 
 is_fstests: false
 fstests_fstyp: "bogus"
diff --git a/playbooks/roles/gen_hosts/tasks/main.yml b/playbooks/roles/gen_hosts/tasks/main.yml
index 518064e..d44566a 100644
--- a/playbooks/roles/gen_hosts/tasks/main.yml
+++ b/playbooks/roles/gen_hosts/tasks/main.yml
@@ -10,6 +10,19 @@
       skip: true
   tags: vars
 
+- name: Parse declared hosts list when using declared hosts
+  set_fact:
+    kdevops_declared_hosts: >-
+      {%- if kdevops_declared_hosts is string -%}
+        {{ (kdevops_declared_hosts | default('')) | regex_replace(',', ' ') | split() }}
+      {%- else -%}
+        {{ kdevops_declared_hosts }}
+      {%- endif -%}
+  when:
+    - kdevops_use_declared_hosts
+    - kdevops_declared_hosts is defined
+  tags: vars
+
 - name: Get our user
   ansible.builtin.command: "whoami"
   register: my_user
@@ -75,6 +88,7 @@
   when:
     - is_fstests
     - ansible_hosts_template.stat.exists
+    - not kdevops_use_declared_hosts
 
 - name: Infer enabled blktests test section types
   ansible.builtin.set_fact:
@@ -89,6 +103,7 @@
     - kdevops_workflows_dedicated_workflow
     - kdevops_workflow_enable_blktests
     - ansible_hosts_template.stat.exists
+    - not kdevops_use_declared_hosts
 
 - name: Debug inferring block test types
   ansible.builtin.debug:
@@ -112,6 +127,7 @@
     - kdevops_workflows_dedicated_workflow
     - kdevops_workflow_enable_selftests
     - ansible_hosts_template.stat.exists
+    - not kdevops_use_declared_hosts
 
 - name: Collect dynamically supported filesystems
   vars:
@@ -155,6 +171,7 @@
     - kdevops_workflows_dedicated_workflow
     - kdevops_workflow_enable_mmtests
     - ansible_hosts_template.stat.exists
+    - not kdevops_use_declared_hosts
 
 - name: Load AI nodes configuration for multi-filesystem setup
   include_vars:
diff --git a/playbooks/roles/gen_hosts/templates/hosts.j2 b/playbooks/roles/gen_hosts/templates/hosts.j2
index be0378d..2ec18de 100644
--- a/playbooks/roles/gen_hosts/templates/hosts.j2
+++ b/playbooks/roles/gen_hosts/templates/hosts.j2
@@ -5,4 +5,10 @@ proper identation. We don't need identation for the ansible hosts file.
 Each workflow which has its own custom ansible host file generated should use
 its own jinja2 template file and define its own ansible task for its generation.
 #}
+{% if kdevops_declared_hosts is defined and kdevops_declared_hosts %}
+{# Use declared hosts that skip bringup process - for bare metal or pre-existing infrastructure #}
+{% include 'workflows/declared-hosts.j2' %}
+{% else %}
+{# Include workflow-specific template dynamically based on workflow name #}
 {% include 'workflows/' + kdevops_workflow_name + '.j2' %}
+{% endif %}
diff --git a/playbooks/roles/gen_hosts/templates/workflows/declared-hosts.j2 b/playbooks/roles/gen_hosts/templates/workflows/declared-hosts.j2
new file mode 100644
index 0000000..eda7805
--- /dev/null
+++ b/playbooks/roles/gen_hosts/templates/workflows/declared-hosts.j2
@@ -0,0 +1,239 @@
+{# Template for declared hosts that skip bringup process #}
+{# This template is used when users have pre-existing infrastructure like:
+   - Bare metal servers
+   - Pre-provisioned VMs
+   - Cloud instances managed outside of kdevops
+   - Any hosts with existing SSH access
+
+   The hosts are provided via kdevops_declared_hosts variable which contains
+   a list of hostnames/IPs that are already accessible via SSH.
+#}
+{# Parse declared hosts if it's a string #}
+{% if kdevops_declared_hosts is string %}
+{% set parsed_hosts = kdevops_declared_hosts | regex_replace(',', ' ') | split() %}
+{% else %}
+{% set parsed_hosts = kdevops_declared_hosts %}
+{% endif %}
+[all]
+localhost ansible_connection=local
+{% for host in parsed_hosts %}
+{{ host }}
+{% endfor %}
+
+[all:vars]
+ansible_python_interpreter = "{{ kdevops_declared_hosts_python_interpreter | default(kdevops_python_interpreter) }}"
+
+{% if kdevops_workflows_dedicated_workflow %}
+{# For workflows, organize hosts into baseline/dev groups for A/B testing #}
+{% if kdevops_baseline_and_dev %}
+[baseline]
+{# Odd-numbered hosts become baseline nodes #}
+{% for host in parsed_hosts %}
+{% if loop.index is odd %}
+{{ host }}
+{% endif %}
+{% endfor %}
+
+[baseline:vars]
+ansible_python_interpreter = "{{ kdevops_declared_hosts_python_interpreter | default(kdevops_python_interpreter) }}"
+
+[dev]
+{# Even-numbered hosts become dev nodes #}
+{% for host in parsed_hosts %}
+{% if loop.index is even %}
+{{ host }}
+{% endif %}
+{% endfor %}
+
+[dev:vars]
+ansible_python_interpreter = "{{ kdevops_declared_hosts_python_interpreter | default(kdevops_python_interpreter) }}"
+
+{% else %}
+{# Without A/B testing, all hosts are baseline #}
+[baseline]
+{% for host in parsed_hosts %}
+{{ host }}
+{% endfor %}
+
+[baseline:vars]
+ansible_python_interpreter = "{{ kdevops_declared_hosts_python_interpreter | default(kdevops_python_interpreter) }}"
+{% endif %}
+
+{# Add workflow-specific groups based on enabled workflow #}
+{% if workflows_reboot_limit %}
+[reboot-limit]
+{% for host in parsed_hosts %}
+{{ host }}
+{% endfor %}
+
+[reboot-limit:vars]
+ansible_python_interpreter = "{{ kdevops_declared_hosts_python_interpreter | default(kdevops_python_interpreter) }}"
+
+{% elif kdevops_workflow_enable_fio_tests %}
+[fio_tests]
+{% for host in parsed_hosts %}
+{{ host }}
+{% endfor %}
+
+[fio_tests:vars]
+ansible_python_interpreter = "{{ kdevops_declared_hosts_python_interpreter | default(kdevops_python_interpreter) }}"
+
+{% elif kdevops_workflow_enable_fstests %}
+[fstests]
+{% for host in parsed_hosts %}
+{{ host }}
+{% endfor %}
+
+[fstests:vars]
+ansible_python_interpreter = "{{ kdevops_declared_hosts_python_interpreter | default(kdevops_python_interpreter) }}"
+
+{# Add per-section groups if needed #}
+{% for section in fstests_enabled_test_types|default([]) %}
+[fstests_{{ section | replace('-', '_') }}]
+{% for host in parsed_hosts %}
+{{ host }}
+{% endfor %}
+
+[fstests_{{ section | replace('-', '_') }}:vars]
+ansible_python_interpreter = "{{ kdevops_declared_hosts_python_interpreter | default(kdevops_python_interpreter) }}"
+{% endfor %}
+
+{% elif kdevops_workflow_enable_blktests %}
+[blktests]
+{% for host in parsed_hosts %}
+{{ host }}
+{% endfor %}
+
+[blktests:vars]
+ansible_python_interpreter = "{{ kdevops_declared_hosts_python_interpreter | default(kdevops_python_interpreter) }}"
+
+{% elif kdevops_workflow_enable_selftests %}
+[selftests]
+{% for host in parsed_hosts %}
+{{ host }}
+{% endfor %}
+
+[selftests:vars]
+ansible_python_interpreter = "{{ kdevops_declared_hosts_python_interpreter | default(kdevops_python_interpreter) }}"
+
+{% elif kdevops_workflow_enable_mmtests %}
+[mmtests]
+{% for host in parsed_hosts %}
+{{ host }}
+{% endfor %}
+
+[mmtests:vars]
+ansible_python_interpreter = "{{ kdevops_declared_hosts_python_interpreter | default(kdevops_python_interpreter) }}"
+
+{% elif kdevops_workflow_enable_sysbench %}
+[sysbench]
+{% for host in parsed_hosts %}
+{{ host }}
+{% endfor %}
+
+[sysbench:vars]
+ansible_python_interpreter = "{{ kdevops_declared_hosts_python_interpreter | default(kdevops_python_interpreter) }}"
+
+{% elif kdevops_workflow_enable_ai|default(false)|bool %}
+[ai]
+{% for host in parsed_hosts %}
+{{ host }}
+{% endfor %}
+
+[ai:vars]
+ansible_python_interpreter = "{{ kdevops_declared_hosts_python_interpreter | default(kdevops_python_interpreter) }}"
+
+{% elif kdevops_workflow_enable_minio|default(false)|bool %}
+[minio]
+{% for host in parsed_hosts %}
+{{ host }}
+{% endfor %}
+
+[minio:vars]
+ansible_python_interpreter = "{{ kdevops_declared_hosts_python_interpreter | default(kdevops_python_interpreter) }}"
+
+{% elif kdevops_workflow_enable_cxl %}
+[cxl]
+{% for host in parsed_hosts %}
+{{ host }}
+{% endfor %}
+
+[cxl:vars]
+ansible_python_interpreter = "{{ kdevops_declared_hosts_python_interpreter | default(kdevops_python_interpreter) }}"
+
+{% elif kdevops_workflow_enable_pynfs %}
+[pynfs]
+{% for host in parsed_hosts %}
+{{ host }}
+{% endfor %}
+
+[pynfs:vars]
+ansible_python_interpreter = "{{ kdevops_declared_hosts_python_interpreter | default(kdevops_python_interpreter) }}"
+
+{% elif kdevops_workflow_enable_gitr %}
+[gitr]
+{% for host in parsed_hosts %}
+{{ host }}
+{% endfor %}
+
+[gitr:vars]
+ansible_python_interpreter = "{{ kdevops_declared_hosts_python_interpreter | default(kdevops_python_interpreter) }}"
+
+{% elif kdevops_workflow_enable_ltp %}
+[ltp]
+{% for host in parsed_hosts %}
+{{ host }}
+{% endfor %}
+
+[ltp:vars]
+ansible_python_interpreter = "{{ kdevops_declared_hosts_python_interpreter | default(kdevops_python_interpreter) }}"
+
+{% elif kdevops_workflow_enable_nfstest %}
+[nfstest]
+{% for host in parsed_hosts %}
+{{ host }}
+{% endfor %}
+
+[nfstest:vars]
+ansible_python_interpreter = "{{ kdevops_declared_hosts_python_interpreter | default(kdevops_python_interpreter) }}"
+{% endif %}
+
+{% else %}
+{# Non-workflow setup - just use baseline group #}
+[baseline]
+{% for host in parsed_hosts %}
+{{ host }}
+{% endfor %}
+
+[baseline:vars]
+ansible_python_interpreter = "{{ kdevops_declared_hosts_python_interpreter | default(kdevops_python_interpreter) }}"
+
+{# For non-dedicated workflows (mix mode), add fstests group if enabled #}
+{% if kdevops_workflow_enable_fstests %}
+[fstests]
+{% for host in parsed_hosts %}
+{{ host }}
+{% endfor %}
+
+[fstests:vars]
+ansible_python_interpreter = "{{ kdevops_declared_hosts_python_interpreter | default(kdevops_python_interpreter) }}"
+
+{# Add per-section groups if needed #}
+{% for section in fstests_enabled_test_types|default([]) %}
+[fstests_{{ section | replace('-', '_') }}]
+{% for host in parsed_hosts %}
+{{ host }}
+{% endfor %}
+
+[fstests_{{ section | replace('-', '_') }}:vars]
+ansible_python_interpreter = "{{ kdevops_declared_hosts_python_interpreter | default(kdevops_python_interpreter) }}"
+{% endfor %}
+{% endif %}
+
+{% endif %}
+
+[service]
+{# Service nodes are typically not needed for declared hosts #}
+
+[service:vars]
+ansible_python_interpreter = "{{ kdevops_declared_hosts_python_interpreter | default(kdevops_python_interpreter) }}"
\ No newline at end of file
diff --git a/playbooks/roles/gen_nodes/defaults/main.yml b/playbooks/roles/gen_nodes/defaults/main.yml
index f88ef65..c8f147e 100644
--- a/playbooks/roles/gen_nodes/defaults/main.yml
+++ b/playbooks/roles/gen_nodes/defaults/main.yml
@@ -18,6 +18,7 @@ kdevops_smbd_enable: false
 kdevops_krb5_enable: false
 kdevops_enable_iscsi: false
 workflows_reboot_limit: false
+kdevops_use_declared_hosts: false
 
 virtualbox_provider: false
 libvirt_provider: false
diff --git a/playbooks/roles/gen_nodes/tasks/main.yml b/playbooks/roles/gen_nodes/tasks/main.yml
index b1a1946..1ab81d3 100644
--- a/playbooks/roles/gen_nodes/tasks/main.yml
+++ b/playbooks/roles/gen_nodes/tasks/main.yml
@@ -25,7 +25,9 @@
     path: "{{ guestfs_path }}"
     state: directory
     mode: "0755"
-  when: kdevops_enable_guestfs|bool
+  when:
+    - kdevops_enable_guestfs|bool
+    - not kdevops_use_declared_hosts
 
 - name: Create nixos directory
   ansible.builtin.file:
-- 
2.50.1


  parent reply	other threads:[~2025-08-31  4:12 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-31  4:11 [PATCH v2 0/4] declared hosts support Luis Chamberlain
2025-08-31  4:11 ` [PATCH v2 1/4] gen_hosts: use kdevops_workflow_name directly for template selection Luis Chamberlain
2025-08-31  4:11 ` Luis Chamberlain [this message]
2025-08-31  4:11 ` [PATCH v2 3/4] Makefile: add missing extra_vars.yaml dependencies Luis Chamberlain
2025-08-31  4:12 ` [PATCH v2 4/4] minio: add MinIO Warp S3 benchmarking with declared hosts support 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=20250831041202.2172115-3-mcgrof@kernel.org \
    --to=mcgrof@kernel.org \
    --cc=cel@kernel.org \
    --cc=da.gomez@kruces.com \
    --cc=hui81.qi@samsung.com \
    --cc=kdevops@lists.linux.dev \
    --cc=kundan.kumar@samsung.com \
    /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