Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit 971fc3c
Author: Greg Clough <[email protected]>
Date:   Tue Mar 27 12:01:10 2018 +0100

    Rebased from master

commit 5c6a5f0
Merge: 871edb6 c657d9d
Author: Greg Clough <[email protected]>
Date:   Tue Mar 27 12:00:08 2018 +0100

    Merge branch 'add_missing_conf_parameters' of https://github.com/gclough/postgresql into add_missing_conf_parameters

commit 871edb6
Author: Greg Clough <[email protected]>
Date:   Tue Mar 27 10:18:54 2018 +0100

    Changed variables to match the "double-quoted" string standard, as introduced in \ANXS#319

commit 2468343
Author: Greg Clough <[email protected]>
Date:   Mon Mar 26 16:53:31 2018 +0100

    Updated to use the standard "{{ var }}" format for new variables, rather than "{{var}}"

commit 68359af
Author: Greg Clough <[email protected]>
Date:   Sat Mar 24 15:30:30 2018 +0000

    Crosscheck, and fix all missing parameters, defaults, etc.

commit c657d9d
Author: Greg Clough <[email protected]>
Date:   Tue Mar 27 10:18:54 2018 +0100

    Changed variables to match the "double-quoted" string standard, as introduced in \ANXS#319

commit d009b72
Merge: 28b0e3a 28a6e9c
Author: Greg Clough <[email protected]>
Date:   Tue Mar 27 10:13:16 2018 +0100

    Merge branch 'master' of https://github.com/ANXS/postgresql into add_missing_conf_parameters

    Conflicts:
    	defaults/main.yml

commit 28b0e3a
Author: Greg Clough <[email protected]>
Date:   Mon Mar 26 16:53:31 2018 +0100

    Updated to use the standard "{{ var }}" format for new variables, rather than "{{var}}"

commit 28a6e9c
Merge: a1ab3cb 67e0fae
Author: Sergei Antipov <[email protected]>
Date:   Mon Mar 26 11:52:03 2018 -0400

    Merge pull request ANXS#319 from gclough/quote_all_enum_parameters

    Quote all string variables, and add spaces around variables "{{ var }}"

commit 67e0fae
Author: Greg Clough <[email protected]>
Date:   Mon Mar 26 12:23:19 2018 +0100

    Octal numbers need to be quoted, otherwise they get converted to Decimal

commit 42074a9
Author: Greg Clough <[email protected]>
Date:   Mon Mar 26 12:20:25 2018 +0100

    Crosschecked, and found some that I missed.

commit cb43081
Author: Greg Clough <[email protected]>
Date:   Mon Mar 26 11:48:01 2018 +0100

    Quote all string variables, and add spaces around variables "{{ var }}" instead of "{{var}""

commit b4f67e3
Author: Greg Clough <[email protected]>
Date:   Sat Mar 24 15:30:30 2018 +0000

    Crosscheck, and fix all missing parameters, defaults, etc.

commit a1ab3cb
Merge: 3861bc2 eabd1a0
Author: Sergei Antipov <[email protected]>
Date:   Fri Mar 23 12:46:42 2018 -0400

    Merge pull request ANXS#313 from gclough/fix_galaxy_centos_name

    Fixed CenOS/RedHat naming... should be EL

commit eabd1a0
Author: Greg Clough <[email protected]>
Date:   Fri Mar 23 15:27:39 2018 +0000

    Fixed CenOS/RedHat naming... should be EL.  Also added tags to help people find it on Galaxy

commit 3861bc2
Merge: 73c77b4 f584dbb
Author: Sergei Antipov <[email protected]>
Date:   Fri Mar 23 11:14:24 2018 -0400

    Merge pull request ANXS#312 from gclough/update_meta_for_centos_redhat

    Added meta data for CentOS and RedHat, plus added tags

commit f584dbb
Author: Greg Clough <[email protected]>
Date:   Fri Mar 23 14:35:52 2018 +0000

    Added meta data for CentOS and RedHat, plus added tags to help with searches

commit 73c77b4
Merge: 7346fdb a3f45f9
Author: Sergei Antipov <[email protected]>
Date:   Mon Mar 19 19:23:31 2018 -0400

    Merge pull request ANXS#307 from sebalix/use_postgresql_ext_for_extensions

    Use postgresql ext for extensions

commit a3f45f9
Author: Greg Clough <[email protected]>
Date:   Thu Mar 15 18:04:13 2018 +0000

    Added extra tests for travis to create extensions in "foobar" database

commit e918dbe
Author: Greg Clough <[email protected]>
Date:   Sat Mar 10 11:19:04 2018 +0000

    Convert from using "psql" to using the Ansible module "postgresql_ext", which I suspect
    is a more reliable method.
  • Loading branch information
