dendrite/server/tasks/main.yaml
author Luke Hoersten <luke@hoersten.org>
Sun, 18 Jul 2021 17:43:46 -0500
changeset 163 40b78af86337
parent 159 writefreely/server/tasks/main.yaml@05d0cf32e077
child 168 8e61e4bb714b
permissions -rw-r--r--
Tons of updates.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
fd351734f007 Prometheus and WriteFreely roles are work in progress.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
     1
---
fd351734f007 Prometheus and WriteFreely roles are work in progress.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
     2
163
40b78af86337 Tons of updates.
Luke Hoersten <luke@hoersten.org>
parents: 159
diff changeset
     3
- name: add dendrite user
17
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
     4
  become: yes
163
40b78af86337 Tons of updates.
Luke Hoersten <luke@hoersten.org>
parents: 159
diff changeset
     5
  user: name="{{dendrite_user}}"
17
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
     6
163
40b78af86337 Tons of updates.
Luke Hoersten <luke@hoersten.org>
parents: 159
diff changeset
     7
# build
40b78af86337 Tons of updates.
Luke Hoersten <luke@hoersten.org>
parents: 159
diff changeset
     8
- name: snap install golang
40b78af86337 Tons of updates.
Luke Hoersten <luke@hoersten.org>
parents: 159
diff changeset
     9
  become: yes
40b78af86337 Tons of updates.
Luke Hoersten <luke@hoersten.org>
parents: 159
diff changeset
    10
  snap: name="go" classic="yes"
40b78af86337 Tons of updates.
Luke Hoersten <luke@hoersten.org>
parents: 159
diff changeset
    11
40b78af86337 Tons of updates.
Luke Hoersten <luke@hoersten.org>
parents: 159
diff changeset
    12
- name: unarchive dendrite
17
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    13
  become: yes
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    14
  unarchive:
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    15
    remote_src: yes
163
40b78af86337 Tons of updates.
Luke Hoersten <luke@hoersten.org>
parents: 159
diff changeset
    16
    src: "{{dendrite_tar}}"
17
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    17
    dest: "/tmp/"
163
40b78af86337 Tons of updates.
Luke Hoersten <luke@hoersten.org>
parents: 159
diff changeset
    18
    creates: "{{dendrite_build_dir}}"
40b78af86337 Tons of updates.
Luke Hoersten <luke@hoersten.org>
parents: 159
diff changeset
    19
    owner: "{{dendrite_user}}"
40b78af86337 Tons of updates.
Luke Hoersten <luke@hoersten.org>
parents: 159
diff changeset
    20
    group: "{{dendrite_user}}"
40b78af86337 Tons of updates.
Luke Hoersten <luke@hoersten.org>
parents: 159
diff changeset
    21
40b78af86337 Tons of updates.
Luke Hoersten <luke@hoersten.org>
parents: 159
diff changeset
    22
- name: check if dendrite build exists
40b78af86337 Tons of updates.
Luke Hoersten <luke@hoersten.org>
parents: 159
diff changeset
    23
  stat:
40b78af86337 Tons of updates.
Luke Hoersten <luke@hoersten.org>
parents: 159
diff changeset
    24
    path: "{{dendrite_build_dir}}/bin"
40b78af86337 Tons of updates.
Luke Hoersten <luke@hoersten.org>
parents: 159
diff changeset
    25
  register: build_file
40b78af86337 Tons of updates.
Luke Hoersten <luke@hoersten.org>
parents: 159
diff changeset
    26
40b78af86337 Tons of updates.
Luke Hoersten <luke@hoersten.org>
parents: 159
diff changeset
    27
- name: build dendrite
40b78af86337 Tons of updates.
Luke Hoersten <luke@hoersten.org>
parents: 159
diff changeset
    28
  become: yes
40b78af86337 Tons of updates.
Luke Hoersten <luke@hoersten.org>
parents: 159
diff changeset
    29
  become_user: "{{dendrite_user}}"
40b78af86337 Tons of updates.
Luke Hoersten <luke@hoersten.org>
parents: 159
diff changeset
    30
  command: "{{dendrite_build_dir}}/build.sh"
40b78af86337 Tons of updates.
Luke Hoersten <luke@hoersten.org>
parents: 159
diff changeset
    31
  args:
