diff --git a/defaults/main.yml b/defaults/main.yml index 5fc05a7..020cc50 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -7,6 +7,10 @@ postgresql_group: postgres postgresql_unix_socket_dir: /var/run/postgresql +postgresql_global_config_options: + - option: unix_socket_directory + value: '{{ postgresql_unix_socket_dir }}' + # Debian only. Used to generate the locales used by PostgreSQL databases. postgresql_locales: - 'en_US.UTF-8' diff --git a/tasks/initialize.yml b/tasks/initialize.yml index 44ffd9b..3196ba6 100644 --- a/tasks/initialize.yml +++ b/tasks/initialize.yml @@ -6,6 +6,21 @@ mode: 0644 notify: restart postgresql +- name: Configure global settings. + lineinfile: + dest: "{{ postgresql_config_path }}/postgresql.conf" + regexp: "^#?{{ item.option }}.+$" + line: "{{ item.option }} = '{{ item.value }}'" + state: "{{ item.state | default('present') }}" + with_items: "{{ postgresql_global_config_options }}" + notify: restart postgresql + +- name: Ensure PostgreSQL unix socket dir exists. + file: + path: "{{ postgresql_unix_socket_dir }}" + state: directory + mode: 0777 + - name: Ensure PostgreSQL data directory exists. file: path: "{{ postgresql_data_dir }}" diff --git a/tasks/variables.yml b/tasks/variables.yml index 08870f4..a0b622d 100644 --- a/tasks/variables.yml +++ b/tasks/variables.yml @@ -32,3 +32,8 @@ set_fact: postgresql_bin_path: "{{ __postgresql_bin_path }}" when: postgresql_bin_path is not defined + +- name: Define postgresql_config_path. + set_fact: + postgresql_config_path: "{{ __postgresql_config_path }}" + when: postgresql_config_path is not defined diff --git a/vars/Debian-8.yml b/vars/Debian-8.yml index 9fd995a..f6ad232 100644 --- a/vars/Debian-8.yml +++ b/vars/Debian-8.yml @@ -2,6 +2,7 @@ __postgresql_version: "9.4" __postgresql_data_dir: "/var/lib/postgresql/{{ __postgresql_version }}/main" __postgresql_bin_path: "/usr/lib/postgresql/{{ __postgresql_version }}/bin" +__postgresql_config_path: "/etc/postgresql/{{ __postgresql_version }}/main" __postgresql_daemon: postgresql __postgresql_packages: - postgresql diff --git a/vars/RedHat.yml b/vars/RedHat.yml index 43ffeb6..1d5c517 100644 --- a/vars/RedHat.yml +++ b/vars/RedHat.yml @@ -2,6 +2,7 @@ __postgresql_version: "9.2" __postgresql_data_dir: "/var/lib/pgsql/data" __postgresql_bin_path: "/usr/bin" +__postgresql_config_path: "/var/lib/pgsql/data" __postgresql_daemon: postgresql __postgresql_packages: - postgresql diff --git a/vars/Ubuntu-14.yml b/vars/Ubuntu-14.yml index cd09ffa..bd6c174 100644 --- a/vars/Ubuntu-14.yml +++ b/vars/Ubuntu-14.yml @@ -2,6 +2,7 @@ __postgresql_version: "9.3" __postgresql_data_dir: "/var/lib/postgresql/{{ __postgresql_version }}/main" __postgresql_bin_path: "/usr/lib/postgresql/{{ __postgresql_version }}/bin" +__postgresql_config_path: "/etc/postgresql/{{ __postgresql_version }}/main" __postgresql_daemon: postgresql __postgresql_packages: - postgresql diff --git a/vars/Ubuntu-16.yml b/vars/Ubuntu-16.yml index 77fde1f..cf2ebb8 100644 --- a/vars/Ubuntu-16.yml +++ b/vars/Ubuntu-16.yml @@ -2,6 +2,7 @@ __postgresql_version: "9.5" __postgresql_data_dir: "/var/lib/postgresql/{{ __postgresql_version }}/main" __postgresql_bin_path: "/usr/lib/postgresql/{{ __postgresql_version }}/bin" +__postgresql_config_path: "/etc/postgresql/{{ __postgresql_version }}/main" __postgresql_daemon: postgresql __postgresql_packages: - postgresql