Skip to content

Commit 4309bf1

Browse files
committed
declared_hosts: add support for pre-existing infrastructure
This adds 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. We borrow the DECLARE_* foo practice from the Linux kernel to ensure the user will declare the hosts they already have set up with: make DECLARE_HOSTS="foo bar" defconfig-foo or make DECLARE_HOSTS="foo bar" menuconfig We just skip the data partition setup, at the role level. The user is encouraged to set DATA_PATH if they want something other than /data/ to be expected to be used. The onus is on them to ensure that the DATA_PATH works for the user the the host is configured to ssh access to already. 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 <[email protected]>
1 parent 40df5ef commit 4309bf1

File tree

13 files changed

+401
-1
lines changed

13 files changed

+401
-1
lines changed

Makefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,13 @@ export KDEVOPS_NODES :=
1919
export PYTHONUNBUFFERED=1
2020
export TOPDIR=./
2121
export TOPDIR_PATH = $(shell readlink -f $(TOPDIR))
22+
23+
# Export CLI override variables for Kconfig to detect them
24+
# Note: We accept DECLARE_HOSTS but export as DECLARED_HOSTS for consistency
25+
ifdef DECLARE_HOSTS
26+
export DECLARED_HOSTS := $(DECLARE_HOSTS)
27+
endif
28+
2229
include scripts/refs.Makefile
2330

2431
KDEVOPS_NODES_ROLE_TEMPLATE_DIR := $(KDEVOPS_PLAYBOOKS_DIR)/roles/gen_nodes/templates

kconfigs/Kconfig.bringup

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@ config CLOUD_INITIALIZED
1313
bool
1414
default $(shell, test -f .cloud.initialized && echo y || echo n) = "y"
1515

16+
# CLI override detection for DECLARED_HOSTS which should enable SKIP_BRINGUP
17+
config SKIP_BRINGUP_SET_BY_CLI
18+
bool
19+
default $(shell, scripts/check-cli-set-var.sh DECLARED_HOSTS)
20+
select SKIP_BRINGUP
21+
select KDEVOPS_USE_DECLARED_HOSTS
22+
1623
choice
1724
prompt "Node bring up method"
1825
default TERRAFORM if CLOUD_INITIALIZED
@@ -85,6 +92,7 @@ config LIBVIRT
8592
source "kconfigs/Kconfig.guestfs"
8693
source "kconfigs/Kconfig.nixos"
8794
source "terraform/Kconfig"
95+
source "kconfigs/Kconfig.declared_hosts"
8896
if LIBVIRT
8997
source "kconfigs/Kconfig.libvirt"
9098
endif

kconfigs/Kconfig.declared_hosts

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Configuration for declared hosts that skip bringup process
2+
3+
config KDEVOPS_USE_DECLARED_HOSTS
4+
bool "Use declared hosts (skip bringup process)"
5+
select WORKFLOW_INFER_USER_AND_GROUP
6+
output yaml
7+
help
8+
Enable this option to use pre-existing hosts that you have already
9+
configured with SSH access. This is useful for:
10+
11+
* Bare metal systems
12+
* Pre-provisioned VMs or cloud instances
13+
* Systems managed by other infrastructure tools
14+
15+
When this option is enabled:
16+
- SSH keys will not be generated (assumes you already have access)
17+
- Bringup and teardown operations will be skipped
18+
- User and group settings will be inferred from the target hosts
19+
- You must provide the list of hosts in KDEVOPS_DECLARED_HOSTS
20+
21+
This option automatically:
22+
- Selects WORKFLOW_INFER_USER_AND_GROUP to detect the correct
23+
user and group on the target systems
24+
- Assumes SSH access is already configured
25+
26+
if KDEVOPS_USE_DECLARED_HOSTS
27+
28+
config KDEVOPS_DECLARED_HOSTS
29+
string "List of declared hosts"
30+
output yaml
31+
default "$(shell, echo ${DECLARED_HOSTS})"
32+
default ""
33+
help
34+
Provide a list of hostnames or IP addresses for the pre-existing
35+
systems you want to use. These hosts must already be accessible
36+
via SSH with the appropriate keys configured.
37+
38+
Format: Space or comma-separated list
39+
Example: "host1 host2 host3" or "host1,host2,host3"
40+
41+
These hosts will be used directly without any bringup process.
42+
Make sure you have:
43+
- SSH access configured
44+
- Required packages installed
45+
- Appropriate user permissions
46+
47+
config KDEVOPS_DECLARED_HOSTS_GROUP_VARS
48+
bool "Apply group variables to declared hosts"
49+
default y
50+
output yaml
51+
help
52+
When enabled, kdevops will apply the appropriate group variables
53+
to the declared hosts based on the selected workflow.
54+
55+
This ensures that declared hosts receive the same configuration
56+
variables as dynamically provisioned hosts would.
57+
58+
endif # KDEVOPS_USE_DECLARED_HOSTS