40b78af86337 Tons of updates.
Luke Hoersten <luke@hoersten.org>
parents: 159
diff changeset
    32
    chdir: "{{dendrite_build_dir}}"
40b78af86337 Tons of updates.
Luke Hoersten <luke@hoersten.org>
parents: 159
diff changeset
    33
  when: not build_file.stat.exists
40b78af86337 Tons of updates.
Luke Hoersten <luke@hoersten.org>
parents: 159
diff changeset
    34
  notify: restart service
40b78af86337 Tons of updates.
Luke Hoersten <luke@hoersten.org>
parents: 159
diff changeset
    35
40b78af86337 Tons of updates.
Luke Hoersten <luke@hoersten.org>
parents: 159
diff changeset
    36
# install
40b78af86337 Tons of updates.
Luke Hoersten <luke@hoersten.org>
parents: 159
diff changeset
    37
- name: install dendrite binary
40b78af86337 Tons of updates.
Luke Hoersten <luke@hoersten.org>
parents: 159
diff changeset
    38
  become: yes
40b78af86337 Tons of updates.
Luke Hoersten <luke@hoersten.org>
parents: 159
diff changeset
    39
  copy:
40b78af86337 Tons of updates.
Luke Hoersten <luke@hoersten.org>
parents: 159
diff changeset
    40
    src: "{{dendrite_build_dir}}/bin/dendrite-monolith-server"
40b78af86337 Tons of updates.
Luke Hoersten <luke@hoersten.org>
parents: 159
diff changeset
    41
    dest: "/usr/local/bin/dendrite-monolith-server"
40b78af86337 Tons of updates.
Luke Hoersten <luke@hoersten.org>
parents: 159
diff changeset
    42
    remote_src: yes
17
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    43
    owner: "root"
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    44
    group: "root"
18
ea20908c3904 Removed use of install command.
Luke Hoersten <luke@hoersten.org>
parents: 17
diff changeset
    45
    mode: "0755"
17
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    46
51
19fa7aa47bf1 Minor writefreely change.
Luke Hoersten <luke@hoersten.org>
parents: 27
diff changeset
    47
- name: create instance dir
17
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    48
  become: yes
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    49
  file:
51
19fa7aa47bf1 Minor writefreely change.
Luke Hoersten <luke@hoersten.org>
parents: 27
diff changeset
    50
    path: "{{item}}"
17
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    51
    state: "directory"
163
40b78af86337 Tons of updates.
Luke Hoersten <luke@hoersten.org>
parents: 159
diff changeset
    52
    owner: "{{dendrite_user}}"
40b78af86337 Tons of updates.
Luke Hoersten <luke@hoersten.org>
parents: 159
diff changeset
    53
    group: "{{dendrite_user}}"
17
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    54
    mode: "0755"
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    55
  notify: reload service
51
19fa7aa47bf1 Minor writefreely change.
Luke Hoersten <luke@hoersten.org>
parents: 27
diff changeset
    56
  loop:
163
40b78af86337 Tons of updates.
Luke Hoersten <luke@hoersten.org>
parents: 159
diff changeset
    57
    - "{{dendrite_dir}}"
40b78af86337 Tons of updates.
Luke Hoersten <luke@hoersten.org>
parents: 159
diff changeset
    58
    - "{{dendrite_dir}}/{{dendrite_instance}}"
17
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    59
163
40b78af86337 Tons of updates.
Luke Hoersten <luke@hoersten.org>
parents: 159
diff changeset
    60
- name: install keys
17
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    61
  become: yes
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    62
  copy:
163
40b78af86337 Tons of updates.
Luke Hoersten <luke@hoersten.org>
parents: 159
diff changeset
    63
    src: "{{item}}"
40b78af86337 Tons of updates.
Luke Hoersten <luke@hoersten.org>
parents: 159
diff changeset
    64
    dest: "{{dendrite_dir}}/{{dendrite_instance}}/"
40b78af86337 Tons of updates.
Luke Hoersten <luke@hoersten.org>
parents: 159
diff changeset
    65
    owner: "{{dendrite_user}}"
40b78af86337 Tons of updates.
Luke Hoersten <luke@hoersten.org>
parents: 159
diff changeset
    66
    group: "{{dendrite_user}}"
40b78af86337 Tons of updates.
Luke Hoersten <luke@hoersten.org>
parents: 159
diff changeset
    67
    mode: "0600"
