---

### tags:

- name: "Create/Resize LVM for datadir"
  include_role:
    name: lvm_with_hetzner_volumes
  vars:
    lvm_with_hetzner_volumes__volprefix: postgres_datadir
    lvm_with_hetzner_volumes__volsize: "{{ postgres_pgdatadir_lvm_hcloudvol_size }}"
    lvm_with_hetzner_volumes__volcount: "{{ postgres_pgdatadir_lvm_hcloudvol_count }}"
    lvm_with_hetzner_volumes__mountpath: "{{ postgres_pgdatadir_lvm_hcloudvol_mountpath }}"

# Minimal requirements for postgres
- name: Include Base Requirements
  include_tasks: base-requirements.yml
  tags:
    - postgres-exporter

# Master requirements for postgres
- name: Include Master Requirements
  include_tasks: master-requirements.yml
  when: server_type == "master"

# Slave requirements for postgres
- name: Include Slave Requirements
  include_tasks: slave-requirements.yml
  when: server_type == "slave"

# Slave requirements for postgres
- name: Create/Resize LVM for Backup
  include_role:
    name: lvm_with_hetzner_volumes
  vars:
    lvm_with_hetzner_volumes__volprefix: "postgres-backup"
    lvm_with_hetzner_volumes__volsize: "{{ postgres_backup_volume_size }}"
    lvm_with_hetzner_volumes__volcount: "{{ postgres_backup_volume_count }}"
    lvm_with_hetzner_volumes__mountpath: "{{ backup_directory }}"
  when: server_type == "slave"
  args:
    apply:
      tags:
        - backup-requirements
  tags:
    - backup-requirements


