This repository has been archived on 2023-05-06. You can view files and clone it, but cannot push or open issues or pull requests.
pleroma-ansible-playbook/roles/pleroma-backend/tasks/main.yml
Dan Anglin b03c997960
change: add a site playbook to the project.
This merge request changes the project from a single role project to a
single playbook project with multiple plays and roles. The single
playbook has multiple plays with each having its own role to
install and configure the different components to run Pleroma.
(postgres database, pleroma backend and nginx).

Certain playbooks can be executed by specifying the
relevant tags.

This change is the first of many changes to start supporting
installations on both single and multiple hosts.

This change includes also includes:

- inventory file.
- host_vars directory for users to add their variables.
- an init playbook to merge the default and the user defined config for Pleroma.
- users can now specify whether to validate certs when performing acme
challenges (default: true).
- more task templating.
2019-10-24 22:51:53 +01:00

99 lines
2.6 KiB
YAML

---
# TODO: Do we need ncurses?
- name: Ensure Pleroma dependencies are installed.
apk:
name: unzip, ncurses
state: present
- name: Ensure group '{{ pleroma_user.group }}' exists.
group:
gid: "{{ pleroma_user.id }}"
name: "{{ pleroma_user.group }}"
state: present
system: yes
- name: Ensure user '{{ pleroma_user.name }}' exists.
user:
group: "{{ pleroma_user.group }}"
home: "{{ pleroma_user.home }}"
name: "{{ pleroma_user.name }}"
shell: "{{ pleroma_user.shell }}"
state: present
system: yes
uid: "{{ pleroma_user.id }}"
- name: Ensure the Pleroma data and config directories exists.
file:
name: "{{ item }}"
state: directory
mode: '0700'
owner: "{{ pleroma_user.name }}"
group: "{{ pleroma_user.group }}"
loop:
- "{{ pleroma_config_dir }}"
- "{{ pleroma_base_data_dir }}"
- "{{ pleroma_uploads_dir }}"
- "{{ pleroma_static_dir }}"
- name: Ensuring that the release build of pleroma is downloaded.
get_url:
url: "{{ pleroma_download_url }}"
dest: "{{ pleroma_download_dest }}"
- name: Unzipping the release build of pleroma.
unarchive:
remote_src: yes
src: "{{ pleroma_download_dest }}"
dest: /tmp
owner: "{{ pleroma_user.name }}"
group: "{{ pleroma_user.group }}"
- name: Ensuring that Pleroma is installed.
shell: |
find /tmp/release/ -mindepth 1 -maxdepth 1 | xargs -I dir mv dir {{ pleroma_user.home }}
args:
creates: "{{ pleroma_user.home }}/bin/pleroma"
- name: Ensuring the configuration file is set.
template:
src: etc_pleroma_config.exs.j2
dest: "{{ pleroma_config_dir }}/config.exs"
owner: "{{ pleroma_user.name }}"
group: "{{ pleroma_user.group }}"
mode: '0400'
- name: Running database migrations.
command:
argv:
- pleroma_ctl
- migrate
environment:
PATH: "{{ ansible_env.PATH }}:/opt/pleroma/bin"
- name: Ensuring that folder permissions are set properly in /opt/pleroma.
shell: |
find {{ pleroma_user.home }} -mindepth 1 -maxdepth 1 -type d | xargs -I dir chmod 0700 dir
find {{ pleroma_user.home }} -mindepth 1 -maxdepth 1 -type d | xargs -I dir chown -R {{ pleroma_user.name }}:{{ pleroma_user.group }} dir
- name: Setting up the Pleroma service.
copy:
src: "{{ pleroma_user.home }}/installation/init.d/pleroma"
dest: /etc/init.d/pleroma
remote_src: yes
owner: root
group: root
mode: '0700'
- name: Ensuring that the Pleroma service is enabled and started.
service:
name: pleroma
enabled: yes
state: restarted
- name: Cleaning up
file:
path: "{{ item }}"
state: absent
loop:
- "{{ pleroma_download_dest }}"
- /tmp/release