skip to Main Content

CentOS 8 does not always come with Python pre-installed, and so Ansible will fail running on the remote machine until it’s been installed. However in a classic Chicken/Egg, you can’t use the Ansible dnf module to install Python.

I’ve been using:

- name: Install Python 3
  raw: dnf -y install python3

However the problem with this is that I either have to set changed_when: false or it will always return a changed state. I’d like the state reported properly if it’s possible.

I found easy_install however this appears to only deal with Python Libraries, and not Python itself. Is there a built-in way to handle this or is raw: the only option?

2

Answers


  1. Chosen as BEST ANSWER

    As it goes, there is no simple answer, the truth is that if Python is not installed, the only method to get it installed with Ansible is to use the raw: method. Here is the answer I was provided at ServerFault... https://serverfault.com/questions/1016870/what-is-the-prefered-method-to-install-python-with-ansible-on-centos-8


Please signup or login to give your own answer.
Back To Top
Search