Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/ANXS/postgresql into fix_…
Browse files Browse the repository at this point in the history
…postgis_on_centos

Conflicts:
	README.md
	defaults/main.yml
	tasks/configure.yml
	tasks/extensions/postgis.yml
	tests/docker/group_vars/all.yml
	tests/docker/group_vars/postgresql.yml
	tests/vars.yml
	vars/xenial.yml
  • Loading branch information
Greg Clough committed Apr 3, 2018
2 parents 11ff6ee + f28e77f commit 90fb6e0
Show file tree
Hide file tree
Showing 13 changed files with 1,458 additions and 76 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ Icon
.Trashes
.vagrant
test
*.retry
17 changes: 9 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,17 @@ ansible-galaxy install ANXS.postgresql


#### Compatibility matrix
| Distribution / PostgreSQL | <= 9.2 | 9.3 | 9.4 | 9.5 | 9.6 |
| ------------------------- |:------:|:---:|:---:|:---:|:---:|
| Ubuntu 14.04 | :no_entry: | :white_check_mark:| :white_check_mark:| :white_check_mark:| :white_check_mark:|
| Ubuntu 16.04 | :no_entry: | :white_check_mark:| :white_check_mark:| :white_check_mark:| :white_check_mark:|
| Debian 8.x | :no_entry: | :white_check_mark:| :white_check_mark:| :white_check_mark:| :white_check_mark:|
| Debian 9.x | :no_entry: | :white_check_mark:| :white_check_mark:| :white_check_mark:| :white_check_mark:|
| Centos 6.x | :no_entry: | :white_check_mark:| :white_check_mark:| :white_check_mark:| :white_check_mark:|
| Centos 7.x | :no_entry: | :white_check_mark:| :white_check_mark:| :white_check_mark:| :white_check_mark:|
| Distribution / PostgreSQL | <= 9.2 | 9.3 | 9.4 | 9.5 | 9.6 | 10 | 11 |
| ------------------------- |:------:|:---:|:---:|:---:|:---:|:--:|:--:|
| Ubuntu 14.04 | :no_entry: | :white_check_mark:| :white_check_mark:| :white_check_mark:| :white_check_mark:| :grey_question:| :grey_question:|
| Ubuntu 16.04 | :no_entry: | :white_check_mark:| :white_check_mark:| :white_check_mark:| :white_check_mark:| :grey_question:| :grey_question:|
| Debian 8.x | :no_entry: | :white_check_mark:| :white_check_mark:| :white_check_mark:| :white_check_mark:| :grey_question:| :grey_question:|
| Debian 9.x | :no_entry: | :white_check_mark:| :white_check_mark:| :white_check_mark:| :white_check_mark:| :grey_question:| :grey_question:|
| CentOS 6.x | :no_entry: | :white_check_mark:| :white_check_mark:| :white_check_mark:| :white_check_mark:| :grey_question:| :grey_question:|
| CentOS 7.x | :no_entry: | :white_check_mark:| :white_check_mark:| :white_check_mark:| :white_check_mark:| :grey_question:| :grey_question:|

- :white_check_mark: - tested, works fine
- :grey_question: - will work in the future (help out if you can)
- :interrobang: - maybe works, not tested
- :no_entry: - PostgreSQL has reached EOL

Expand Down
31 changes: 30 additions & 1 deletion defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ postgresql_postgis_release_compatibility:
postgresql_ext_postgis_version: "{{ postgresql_postgis_release_compatibility.get(postgresql_version) }}"
postgresql_ext_postgis_version_terse: "{{ postgresql_ext_postgis_version | replace('.','') }}"

postgresql_ext_postgis_deps:
- libgeos-c1
- "postgresql-{{ postgresql_version }}-postgis-{{ postgresql_ext_postgis_version }}"
- "postgresql-{{ postgresql_version }}-postgis-scripts"

