--- - name: "Check for {{ item.binary }} binary" ansible.builtin.command: "which {{ item.binary }}" changed_when: false failed_when: python_installed.rc not in [ 0, 1 ] register: python_installed - name: "Check for {{ item.binary }} download" ansible.builtin.stat: path: "{{ python_build_dir }}/python-{{ item.version }}.tgz" register: python_download - when: python_installed.rc not in [ 0 ] block: # TODO: verify for checksum - name: "Retrieve python {{ item.version }} source" become: true ansible.builtin.get_url: url: "{{ python_download_url }}/{{ item.version }}/Python-{{ item.version }}.tgz" dest: "{{ python_build_dir }}/python-{{ item.version }}.tgz" owner: "{{ ansible_user_id }}" group: "{{ ansible_user_id }}" when: not python_download.stat.exists - name: "Extract python {{ item.version }} sources" become: true ansible.builtin.unarchive: src: "{{ python_build_dir }}/python-{{ item.version }}.tgz" dest: "{{ python_build_dir }}" include: "Python-{{ item.version }}" - name: Rename source directory become: true ansible.builtin.command: "mv {{ python_build_dir}}/Python-{{ item.version }} {{ python_build_dir }}/{{ item.path }}" - name: Set correct permissions become: true ansible.builtin.file: path: "{{ python_build_dir }}/{{ item.path }}" recurse: true owner: "{{ ansible_user_id }}" group: "{{ ansible_user_id }}" state: directory - name: Configure build ansible.builtin.command: "sh ./configure --prefix={{ python_install_dir }}/{{ item.path }}" args: chdir: "{{ python_build_dir }}/{{ item.path }}/" - name: Make build ansible.builtin.command: "make" args: chdir: "{{ python_build_dir }}/{{ item.path }}/" - name: Install build become: true ansible.builtin.command: "make install" args: chdir: "{{ python_build_dir }}/{{ item.path }}/" - name: "Create symlink for python {{ item.version }}" become: true ansible.builtin.file: src: "{{ python_install_dir }}/{{ item.path }}/bin/{{ item.binary }}" dest: "/usr/bin/{{ item.binary }}" state: link