summaryrefslogtreecommitdiff
path: root/roles/etherpad/tasks/main.yml
blob: 9575ce9dd2ca6fec65d5ba44bf253d1ba4faffb2 (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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
- name: Install PNPM and Git
  community.general.apk:
    name:
      - pnpm
      - git

- name: Install tsx globally
  ansible.builtin.shell: pnpm install --global tsx
  register: pnpm_install_tsx
  changed_when: "'Already up to date' not in pnpm_install_tsx.stdout"
  environment:
    PNPM_HOME: "{{ ansible_facts.env.HOME }}/.local/share/pnpm"
    PATH: "{{ ansible_facts.env.PATH }}:{{ ansible_facts.env.HOME }}/.local/share/pnpm"

- name: Checkout source code for latest etherpad release
  register: etherpad_src
  ansible.builtin.git:
    repo: https://github.com/ether/etherpad.git
    dest: "{{ src_dir }}/etherpad"
    depth: 1
    version: master

- name: Install etherpad settings
  register: etherpad_settings
  ansible.builtin.template:
    src: settings.json
    dest: "{{ src_dir }}/etherpad/settings.json"
    mode: "640"

- name: Install etherpad dependencies
  register: etherpad_dependencies
  changed_when: "'Already up to date' not in etherpad_dependencies.stdout"
  ansible.builtin.command:
    chdir: "{{ src_dir }}/etherpad"
    cmd: pnpm install

- name: Install etherpad service
  register: etherpad_service
  ansible.builtin.template:
    src: openrc/etherpad
    dest: /etc/init.d/etherpad
    mode: "755"

- name: Restart etherpad service and configure to start on boot
  when:
    etherpad_src is changed
      or etherpad_service is changed
      or etherpad_settings is changed
      or etherpad_dependencies is changed
  ansible.builtin.service:
    name: etherpad
    enabled: true
    state: restarted

- name: Start etherpad service and configure to start on boot
  when:
    not (
      etherpad_src is changed
        or etherpad_settings is changed
        or etherpad_service is changed
        or etherpad_dependencies is changed )
  ansible.builtin.service:
    name: etherpad
    enabled: true
    state: started

- name: Install script to update etherpad
  ansible.builtin.template:
    src: update_etherpad
    dest: /usr/bin/update_etherpad
    mode: "755"

- name: Install daily crontab to update etherpad
  ansible.builtin.cron:
    special_time: daily
    name: Update etherpad
    job: /usr/bin/update_etherpad