How can I make Ansible use newer python due to errors when running playbook under other version?

RHEL 8.9 has python3.6, 3.8, 3.9, and 3.11 available to it. It uses alternatives to set the priority on them, and pip3 inherits whatever python3 is set to. Since you’re not enforcing a version, it’s apparently defaulting to python3.6 and pip3 is installing based on that.

Possible solutions:

  1. Be more specific in your installation versions. dnf install -y python3.11-pip && pip3.11 install -U ansible
  2. Update your alternatives: dnf install -y python3.11-pip && update-alternatives --set python3 /usr/bin/python3.11 && pip3 install -U ansible
  3. Install EPEL and use the ansible-core version provided by AppStream dnf install -y ansible # this is what I do, but EPEL is tailored and provided through Satellite Content Views instead of installing epel-release.
2 Likes