roles/pleroma/tasks/main.yaml
author Luke Hoersten <luke@hoersten.org>
Sun, 19 Jan 2020 13:41:08 -0600
changeset 84 d0c40727e6ff
parent 81 5fe7c52b2063
child 86 3dcdaac4adbf
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
48a3a65119d5 Initial commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
     3
- name: add erland solutions key
48a3a65119d5 Initial commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
     4
  become: yes
75
d8c87a41cc6d Pleroma role updates. Added Postgresql role.
Luke Hoersten <luke@hoersten.org>
parents: 74
diff changeset
     5
  apt_key: url="http://packages.erlang-solutions.com/debian/erlang_solutions.asc"
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: install erland solutions repo
48a3a65119d5 Initial commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
     8
  become: yes
75
d8c87a41cc6d Pleroma role updates. Added Postgresql role.
Luke Hoersten <luke@hoersten.org>
parents: 74
diff changeset
     9
  apt_repository: repo="deb http://binaries.erlang-solutions.com/debian buster contrib"
60
48a3a65119d5 Initial commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    10
48a3a65119d5 Initial commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    11
- name: update apt package cache
48a3a65119d5 Initial commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    12
  become: yes
48a3a65119d5 Initial commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    13
  apt: upgrade="dist" update_cache="yes" cache_valid_time="3600"
48a3a65119d5 Initial commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    14
73
3e6344570822 Fixed deprecated ansible syntax.
Luke Hoersten <luke@hoersten.org>
parents: 69
diff changeset
    15
- name: install pleroma apt packages
60
48a3a65119d5 Initial commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    16
  become: yes
73
3e6344570822 Fixed deprecated ansible syntax.
Luke Hoersten <luke@hoersten.org>
parents: 69
diff changeset
    17
  apt: name="{{pleroma_apt_packages}}"
60
48a3a65119d5 Initial commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    18
48a3a65119d5 Initial commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    19
- name: add users
48a3a65119d5 Initial commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    20
  become: yes
48a3a65119d5 Initial commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    21
  user: name="{{pleroma_user}}" shell="/bin/bash"
48a3a65119d5 Initial commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    22
48a3a65119d5 Initial commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    23
- name: checkout plemora
48a3a65119d5 Initial commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    24
  become: yes
48a3a65119d5 Initial commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    25
  become_user: "{{pleroma_user}}"
48a3a65119d5 Initial commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    26
  git:
48a3a65119d5 Initial commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    27
    repo: "https://git.pleroma.social/pleroma/pleroma.git"
48a3a65119d5 Initial commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    28
    dest: "~{{pleroma_user}}/pleroma"
75
d8c87a41cc6d Pleroma role updates. Added Postgresql role.
Luke Hoersten <luke@hoersten.org>
parents: 74
diff changeset
    29
    version: "{{pleroma_version}}"
60
48a3a65119d5 Initial commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    30
    force: yes
48a3a65119d5 Initial commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    31
81
5fe7c52b2063 Fixed pgsql permissions.
Luke Hoersten <luke@hoersten.org>
parents: 75
diff changeset
    32
- name: install pleroma config
60
48a3a65119d5 Initial commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    33
  template:
81
5fe7c52b2063 Fixed pgsql permissions.
Luke Hoersten <luke@hoersten.org>
parents: 75
diff changeset
    34
    src: "prod.secret.exs.j2"
5fe7c52b2063 Fixed pgsql permissions.
Luke Hoersten <luke@hoersten.org>
parents: 75
diff changeset
    35
    dest: "~{{pleroma_user}}/pleroma/config/prod.secret.exs"
60
48a3a65119d5 Initial commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    36
    owner: "{{pleroma_user}}"
48a3a65119d5 Initial commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    37
    group: "{{pleroma_user}}"
81
5fe7c52b2063 Fixed pgsql permissions.
Luke Hoersten <luke@hoersten.org>
parents: 75
diff changeset
    38
    mode: "0700"
60
48a3a65119d5 Initial commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    39
  become: yes
62
63586cf10d46 Added more config variables to pleroma.
Luke Hoersten <luke@hoersten.org>
parents: 60
diff changeset
    40
  notify: restart pleroma
60
48a3a65119d5 Initial commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    41
81
5fe7c52b2063 Fixed pgsql permissions.
Luke Hoersten <luke@hoersten.org>
parents: 75
diff changeset
    42
- name: install pleroma db schema file
5fe7c52b2063 Fixed pgsql permissions.
Luke Hoersten <luke@hoersten.org>
parents: 75
diff changeset
    43
  template:
5fe7c52b2063 Fixed pgsql permissions.
Luke Hoersten <luke@hoersten.org>
parents: 75
diff changeset
    44
    src: "setup_db.psql.j2"
