From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0E93E35977 for ; Sun, 31 Aug 2025 04:12:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.137.202.133 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756613531; cv=none; b=X/bpElGFKhexlRfHfxp/dKjBob4hN5B2Ysvh3K44+aD94WRqs9Y+6HTDiBg++mUHVUjLlzrk2EckcbB7uP7MlZmpAhOVUONr2yfgY58Ss1mWfrK/FCoKO0hZxB5LUFo84o0zMeSQoZo9VS90CFY4EvhppqWz+IY6WycR0rworos= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756613531; c=relaxed/simple; bh=KE3VCYNaKijyx5p0ddsTuos96JwjCb7la5cZRtVKn4Q=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hb+9ihsjfkDQkLsQm816lxXSi4qHBTkTbzNqiKjDLhYOX5fbprW/Yjn3WGbPdm3zzLLcqFzUZR4jTJeE8LRli5T/lhsqA7AUDIVhhdiriW2B2+BcbN7bT7E/ucBJ/eVWxvVrCMMCjWS9iFxm1+3xBLUclXv31Z8eb/0jw5q0irU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=kernel.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=4xWXoe0O; arc=none smtp.client-ip=198.137.202.133 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="4xWXoe0O" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description; bh=HFSbMrNQAiQUNPiqL28G5OgqbEXB3ZITFOqlceNYikE=; b=4xWXoe0OLtVSjKB0H8uwI961sG rlc8xVV/dkXxIvTq9u8fY8jrlRnNqKGJ+m7h6l8bOmgiFu54r9h/jhfcVDvw79sZB9Qq4cQM7UN4E n5M4JuCTRrMu4UNP+hGMKR7pNzbNt2M6CN/0J+LVKnjqjcwliTuYDn9FRdGCBMJUPRbwt4fJKRy+s cK7QwveS595GFIMQhm9PZGih2d7GALs39/z9tLxdCibTTnpF66EDY8xCs7sHs4e/hbpIkYnbtoZt6 lpgMxjFVuTL7sC4DjXYii9WU6EMAh1jZ0ZrXAUNXj0VtpuswDyBHiNXrUcsiSurTUyQJBUkLWx84o NC1eEcSw==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.98.2 #2 (Red Hat Linux)) id 1usZQE-0000000975M-3AgO; Sun, 31 Aug 2025 04:12:06 +0000 From: Luis Chamberlain To: Chuck Lever , Daniel Gomez , kdevops@lists.linux.dev Cc: hui81.qi@samsung.com, kundan.kumar@samsung.com, Luis Chamberlain Subject: [PATCH v2 2/4] declared_hosts: add support for pre-existing infrastructure Date: Sat, 30 Aug 2025 21:11:58 -0700 Message-ID: <20250831041202.2172115-3-mcgrof@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250831041202.2172115-1-mcgrof@kernel.org> References: <20250831041202.2172115-1-mcgrof@kernel.org> Precedence: bulk X-Mailing-List: kdevops@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: Luis Chamberlain 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 --- 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