summaryrefslogtreecommitdiff
path: root/roles/apps/etherpad-lite/tasks/main.yml
blob: 416ab7ff9a846a77369c4eeec4ddb006c7b9463e (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
---
- name: create zfs datasets
  when: etherpad_lite_zfs is defined
  block:
  - name: create zfs base dataset
    zfs:
      name: "{{ etherpad_lite_zfs.pool }}/{{ etherpad_lite_zfs.name }}"
      state: present
      extra_zfs_properties: "{{ etherpad_lite_zfs.properties | default(omit) }}"

  - name: create zfs volumes for instances
    loop: "{{ etherpad_lite_instances | dict2items }}"
    loop_control:
      label: "{{ item.key }} ({{ (item.value.zfs_properties | default({})).items() | map('join', '=') | join(', ') }})"
    zfs:
      name: "{{ etherpad_lite_zfs.pool }}/{{ etherpad_lite_zfs.name }}/{{ item.key }}"
      state: present
      extra_zfs_properties: "{{ item.value.zfs_properties | default(omit) }}"

  - name: configure etherpad_lite base bath
    set_fact:
      etherpad_lite_base_path: "{{ zfs_zpools[etherpad_lite_zfs.pool].mountpoint }}/{{ etherpad_lite_zfs.name }}"


- name: create instance subdirectories
  when: etherpad_lite_zfs is not defined
  loop: "{{ etherpad_lite_instances | list }}"
  file:
    path: "{{ etherpad_lite_base_path }}/{{ item }}"
    state: directory



- name: add group for etherpad-lite app
  group:
    name: epl-app
    gid: "{{ etherpad_lite_app_gid }}"

- name: add user for etherpad-lite app
  user:
    name: epl-app
    uid: "{{ etherpad_lite_app_uid }}"
    group: epl-app
    password: "!"

- name: create etherpad_lite app subdirectory
  loop: "{{ etherpad_lite_instances | list }}"
  file:
    path: "{{ etherpad_lite_base_path }}/{{ item }}/etherpad-lite"
    owner: "{{ etherpad_lite_app_uid }}"
    group: "{{ etherpad_lite_app_gid }}"
    state: directory


- name: add group for etherpad-lite db
  group:
    name: epl-db
    gid: "{{ etherpad_lite_db_gid }}"

- name: add user for etherpad-lite db
  user:
    name: epl-db
    uid: "{{ etherpad_lite_db_uid }}"
    group: epl-db
    password: "!"

- name: create etherpad-lite database subdirectory
  loop: "{{ etherpad_lite_instances | dict2items}}"
  loop_control:
    label: "{{ item.key }} ({{ item.value.database.type }})"
  file:
    path: "{{ etherpad_lite_base_path }}/{{ item.key }}/{{ item.value.database.type }}"
    owner: "{{ etherpad_lite_db_uid }}"
    group: "{{ etherpad_lite_db_gid }}"
    state: directory


- name: create etherpad-lite config directory
  loop: "{{ etherpad_lite_instances | list }}"
  file:
    path: "{{ etherpad_lite_base_path }}/{{ item }}/config"
    state: directory

- name: create settings json
  loop: "{{ etherpad_lite_instances | dict2items }}"
  loop_control:
    label: "{{ item.key }}"
  copy:
    content: "{{ item.value.settings | combine({'ip': '0.0.0.0', 'port': 9001}) | to_nice_json }}"
    dest: "{{ etherpad_lite_base_path }}/{{ item.key }}/config/settings.json"
    mode: 0600
    owner: "{{ etherpad_lite_app_uid }}"
    group: "{{ etherpad_lite_app_gid }}"

- name: install pod manifest
  loop: "{{ etherpad_lite_instances | dict2items }}"
  loop_control:
    label: "{{ item.key }}"
  vars:
    kubernetes_standalone_pod:
      name: "etherpad-lite-{{ item.key }}"
      spec: "{{ lookup('template', 'pod-spec-with-{{ item.value.database.type }}.yml.j2') }}"
      mode: 0600
      config_hash_items:
      - path: "{{ etherpad_lite_base_path }}/{{ item.key }}/config/settings.json"
        properties:
        - checksum
  include_role:
    name: kubernetes/standalone/pod

- name: configure nginx vhost
  loop: "{{ etherpad_lite_instances | dict2items }}"
  vars:
    nginx_vhost:
      name: "etherpad-lite-{{ item.key }}"
      content: "{{ lookup('template', 'nginx-vhost.conf.j2') }}"
      acme: true
      hostnames: "{{ item.value.hostnames }}"
  include_role:
    name: nginx/vhost