--- - name: Check if distutils is installed for Debian based systems become: true ansible.builtin.apt: name: - python3-apt - python3-distutils state: present when: ansible_facts.os_family == 'Debian' - name: Check if poetry is installed ansible.builtin.stat: path: "{{ xdg_data_home }}/poetry" register: poetry_installed changed_when: false - name: Create poetry working directory ansible.builtin.tempfile: state: directory register: poetry_work_dir when: not poetry_installed.stat.exists - name: Set poetry installer destination ansible.builtin.set_fact: poetry_install_dest: "{{ poetry_work_dir.path }}/poetry-install.py" when: not poetry_installed.stat.exists - name: Download poetry installer ansible.builtin.get_url: url: https://install.python-poetry.org/ dest: "{{ poetry_install_dest }}" mode: "0644" when: not poetry_installed.stat.exists - name: Install Poetry ansible.builtin.shell: > python3 "{{ poetry_install_dest }}" -f -y environment: POETRY_HOME: "{{ xdg_data_home }}/poetry" register: poetry_installer when: not poetry_installed.stat.exists changed_when: not 'already installed' in poetry_installer.stdout