Skip to content

Commit f25f3de

Browse files
committed
ansible_cfg: add python interpreter support
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 <[email protected]>
1 parent 24e657f commit f25f3de

File tree

2 files changed

+65
-0
lines changed

2 files changed

+65
-0
lines changed

kconfigs/Kconfig.ansible_cfg

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ config ANSIBLE_CFG_CALLBACK_PLUGIN_SET_BY_CLI
22
bool
33
default $(shell, scripts/check-cli-set-var.sh ANSIBLE_CFG_CALLBACK_PLUGIN)
44

5+
config ANSIBLE_CFG_INTERPRETER_PYTHON_SET_BY_CLI
6+
bool
7+
default $(shell, scripts/check-cli-set-var.sh ANSIBLE_CFG_INTERPRETER_PYTHON)
8+
59
menu "Ansible Callback Plugin Configuration"
610
choice
711
prompt "Ansible Callback Plugin"
@@ -108,6 +112,66 @@ config ANSIBLE_CFG_DEPRECATION_WARNINGS
108112
Toggle to control the showing of deprecation warnings
109113
https://docs.ansible.com/ansible/latest/reference_appendices/config.html#deprecation-warnings
110114

115+
menu "Ansible Python Interpreter"
116+
choice
117+
prompt "Ansible Python Interpreter"
118+
default ANSIBLE_CFG_INTERPRETER_PYTHON_AUTO if !ANSIBLE_CFG_INTERPRETER_PYTHON_SET_BY_CLI
119+
default ANSIBLE_CFG_INTERPRETER_PYTHON_CUSTOM if ANSIBLE_CFG_INTERPRETER_PYTHON_SET_BY_CLI
120+
121+
config ANSIBLE_CFG_INTERPRETER_PYTHON_AUTO
122+
bool "Ansible Python Interpreter: Auto"
123+
help
124+
https://docs.ansible.com/ansible/latest/reference_appendices/interpreter_discovery.html#interpreter-discovery
125+
126+
config ANSIBLE_CFG_INTERPRETER_PYTHON_AUTO_LEGACY
127+
bool "Ansible Python Interpreter: Auto Legacy"
128+
help
129+
https://docs.ansible.com/ansible/latest/reference_appendices/interpreter_discovery.html#interpreter-discovery
130+
131+
config ANSIBLE_CFG_INTERPRETER_PYTHON_AUTO_LEGACY_CLIENT
132+
bool "Ansible Python Interpreter: Auto Legacy Client"
133+
help
134+
https://docs.ansible.com/ansible/latest/reference_appendices/interpreter_discovery.html#interpreter-discovery
135+
136+
config ANSIBLE_CFG_INTERPRETER_PYTHON_AUTO_SILENT
137+
bool "Ansible Python Interpreter: Auto Silent"
138+
help
139+
https://docs.ansible.com/ansible/latest/reference_appendices/interpreter_discovery.html#interpreter-discovery
140+
141+
config ANSIBLE_CFG_INTERPRETER_PYTHON_CUSTOM
142+
bool "Ansible Python Interpreter: Custom"
143+
help
144+
https://docs.ansible.com/ansible/latest/reference_appendices/interpreter_discovery.html#interpreter-discovery
145+
146+
endchoice
147+
148+
if ANSIBLE_CFG_INTERPRETER_PYTHON_CUSTOM
149+
150+
config ANSIBLE_CFG_INTERPRETER_PYTHON_CUSTOM_NAME
151+
string "Custom Ansible Python Interpreter Name"
152+
default $(shell, ./scripts/append-makefile-vars.sh $(ANSIBLE_CFG_INTERPRETER_PYTHON)) if ANSIBLE_CFG_INTERPRETER_PYTHON_SET_BY_CLI
153+
default "/usr/bin/python3" if !ANSIBLE_CFG_INTERPRETER_PYTHON_SET_BY_CLI
154+
155+
endif # ANSIBLE_CFG_INTERPRETER_PYTHON_CUSTOM
156+
157+
config ANSIBLE_CFG_INTERPRETER_PYTHON_STRING
158+
string
159+
output yaml
160+
default "auto" if ANSIBLE_CFG_INTERPRETER_PYTHON_AUTO
161+
default "auto_legacy" if ANSIBLE_CFG_INTERPRETER_PYTHON_AUTO_LEGACY
162+
default "auto_legacy_client" if ANSIBLE_CFG_INTERPRETER_PYTHON_AUTO_LEGACY_CLIENT
163+
default "auto_silent" if ANSIBLE_CFG_INTERPRETER_PYTHON_AUTO_SILENT
164+
default ANSIBLE_CFG_INTERPRETER_PYTHON_CUSTOM_NAME if ANSIBLE_CFG_INTERPRETER_PYTHON_CUSTOM
165+
help
166+
Path to the Python interpreter to be used for module execution on remote targets,
167+
or an automatic discovery mode.
168+
https://docs.ansible.com/ansible/latest/reference_appendices/python_3_support.html#using-python-3-on-the-managed-machines-with-commands-and-playbooks
169+
https://docs.ansible.com/ansible/latest/reference_appendices/interpreter_discovery.html#interpreter-discovery
170+
https://docs.ansible.com/ansible/latest/reference_appendices/config.html#interpreter-python
171+
https://docs.ansible.com/ansible/latest/reference_appendices/config.html#envvar-ANSIBLE_PYTHON_INTERPRETER
172+
173+
endmenu
174+
111175
if DISTRO_OPENSUSE
112176

113177
config ANSIBLE_CFG_RECONNECTION_RETRIES

playbooks/roles/ansible_cfg/templates/ansible.cfg.j2

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ display_skipped_hosts = {{ ansible_cfg_callback_plugin_display_skipped_hosts }}
88
show_custom_stats = {{ ansible_cfg_callback_plugin_show_custom_stats }}
99
show_per_host_start = {{ ansible_cfg_callback_plugin_show_per_host_start }}
1010
show_task_path_on_failure = {{ ansible_cfg_callback_plugin_show_task_path_on_failure }}
11+
interpreter_python = {{ ansible_cfg_interpreter_python_string }}
1112
{% if ansible_facts['distribution'] == 'openSUSE' %}
1213
[connection]
1314
retries = {{ ansible_cfg_reconnection_retries }}

0 commit comments

Comments
 (0)