pleroma-otp/tasks/main.yaml
author Luke Hoersten <luke@hoersten.org>
Sat, 02 May 2020 18:37:45 -0500
changeset 95 35b63b150a51
parent 93 976670b2ca63
child 97 33039e6345cd
permissions -rw-r--r--
Added pleroma web root.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
60
48a3a65119d5 Initial commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
     1
---
48a3a65119d5 Initial commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
     2
48a3a65119d5 Initial commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
     3
- name: add users
48a3a65119d5 Initial commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
     4
  become: yes
84
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
     5
  user: name="pleroma" shell="/bin/false" home="/opt/pleroma" system="yes"
60
48a3a65119d5 Initial commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
     6
84
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
     7
- name: create config and data directory
60
48a3a65119d5 Initial commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
     8
  become: yes
84
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
     9
  file:
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    10
    path: "{{item}}"
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    11
    state: "directory"
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    12
    mode: "0755"
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    13
  with_items:
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    14
    - "{{pleroma_data_dir}}"
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    15
    - "/etc/pleroma"
85
dcfd23308c32 Completed pleroma-otp role.
Luke Hoersten <luke@hoersten.org>
parents: 84
diff changeset
    16
    - "/opt/pleroma"
60
48a3a65119d5 Initial commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    17
81
5fe7c52b2063 Fixed pgsql permissions.
Luke Hoersten <luke@hoersten.org>
parents: 75
diff changeset
    18
- name: install pleroma config
60
48a3a65119d5 Initial commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    19
  template:
84
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    20
    src: "config.exs.j2"
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    21
    dest: "/etc/pleroma/{{pleroma_instance}}.config.exs"
85
dcfd23308c32 Completed pleroma-otp role.
Luke Hoersten <luke@hoersten.org>
parents: 84
diff changeset
    22
    owner: "pleroma"
dcfd23308c32 Completed pleroma-otp role.
Luke Hoersten <luke@hoersten.org>
parents: 84
diff changeset
    23
    group: "pleroma"
dcfd23308c32 Completed pleroma-otp role.
Luke Hoersten <luke@hoersten.org>
parents: 84
diff changeset
    24
    mode: "0600"
81
5fe7c52b2063 Fixed pgsql permissions.
Luke Hoersten <luke@hoersten.org>
parents: 75
diff changeset
    25
  become: yes
85
dcfd23308c32 Completed pleroma-otp role.
Luke Hoersten <luke@hoersten.org>
parents: 84
diff changeset
    26
  notify: restart pleroma instance
75
d8c87a41cc6d Pleroma role updates. Added Postgresql role.
Luke Hoersten <luke@hoersten.org>
parents: 74
diff changeset
    27
84
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    28
- name: create instance data directory
60
48a3a65119d5 Initial commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    29
  become: yes
84
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    30
  file:
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    31
    path: "{{item}}"
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    32
    state: "directory"
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    33
    owner: "pleroma"
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    34
    group: "pleroma"
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    35
    mode: "0755"
60
48a3a65119d5 Initial commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    36
  with_items:
84
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    37
    - "{{pleroma_data_dir}}/{{pleroma_instance}}"
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    38
    - "{{pleroma_data_dir}}/{{pleroma_instance}}/uploads"
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    39
    - "{{pleroma_data_dir}}/{{pleroma_instance}}/static"
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    40
    - "{{pleroma_data_dir}}/{{pleroma_instance}}/static/emoji"
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    41
85
dcfd23308c32 Completed pleroma-otp role.
Luke Hoersten <luke@hoersten.org>
parents: 84
diff changeset
    42
- name: install pleroma db schema file
92
d4924111ce28 Made pleroma roles idempotent.
Luke Hoersten <luke@hoersten.org>
parents: 89
diff changeset
    43
  become: yes
85
dcfd23308c32 Completed pleroma-otp role.
Luke Hoersten <luke@hoersten.org>
parents: 84
diff changeset
    44
  template:
dcfd23308c32 Completed pleroma-otp role.
Luke Hoersten <luke@hoersten.org>
parents: 84
diff changeset
    45
    src: "setup_db.psql.j2"
