- 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', 'python3-pip', 'python-setuptools', 'python3-setuptools', 'python-gdbm', 'python-openssl', 'python3-openssl', ] state: latest update_cache: yes 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 "wheel < 0.31.1" flake8 sphinx twine' when: python.changed loop: ['python3', 'python2']