Skip to content

Commit ac1084a

Browse files
committed
Feat: Add postgres-11/12
Signed-off-by: Mahdi Fooladgar (professormahi) <professormahi_f@yahoo.com>
1 parent d20c2d9 commit ac1084a

File tree

2 files changed

+26
-7
lines changed

2 files changed

+26
-7
lines changed

roles/postgres_hardening/defaults/main.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,7 @@ postgres_hardening_restart_postgres: true
99
# Postgres user/group
1010
postgres_user: postgres
1111
postgres_group: postgres
12+
13+
# SSL
14+
ssl_enabled: "on"
15+
ssl_ciphers: ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH

roles/postgres_hardening/tasks/hardening.yml

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,30 +68,45 @@
6868
msg: "Postgres Version is not secure or supported!"
6969
when: not postgres_version or 'RC' in postgres_version_raw or 'DEVEL' in postgres_version_raw or 'BETA' in postgres_version_raw
7070

71-
7271
#################################
7372
# POSTGRES-10 ###################
7473
#################################
75-
- name: Manage permissions on /etc/postgresql/14/main
74+
- name: Manage permissions on /etc/postgresql/<version>/main
7675
ansible.builtin.file:
77-
path: /etc/postgresql/14/main
76+
path: "/etc/postgresql/{{ postgres_version }}/main"
7877
state: directory
7978
owner: "{{ postgres_user }}"
8079
group: "{{ postgres_group }}"
8180
mode: u=rwx,g=,o=
8281

83-
- name: Manage permissions on /etc/postgresql/14/main/postgresql.conf
82+
- name: Manage permissions on /etc/postgresql/<version>/main/postgresql.conf
8483
ansible.builtin.file:
85-
path: /etc/postgresql/14/main/postgresql.conf
84+
path: "/etc/postgresql/{{ postgres_version }}/main/postgresql.conf"
8685
state: file
8786
owner: "{{ postgres_user }}"
8887
group: "{{ postgres_group }}"
8988
mode: u=rw,g=r,o=
9089

91-
- name: Manage permissions on /etc/postgresql/14/main/pg_hba.conf
90+
- name: Manage permissions on /etc/postgresql/<version>/main/pg_hba.conf
9291
ansible.builtin.file:
93-
path: /etc/postgresql/14/main/pg_hba.conf
92+
path: "/etc/postgresql/{{ postgres_version }}/main/pg_hba.conf"
9493
state: file
9594
owner: "{{ postgres_user }}"
9695
group: "{{ postgres_group }}"
9796
mode: u=rw,g=,o=
97+
98+
#################################
99+
# POSTGRES-11/12 ################
100+
#################################
101+
- name: Secure postgresql.conf Configuration
102+
ansible.builtin.lineinfile:
103+
path: "/etc/postgresql/{{ postgres_version }}/main/postgresql.conf"
104+
line: "{{ item.line }}"
105+
regexp: "{{ item.regexp }}"
106+
state: present
107+
with_items:
108+
- line: "ssl = {{ ssl_enabled }}"
109+
regexp: "#?ssl\\s?="
110+
- line: "ssl_ciphers = '{{ ssl_ciphers }}'"
111+
regexp: "#?ssl_ciphers\\s?="
112+
notify: Restart postgres

0 commit comments

Comments
 (0)