# vim: ft=yaml.ansible
---
- name: Create subfolder for Mastodon data
  file:
    name: "{{ services.mastodon.volume_folder }}/mastodon_data"
    state: directory
    owner: "991"
    mode: u=rwx,g=rx,o=rx

- name: Create subfolder for PostgreSQL data
  file:
    name: "{{ services.mastodon.volume_folder }}/postgres_data"
    state: directory
    owner: "70"
    mode: u=rwx,go=

- name: Create subfolder for PostgreSQL config
  file:
    name: "{{ services.mastodon.volume_folder }}/postgres_config"
    state: directory
    owner: root
    mode: u=rwx,g=rx,o=rx

- name: Create subfolder for Redis data
  file:
    name: "{{ services.mastodon.volume_folder }}/redis_data"
    state: directory
    owner: "999"
    group: "1000"
    mode: u=rwx,g=rx,o=rx

- name: Upload mastodon.env file
  template:
    src: mastodon/env.j2
    dest: "{{ services.mastodon.volume_folder }}/mastodon.env"

- name: Upload vhost config for Mastodon domain
  copy:
    src: vhost/mastodon
    dest: "{{ services.nginx_proxy.volume_folder }}/vhost/{{ services.mastodon.domain }}"

- name: Upload PostgreSQL config
  copy:
    src: mastodon/postgresql.conf
    dest: "{{ services.mastodon.volume_folder }}/postgres_config/postgresql.conf"