postgresql_ext_postgis_deps:
- libgeos-c1
- "postgresql-{{ postgresql_version }}-postgis-{{ postgresql_ext_postgis_version }}"
Expand Down Expand Up @@ -126,6 +131,7 @@ postgresql_ssl_ciphers:
- "@STRENGTH"
postgresql_ssl_prefer_server_ciphers: on
postgresql_ssl_ecdh_curve: "prime256v1"
postgresal_ssl_dh_params_file: "" # (>= 10)
postgresql_ssl_renegotiation_limit: 512MB # amount of data between renegotiations
postgresql_ssl_cert_file: "/etc/ssl/certs/ssl-cert-snakeoil.pem" # (>= 9.2)
postgresql_ssl_key_file: "/etc/ssl/private/ssl-cert-snakeoil.key" # (>= 9.2)
Expand Down Expand Up @@ -209,6 +215,7 @@ postgresql_bgwriter_flush_after: 0 # (>= 9.6) 0 disables,
postgresql_effective_io_concurrency: 1 # 1-1000; 0 disables prefetching
postgresql_max_worker_processes: 8 # (change requires restart)
postgresql_max_parallel_workers_per_gather: 0 # (>= 9.6) taken from max_worker_processes
postgresql_max_parallel_workers: 8 # (>= 10)
postgresql_old_snapshot_threshold: -1 # (>= 9.6) 1min-60d; -1 disables; 0 is immediate
# (change requires restart)
postgresql_backend_flush_after: 0 # (>= 9.6) 0 disables, default is 0
Expand Down Expand Up @@ -329,6 +336,15 @@ postgresql_wal_receiver_timeout: 60s
# time to wait before retrying to retrieve WAL after a failed attempt
postgresql_wal_retrieve_retry_interval: 5s # (>= 9.5)

# - Subscribers - (>= 10)

# These settings are ignored on a publisher.

postgresql_max_logical_replication_workers: 4 # (>= 10) taken from max_worker_processes
# (change requires restart)
postgresql_max_sync_workers_per_subscription: 2 # (>= 10) taken from max_logical_replication_workers


#------------------------------------------------------------------------------
# QUERY TUNING
#------------------------------------------------------------------------------
Expand Down Expand Up @@ -357,7 +373,9 @@ postgresql_cpu_index_tuple_cost: 0.005 # same scale as above
postgresql_cpu_operator_cost: 0.0025 # same scale as above
postgresql_parallel_tuple_cost: 0.1 # same scale as above (>= 9.6)
postgresql_parallel_setup_cost: 1000.0 # same scale as above (>= 9.6)
postgresql_min_parallel_relation_size: 8MB # (>= 9.6)
postgresql_min_parallel_relation_size: 8MB # (= 9.6) replaced by below two parameters in 10
postgresql_min_parallel_table_scan_size: 8MB # (>= 10)
postgresql_min_parallel_index_scan_size: 512kB # (>= 10)
postgresql_effective_cache_size: 128MB


Expand Down Expand Up @@ -509,6 +527,7 @@ postgresql_log_line_prefix: "%t "
# log lock waits >= deadlock_timeout
postgresql_log_lock_waits: off
postgresql_log_statement: "none" # none, ddl, mod, all
postgresql_log_replication_commands: off
# log temporary files equal or larger
postgresql_log_temp_files: -1
postgresql_log_timezone: "UTC"
Expand Down Expand Up @@ -598,6 +617,7 @@ postgresql_bytea_output: "hex" # hex, escape
postgresql_xmlbinary: "base64"
postgresql_xmloption: "content"
postgresql_gin_fuzzy_search_limit: 0 # (<= 9.2)
postgresql_gin_pending_list_limit: 4MB # (>= 9.5)


# - Locale and Formatting -
Expand Down Expand Up @@ -649,6 +669,11 @@ postgresql_max_locks_per_transaction: 64 # min 10
# lock table slots.
postgresql_max_pred_locks_per_transaction: 64 # min 10

