pleroma-otp/tasks/main.yaml
author Luke Hoersten <luke@hoersten.org>
Sun, 26 Apr 2020 14:14:18 -0500
changeset 94 7082ab4828c5
parent 93 976670b2ca63
child 97 33039e6345cd
permissions -rw-r--r--
Remove openssl configs.

---

- name: add users
  become: yes
  user: name="pleroma" shell="/bin/false" home="/opt/pleroma" system="yes"

- name: create config and data directory
  become: yes
  file:
    path: "{{item}}"
    state: "directory"
    mode: "0755"
  with_items:
    - "{{pleroma_data_dir}}"
    - "/etc/pleroma"
    - "/opt/pleroma"

- name: install pleroma config
  template:
    src: "config.exs.j2"
    dest: "/etc/pleroma/{{pleroma_instance}}.config.exs"
    owner: "pleroma"
    group: "pleroma"
    mode: "0600"
  become: yes
  notify: restart pleroma instance

- name: create instance data directory
  become: yes
  file:
    path: "{{item}}"
    state: "directory"
    owner: "pleroma"
    group: "pleroma"
    mode: "0755"
  with_items:
    - "{{pleroma_data_dir}}/{{pleroma_instance}}"
    - "{{pleroma_data_dir}}/{{pleroma_instance}}/uploads"
    - "{{pleroma_data_dir}}/{{pleroma_instance}}/static"
    - "{{pleroma_data_dir}}/{{pleroma_instance}}/static/emoji"

- name: install pleroma db schema file
  become: yes
  template:
    src: "setup_db.psql.j2"
    dest: "/tmp/setup_db_{{pleroma_instance}}.psql"
    owner: "{{pleroma_db_superuser}}"
    group: "{{pleroma_db_superuser}}"
    mode: "0600"
  changed_when: false

- name: install pleroma psql
  become: yes
  become_user: "{{pleroma_db_superuser}}"
  command: "psql -f /tmp/setup_db_{{pleroma_instance}}.psql"
  changed_when: false

- name: download and unarchive pleroma release
  become: yes
  unarchive:
    src: "{{pleroma_download_url}}"
    dest: "/tmp/"
    remote_src: yes
    creates: "/tmp/release"
  notify: restart pleroma instance

- name: install pleroma release
  become: yes
  copy: remote_src="True" src="/tmp/release/" dest="/opt/pleroma/" owner="pleroma" group="pleroma"
  notify: restart pleroma instance

- name: remove tmp release folder
  become: yes
  file: path="{{item}}" state="absent"
  with_items:
    - "/tmp/setup_db.psql"
    - "/tmp/release/"
  when: pleroma_cleanup_tmp

- import_tasks: s3-backup.yaml
  when: pleroma_s3_backup_enabled

- name: configure pleroma systemd service
  become: yes
  copy:
    src: "[email protected]"
    dest: "/lib/systemd/system/[email protected]"
  notify: restart pleroma instance

- name: ensure pleroma instance is enabled and started
  become: yes
  systemd: name="pleroma@{{pleroma_instance}}.service" enabled="yes" state="started"

- name: migrate db
  become: yes
  become_user: "pleroma"
  command: "/opt/pleroma/bin/pleroma_ctl migrate"
  args:
    chdir: "/opt/pleroma/"
  environment:
    PLEROMA_CONFIG_PATH: "/etc/pleroma/{{pleroma_instance}}.config.exs"
  changed_when: false