Skip to content

Commit

Permalink
Update to current distros and Ansible versions
Browse files Browse the repository at this point in the history
  • Loading branch information
nmusatti committed Feb 1, 2025
1 parent ffe5fa6 commit c81f4e7
Show file tree
Hide file tree
Showing 10 changed files with 90 additions and 110 deletions.
11 changes: 5 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,23 @@ name: test

jobs:
test:
runs-on: ubuntu-20.04
runs-on: ubuntu-22.04
strategy:
matrix:
platform:
- rockylinux9
- rockylinux8
# - rockylinux8
- centos-stream10
- centos-stream9
# - fedora41
- fedora41
- fedora40
- fedora39
- ubuntu2404
- ubuntu2204
- ubuntu2004

steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
- run: |
python3 -m pip install --upgrade pip
python3 -m pip install tox
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ waco_python
An opinionated Ansible role that allows you to perform system and/or source Python installations and
to complement them by creating custom virtualenv's and installing Ansible, Mercurial or Sphinx.
Supported distributions are the currently maintained releases of the Red Hat family and
derivatives, and of the Ubuntu LTS variants. At this time tests are run on Rocky Linux 8, CentOS 7,
Fedora 35, Fedora 34, Ubuntu 20.04 and Ubuntu 18.04.
derivatives, and of the Ubuntu LTS variants. At this time tests are run on Rocky Linux 9, CentOS Stream 10,
CentOS Stream 9, Fedora 41, Fedora 40, Fedora 39, Ubuntu 24.04, Ubuntu 22.04 and Ubuntu 20.04.


Requirements
Expand Down Expand Up @@ -40,7 +40,7 @@ Whether to install Sphinx, in a specific virtualenv based on the latest Python v

Owner and group of source Python installations.

wapy_source_versions: [ 3.10.1 ]
wapy_source_versions: [ 3.13.1 ]

The Python source releases to be installed.

Expand Down Expand Up @@ -114,7 +114,7 @@ with the [waco-master](https://github.com/waco-org/waco-master) role.
- role: waco_org.waco_python
vars:
wapy_source_versions:
- 3.10.1
- 3.13.1
wapy_has_sphinx: true

License
Expand Down
21 changes: 12 additions & 9 deletions defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
---
# Workstation as Code
# Copyright Nicola Musatti 2020 - 2022.
# Copyright Nicola Musatti 2020 - 2025.

wapy_has_ansible: false
wapy_has_mercurial: false
wapy_has_sphinx: false
wapy_user: python
wapy_group: "{{ wapy_user }}"
wapy_source_versions:
- 3.10.6
# - 3.9.13
# - 3.8.13
# - 3.7.13
# - 3.6.15
# - 2.7.18
- 3.13.1
# - 3.12.8
# - 3.11.11
# - 3.10.16
# - 3.9.21
# - 3.8.20
# - 3.7.17
wapy_build_root_dir: "/sw"
wapy_install_root_dir: "/opt"
# wapy_pip_version: 20.3.1
# wapy_pip_version: 24.3.1
wapy_source_packages:
- ipython
- pip
Expand All @@ -36,6 +37,7 @@ wapy_source_venv_packages:
- six
- tox
- twine
- virtualenv
- wheel
wapy_system_venv_root_dir: "/opt"
wapy_system_venv_prefix: "sysvenv"
Expand All @@ -44,7 +46,8 @@ wapy_ansible_packages:
- ansible
- ansible-lint
- flake8
- molecule[docker,lint]
- molecule
- molecule-plugins[docker]
- pytest
- selinux
- pytest-testinfra
Expand Down
14 changes: 6 additions & 8 deletions meta/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
# Workstation as Code
# Copyright Nicola Musatti 2020 - 2022.
# Copyright Nicola Musatti 2020 - 2025.

galaxy_info:
role_name: waco_python
Expand All @@ -10,24 +10,22 @@ galaxy_info:
company: The Waco project

license: GPLv3

min_ansible_version: "2.10"

min_ansible_version: "2.17"
platforms:
- name: EL
versions:
- "9"
- "8"
- "7"
- name: Fedora
versions:
- "36"
- "35"
- "41"
- "40"
- "39"
- name: Ubuntu
versions:
- noble
- jammy
- focal
- bionic

galaxy_tags: []

Expand Down
2 changes: 1 addition & 1 deletion molecule/default/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
- role: waco_org.waco_python
vars:
wapy_source_versions:
- "3.9.0"
- "3.13.1"
wapy_has_ansible: true
wapy_has_mercurial: true
wapy_has_sphinx: true
12 changes: 6 additions & 6 deletions molecule/default/tests/test_default.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,23 +25,23 @@ def test_python2(host):


def test_source_python(host):
f = host.file('/opt/Python-3.9/bin/python3.9')
f = host.file('/opt/Python-3.13/bin/python3.13')
assert f.exists
assert f.user == 'python'
assert f.group == 'python'

assert '3.9.0' in host.check_output(
'/opt/Python-3.9/bin/python3.9 --version')
assert '3.13.1' in host.check_output(
'/opt/Python-3.13/bin/python3.13 --version')


def test_venv_python(host):
f = host.file('/opt/venv-3.9/dev/bin/python3.9')
f = host.file('/opt/venv-3.13/dev/bin/python3.13')
assert f.exists
assert f.user == 'python'
assert f.group == 'python'

assert '3.9.0' in host.check_output(
'/opt/venv-3.9/dev/bin/python3.9 --version')
assert '3.13.1' in host.check_output(
'/opt/venv-3.13/dev/bin/python3.13 --version')


def test_ansible(host):
Expand Down
52 changes: 23 additions & 29 deletions tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
# Workstation as Code
# Copyright Nicola Musatti 2020 - 2023.
# Copyright Nicola Musatti 2020 - 2025.

- name: Create the Python installation group
ansible.builtin.group:
Expand All @@ -13,59 +13,53 @@
group: "{{ wapy_group }}"
become: true

- name: Install GnuPG 2 (EL 10)
ansible.builtin.dnf:
name:
- gnupg2
state: present
become: true
when: wapy_platform in ('EL10')

- name: Enable the EPEL repository
ansible.builtin.include_role:
name: geerlingguy.repo-epel
when: wapy_platform in ('EL7', 'EL8', 'EL9')
when: wapy_platform in ('EL10', 'EL9', 'EL8')

- name: Install system Python (EL 9)
ansible.builtin.dnf:
name:
- python3
state: present
- name: Check if the Code Ready Linux Builder repository is installed (EL 10, EL 9)
ansible.builtin.command: "crb status"
become: true
when: wapy_platform in ('EL9')
register: crb
changed_when: false
when: wapy_platform in ('EL10', 'EL9')

- name: Install system Python (EL 8, Fedora)
ansible.builtin.dnf:
name:
- python2
- python3
state: present
- name: Enable the Code Ready Linux Builder repository (EL 10, EL 9)
ansible.builtin.command: "crb enable"
become: true
when: wapy_platform in ('EL8', 'Fedora')
when: wapy_platform in ('EL10', 'EL9') and 'disabled' in crb.stdout

- name: Install system Python (EL 7)
ansible.builtin.yum:
- name: Install system Python
ansible.builtin.dnf:
name:
- python2
- python3
state: present
become: true
when: wapy_platform == 'EL7'
when: ansible_os_family == 'RedHat'

- name: Install system Python (Ubuntu)
ansible.builtin.apt:
name:
- "{{ (ansible_distribution_version == '18.04') | ternary('python', 'python2') }}"
- python3
state: present
become: true
when: wapy_platform == 'Ubuntu'

- name: "Install system Python dependencies (EL 9, EL 8, Fedora)"
- name: "Install system Python dependencies (EL 10, EL 9, EL 8, Fedora)"
ansible.builtin.dnf:
name: "{{ wapy_system_python_deps }}"
state: present
become: true
when: wapy_platform in ('EL9', 'EL8', 'Fedora')

- name: "Install system Python dependencies (EL 7)"
ansible.builtin.yum:
name: "{{ wapy_system_python_deps }}"
state: present
become: true
when: wapy_platform == 'EL7'
when: wapy_platform in ('EL10', 'EL9', 'EL8', 'Fedora')

- name: "Install system Python dependencies (Ubuntu)"
ansible.builtin.apt:
Expand Down
21 changes: 4 additions & 17 deletions tasks/redhat/ansible_mercurial.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
# Workstation as Code
# Copyright Nicola Musatti 2022 - 2023.
# Copyright Nicola Musatti 2022 - 2025.

- name: "Register SELinux compatible source virtualenv tools"
ansible.builtin.set_fact:
Expand All @@ -16,8 +16,7 @@
ansible.builtin.set_fact:
selinux_virtualenv_dir: "{{ wapy_system_venv_root_dir }}/{{ wapy_system_venv_prefix }}-{{
wapy_selinux_python_minor }}"
selinux_virtualenv_command: "/usr/bin/virtualenv{{
(wapy_platform == 'Fedora') | ternary('', '-' + wapy_selinux_python_minor) }}"
selinux_virtualenv_command: "/usr/bin/virtualenv"
selinux_virtualenv_python: "/usr/bin/python{{ wapy_selinux_python_minor }}"
when: selinux_python_release is not defined

