public inbox for kdevops@lists.linux.dev
 help / color / mirror / Atom feed
From: Daniel Gomez <da.gomez@kernel.org>
To: Luis Chamberlain <mcgrof@kernel.org>,
	 Chuck Lever <chuck.lever@oracle.com>
Cc: kdevops@lists.linux.dev, Daniel Gomez <da.gomez@kernel.org>,
	 Daniel Gomez <da.gomez@samsung.com>
Subject: [PATCH v2 09/10] ansible_cfg: add support to change ansible.cfg file location
Date: Fri, 02 May 2025 14:13:26 +0200	[thread overview]
Message-ID: <20250502-ansible_cfg_inventory-v2-9-d3c19ff4aa6e@samsung.com> (raw)
In-Reply-To: <20250502-ansible_cfg_inventory-v2-0-d3c19ff4aa6e@samsung.com>

From: Daniel Gomez <da.gomez@samsung.com>

This adds support to change the Ansible Configuration filename and
location via Kconfig.

It also fixes the target to generate the file only if it doesn't exist,
instead of regenerating it every time make is invoked. Removing the
quotes from the variable used as target fixes the problem.

Remove the file from MAINTAINERS list as it is autogenerated and not
in tree.

Reported-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Daniel Gomez <da.gomez@samsung.com>
---
 MAINTAINERS                                |  1 -
 Makefile                                   | 15 +++++++--------
 kconfigs/Kconfig.ansible_cfg               | 15 +++++++++++++++
 playbooks/roles/ansible_cfg/tasks/main.yml |  2 +-
 4 files changed, 23 insertions(+), 10 deletions(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index 30591209e5a05faacfba87ddd2038c92ec846bda..d6f578c0be62ac3809084223ae190a70d3b23d0a 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -72,7 +72,6 @@ M:	Daniel Gomez <da.gomez@samsung.com>
 L:	kdevops@lists.linux.dev
 S:	Maintained
 T:	git https://github.com/linux-kdevops/kdevops.git
-F:	ansible.cfg
 F:	kconfigs/Kconfig.ansible_cfg
 F:	playbooks/ansible_cfg.yml
 F:	playbooks/roles/ansible_cfg
diff --git a/Makefile b/Makefile
index de0db3cc9137f749fa205acce5487073f998f789..0995337767c8575b38c2effda495674b6fbb43ae 100644
--- a/Makefile
+++ b/Makefile
@@ -26,6 +26,7 @@ KDEVOPS_NODES_ROLE_TEMPLATE_DIR :=		$(KDEVOPS_PLAYBOOKS_DIR)/roles/gen_nodes/tem
 export KDEVOPS_NODES_TEMPLATE :=
 export KDEVOPS_MRPROPER :=
 
+ANSIBLE_CFG_FILE := $(shell echo $(CONFIG_ANSIBLE_CFG_FILE) | tr --delete '"')
 ANSIBLE_INVENTORY_FILE := $(shell echo $(CONFIG_ANSIBLE_CFG_INVENTORY) | tr --delete '"')
 
 KDEVOPS_INSTALL_TARGETS :=
@@ -195,16 +196,14 @@ include scripts/gen-nodes.Makefile
 	make -f scripts/build.Makefile help                             ;\
 	false)
 
-
-PHONY += ansible.cfg
-ansible.cfg:
+$(ANSIBLE_CFG_FILE):
 	@$(Q)ansible-playbook $(ANSIBLE_VERBOSE) \
 		$(KDEVOPS_PLAYBOOKS_DIR)/ansible_cfg.yml \
 		--extra-vars=@./.extra_vars_auto.yaml
 
 PHONY += $(EXTRA_VAR_INPUTS) $(EXTRA_VAR_INPUTS_LAST)
 
-$(KDEVOPS_EXTRA_VARS): .config ansible.cfg $(EXTRA_VAR_INPUTS) $(EXTRA_VAR_INPUTS_LAST)
+$(KDEVOPS_EXTRA_VARS): .config $(ANSIBLE_CFG_FILE) $(EXTRA_VAR_INPUTS) $(EXTRA_VAR_INPUTS_LAST)
 
 playbooks/secret.yml:
 	@if [[ "$(CONFIG_KDEVOPS_REG_TWOLINE_REGCODE)" == "" ]]; then \
@@ -216,7 +215,7 @@ playbooks/secret.yml:
 	@echo "$(CONFIG_KDEVOPS_REG_TWOLINE_REGCODE_VAR): $(CONFIG_KDEVOPS_REG_TWOLINE_REGCODE)" >> $@
 
 ifeq (y,$(CONFIG_KDEVOPS_ENABLE_DISTRO_EXTRA_ADDONS))
-$(KDEVOPS_EXTRA_ADDON_DEST): .config ansible.cfg $(KDEVOPS_EXTRA_ADDON_SOURCE)
+$(KDEVOPS_EXTRA_ADDON_DEST): .config $(ANSIBLE_CFG_FILE) $(KDEVOPS_EXTRA_ADDON_SOURCE)
 	$(Q)cp $(KDEVOPS_EXTRA_ADDON_SOURCE) $(KDEVOPS_EXTRA_ADDON_DEST)
 endif
 
@@ -227,13 +226,13 @@ include scripts/bringup.Makefile
 endif
 
 DEFAULT_DEPS += $(ANSIBLE_INVENTORY_FILE)
