[PATCH v2 37/37] inventory: generate the inventory pathname dynamically
Chuck Lever <[email protected]>
| Newsgroups | dev.linux.lists.kdevops |
|---|---|
| Message-ID | <[email protected]> |
From: Chuck Lever <[email protected]> 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. Signed-off-by: Chuck Lever <[email protected]> --- Makefile | 8 ++++++++ kconfigs/Kconfig.ansible_cfg | 12 ++++++++++++ 2 files changed, 20 insertions(+) diff --git a/Makefile b/Makefile index f13d1f5c91ce..7d8b91f4c163 100644 --- a/Makefile +++ b/Makefile @@ -35,7 +35,12 @@ else ANSIBLE_CFG_FILE := $(TOPDIR_PATH)/ansible.cfg export ANSIBLE_CONFIG := $(ANSIBLE_CFG_FILE) endif + +ifeq (y,$(CONFIG_ANSIBLE_CFG_INVENTORY_CUSTOM)) ANSIBLE_INVENTORY_FILE := $(shell echo $(CONFIG_ANSIBLE_CFG_INVENTORY) | tr --delete '"') +else +ANSIBLE_INVENTORY_FILE := $(TOPDIR_PATH)/hosts +endif KDEVOPS_INSTALL_TARGETS := @@ -92,6 +97,9 @@ ANSIBLE_EXTRA_ARGS += topdir_path_sha256sum='$(TOPDIR_PATH_SHA256SUM)' ifneq (y,$(CONFIG_ANSIBLE_CFG_FILE_CUSTOM)) ANSIBLE_EXTRA_ARGS += ansible_cfg_file='$(ANSIBLE_CFG_FILE)' endif +ifneq (y,$(CONFIG_ANSIBLE_CFG_INVENTORY_CUSTOM)) +ANSIBLE_EXTRA_ARGS += ansible_cfg_inventory='$(ANSIBLE_INVENTORY_FILE)' +endif export KDEVOPS_HOSTS_TEMPLATE := hosts.j2 diff --git a/kconfigs/Kconfig.ansible_cfg b/kconfigs/Kconfig.ansible_cfg index 8b32d4986a76..a5812995c3fa 100644 --- a/kconfigs/Kconfig.ansible_cfg +++ b/kconfigs/Kconfig.ansible_cfg @@ -263,6 +263,16 @@ config ANSIBLE_CFG_TASK_DEBUGGER https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_debugger.html#id10 +config ANSIBLE_CFG_INVENTORY_CUSTOM + bool "Set a custom location for the Ansible inventory" + help + When this option is set to N, kdevops creates its + inventory file in a sensible default location. If it is + set to Y, you can set the path and filename of the Ansible + inventory. + +if ANSIBLE_CFG_INVENTORY_CUSTOM + config ANSIBLE_CFG_INVENTORY string "Ansible inventory sources" output yaml @@ -282,6 +292,8 @@ config ANSIBLE_CFG_INVENTORY For more details, refer to the Ansible documentation: https://docs.ansible.com/ansible/latest/reference_appendices/config.html#default-host-list +endif # ANSIBLE_CFG_INVENTORY_CUSTOM + if DISTRO_OPENSUSE config ANSIBLE_CFG_RECONNECTION_RETRIES -- 2.51.0