5fe7c52b2063 Fixed pgsql permissions.
Luke Hoersten <luke@hoersten.org>
parents: 75
diff changeset
    45
    dest: "/tmp/setup_db.psql"
5fe7c52b2063 Fixed pgsql permissions.
Luke Hoersten <luke@hoersten.org>
parents: 75
diff changeset
    46
    owner: "{{pleroma_db_superuser}}"
5fe7c52b2063 Fixed pgsql permissions.
Luke Hoersten <luke@hoersten.org>
parents: 75
diff changeset
    47
    group: "{{pleroma_db_superuser}}"
5fe7c52b2063 Fixed pgsql permissions.
Luke Hoersten <luke@hoersten.org>
parents: 75
diff changeset
    48
    mode: "0700"
5fe7c52b2063 Fixed pgsql permissions.
Luke Hoersten <luke@hoersten.org>
parents: 75
diff changeset
    49
  become: yes
5fe7c52b2063 Fixed pgsql permissions.
Luke Hoersten <luke@hoersten.org>
parents: 75
diff changeset
    50
60
48a3a65119d5 Initial commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    51
- name: install pleroma psql
48a3a65119d5 Initial commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    52
  become: yes
66
652a236229c2 Updated for external DB.
Luke Hoersten <luke@hoersten.org>
parents: 65
diff changeset
    53
  become_user: "{{pleroma_db_superuser}}"
81
5fe7c52b2063 Fixed pgsql permissions.
Luke Hoersten <luke@hoersten.org>
parents: 75
diff changeset
    54
  command: "psql -f /tmp/setup_db.psql"
62
63586cf10d46 Added more config variables to pleroma.
Luke Hoersten <luke@hoersten.org>
parents: 60
diff changeset
    55
  notify: restart pleroma
75
d8c87a41cc6d Pleroma role updates. Added Postgresql role.
Luke Hoersten <luke@hoersten.org>
parents: 74
diff changeset
    56
d8c87a41cc6d Pleroma role updates. Added Postgresql role.
Luke Hoersten <luke@hoersten.org>
parents: 74
diff changeset
    57
# - name: restore
d8c87a41cc6d Pleroma role updates. Added Postgresql role.
Luke Hoersten <luke@hoersten.org>
parents: 74
diff changeset
    58
#   postgresql_db:
d8c87a41cc6d Pleroma role updates. Added Postgresql role.
Luke Hoersten <luke@hoersten.org>
parents: 74
diff changeset
    59
#     state: "restore"
d8c87a41cc6d Pleroma role updates. Added Postgresql role.
Luke Hoersten <luke@hoersten.org>
parents: 74
diff changeset
    60
#     db: "{{pleroma_user}}"
d8c87a41cc6d Pleroma role updates. Added Postgresql role.
Luke Hoersten <luke@hoersten.org>
parents: 74
diff changeset
    61
#     target: "/tmp/{{pleroma_user}}-backup.sql"
d8c87a41cc6d Pleroma role updates. Added Postgresql role.
Luke Hoersten <luke@hoersten.org>
parents: 74
diff changeset
    62
#     login_user: "{{pleroma_user}}"
d8c87a41cc6d Pleroma role updates. Added Postgresql role.
Luke Hoersten <luke@hoersten.org>
parents: 74
diff changeset
    63
#     login_password: "{{pleroma_db_passwd}}"
d8c87a41cc6d Pleroma role updates. Added Postgresql role.
Luke Hoersten <luke@hoersten.org>
parents: 74
diff changeset
    64
#     login_host: "{{pleroma_db_host}}"
d8c87a41cc6d Pleroma role updates. Added Postgresql role.
Luke Hoersten <luke@hoersten.org>
parents: 74
diff changeset
    65
#   when: "{{pleroma_restore_db}}"
60
48a3a65119d5 Initial commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    66
48a3a65119d5 Initial commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    67
- name: migrate db
48a3a65119d5 Initial commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    68
  become: yes
48a3a65119d5 Initial commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    69
  become_user: "{{pleroma_user}}"
48a3a65119d5 Initial commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    70
  command: "{{item}}"
48a3a65119d5 Initial commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    71
  args:
48a3a65119d5 Initial commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    72
    chdir: "~{{pleroma_user}}/pleroma/"
48a3a65119d5 Initial commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    73
  with_items:
48a3a65119d5 Initial commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    74
    - "mix local.hex --force"
48a3a65119d5 Initial commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    75
    - "mix local.rebar --force"
48a3a65119d5 Initial commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    76
    - "mix deps.get"
74
dc20ec78acdd Location of mix changed.
Luke Hoersten <luke@hoersten.org>
parents: 73
diff changeset
    77
    - "mix ecto.migrate"
