Skip to content

python interpreter in ansible.cfg

Daniel Gomez kdevops 1 version In review

Get series with b4
b4 am [email protected] change-id 20250402-python-interpreter-cbb06a40c8ff

Versions newest first

  1. v1 Latest2 patches 1 replyIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2ansible_cfg: add python interpreter supportkconfigs/Kconfig.ansible_cfg playbooks/roles/ansible_cfg/defaults/main.yml playbooks/roles/ansible_cfg/templates/ansible.cfg.j2+66 -00 replies
2/2Makefile: remove ansible_python_interpreterMakefile Makefile.build_qemu Makefile.hypervisor-tunings +12 more+20 -510 replies

Reviews trailers per patch

None of the 2 patches has a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchLuis Chamberlain
SeriesR-b
1/2
2/2

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH 0/2] python interpreter in ansible.cfg

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:

kconfigs/Kconfig.ansible_cfg +2 -1
index 0c29300..9172e42 100644
@@ -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 <[email protected]>
To: Luis Chamberlain <[email protected]>
Cc: [email protected]
Cc: Daniel Gomez <[email protected]>

---
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,

Signature · 1 line
Daniel Gomez <[email protected]>