Skip to content

Commit dc032f9

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]> Reviewed-by: Daniel Gomez <[email protected]> Tested-by: Daniel Gomez <[email protected]> Signed-off-by: Chuck Lever <[email protected]>
1 parent 796a8f2 commit dc032f9

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
@@ -42,7 +42,12 @@ else
4242
ANSIBLE_CFG_FILE := $(TOPDIR_PATH)/ansible.cfg
4343
export ANSIBLE_CONFIG := $(ANSIBLE_CFG_FILE)
4444
endif
45+
46+
ifeq (y,$(CONFIG_ANSIBLE_CFG_INVENTORY_CUSTOM))
4547
ANSIBLE_INVENTORY_FILE := $(shell echo $(CONFIG_ANSIBLE_CFG_INVENTORY) | tr --delete '"')
48+
else
49+
ANSIBLE_INVENTORY_FILE := $(TOPDIR_PATH)/hosts
50+
endif
4651

4752
KDEVOPS_INSTALL_TARGETS :=
4853

@@ -99,6 +104,9 @@ ANSIBLE_EXTRA_ARGS += topdir_path_sha256sum='$(TOPDIR_PATH_SHA256SUM)'
99104
ifneq (y,$(CONFIG_ANSIBLE_CFG_FILE_CUSTOM))
100105
ANSIBLE_EXTRA_ARGS += ansible_cfg_file='$(ANSIBLE_CFG_FILE)'
101106
endif
107+
ifneq (y,$(CONFIG_ANSIBLE_CFG_INVENTORY_CUSTOM))
108+
ANSIBLE_EXTRA_ARGS += ansible_cfg_inventory='$(ANSIBLE_INVENTORY_FILE)'
109+
endif
102110

103111
export KDEVOPS_HOSTS_TEMPLATE := hosts.j2
104112

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)