All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] python interpreter in ansible.cfg
@ 2025-04-04 20:01 Daniel Gomez
  2025-04-04 20:01 ` [PATCH 1/2] ansible_cfg: add python interpreter support Daniel Gomez
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Daniel Gomez @ 2025-04-04 20:01 UTC (permalink / raw)
  To: Daniel Gomez, Luis Chamberlain; +Cc: kdevops, Daniel Gomez

This adds support for the Ansible Python Interpreter [1] in Kconfig
and cli. Instead of setting the interpreter individually for every
task/target, just set it globally with the Ansible variable dedicated
for it (interpreter_python).

Set the default interpreter to auto_silent to silent the warning. From
documentation [2]:
"The fallback behavior will issue a warning that the interpreter
should be set explicitly (since interpreters installed later may change
which one is used). This warning behavior can be disabled by setting
auto_silent or auto_legacy_silent"

'auto_silent' will prevent this warning:
  TASK [Gathering Facts]
  
  [started TASK: Gathering Facts on localhost]
  Warning: : Platform linux on host localhost is using the discovered
  Python
  ok: [localhost]
  
  interpreter at /usr/bin/python3.13, but future installation of another
  Python interpreter could change the meaning of that path. See
  
  https://docs.ansible.com/ansible-
  core/2.18/reference_appendices/interpreter_discovery.html for more
  information.
  https://docs.ansible.com/ansible-core/2.18/reference_appendices/
  interpreter_discovery.html

In addition, this allows setting a custom interpreter if a specific
distribution requires it, such as NixOS:

diff --git a/kconfigs/Kconfig.ansible_cfg b/kconfigs/Kconfig.ansible_cfg
index 0c29300..9172e42 100644
--- a/kconfigs/Kconfig.ansible_cfg
+++ b/kconfigs/Kconfig.ansible_cfg
@@ -116,7 +116,7 @@ menu "Ansible Python Interpreter"
 choice
        prompt "Ansible Python Interpreter"
        default ANSIBLE_CFG_INTERPRETER_PYTHON_AUTO if !ANSIBLE_CFG_INTERPRETER_PYTHON_SET_BY_CLI
-       default ANSIBLE_CFG_INTERPRETER_PYTHON_CUSTOM if ANSIBLE_CFG_INTERPRETER_PYTHON_SET_BY_CLI
+       default ANSIBLE_CFG_INTERPRETER_PYTHON_CUSTOM if ANSIBLE_CFG_INTERPRETER_PYTHON_SET_BY_CLI || DISTRO_NIXOS

 config ANSIBLE_CFG_INTERPRETER_PYTHON_AUTO
        bool "Ansible Python Interpreter: Auto"
@@ -151,6 +151,7 @@ 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/python3" if !ANSIBLE_CFG_INTERPRETER_PYTHON_SET_BY_CLI
+       default "/usr/local/env python3" if !ANSIBLE_CFG_INTERPRETER_PYTHON_SET_BY_CLI && DISTRO_NIXOS

 endif # ANSIBLE_CFG_INTERPRETER_PYTHON_CUSTOM

[1]
https://docs.ansible.com/ansible-core/2.18/reference_appendices/interpreter_discovery.html
https://docs.ansible.com/ansible/latest/reference_appendices/config.html#interpreter-python

[2]
https://docs.ansible.com/ansible/latest/reference_appendices/config.html#interpreter-python-fallback

To: Daniel Gomez <da.gomez@samsung.com>
To: Luis Chamberlain <mcgrof@kernel.org>
Cc: kdevops@lists.linux.dev
Cc: Daniel Gomez <da.gomez@kernel.org>

Signed-off-by: Daniel Gomez <da.gomez@samsung.com>
---
Daniel Gomez (2):
      ansible_cfg: add python interpreter support
      Makefile: remove ansible_python_interpreter

 Makefile                                           |  2 -
 Makefile.build_qemu                                |  4 --
 Makefile.hypervisor-tunings                        |  1 -
 Makefile.kdevops                                   | 21 +++----
 Makefile.linux-mirror                              |  2 -
 Makefile.postfix                                   |  1 -
 kconfigs/Kconfig.ansible_cfg                       | 64 ++++++++++++++++++++++
 playbooks/roles/ansible_cfg/defaults/main.yml      |  1 +
 .../roles/ansible_cfg/templates/ansible.cfg.j2     |  1 +
 scripts/archive.Makefile                           |  1 -
 scripts/dynamic-pci-kconfig.Makefile               |  3 +-
 scripts/guestfs.Makefile                           | 14 ++---
 scripts/install-menuconfig-deps.Makefile           |  1 -
 scripts/journal-server.Makefile                    |  3 +-
 scripts/kconfig-ansible.Makefile                   |  1 +
 scripts/systemd-timesync.Makefile                  |  3 +-
 scripts/terraform.Makefile                         |  8 +--
 scripts/vagrant.Makefile                           |  6 +-
 18 files changed, 86 insertions(+), 51 deletions(-)
---
base-commit: 41edfaca90249f4e7bd975a906f64340460d3dbf
change-id: 20250402-python-interpreter-cbb06a40c8ff

Best regards,
-- 
Daniel Gomez <da.gomez@samsung.com>


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-04-04 23:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-04 20:01 [PATCH 0/2] python interpreter in ansible.cfg Daniel Gomez
2025-04-04 20:01 ` [PATCH 1/2] ansible_cfg: add python interpreter support Daniel Gomez
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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.