kconfigs/workflows/Kconfig

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ choice
124124
config KDEVOPS_WORKFLOW_DEDICATE_FSTESTS
125125
bool "fstests"
126126
select KDEVOPS_WORKFLOW_ENABLE_FSTESTS
127+
depends on !KDEVOPS_USE_DECLARED_HOSTS
127128
help
128129
This will dedicate your configuration only to fstests.
129130

@@ -139,12 +140,14 @@ config KDEVOPS_WORKFLOW_DEDICATE_FSTESTS
139140

140141
config KDEVOPS_WORKFLOW_DEDICATE_BLKTESTS
141142
bool "blktests"
143+
depends on !KDEVOPS_USE_DECLARED_HOSTS
142144
select KDEVOPS_WORKFLOW_ENABLE_BLKTESTS
143145
help
144146
This will dedicate your configuration only to blktests.
145147

146148
config KDEVOPS_WORKFLOW_DEDICATE_CXL
147149
bool "cxl"
150+
depends on !KDEVOPS_USE_DECLARED_HOSTS
148151
select KDEVOPS_WORKFLOW_ENABLE_CXL
149152
help
150153
This will dedicate your configuration only to cxl work.
@@ -159,13 +162,15 @@ config KDEVOPS_WORKFLOW_DEDICATE_CXL
159162

160163
config KDEVOPS_WORKFLOW_DEDICATE_PYNFS
161164
bool "pynfs"
165+
depends on !KDEVOPS_USE_DECLARED_HOSTS
162166
select KDEVOPS_WORKFLOW_ENABLE_PYNFS
163167
help
164168
This will dedicate your configuration only to running pynfs
165169
(over loopback).
166170

167171
config KDEVOPS_WORKFLOW_DEDICATE_SELFTESTS
168172
bool "Linux kernel selftests"
173+
depends on !KDEVOPS_USE_DECLARED_HOSTS
169174
select KDEVOPS_WORKFLOW_ENABLE_SELFTESTS
170175
help
171176
This will dedicate your configuration only to Linux kernel
@@ -174,48 +179,55 @@ config KDEVOPS_WORKFLOW_DEDICATE_SELFTESTS
174179

175180
config KDEVOPS_WORKFLOW_DEDICATE_GITR
176181
bool "gitr"
182+
depends on !KDEVOPS_USE_DECLARED_HOSTS
177183
select KDEVOPS_WORKFLOW_ENABLE_GITR
178184
help
179185
This will dedicate your configuration to running only the
180186
multi-threaded git regression workflow.
181187

182188
config KDEVOPS_WORKFLOW_DEDICATE_LTP
183189
bool "ltp"
190+
depends on !KDEVOPS_USE_DECLARED_HOSTS
184191
select KDEVOPS_WORKFLOW_ENABLE_LTP
185192
help
186193
This will dedicate your configuration to running only the
187194
ltp workflow in separate target nodes per testing group.
188195

189196
config KDEVOPS_WORKFLOW_DEDICATE_NFSTEST
190197
bool "nfstest"
198+
depends on !KDEVOPS_USE_DECLARED_HOSTS
191199
select KDEVOPS_WORKFLOW_ENABLE_NFSTEST
192200
help
193201
This will dedicate your configuration to running only the
194202
nfstest workflow in separate target nodes per testing group.
195203

