在 CentOS 8 上使用 Ansible 安装 Python 的首选方法是什么
What is the prefered method to install Python with Ansible on CentOS 8
CentOS 8 并不总是预装 Python,因此在安装 Ansible 之前,远程机器上的 Ansible 会失败 运行。然而,在经典 Chicken/Egg 中,您不能使用 Ansible dnf
模块来安装 Python.
我一直在使用:
- name: Install Python 3
raw: dnf -y install python3
但是问题是我要么必须设置 changed_when: false
要么它总是 return 一个改变的状态。如果可能的话,我希望正确报告状态。
我发现 easy_install
但这似乎只处理 Python 库,而不处理 Python 本身。有内置的方法来处理这个问题还是 raw:
是唯一的选择?
这是不正确的。 CentOS 8 自带 platform-python 开箱即用,Ansible >= 2.8 将默认使用。
https://developers.redhat.com/blog/2018/11/14/python-in-rhel-8-3
https://www.ansible.com/blog/integrating-ansible-and-red-hat-enterprise-linux-8-beta
https://docs.ansible.com/ansible/latest/reference_appendices/interpreter_discovery.html
快乐自动化!
事实上,没有简单的答案,事实是如果 Python 没有安装,用 Ansible 安装它的唯一方法是使用 raw:
方法。这是我在 ServerFault 上得到的答案... https://serverfault.com/questions/1016870/what-is-the-prefered-method-to-install-python-with-ansible-on-centos-8
CentOS 8 并不总是预装 Python,因此在安装 Ansible 之前,远程机器上的 Ansible 会失败 运行。然而,在经典 Chicken/Egg 中,您不能使用 Ansible dnf
模块来安装 Python.
我一直在使用:
- name: Install Python 3
raw: dnf -y install python3
但是问题是我要么必须设置 changed_when: false
要么它总是 return 一个改变的状态。如果可能的话,我希望正确报告状态。
我发现 easy_install
但这似乎只处理 Python 库,而不处理 Python 本身。有内置的方法来处理这个问题还是 raw:
是唯一的选择?
这是不正确的。 CentOS 8 自带 platform-python 开箱即用,Ansible >= 2.8 将默认使用。
https://developers.redhat.com/blog/2018/11/14/python-in-rhel-8-3
https://www.ansible.com/blog/integrating-ansible-and-red-hat-enterprise-linux-8-beta
https://docs.ansible.com/ansible/latest/reference_appendices/interpreter_discovery.html
快乐自动化!
事实上,没有简单的答案,事实是如果 Python 没有安装,用 Ansible 安装它的唯一方法是使用 raw:
方法。这是我在 ServerFault 上得到的答案... https://serverfault.com/questions/1016870/what-is-the-prefered-method-to-install-python-with-ansible-on-centos-8