roles/pleroma/tasks/main.yaml
author Luke Hoersten <luke@hoersten.org>
Sat, 19 Jan 2019 11:48:07 -0600
changeset 70 2cfe2fb975a8
parent 69 be979818d483
child 73 3e6344570822
permissions -rw-r--r--
Added readme.

---

- name: add erland solutions key
  become: yes
  apt_key: "url=http://packages.erlang-solutions.com/debian/erlang_solutions.asc"

- name: install erland solutions repo
  become: yes
  apt_repository: repo="deb http://binaries.erlang-solutions.com/debian bionic contrib"

- name: update apt package cache
  become: yes
  apt: upgrade="dist" update_cache="yes" cache_valid_time="3600"

- name: install extra apt packages
  become: yes
  apt: name="{{item}}"
  with_items:
    - "postgresql"
    - "esl-erlang"
    - "elixir"
    - "build-essential"
    - "git"

- name: add users
  become: yes
  user: name="{{pleroma_user}}" shell="/bin/bash"

- name: checkout plemora
  become: yes
  become_user: "{{pleroma_user}}"
  git:
    repo: "https://git.pleroma.social/pleroma/pleroma.git"
    dest: "~{{pleroma_user}}/pleroma"
    force: yes

- name: install pleroma config files
  template:
    src: "{{item}}.j2"
    dest: "~{{pleroma_user}}/pleroma/config/{{item}}"
    owner: "{{pleroma_user}}"
    group: "{{pleroma_user}}"
    mode: "0775"
  become: yes
  become_user: "{{pleroma_user}}"
  with_items:
    - "setup_db.psql"
    - "prod.secret.exs"
  notify: restart pleroma

- name: install pleroma psql
  become: yes
  become_user: "{{pleroma_db_superuser}}"
  command: "psql -f ~{{pleroma_user}}/pleroma/config/setup_db.psql -h {{pleroma_db_host}}"
  notify: restart pleroma
  environment:
    PGUSER: "{{pleroma_db_superuser}}"
    PGPASSWORD: "{{pleroma_db_superpass}}"

- name: migrate db
  become: yes
  become_user: "{{pleroma_user}}"
  command: "{{item}}"
  args:
    chdir: "~{{pleroma_user}}/pleroma/"
  with_items:
    - "mix local.hex --force"
    - "mix local.rebar --force"
    - "mix deps.get"
    # - "mix ecto.migrate"
  notify: restart pleroma
  environment:
    MIX_ENV: "prod"

- name: install pleroma systemd service
  template:
    src: "pleroma.service.j2"
    dest: "/lib/systemd/system/{{pleroma_user}}.service"
    owner: "{{pleroma_user}}"
    group: "{{pleroma_user}}"
    mode: "0770"
  become: yes

- name: enable pleroma systemd service
  systemd: name="{{pleroma_user}}" enabled="yes" state="started"
  become: yes