Skip to content

Commit

Permalink
Python 3.11 use on RedHat 8 and above (#573)
Browse files Browse the repository at this point in the history
  • Loading branch information
weisscorp authored Feb 8, 2024
1 parent e41ac9f commit 06efec5
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 21 deletions.
44 changes: 37 additions & 7 deletions roles/packages/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,37 @@
- ansible_distribution_major_version >= '8'
tags: install_packages

- name: Set Python alternative
community.general.alternatives:
name: python3
path: /usr/bin/python{{ python_version }}
link: /usr/bin/python3
priority: 1100
state: selected
when:
- installation_method == "repo"
- ansible_os_family == "RedHat"
- ansible_distribution_major_version >= '8'
- python_version | default('') | length > 1
tags: install_packages

- name: Set Pip alternative
community.general.alternatives:
name: pip3
path: /usr/bin/pip{{ python_version }}
link: /usr/bin/pip3
priority: 1100
state: selected
when:
- installation_method == "repo"
- ansible_os_family == "RedHat"
- ansible_distribution_major_version >= '8'
- python_version | default('') | length > 1
- pip_package in system_packages
vars:
pip_package: "python{{ python_version | default('3') }}-pip"
tags: install_packages

# Debian
- name: Install system packages
ansible.builtin.apt:
Expand Down Expand Up @@ -177,13 +208,12 @@
state: present
loop: "{{ timescaledb_package }}"
vars:
timescaledb_package:
- >
{% if postgresql_version | int >= 11 %}
timescaledb-2-postgresql-{{ postgresql_version }}
{% else %}
timescaledb-postgresql-{{ postgresql_version }}
{% endif %}
timescaledb_package: >-
[{% if postgresql_version | int >= 11 %}
"timescaledb-2-postgresql-{{ postgresql_version }}"
{% else %}
"timescaledb-postgresql-{{ postgresql_version }}"
{% endif %}]
register: package_status
until: package_status is success
delay: 5
Expand Down
4 changes: 3 additions & 1 deletion roles/patroni/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
- ansible.builtin.import_tasks: pip.yml
when:
- patroni_installation_method == "pip"
- system_packages is not search("python3-pip")
- pip_package not in system_packages
vars:
pip_package: "python{{ python_version | default('3') }}-pip"
tags: patroni, patroni_install, pip

# Patroni install
Expand Down
13 changes: 6 additions & 7 deletions roles/upgrade/tasks/packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,12 @@
state: latest
loop: "{{ timescaledb_package }}"
vars:
timescaledb_package:
- >
{% if pg_new_version | int >= 11 %}
timescaledb-2-postgresql-{{ pg_new_version }}
{% else %}
timescaledb-postgresql-{{ pg_new_version }}
{% endif %}
timescaledb_package: >-
[{% if pg_new_version | int >= 11 %}
"timescaledb-2-postgresql-{{ pg_new_version }}"
{% else %}
"timescaledb-postgresql-{{ pg_new_version }}"
{% endif %}]
register: package_status
until: package_status is success
delay: 5
Expand Down
14 changes: 8 additions & 6 deletions vars/RedHat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ install_postgresql_repo: true # or 'false' (installed from the package "pgdg-re
install_scl_repo: true # or 'false' (Redhat 7 family only)

# Packages (for yum repo)
python_version: "3.11"

os_specific_packages:
RedHat-7:
- python
Expand All @@ -52,12 +54,12 @@ os_specific_packages:
- dnf-utils
system_packages:
- "{{ os_specific_packages[ansible_os_family ~ '-' ~ ansible_distribution_major_version] }}"
- python3
- python3-devel
- python3-psycopg2
- python3-setuptools
- python3-pip
- python3-urllib3
- python{{ python_version }}
- python{{ python_version }}-devel
- python{{ python_version }}-psycopg2
- python{{ python_version }}-setuptools
- python{{ python_version }}-pip
- python{{ python_version }}-urllib3
- less
- sudo
- vim
Expand Down

0 comments on commit 06efec5

Please sign in to comment.