summaryrefslogtreecommitdiffstats
path: root/roles/pad/tasks/main.yml
blob: b720b40b35680fce239782de521e752c4f9cc374 (plain) (blame)
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
---
# tasks file for pad
- name: Set up packages as root
  block:
  - name: Add GPG
    apt:
      update_cache: yes
      name:
        - gpg
        - sudo
  - name: Add nodesource key
    apt_key:
      id: 2F59B5F99B1BE0B4
      keyserver: keyserver.ubuntu.com
      state: present
  - name: Add nodesource repository
    ansible.builtin.apt_repository:
      repo: deb https://deb.nodesource.com/node_20.x nodistro main
      update_cache: yes
  - name: Install packages
    apt:
      update_cache: yes
      name:
        - git
        - systemd
        - sudo
        - nodejs
        - mariadb-server
        - mariadb-client
      state: present
  - name: Create etherpad user
    user:
      name: etherpad
      home: /home/etherpad
      shell: /bin/bash
      state: present
- import_tasks: mariadb.yml
  become: true
- name: Set up etherpad as the etherpad user
  tags: etherpad-src
  become: true
  become_user: "{{ etherpad_user }}"
  block:
  - name: Install etherpad
    git:
      repo: https://github.com/ether/etherpad-lite.git
      dest: "{{ etherpad_path }}"
      version: v1.9.7
      depth: 1
  - name: Configure etherpad
    template:
      src: templates/settings.json
      dest: "{{ etherpad_path }}/settings.json"
  - name: Install dependencies
    shell: cd {{ etherpad_path }}; . src/bin/functions.sh; src/bin/installDeps.sh
  # - name: Install etherpad plugins
  #   npm:
  #     name: ep_scrolltoanchor
  #     path: "{{ etherpad_path }}"
  - name: Change ownership
    file:
      dest: /home/etherpad/etherpad
      owner: "{{ etherpad_user }}"
      group: "{{ etherpad_group }}"
      recurse: true
  - name: Set etherpad API key
    copy:
      content: "{{ etherpad_api_key }}"
      dest: "{{ etherpad_path }}/APIKEY.txt"
      owner: "{{ etherpad_user }}"
      mode: "0600"
- name: Install init.d configuration
  tags: system
  become: true
  template:
    src: etherpad.init.d
    dest: /etc/init.d/etherpad
    owner: root
    group: root
    mode: 0755
  when: use_initd
- name: Install systemd configuration
  tags: system
  become: true
  template:
    src: etherpad.service
    dest: /etc/systemd/system/etherpad.service
    owner: root
    group: root
    mode: 0755
  when: not use_initd
- name: Restart Etherpad
  become: true
  service:
    name: etherpad
    state: restarted
- tags: create-pads
  include_vars:
    file: talks.json
    name: talks
- name: Set slugs
  tags: create-pads
  set_fact:
    slugs:
- name: Wait for OK
  tags: create-pads
  uri:
    url: "https://{{ etherpad_server_name }}/api/1/createPad?apikey={{ etherpad_api_key }}&padID={{etherpad_year}}"
  register: _result
  until: _result.status == 200
  retries: 720
  delay: 5  
- debug:
    var: _result
  tags: create-pads
- name: Create pads
  tags: create-pads
  uri:
    url: "https://{{ etherpad_server_name }}/api/1/createPad?apikey={{ etherpad_api_key }}&padID={{etherpad_year}}-{{ item.slug }}"
  loop: "{{ talks | json_query('talks[*]') }}"