postgresql_max_pred_locks_per_relation: -2 # (>= 10) negative values mean
# (max_pred_locks_per_transaction
# / -max_pred_locks_per_relation) - 1
postgresql_max_pred_locks_per_page: 2 # (>= 10) min 0


#------------------------------------------------------------------------------
# VERSION/PLATFORM COMPATIBILITY
Expand Down Expand Up @@ -723,6 +748,7 @@ postgresql_pgdg_releases:
9.4: 3,
9.5: 3,
9.6: 3,
10: 2,
}
centos: {
9.1: 7,
Expand All @@ -731,6 +757,7 @@ postgresql_pgdg_releases:
9.4: 3,
9.5: 3,
9.6: 3,
10: 2,
}
sl: {
9.1: 8,
Expand All @@ -739,6 +766,7 @@ postgresql_pgdg_releases:
9.4: 3,
9.5: 3,
9.6: 3,
10: 2,
}
oraclelinux: {
9.1: 8,
Expand All @@ -747,6 +775,7 @@ postgresql_pgdg_releases:
9.4: 3,
9.5: 3,
9.6: 3,
10: 2,
}
postgresql_version_terse: "{{ postgresql_version | replace('.', '') }}"
postgresql_yum_repository_base_url: "http://yum.postgresql.org"
Expand Down
17 changes: 13 additions & 4 deletions handlers/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
# file: postgresql/handlers/main.yml

- name: restart postgresql
service:
name: "{{ postgresql_service_name }}"
state: restarted
- name: restart postgresql with service
service:
name: "{{ postgresql_service_name }}"
state: restarted
enabled: yes

- name: restart postgresql with systemd
systemd:
name: "{{ postgresql_service_name }}"
state: restarted
enabled: yes
when: ansible_service_mgr == 'systemd'

14 changes: 2 additions & 12 deletions tasks/configure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@
state: directory
mode: 0755
when: ansible_os_family == "RedHat"
notify: restart postgresql with systemd

- name: PostgreSQL | Use the conf directory when starting the Postgres service | RedHat
template:
Expand All @@ -151,15 +152,4 @@
owner: "{{ postgresql_service_user }}"
group: "{{ postgresql_service_group }}"
mode: u=rwX,g=rwXs,o=rx

- name: PostgreSQL | Enable service
service:
name: "{{ postgresql_service_name }}"
enabled: yes
when: postgresql_service_enabled

- name: PostgreSQL | Restart PostgreSQL
service:
name: "{{ postgresql_service_name }}"
state: restarted
when: postgresql_configuration_pt1.changed or postgresql_configuration_pt2.changed or postgresql_configuration_pt3.changed or postgresql_systemd_custom_conf.changed
notify: restart postgresql with service
61 changes: 32 additions & 29 deletions tasks/install_yum.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,39 @@

# The standard ca-certs are needed because without them apt_key will fail to
# validate www.postgresql.org (or probably any other source).
- name: PostgreSQL | Make sure the CA certificates are available
yum:
name: ca-certificates
state: present

- name: PostgreSQL | Add PostgreSQL repository
yum:
name: "{{ postgresql_yum_repository_url }}"
state: present
- block:
- name: PostgreSQL | Make sure the CA certificates are available
yum:
name: ca-certificates
state: present

- name: PostgreSQL | Make sure the dependencies are installed
yum:
name: "{{ item }}"
state: present
update_cache: yes
with_items: ["python-psycopg2", "python-pycurl", "glibc-common"]
- name: PostgreSQL | Add PostgreSQL repository
yum:
name: "{{ postgresql_yum_repository_url }}"
state: present

- name: PostgreSQL | Install PostgreSQL
yum:
name: "{{ item }}"
state: present
environment: "{{ postgresql_env }}"
with_items:
- "postgresql{{ postgresql_version_terse }}-server"
- "postgresql{{ postgresql_version_terse }}"
- "postgresql{{ postgresql_version_terse }}-contrib"
- name: PostgreSQL | Make sure the dependencies are installed
yum:
name: "{{ item }}"
state: present
update_cache: yes
with_items: ["python-psycopg2", "python-pycurl", "glibc-common"]

