2015-05-28 11:32:57 +02:00
|
|
|
---
|
2019-03-26 18:41:03 +01:00
|
|
|
- block:
|
|
|
|
- name: Check if the new postgresql data directory exists
|
|
|
|
stat: path={{ psql_data_dir }}
|
|
|
|
register: postgresql_data_dir
|
|
|
|
|
|
|
|
- name: Stop the postgresql service while reconfiguring the data directory
|
|
|
|
service: name=postgresql state=stopped
|
|
|
|
when: postgresql_data_dir.stat.isdir is not defined
|
|
|
|
|
|
|
|
- name: Create the postgresql data directory if it is not in the default place
|
|
|
|
file: dest={{ psql_data_dir }} owner=postgres group=postgres mode=700 recurse=yes state=directory
|
|
|
|
|
|
|
|
- name: Set the postgresql data dir if it is different from the default
|
|
|
|
become: True
|
|
|
|
become_user: postgres
|
|
|
|
action: configfile path={{ psql_conf_dir }}/postgresql.conf key=data_directory value="'{{ psql_data_dir }}'"
|
|
|
|
|
|
|
|
- name: Copy the postgresql data directory into the new place
|
|
|
|
shell: '[ "/var/lib/postgresql/{{ psql_version }}/main" != "{{ psql_data_dir }}" ] && cp -a /var/lib/postgresql/{{ psql_version }}/main/* {{ psql_data_dir }}'
|
|
|
|
args:
|
|
|
|
creates: '{{ psql_data_dir }}/main/base'
|
|
|
|
when: postgresql_data_dir.stat.isdir is not defined
|
|
|
|
|
|
|
|
- name: Start the postgresql service that will use the new data directory
|
|
|
|
service: name=postgresql state=started
|
|
|
|
when: postgresql_data_dir.stat.isdir is not defined
|
2015-05-28 11:32:57 +02:00
|
|
|
|
|
|
|
when: psql_use_alternate_data_dir
|
2016-03-07 19:18:46 +01:00
|
|
|
tags: [ 'postgresql', 'postgres', 'pg_conf' ]
|
2015-05-28 11:32:57 +02:00
|
|
|
|
2017-08-23 14:06:58 +02:00
|
|
|
- name: Set some postgresql configuration parameters that require a db restart
|
2017-03-07 13:12:36 +01:00
|
|
|
become: True
|
|
|
|
become_user: postgres
|
2016-12-18 19:12:51 +01:00
|
|
|
action: configfile path={{ psql_conf_dir }}/postgresql.conf key={{ item.name }} value="{{ item.value }}"
|
2016-03-02 16:44:43 +01:00
|
|
|
with_items: '{{ psql_conf_parameters }}'
|
2015-05-28 11:32:57 +02:00
|
|
|
when: item.set == 'True'
|
|
|
|
notify: Restart postgresql
|
2016-03-07 19:18:46 +01:00
|
|
|
tags: [ 'postgresql', 'postgres', 'pg_conf' ]
|
2015-05-28 11:32:57 +02:00
|
|
|
|
2017-08-23 14:06:58 +02:00
|
|
|
- name: Set the postgresql logging configuration parameters
|
|
|
|
become: True
|
|
|
|
become_user: postgres
|
|
|
|
action: configfile path={{ psql_conf_dir }}/postgresql.conf key={{ item.name }} value="{{ item.value }}"
|
2017-08-23 15:05:03 +02:00
|
|
|
with_items: '{{ psql_log_configuration }}'
|
2017-08-23 14:06:58 +02:00
|
|
|
when: item.set == 'True'
|
|
|
|
notify: Reload postgresql
|
|
|
|
tags: [ 'postgresql', 'postgres', 'pg_conf', 'pg_conf_log' ]
|
|
|
|
|
|
|
|
- name: Set the postgresql autovacuum configuration parameters
|
|
|
|
become: True
|
|
|
|
become_user: postgres
|
|
|
|
action: configfile path={{ psql_conf_dir }}/postgresql.conf key={{ item.name }} value="{{ item.value }}"
|
2017-08-23 15:05:03 +02:00
|
|
|
with_items: '{{ psql_autovacuum_configuration }}'
|
2017-08-23 14:06:58 +02:00
|
|
|
when: item.set == 'True'
|
|
|
|
notify: Reload postgresql
|
2017-08-23 15:05:03 +02:00
|
|
|
tags: [ 'postgresql', 'postgres', 'pg_conf', 'pg_conf_autovacuum' ]
|
2017-08-23 14:06:58 +02:00
|
|
|
|