196204
config KDEVOPS_WORKFLOW_DEDICATE_SYSBENCH
197205
bool "sysbench"
206+
depends on !KDEVOPS_USE_DECLARED_HOSTS
198207
select KDEVOPS_WORKFLOW_ENABLE_SYSBENCH
199208
help
200209
This will dedicate your configuration to running only the
201210
sysbench workflow.
202211

203212
config KDEVOPS_WORKFLOW_DEDICATE_MMTESTS
204213
bool "mmtests"
214+
depends on !KDEVOPS_USE_DECLARED_HOSTS
205215
select KDEVOPS_WORKFLOW_ENABLE_MMTESTS
206216
help
207217
This will dedicate your configuration to running only the
208218
mmtests workflow for memory fragmentation testing.
209219

210220
config KDEVOPS_WORKFLOW_DEDICATE_FIO_TESTS
211221
bool "fio-tests"
222+
depends on !KDEVOPS_USE_DECLARED_HOSTS
212223
select KDEVOPS_WORKFLOW_ENABLE_FIO_TESTS
213224
help
214225
This will dedicate your configuration to running only the
215226
fio-tests workflow for comprehensive storage performance testing.
216227

217228
config KDEVOPS_WORKFLOW_DEDICATE_AI
218229
bool "ai"
230+
depends on !KDEVOPS_USE_DECLARED_HOSTS
219231
select KDEVOPS_WORKFLOW_ENABLE_AI
220232
help
221233
This will dedicate your configuration to running only the
@@ -264,6 +276,7 @@ config KDEVOPS_WORKFLOW_NOT_DEDICATED_ENABLE_FSTESTS
264276

265277
config KDEVOPS_WORKFLOW_NOT_DEDICATED_ENABLE_BLKTESTS
266278
bool "blktests"
279+
depends on !KDEVOPS_USE_DECLARED_HOSTS
267280
select KDEVOPS_WORKFLOW_ENABLE_BLKTESTS
268281
help
269282
Select this option if you are doing block layer development and want
@@ -272,6 +285,7 @@ config KDEVOPS_WORKFLOW_NOT_DEDICATED_ENABLE_BLKTESTS
272285

273286
config KDEVOPS_WORKFLOW_NOT_DEDICATED_ENABLE_CXL
274287
bool "cxl"
288+
depends on !KDEVOPS_USE_DECLARED_HOSTS
275289
select KDEVOPS_WORKFLOW_ENABLE_CXL
276290
help
277291
Select this option if you are doing cxl development and testing.
@@ -285,6 +299,7 @@ config KDEVOPS_WORKFLOW_NOT_DEDICATED_ENABLE_CXL
285299

286300
config KDEVOPS_WORKFLOW_NOT_DEDICATED_ENABLE_PYNFS
287301
bool "pynfs"
302+
depends on !KDEVOPS_USE_DECLARED_HOSTS
288303
select KDEVOPS_WORKFLOW_ENABLE_PYNFS
289304
depends on LIBVIRT || TERRAFORM_PRIVATE_NET
290305
help
@@ -294,13 +309,15 @@ config KDEVOPS_WORKFLOW_NOT_DEDICATED_ENABLE_PYNFS
294309

295310
config KDEVOPS_WORKFLOW_NOT_DEDICATED_ENABLE_SELFTESTS
296311
bool "Linux kernel selftest"
312+
depends on !KDEVOPS_USE_DECLARED_HOSTS
297313
select KDEVOPS_WORKFLOW_ENABLE_SELFTESTS
298314
help
299315
Select this option if you are doing Linux kernel developent and
300316
testing with sefltests.
301317

302318
config KDEVOPS_WORKFLOW_NOT_DEDICATED_ENABLE_GITR
303319
bool "gitr"
320+
depends on !KDEVOPS_USE_DECLARED_HOSTS
304321
select KDEVOPS_WORKFLOW_ENABLE_GITR
305322
depends on LIBVIRT || TERRAFORM_PRIVATE_NET
306323
help
@@ -309,6 +326,7 @@ config KDEVOPS_WORKFLOW_NOT_DEDICATED_ENABLE_GITR
309326

