diff --git a/playbook.yml b/playbook.yml index b1c037e..c5ee72a 100644 --- a/playbook.yml +++ b/playbook.yml @@ -1,12 +1,12 @@ --- -- name: Initialising the playbook. +- name: Gathering user's configuration. hosts: all roles: - init tags: - always -- name: Setting up the Pleroma database. +- name: Installing and configuring the PostgreSQL engine. hosts: pleroma_database become: yes become_method: sudo @@ -14,6 +14,19 @@ - pleroma-database tags: - pleroma-database + vars: + pleroma_database_installation: True + +- name: Performing database administration. + hosts: pleroma_database + become: yes + become_method: sudo + roles: + - pleroma-database + tags: + - pleroma-database + vars: + pleroma_database_administration: True - name: Setting up Pleroma. hosts: pleroma_main diff --git a/roles/pleroma-database/tasks/main.yml b/roles/pleroma-database/tasks/main.yml index 2363f9b..b6663f5 100644 --- a/roles/pleroma-database/tasks/main.yml +++ b/roles/pleroma-database/tasks/main.yml @@ -3,6 +3,7 @@ apk: name: "{{ pleroma_postgres_packages }}" state: present + when: pleroma_database_installation | default(False) - name: Postgres -- Ensure that the database is initialised. command: @@ -10,6 +11,7 @@ - /etc/init.d/postgresql - setup creates: /var/lib/postgresql/11/data/postgresql.conf + when: pleroma_database_installation | default(False) - name: Postgres -- Ensuring that the additional directories exist. file: @@ -21,6 +23,7 @@ loop: - "{{ pleroma_postgres_log_dir }}" - "{{ pleroma_postgres_confd }}" + when: pleroma_database_installation | default(False) - name: Postgres -- Ensuring that PostgreSQL is configured. template: @@ -32,6 +35,8 @@ loop: - { src: etc_postgresql_pg_hba.conf.j2, dest: "{{ pleroma_postgres_base_conf }}/pg_hba.conf" } - { src: etc_postgresql_confd_postgresql_override.conf, dest: "{{ pleroma_postgres_confd }}/postgresql_override.conf" } + when: pleroma_database_installation | default(False) + notify: "restart postgres" - name: Postgres -- Ensuring that the symlink to the override config is present. file: @@ -41,6 +46,8 @@ path: "{{ pleroma_postgres_confd_symlink }}" src: "{{ pleroma_postgres_confd }}" state: link + when: pleroma_database_installation | default(False) + notify: "restart postgres" - name: Postgres -- Ensuring that the override config is included in the main config. lineinfile: @@ -51,12 +58,14 @@ path: "{{ pleroma_postgres_base_conf }}/postgresql.conf" regexp: ^.*include\s=\s'.*'.*$ state: present + when: pleroma_database_installation | default(False) + notify: "restart postgres" - name: Postgres -- Ensuring that PostgreSQL is enabled and started. service: name: postgresql enabled: yes - state: restarted + when: pleroma_database_installation | default(False) - name: Postgres -- Ensuring that Postgres is available before continuing. wait_for: @@ -65,6 +74,7 @@ host: localhost port: 5432 state: started + when: pleroma_database_administration | default(False) - name: Postgres -- Ensuring that the database user {{ pleroma.config.db.user }} exists. become_user: postgres @@ -77,6 +87,7 @@ state: present vars: ansible_ssh_pipelining: true + when: pleroma_database_administration | default(False) - name: Postgres -- Ensuring that the database {{ pleroma.config.db.name }} exists. become_user: postgres @@ -89,6 +100,7 @@ state: present vars: ansible_ssh_pipelining: true + when: pleroma_database_administration | default(False) - name: Postgres -- Ensuring the PostgreSQL extensions is added to the database. become_user: postgres @@ -103,3 +115,4 @@ - uuid-ossp vars: ansible_ssh_pipelining: true + when: pleroma_database_administration | default(False)