You've already forked matrix-docker-ansible-deploy
mirror of
https://github.com/spantaleev/matrix-docker-ansible-deploy.git
synced 2025-06-12 22:17:28 +02:00
Do not use the postgresql_user/postgresql_db modules
While these modules are really nice and helpful, we can't use them for at least 2 reasons: - for us, Postgres runs in a container on a private Docker network (`--network=matrix`) without usually being exposed to the host. These modules execute on the host so they won't be able to reach it. - these modules require `psycopg2`, so we need to install it before using it. This might or might not be its own can of worms.
This commit is contained in:
@ -1,28 +1,13 @@
|
||||
---
|
||||
|
||||
- name: Retrieve IP of postgres container
|
||||
command: "{{ matrix_host_command_docker }} inspect matrix-postgres --format='{% raw %}{{ .NetworkSettings.Networks.{% endraw %}{{ matrix_docker_network }}{% raw %}.IPAddress }}{% endraw %}'"
|
||||
register: matrix_postgres_container_ip
|
||||
# TODO - we should ensure matrix-postgres.service is started.
|
||||
# .. and that if we had just started it, we've given it ample time to initialize,
|
||||
# before we attempt to run queries against it.
|
||||
|
||||
- name: Create additional users in postgres
|
||||
postgresql_user:
|
||||
name: "{{ item.username }}"
|
||||
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.username }}"
|
||||
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 }}"
|
||||
- name: Create additional Postgers user and database
|
||||
include_tasks: "{{ role_path }}/tasks/util/create_additional_database.yml"
|
||||
with_items: "{{ matrix_postgres_additional_databases }}"
|
||||
loop_control:
|
||||
loop_var: additional_db
|
||||
# Suppress logging to avoid dumping the credentials to the shell
|
||||
no_log: true
|
||||
|
Reference in New Issue
Block a user