pleroma/otp/tasks/main.yaml
author Luke Hoersten <luke@hoersten.org>
Sat, 04 Jul 2020 12:47:25 -0500
changeset 114 34c8632d763d
parent 103 78a072bbf3c1
child 120 7b3b01948954
permissions -rw-r--r--
Added oragono role.
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
101
bce4a3fd8da8 Added dep for ubuntu
Luke Hoersten <luke@hoersten.org>
parents: 98
diff changeset
     7
- name: apt install pleroma dependencies
bce4a3fd8da8 Added dep for ubuntu
Luke Hoersten <luke@hoersten.org>
parents: 98
diff changeset
     8
  become: yes
bce4a3fd8da8 Added dep for ubuntu
Luke Hoersten <luke@hoersten.org>
parents: 98
diff changeset
     9
  apt: name="libtinfo5"
bce4a3fd8da8 Added dep for ubuntu
Luke Hoersten <luke@hoersten.org>
parents: 98
diff changeset
    10
84
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    11
- name: create config and data directory
60
48a3a65119d5 Initial commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    12
  become: yes
84
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    13
  file:
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    14
    path: "{{item}}"
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    15
    state: "directory"
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    16
    mode: "0755"
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    17
  with_items:
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    18
    - "{{pleroma_data_dir}}"
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    19
    - "/etc/pleroma"
85
dcfd23308c32 Completed pleroma-otp role.
Luke Hoersten <luke@hoersten.org>
parents: 84
diff changeset
    20
    - "/opt/pleroma"
60
48a3a65119d5 Initial commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    21
81
5fe7c52b2063 Fixed pgsql permissions.
Luke Hoersten <luke@hoersten.org>
parents: 75
diff changeset
    22
- name: install pleroma config
60
48a3a65119d5 Initial commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    23
  template:
84
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    24
    src: "config.exs.j2"
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    25
    dest: "/etc/pleroma/{{pleroma_instance}}.config.exs"
85
dcfd23308c32 Completed pleroma-otp role.
Luke Hoersten <luke@hoersten.org>
parents: 84
diff changeset
    26
    owner: "pleroma"
dcfd23308c32 Completed pleroma-otp role.
Luke Hoersten <luke@hoersten.org>
parents: 84
diff changeset
    27
    group: "pleroma"
dcfd23308c32 Completed pleroma-otp role.
Luke Hoersten <luke@hoersten.org>
parents: 84
diff changeset
    28
    mode: "0600"
81
5fe7c52b2063 Fixed pgsql permissions.
Luke Hoersten <luke@hoersten.org>
parents: 75
diff changeset
    29
  become: yes
85
dcfd23308c32 Completed pleroma-otp role.
Luke Hoersten <luke@hoersten.org>
parents: 84
diff changeset
    30
  notify: restart pleroma instance
75
d8c87a41cc6d Pleroma role updates. Added Postgresql role.
Luke Hoersten <luke@hoersten.org>
parents: 74
diff changeset
    31
84
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    32
- name: create instance data directory
60
48a3a65119d5 Initial commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    33
  become: yes
84
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    34
  file:
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    35
    path: "{{item}}"
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    36
    state: "directory"
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    37
    owner: "pleroma"
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    38
    group: "pleroma"
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    39
    mode: "0755"
60
48a3a65119d5 Initial commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    40
  with_items:
84
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    41
    - "{{pleroma_data_dir}}/{{pleroma_instance}}"
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    42
    - "{{pleroma_data_dir}}/{{pleroma_instance}}/uploads"
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    43
    - "{{pleroma_data_dir}}/{{pleroma_instance}}/static"
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    44
    - "{{pleroma_data_dir}}/{{pleroma_instance}}/static/emoji"
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    45
85
dcfd23308c32 Completed pleroma-otp role.
Luke Hoersten <luke@hoersten.org>
parents: 84
diff changeset
    46
- name: install pleroma db schema file
92
d4924111ce28 Made pleroma roles idempotent.
Luke Hoersten <luke@hoersten.org>
parents: 89
diff changeset
    47
  become: yes
85
dcfd23308c32 Completed pleroma-otp role.
Luke Hoersten <luke@hoersten.org>
parents: 84
diff changeset
    48
  template:
