Skip to content

Commit 3b31943

Browse files
committed
Add role "pgpass"
1 parent b6be91f commit 3b31943

File tree

6 files changed

+33
-0
lines changed

6 files changed

+33
-0
lines changed

add_pgnode.yml

+2
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,8 @@
150150
- role: pgbouncer
151151
when: pgbouncer_install|bool
152152

153+
- role: pgpass
154+
153155
- role: patroni
154156

155157
- role: vip-manager

config_pgcluster.yml

+2
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,8 @@
144144
tags: always
145145

146146
roles:
147+
- role: pgpass
148+
147149
- role: patroni/config
148150

149151
- role: vip-manager

deploy_pgcluster.yml

+2
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,8 @@
223223
- role: pgbouncer
224224
when: pgbouncer_install|bool
225225

226+
- role: pgpass
227+
226228
- role: patroni
227229

228230
- role: vip-manager

roles/pgpass/tasks/main.yml

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
---
2+
3+
- name: "Configure a password file ({{ postgresql_home_dir }}/.pgpass)"
4+
become: true
5+
become_user: postgres
6+
copy:
7+
content: |
8+
{% for pgpass in postgresql_pgpass %}
9+
{{ pgpass }}
10+
{% endfor %}
11+
dest: "{{ postgresql_home_dir }}/.pgpass"
12+
owner: postgres
13+
group: postgres
14+
mode: 0600
15+
when:
16+
- postgresql_pgpass is defined
17+
- postgresql_pgpass | length > 0
18+
tags: pgpass
19+
20+
...

tags.md

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
- - etcd_start
3535
- - etcd_status
3636
- consul
37+
- pgpass
3738
- patroni
3839
- - pip
3940
- - patroni_install

vars/main.yml

+6
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,12 @@ postgresql_pg_ident: []
265265
# - { mapname: "main", system_username: "postgres", pg_username: "backup" }
266266
# - { mapname: "", system_username: "", pg_username: "" }
267267

268+
# the password file (~/.pgpass)
269+
postgresql_pgpass:
270+
- "localhost:{{ postgresql_port }}:*:{{ patroni_superuser_username }}:{{ patroni_superuser_password }}"
271+
- "{{ inventory_hostname }}:{{ postgresql_port }}:*:{{ patroni_superuser_username }}:{{ patroni_superuser_password }}"
272+
# - hostname:port:database:username:password
273+
268274

269275
# PgBouncer parameters
270276
pgbouncer_install: true # or 'false' if you do not want to install and configure the pgbouncer service

0 commit comments

Comments
 (0)