1
1
PostgreSQL
2
2
==========
3
3
4
- An [ Ansible] [ ansible ] role for installing and managing [ PostgreSQL] [ postgresql ]
5
- servers. This role works with both Debian and RedHat based systems, and
6
- provides backup scripts for [ PostgreSQL Continuous Archiving and Point-in-Time
4
+ An [ Ansible] [ ansible ] role for installing and managing [ PostgreSQL] [ postgresql ] servers. This role works with both
5
+ Debian and RedHat based systems, and provides backup scripts for [ PostgreSQL Continuous Archiving and Point-in-Time
7
6
Recovery] [ postgresql_pitr ] .
8
7
9
- On RedHat-based platforms, the [ PostgreSQL Global Development Group (PGDG)
10
- packages] [ pgdg_yum ] packages will be installed. On Debian-based platforms, you
11
- can choose from the distribution's packages (from APT) or the [ PGDG
8
+ On RedHat-based platforms, the [ PostgreSQL Global Development Group (PGDG) packages] [ pgdg_yum ] packages will be
9
+ installed. On Debian-based platforms, you can choose from the distribution's packages (from APT) or the [ PGDG
12
10
packages] [ pgdg_apt ] .
13
11
14
12
[ ansible ] : http://www.ansible.com/
@@ -17,38 +15,32 @@ packages][pgdg_apt].
17
15
[ pgdg_yum ] : http://yum.postgresql.org/
18
16
[ pgdg_apt ] : http://apt.postgresql.org/
19
17
20
- ** Changes that require a restart will not be applied unless you manually
21
- restart PostgreSQL.** This role will reload the server for those configuration
22
- changes that can be updated with only a reload because reloading is a
23
- non-intrusive operation, but options that require a full restart will not cause
24
- the server to restart.
18
+ ** Changes that require a restart will not be applied unless you manually restart PostgreSQL.** This role will reload the
19
+ server for those configuration changes that can be updated with only a reload because reloading is a non-intrusive
20
+ operation, but options that require a full restart will not cause the server to restart.
25
21
26
22
Requirements
27
23
------------
28
24
29
- This role requires Ansible 1.8 +
25
+ This role requires Ansible 2.4 +
30
26
31
27
Role Variables
32
28
--------------
33
29
34
30
### All variables are optional ###
35
31
36
- - ` postgresql_user_name ` : System username to be used for PostgreSQL (default:
37
- ` postgres ` ).
32
+ - ` postgresql_user_name ` : System username to be used for PostgreSQL (default: ` postgres ` ).
38
33
39
- - ` postgresql_version ` : PostgreSQL version to install. On Debian-based
40
- platforms, the default is whatever version is pointed to by the ` postgresql `
41
- metapackage). On RedHat-based platforms, the default is ` 9.4 ` .
34
+ - ` postgresql_version ` : PostgreSQL version to install. On Debian-based platforms, the default is whatever version is
35
+ pointed to by the ` postgresql ` metapackage). On RedHat-based platforms, the default is ` 9.4 ` .
42
36
43
- - ` postgresql_flavor ` : On Debian-based platforms, this specifies whether you
44
- want to use PostgreSQL packages from pgdg or the distribution's apt
45
- repositories. Possible values: ` apt ` , ` pgdg ` (default: ` apt ` ).
37
+ - ` postgresql_flavor ` : On Debian-based platforms, this specifies whether you want to use PostgreSQL packages from pgdg
38
+ or the distribution's apt repositories. Possible values: ` apt ` , ` pgdg ` (default: ` apt ` ).
46
39
47
- - ` postgresql_conf ` : A hash (dictionary) of ` postgresql.conf ` options and
48
- values. These options are not added to ` postgresql.conf ` directly - the role
49
- adds a ` conf.d ` subdirectory in the configuration directory and an include
50
- statement for that directory to ` postgresql.conf ` . Options set in
51
- ` postgresql_conf ` are then set in ` conf.d/25ansible_postgresql.conf ` .
40
+ - ` postgresql_conf ` : A hash (dictionary) of ` postgresql.conf ` options and values. These options are not added to
41
+ ` postgresql.conf ` directly - the role adds a ` conf.d ` subdirectory in the configuration directory and an include
42
+ statement for that directory to ` postgresql.conf ` . Options set in ` postgresql_conf ` are then set in
43
+ ` conf.d/25ansible_postgresql.conf ` .
52
44
53
45
Due to YAML parsing, you must take care when defining values in
54
46
` postgresql_conf ` to ensure they are properly written to the config file. For
@@ -71,60 +63,49 @@ Role Variables
71
63
72
64
- `postgresql_pg_hba_conf`: A list of lines to add to `pg_hba.conf`
73
65
74
- - `postgresql_pg_hba_local_postgres_user`: If set to `false`, this will remove
75
- the `postgres` user's entry from `pg_hba.conf` that is preconfigured on
76
- Debian-based PostgreSQL installations. You probably do not want to do this
66
+ - `postgresql_pg_hba_local_postgres_user`: If set to `false`, this will remove the `postgres` user's entry from
67
+ `pg_hba.conf` that is preconfigured on Debian-based PostgreSQL installations. You probably do not want to do this
77
68
unless you know what you're doing.
78
69
79
- - `postgresql_pg_hba_local_socket`: If set to `false`, this will remove the
80
- `local` entry from `pg_hba.conf` that is preconfigured by the PostgreSQL
81
- package.
70
+ - `postgresql_pg_hba_local_socket`: If set to `false`, this will remove the `local` entry from `pg_hba.conf` that is
71
+ preconfigured by the PostgreSQL package.
82
72
83
- - `postgresql_pg_hba_local_ipv4`: If set to `false`, this will remove the `host
84
- ... 127.0.0.1/32` entry from `pg_hba.conf` that is preconfigured by the
85
- PostgreSQL package.
73
+ - `postgresql_pg_hba_local_ipv4`: If set to `false`, this will remove the `host ... 127.0.0.1/32` entry from
74
+ `pg_hba.conf` that is preconfigured by the PostgreSQL package.
86
75
87
- - `postgresql_pg_hba_local_ipv6`: If set to `false`, this will remove the `host
88
- ... ::1/128` entry from `pg_hba.conf` that is preconfigured by the PostgreSQL
89
- package.
76
+ - `postgresql_pg_hba_local_ipv6`: If set to `false`, this will remove the `host ... ::1/128` entry from `pg_hba.conf`
77
+ that is preconfigured by the PostgreSQL package.
90
78
91
- - `postgresql_pgdata_dir`: Only set this if you have changed the `$PGDATA`
92
- directory from the package default. Note this does not configure PostgreSQL
93
- to actually use a different directory, you will need to do that yourself, it
94
- just allows the role to properly locate the directory.
79
+ - `postgresql_pgdata_dir`: Only set this if you have changed the `$PGDATA` directory from the package default. Note this
80
+ does not configure PostgreSQL to actually use a different directory, you will need to do that yourself, it just allows
81
+ the role to properly locate the directory.
95
82
96
- - `postgresql_conf_dir`: As with `postgresql_pgdata_dir` except for the
97
- configuration directory.
83
+ - `postgresql_conf_dir`: As with `postgresql_pgdata_dir` except for the configuration directory.
98
84
99
85
### Backups ###
100
86
101
- - `postgresql_backup_dir`: If set, enables [PITR][postgresql_pitr] backups. Set
102
- this to a directory where your database will be backed up (this can be any
103
- format supported by rsync, e.g. `user@host:/path`). The most recent backup
104
- will be in a subdirectory named `current`.
87
+ - `postgresql_backup_dir`: If set, enables [PITR][postgresql_pitr] backups. Set this to a directory where your database
88
+ will be backed up (this can be any format supported by rsync, e.g. `user@host:/path`). The most recent backup will be
89
+ in a subdirectory named `current`.
105
90
106
- - `postgresql_backup_rotate`: Boolean, defaults to `true`, which will cause the
107
- `current` directory to be renamed prior to creating a new backup. If set to
108
- `false`, `current` will be deleted (this is useful if you are using snapshots
109
- or some other means to archive previous backups).
91
+ - `postgresql_backup_rotate`: Boolean, defaults to `true`, which will cause the `current` directory to be renamed prior
92
+ to creating a new backup. If set to `false`, `current` will be deleted (this is useful if you are using snapshots or
93
+ some other means to archive previous backups).
110
94
111
- - `postgresql_backup_local_dir`: Filesystem path on the PostgreSQL server where
112
- backup scripts will be placed and working WALs will be written prior to a WAL
113
- archive.
95
+ - `postgresql_backup_local_dir`: Filesystem path on the PostgreSQL server where backup scripts will be placed and
96
+ working WALs will be written prior to a WAL archive.
114
97
115
- - `postgresql_backup_[hour|minute]`: Controls what time the cron job will run
116
- to perform a full backup. Defaults to 1:00 AM.
98
+ - `postgresql_backup_[hour|minute]`: Controls what time the cron job will run to perform a full backup. Defaults to 1:00
99
+ AM.
117
100
118
- - `postgresql_backup_[day|month|weekday]`: Additional cron controls for when
119
- the full backup is performed (default: `*`).
101
+ - `postgresql_backup_[day|month|weekday]`: Additional cron controls for when the full backup is performed (default:
102
+ `*`).
120
103
121
- - `postgresql_backup_mail_recipient`: User or address that should receive mail
122
- from the backup scripts.
104
+ - `postgresql_backup_mail_recipient`: User or address that should receive mail from the backup scripts.
123
105
124
106
- `postgresql_backup_remote_rsync_path`: Path to `rsync` on the remote system.
125
107
126
- - `postgresql_backup_post_command`: Arbitrary command to run after successful
127
- completion of a scheduled backup.
108
+ - `postgresql_backup_post_command`: Arbitrary command to run after successful completion of a scheduled backup.
128
109
129
110
Dependencies
130
111
------------
134
115
Example Playbook
135
116
----------------
136
117
137
- Standard install: Default `postgresql.conf`, `pg_hba.conf` and default version
138
- for the OS:
118
+ Standard install: Default `postgresql.conf`, `pg_hba.conf` and default version for the OS:
139
119
140
120
```yaml
141
121
---
@@ -159,16 +139,15 @@ Use the pgdg packages on a Debian-based host:
159
139
- postgresql
160
140
` ` `
161
141
162
- Use the PostgreSQL 9.3 packages and set some ` postgresql.conf` options and
163
- `pg_hba.conf` entries :
142
+ Use the PostgreSQL 9.5 packages and set some ` postgresql.conf` options and `pg_hba.conf` entries:
164
143
165
144
` ` ` yaml
166
145
---
167
146
168
147
- hosts: dbservers
169
148
remote_user: root
170
149
vars:
171
- postgresql_version: 9.3
150
+ postgresql_version: 9.5
172
151
postgresql_conf:
173
152
listen_addresses: "''" # disable network listening (listen on unix socket only)
174
153
max_connections: 50 # decrease connection limit
0 commit comments