From 88d721ad405c7944c443fc6214adaaee42bfe3e0 Mon Sep 17 00:00:00 2001 From: Kungfoome Date: Sat, 11 Jun 2022 05:13:34 +0200 Subject: [PATCH] Modify postgres role to be more customizable Currently, you can't open the port for postgres to allow ansible to interact and run queries from outside the container. This will open the port to localhost only and allow you to directly communicate with the postgres intance. This is needed for another PR, so we can run a query against the instance. Also, added username and password variables, so this can be added into the accounts.yml --- defaults/settings.yml.default | 3 +++ roles/postgres/tasks/main.yml | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/defaults/settings.yml.default b/defaults/settings.yml.default index 5f4c6aa1f..b550313ac 100644 --- a/defaults/settings.yml.default +++ b/defaults/settings.yml.default @@ -87,6 +87,9 @@ plex_auto_collections: state: present plex_meta_manager: time: 03:00 +postgres: + published_ports: + - 127.0.0.1:5432:5432 qbittorrentvpn: vpn_endpoint: netherlands.ovpn vpn_user: your_vpn_username diff --git a/roles/postgres/tasks/main.yml b/roles/postgres/tasks/main.yml index 24dac3686..7b77268a3 100644 --- a/roles/postgres/tasks/main.yml +++ b/roles/postgres/tasks/main.yml @@ -30,13 +30,15 @@ PUID: "{{ uid }}" PGID: "{{ gid }}" LOG_LEVEL: DEBUG - POSTGRES_PASSWORD: mysecretpassword + POSTGRES_USER: "{{ postgres.user }}" + POSTGRES_PASSWORD: "{{ postgres.password }}" volumes: - /opt/postgres/data:/var/lib/postgresql/data labels: "com.github.cloudbox.cloudbox_managed": "true" networks: - name: cloudbox + published_ports: "{{ postgres.published_ports|default('127.0.0.1:5432:5432',true) }}" purge_networks: yes restart_policy: unless-stopped state: started