dcfd23308c32 Completed pleroma-otp role.
Luke Hoersten <luke@hoersten.org>
parents: 84
diff changeset
    49
    src: "setup_db.psql.j2"
92
d4924111ce28 Made pleroma roles idempotent.
Luke Hoersten <luke@hoersten.org>
parents: 89
diff changeset
    50
    dest: "/tmp/setup_db_{{pleroma_instance}}.psql"
85
dcfd23308c32 Completed pleroma-otp role.
Luke Hoersten <luke@hoersten.org>
parents: 84
diff changeset
    51
    owner: "{{pleroma_db_superuser}}"
dcfd23308c32 Completed pleroma-otp role.
Luke Hoersten <luke@hoersten.org>
parents: 84
diff changeset
    52
    group: "{{pleroma_db_superuser}}"
dcfd23308c32 Completed pleroma-otp role.
Luke Hoersten <luke@hoersten.org>
parents: 84
diff changeset
    53
    mode: "0600"
92
d4924111ce28 Made pleroma roles idempotent.
Luke Hoersten <luke@hoersten.org>
parents: 89
diff changeset
    54
  changed_when: false
60
48a3a65119d5 Initial commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    55
85
dcfd23308c32 Completed pleroma-otp role.
Luke Hoersten <luke@hoersten.org>
parents: 84
diff changeset
    56
- name: install pleroma psql
dcfd23308c32 Completed pleroma-otp role.
Luke Hoersten <luke@hoersten.org>
parents: 84
diff changeset
    57
  become: yes
dcfd23308c32 Completed pleroma-otp role.
Luke Hoersten <luke@hoersten.org>
parents: 84
diff changeset
    58
  become_user: "{{pleroma_db_superuser}}"
92
d4924111ce28 Made pleroma roles idempotent.
Luke Hoersten <luke@hoersten.org>
parents: 89
diff changeset
    59
  command: "psql -f /tmp/setup_db_{{pleroma_instance}}.psql"
d4924111ce28 Made pleroma roles idempotent.
Luke Hoersten <luke@hoersten.org>
parents: 89
diff changeset
    60
  changed_when: false
84
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    61
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    62
- name: download and unarchive pleroma release
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    63
  become: yes
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    64
  unarchive:
85
dcfd23308c32 Completed pleroma-otp role.
Luke Hoersten <luke@hoersten.org>
parents: 84
diff changeset
    65
    src: "{{pleroma_download_url}}"
84
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    66
    dest: "/tmp/"
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    67
    remote_src: yes
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    68
    creates: "/tmp/release"
85
dcfd23308c32 Completed pleroma-otp role.
Luke Hoersten <luke@hoersten.org>
parents: 84
diff changeset
    69
  notify: restart pleroma instance
84
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    70
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    71
- name: install pleroma release
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    72
  become: yes
97
33039e6345cd Minor style change.
Luke Hoersten <luke@hoersten.org>
parents: 93
diff changeset
    73
  copy:
33039e6345cd Minor style change.
Luke Hoersten <luke@hoersten.org>
parents: 93
diff changeset
    74
    remote_src: true
33039e6345cd Minor style change.
Luke Hoersten <luke@hoersten.org>
parents: 93
diff changeset
    75
    src: "/tmp/release/"
33039e6345cd Minor style change.
Luke Hoersten <luke@hoersten.org>
parents: 93
diff changeset
    76
    dest: "/opt/pleroma/"
33039e6345cd Minor style change.
Luke Hoersten <luke@hoersten.org>
parents: 93
diff changeset
    77
    owner: "pleroma"
33039e6345cd Minor style change.
Luke Hoersten <luke@hoersten.org>
parents: 93
diff changeset
    78
    group: "pleroma"
98
444887b61044 Made pleroma role idempotent.
Luke Hoersten <luke@hoersten.org>
parents: 97
diff changeset
    79
  changed_when: false
84
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    80
88
63efc98132f7 Added pleroma instance backup to s3.
Luke Hoersten <luke@hoersten.org>
parents: 87
diff changeset
    81
- name: remove tmp release folder
63efc98132f7 Added pleroma instance backup to s3.
Luke Hoersten <luke@hoersten.org>
parents: 87
diff changeset
    82
  become: yes
