forked from linux-system-roles/postgresql
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Add test for postgresql_cert_name
- Loading branch information
Showing
1 changed file
with
54 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
--- | ||
|
||
- name: Test PostgreSQL server with ssl support using certificate role | ||
hosts: all | ||
tasks: | ||
- name: Test PostgreSQL server user certificate in custom path | ||
vars: | ||
postgresql_password: redhat | ||
block: | ||
- name: Generate certificate using certificate role | ||
include_role: | ||
name: fedora.linux_system_roles.certificate | ||
vars: | ||
certificate_requests: | ||
- name: /tmp/mycert | ||
dns: www.example.com | ||
ca: self-sign | ||
certificate_test_mode: true | ||
|
||
- name: Deploy postgresql | ||
include_tasks: tasks/install_and_check.yml | ||
vars: | ||
__test_clean_instance: false | ||
__test_check_unix_socket: false | ||
postgresql_cert_name: /tmp/mycert | ||
postgresql_ssl_enable: true | ||
postgresql_pg_hba_conf: | ||
- type: hostssl | ||
database: all | ||
user: all | ||
auth_method: md5 | ||
address: '127.0.0.1/32' | ||
|
||
- name: Gather output of psql | ||
environment: | ||
PGPASSWORD: "{{ postgresql_password }}" | ||
shell: | | ||
set -euo pipefail | ||
echo "\conninfo" | psql -U postgres -h 127.0.0.1 | ||
register: result | ||
changed_when: false | ||
|
||
- name: Check output of psql | ||
assert: | ||
that: >- | ||
"SSL connection" in result.stdout | ||
always: | ||
- name: Stop tracking certificate | ||
command: getcert stop-tracking -f /etc/pki/tls/certs/test_crt.crt | ||
changed_when: false | ||
|
||
- name: Clean up | ||
include_tasks: tasks/clean_instance.yml | ||
tags: tests::cleanup |