92
d4924111ce28 Made pleroma roles idempotent.
Luke Hoersten <luke@hoersten.org>
parents: 89
diff changeset
    46
    dest: "/tmp/setup_db_{{pleroma_instance}}.psql"
85
dcfd23308c32 Completed pleroma-otp role.
Luke Hoersten <luke@hoersten.org>
parents: 84
diff changeset
    47
    owner: "{{pleroma_db_superuser}}"
dcfd23308c32 Completed pleroma-otp role.
Luke Hoersten <luke@hoersten.org>
parents: 84
diff changeset
    48
    group: "{{pleroma_db_superuser}}"
dcfd23308c32 Completed pleroma-otp role.
Luke Hoersten <luke@hoersten.org>
parents: 84
diff changeset
    49
    mode: "0600"
92
d4924111ce28 Made pleroma roles idempotent.
Luke Hoersten <luke@hoersten.org>
parents: 89
diff changeset
    50
  changed_when: false
60
48a3a65119d5 Initial commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    51
85
dcfd23308c32 Completed pleroma-otp role.
Luke Hoersten <luke@hoersten.org>
parents: 84
diff changeset
    52
- name: install pleroma psql
dcfd23308c32 Completed pleroma-otp role.
Luke Hoersten <luke@hoersten.org>
parents: 84
diff changeset
    53
  become: yes
dcfd23308c32 Completed pleroma-otp role.
Luke Hoersten <luke@hoersten.org>
parents: 84
diff changeset
    54
  become_user: "{{pleroma_db_superuser}}"
92
d4924111ce28 Made pleroma roles idempotent.
Luke Hoersten <luke@hoersten.org>
parents: 89
diff changeset
    55
  command: "psql -f /tmp/setup_db_{{pleroma_instance}}.psql"
d4924111ce28 Made pleroma roles idempotent.
Luke Hoersten <luke@hoersten.org>
parents: 89
diff changeset
    56
  changed_when: false
84
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    57
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    58
- name: download and unarchive pleroma release
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    59
  become: yes
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    60
  unarchive:
85
dcfd23308c32 Completed pleroma-otp role.
Luke Hoersten <luke@hoersten.org>
parents: 84
diff changeset
    61
    src: "{{pleroma_download_url}}"
84
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    62
    dest: "/tmp/"
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    63
    remote_src: yes
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    64
    creates: "/tmp/release"
85
dcfd23308c32 Completed pleroma-otp role.
Luke Hoersten <luke@hoersten.org>
parents: 84
diff changeset
    65
  notify: restart pleroma instance
84
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    66
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    67
- name: install pleroma release
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    68
  become: yes
85
dcfd23308c32 Completed pleroma-otp role.
Luke Hoersten <luke@hoersten.org>
parents: 84
diff changeset
    69
  copy: remote_src="True" src="/tmp/release/" dest="/opt/pleroma/" owner="pleroma" group="pleroma"
dcfd23308c32 Completed pleroma-otp role.
Luke Hoersten <luke@hoersten.org>
parents: 84
diff changeset
    70
  notify: restart pleroma instance
84
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    71
88
63efc98132f7 Added pleroma instance backup to s3.
Luke Hoersten <luke@hoersten.org>
parents: 87
diff changeset
    72
- name: remove tmp release folder
63efc98132f7 Added pleroma instance backup to s3.
Luke Hoersten <luke@hoersten.org>
parents: 87
diff changeset
    73
  become: yes
63efc98132f7 Added pleroma instance backup to s3.
Luke Hoersten <luke@hoersten.org>
parents: 87
diff changeset
    74
  file: path="{{item}}" state="absent"
63efc98132f7 Added pleroma instance backup to s3.
Luke Hoersten <luke@hoersten.org>
parents: 87
diff changeset
    75
  with_items:
63efc98132f7 Added pleroma instance backup to s3.
Luke Hoersten <luke@hoersten.org>
parents: 87
diff changeset
    76
    - "/tmp/setup_db.psql"
63efc98132f7 Added pleroma instance backup to s3.
Luke Hoersten <luke@hoersten.org>
parents: 87
diff changeset
    77
    - "/tmp/release/"
