coglinev3.ansible_python

Ansible Role: ansible_python

Build GitHub tag (latest by date) License

Ansible requires Python 2 (version 2.6 or higher) or Python 3 (version 3.5 or higher) to function. However, some Linux distributions and Docker images, like Ubuntu, do not come with Python installed by default. To avoid manually installing Python on those systems, this Ansible role uses the raw module (which doesn’t need Python) to install the Python2 or Python3 package. This allows you to use Ansible as usual on those systems.

Warning: Ansible 2.11 will treat Python 3.8 as a recommended requirement for the control node, but will still work with the previous Python versions. Starting with Ansible 2.12, Python 3.8 or newer will be necessary for the control node. From Ansible 2.11 onwards, it will only be packaged for Python 3.8 and later.

You should run this role before your main tasks by listing it under pre_tasks, and set gather_facts to false, as shown in the example below.

Supported Linux distributions for this role include:

  • Alpine Linux 3.12 to 3.19
  • Amazon Linux 2023
  • Debian 10 (Buster), 11 (Bullseye), and 12 (Bookworm)
  • Enterprise Linux 7, 8, and 9
  • Fedora 34 to 39
  • Ubuntu 18.04 LTS, 20.04 LTS, and 22.04 LTS

The role has been tested using Molecule and Docker on GitHub, as well as in this Multi-VM Vagrant environment.

Requirements

None.

Role Variables

None.

Dependencies

None.

Example

---

- hosts: all
  become: true
  # Disable fact gathering since it requires Python
  gather_facts: false
  pre_tasks:
    - name: "Install python if needed"
      include_role:
        name: "coglinev3.ansible_python"
    - name: Gather facts
      setup: # Enable fact gathering
  tasks:
    - name: Your other tasks go here

Version

Release: 1.14.2

License

BSD

Author Information

Copyright © 2020 - 2024 Cogline.v3.

Informazioni sul progetto

With the help of the raw module, this Ansible role installs python on a system where python is missing.

Installa
ansible-galaxy install coglinev3.ansible_python
Licenza
bsd-3-clause
Download
7.3k
Proprietario