mirror of
https://github.com/spantaleev/matrix-docker-ansible-deploy.git
synced 2024-12-22 20:45:48 +00:00
Relocate Postgres additional database creation logic
Moving it above the "uninstalling" set of tasks is better. Extracting it out to another file at the same time, for readability, especially given that it will probably have to become more complex in the future (potentially installing `jq`, etc.)
This commit is contained in:
parent
dac0d3a682
commit
527d5f57d5
@ -113,6 +113,13 @@
|
|||||||
daemon_reload: yes
|
daemon_reload: yes
|
||||||
when: "matrix_postgres_enabled|bool and matrix_postgres_systemd_service_result.changed"
|
when: "matrix_postgres_enabled|bool and matrix_postgres_systemd_service_result.changed"
|
||||||
|
|
||||||
|
- include_tasks:
|
||||||
|
file: "{{ role_path }}/tasks/util/create_additional_databases.yml"
|
||||||
|
apply:
|
||||||
|
tags:
|
||||||
|
- always
|
||||||
|
when: "matrix_postgres_enabled|bool"
|
||||||
|
|
||||||
#
|
#
|
||||||
# Tasks related to getting rid of the internal postgres server (if it was previously enabled)
|
# Tasks related to getting rid of the internal postgres server (if it was previously enabled)
|
||||||
#
|
#
|
||||||
@ -162,33 +169,3 @@
|
|||||||
- matrix-change-user-admin-status
|
- matrix-change-user-admin-status
|
||||||
- matrix-postgres-update-user-password-hash
|
- matrix-postgres-update-user-password-hash
|
||||||
when: "not matrix_postgres_enabled|bool"
|
when: "not matrix_postgres_enabled|bool"
|
||||||
|
|
||||||
# Create additional databases
|
|
||||||
- name: Retrieve IP of postgres container
|
|
||||||
shell: "docker inspect matrix-postgres | jq -r '.[0].NetworkSettings.Networks.{{ matrix_docker_network }}.IPAddress'"
|
|
||||||
register: matirx_postgres_container_ip
|
|
||||||
|
|
||||||
- name: Create additional users in postgres
|
|
||||||
postgresql_user:
|
|
||||||
name: "{{ item.name }}"
|
|
||||||
password: "{{ item.pass }}"
|
|
||||||
login_host: "{{ matrx_postgres_container_ip.stdout }}"
|
|
||||||
login_port: 5432
|
|
||||||
login_user: "{{ matrix_postgres_connection_username }}"
|
|
||||||
login_password: "{{ matrix_postgres_connection_password }}"
|
|
||||||
login_db: "{{ matrix_postgres_db_name }}"
|
|
||||||
loop: matrix_postgres_additional_databases
|
|
||||||
when: matrix_postgres_enabed|bool
|
|
||||||
|
|
||||||
- name: Create additional users in postgres
|
|
||||||
postgresql_db:
|
|
||||||
name: "{{ item.name }}"
|
|
||||||
owner: "{{ item.name }}"
|
|
||||||
lc_ctype: 'C'
|
|
||||||
lc_collate: 'C'
|
|
||||||
login_host: "{{ matrx_postgres_container_ip.stdout }}"
|
|
||||||
login_port: 5432
|
|
||||||
login_user: "{{ matrix_postgres_connection_username }}"
|
|
||||||
login_password: "{{ matrix_postgres_connection_password }}"
|
|
||||||
loop: matrix_postgres_additional_databases
|
|
||||||
when: matrix_postgres_enabled|bool
|
|
||||||
|
@ -0,0 +1,28 @@
|
|||||||
|
---
|
||||||
|
|
||||||
|
- name: Retrieve IP of postgres container
|
||||||
|
shell: "docker inspect matrix-postgres | jq -r '.[0].NetworkSettings.Networks.{{ matrix_docker_network }}.IPAddress'"
|
||||||
|
register: matrix_postgres_container_ip
|
||||||
|
|
||||||
|
- name: Create additional users in postgres
|
||||||
|
postgresql_user:
|
||||||
|
name: "{{ item.name }}"
|
||||||
|
password: "{{ item.pass }}"
|
||||||
|
login_host: "{{ matrix_postgres_container_ip.stdout }}"
|
||||||
|
login_port: 5432
|
||||||
|
login_user: "{{ matrix_postgres_connection_username }}"
|
||||||
|
login_password: "{{ matrix_postgres_connection_password }}"
|
||||||
|
login_db: "{{ matrix_postgres_db_name }}"
|
||||||
|
loop: matrix_postgres_additional_databases
|
||||||
|
|
||||||
|
- name: Create additional users in postgres
|
||||||
|
postgresql_db:
|
||||||
|
name: "{{ item.name }}"
|
||||||
|
owner: "{{ item.name }}"
|
||||||
|
lc_ctype: 'C'
|
||||||
|
lc_collate: 'C'
|
||||||
|
login_host: "{{ matrix_postgres_container_ip.stdout }}"
|
||||||
|
login_port: 5432
|
||||||
|
login_user: "{{ matrix_postgres_connection_username }}"
|
||||||
|
login_password: "{{ matrix_postgres_connection_password }}"
|
||||||
|
loop: matrix_postgres_additional_databases
|
Loading…
Reference in New Issue
Block a user