310327
config KDEVOPS_WORKFLOW_NOT_DEDICATED_ENABLE_LTP
311328
bool "ltp"
329+
depends on !KDEVOPS_USE_DECLARED_HOSTS
312330
select KDEVOPS_WORKFLOW_ENABLE_LTP
313331
depends on LIBVIRT || TERRAFORM_PRIVATE_NET
314332
help
@@ -317,6 +335,7 @@ config KDEVOPS_WORKFLOW_NOT_DEDICATED_ENABLE_LTP
317335

318336
config KDEVOPS_WORKFLOW_NOT_DEDICATED_ENABLE_NFSTEST
319337
bool "nfstest"
338+
depends on !KDEVOPS_USE_DECLARED_HOSTS
320339
select KDEVOPS_WORKFLOW_ENABLE_NFSTEST
321340
depends on LIBVIRT || TERRAFORM_PRIVATE_NET
322341
help
@@ -325,6 +344,7 @@ config KDEVOPS_WORKFLOW_NOT_DEDICATED_ENABLE_NFSTEST
325344

326345
config KDEVOPS_WORKFLOW_NOT_DEDICATED_ENABLE_SYSBENCH
327346
bool "sysbench"
347+
depends on !KDEVOPS_USE_DECLARED_HOSTS
328348
select KDEVOPS_WORKFLOW_ENABLE_SYSBENCH
329349
depends on LIBVIRT || TERRAFORM_PRIVATE_NET
330350
help
@@ -333,6 +353,7 @@ config KDEVOPS_WORKFLOW_NOT_DEDICATED_ENABLE_SYSBENCH
333353

334354
config KDEVOPS_WORKFLOW_NOT_DEDICATED_ENABLE_MMTESTS
335355
bool "mmtests"
356+
depends on !KDEVOPS_USE_DECLARED_HOSTS
336357
select KDEVOPS_WORKFLOW_ENABLE_MMTESTS
337358
depends on LIBVIRT || TERRAFORM_PRIVATE_NET
338359
help
@@ -341,6 +362,7 @@ config KDEVOPS_WORKFLOW_NOT_DEDICATED_ENABLE_MMTESTS
341362

342363
config KDEVOPS_WORKFLOW_NOT_DEDICATED_ENABLE_FIO_TESTS
343364
bool "fio-tests"
365+
depends on !KDEVOPS_USE_DECLARED_HOSTS
344366
select KDEVOPS_WORKFLOW_ENABLE_FIO_TESTS
345367
depends on LIBVIRT || TERRAFORM_PRIVATE_NET
346368
help
@@ -349,6 +371,7 @@ config KDEVOPS_WORKFLOW_NOT_DEDICATED_ENABLE_FIO_TESTS
349371

350372
config KDEVOPS_WORKFLOW_NOT_DEDICATED_ENABLE_AI
351373
bool "ai"
374+
depends on !KDEVOPS_USE_DECLARED_HOSTS
352375
select KDEVOPS_WORKFLOW_ENABLE_AI
353376
depends on LIBVIRT || TERRAFORM_PRIVATE_NET
354377
help

kconfigs/workflows/Kconfig.data_partition

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1+
config WORKFLOW_DATA_PATH_SET_BY_CLI
2+
bool
3+
default $(shell, scripts/check-cli-set-var.sh DATA_PATH)
4+
15
config WORKFLOW_DATA_DEVICE_ENABLE_CUSTOM
26
bool "Enable custom device to use to create the workflow data parition"
7+
depends on !KDEVOPS_USE_DECLARED_HOSTS
38
help
49
Enable this if you want to override the default data device.
510
Typically we have enough heuristics with kconfig to get this right
@@ -29,6 +34,7 @@ config WORKFLOW_DATA_DEVICE_CUSTOM
2934

