Skip to content

Commit a291d40

Browse files
committed
Fix and set useful backup extension for postgresql.conf file
1 parent 663db90 commit a291d40

2 files changed

Lines changed: 30 additions & 21 deletions

File tree

pillar.example

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

17+
# This section will append your configuration to postgresql.conf.
18+
postgresconf: |
19+
listen_addresses = 'localhost,*'
20+
21+
# Backup extension for postgresql.conf file, defaults to `.bak`.
22+
# Set to False to stop creation of backup on postgresql.conf changes.
23+
{%- if 'status.time' in salt.keys() %}
24+
postgresconf_backup: ".backup@{{ salt['status.time']('%y-%m-%d_%H:%M:%S') }}"
25+
{%- endif %}
26+
1727
# Path to the `pg_hba.conf` file Jinja template on Salt Fileserver
1828
pg_hba.conf: salt://postgres/templates/pg_hba.conf.j2
1929

@@ -87,11 +97,13 @@ postgres:
8797
absentUser:
8898
ensure: absent
8999

100+
# tablespaces to be created
90101
tablespaces:
91102
my_space:
92103
directory: /srv/my_tablespace
93104
owner: localUser
94105

106+
# databases to be created
95107
databases:
96108
db1:
97109
owner: 'localUser'
@@ -118,11 +130,4 @@ postgres:
118130
maintenance_db: db1
119131
#postgis: {}
120132

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
133+
# 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)