Skip to content

Commit 8007716

Browse files
Merge pull request #135 from vutny/set-postgresql.conf-backup-extension
Fix and set useful backup extension for postgresql.conf file
2 parents 663db90 + 3a022aa commit 8007716

File tree

2 files changed

+31
-21
lines changed

2 files changed

+31
-21
lines changed

pillar.example

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,17 @@ postgres:
1414
- postgresql-contrib
1515
- postgresql-plpython
1616

17+
# Append the lines under this item to your postgresql.conf file.
18+
# Pay attention to indent exactly with 4 spaces for all lines.
19+
postgresconf: |
20+
listen_addresses = '*' # listen on all interfaces
21+
22+
# Backup extension for postgresql.conf file, defaults to `.bak`.
23+
# Set to False to stop creation of backup on postgresql.conf changes.
24+
{%- if 'status.time' in salt.keys() %}
25+
postgresconf_backup: ".backup@{{ salt['status.time']('%y-%m-%d_%H:%M:%S') }}"
26+
{%- endif %}
27+
1728
# Path to the `pg_hba.conf` file Jinja template on Salt Fileserver
1829
pg_hba.conf: salt://postgres/templates/pg_hba.conf.j2
1930

@@ -87,11 +98,13 @@ postgres:
8798
absentUser:
8899
ensure: absent
89100

101+
# tablespaces to be created
90102
tablespaces:
91103
my_space:
92104
directory: /srv/my_tablespace
93105
owner: localUser
94106

107+
# databases to be created
95108
databases:
96109
db1:
97110
owner: 'localUser'
@@ -118,11 +131,4 @@ postgres:
118131
maintenance_db: db1
119132
#postgis: {}
120133

121-
# Backup extension defaults to .bak if postgresconf_backup is True.
122-
# Set to False to stop creation of backup on postgresql.conf changes.
123-
postgresconf_backup: True
124-
# This section will append your configuration to postgresql.conf.
125-
postgresconf: |
126-
listen_addresses = 'localhost,*'
127-
128-
# vim: ft=yaml:sw=2
134+
# vim: ft=yaml ts=2 sts=2 sw=2 et

postgres/defaults.yaml

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,22 @@ postgres:
1111
python: python-psycopg2
1212
user: postgres
1313
group: postgres
14+
15+
# if prepare_cluster is over-ridden in any of:
16+
# - osmap.yaml
17+
# - oscodenamemap.yaml
18+
# - osfingermap.yaml
19+
# you will have to specify a complete dictionary.
20+
prepare_cluster:
21+
user: root
22+
command: service postgresql initdb
23+
test: test -f /var/lib/pgsql/data/PG_VERSION
24+
env: {}
25+
1426
conf_dir: /var/lib/pgsql/data
27+
postgresconf: ""
28+
postgresconf_backup: '.bak'
29+
1530
pg_hba.conf: salt://postgres/templates/pg_hba.conf.j2
1631
acls:
1732
# "local" is for Unix domain socket connections only
@@ -20,22 +35,11 @@ postgres:
2035
- ['host', 'all', 'all', '127.0.0.1/32', 'md5']
2136
# IPv6 local connections:
2237
- ['host', 'all', 'all', '::1/128', 'md5']
38+
2339
service: postgresql
40+
2441
users: {}
2542
tablespaces: {}
2643
databases: {}
2744
schemas: {}
2845
extensions: {}
29-
postgresconf_backup: True
30-
postgresconf: ""
31-
32-
# if prepare_cluster is over-ridden in any of:
33-
# - osmap.yaml
34-
# - oscodenamemap.yaml
35-
# - osfingermap.yaml
36-
# you will have to specify a complete dictionary.
37-
prepare_cluster:
38-
user: root
39-
command: service postgresql initdb
40-
test: test -f /var/lib/pgsql/data/PG_VERSION
41-
env: {}

0 commit comments

Comments
 (0)