1 # Copyright (C) The Arvados Authors. All rights reserved.
3 # SPDX-License-Identifier: Apache-2.0
5 - name: Install PostgreSQL server package
8 name: "{{ arvados_postgresql_package }}"
10 - name: Find pg_hba.conf file
11 when: arvados_postgresql_hba_file is falsy
14 community.postgresql.postgresql_query:
17 register: pg_hba_query
19 - name: Create pg_hba.conf entries
20 when: arvados_postgresql_hba_databases is truthy and arvados_postgresql_hba_users is truthy
22 loop: "{{ arvados_postgresql_hba_sources }}"
23 community.postgresql.postgresql_pg_hba:
24 dest: "{{ arvados_postgresql_hba_file or pg_hba_query.query_result.0.hba_file }}"
25 contype: "{{ arvados_postgresql_hba_contype }}"
26 databases: "{{ arvados_postgresql_hba_databases }}"
27 method: "{{ arvados_postgresql_hba_method }}"
28 users: "{{ arvados_postgresql_hba_users }}"
30 register: pg_hba_entries
32 - name: Write PostgreSQL conf.d file
33 when: arvados_postgresql_config is truthy
36 conf_dir: "{{ (arvados_postgresql_hba_file or pg_hba_query.query_result.0.hba_file)|dirname }}"
37 ansible.builtin.template:
38 src: arvados-ansible.conf.j2
39 dest: "{{ arvados_postgreqsl_config_path or (conf_dir, 'conf.d', 'arvados-ansible.conf')|path_join }}"
43 register: arvados_postgresql_config_update
45 - name: Set up PostgreSQL service
47 ansible.builtin.systemd_service:
48 name: "postgresql@{{ (arvados_postgresql_hba_file or pg_hba_query.query_result.0.hba_file)|dirname|relpath('/etc/postgresql')|replace('/', '-') }}.service"
49 state: "{{ 'restarted' if arvados_postgresql_config_update.changed else 'reloaded' if pg_hba_entries.changed else 'started' }}"