- name: Install Python and packages (Debian) become: true apt: autoclean: yes autoremove: yes cache_valid_time: 3600 install_recommends: no name: ['patchelf', # for auditwheel 'python', 'python2.7', 'python3', "{{ python_pip_pkg }}", 'python3-pip', 'python-setuptools', 'python3-setuptools', 'python-gdbm', "{{ python_openssl_pkg }}", 'python3-openssl', 'python-is-python2', ] state: latest update_cache: yes vars: - python_pip_pkg: "python-pip{% if ansible_facts.distribution_major_version in ['9', '10'] %}{% elif ansible_facts.distribution_major_version == '11' %}-whl{% endif %}" - python_openssl_pkg: "{% if ansible_facts.distribution_major_version in ['9', '10'] %}python-openssl{% elif ansible_facts.distribution_major_version == '11' %}python3-openssl{% endif %}" register: python when: ansible_facts.os_family == 'Debian' - name: Install Python and packages (RedHat) become: true dnf: name: ['python2', 'python3', 'python2-pip', 'python3-pip', 'python2-setuptools', 'python3-setuptools', 'python2-pyOpenSSL', 'python3-pyOpenSSL', ] state: latest update_cache: yes register: python when: ansible_facts.os_family == 'RedHat' - name: Upgrade Python packages become: true shell: 'umask 022; exec {{ item }} -m pip install --compile --upgrade "pip<19.1" setuptools tox virtualenv virtualenvwrapper flake8 sphinx twine' when: python.changed loop: ['python3', 'python2'] - name: Install wheel for Python2 become: true shell: 'umask 022; exec python2 -m pip install --compile --upgrade "wheel==0.31.1"' when: python.changed - name: Install wheel and auditwheel for Python3 become: true shell: 'umask 022; exec python3 -m pip install --compile --upgrade "wheel==0.34.1" "auditwheel==3.1.0"' when: python.changed