- name: PostgreSQL | Install PostgreSQL
yum:
name: "{{ item }}"
state: present
environment: "{{ postgresql_env }}"
with_items:
- "postgresql{{ postgresql_version_terse }}-server"
- "postgresql{{ postgresql_version_terse }}"
- "postgresql{{ postgresql_version_terse }}-contrib"

- name: PostgreSQL | PGTune
yum:
name: pgtune
state: present
environment: "{{ postgresql_env }}"
when: postgresql_pgtune

- name: PostgreSQL | PGTune
yum:
name: pgtune
state: present
environment: "{{ postgresql_env }}"
when: postgresql_pgtune
35 changes: 24 additions & 11 deletions templates/HOWTO.postgresql.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,34 @@
How to add a new PostgreSQL version
===================================

1) Download the Debian package 'postgresql-9.X_[...].deb' from
http://apt.postgresql.org/pub/repos/apt/pool/main/p/postgresql-9.X/
Note: (https://www.postgresql.org/support/versioning)

2) Extract the 'usr/share/postgresql/9.1/postgresql.conf.sample' file
and save it under the 'templates' role directory
=> templates/postgresql.conf.9.{X}.orig
Beginning with version 10, a major release is indicated by increasing the first part of the version,
e.g. 10 to 11. Before version 10, a major release was indicated by increasing either the first or second
part of the version number, e.g. 9.5 to 9.6.

3) Check the difference between another version:
=> vimdiff postgresql.conf.9.{X-1}.orig postgresql.conf.9.{X}.orig
Do the following steps: ( versions mentioned for transitioninng from version 9.6 to 10 )

4) Copy an existing template:
=> cp postgresql.conf.9.{X-1}.j2 postgresql.conf.9.{X}.j2
1) Download the Debian package 'postgresql-<major_version>_[...].deb' from
http://apt.postgresql.org/pub/repos/apt/pool/main/p/postgresql-<major_version>, e.g. for new version 10 from
http://apt.postgresql.org/pub/repos/apt/pool/main/p/postgresql-10

2) Extract the 'usr/share/postgresql/<major-version>/postgresql.conf.sample' file with
dpkg-deb -x postgresql-<major_version>_[...].deb dir/to/extract/to/

and save it under the 'templates' role directory
=> templates/postgresql.conf.<major_version>.orig

3) Check the difference between another version, e.g. for 9.6 -> 10:
=> vimdiff postgresql.conf.10.orig postgresql.conf.9.6.orig

4) Copy an existing template, e.g.:
=> cp postgresql.conf.9.6.j2 postgresql.conf.10.j2

5) Update the new template following the major differences.

5) If there are new options or some of them removed, update the 'default/main.yml' file and add a "(>= 9.X)" or "(<= 9.X)" comment to them.
6) If there are new options or some of them removed, update the 'default/main.yml' file and add a "(>= 10)" or "(<= 10)" comment to them.

7) For yum based installation add version and minor version of postgresql in 'default/main.yml' under '# YUM settings' at end of file

6) Update the '.travis.yml' file to test its new version.
8) Update the '.travis.yml' file to test its new version.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ User={{ postgresql_service_user }}
Group={{ postgresql_service_group }}

Environment=PGDATA={{ postgresql_conf_directory }}

ExecStartPre=
{% if postgresql_version | version_compare('10', '>=') %}
ExecStartPre={{ postgresql_bin_directory }}/postgresql-{{ postgresql_version_terse }}-check-db-dir {{ postgresql_data_directory }}
{% else %}
ExecStartPre={{ postgresql_bin_directory }}/postgresql{{ postgresql_version_terse }}-check-db-dir {{ postgresql_data_directory }}
{% endif %}
Loading

0 comments on commit 90fb6e0

Please sign in to comment.