Greg Clough committed Mar 27, 2018
1 parent 7346fdb commit 4a9cd1a
Show file tree
Hide file tree
Showing 12 changed files with 213 additions and 94 deletions.
185 changes: 103 additions & 82 deletions defaults/main.yml

Large diffs are not rendered by default.

21 changes: 20 additions & 1 deletion meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,30 @@ galaxy_info:
min_ansible_version: 2.4.0
license: MIT
platforms:
- name: Debian
versions:
- jessie
- stretch
- name: Ubuntu
versions:
- all
- xenial
- trusty
- name: EL
versions:
- 6
- 7
categories:
- database
- database:sql
galaxy_tags:
- postgresql
- postgres
- sql
- database
- postgis
- debian
- ubuntu
- centos
- redhat

dependencies: []
11 changes: 6 additions & 5 deletions tasks/databases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@
when: postgresql_databases|length > 0

- name: PostgreSQL | Add extensions to the databases
shell: "psql {{item.0.db}} --username {{postgresql_admin_user}} -c 'CREATE EXTENSION IF NOT EXISTS {{ item.1 }};'"
become: yes
become_user: "{{postgresql_service_user}}"
postgresql_ext:
db: "{{ item.0.db }}"
login_user: "{{ postgresql_service_user }}"
port: "{{ postgresql_port }}"
name: "{{ item.1 }}"
with_subelements:
- "{{postgresql_database_extensions}}"
- "{{ postgresql_database_extensions }}"
- extensions
register: result
changed_when: "'NOTICE' not in result.stderr"

- name: PostgreSQL | Add hstore to the databases with the requirement
become: yes
Expand Down
47 changes: 47 additions & 0 deletions templates/crosscheck_parameters.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
#!/bin/bash -

#
# Identify a unique filename
#
TEMP_FILE=/tmp/`basename $0`.$$

#
# Loop through all postgresql.conf.orig files, and compare them to the j2 files
#
for FILE in postgresql.conf-[0-9]*\.orig; do
#
# Extract the base filename, removing ".orig"
#
BASE_FILE="`echo $FILE | sed s/\.orig\$//`"

#
# If we crash, then cleanup
#
trap 'rm -f ${TEMP_FILE}.orig ${TEMP_FILE}.j2 ${TEMP_FILE}.defaults' 0

#
# Extract a unique, sorted list of the parameter names
#
cat ${BASE_FILE}.orig | sed s/\#// | grep ^[a-z] | cut -f1 -d' ' | sort | uniq > ${TEMP_FILE}.orig
cat ${BASE_FILE}.j2 | sed s/\#// | grep ^[a-z] | cut -f1 -d' ' | sort | uniq > ${TEMP_FILE}.j2
cat ../defaults/main.yml | sed s/\#// | grep ^[a-z] | cut -f1 -d':' | sed s/^postgresql_// | sort | uniq > ${TEMP_FILE}.defaults

#
# Output a comparision
#
echo ================================================================================
echo ${BASE_FILE}.orig ${BASE_FILE}.j2
diff ${TEMP_FILE}.orig ${TEMP_FILE}.j2 && echo All parameters exist in both files
echo --------------------------------------------------------------------------------
echo ${BASE_FILE}.defaults ${BASE_FILE}.j2
cat ${TEMP_FILE}.j2 | while read PARAM; do
grep ^postgresql_${PARAM}: ../defaults/main.yml > /dev/null 2>&1 || echo "Missing $PARAM in ../defaults/main.yml"
done
echo ================================================================================
echo

