Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extended and adapted to install PostgreSQL 10 for CentOS and Ubuntu #267

Merged
merged 19 commits into from
Mar 29, 2018
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
93b7143
Extended and adapted to install PostgreSQL 10 for CentOS and Ubuntu
Nov 24, 2017
b6b12a7
Removed tabs from defaults/main.yml.
Feb 7, 2018
430bb1e
Adapted .travis.yml and yml files to run tests successfully for all g…
Feb 9, 2018
fd9b231
Bug fix. Removed remains for my local teste in test/playbook.yml.
Feb 9, 2018
5a02391
Bug fix and refinement for postgresql.conf-10.* .
Feb 16, 2018
3dec063
Merge current project master branch (remote-tracking branch 'project/…
Mar 26, 2018
db0e837
Merge remote-tracking branch 'project/master' into wp-update-to-postg…
Mar 26, 2018
fec5895
Added suggestions from gclough.
Mar 27, 2018
59c1ccc
Replaced vagrant setup by project's master branch.
Mar 27, 2018
82140ca
Updated tests/docker/group_vars/all.yml to include version 10.
Mar 28, 2018
9cdd7ae
Uncommented 'no_log: true' in users.yml.
Mar 28, 2018
61b63c5
Uncommented user baz in tests/docker/group_vars/postgresql.yml.
Mar 28, 2018
996d471
Recreated user baz but without passwd. We need him as database owner …
Mar 28, 2018
53c7d5b
Added encrypted passwd for user baz.
Mar 28, 2018
511f5b0
Commented need for encrypted password if version >= 10.
Mar 28, 2018
dec9295
Merge branch 'fix-no-log' into wp-update-to-postgres-10
Mar 28, 2018
7ae272f
Reenabled no_log: true for task PostgreSQL | Make sure the PostgreSQ…
Mar 29, 2018
bf33550
Just to trigger a new build on github. Added blank in README.md.
Mar 29, 2018
38b8851
Second try to trigger a rebuild. Blank in README.md deleted.
Mar 29, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 19 additions & 3 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ Vagrant.configure('2') do |config|
config.ssh.insert_key = false
config.ssh.private_key_path = '~/.vagrant.d/insecure_private_key'

config.vm.define 'anxs' do |machine|
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this related to the PostgreSQL v10 update? It looks interesting, but isn't related to this Pull Request, right?

machine.vm.box = "bento/ubuntu-16.04"
config.vm.define 'centos-vm' do |machine|
machine.vm.box = "bento/centos-7.4"
#machine.vm.box = "bento/ubuntu-16.04"
# machine.vm.box = "ubuntu/trusty64"
#machine.vm.box = "ubuntu/precise64"
#machine.vm.box = "debian/jessie64"
Expand All @@ -17,7 +18,8 @@ Vagrant.configure('2') do |config|
#machine.vm.box = "chef/centos-6.6"

machine.vm.network :private_network, ip: '192.168.88.22'
machine.vm.hostname = 'anxs.local'

machine.vm.hostname = 'centos-vm'

machine.vm.provision 'ansible' do |ansible|
ansible.playbook = 'tests/playbook.yml'
Expand All @@ -28,4 +30,18 @@ Vagrant.configure('2') do |config|

end

# config.vm.define 'ubuntu-vm' do |machine| machine.vm.box = "bento/ubuntu-16.04"
# machine.vm.network :private_network, ip: '192.168.88.23'
#
# machine.vm.hostname = 'ubuntu-vm'
#
# machine.vm.provision 'ansible' do |ansible|
# ansible.playbook = 'tests/playbook.yml'
# ansible.become = true
# ansible.inventory_path = 'vagrant-inventory'
# ansible.host_key_checking = false
# end
#
# end

end
30 changes: 27 additions & 3 deletions defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# file: postgresql/defaults/main.yml

# Basic settings
postgresql_version: 9.3
postgresql_version: 9.6 # if you use postgis too check whether the postgresql/postgis versions work together
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably don't need that postgis comment in there. There is a PR #310 , which will give reasonable defaults for PostGIS now.

postgresql_encoding: 'UTF-8'
postgresql_locale_parts:
- 'en_US' # Locale
Expand Down Expand Up @@ -117,6 +117,7 @@ postgresql_ssl_ciphers:
postgresql_ssl_prefer_server_ciphers: on
postgresql_ssl_ecdh_curve: 'prime256v1'
postgresql_ssl_renegotiation_limit: 512MB # amount of data between renegotiations
postgresal_ssl_dh_params_file: '' # (>= 10) specify file name for custom OpenSSL DH parameters
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in parameter name sal... should be sql.

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)
postgresql_ssl_ca_file: '' # (>= 9.2)
Expand Down Expand Up @@ -319,6 +320,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 @@ -347,7 +357,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)
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 @@ -499,11 +511,13 @@ 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 # (>= 10)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was introduced in v9.5, not v10:

https://www.postgresql.org/docs/9.5/static/runtime-config-logging.html#GUC-LOG-REPLICATION-COMMANDS

I've added #314 to backport this

# log temporary files equal or larger
postgresql_log_temp_files: -1
postgresql_log_timezone: UTC



Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why the 3rd blank line?

#------------------------------------------------------------------------------
# RUNTIME STATISTICS
#------------------------------------------------------------------------------
Expand Down Expand Up @@ -587,7 +601,8 @@ postgresql_vacuum_multixact_freeze_table_age: 150000000 # (>= 9.3)
postgresql_bytea_output: hex # hex, escape
postgresql_xmlbinary: base64
postgresql_xmloption: content
postgresql_gin_fuzzy_search_limit: 0 # (<= 9.2)
postgresql_gin_fuzzy_search_limit: 0 # (<= 9.2, >=10)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This parameter has been around at least since 9.0... and still exists in 10. We should remove the entire comment about version ranges.

