<p>无法在控制器上配置Ansible使用的Python版本</p>
<p><a href="https://docs.ansible.com/ansible/latest/reference_appendices/config.html#interpreter-python" rel="nofollow noreferrer">ANSIBLE_PYTHON_INTERPRETER</a>将设置配置参数:</p>
<blockquote>
<p>Path to the Python interpreter to be used for module execution on <strong>remote targets</strong></p>
</blockquote>
<p>控制器上Python的版本取决于Ansible的构建方式。比如说</p>
<ul>
<li><a href="https://packages.ubuntu.com/bionic/ansible" rel="nofollow noreferrer">Ubuntu 18.04</a>使用Python 2.x</li>
</ul>
<pre class="lang-sh prettyprint-override"><code>shell> grep DISTRIB_DESCRIPTION /etc/lsb-release
DISTRIB_DESCRIPTION="Ubuntu 18.04.4 LTS"
shell> dpkg -l | grep ansible
ii ansible 2.9.6-1ppa~bionic
shell> ansible version
ansible 2.9.6
config file = /home/admin/.ansible.cfg
configured module search path = [u'/home/admin/.ansible/my_modules']
ansible python module location = /usr/lib/python2.7/dist-packages/ansible
executable location = /usr/bin/ansible
python version = 2.7.17 (default, Nov 7 2019, 10:07:09) [GCC 7.4.0]
</code></pre>
<ul>
<li><a href="https://packages.ubuntu.com/focal/ansible" rel="nofollow noreferrer">Ubuntu 20.04</a>使用Python 3.x</li>
</ul>
<pre class="lang-sh prettyprint-override"><code>shell> grep DISTRIB_DESCRIPTION /etc/lsb-release
DISTRIB_DESCRIPTION="Ubuntu 20.04 LTS"
shell> dpkg -l | grep ansible
ii ansible 2.9.6+dfsg-1
shell> ansible version
ansible 2.9.6
config file = /home/admin/.ansible.cfg
configured module search path = ['/home/admin/.ansible/my_modules']
ansible python module location = /usr/lib/python3/dist-packages/ansible
executable location = /usr/bin/ansible
python version = 3.8.2 (default, Apr 27 2020, 15:53:34) [GCC 9.3.0]
</code></pre>