#
# Cleanup
#
rm -f ${TEMP_FILE}.orig ${TEMP_FILE}.j2 ${TEMP_FILE}.defaults
done
1 change: 1 addition & 0 deletions templates/postgresql.conf-9.3.j2
Original file line number Diff line number Diff line change
Expand Up @@ -501,6 +501,7 @@ vacuum_multixact_freeze_table_age = {{postgresql_vacuum_multixact_freeze_table_a
bytea_output = '{{postgresql_bytea_output}}' # hex, escape
xmlbinary = '{{postgresql_xmlbinary}}'
xmloption = '{{postgresql_xmloption}}'
gin_fuzzy_search_limit = '{{ postgresql_gin_fuzzy_search_limit }}'

# - Locale and Formatting -

Expand Down
3 changes: 2 additions & 1 deletion templates/postgresql.conf-9.3.orig
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
#ssl = off # (change requires restart)
#ssl_ciphers = 'DEFAULT:!LOW:!EXP:!MD5:@STRENGTH' # allowed SSL ciphers
# (change requires restart)
#ssl_renegotiation_limit = 512MB # amount of data between renegotiations
#ssl_renegotiation_limit = 0 # amount of data between renegotiations
#ssl_cert_file = 'server.crt' # (change requires restart)
#ssl_key_file = 'server.key' # (change requires restart)
#ssl_ca_file = '' # (change requires restart)
Expand Down Expand Up @@ -500,6 +500,7 @@
#bytea_output = 'hex' # hex, escape
#xmlbinary = 'base64'
#xmloption = 'content'
#gin_fuzzy_search_limit = 0

# - Locale and Formatting -

Expand Down
1 change: 1 addition & 0 deletions templates/postgresql.conf-9.4.j2
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,7 @@ vacuum_multixact_freeze_table_age = {{postgresql_vacuum_multixact_freeze_table_a
bytea_output = '{{postgresql_bytea_output}}' # hex, escape
xmlbinary = '{{postgresql_xmlbinary}}'
xmloption = '{{postgresql_xmloption}}'
gin_fuzzy_search_limit = '{{ postgresql_gin_fuzzy_search_limit }}'

# - Locale and Formatting -

Expand Down
3 changes: 2 additions & 1 deletion templates/postgresql.conf-9.4.orig
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
# (change requires restart)
#ssl_prefer_server_ciphers = on # (change requires restart)
#ssl_ecdh_curve = 'prime256v1' # (change requires restart)
#ssl_renegotiation_limit = 512MB # amount of data between renegotiations
#ssl_renegotiation_limit = 0 # amount of data between renegotiations
#ssl_cert_file = 'server.crt' # (change requires restart)
#ssl_key_file = 'server.key' # (change requires restart)
#ssl_ca_file = '' # (change requires restart)
Expand Down Expand Up @@ -517,6 +517,7 @@
#bytea_output = 'hex' # hex, escape
#xmlbinary = 'base64'
#xmloption = 'content'
#gin_fuzzy_search_limit = 0

# - Locale and Formatting -

Expand Down
12 changes: 11 additions & 1 deletion templates/postgresql.conf-9.5.j2
Original file line number Diff line number Diff line change
Expand Up @@ -437,12 +437,20 @@ log_line_prefix = '{{postgresql_log_line_prefix}}' # special values:
# e.g. '<%u%%%d> '
log_lock_waits = {{'on' if postgresql_log_lock_waits else 'off'}} # log lock waits >= deadlock_timeout
log_statement = '{{postgresql_log_statement}}' # none, ddl, mod, all
log_replication_commands = {{'on' if postgresql_log_replication_commands else 'off'}}
log_temp_files = {{postgresql_log_temp_files}} # log temporary files equal or larger
# than the specified size in kilobytes;
# -1 disables, 0 logs all temp files
log_timezone = '{{postgresql_log_timezone}}'


# - Process Title -

cluster_name = '{{ postgresql_cluster_name }}' # added to process titles if nonempty
# (change requires restart)
update_process_title = {{'on' if postgresql_update_process_title else 'off'}}


#------------------------------------------------------------------------------
# RUNTIME STATISTICS
#------------------------------------------------------------------------------
Expand All @@ -454,7 +462,6 @@ track_counts = {{'on' if postgresql_track_counts else 'off'}}
track_io_timing = {{'on' if postgresql_track_io_timing else 'off'}}
track_functions = {{postgresql_track_functions}} # none, pl, all
track_activity_query_size = {{postgresql_track_activity_query_size}} # (change requires restart)
update_process_title = {{'on' if postgresql_update_process_title else 'off'}}
stats_temp_directory = '{{postgresql_stats_temp_directory}}'


Expand Down Expand Up @@ -522,6 +529,8 @@ vacuum_multixact_freeze_table_age = {{postgresql_vacuum_multixact_freeze_table_a
bytea_output = '{{postgresql_bytea_output}}' # hex, escape
xmlbinary = '{{postgresql_xmlbinary}}'
xmloption = '{{postgresql_xmloption}}'
gin_fuzzy_search_limit = '{{ postgresql_gin_fuzzy_search_limit }}'
gin_pending_list_limit = '{{ postgresql_gin_pending_list_limit }}'

# - Locale and Formatting -

Expand Down Expand Up @@ -585,6 +594,7 @@ backslash_quote = {{postgresql_backslash_quote}} # on, off, or safe_encoding
default_with_oids = {{'on' if postgresql_default_with_oids else 'off'}}
escape_string_warning = {{'on' if postgresql_escape_string_warning else 'off'}}
lo_compat_privileges = {{'on' if postgresql_lo_compat_privileges else 'off'}}
operator_precedence_warning = {{'on' if postgresql_operator_precedence_warning else 'off'}}
quote_all_identifiers = {{'on' if postgresql_quote_all_identifiers else 'off'}}
sql_inheritance = {{'on' if postgresql_sql_inheritance else 'off'}}
standard_conforming_strings = {{'on' if postgresql_standard_conforming_strings else 'off'}}
Expand Down
12 changes: 11 additions & 1 deletion templates/postgresql.conf-9.6.j2
Original file line number Diff line number Diff line change
Expand Up @@ -451,12 +451,20 @@ log_line_prefix = '{{postgresql_log_line_prefix}}' # special values:
# e.g. '<%u%%%d> '
log_lock_waits = {{'on' if postgresql_log_lock_waits else 'off'}} # log lock waits >= deadlock_timeout
log_statement = '{{postgresql_log_statement}}' # none, ddl, mod, all
log_replication_commands = {{'on' if postgresql_log_replication_commands else 'off'}}
log_temp_files = {{postgresql_log_temp_files}} # log temporary files equal or larger
# than the specified size in kilobytes;
# -1 disables, 0 logs all temp files
log_timezone = '{{postgresql_log_timezone}}'


# - Process Title -

cluster_name = '{{ postgresql_cluster_name }}' # added to process titles if nonempty
# (change requires restart)
update_process_title = {{'on' if postgresql_update_process_title else 'off'}}


#------------------------------------------------------------------------------
# RUNTIME STATISTICS
#------------------------------------------------------------------------------
Expand All @@ -468,7 +476,6 @@ track_counts = {{'on' if postgresql_track_counts else 'off'}}
track_io_timing = {{'on' if postgresql_track_io_timing else 'off'}}
track_functions = {{postgresql_track_functions}} # none, pl, all
track_activity_query_size = {{postgresql_track_activity_query_size}} # (change requires restart)
update_process_title = {{'on' if postgresql_update_process_title else 'off'}}
stats_temp_directory = '{{postgresql_stats_temp_directory}}'


Expand Down Expand Up @@ -537,6 +544,8 @@ vacuum_multixact_freeze_table_age = {{postgresql_vacuum_multixact_freeze_table_a
bytea_output = '{{postgresql_bytea_output}}' # hex, escape
xmlbinary = '{{postgresql_xmlbinary}}'
xmloption = '{{postgresql_xmloption}}'
gin_fuzzy_search_limit = '{{ postgresql_gin_fuzzy_search_limit }}'
gin_pending_list_limit = '{{ postgresql_gin_pending_list_limit }}'

# - Locale and Formatting -

Expand Down Expand Up @@ -597,6 +606,7 @@ backslash_quote = {{postgresql_backslash_quote}} # on, off, or safe_encoding
default_with_oids = {{'on' if postgresql_default_with_oids else 'off'}}
escape_string_warning = {{'on' if postgresql_escape_string_warning else 'off'}}
lo_compat_privileges = {{'on' if postgresql_lo_compat_privileges else 'off'}}
operator_precedence_warning = {{'on' if postgresql_operator_precedence_warning else 'off'}}
quote_all_identifiers = {{'on' if postgresql_quote_all_identifiers else 'off'}}
sql_inheritance = {{'on' if postgresql_sql_inheritance else 'off'}}
standard_conforming_strings = {{'on' if postgresql_standard_conforming_strings else 'off'}}
Expand Down
4 changes: 2 additions & 2 deletions templates/postgresql.conf-9.6.orig
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@
#bgwriter_delay = 200ms # 10-10000ms between rounds
#bgwriter_lru_maxpages = 100 # 0-1000 max buffers written/round
#bgwriter_lru_multiplier = 2.0 # 0-10.0 multiplier on buffers scanned/round
#bgwriter_flush_after = 0 # 0 disables,
#bgwriter_flush_after = 512kB # 0 disables,
# default is 512kB on linux, 0 otherwise

# - Asynchronous Behavior -
Expand Down Expand Up @@ -207,7 +207,7 @@
#max_wal_size = 1GB
#min_wal_size = 80MB
#checkpoint_completion_target = 0.5 # checkpoint target duration, 0.0 - 1.0
#checkpoint_flush_after = 0 # 0 disables,
#checkpoint_flush_after = 256kB # 0 disables,
# default is 256kB on linux, 0 otherwise
#checkpoint_warning = 30s # 0 disables

Expand Down
7 changes: 7 additions & 0 deletions tests/docker/group_vars/postgresql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,10 @@ postgresql_ext_install_contrib: true
postgresql_ssl: false
postgresql_pgtune: false
postgresql_ext_install_postgis: false

postgresql_database_extensions:
- db: foobar
extensions:
- adminpack
- pgcrypto
- unaccent

0 comments on commit 4a9cd1a

Please sign in to comment.