63efc98132f7 Added pleroma instance backup to s3.
Luke Hoersten <luke@hoersten.org>
parents: 87
diff changeset
    83
  file: path="{{item}}" state="absent"
63efc98132f7 Added pleroma instance backup to s3.
Luke Hoersten <luke@hoersten.org>
parents: 87
diff changeset
    84
  with_items:
63efc98132f7 Added pleroma instance backup to s3.
Luke Hoersten <luke@hoersten.org>
parents: 87
diff changeset
    85
    - "/tmp/setup_db.psql"
63efc98132f7 Added pleroma instance backup to s3.
Luke Hoersten <luke@hoersten.org>
parents: 87
diff changeset
    86
    - "/tmp/release/"
63efc98132f7 Added pleroma instance backup to s3.
Luke Hoersten <luke@hoersten.org>
parents: 87
diff changeset
    87
  when: pleroma_cleanup_tmp
63efc98132f7 Added pleroma instance backup to s3.
Luke Hoersten <luke@hoersten.org>
parents: 87
diff changeset
    88
87
4f87097dd651 Got pleroma otp multi-instance working.
Luke Hoersten <luke@hoersten.org>
parents: 85
diff changeset
    89
- name: configure pleroma systemd service
85
dcfd23308c32 Completed pleroma-otp role.
Luke Hoersten <luke@hoersten.org>
parents: 84
diff changeset
    90
  become: yes
dcfd23308c32 Completed pleroma-otp role.
Luke Hoersten <luke@hoersten.org>
parents: 84
diff changeset
    91
  copy:
dcfd23308c32 Completed pleroma-otp role.
Luke Hoersten <luke@hoersten.org>
parents: 84
diff changeset
    92
    src: "[email protected]"
dcfd23308c32 Completed pleroma-otp role.
Luke Hoersten <luke@hoersten.org>
parents: 84
diff changeset
    93
    dest: "/lib/systemd/system/[email protected]"
dcfd23308c32 Completed pleroma-otp role.
Luke Hoersten <luke@hoersten.org>
parents: 84
diff changeset
    94
  notify: restart pleroma instance
84
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    95
87
4f87097dd651 Got pleroma otp multi-instance working.
Luke Hoersten <luke@hoersten.org>
parents: 85
diff changeset
    96
- name: ensure pleroma instance is enabled and started
85
dcfd23308c32 Completed pleroma-otp role.
Luke Hoersten <luke@hoersten.org>
parents: 84
diff changeset
    97
  become: yes
dcfd23308c32 Completed pleroma-otp role.
Luke Hoersten <luke@hoersten.org>
parents: 84
diff changeset
    98
  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
    99
85
dcfd23308c32 Completed pleroma-otp role.
Luke Hoersten <luke@hoersten.org>
parents: 84
diff changeset
   100
- name: migrate db
dcfd23308c32 Completed pleroma-otp role.
Luke Hoersten <luke@hoersten.org>
parents: 84
diff changeset
   101
  become: yes
dcfd23308c32 Completed pleroma-otp role.
Luke Hoersten <luke@hoersten.org>
parents: 84
diff changeset
   102
  become_user: "pleroma"
dcfd23308c32 Completed pleroma-otp role.
Luke Hoersten <luke@hoersten.org>
parents: 84
diff changeset
   103
  command: "/opt/pleroma/bin/pleroma_ctl migrate"
dcfd23308c32 Completed pleroma-otp role.
Luke Hoersten <luke@hoersten.org>
parents: 84
diff changeset
   104
  args:
dcfd23308c32 Completed pleroma-otp role.
Luke Hoersten <luke@hoersten.org>
parents: 84
diff changeset
   105
    chdir: "/opt/pleroma/"
dcfd23308c32 Completed pleroma-otp role.
Luke Hoersten <luke@hoersten.org>
parents: 84
diff changeset
   106
  environment:
dcfd23308c32 Completed pleroma-otp role.
Luke Hoersten <luke@hoersten.org>
parents: 84
diff changeset
   107
    PLEROMA_CONFIG_PATH: "/etc/pleroma/{{pleroma_instance}}.config.exs"
92
d4924111ce28 Made pleroma roles idempotent.
Luke Hoersten <luke@hoersten.org>
parents: 89
diff changeset
   108
  changed_when: false