From a86f063e5ce8b6a1743dc7907fa293c292ad9c25 Mon Sep 17 00:00:00 2001 From: Anil Belur Date: Sun, 18 Feb 2024 16:47:05 +1000 Subject: [PATCH] Fix: Install python 3.10.x on CentOS 7 Python 3.10.x is a pre-requiste for the ansible version 9.2.0 used fro the packer jobs. However the version of python 3.10.x requires openssl11 libs and headers to be installed so that pyenv install builds the required runtime dependencies. ERROR: "ModuleNotFoundErrorr No module named '_ssl'" "The Python ssl extension was not compiled. Missing the OpenSSL lib?" Ref: https://github.com/pyenv/pyenv/wiki/Common-build-problems Change-Id: Ib1c51882f057b7cf2c3a3c9307d524c9cf45b3a2 Signed-off-by: Anil Belur --- tasks/main.yml | 16 +++++++++++++++- vars/RedHat.yml | 2 ++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/tasks/main.yml b/tasks/main.yml index 5db66c9..ca7b6cf 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -39,6 +39,15 @@ ansible.builtin.command: "dnf install compat-openssl10* -y" when: ansible_distribution == 'CentOS' and ansible_distribution_major_version >= '8' + - name: Install SSL dependencies required pyenv for python 3.10.x for CentOS 7 # noqa no-changed-when + when: ansible_distribution == 'CentOS' and ansible_distribution_major_version == '7' + ansible.builtin.yum: + name: + - openssl11 + - openssl11-devel + update_cache: yes + state: present + - name: Install Python 3.x versions via pyenv become: true environment: @@ -57,11 +66,16 @@ - name: 'Install Python {{ pyenv_cmd }}' # noqa no-changed-when ansible.builtin.command: 'pyenv install -s {{ item }}' loop: '{{ python_versions }}' + - name: 'Install Python on CentOS 7 {{ python310_version }}' # noqa no-changed-when + ansible.builtin.shell: | + CPPFLAGS=$(pkg-config --cflags openssl11) LDFLAGS=$(pkg-config --libs openssl11) pyenv install -s {{ python310_version }} + when: + - ansible_distribution == 'CentOS' and ansible_distribution_major_version == '7' - 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') + (ansible_distribution == 'CentOS' and ansible_distribution_major_version >= '7') - name: 'Install Python {{ python311_version }}' # noqa no-changed-when ansible.builtin.command: pyenv install -s {{ python311_version }} when: diff --git a/vars/RedHat.yml b/vars/RedHat.yml index 56e04c8..b3c8a33 100644 --- a/vars/RedHat.yml +++ b/vars/RedHat.yml @@ -11,3 +11,5 @@ python_packages_distro: - python36-pip - python36-setuptools - python36-virtualenv + - openssl11 + - openssl11-devel -- 2.16.6