Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow configurable Postgres authentication #320

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,9 @@ build_guides: false
db:
postgres:
enabled: true
auth: scram-sha-256
adminpass: DVn33dsth1s
adminuser: postgres
name: dvndb
host: localhost
user: dvnuser
Expand Down
15 changes: 13 additions & 2 deletions tasks/postgres.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,14 +109,20 @@
- meta: flush_handlers

- name: dataverse python installer wants to be a postgres admin
postgresql_user:
name: postgres
community.postgresql.postgresql_user:
db: postgres
login_user: '{{ db.postgres.adminuser }}'
name: '{{ db.postgres.adminuser }}'
password: '{{ db.postgres.adminpass }}'
become: true
become_user: postgres
when: db.use_rds == false

- name: create dataverse postgres database
postgresql_db:
name: '{{ db.postgres.name }}'
become: true
become_user: postgres
when: db.use_rds == false

- name: create dataverse postgres user, set permissions
Expand All @@ -125,6 +131,8 @@
name: '{{ db.postgres.user }}'
password: '{{ db.postgres.pass }}'
role_attr_flags: 'NOSUPERUSER,CREATEDB,CREATEROLE,INHERIT,LOGIN'
become: true
become_user: postgres
when: db.use_rds == false

- name: postgresql 15 requires explicit permissions on public schema
Expand All @@ -134,6 +142,9 @@
type: schema
objs: public
role: '{{ db.postgres.user }}'
become: true
become_user: postgres
when: db.use_rds == false

- ansible.builtin.import_tasks: postgres_sequential_identifiers.yml
when: dataverse.api.test_suite == true
14 changes: 7 additions & 7 deletions templates/pg_hba.conf.j2
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
# "local" is for Unix domain socket connections only
local all all trust
local all all peer
# IPv4 local connections:
host all all 127.0.0.1/32 password
host all all 127.0.0.1/32 {{ db.postgres.auth }}
# IPv6 local connections:
host all all ::1/128 password
host all all ::1/128 {{ db.postgres.auth }}

# replication and dataverse access from other servers
{% if db.postgres.replication.enabled is defined %}
{% for item in db.postgres.replication.servers %}
{% if item | regex_search(".*/.*") %}
host all all {{ item }} md5
host replication rep {{ item }} md5
host all all {{ item }} {{ db.postgres.auth }}
host replication rep {{ item }} {{ db.postgres.auth }}
{% else %}
host all all {{ item }}/32 md5
host replication rep {{ item }}/32 md5
host all all {{ item }}/32 {{ db.postgres.auth }}
host replication rep {{ item }}/32 {{ db.postgres.auth }}
{% endif %}
{% endfor %}
{% endif %}
2 changes: 2 additions & 0 deletions tests/group_vars/jenkins.yml
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,8 @@ db:
postgres:
enabled: true
adminpass: DVn33dsth1s
adminuser: postgres
auth: scram-sha-256
name: dvndb
host: localhost
user: dvnuser
Expand Down
2 changes: 2 additions & 0 deletions tests/group_vars/memorytests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,8 @@ db:
postgres:
enabled: true
adminpass: DVn33dsth1s
adminuser: postgres
auth: scram-sha-256
name: dvndb
host: localhost
user: dvnuser
Expand Down
2 changes: 2 additions & 0 deletions tests/group_vars/vagrant.yml
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,8 @@ build_guides: false
db:
postgres:
enabled: true
auth: scram-sha-256
adminuser: postgres
adminpass: DVn33dsth1s
name: vagrantdb
host: localhost
Expand Down