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

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

  - name: configure wikijs base bath
    set_fact:
      wikijs_base_path: "{{ (zfs_pools[wikijs_zfs.pool].mountpoint, wikijs_zfs.name) | path_join }}"


- name: create instance subdirectories
  when: wikijs_zfs is not defined
  loop: "{{ wikijs_instances | list }}"
  file:
    path: "{{ wikijs_base_path }}/{{ item }}"
    state: directory


- name: add group for wikijs db
  group:
    name: wikijs-db
    gid: "{{ wikijs_db_gid }}"

- name: add user for wikijs db
  user:
    name: wikijs-db
    uid: "{{ wikijs_db_uid }}"
    group: wikijs-db
    password: "!"

- name: create wikijs database subdirectory
  loop: "{{ wikijs_instances | dict2items}}"
  loop_control:
    label: "{{ item.key }}"
  file:
    path: "{{ wikijs_base_path }}/{{ item.key }}/postgres"
    owner: "{{ wikijs_db_uid }}"
    group: "{{ wikijs_db_gid }}"
    state: directory


- name: install pod manifest
  loop: "{{ wikijs_instances | dict2items }}"
  loop_control:
    label: "{{ item.key }}"
  vars:
    kubernetes_standalone_pod:
      name: "wikijs-{{ item.key }}"
      spec: "{{ lookup('template', 'pod-spec.yml.j2') }}"
      mode: "0600"
  include_role:
    name: kubernetes/standalone/pod

- name: configure nginx vhost
  loop: "{{ wikijs_instances | dict2items }}"
  loop_control:
    label: "{{ item.key }}"
  vars:
    nginx_vhost:
      name: "wikijs-{{ item.key }}"
      template: generic
      tls:
        certificate_provider: "{{ acme_client }}"
      hostnames:
      - "{{ item.value.hostname }}"
      locations:
        '/':
          proxy_pass: "http://127.0.0.1:{{ item.value.port }}"
          extra_directives: |-
            client_max_body_size 0;
  include_role:
    name: nginx/vhost