3035
config WORKFLOW_DATA_DEVICE
3136
string
37+
depends on !KDEVOPS_USE_DECLARED_HOSTS
3238
default "/dev/disk/by-id/nvme-QEMU_NVMe_Ctrl_kdevops0" if LIBVIRT && LIBVIRT_EXTRA_STORAGE_DRIVE_NVME
3339
default "/dev/disk/by-id/virtio-kdevops0" if LIBVIRT && LIBVIRT_EXTRA_STORAGE_DRIVE_VIRTIO
3440
default "/dev/disk/by-id/ata-QEMU_HARDDISK_kdevops0" if LIBVIRT && LIBVIRT_EXTRA_STORAGE_DRIVE_IDE
@@ -37,16 +43,21 @@ config WORKFLOW_DATA_DEVICE
3743
default TERRAFORM_AWS_DATA_VOLUME_DEVICE_FILE_NAME if TERRAFORM_AWS
3844
default TERRAFORM_OCI_DATA_VOLUME_DEVICE_FILE_NAME if TERRAFORM_OCI
3945
default WORKFLOW_DATA_DEVICE_CUSTOM if WORKFLOW_DATA_DEVICE_ENABLE_CUSTOM
46+
default "" if KDEVOPS_USE_DECLARED_HOSTS
4047

4148
config WORKFLOW_DATA_PATH
4249
string "Directory path to place data for workflows"
43-
default "/data"
50+
default "$(shell, echo ${DATA_PATH})" if WORKFLOW_DATA_PATH_SET_BY_CLI
51+
default "/data" if !WORKFLOW_DATA_PATH_SET_BY_CLI
4452
help
4553
The data workflow is kept then in a location other than your default
4654
user home directory. Use this option to specify the path which we
4755
will use to place your workflow data. This will be the mount point
4856
for the new worfklow data partition created.
4957

58+
When using declared hosts, this path should already exist on the
59+
target systems.
60+
5061
config WORKFLOW_INFER_USER_AND_GROUP
5162
bool "Infer user and group to use for the workflow data partition"
5263
default y

playbooks/create_data_partition.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,5 @@
33
hosts: baseline:dev
44
roles:
55
- role: create_data_partition
6+
when:
7+
- kdevops_use_declared_hosts|bool
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
---
22
kdevops_enable_terraform: false
3+
kdevops_use_declared_hosts: false

playbooks/roles/devconfig/defaults/main.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,5 @@ kdevops_enable_guestfs: false
5757
guestfs_copy_sources_from_host_to_guest: false
5858
distro_debian_has_hop1_sources: false
5959
unattended_upgrades_installed: false
60+
workflow_infer_user_and_group: false
61+
kdevops_use_declared_hosts: false

playbooks/roles/devconfig/tasks/main.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,31 @@
1717
ansible.builtin.setup:
1818
tags: always
1919

20+
# For declared hosts, infer user and group from the target systems
21+
- name: Infer user on declared hosts
22+
ansible.builtin.command: "whoami"
23+
register: declared_host_user
24+
when:
25+
- kdevops_use_declared_hosts
26+
- workflow_infer_user_and_group
27+
changed_when: false
28+
29+
- name: Infer group on declared hosts
30+
ansible.builtin.command: "id -g -n"
31+
register: declared_host_group
32+
when:
33+
- kdevops_use_declared_hosts
34+
- workflow_infer_user_and_group
35+
changed_when: false
36+
37+
- name: Set inferred user and group for declared hosts
38+
set_fact:
39+
data_user: "{{ declared_host_user.stdout | default(data_user) }}"
40+
data_group: "{{ declared_host_group.stdout | default(data_group) }}"
41+
when:
42+
- kdevops_use_declared_hosts
43+
- workflow_infer_user_and_group
44+
2045
# Update /etc/hostname first so the change gets picked up by the reboot
2146
# that occurs during the distro-specific tasks
2247

playbooks/roles/gen_hosts/defaults/main.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ kdevops_workflow_enable_fio_tests: false
3131
kdevops_workflow_enable_mmtests: false
3232
kdevops_workflow_enable_ai: false
3333
workflows_reboot_limit: false
34+
kdevops_use_declared_hosts: false
3435

3536
is_fstests: false
3637
fstests_fstyp: "bogus"

0 commit comments

Comments
 (0)