- name: Depoly jwebmail hosts: myhosts vars: wheels: "{{ lookup('ansible.builtin.fileglob', 'dist/*.whl', wantlist=True)|map('basename') }}" latest_version: "{{ wheels|map('split', '-')|map(attribute=1)|community.general.version_sort|last }}" tasks: - name: Info ansible.builtin.debug: var: latest_version - name: Copy ansible.builtin.copy: src: "dist/jwebmail-{{ latest_version }}-py3-none-any.whl" dest: "jwebmail-{{ latest_version }}-py3-none-any.whl" register: new_version - name: Update ansible.builtin.pip: name: - "file:///home/{{ ansible_facts.user_id }}/jwebmail-{{ latest_version }}-py3-none-any.whl" virtualenv: "/usr/local/jwebmail" become: true - name: Extract ansible.builtin.copy: src: "script/extract-release" dest: "/usr/local/bin/jwebmail-extract" mode: "0755" become: true - name: Restart ansible.builtin.systemd_service: name: jwebmail state: restarted become: true when: new_version is changed