add container grafana
This commit is contained in:
parent
154cfe056f
commit
626f20daee
9 changed files with 67 additions and 0 deletions
|
@ -51,3 +51,8 @@
|
|||
tags:
|
||||
- booklore
|
||||
- docker-container
|
||||
|
||||
- role: deploy_container_grafana
|
||||
tags:
|
||||
- grafana
|
||||
- docker-container
|
||||
|
|
3
ansible/roles/deploy_container_grafana/defaults/main.yml
Normal file
3
ansible/roles/deploy_container_grafana/defaults/main.yml
Normal file
|
@ -0,0 +1,3 @@
|
|||
---
|
||||
container_grafana_version: latest
|
||||
container_grafana_domain: grafana.example.com
|
0
ansible/roles/deploy_container_grafana/files/.gitkeep
Normal file
0
ansible/roles/deploy_container_grafana/files/.gitkeep
Normal file
0
ansible/roles/deploy_container_grafana/handlers/main.yml
Normal file
0
ansible/roles/deploy_container_grafana/handlers/main.yml
Normal file
0
ansible/roles/deploy_container_grafana/meta/main.yml
Normal file
0
ansible/roles/deploy_container_grafana/meta/main.yml
Normal file
24
ansible/roles/deploy_container_grafana/tasks/main.yml
Normal file
24
ansible/roles/deploy_container_grafana/tasks/main.yml
Normal file
|
@ -0,0 +1,24 @@
|
|||
---
|
||||
- name: Ensure data directories exist
|
||||
ansible.builtin.file:
|
||||
path: "{{ container_base_dir }}/"
|
||||
state: directory
|
||||
mode: '0755'
|
||||
become: false
|
||||
|
||||
- name: Deploy Docker Compose and .env files
|
||||
ansible.builtin.template:
|
||||
src: "{{ item.src }}"
|
||||
dest: "{{ container_base_dir }}/{{ item.dest }}"
|
||||
mode: '0644'
|
||||
loop:
|
||||
- { src: 'docker-compose.yml.j2', dest: 'docker-compose.yml' }
|
||||
- { src: '.env.j2', dest: '.env' }
|
||||
become: false
|
||||
|
||||
- name: Start Container
|
||||
community.docker.docker_compose_v2:
|
||||
project_src: "{{ container_base_dir }}"
|
||||
pull: always
|
||||
docker_host: "unix:///run/user/1000/docker.sock"
|
||||
become: false
|
2
ansible/roles/deploy_container_grafana/templates/.env.j2
Normal file
2
ansible/roles/deploy_container_grafana/templates/.env.j2
Normal file
|
@ -0,0 +1,2 @@
|
|||
GRAFANA_VERSION={{ container_grafana_version }}
|
||||
GRAFANA_DOMAIN={{ container_grafana_domain }}
|
|
@ -0,0 +1,32 @@
|
|||
---
|
||||
services:
|
||||
grafana:
|
||||
image: grafana/grafana:${GRAFANA_VERSION}
|
||||
container_name: grafana
|
||||
restart: unless-stopped
|
||||
networks:
|
||||
traefik:
|
||||
volumes:
|
||||
- 'grafana_storage:/var/lib/grafana'
|
||||
environment:
|
||||
- GF_SERVER_ROOT_URL=https://${GRAFANA_DOMAIN}/
|
||||
- GF_PLUGINS_PREINSTALL=grafana-clock-panel
|
||||
labels:
|
||||
- "traefik.enable=true"
|
||||
- "traefik.docker.network=traefik"
|
||||
- "traefik.http.routers.grafana.entrypoints=http"
|
||||
- "traefik.http.routers.grafana.rule=Host(`${GRAFANA_DOMAIN}`)"
|
||||
- "traefik.http.middlewares.grafana-https-redirect.redirectscheme.scheme=https"
|
||||
- "traefik.http.routers.grafana.middlewares=grafana-https-redirect"
|
||||
- "traefik.http.routers.grafana-secure.entrypoints=https"
|
||||
- "traefik.http.routers.grafana-secure.rule=Host(`${GRAFANA_DOMAIN}`)"
|
||||
- "traefik.http.routers.grafana-secure.tls=true"
|
||||
- "traefik.http.routers.grafana-secure.service=grafana"
|
||||
- "traefik.http.services.grafana.loadbalancer.server.port=3000"
|
||||
|
||||
volumes:
|
||||
grafana_storage: {}
|
||||
|
||||
networks:
|
||||
traefik:
|
||||
external: true
|
1
ansible/roles/deploy_container_grafana/vars/main.yml
Normal file
1
ansible/roles/deploy_container_grafana/vars/main.yml
Normal file
|
@ -0,0 +1 @@
|
|||
container_base_dir: /opt/docker/grafana
|
Loading…
Add table
Reference in a new issue