Skip to content

Commit bdd1df9

Browse files
committed
inventory: generate the inventory pathname dynamically
My CI workflows need the inventory location to be determined at run time, not set by the kdevops .config file, so the .configs can be portable amongst test runners and test branches. Reviewed-by: Luis Chamberlain <[email protected]> Signed-off-by: Chuck Lever <[email protected]>
1 parent 70d8f9d commit bdd1df9

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,12 @@ else
3535
ANSIBLE_CFG_FILE := $(TOPDIR_PATH)/ansible.cfg
3636
export ANSIBLE_CONFIG := $(ANSIBLE_CFG_FILE)
3737
endif
38+
39+
ifeq (y,$(CONFIG_ANSIBLE_CFG_INVENTORY_CUSTOM))
3840
ANSIBLE_INVENTORY_FILE := $(shell echo $(CONFIG_ANSIBLE_CFG_INVENTORY) | tr --delete '"')
41+
else
42+
ANSIBLE_INVENTORY_FILE := $(TOPDIR_PATH)/hosts
43+
endif
3944

4045
KDEVOPS_INSTALL_TARGETS :=
4146

@@ -92,6 +97,9 @@ ANSIBLE_EXTRA_ARGS += topdir_path_sha256sum='$(TOPDIR_PATH_SHA256SUM)'
9297
ifneq (y,$(CONFIG_ANSIBLE_CFG_FILE_CUSTOM))
9398
ANSIBLE_EXTRA_ARGS += ansible_cfg_file='$(ANSIBLE_CFG_FILE)'
9499
endif
100+
ifneq (y,$(CONFIG_ANSIBLE_CFG_INVENTORY_CUSTOM))
101+
ANSIBLE_EXTRA_ARGS += ansible_cfg_inventory='$(ANSIBLE_INVENTORY_FILE)'
102+
endif
95103

96104
export KDEVOPS_HOSTS_TEMPLATE := hosts.j2
97105

kconfigs/Kconfig.ansible_cfg

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,16 @@ config ANSIBLE_CFG_TASK_DEBUGGER
263263

264264
https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_debugger.html#id10
265265

266+
config ANSIBLE_CFG_INVENTORY_CUSTOM
267+
bool "Set a custom location for the Ansible inventory"
268+
help
269+
When this option is set to N, kdevops creates its
270+
inventory file in a sensible default location. If it is
271+
set to Y, you can set the path and filename of the Ansible
272+
inventory.
273+
274+
if ANSIBLE_CFG_INVENTORY_CUSTOM
275+
266276
config ANSIBLE_CFG_INVENTORY
267277
string "Ansible inventory sources"
268278
output yaml
@@ -282,6 +292,8 @@ config ANSIBLE_CFG_INVENTORY
282292
For more details, refer to the Ansible documentation:
283293
https://docs.ansible.com/ansible/latest/reference_appendices/config.html#default-host-list
284294

295+
endif # ANSIBLE_CFG_INVENTORY_CUSTOM
296+
285297
if DISTRO_OPENSUSE
286298

287299
config ANSIBLE_CFG_RECONNECTION_RETRIES

0 commit comments

Comments
 (0)