我有一个需要Python3.8或更高版本才能运行的Ansible模块。我们通过AWX部署我们的剧本(由另一个团队管理)。有没有一种方法可以让AWX运行特定版本的python,或者这是需要在AWX方面解决的问题?
我已经尝试将ansible_python_interpreter和interpreter_python添加到我的ansible.cfg中,添加为vars,并将其添加到模块中作为vars:
vars:
ansible_python_interpreter: /usr/bin/python3.9
interpreter_python: /usr/bin/python3.9
OR
import_role:
name: aviconfig
vars:
ansible_playbook_python: /usr/bin/python3.9
interpreter_python: /usr/bin/python3.9
但是当我在AWX中查看任务时,我得到以下错误:
fatal: [localhost]: FAILED! => {
"msg": "Unable to import vmware.alb.avi_serviceenginegroup due to more than 255 arguments"
}
在AWX GUI中,没有"执行环境"的下拉菜单;
参见INTERPRETER_PYTHON。引言:
用于在远程目标上执行模块的Python解释器的路径…
- ansible_python_interpreter是一个变量
- interpreter_python是ansible.cfg 中使用的配置键。
当你声明变量
vars:
ansible_python_interpreter: /usr/bin/python3.9
interpreter_python: /usr/bin/python3.9
模块将在远程主机上使用/usr/bin/python3.9。变量interpreter_python不影响任何东西。这可以在配置文件中使用。参见配置Ansible
shell> cat ansible.cfg
[defaults]
interpreter_python = /usr/bin/python3.9
...
一般来说,你可以为play、role、block和task声明变量。例如,为每个任务声明Python版本
shell> cat pb.yml
- hosts: test_14
tasks:
- ping:
vars:
ansible_python_interpreter: /usr/local/bin/python3.7
- ping:
vars:
ansible_python_interpreter: /usr/local/bin/python3.8
- ping:
vars:
ansible_python_interpreter: /usr/local/bin/python3.9
为
<一口>shell> ansible-playbook pb.yml -vvv | grep /usr/local/bin/python
& lt; 10.1.0.17>SSH:执行ssh - c - o ControlMaster = auto - o ControlPersist = 60年代- o KbdInteractiveAuthentication = no - o PreferredAuthentications = gssapi-with-mic gssapi-keyex, hostbased, publickey - o PasswordAuthentication = no - o '用户="asadmin"' - o ConnectTimeout = 10 - o ' ControlPath ="/出口/home/vlado.config/.ansible/cp/d6c0760925"tt 10.1.0.17/bin/sh - c"""sudo - h - s - n - u root/bin/sh - c"""""""""呼应BECOME-SUCCESS-qbxxhglwszmqjmslnpbuxgocmzxfidxv;/usr/地方/bin/python3.7/home/asadmin/.ansible/tmp/ansible-tmp-1680757723.166957-1264442-114878406354546/AnsiballZ_ping.py'"'"'"'"';睡眠0""">
& lt; 10.1.0.17>SSH:执行ssh - c - o ControlMaster = auto - o ControlPersist = 60年代- o KbdInteractiveAuthentication = no - o PreferredAuthentications = gssapi-with-mic gssapi-keyex, hostbased, publickey - o PasswordAuthentication = no - o '用户="asadmin"' - o ConnectTimeout = 10 - o ' ControlPath ="/出口/home/vlado.config/.ansible/cp/d6c0760925"tt 10.1.0.17/bin/sh - c"""sudo - h - s - n - u root/bin/sh - c"""""""""呼应BECOME-SUCCESS-vhudpllaaigkgxbwegttypeoavwuljwc;/usr/地方/bin/python3.8/home/asadmin/.ansible/tmp/ansible-tmp-1680757724.7586734-1264451-30500526050593/AnsiballZ_ping.py'"'"'"'"'"'睡眠0""">
& lt; 10.1.0.17>SSH:执行ssh - c - o ControlMaster = auto - o ControlPersist = 60年代- o KbdInteractiveAuthentication = no - o PreferredAuthentications = gssapi-with-mic gssapi-keyex, hostbased, publickey - o PasswordAuthentication = no - o '用户="asadmin"' - o ConnectTimeout = 10 - o ' ControlPath ="/出口/home/vlado.config/.ansible/cp/d6c0760925"tt 10.1.0.17/bin/sh - c"""sudo - h - s - n - u root/bin/sh - c"""""""""呼应BECOME-SUCCESS-thetuokxemcxduldbrtcipfitzucsytj;/usr/地方/bin/python3.9/home/asadmin/.ansible/tmp/ansible-tmp-1680757726.1293967-1264468-188410557208290/AnsiballZ_ping.py'"'"'"'"睡眠0""">
参见Ansible使用错误的Python版本。
一口>