63efc98132f7 Added pleroma instance backup to s3.
Luke Hoersten <luke@hoersten.org>
parents: 87
diff changeset
    78
  when: pleroma_cleanup_tmp
63efc98132f7 Added pleroma instance backup to s3.
Luke Hoersten <luke@hoersten.org>
parents: 87
diff changeset
    79
89
4e1cf6df4ac9 Fixed systemd timer states.
Luke Hoersten <luke@hoersten.org>
parents: 88
diff changeset
    80
- import_tasks: s3-backup.yaml
88
63efc98132f7 Added pleroma instance backup to s3.
Luke Hoersten <luke@hoersten.org>
parents: 87
diff changeset
    81
  when: pleroma_s3_backup_enabled
85
dcfd23308c32 Completed pleroma-otp role.
Luke Hoersten <luke@hoersten.org>
parents: 84
diff changeset
    82
87
4f87097dd651 Got pleroma otp multi-instance working.
Luke Hoersten <luke@hoersten.org>
parents: 85
diff changeset
    83
- name: configure pleroma systemd service
85
dcfd23308c32 Completed pleroma-otp role.
Luke Hoersten <luke@hoersten.org>
parents: 84
diff changeset
    84
  become: yes
dcfd23308c32 Completed pleroma-otp role.
Luke Hoersten <luke@hoersten.org>
parents: 84
diff changeset
    85
  copy:
dcfd23308c32 Completed pleroma-otp role.
Luke Hoersten <luke@hoersten.org>
parents: 84
diff changeset
    86
    src: "[email protected]"
dcfd23308c32 Completed pleroma-otp role.
Luke Hoersten <luke@hoersten.org>
parents: 84
diff changeset
    87
    dest: "/lib/systemd/system/[email protected]"
dcfd23308c32 Completed pleroma-otp role.
Luke Hoersten <luke@hoersten.org>
parents: 84
diff changeset
    88
  notify: restart pleroma instance
84
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    89
87
4f87097dd651 Got pleroma otp multi-instance working.
Luke Hoersten <luke@hoersten.org>
parents: 85
diff changeset
    90
- name: ensure pleroma instance is enabled and started
85
dcfd23308c32 Completed pleroma-otp role.
Luke Hoersten <luke@hoersten.org>
parents: 84
diff changeset
    91
  become: yes
dcfd23308c32 Completed pleroma-otp role.
Luke Hoersten <luke@hoersten.org>
parents: 84
diff changeset
    92
  systemd: name="pleroma@{{pleroma_instance}}.service" enabled="yes" state="started"
84
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    93
85
dcfd23308c32 Completed pleroma-otp role.
Luke Hoersten <luke@hoersten.org>
parents: 84
diff changeset
    94
- name: migrate db
dcfd23308c32 Completed pleroma-otp role.
Luke Hoersten <luke@hoersten.org>
parents: 84
diff changeset
    95
  become: yes
dcfd23308c32 Completed pleroma-otp role.
Luke Hoersten <luke@hoersten.org>
parents: 84
diff changeset
    96
  become_user: "pleroma"
dcfd23308c32 Completed pleroma-otp role.
Luke Hoersten <luke@hoersten.org>
parents: 84
diff changeset
    97
  command: "/opt/pleroma/bin/pleroma_ctl migrate"
dcfd23308c32 Completed pleroma-otp role.
Luke Hoersten <luke@hoersten.org>
parents: 84
diff changeset
    98
  args:
dcfd23308c32 Completed pleroma-otp role.
Luke Hoersten <luke@hoersten.org>
parents: 84
diff changeset
    99
    chdir: "/opt/pleroma/"
dcfd23308c32 Completed pleroma-otp role.
Luke Hoersten <luke@hoersten.org>
parents: 84
diff changeset
   100
  environment:
dcfd23308c32 Completed pleroma-otp role.
Luke Hoersten <luke@hoersten.org>
parents: 84
diff changeset
   101
    PLEROMA_CONFIG_PATH: "/etc/pleroma/{{pleroma_instance}}.config.exs"
92
d4924111ce28 Made pleroma roles idempotent.
Luke Hoersten <luke@hoersten.org>
parents: 89
diff changeset
   102
  changed_when: false