62
63586cf10d46 Added more config variables to pleroma.
Luke Hoersten <luke@hoersten.org>
parents: 60
diff changeset
    78
  notify: restart pleroma
65
4538ad030906 Moved mix commands to prod.
Luke Hoersten <luke@hoersten.org>
parents: 64
diff changeset
    79
  environment:
4538ad030906 Moved mix commands to prod.
Luke Hoersten <luke@hoersten.org>
parents: 64
diff changeset
    80
    MIX_ENV: "prod"
60
48a3a65119d5 Initial commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    81
48a3a65119d5 Initial commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    82
- name: install pleroma systemd service
48a3a65119d5 Initial commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    83
  template:
48a3a65119d5 Initial commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    84
    src: "pleroma.service.j2"
67
bd34ae082697 Split out nginx sites.
Luke Hoersten <luke@hoersten.org>
parents: 66
diff changeset
    85
    dest: "/lib/systemd/system/{{pleroma_user}}.service"
60
48a3a65119d5 Initial commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    86
    owner: "{{pleroma_user}}"
48a3a65119d5 Initial commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    87
    group: "{{pleroma_user}}"
48a3a65119d5 Initial commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    88
    mode: "0770"
48a3a65119d5 Initial commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    89
  become: yes
48a3a65119d5 Initial commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    90
48a3a65119d5 Initial commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    91
- name: enable pleroma systemd service
67
bd34ae082697 Split out nginx sites.
Luke Hoersten <luke@hoersten.org>
parents: 66
diff changeset
    92
  systemd: name="{{pleroma_user}}" enabled="yes" state="started"
60
48a3a65119d5 Initial commit.
Luke Hoersten <luke@hoersten.org>
parents:
diff changeset
    93
  become: yes
75
d8c87a41cc6d Pleroma role updates. Added Postgresql role.
Luke Hoersten <luke@hoersten.org>
parents: 74
diff changeset
    94
d8c87a41cc6d Pleroma role updates. Added Postgresql role.
Luke Hoersten <luke@hoersten.org>
parents: 74
diff changeset
    95
d8c87a41cc6d Pleroma role updates. Added Postgresql role.
Luke Hoersten <luke@hoersten.org>
parents: 74
diff changeset
    96
# - name: backup db
d8c87a41cc6d Pleroma role updates. Added Postgresql role.
Luke Hoersten <luke@hoersten.org>
parents: 74
diff changeset
    97
#   postgresql_db:
d8c87a41cc6d Pleroma role updates. Added Postgresql role.
Luke Hoersten <luke@hoersten.org>
parents: 74
diff changeset
    98
#     state: "dump"
d8c87a41cc6d Pleroma role updates. Added Postgresql role.
Luke Hoersten <luke@hoersten.org>
parents: 74
diff changeset
    99
#     db: "{{pleroma_user}}"
d8c87a41cc6d Pleroma role updates. Added Postgresql role.
Luke Hoersten <luke@hoersten.org>
parents: 74
diff changeset
   100
#     target: "/tmp/{{pleroma_user}}-backup.sql"
d8c87a41cc6d Pleroma role updates. Added Postgresql role.
Luke Hoersten <luke@hoersten.org>
parents: 74
diff changeset
   101
#     login_user: "{{pleroma_user}}"
d8c87a41cc6d Pleroma role updates. Added Postgresql role.
Luke Hoersten <luke@hoersten.org>
parents: 74
diff changeset
   102
#     login_password: "{{pleroma_db_passwd}}"
d8c87a41cc6d Pleroma role updates. Added Postgresql role.
Luke Hoersten <luke@hoersten.org>
parents: 74
diff changeset
   103
#     login_host: "{{pleroma_db_host}}"
d8c87a41cc6d Pleroma role updates. Added Postgresql role.
Luke Hoersten <luke@hoersten.org>
parents: 74
diff changeset
   104
d8c87a41cc6d Pleroma role updates. Added Postgresql role.
Luke Hoersten <luke@hoersten.org>
parents: 74
diff changeset
   105
d8c87a41cc6d Pleroma role updates. Added Postgresql role.
Luke Hoersten <luke@hoersten.org>
parents: 74
diff changeset
   106
d8c87a41cc6d Pleroma role updates. Added Postgresql role.
Luke Hoersten <luke@hoersten.org>
parents: 74
diff changeset
   107
d8c87a41cc6d Pleroma role updates. Added Postgresql role.
Luke Hoersten <luke@hoersten.org>
parents: 74
diff changeset
   108
d8c87a41cc6d Pleroma role updates. Added Postgresql role.
Luke Hoersten <luke@hoersten.org>
parents: 74
diff changeset
   109
# pg_dump -U pleroma_nth_io -h pleroma.ctzpnw3lfkwz.us-east-1.rds.amazonaws.com pleroma_nth_io -f pleroma_nth_io_dump.sql