diff --git a/env.yml b/env.yml index 8091f23..099c080 100644 --- a/env.yml +++ b/env.yml @@ -3,6 +3,7 @@ timezone: "Europe/Paris" host_uid: 1000 docker_projects_dir: "{{ ansible_env['HOME'] }}/docker-projects" project_dir: "{{ docker_projects_dir }}/{{ role_name }}" +docker_host: "unix:///run/user/{{ host_uid }}/docker.sock" # UID shift for mapping between host & containers uid_shift: 99999 diff --git a/roles/dockerd/tasks/main.yml b/roles/dockerd/tasks/main.yml index 7134a86..5628d96 100644 --- a/roles/dockerd/tasks/main.yml +++ b/roles/dockerd/tasks/main.yml @@ -40,7 +40,7 @@ lineinfile: path: "{{ ansible_env['HOME'] }}/.profile" regex: '^export DOCKER_HOST=' - line: "export DOCKER_HOST=unix:///run/user/{{ host_uid }}/docker.sock" + line: "export DOCKER_HOST={{ docker_host }}" - name: "Make sure lingering is enabled for user {{ host_uid }}" command: diff --git a/roles/hedgedoc/tasks/backup.yml b/roles/hedgedoc/tasks/backup.yml index 5e1ca62..fed2a18 100644 --- a/roles/hedgedoc/tasks/backup.yml +++ b/roles/hedgedoc/tasks/backup.yml @@ -1,7 +1,7 @@ - name: Backup MySQL database community.docker.docker_container_exec: container: hedgedoc-mysql - docker_host: "unix:///run/user/{{ host_uid }}/docker.sock" + docker_host: "{{ docker_host }}" argv: - /bin/bash - "-c" diff --git a/roles/postgres/tasks/backup.yml b/roles/postgres/tasks/backup.yml index e9bfef1..cd90c01 100644 --- a/roles/postgres/tasks/backup.yml +++ b/roles/postgres/tasks/backup.yml @@ -8,7 +8,7 @@ - --stdin-name dumpall.sql environment: - DOCKER_HOST: "unix:///run/user/{{ host_uid }}/docker.sock" + DOCKER_HOST: "{{ docker_host }}" BORG_PASSCOMMAND: "cat {{ borg_passphrase_file }}" become: true diff --git a/roles/synapse/tasks/backup.yml b/roles/synapse/tasks/backup.yml index f4d02fc..dc38e8e 100644 --- a/roles/synapse/tasks/backup.yml +++ b/roles/synapse/tasks/backup.yml @@ -1,7 +1,7 @@ - name: Backup PostgreSQL database community.docker.docker_container_exec: container: synapse-postgres - docker_host: "unix:///run/user/{{ host_uid }}/docker.sock" + docker_host: "{{ docker_host }}" command: | pg_dump -c -d synapse