從下面的代碼片段中可以看出,ansible 的可執行檔案似乎忽略了 ansible_python_interpreter 變數。如果不求助于清單檔案(這是針對基于 hashicorp 打包程式的 gitlab 管道 - 呼叫 ansible),我如何強制 ansible 使用我擁有的任何 python 版本?在這種情況下,它是 Ubuntu 18.04,所以我想從 python-2.7 切換到 python-3.6。
另一個相關的原因可能是 ansibles pkg(策略?)總是在仿生上安裝 python-2.7。
root@ubuntu18:~# ansible --version
ansible 2.9.27
config file = /etc/ansible/ansible.cfg
configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python2.7/dist-packages/ansible
executable location = /usr/bin/ansible
python version = 2.7.17 (default, Feb 27 2021, 15:10:58) [GCC 7.5.0]
root@ubuntu18:~# /usr/bin/python3.6 --version
Python 3.6.9
root@ubuntu18:~# ansible --version -e 'ansible_python_interpreter=/usr/bin/python3.6'
ansible 2.9.27
config file = /etc/ansible/ansible.cfg
configured module search path = [u'/root/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
ansible python module location = /usr/lib/python2.7/dist-packages/ansible
executable location = /usr/bin/ansible
python version = 2.7.17 (default, Feb 27 2021, 15:10:58) [GCC 7.5.0]
root@ubuntu18:~#
我最后的手段似乎是使用 pip3 安裝 ansible,但這需要對管道 yaml 和打包程式的 json 進行大量重寫。
任何幫助將不勝感激。
干杯
uj5u.com熱心網友回復:
您沒有提供任何證據表明該引數被忽略。ansible_python_intepreter適用于目標上模塊的執行,而不是 Ansible 本身的執行。
Ansible 控制行程始終使用它安裝在其下的 Python 解釋器;改變這一點的最好方法是改變你的安裝程序。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/364683.html
標籤:Python 蟒蛇-3.x 乌本图 能听懂的 ubuntu-18.04