40b78af86337 Tons of updates.
Luke Hoersten <luke@hoersten.org>
parents: 159
diff changeset
    68
  loop: "{{dendrite_keys}}"
1
fd351734f007 Prometheus and WriteFreely roles are work in progress.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    69
163
40b78af86337 Tons of updates.
Luke Hoersten <luke@hoersten.org>
parents: 159
diff changeset
    70
- name: copy db schema file
17
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    71
  become: yes
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    72
  template:
163
40b78af86337 Tons of updates.
Luke Hoersten <luke@hoersten.org>
parents: 159
diff changeset
    73
    src: "setup_db.psql.j2"
40b78af86337 Tons of updates.
Luke Hoersten <luke@hoersten.org>
parents: 159
diff changeset
    74
    dest: "/tmp/setup_db_dendrite_{{dendrite_instance}}.psql"
40b78af86337 Tons of updates.
Luke Hoersten <luke@hoersten.org>
parents: 159
diff changeset
    75
    owner: "postgres"
40b78af86337 Tons of updates.
Luke Hoersten <luke@hoersten.org>
parents: 159
diff changeset
    76
    group: "postgres"
40b78af86337 Tons of updates.
Luke Hoersten <luke@hoersten.org>
parents: 159
diff changeset
    77
    mode: "0600"
17
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    78
163
40b78af86337 Tons of updates.
Luke Hoersten <luke@hoersten.org>
parents: 159
diff changeset
    79
- name: install db schema psql
40b78af86337 Tons of updates.
Luke Hoersten <luke@hoersten.org>
parents: 159
diff changeset
    80
  become: yes
40b78af86337 Tons of updates.
Luke Hoersten <luke@hoersten.org>
parents: 159
diff changeset
    81
  become_user: "postgres"
40b78af86337 Tons of updates.
Luke Hoersten <luke@hoersten.org>
parents: 159
diff changeset
    82
  command: "psql -f /tmp/setup_db_dendrite_{{dendrite_instance}}.psql"
40b78af86337 Tons of updates.
Luke Hoersten <luke@hoersten.org>
parents: 159
diff changeset
    83
  changed_when: false
17
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    84
163
40b78af86337 Tons of updates.
Luke Hoersten <luke@hoersten.org>
parents: 159
diff changeset
    85
- name: configure dendrite
17
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    86
  become: yes
163
40b78af86337 Tons of updates.
Luke Hoersten <luke@hoersten.org>
parents: 159
diff changeset
    87
  template:
40b78af86337 Tons of updates.
Luke Hoersten <luke@hoersten.org>
parents: 159
diff changeset
    88
    src: "dendrite.yaml.j2"
40b78af86337 Tons of updates.
Luke Hoersten <luke@hoersten.org>
parents: 159
diff changeset
    89
    dest: "{{dendrite_dir}}/{{dendrite_instance}}/dendrite.yaml"
40b78af86337 Tons of updates.
Luke Hoersten <luke@hoersten.org>
parents: 159
diff changeset
    90
    mode: "0644"
40b78af86337 Tons of updates.
Luke Hoersten <luke@hoersten.org>
parents: 159
diff changeset
    91
    owner: "{{dendrite_user}}"
40b78af86337 Tons of updates.
Luke Hoersten <luke@hoersten.org>
parents: 159
diff changeset
    92
    group: "{{dendrite_user}}"
40b78af86337 Tons of updates.
Luke Hoersten <luke@hoersten.org>
parents: 159
diff changeset
    93
  notify: reload service
17
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    94
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    95
- name: install systemd service
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    96
  become: yes
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
    97
  template:
163
40b78af86337 Tons of updates.
Luke Hoersten <luke@hoersten.org>
parents: 159
diff changeset
    98
    src: "[email protected]"
40b78af86337 Tons of updates.
Luke Hoersten <luke@hoersten.org>
parents: 159
diff changeset
    99
    dest: "/lib/systemd/system/[email protected]"
17
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
   100
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
   101
- name: ensure service is started
41034ea52480 Completed writefreely role
Luke Hoersten <luke@hoersten.org>
parents: 2
diff changeset
   102
  become: yes
163
40b78af86337 Tons of updates.
Luke Hoersten <luke@hoersten.org>
parents: 159
diff changeset
   103
  systemd: name="dendrite@{{dendrite_instance}}.service" enabled="yes" state="started"