postgresql role: some cleanup.

This commit is contained in:
Andrea Dell'Amico 2019-12-12 21:01:51 +01:00
parent e6abbf1791
commit f2c7de88c9
3 changed files with 16 additions and 21 deletions

View File

@ -11,10 +11,10 @@
- '{{ psql_db_data | default([]) }}' - '{{ psql_db_data | default([]) }}'
- allowed_hosts - allowed_hosts
when: when:
- psql_listen_on_ext_int - psql_listen_on_ext_int | bool
- psql_db_data is defined - psql_db_data is defined
- item.1 is defined - item.1 is defined
- not psql_force_ssl_client_connection - not psql_force_ssl_client_connection | bool
notify: Reload postgresql notify: Reload postgresql
tags: [ 'postgresql', 'postgres', 'pg_hba', 'pg_db' ] tags: [ 'postgresql', 'postgres', 'pg_hba', 'pg_db' ]
@ -24,10 +24,10 @@
- '{{ psql_db_data | default([]) }}' - '{{ psql_db_data | default([]) }}'
- allowed_hosts - allowed_hosts
when: when:
- psql_listen_on_ext_int - psql_listen_on_ext_int | bool
- psql_db_data is defined - psql_db_data is defined
- item.1 is defined - item.1 is defined
- psql_force_ssl_client_connection - psql_force_ssl_client_connection | bool
notify: Reload postgresql notify: Reload postgresql
tags: [ 'postgresql', 'postgres', 'pg_hba', 'pg_db' ] tags: [ 'postgresql', 'postgres', 'pg_hba', 'pg_db' ]
@ -46,16 +46,14 @@
action: configfile path={{ psql_conf_dir }}/postgresql.conf key=listen_addresses value="'*'" action: configfile path={{ psql_conf_dir }}/postgresql.conf key=listen_addresses value="'*'"
register: restart_postgresql register: restart_postgresql
when: when:
- psql_listen_on_ext_int - psql_listen_on_ext_int | bool
- psql_db_data is defined
tags: [ 'postgresql', 'postgres', 'pg_conf' ] tags: [ 'postgresql', 'postgres', 'pg_conf' ]
- name: If postgresql is only accessed from localhost make it listen only on the localhost interface - 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'" action: configfile path={{ psql_conf_dir }}/postgresql.conf key=listen_addresses value="'localhost'"
register: restart_postgresql register: restart_postgresql
when: when:
- not psql_listen_on_ext_int - not psql_listen_on_ext_int | bool
- psql_db_data is defined
tags: [ 'postgresql', 'postgres', 'pg_conf' ] tags: [ 'postgresql', 'postgres', 'pg_conf' ]
- name: Log the connections - name: Log the connections
@ -74,8 +72,7 @@
action: configfile path={{ psql_conf_dir }}/postgresql.conf key=log_hostname value="on" action: configfile path={{ psql_conf_dir }}/postgresql.conf key=log_hostname value="on"
register: restart_postgresql register: restart_postgresql
when: when:
- psql_listen_on_ext_int - psql_listen_on_ext_int | bool
- psql_db_data is defined
tags: [ 'postgresql', 'postgres', 'pg_conf' ] tags: [ 'postgresql', 'postgres', 'pg_conf' ]
- name: Set the correct permissions to the postgresql files - 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 - name: Restart the postgresql server after changing parameters that need a restart
service: name=postgresql state=restarted service: name=postgresql state=restarted
when: when:
- postgresql_enabled - restart_postgresql is changed
- ( restart_postgresql is defined ) and ( restart_postgresql is changed ) ignore_errors: True
tags: [ 'postgresql', 'postgres', 'pg_hba', 'pg_conf' ] tags: [ 'postgresql', 'postgres', 'pg_hba', 'pg_conf' ]

View File

@ -11,25 +11,24 @@
when: psql_postgresql_install when: psql_postgresql_install
- import_tasks: psql-kernel-sharedmem.yml - import_tasks: psql-kernel-sharedmem.yml
when: when:
- psql_postgresql_install - psql_postgresql_install | bool
- psql_set_shared_memory - psql_set_shared_memory | bool
- import_tasks: configure-access.yml - import_tasks: configure-access.yml
when: when:
- psql_postgresql_install - psql_postgresql_install | bool
- psql_db_data is defined
- import_tasks: postgresql-service-status.yml - import_tasks: postgresql-service-status.yml
when: psql_postgresql_install when: psql_postgresql_install
- import_tasks: postgres_pgpool.yml - import_tasks: postgres_pgpool.yml
when: psql_pgpool_install when: psql_pgpool_install
- import_tasks: manage_pg_db.yml - import_tasks: manage_pg_db.yml
when: when:
- psql_postgresql_install - psql_postgresql_install | bool
- psql_db_data is defined - psql_db_data is defined | bool
- import_tasks: postgresql-backup.yml - import_tasks: postgresql-backup.yml
when: when:
- psql_postgresql_install - psql_postgresql_install | bool
- import_tasks: pgpool-ii.yml - import_tasks: pgpool-ii.yml
when: psql_pgpool_service_install when: psql_pgpool_service_install | bool
- import_tasks: postgresql-letsencrypt-acmetool.yml - import_tasks: postgresql-letsencrypt-acmetool.yml
when: when:
- letsencrypt_acme_install is defined - letsencrypt_acme_install is defined

View File

@ -1,7 +1,6 @@
--- ---
- name: Backup script for the postgresql database(s) - 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.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' ] tags: [ 'pgbackup_cron', 'pg_backup', 'postgresql', 'postgres' ]
- name: daily cron job for the postgresql database(s) backup - name: daily cron job for the postgresql database(s) backup