-$(ANSIBLE_INVENTORY_FILE): .config ansible.cfg $(KDEVOPS_HOSTS_TEMPLATE)
+$(ANSIBLE_INVENTORY_FILE): .config $(ANSIBLE_CFG_FILE) $(KDEVOPS_HOSTS_TEMPLATE)
 	$(Q)ansible-playbook $(ANSIBLE_VERBOSE) \
 		$(KDEVOPS_PLAYBOOKS_DIR)/gen_hosts.yml \
 		--extra-vars=@./extra_vars.yaml
 
 DEFAULT_DEPS += $(KDEVOPS_NODES)
-$(KDEVOPS_NODES) $(KDEVOPS_VAGRANT): .config ansible.cfg $(KDEVOPS_NODES_TEMPLATE)
+$(KDEVOPS_NODES) $(KDEVOPS_VAGRANT): .config $(ANSIBLE_CFG_FILE) $(KDEVOPS_NODES_TEMPLATE)
 	$(Q)ansible-playbook $(ANSIBLE_VERBOSE) \
 		$(KDEVOPS_PLAYBOOKS_DIR)/gen_nodes.yml \
 		--extra-vars=@./extra_vars.yaml
@@ -262,7 +261,7 @@ mrproper:
 	$(Q)rm -f $(KDEVOPS_NODES)
 	$(Q)rm -f $(ANSIBLE_CFG_INVENTORY) $(KDEVOPS_MRPROPER)
 	$(Q)rm -f .config .config.old extra_vars.yaml $(KCONFIG_YAMLCFG)
-	$(Q)rm -f ansible.cfg
+	$(Q)rm -f $(ANSIBLE_CFG_FILE)
 	$(Q)rm -f playbooks/secret.yml $(KDEVOPS_EXTRA_ADDON_DEST)
 	$(Q)rm -rf include
 	$(Q)rm -rf guestfs
diff --git a/kconfigs/Kconfig.ansible_cfg b/kconfigs/Kconfig.ansible_cfg
index d78ea7507632ae86481633e83a845e81e6f7ad92..9050b343b558c6531d5b802a48d3cc8ff60c37cd 100644
--- a/kconfigs/Kconfig.ansible_cfg
+++ b/kconfigs/Kconfig.ansible_cfg
@@ -1,3 +1,18 @@
+config ANSIBLE_CFG_FILE
+	string "Ansible configuration file"
+	output yaml
+	default "$(TOPDIR_PATH)/ansible.cfg"
+	help
+	  Path and filename to the Ansible configuration file.
+
+	  This option lets you specify the path and filename for the Ansible
+	  configuration file. If the specified file already exists, it will not
+	  be overwritten. Otherwise, kdevops will generate one using the settings
+	  defined in this Kconfig menu.
+
+	  For more details, refer to the Ansible documentation:
+	  https://docs.ansible.com/ansible/latest/reference_appendices/config.html#the-configuration-file
+
 config ANSIBLE_CFG_CALLBACK_PLUGIN_SET_BY_CLI
 	bool
 	default $(shell, scripts/check-cli-set-var.sh ANSIBLE_CFG_CALLBACK_PLUGIN)
diff --git a/playbooks/roles/ansible_cfg/tasks/main.yml b/playbooks/roles/ansible_cfg/tasks/main.yml
index a85d525f21b1a8968e4da73df6882f57b83c32d2..142a14615374e30a4549cfc5f72ddd8eb7f8ceaa 100644
--- a/playbooks/roles/ansible_cfg/tasks/main.yml
+++ b/playbooks/roles/ansible_cfg/tasks/main.yml
@@ -14,5 +14,5 @@
 - name: Generate kdevops ansible.cfg
   ansible.builtin.template:
     src: "ansible.cfg.j2"
-    dest: "{{ topdir_path }}/ansible.cfg"
+    dest: "{{ ansible_cfg_file }}"
     mode: '0755'

-- 
2.49.0


  parent reply	other threads:[~2025-05-02 12:13 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-02 12:13 [PATCH v2 00/10] Define Ansible inventory in the Ansible Configuration file Daniel Gomez
2025-05-02 12:13 ` [PATCH v2 01/10] playbooks: fix playbook name for all hosts plays Daniel Gomez
2025-05-02 12:13 ` [PATCH v2 02/10] playbooks: fix playbook name for localhost plays Daniel Gomez
2025-05-02 12:13 ` [PATCH v2 03/10] Makefile: use long form of limit argument for clarity Daniel Gomez
2025-05-02 12:13 ` [PATCH v2 04/10] Makefile: print target when debug Daniel Gomez
2025-05-02 12:13 ` [PATCH v2 05/10] .github/workflows/fstests.yml: enable make verbosity Daniel Gomez
2025-05-02 12:13 ` [PATCH v2 06/10] ansible_cfg: add inventory support Daniel Gomez
2025-05-02 12:13 ` [PATCH v2 07/10] gen_hosts: templates: add localhost to all hosts Daniel Gomez
2025-05-02 18:56   ` Chuck Lever
2025-05-03 17:45     ` Daniel Gomez
2025-05-02 12:13 ` [PATCH v2 08/10] Makefile: use inventory from ansible.cfg Daniel Gomez
2025-05-02 13:47   ` Daniel Gomez
2025-05-02 16:08     ` Chuck Lever
2025-05-02 19:11       ` Daniel Gomez
2025-05-02 12:13 ` Daniel Gomez [this message]
2025-05-02 12:13 ` [PATCH v2 10/10] docs: ansible_cfg: add documentation Daniel Gomez

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250502-ansible_cfg_inventory-v2-9-d3c19ff4aa6e@samsung.com \
    --to=da.gomez@kernel.org \
    --cc=chuck.lever@oracle.com \
    --cc=da.gomez@samsung.com \
    --cc=kdevops@lists.linux.dev \
    --cc=mcgrof@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox