-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpostgresql.yml
74 lines (72 loc) · 1.82 KB
/
postgresql.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
---
- hosts: db
become: yes
gather_facts: no
vars_files:
- secrets.yml
tasks:
- name: ensure apt cache is up to date
apt:
update_cache: yes
cache_valid_time: 86400
- name: ensure packages are installed
apt:
name:
- postgresql
- libpq-dev
- python3-psycopg2
- acl
- hosts: db
become: yes
become_user: postgres
gather_facts: no
vars_files:
- secrets.yml
tasks:
- name: ensure database is created
postgresql_db:
name: '{{ ads_db_name }}'
- name: ensure user has access to database
postgresql_user:
db: '{{ ads_db_name }}'
name: '{{ ads_db_user }}'
password: '{{ ads_db_password }}'
priv: ALL
- name: ensure user has no extra privileges
postgresql_user:
name: '{{ ads_db_user }}'
role_attr_flags: NOSUPERUSER,NOCREATEDB
- name: ensure no other user can access the database
postgresql_privs:
db: '{{ ads_db_name }}'
role: PUBLIC
type: database
priv: ALL
state: absent
- hosts: db
become: yes
become_user: postgres
gather_facts: no
vars_files:
- secrets.yml
tasks:
- name: ensure database is created
postgresql_db:
name: '{{ auth_db_name }}'
- name: ensure user has access to database
postgresql_user:
db: '{{ auth_db_name }}'
name: '{{ auth_db_user }}'
password: '{{ auth_db_password }}'
priv: ALL
- name: ensure user has no extra privileges
postgresql_user:
name: '{{ auth_db_user }}'
role_attr_flags: SUPERUSER,NOCREATEDB
- name: ensure no other user can access the database
postgresql_privs:
db: '{{ auth_db_name }}'
role: PUBLIC
type: database
priv: ALL
state: absent