Expand All @@ -39,27 +38,15 @@
become: true
when: (wapy_has_ansible or wapy_has_mercurial or wapy_has_sphinx) and selinux_python_release is not defined

- name: Install Ansible and Molecule in a virtualenv (EL 7)
- name: Install Ansible and Molecule in a virtualenv
ansible.builtin.pip:
name: "{{ wapy_ansible_packages }}"
virtualenv: "{{ selinux_virtualenv_dir }}/{{ wapy_ansible_venv }}"
virtualenv_command: "{{ selinux_virtualenv_command }}"
virtualenv_python: "{{ selinux_virtualenv_python }}"
environment:
LC_ALL: "en_US.UTF-8"
become: true
become_user: "{{ wapy_user }}"
when: wapy_has_ansible and wapy_platform == 'EL7'

- name: Install Ansible and Molecule in a virtualenv (EL 8, Fedora)
ansible.builtin.pip:
name: "{{ wapy_ansible_packages }}"
virtualenv: "{{ selinux_virtualenv_dir }}/{{ wapy_ansible_venv }}"
virtualenv_command: "{{ selinux_virtualenv_command }}"
virtualenv_python: "{{ selinux_virtualenv_python }}"
become: true
become_user: "{{ wapy_user }}"
when: wapy_has_ansible and wapy_platform != 'EL7'
when: wapy_has_ansible

- name: Install Mercurial in a virtualenv
ansible.builtin.pip:
Expand Down
20 changes: 10 additions & 10 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
minversion=3.24
envlist =
rockylinux9
rockylinux8
centos-stream10
centos-stream9
#fedora41
# rockylinux8
fedora41
fedora40
fedora39
centos-stream10
centos-stream9
ubuntu2404
ubuntu2204
ubuntu2004
Expand All @@ -16,16 +16,16 @@ skipsdist=true

[testenv]
deps =
ansible<2.17
ansible
ansible-compat
ansible-lint
molecule
molecule-plugins[docker]
pytest
pytest-testinfra
rich
selinux<0.3.0
yamllint
pytest
pytest-testinfra
rich
selinux
yamllint

commands = molecule {posargs}

Expand Down
Loading

0 comments on commit c81f4e7

Please sign in to comment.