roles/pleroma-otp/tasks/main.yaml
author Luke Hoersten <luke@hoersten.org>
Sun, 19 Jan 2020 13:41:08 -0600
changeset 84 d0c40727e6ff
parent 81 roles/pleroma/tasks/main.yaml@5fe7c52b2063
child 85 dcfd23308c32
permissions -rw-r--r--
Added WIP pleroma OTP 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
73
3e6344570822 Fixed deprecated ansible syntax.
Luke Hoersten <luke@hoersten.org>
parents: 69
diff changeset
     3
- name: install pleroma apt packages
60
48a3a65119d5 Initial commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
     4
  become: yes
73
3e6344570822 Fixed deprecated ansible syntax.
Luke Hoersten <luke@hoersten.org>
parents: 69
diff changeset
     5
  apt: name="{{pleroma_apt_packages}}"
60
48a3a65119d5 Initial commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
     6
48a3a65119d5 Initial commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
     7
- name: add users
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
  user: name="pleroma" shell="/bin/false" home="/opt/pleroma" system="yes"
60
48a3a65119d5 Initial commit.
Luke Hoersten <luke@hoersten.org>
parents:
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"
60
48a3a65119d5 Initial commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    20
81
5fe7c52b2063 Fixed pgsql permissions.
Luke Hoersten <luke@hoersten.org>
parents: 75
diff changeset
    21
- name: install pleroma config
60
48a3a65119d5 Initial commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    22
  template:
84
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    23
    src: "config.exs.j2"
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    24
    dest: "/etc/pleroma/{{pleroma_instance}}.config.exs"
81
5fe7c52b2063 Fixed pgsql permissions.
Luke Hoersten <luke@hoersten.org>
parents: 75
diff changeset
    25
    mode: "0700"
5fe7c52b2063 Fixed pgsql permissions.
Luke Hoersten <luke@hoersten.org>
parents: 75
diff changeset
    26
  become: yes
84
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    27
  notify: "restart pleroma {{pleroma_instance}} instance"
75
d8c87a41cc6d Pleroma role updates. Added Postgresql role.
Luke Hoersten <luke@hoersten.org>
parents: 74
diff changeset
    28
84
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    29
- name: create instance data directory
60
48a3a65119d5 Initial commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    30
  become: yes
84
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    31
  file:
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    32
    path: "{{item}}"
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    33
    state: "directory"
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    34
    owner: "pleroma"
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    35
    group: "pleroma"
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    36
    mode: "0755"
60
48a3a65119d5 Initial commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    37
  with_items:
84
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    38
    - "{{pleroma_data_dir}}/{{pleroma_instance}}"
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    39
    - "{{pleroma_data_dir}}/{{pleroma_instance}}/uploads"
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    40
    - "{{pleroma_data_dir}}/{{pleroma_instance}}/static"
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    41
    - "{{pleroma_data_dir}}/{{pleroma_instance}}/static/emoji"
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    42
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    43
# Set config path in systemd: PLEROMA_CONFIG_PATH
60
48a3a65119d5 Initial commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    44
84
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    45
# - name: install pleroma db schema file
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    46
#   template:
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    47
#     src: "setup_db.psql.j2"
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    48
#     dest: "/tmp/setup_db.psql"
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    49
#     owner: "{{pleroma_db_superuser}}"
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    50
#     group: "{{pleroma_db_superuser}}"
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    51
#     mode: "0700"
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    52
#   become: yes
60
48a3a65119d5 Initial commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    53
84
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    54
# - name: install pleroma psql
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    55
#   become: yes
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    56
#   become_user: "{{pleroma_db_superuser}}"
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    57
#   command: "psql -f /tmp/setup_db.psql"
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    58
#   notify: restart pleroma
75
d8c87a41cc6d Pleroma role updates. Added Postgresql role.
Luke Hoersten <luke@hoersten.org>
parents: 74
diff changeset
    59
d8c87a41cc6d Pleroma role updates. Added Postgresql role.
Luke Hoersten <luke@hoersten.org>
parents: 74
diff changeset
    60
d8c87a41cc6d Pleroma role updates. Added Postgresql role.
Luke Hoersten <luke@hoersten.org>
parents: 74
diff changeset
    61
d8c87a41cc6d Pleroma role updates. Added Postgresql role.
Luke Hoersten <luke@hoersten.org>
parents: 74
diff changeset
    62
d8c87a41cc6d Pleroma role updates. Added Postgresql role.
Luke Hoersten <luke@hoersten.org>
parents: 74
diff changeset
    63
84
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    64
# MIGERATION
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    65
# mv ~pleroma/uploads/* /var/lib/pleroma/uploads
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    66
# mv ~pleroma/instance/static /var/lib/pleroma/static
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    67
# mv ~pleroma/priv/static/emoji /var/lib/pleroma/static/emoji
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    68
# mv ~pleroma/config/prod.secret.exs /etc/pleroma/config.exs
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    69
# Change `use Mix.Config` at the top to `import Config`
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    70
# rm -r ~pleroma/*
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    71
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    72
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    73
- name: download and unarchive pleroma release
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    74
  become: yes
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    75
  unarchive:
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    76
    src: "https://git.pleroma.social/api/v4/projects/2/jobs/artifacts/{{pleroma_branch}}/download?job={{pleroma_flavor}}"
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    77
    dest: "/tmp/"
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    78
    remote_src: yes
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    79
    creates: "/tmp/release"
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    80
  notify: "restart pleroma {{pleroma_instance}} instance"
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    81
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    82
- name: install pleroma release
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    83
  become: yes
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    84
  copy: remote_src="True" src="/tmp/release/" dest="/opt/pleroma/"
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    85
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    86
# - name: Remove old files foo
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    87
#   file: path="/path/to/foo" state="absent"
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    88
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    89
# ***
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    90
# mv /tmp/release/* ~pleroma/
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    91
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    92
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    93
# Copy the service into a proper directory
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    94
# cp ~pleroma/installation/pleroma.service /etc/systemd/system/pleroma.service
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    95
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    96
# - name: "configure pleroma systemd service"
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    97
#   become: yes
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    98
#   copy:
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
    99
#     src: "[email protected]"
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
   100
#     dest: "/lib/systemd/system/[email protected]"
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
   101
#   notify: "restart pleroma {{pleroma_instance}} instance"
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
   102
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
   103
# - name: "ensure pleroma {{pleroma_instance}} instance is enabled and started"
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
   104
#   become: yes
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
   105
#   systemd: name="pleroma@{{pleroma_instance}}" enabled="yes" state="started"
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
   106
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
   107
# - name: migrate db
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
   108
#   become: yes
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
   109
#   become_user: "pleroma"
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
   110
#   command: "/opt/pleroma/bin/pleroma_ctl migrate"
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
   111
#   args:
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
   112
#     chdir: "/opt/pleroma/"
d0c40727e6ff Added WIP pleroma OTP role.
Luke Hoersten <luke@hoersten.org>
parents: 81
diff changeset
   113
#   notify: restart pleroma