https://www.postgresql.org/docs/10/static/runtime-config-client.html

postgresql_gin_pending_list_limit: 4MB # (>= 10)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was added in v9.5, not in v10. I've added that to #314 too.



# - Locale and Formatting -
Expand Down Expand Up @@ -639,6 +654,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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need these comments in this file? If someone wants to know what it does, then they can check the doco, or the postresql.conf itself.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right. Same for other comments taken from the original config file. May be for less exerienced people like me helpful to read it here too :-).

# / -max_pred_locks_per_relation) - 1
postgresql_max_pred_locks_per_page: 2 # (>= 10) min 0


#------------------------------------------------------------------------------
# VERSION/PLATFORM COMPATIBILITY
Expand Down Expand Up @@ -713,6 +733,7 @@ postgresql_pgdg_releases:
9.4: 3,
9.5: 3,
9.6: 3,
10: 2,
}
centos: {
9.1: 7,
Expand All @@ -721,6 +742,7 @@ postgresql_pgdg_releases:
9.4: 3,
9.5: 3,
9.6: 3,
10: 2,
}
sl: {
9.1: 8,
Expand All @@ -729,6 +751,7 @@ postgresql_pgdg_releases:
9.4: 3,
9.5: 3,
9.6: 3,
10: 2,
}
oraclelinux: {
9.1: 8,
Expand All @@ -737,6 +760,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
8 changes: 5 additions & 3 deletions tasks/extensions.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# file: postgresql/tasks/extensions.yml

- include: extensions/contrib.yml
- include_tasks: extensions/contrib.yml
when: postgresql_ext_install_contrib
- include: extensions/dev_headers.yml

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Superseded by #293... but adding the spaces is probably a good idea.

- include_tasks: extensions/dev_headers.yml
when: postgresql_ext_install_dev_headers
- include: extensions/postgis.yml

- include_tasks: extensions/postgis.yml
when: postgresql_ext_install_postgis
16 changes: 8 additions & 8 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,29 @@
- "../vars/empty.yml"
tags: [always]

- include: install.yml
- include_tasks: install.yml
when: ansible_pkg_mgr == "apt"
tags: [postgresql, postgresql-install]

- include: install_yum.yml
- include_tasks: install_yum.yml
when: ansible_pkg_mgr == "yum"
tags: [postgresql, postgresql-install]

- include: extensions.yml
- include_tasks: extensions.yml
tags: [postgresql, postgresql-extensions]

- include: configure.yml
- include_tasks: configure.yml
tags: [postgresql, postgresql-configure]

- include: users.yml
- include_tasks: users.yml
tags: [postgresql, postgresql-users]

- include: databases.yml
- include_tasks: databases.yml
tags: [postgresql, postgresql-databases]

- include: users_privileges.yml
- include_tasks: users_privileges.yml
tags: [postgresql, postgresql-users]

- include: monit.yml
- include_tasks: monit.yml
when: monit_protection is defined and monit_protection == true
tags: [postgresql, postgresql-monit]
12 changes: 8 additions & 4 deletions templates/HOWTO.postgresql.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
How to add a new PostgreSQL version
===================================

1) Download the Debian package 'postgresql-9.X_[...].deb' from
1) Download the Debian package 'postgresql-<version>_[...].deb' from
http://apt.postgresql.org/pub/repos/apt/pool/main/p/postgresql-9.X/

2) Extract the 'usr/share/postgresql/9.1/postgresql.conf.sample' file
and save it under the 'templates' role directory
2) Extract the 'usr/share/postgresql/9.1/postgresql.conf.sample' file with
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update to v10 here too, not v9.1

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

dpkg-deb -x postgresql-<version>_[...].deb dir/to/extract/to/

and save it under the 'templates' role directory
=> templates/postgresql.conf.9.{X}.orig
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update to <version> here too... but should we match the role and use <postgresql_version>?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.


3) Check the difference between another version:
Expand All @@ -19,4 +21,6 @@ and save it under the 'templates' role directory

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) Update the '.travis.yml' file to test its new version.
7) For yum based installation add version and minor version of postgresql in 'default/main.yml' under '# YUM settings' at end of file
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You skipped the point 6) (5 to 7)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Sébastien,
all ansible tests now pass including a new one for ansible 2.4.2.0/posgresql10.
Docker tests currently commented out - do not know docker ;-).

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that @sebalix was saying that in the file, there is now no step 6

  1. (SHOULD THIS BE STEP 6?)


8) Update the '.travis.yml' file to test its new version.
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,8 @@ Group={{ postgresql_service_group }}
Environment=PGDATA={{ postgresql_conf_directory }}

ExecStartPre=
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why leave this blank line here... it's a historical typo, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Blank line deleted.

{% if postgresql_version == 10 %}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At this point I'd say >= 10, as I suspect this format will stay for v11, v12, etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for re-reviewing... but we should be using the version_compare() function here. (and anywhere else you're comparing versions)

{% if postgresql_version | version_compare ('10', '>=') %}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done ;-)

ExecStartPre={{ postgresql_bin_directory }}/postgresql-{{ postgresql_version_terse }}-check-db-dir {{ postgresql_data_directory }}
{% else %}
Copy link
Collaborator

@gclough gclough Mar 23, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the indentation on this correct? Should it be better written in this format, ans using the version_compare() builtin:

{% if postgresql_version | version_check('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 %}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation removed. version_compare() filter used to check the version.

ExecStartPre={{ postgresql_bin_directory }}/postgresql{{ postgresql_version_terse }}-check-db-dir {{ postgresql_data_directory }}
{% endif %}
Loading