hosts: all
gather_facts: true
tasks:
- - rpm_key:
+ - ansible.builtin.rpm_key:
state: present
key: https://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-8
when: ansible_os_family == 'RedHat'
become: true
- name: Install Fedora EPEL repo
- yum:
+ ansible.builtin.yum:
name: https://dl.fedoraproject.org/pub/epel/epel-release-latest-{{ ansible_distribution_major_version }}.noarch.rpm
state: present
when: ansible_os_family == 'RedHat'
become: true
- name: Update APT cache
- apt:
+ ansible.builtin.package:
update_cache: yes
when: ansible_distribution == 'Ubuntu'
become: true
- name: Install Git
- package: name=git state=present
+ ansible.builtin.package: name=git state=present
- name: Install Python compile dependencies
- yum:
+ ansible.builtin.yum:
name:
- bzip2-devel
- gcc
become: true
- name: Install Python compile dependencies
- apt:
+ ansible.builtin.package:
name:
- libbz2-dev
- gcc
---
- name: Include distro specific variables
- include_vars: "{{ item }}"
+ ansible.builtin.include_vars: "{{ item }}"
with_first_found:
- '{{ ansible_distribution }}-{{ ansible_distribution_major_version }}.yml'
- '{{ ansible_distribution }}.yml'
- '{{ ansible_os_family }}.yml'
- name: Install Python
- package:
+ ansible.builtin.package:
name: '{{ python_packages }}'
state: present
become: true
- name: Pre-set python versions required for pyenv global command
block:
- name: "Set Python version on Ubuntu >= 18.04 or CentOS 7"
- set_fact:
+ ansible.builtin.set_fact:
pyenv_cmd: "{{ python_versions | join(' ') }}"
when:
- (ansible_distribution == 'Ubuntu' and ansible_distribution_version >= '18.04') or
(ansible_distribution == 'CentOS')
- name: "Set Python 3.10 on CentOS >= 8 or on Ubuntu >= 18/04"
- set_fact:
- pyenv_cmd: "{{ (python_versions | join(' ')) ~ ' ' ~ python310_version }}"
+ ansible.builtin.set_fact:
+ pyenv_cmd: "{{ (python_versions | join(' ')) ~ ' ' ~ python310_version ~ ' ' ~ python311_version }}"
when:
- (ansible_distribution == 'Ubuntu' and ansible_distribution_version >= '18.04') or
(ansible_distribution == 'CentOS' and ansible_distribution_major_version >= '8')
# The compat-openssl libs are available only for CentOS8, so python 3.10x will
# be available for >= CentOS8
- name: Install SSL dependencies required pyenv for python 3.10.x
+ become: true
block:
- - name: Update SSL dependencies for CentOS
- command: "dnf install compat-openssl10* -y"
+ - name: Update SSL dependencies for CentOS # noqa no-changed-when
+ ansible.builtin.command: "dnf install compat-openssl10* -y"
when: ansible_distribution == 'CentOS' and ansible_distribution_major_version >= '8'
- become: true
- name: Install Python 3.x versions via pyenv
+ become: true
environment:
PYENV_ROOT: /opt/pyenv
PATH: '/opt/pyenv/bin:{{ ansible_env.PATH }}'
PYTHON38_VERSION: '{{ python38_version }}'
PYTHON39_VERSION: '{{ python39_version }}'
PYTHON310_VERSION: '{{ python310_version }}'
+ PYTHON311_VERSION: '{{ python311_version }}'
block:
- name: 'Install pyenv {{ pyenv_version }}'
- git:
+ ansible.builtin.git:
repo: https://github.com/pyenv/pyenv.git
dest: /opt/pyenv
version: '{{ pyenv_version }}'
- - name: 'Install Python {{ pyenv_cmd }}'
- command: 'pyenv install -s {{ item }}'
+ - name: 'Install Python {{ pyenv_cmd }}' # noqa no-changed-when
+ ansible.builtin.command: 'pyenv install -s {{ item }}'
loop: '{{ python_versions }}'
- - name: 'Install Python {{ python310_version }}'
- command: 'pyenv install -s {{ python310_version }}'
+ - name: 'Install Python {{ python310_version }}' # noqa no-changed-when
+ ansible.builtin.command: pyenv install -s {{ python310_version }}
when:
- (ansible_distribution == 'Ubuntu' and ansible_distribution_version >= '18.04') or
(ansible_distribution == 'CentOS' and ansible_distribution_major_version >= '8')
- - name: 'Set the required python 3.x versions using pyenv on Ubuntu'
- command: 'pyenv global system {{ pyenv_cmd }}'
+ - name: 'Install Python {{ python311_version }}' # noqa no-changed-when
+ ansible.builtin.command: pyenv install -s {{ python311_version }}
+ when:
+ - (ansible_distribution == 'Ubuntu' and ansible_distribution_version >= '18.04') or
+ (ansible_distribution == 'CentOS' and ansible_distribution_major_version >= '8')
+ - name: 'Set the required python 3.x versions using pyenv on Ubuntu' # noqa no-changed-when
+ ansible.builtin.command: 'pyenv global system {{ pyenv_cmd }}'
when: ansible_distribution == 'Ubuntu'
- - name: 'Set the required python 3.x versions using pyenv on CentOS'
- command: 'pyenv global {{ pyenv_cmd }}'
+ - name: 'Set the required python 3.x versions using pyenv on CentOS' # noqa no-changed-when
+ ansible.builtin.command: 'pyenv global {{ pyenv_cmd }}'
when: ansible_distribution == 'CentOS'
- become: true