diff --git a/defaults/main.yml b/defaults/main.yml index a39a381..9d3278d 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -9,6 +9,7 @@ grafana_cont_name: '{{ grafana_service_name }}' grafana_cont_vol: '{{ grafana_service_path }}/data' # see: http://docs.grafana.org/installation/docker/#migration-from-a-previous-version-of-the-docker-container-to-5-1-or-later grafana_cont_uid: 472 +grafana_cont_networks: [] # Permission adjust for dockremap. grafana_host_uid: '{{ 100000 + grafana_cont_uid | int }}' grafana_cont_port: 9400 diff --git a/templates/docker-compose.yml.j2 b/templates/docker-compose.yml.j2 index adb5111..bc67ac7 100644 --- a/templates/docker-compose.yml.j2 +++ b/templates/docker-compose.yml.j2 @@ -6,6 +6,9 @@ services: restart: always environment: GF_INSTALL_PLUGINS: '{{ grafana_plugins | join(",") }}' +{% if grafana_cont_networks != [] %} + networks: {{ grafana_cont_networks | to_json }} +{% endif %} ports: - '127.0.0.1:{{ grafana_cont_port }}:{{ grafana_cont_port }}' volumes: @@ -16,3 +19,11 @@ services: interval: 30s timeout: 10s retries: 3 + +{% if grafana_cont_networks != [] %} +{% for network in grafana_cont_networks %} +networks: + {{ network }}: + external: true +{% endfor %} +{% endif %}