diff --git a/ansible/main.yml b/ansible/main.yml index f7fa188..ac11543 100644 --- a/ansible/main.yml +++ b/ansible/main.yml @@ -33,6 +33,7 @@ - intersect-docker - plausible - duplicati + - grafana # Arch boxes - hosts: diff --git a/ansible/roles/grafana/files/docker-compose.yml b/ansible/roles/grafana/files/docker-compose.yml new file mode 100644 index 0000000..061429f --- /dev/null +++ b/ansible/roles/grafana/files/docker-compose.yml @@ -0,0 +1,19 @@ +version: "2.3" + +services: + grafana: + image: grafana/grafana:latest + environment: + - TZ=Europe/London + ports: + - 3000:3000 + volumes: + - ./grafana:/var/lib/grafana + restart: unless-stopped + networks: + - default + - grafana + +networks: + grafana: + external: true diff --git a/ansible/roles/grafana/handlers/main.yml b/ansible/roles/grafana/handlers/main.yml new file mode 100644 index 0000000..92aa72c --- /dev/null +++ b/ansible/roles/grafana/handlers/main.yml @@ -0,0 +1,4 @@ +- name: restart grafana + shell: + chdir: /opt/grafana + cmd: "{{ docker_update_command }}" diff --git a/ansible/roles/grafana/tasks/main.yml b/ansible/roles/grafana/tasks/main.yml new file mode 100644 index 0000000..dd10b85 --- /dev/null +++ b/ansible/roles/grafana/tasks/main.yml @@ -0,0 +1,30 @@ +- name: Create install directory + file: + path: /opt/grafana + state: directory + owner: "{{ docker_user.name }}" + mode: "{{ docker_compose_directory_mask }}" + become: true + +- name: Create grafana network + docker_network: + name: grafana + +- name: Create config directory + file: + path: /opt/grafana/grafana + state: directory + mode: "{{ docker_compose_directory_mask }}" + owner: "472" + group: "472" + become: true + +- name: Install compose file + template: + src: files/docker-compose.yml + dest: /opt/grafana/docker-compose.yml + mode: "{{ docker_compose_file_mask }}" + owner: "{{ docker_user.name }}" + validate: /usr/bin/docker-compose -f %s config + notify: restart grafana + become: true diff --git a/ansible/roles/home-assistant/files/docker-compose.yml b/ansible/roles/home-assistant/files/docker-compose.yml index 035d6bc..142e6d1 100644 --- a/ansible/roles/home-assistant/files/docker-compose.yml +++ b/ansible/roles/home-assistant/files/docker-compose.yml @@ -24,6 +24,11 @@ services: - ./influxdb:/var/lib/influxdb ports: - 127.0.0.1:48086:8086 + networks: + default: + grafana: + aliases: + - ha-influxdb environment: - INFLUXDB_DB=home_assistant - INFLUXDB_HTTP_AUTH_ENABLED= @@ -34,3 +39,7 @@ services: network_mode: host volumes: - ./esphome:/config + +networks: + grafana: + external: true