pleroma-otp/tasks/main.yaml
author Luke Hoersten <luke@hoersten.org>
Mon, 08 Jun 2020 17:18:28 -0500
changeset 99 ed9f4d0ddce3
parent 98 444887b61044
child 101 bce4a3fd8da8
permissions -rw-r--r--
Changed index to www redirect.
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
97
33039e6345cd Minor style change.
Luke Hoersten <luke@hoersten.org>
parents: 93
diff changeset
    69
  copy:
33039e6345cd Minor style change.
Luke Hoersten <luke@hoersten.org>
parents: 93
diff changeset
    70
    remote_src: true
33039e6345cd Minor style change.
Luke Hoersten <luke@hoersten.org>
parents: 93
diff changeset
    71
    src: "/tmp/release/"
33039e6345cd Minor style change.
Luke Hoersten <luke@hoersten.org>
parents: 93
diff changeset
    72
    dest: "/opt/pleroma/"
33039e6345cd Minor style change.
Luke Hoersten <luke@hoersten.org>
parents: 93
diff changeset
    73
    owner: "pleroma"
33039e6345cd Minor style change.
Luke Hoersten <luke@hoersten.org>
parents: 93
diff changeset
    74
    group: "pleroma"
98
444887b61044 Made pleroma role idempotent.
Luke Hoersten <luke@hoersten.org>
parents: 97
diff changeset
    75
  changed_when: false
84
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    76
88
63efc98132f7 Added pleroma instance backup to s3.
Luke Hoersten <luke@hoersten.org>
parents: 87
diff changeset
    77
- name: remove tmp release folder
63efc98132f7 Added pleroma instance backup to s3.
Luke Hoersten <luke@hoersten.org>
parents: 87
diff changeset
    78
  become: yes
63efc98132f7 Added pleroma instance backup to s3.
Luke Hoersten <luke@hoersten.org>
parents: 87
diff changeset
    79
  file: path="{{item}}" state="absent"
63efc98132f7 Added pleroma instance backup to s3.
Luke Hoersten <luke@hoersten.org>
parents: 87
diff changeset
    80
  with_items:
63efc98132f7 Added pleroma instance backup to s3.
Luke Hoersten <luke@hoersten.org>
parents: 87
diff changeset
    81
    - "/tmp/setup_db.psql"
63efc98132f7 Added pleroma instance backup to s3.
Luke Hoersten <luke@hoersten.org>
parents: 87
diff changeset
    82
    - "/tmp/release/"
63efc98132f7 Added pleroma instance backup to s3.
Luke Hoersten <luke@hoersten.org>
parents: 87
diff changeset
    83
  when: pleroma_cleanup_tmp
63efc98132f7 Added pleroma instance backup to s3.
Luke Hoersten <luke@hoersten.org>
parents: 87
diff changeset
    84
89
4e1cf6df4ac9 Fixed systemd timer states.
Luke Hoersten <luke@hoersten.org>
parents: 88
diff changeset
    85
- import_tasks: s3-backup.yaml
88
63efc98132f7 Added pleroma instance backup to s3.
Luke Hoersten <luke@hoersten.org>
parents: 87
diff changeset
    86
  when: pleroma_s3_backup_enabled
85
dcfd23308c32 Completed pleroma-otp role.
Luke Hoersten <luke@hoersten.org>
parents: 84
diff changeset
    87
87
4f87097dd651 Got pleroma otp multi-instance working.
Luke Hoersten <luke@hoersten.org>
parents: 85
diff changeset
    88
- name: configure pleroma systemd service
85
dcfd23308c32 Completed pleroma-otp role.
Luke Hoersten <luke@hoersten.org>
parents: 84
diff changeset
    89
  become: yes
dcfd23308c32 Completed pleroma-otp role.
Luke Hoersten <luke@hoersten.org>
parents: 84
diff changeset
    90
  copy:
dcfd23308c32 Completed pleroma-otp role.
Luke Hoersten <luke@hoersten.org>
parents: 84
diff changeset
    91
    src: "[email protected]"
dcfd23308c32 Completed pleroma-otp role.
Luke Hoersten <luke@hoersten.org>
parents: 84
diff changeset
    92
    dest: "/lib/systemd/system/[email protected]"
dcfd23308c32 Completed pleroma-otp role.
Luke Hoersten <luke@hoersten.org>
parents: 84
diff changeset
    93
  notify: restart pleroma instance
84
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    94
87
4f87097dd651 Got pleroma otp multi-instance working.
Luke Hoersten <luke@hoersten.org>
parents: 85
diff changeset
    95
- name: ensure pleroma instance is enabled and started
85
dcfd23308c32 Completed pleroma-otp role.
Luke Hoersten <luke@hoersten.org>
parents: 84
diff changeset
    96
  become: yes
dcfd23308c32 Completed pleroma-otp role.
Luke Hoersten <luke@hoersten.org>
parents: 84
diff changeset
    97
  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
    98
85
dcfd23308c32 Completed pleroma-otp role.
Luke Hoersten <luke@hoersten.org>
parents: 84
diff changeset
    99
- name: migrate db
dcfd23308c32 Completed pleroma-otp role.
Luke Hoersten <luke@hoersten.org>
parents: 84
diff changeset
   100
  become: yes
dcfd23308c32 Completed pleroma-otp role.
Luke Hoersten <luke@hoersten.org>
parents: 84
diff changeset
   101
  become_user: "pleroma"
dcfd23308c32 Completed pleroma-otp role.
Luke Hoersten <luke@hoersten.org>
parents: 84
diff changeset
   102
  command: "/opt/pleroma/bin/pleroma_ctl migrate"
dcfd23308c32 Completed pleroma-otp role.
Luke Hoersten <luke@hoersten.org>
parents: 84
diff changeset
   103
  args:
dcfd23308c32 Completed pleroma-otp role.
Luke Hoersten <luke@hoersten.org>
parents: 84
diff changeset
   104
    chdir: "/opt/pleroma/"
dcfd23308c32 Completed pleroma-otp role.
Luke Hoersten <luke@hoersten.org>
parents: 84
diff changeset
   105
  environment:
dcfd23308c32 Completed pleroma-otp role.
Luke Hoersten <luke@hoersten.org>
parents: 84
diff changeset
   106
    PLEROMA_CONFIG_PATH: "/etc/pleroma/{{pleroma_instance}}.config.exs"
92
d4924111ce28 Made pleroma roles idempotent.
Luke Hoersten <luke@hoersten.org>
parents: 89
diff changeset
   107
  changed_when: false