[PATCH v3 35/36] ansible.cfg: generate an ansible.cfg file in TOPDIR

Chuck Lever <[email protected]>
Newsgroups dev.linux.lists.kdevops
Message-ID <[email protected]>
From: Chuck Lever <[email protected]>

I need an ansible.cfg that is generated by the Kconfig menu, but
whose pathname is selected dynamically based on where kdevops is
being run rather than having that path baked into the .config.

Reviewed-by: Luis Chamberlain <[email protected]>
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 7230c2871d4d..3c48fea1421e 100644
--- a/Makefile
+++ b/Makefile
@@ -26,10 +26,15 @@ KDEVOPS_NODES_ROLE_TEMPLATE_DIR :=		$(KDEVOPS_PLAYBOOKS_DIR)/roles/gen_nodes/tem
 export KDEVOPS_NODES_TEMPLATE :=
 export KDEVOPS_MRPROPER :=
 
+ifeq (y,$(CONFIG_ANSIBLE_CFG_FILE_CUSTOM))
 ifneq ($(strip $(CONFIG_ANSIBLE_CFG_FILE)),)
 ANSIBLE_CFG_FILE := $(shell echo $(CONFIG_ANSIBLE_CFG_FILE) | tr --delete '"')
 export ANSIBLE_CONFIG := $(ANSIBLE_CFG_FILE)
 endif
+else
+ANSIBLE_CFG_FILE := $(TOPDIR_PATH)/ansible.cfg
+export ANSIBLE_CONFIG := $(ANSIBLE_CFG_FILE)
+endif
 ANSIBLE_INVENTORY_FILE := $(shell echo $(CONFIG_ANSIBLE_CFG_INVENTORY) | tr --delete '"')
 
 KDEVOPS_INSTALL_TARGETS :=
@@ -84,6 +89,9 @@ CFLAGS += $(INCLUDES)
 
 ANSIBLE_EXTRA_ARGS += kdevops_version='$(PROJECTRELEASE)'
 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
 
 export KDEVOPS_HOSTS_TEMPLATE := hosts.j2
 
diff --git a/kconfigs/Kconfig.ansible_cfg b/kconfigs/Kconfig.ansible_cfg
index dbd189f5d19e..8b32d4986a76 100644
--- a/kconfigs/Kconfig.ansible_cfg
+++ b/kconfigs/Kconfig.ansible_cfg
@@ -18,6 +18,16 @@ config ANSIBLE_CFG_INVENTORY_SET_BY_CLI
 	bool
 	default $(shell, scripts/check-cli-set-var.sh KDEVOPS_HOSTS)
 
+config ANSIBLE_CFG_FILE_CUSTOM
+	bool "Set a custom location for the ansible.cfg file"
+	help
+	  When this option is set to N, kdevops creates an ansible.cfg
+	  in a sensible default location, using the settings defined
+	  in this Kconfig menu. If it is set to Y, you can set the
+	  path and filename of the Ansible configuration file.
+
+if ANSIBLE_CFG_FILE_CUSTOM
+
 config ANSIBLE_CFG_FILE
 	string "Ansible configuration file"
 	output yaml
@@ -41,6 +51,8 @@ config ANSIBLE_CFG_FILE
 	  For more details, refer to the Ansible documentation:
 	  https://docs.ansible.com/ansible/latest/reference_appendices/config.html#the-configuration-file
 
+endif # ANSIBLE_CFG_FILE_CUSTOM
+
 menu "Ansible Callback Plugin Configuration"
 choice
 	prompt "Ansible Callback Plugin"
-- 
2.51.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.