From: Daniel Gomez <da.gomez@kernel.org>
To: Daniel Gomez <da.gomez@samsung.com>,
Luis Chamberlain <mcgrof@kernel.org>
Cc: kdevops@lists.linux.dev, Daniel Gomez <da.gomez@kernel.org>
Subject: [PATCH 1/2] ansible_cfg: add python interpreter support
Date: Fri, 04 Apr 2025 20:01:15 +0000 [thread overview]
Message-ID: <20250404-python-interpreter-v1-1-04783b627ce7@samsung.com> (raw)
In-Reply-To: <20250404-python-interpreter-v1-0-04783b627ce7@samsung.com>
From: Daniel Gomez <da.gomez@samsung.com>
Ansible Python interpreter can be set globally in [defaults] section
of ansible.fg with the interpreter_python key. Add support for it in
Kconfig ansible_cfg and allow cli to overwrite the the value.
https://docs.ansible.com/ansible/latest/reference_appendices/
interpreter_discovery.html#interpreter-discovery
https://docs.ansible.com/ansible/latest/reference_appendices/
config.html#interpreter-python
Signed-off-by: Daniel Gomez <da.gomez@samsung.com>
---
kconfigs/Kconfig.ansible_cfg | 64 ++++++++++++++++++++++
playbooks/roles/ansible_cfg/defaults/main.yml | 1 +
.../roles/ansible_cfg/templates/ansible.cfg.j2 | 1 +
3 files changed, 66 insertions(+)
diff --git a/kconfigs/Kconfig.ansible_cfg b/kconfigs/Kconfig.ansible_cfg
index 7286b0fe502521835a2dada19b9d59207fc37b94..3d9b635abb7232f53c8537f60663c8f6e1f861fd 100644
--- a/kconfigs/Kconfig.ansible_cfg
+++ b/kconfigs/Kconfig.ansible_cfg
@@ -2,6 +2,10 @@ config ANSIBLE_CFG_CALLBACK_PLUGIN_SET_BY_CLI
bool
default $(shell, scripts/check-cli-set-var.sh ANSIBLE_CFG_CALLBACK_PLUGIN)
+config ANSIBLE_CFG_INTERPRETER_PYTHON_SET_BY_CLI
+ bool
+ default $(shell, scripts/check-cli-set-var.sh ANSIBLE_CFG_INTERPRETER_PYTHON)
+
menu "Ansible Callback Plugin Configuration"
choice
prompt "Ansible Callback Plugin"
@@ -108,6 +112,66 @@ config ANSIBLE_CFG_DEPRECATION_WARNINGS
Toggle to control the showing of deprecation warnings
https://docs.ansible.com/ansible/latest/reference_appendices/config.html#deprecation-warnings
+menu "Ansible Python Interpreter"
+choice
+ prompt "Ansible Python Interpreter"
+ default ANSIBLE_CFG_INTERPRETER_PYTHON_AUTO_SILENT if !ANSIBLE_CFG_INTERPRETER_PYTHON_SET_BY_CLI
+ default ANSIBLE_CFG_INTERPRETER_PYTHON_CUSTOM if ANSIBLE_CFG_INTERPRETER_PYTHON_SET_BY_CLI
+
+config ANSIBLE_CFG_INTERPRETER_PYTHON_AUTO
+ bool "Ansible Python Interpreter: Auto"
+ help
+ https://docs.ansible.com/ansible/latest/reference_appendices/interpreter_discovery.html#interpreter-discovery
+
+config ANSIBLE_CFG_INTERPRETER_PYTHON_AUTO_LEGACY
+ bool "Ansible Python Interpreter: Auto Legacy"
+ help
+ https://docs.ansible.com/ansible/latest/reference_appendices/interpreter_discovery.html#interpreter-discovery
+
+config ANSIBLE_CFG_INTERPRETER_PYTHON_AUTO_LEGACY_CLIENT
+ bool "Ansible Python Interpreter: Auto Legacy Client"
+ help
+ https://docs.ansible.com/ansible/latest/reference_appendices/interpreter_discovery.html#interpreter-discovery
+
+config ANSIBLE_CFG_INTERPRETER_PYTHON_AUTO_SILENT
+ bool "Ansible Python Interpreter: Auto Silent"
+ help
+ https://docs.ansible.com/ansible/latest/reference_appendices/interpreter_discovery.html#interpreter-discovery
+
+config ANSIBLE_CFG_INTERPRETER_PYTHON_CUSTOM
+ bool "Ansible Python Interpreter: Custom"
+ help
+ https://docs.ansible.com/ansible/latest/reference_appendices/interpreter_discovery.html#interpreter-discovery
+
+endchoice
+
+if ANSIBLE_CFG_INTERPRETER_PYTHON_CUSTOM
+
+config ANSIBLE_CFG_INTERPRETER_PYTHON_CUSTOM_NAME
+ string "Custom Ansible Python Interpreter Name"
+ default $(shell, ./scripts/append-makefile-vars.sh $(ANSIBLE_CFG_INTERPRETER_PYTHON)) if ANSIBLE_CFG_INTERPRETER_PYTHON_SET_BY_CLI
+ default "/usr/bin/env python3" if !ANSIBLE_CFG_INTERPRETER_PYTHON_SET_BY_CLI
+
+endif # ANSIBLE_CFG_INTERPRETER_PYTHON_CUSTOM
+
+config ANSIBLE_CFG_INTERPRETER_PYTHON_STRING
+ string
+ output yaml
+ default "auto" if ANSIBLE_CFG_INTERPRETER_PYTHON_AUTO
+ default "auto_legacy" if ANSIBLE_CFG_INTERPRETER_PYTHON_AUTO_LEGACY
+ default "auto_legacy_client" if ANSIBLE_CFG_INTERPRETER_PYTHON_AUTO_LEGACY_CLIENT
+ default "auto_silent" if ANSIBLE_CFG_INTERPRETER_PYTHON_AUTO_SILENT
+ default ANSIBLE_CFG_INTERPRETER_PYTHON_CUSTOM_NAME if ANSIBLE_CFG_INTERPRETER_PYTHON_CUSTOM
+ help
+ Path to the Python interpreter to be used for module execution on remote targets,
+ or an automatic discovery mode.
+ https://docs.ansible.com/ansible/latest/reference_appendices/python_3_support.html#using-python-3-on-the-managed-machines-with-commands-and-playbooks
+ https://docs.ansible.com/ansible/latest/reference_appendices/interpreter_discovery.html#interpreter-discovery
+ https://docs.ansible.com/ansible/latest/reference_appendices/config.html#interpreter-python
+ https://docs.ansible.com/ansible/latest/reference_appendices/config.html#envvar-ANSIBLE_PYTHON_INTERPRETER
+
+endmenu
+
if DISTRO_OPENSUSE
config ANSIBLE_CFG_RECONNECTION_RETRIES
diff --git a/playbooks/roles/ansible_cfg/defaults/main.yml b/playbooks/roles/ansible_cfg/defaults/main.yml
index c98334aa8f81e397ce4950a84f108a21d78fc784..f8ec327a5a1687dff5791ee7c763b06939f718f4 100644
--- a/playbooks/roles/ansible_cfg/defaults/main.yml
+++ b/playbooks/roles/ansible_cfg/defaults/main.yml
@@ -8,3 +8,4 @@ ansible_cfg_callback_plugin_display_skipped_hosts: true
ansible_cfg_callback_plugin_show_custom_stats: false
ansible_cfg_callback_plugin_show_per_host_start: true
ansible_cfg_callback_plugin_show_task_path_on_failure: true
+ansible_cfg_interpreter_python: "auto_silent"
diff --git a/playbooks/roles/ansible_cfg/templates/ansible.cfg.j2 b/playbooks/roles/ansible_cfg/templates/ansible.cfg.j2
index e13931b5ce97807365a0e0caa0db921a3b2930d7..666ee344901df064c81d8c5aaadc82af38a01897 100644
--- a/playbooks/roles/ansible_cfg/templates/ansible.cfg.j2
+++ b/playbooks/roles/ansible_cfg/templates/ansible.cfg.j2
@@ -8,6 +8,7 @@ display_skipped_hosts = {{ ansible_cfg_callback_plugin_display_skipped_hosts }}
show_custom_stats = {{ ansible_cfg_callback_plugin_show_custom_stats }}
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 }}
{% if ansible_facts['distribution'] == 'openSUSE' %}
[connection]
retries = {{ ansible_cfg_reconnection_retries }}
--
2.47.2
next prev parent reply other threads:[~2025-04-04 20:01 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-04 20:01 [PATCH 0/2] python interpreter in ansible.cfg Daniel Gomez
2025-04-04 20:01 ` Daniel Gomez [this message]
2025-04-04 20:01 ` [PATCH 2/2] Makefile: remove ansible_python_interpreter Daniel Gomez
2025-04-04 23:39 ` [PATCH 0/2] python interpreter in ansible.cfg Luis Chamberlain
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=20250404-python-interpreter-v1-1-04783b627ce7@samsung.com \
--to=da.gomez@kernel.org \
--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