From 8da7fcb76a2250948d68e6f3b3b1c68e072102a8 Mon Sep 17 00:00:00 2001 From: Miguel Caballer Date: Mon, 1 Mar 2021 12:34:48 +0100 Subject: [PATCH] Deprecate centos 6 and improve recipes --- contextualization/basic.yml | 2 +- contextualization/conf-ansible.yml | 63 ++++++++++-------------------- 2 files changed, 21 insertions(+), 44 deletions(-) diff --git a/contextualization/basic.yml b/contextualization/basic.yml index 0f4c60567..09a723b0b 100644 --- a/contextualization/basic.yml +++ b/contextualization/basic.yml @@ -27,7 +27,7 @@ ignore_errors: yes - name: Bootstrap with python RedHat/CentOS - raw: sudo yum install -y python3 || { sudo yum install -y epel-release https://repo.ius.io/ius-release-el6.rpm && sudo yum install -y python36 && ln -s /usr/bin/python3.6 /usr/bin/python3; } + raw: sudo yum install -y python3 ignore_errors: yes register: python_install changed_when: python_install.stdout_lines|length > 1 diff --git a/contextualization/conf-ansible.yml b/contextualization/conf-ansible.yml index ec8b67d67..06d5e2453 100644 --- a/contextualization/conf-ansible.yml +++ b/contextualization/conf-ansible.yml @@ -31,7 +31,7 @@ ignore_errors: yes - name: Bootstrap with python RedHat/CentOS - raw: sudo yum install -y python3 || { sudo yum install -y epel-release https://repo.ius.io/ius-release-el6.rpm && sudo yum install -y python36 && ln -s /usr/bin/python3.6 /usr/bin/python3; } + raw: sudo yum install -y python3 ignore_errors: yes register: python_install changed_when: python_install.stdout_lines|length > 1 @@ -96,7 +96,7 @@ command: apt install -y --no-install-recommends gcc python3-apt python3.5-dev libffi-dev libssl-dev python3-pip wget python3-setuptools sshpass openssh-client unzip - name: Ubuntu 14 install pip3.5 - command: python3.5 /usr/lib/python3/dist-packages/easy_install.py "pip>=9.0.3" creates=/usr/local/bin/pip3.5 + command: python3.5 /usr/lib/python3/dist-packages/easy_install.py "pip>=18.0,<21.0" creates=/usr/local/bin/pip3.5 - name: Remove old pip3 in Ubuntu 14 file: path=/usr/bin/pip3 state=absent @@ -113,15 +113,7 @@ - name: Yum install requisites RH 7/8 or Fedora command: yum install -y python3-pip python3-setuptools sshpass openssh-clients - when: (ansible_os_family == "RedHat" and ansible_distribution_major_version|int > 6) - - - name: Yum install requisites RH 6 - command: yum install -y python36-pip python36-setuptools sshpass openssh-clients gcc libffi-devel openssl-devel python36-devel - when: ansible_os_family == "RedHat" and ansible_distribution_major_version|int <= 6 - - - name: Link pip3 in RH 6 - command: ln -s /usr/bin/pip3.6 /usr/bin/pip3 creates=/usr/bin/pip3 - when: ansible_os_family == "RedHat" and ansible_distribution_major_version|int <= 6 + when: ansible_os_family == "RedHat" - name: Zypper install requirements Suse zypper: name=python3-pip,python3-setuptools,gcc,python3-devel,wget,libffi-devel,openssl-devel,python3-cryptography,make state=present @@ -152,19 +144,31 @@ ######################################### Use pip to enable to set the version ############################################# - # Version over 21 raises error in older S.O. as ubuntu 16 - - name: Upgrade pip + # Version over 21 does not work with python 3.5 or older + - name: Upgrade pip in py3.5 pip: name: pip>18.0,<21.0 executable: pip3 + when: ansible_python_version is version('3.6', '<') + + - name: Upgrade pip in py3.6 + + pip: + name: pip>18.0 + executable: pip3 + when: ansible_python_version is version('3.6', '>=') - name: Upgrade setuptools with Pip pip: name=setuptools state=latest executable=pip3 - when: ansible_os_family != "RedHat" or ansible_distribution_major_version|int > 6 + + - name: Install cryptography + pip: + name: cryptography<3.3 + executable: pip3 - name: Install pyOpenSSL - pip: name=pyOpenSSL state=latest executable=pip3 - when: ansible_os_family != "RedHat" or ansible_distribution_major_version|int > 6 + pip: + name: pyOpenSSL>20.0 + executable: pip3 - name: Ubuntu 14 extra pip packages needed to avoid https issues pip: name=urllib3,ndg-httpsclient,pyasn1 executable=pip3 @@ -174,19 +178,6 @@ pip: name=cryptography version=2.9.2 executable=pip3 when: ansible_distribution == "Ubuntu" and ansible_distribution_major_version|int <= 14 - - name: Install pkgs with Pip in RH6 - pip: name="{{ item.name }}" version="{{ item.version }}" executable=pip3 - when: ansible_os_family == "RedHat" and ansible_distribution_major_version|int <= 6 - with_items: - - { name: 'setuptools', version: '28.8.1' } - - { name: 'pyyaml', version: '3.13' } - - { name: 'idna', version: '2.7' } - - { name: 'argparse', version: '1.4.0' } - - { name: 'paramiko', version: '2.2.4' } - - { name: 'xmltodict', version: '0.11.0' } - - { name: 'cryptography', version: '2.1.0' } - - { name: 'pyOpenSSL', version: '17.0.0' } - - name: Install pyyaml pip: name=pyyaml executable=pip3 @@ -203,10 +194,6 @@ - name: Install jmespath with Pip pip: name=jmespath executable=pip3 - - name: Install cffi with Pip in RH6 - pip: name=cffi executable=pip3 - when: ansible_os_family == "RedHat" and ansible_distribution_major_version|int <= 6 - - name: Install scp with Pip pip: name=scp executable=pip3 @@ -240,16 +227,6 @@ - name: Set transport to ssh in ansible.cfg ini_file: dest=/etc/ansible/ansible.cfg section=defaults option=transport value=ssh - when: ansible_os_family == "Debian" or (ansible_os_family == "RedHat" and ansible_distribution_major_version|int >= 6) or (ansible_os_family == "Suse" and ansible_distribution_major_version|int >= 10) - - - name: Set transport to smart in ansible.cfg - ini_file: dest=/etc/ansible/ansible.cfg section=defaults option=transport value=smart - when: (ansible_os_family == "RedHat" and ansible_distribution_major_version|int < 6) or (ansible_os_family == "Suse" and ansible_distribution_major_version|int < 10) - name: Change ssh_args to set ControlPersist to 15 min in ansible.cfg ini_file: dest=/etc/ansible/ansible.cfg section=ssh_connection option=ssh_args value="-o ControlMaster=auto -o ControlPersist=900s -o UserKnownHostsFile=/dev/null" - when: ansible_os_family == "Debian" or (ansible_os_family == "RedHat" and ansible_distribution_major_version|int >= 7) or (ansible_os_family == "Suse" and ansible_distribution_major_version|int >= 12) - - - name: Change ssh_args to remove ControlPersist in REL 6 and older in ansible.cfg - ini_file: dest=/etc/ansible/ansible.cfg section=ssh_connection option=ssh_args value="-o UserKnownHostsFile=/dev/null" - when: (ansible_os_family == "RedHat" and ansible_distribution_major_version|int < 7) or (ansible_os_family == "Suse" and ansible_distribution_major_version|int < 12)