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 06/10] ansible_cfg: add inventory support
Date: Fri, 02 May 2025 14:13:23 +0200 [thread overview]
Message-ID: <20250502-ansible_cfg_inventory-v2-6-d3c19ff4aa6e@samsung.com> (raw)
In-Reply-To: <20250502-ansible_cfg_inventory-v2-0-d3c19ff4aa6e@samsung.com>
From: Daniel Gomez <da.gomez@samsung.com>
Allow to configure the inventory file (currently via KDEVOPS_HOSTFILE
and KDEVOPS_HOSTS) via ansible.cfg.
The Ansible inventory file [1][2][3] is used in all kdevops/Makefile
ansible-playbook calls. Enable this configuration to the global Ansible
configuration file (ansible.cfg) and allow to define the inventory via
Kconfig. This will simplify the playbook invocation.
[1]
https://docs.ansible.com/ansible/latest/reference_appendices/
config.html#default-host-list
[2]
https://docs.ansible.com/ansible/latest/cli/
ansible-inventory.html#cmdoption-ansible-inventory-i
[3]
https://docs.ansible.com/ansible/latest/reference_appendices/
config.html#envvar-ANSIBLE_INVENTORY
This has no effect yet, as all ansible-playbook calls currently specify
the --inventory (-i) argument. The next commits will clean up the code
and allow the inventory defined in ansible.cfg to take effect.
Keep the ANSIBLE_CFG_ prefix to refer to the kdevops Ansible
configuration module. This isn't part of the Ansible config file, but
rather of the kdevops module that configures Ansible.
Signed-off-by: Daniel Gomez <da.gomez@samsung.com>
---
kconfigs/Kconfig.ansible_cfg | 18 ++++++++++++++++++
kconfigs/Kconfig.ansible_provisioning | 6 ------
playbooks/roles/ansible_cfg/templates/ansible.cfg.j2 | 1 +
3 files changed, 19 insertions(+), 6 deletions(-)
diff --git a/kconfigs/Kconfig.ansible_cfg b/kconfigs/Kconfig.ansible_cfg
index b587596bc8d5f1215fa8c006f32d941bea5288cc..d78ea7507632ae86481633e83a845e81e6f7ad92 100644
--- a/kconfigs/Kconfig.ansible_cfg
+++ b/kconfigs/Kconfig.ansible_cfg
@@ -207,6 +207,24 @@ config ANSIBLE_CFG_FORKS
endif # !ANSIBLE_CFG_FORKS_CUSTOM
+config ANSIBLE_CFG_INVENTORY
+ string "Ansible inventory sources"
+ output yaml
+ default "$(TOPDIR_PATH)/hosts"
+ help
+ Comma-separated list of Ansible inventory source paths.
+
+ This is mapped to the [defaults] section of the Ansible configuration
+ file (ansible.cfg):
+ inventory = <value>
+
+ Each entry can be a path to an inventory file or directory,
+ such as:
+ /path/to/hosts,/path/to/inventory_dir
+
+ For more details, refer to the Ansible documentation:
+ https://docs.ansible.com/ansible/latest/reference_appendices/config.html#default-host-list
+
if DISTRO_OPENSUSE
config ANSIBLE_CFG_RECONNECTION_RETRIES
diff --git a/kconfigs/Kconfig.ansible_provisioning b/kconfigs/Kconfig.ansible_provisioning
index 63f04306e7b26f228defa9e50630f5ed07eaac37..4416d06754df3a9645fef15173e83e2279cfce1a 100644
--- a/kconfigs/Kconfig.ansible_provisioning
+++ b/kconfigs/Kconfig.ansible_provisioning
@@ -98,12 +98,6 @@ config KDEVOPS_DEVCONFIG_SYSTEMD_WATCHDOG_TIMEOUT_KEXEC
endif # KDEVOPS_DEVCONFIG_ENABLE_SYSTEMD_WATCHDOG
-config KDEVOPS_ANSIBLE_INVENTORY_FILE
- string "The ansible inventory file to use"
- default $(shell, scripts/append-makefile-vars.sh $(KDEVOPS_HOSTFILE))
- help
- The file to use for the ansible inventory.
-
config HAVE_DISTRO_PREFERS_ANSIBLE_PYTHON2
bool
default n
diff --git a/playbooks/roles/ansible_cfg/templates/ansible.cfg.j2 b/playbooks/roles/ansible_cfg/templates/ansible.cfg.j2
index 2bc916321f424ab93447af40eccef30911d27bb6..fddbab6d3a4dc03524a819b5b695336445ecb732 100644
--- a/playbooks/roles/ansible_cfg/templates/ansible.cfg.j2
+++ b/playbooks/roles/ansible_cfg/templates/ansible.cfg.j2
@@ -10,6 +10,7 @@ show_per_host_start = {{ ansible_cfg_callback_plugin_show_per_host_start }}
show_task_path_on_failure = {{ ansible_cfg_callback_plugin_show_task_path_on_failure }}
interpreter_python = {{ ansible_cfg_interpreter_python_string }}
forks = {{ ansible_cfg_forks }}
+inventory = {{ ansible_cfg_inventory }}
{% if ansible_facts['distribution'] == 'openSUSE' %}
[connection]
retries = {{ ansible_cfg_reconnection_retries }}
--
2.49.0
next prev 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 ` Daniel Gomez [this message]
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 ` [PATCH v2 09/10] ansible_cfg: add support to change ansible.cfg file location Daniel Gomez
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-6-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