Feat: Add v3.10.x and re-factor code 03/70503/10
authorAnil Belur <abelur@linuxfoundation.org>
Mon, 22 Aug 2022 07:38:36 +0000 (17:38 +1000)
committerAnil Belur <abelur@linuxfoundation.org>
Sun, 28 Aug 2022 21:26:08 +0000 (07:26 +1000)
- Add new version 3.10.x support.
- Bump 3.8.x, 3.9.x to the latest update.
- Bump the pyenv version to v2.3.3.
- Remove deprecated versions of python:
  (3.4.10, 3.5.10, 3.6.13, 3.7.10)
- Refactor the python-install role to address 'line too
   long' error while building the pyenv command.
- Install compact-openssl10 dependencies for python 3.10
  ERROR: The Python ssl extension was not compiled. Missing the
  OpenSSL lib?
  The compat-openssl libs are available only for CentOS8, so python
  3.10x will be available for >= CentOS8.
- Include libssl-dev required for building Ubuntu {18,20}.04

Issue-ID: RELENG-4357
Ref: https://github.com/pyenv/pyenv/issues/950
Change-Id: I3fe4fed872a43bf21a07fefc6c161b143f306ca2
Signed-off-by: Anil Belur <abelur@linuxfoundation.org>
defaults/main.yml
molecule/default/molecule.yml
tasks/main.yml
vars/Debian.yml
vars/Ubuntu-20.yml

index 3ab76ca..fc2ec30 100644 (file)
@@ -1,10 +1,9 @@
 ---
-pyenv_version: v1.2.23
-python34_version: 3.4.10
-python35_version: 3.5.10
-python36_version: 3.6.13
-python37_version: 3.7.10
-python38_version: 3.8.7
-python39_version: 3.9.1
+pyenv_version: v2.3.3
+python39_version: 3.9.13
+python38_version: 3.8.13
+python310_version: 3.10.6
 
-pyenv_command: 'pyenv global system {{python38_version}} {{python37_version}} {{python36_version}} {{python35_version}} {{python34_version}}'
+python_versions:
+  - '{{ python39_version }}'
+  - '{{ python38_version }}'
index a129c9d..7d381a9 100644 (file)
@@ -4,7 +4,6 @@ dependency:
 driver:
   name: docker
 lint: |
-  set -e
   yamllint .
   ansible-lint tasks/*.yml
 platforms:
index b0a9450..6b936d3 100644 (file)
     state: present
   become: true
 
-- name: Check pyenv global command
+- name: Pre-set python versions required for pyenv global command
   block:
-    - name: On Ubuntu >= 18.04
+    - name: "Set Python version on Ubuntu >= 18.04 or CentOS 7"
       set_fact:
-        pyenv_command: 'pyenv global system {{ python39_version }} {{ python38_version }} {{ python37_version }} {{ python36_version }} {{ python35_version }}'
-      when: ansible_distribution_version >= '18.04'
-    - name: On CentOS >= 8
+        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_command: 'pyenv global {{ python39_version }} {{ python38_version }} {{ python37_version }} {{ python36_version }} {{ python35_version }}'
+        pyenv_cmd: "{{ (python_versions | join(' ')) ~ ' ' ~ python310_version }}"
+      when:
+        - (ansible_distribution == 'Ubuntu' and ansible_distribution_version >= '18.04') or
+          (ansible_distribution == 'CentOS' and ansible_distribution_major_version >= '8')
+
+# Ref: https://github.com/pyenv/pyenv/issues/950
+# ERROR: The Python ssl extension was not compiled. Missing the OpenSSL lib?
+# 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
+  block:
+    - name: Update SSL dependencies for CentOS
+      command: "dnf install compat-openssl10* -y"
       when: ansible_distribution == 'CentOS' and ansible_distribution_major_version >= '8'
+  become: true
 
-- name: Install Python via pyenv
+- name: Install Python 3.x versions via pyenv
   environment:
     PYENV_ROOT: /opt/pyenv
     PATH: '/opt/pyenv/bin:{{ ansible_env.PATH }}'
-    PYTHON34_VERSION: '{{ python34_version }}'
-    PYTHON35_VERSION: '{{ python35_version }}'
-    PYTHON36_VERSION: '{{ python36_version }}'
-    PYTHON37_VERSION: '{{ python37_version }}'
     PYTHON38_VERSION: '{{ python38_version }}'
     PYTHON39_VERSION: '{{ python39_version }}'
+    PYTHON310_VERSION: '{{ python310_version }}'
   block:
     - name: 'Install pyenv {{ pyenv_version }}'
       git:
         repo: https://github.com/pyenv/pyenv.git
         dest: /opt/pyenv
         version: '{{ pyenv_version }}'
-    - name: 'Install Python {{ python34_version }}'
-      command: pyenv install -s "$PYTHON34_VERSION"
-      when: ansible_distribution_version < '18.04'
-    - name: 'Install Python {{ python35_version }}'
-      command: pyenv install -s "$PYTHON35_VERSION"
-    - name: 'Install Python {{ python36_version }}'
-      command: pyenv install -s "$PYTHON36_VERSION"
-    - name: 'Install Python {{ python37_version }}'
-      command: pyenv install -s "$PYTHON37_VERSION"
-    - name: 'Install Python {{ python38_version }}'
-      command: pyenv install -s "$PYTHON38_VERSION"
-    - name: 'Install Python {{ python39_version }}'
-      command: pyenv install -s "$PYTHON39_VERSION"
-    - name: Set pyenv global
-      command: '{{ pyenv_command }}'
+    - name: 'Install Python {{ pyenv_cmd }}'
+      command: 'pyenv install -s {{ item }}'
+      loop: '{{ python_versions }}'
+    - name: 'Install Python {{ python310_version }}'
+      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 }}'
+      when: ansible_distribution == 'Ubuntu'
+    - name: 'Set the required python 3.x versions using pyenv on CentOS'
+      command: 'pyenv global {{ pyenv_cmd }}'
+      when: ansible_distribution == 'CentOS'
   become: true
index 01c4026..5465ff6 100644 (file)
@@ -1,6 +1,7 @@
 ---
 python_packages_distro:
   - libffi-dev
+  - libssl-dev
   - python
   - python-dev
   - python-openssl
index 47f13a8..cb4d2b5 100644 (file)
@@ -1,6 +1,7 @@
 ---
 python_packages_distro:
   - libffi-dev
+  - libssl-dev
   - python-is-python3
   - python3
   - python3