diff --git a/library/roles/postgresql/tasks/configure-access.yml b/library/roles/postgresql/tasks/configure-access.yml index 384aa723..f2871b2c 100644 --- a/library/roles/postgresql/tasks/configure-access.yml +++ b/library/roles/postgresql/tasks/configure-access.yml @@ -11,10 +11,10 @@ - '{{ psql_db_data | default([]) }}' - allowed_hosts when: - - psql_listen_on_ext_int + - psql_listen_on_ext_int | bool - psql_db_data is defined - item.1 is defined - - not psql_force_ssl_client_connection + - not psql_force_ssl_client_connection | bool notify: Reload postgresql tags: [ 'postgresql', 'postgres', 'pg_hba', 'pg_db' ] @@ -24,10 +24,10 @@ - '{{ psql_db_data | default([]) }}' - allowed_hosts when: - - psql_listen_on_ext_int + - psql_listen_on_ext_int | bool - psql_db_data is defined - item.1 is defined - - psql_force_ssl_client_connection + - psql_force_ssl_client_connection | bool notify: Reload postgresql tags: [ 'postgresql', 'postgres', 'pg_hba', 'pg_db' ] @@ -46,16 +46,14 @@ action: configfile path={{ psql_conf_dir }}/postgresql.conf key=listen_addresses value="'*'" register: restart_postgresql when: - - psql_listen_on_ext_int - - psql_db_data is defined + - psql_listen_on_ext_int | bool tags: [ 'postgresql', 'postgres', 'pg_conf' ] - name: If postgresql is only accessed from localhost make it listen only on the localhost interface action: configfile path={{ psql_conf_dir }}/postgresql.conf key=listen_addresses value="'localhost'" register: restart_postgresql when: - - not psql_listen_on_ext_int - - psql_db_data is defined + - not psql_listen_on_ext_int | bool tags: [ 'postgresql', 'postgres', 'pg_conf' ] - name: Log the connections @@ -74,8 +72,7 @@ action: configfile path={{ psql_conf_dir }}/postgresql.conf key=log_hostname value="on" register: restart_postgresql when: - - psql_listen_on_ext_int - - psql_db_data is defined + - psql_listen_on_ext_int | bool tags: [ 'postgresql', 'postgres', 'pg_conf' ] - name: Set the correct permissions to the postgresql files @@ -88,6 +85,6 @@ - name: Restart the postgresql server after changing parameters that need a restart service: name=postgresql state=restarted when: - - postgresql_enabled - - ( restart_postgresql is defined ) and ( restart_postgresql is changed ) + - restart_postgresql is changed + ignore_errors: True tags: [ 'postgresql', 'postgres', 'pg_hba', 'pg_conf' ] diff --git a/library/roles/postgresql/tasks/main.yml b/library/roles/postgresql/tasks/main.yml index 51b98e91..1204603d 100644 --- a/library/roles/postgresql/tasks/main.yml +++ b/library/roles/postgresql/tasks/main.yml @@ -11,25 +11,24 @@ when: psql_postgresql_install - import_tasks: psql-kernel-sharedmem.yml when: - - psql_postgresql_install - - psql_set_shared_memory + - psql_postgresql_install | bool + - psql_set_shared_memory | bool - import_tasks: configure-access.yml when: - - psql_postgresql_install - - psql_db_data is defined + - psql_postgresql_install | bool - import_tasks: postgresql-service-status.yml when: psql_postgresql_install - import_tasks: postgres_pgpool.yml when: psql_pgpool_install - import_tasks: manage_pg_db.yml when: - - psql_postgresql_install - - psql_db_data is defined + - psql_postgresql_install | bool + - psql_db_data is defined | bool - import_tasks: postgresql-backup.yml when: - - psql_postgresql_install + - psql_postgresql_install | bool - import_tasks: pgpool-ii.yml - when: psql_pgpool_service_install + when: psql_pgpool_service_install | bool - import_tasks: postgresql-letsencrypt-acmetool.yml when: - letsencrypt_acme_install is defined diff --git a/library/roles/postgresql/tasks/postgresql-backup.yml b/library/roles/postgresql/tasks/postgresql-backup.yml index a88e364d..874193e6 100644 --- a/library/roles/postgresql/tasks/postgresql-backup.yml +++ b/library/roles/postgresql/tasks/postgresql-backup.yml @@ -1,7 +1,6 @@ --- - name: Backup script for the postgresql database(s) copy: src=postgresql-backup.sh dest=/usr/local/sbin/postgresql-backup owner=root mode=0744 - copy: src=postgresql-backup.cron dest=/usr/local/sbin/postgresql-backup.cron owner=root mode=0744 tags: [ 'pgbackup_cron', 'pg_backup', 'postgresql', 'postgres' ] - name: daily cron job for the postgresql database(s) backup