summaryrefslogtreecommitdiff
path: root/depoly.yml
blob: 369ba6d8d63764102c854c8819968ec4725bbcb8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
- 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"
          - "toml"
        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