-
-
Notifications
You must be signed in to change notification settings - Fork 428
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enabled TLS encryption for PostgreSQL and PgBouncer (#849)
- Loading branch information
Showing
9 changed files
with
113 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
--- | ||
# for add_pgnode.yml | ||
|
||
- name: Ensure TLS directories exist | ||
ansible.builtin.file: | ||
path: "{{ item | dirname }}" | ||
state: directory | ||
owner: "{{ tls_owner | default('postgres') }}" | ||
group: "{{ tls_owner | default('postgres') }}" | ||
mode: "0750" | ||
loop: | ||
- "{{ tls_privatekey_path | default('/etc/tls/server.key') }}" | ||
- "{{ tls_cert_path | default('/etc/tls/server.crt') }}" | ||
|
||
- name: Fetch TLS certificate and key from master | ||
run_once: true | ||
ansible.builtin.fetch: | ||
src: "{{ item }}" | ||
dest: "files/tls/" | ||
validate_checksum: true | ||
flat: true | ||
delegate_to: "{{ groups.master[0] }}" | ||
loop: | ||
- "{{ tls_privatekey_path | default('/etc/tls/server.key') }}" | ||
- "{{ tls_cert_path | default('/etc/tls/server.crt') }}" | ||
|
||
- name: Copy TLS certificate and key to replica | ||
ansible.builtin.copy: | ||
src: "files/tls/{{ item.path | basename }}" | ||
dest: "{{ item.path }}" | ||
owner: "{{ tls_owner | default('postgres') }}" | ||
group: "{{ tls_owner | default('postgres') }}" | ||
mode: "{{ item.mode }}" | ||
loop: | ||
- { path: "{{ tls_privatekey_path | default('/etc/tls/server.key') }}", mode: "{{ tls_privatekey_mode | default('0400') }}" } | ||
- { path: "{{ tls_cert_path | default('/etc/tls/server.crt') }}", mode: "{{ tls_cert_mode | default('0644') }}" } | ||
|
||
- name: Delete TLS certificate and key from the ansible controller | ||
ansible.builtin.file: | ||
path: "files/tls/" | ||
state: absent | ||
delegate_to: localhost |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
--- | ||
- name: Ensure TLS directories exist | ||
ansible.builtin.file: | ||
path: "{{ item | dirname }}" | ||
state: directory | ||
owner: "{{ tls_owner | default('postgres') }}" | ||
group: "{{ tls_owner | default('postgres') }}" | ||
mode: "0750" | ||
loop: | ||
- "{{ tls_privatekey_path | default('/etc/tls/server.key') }}" | ||
- "{{ tls_cert_path | default('/etc/tls/server.crt') }}" | ||
|
||
- name: "Generate private TLS key {{ tls_privatekey_path | default('/etc/tls/server.key') }}" | ||
community.crypto.openssl_privatekey: | ||
path: "{{ tls_privatekey_path | default('/etc/tls/server.key') }}" | ||
owner: "{{ tls_owner | default('postgres') }}" | ||
group: "{{ tls_owner | default('postgres') }}" | ||
mode: "{{ tls_privatekey_mode | default('0400') }}" | ||
size: "{{ tls_privatekey_size | default(4096) }}" | ||
type: "{{ tls_privatekey_type | default('RSA') }}" | ||
|
||
- name: "Generate self-signed TLS certificate {{ tls_cert_path | default('/etc/tls/server.crt') }}" | ||
community.crypto.x509_certificate: | ||
path: "{{ tls_cert_path | default('/etc/tls/server.crt') }}" | ||
privatekey_path: "{{ tls_privatekey_path | default('/etc/tls/server.key') }}" | ||
owner: "{{ tls_owner | default('postgres') }}" | ||
group: "{{ tls_owner | default('postgres') }}" | ||
mode: "{{ tls_cert_mode | default('0644') }}" | ||
provider: "{{ tls_cert_provider | default('selfsigned') }}" | ||
entrust_not_after: "+{{ tls_cert_valid_days | default(3650) }}d" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters