|
|
|
@ -1,10 +1,10 @@
|
|
|
|
---
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
|
|
### tags:
|
|
|
|
### tags:
|
|
|
|
### update_config
|
|
|
|
### update_config
|
|
|
|
### update_deployment
|
|
|
|
### update_deployment
|
|
|
|
### update-digitalocean-metrics
|
|
|
|
### update-digitalocean-metrics
|
|
|
|
### update-hetzner-metrics
|
|
|
|
### update-hetzner-metrics
|
|
|
|
|
|
|
|
### grafana-user-update
|
|
|
|
|
|
|
|
|
|
|
|
- name: "Create/Resize LVM for datadir"
|
|
|
|
- name: "Create/Resize LVM for datadir"
|
|
|
|
include_role:
|
|
|
|
include_role:
|
|
|
|
@ -28,7 +28,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
- name: "Check if {{ inventory_hostname }}/docker-compose.yml exists"
|
|
|
|
- name: "Check if {{ inventory_hostname }}/docker-compose.yml exists"
|
|
|
|
stat:
|
|
|
|
stat:
|
|
|
|
path: '{{ service_base_path }}/{{ inventory_hostname }}/docker-compose.yml'
|
|
|
|
path: "{{ service_base_path }}/{{ inventory_hostname }}/docker-compose.yml"
|
|
|
|
register: check_docker_compose_file
|
|
|
|
register: check_docker_compose_file
|
|
|
|
tags:
|
|
|
|
tags:
|
|
|
|
- update_config
|
|
|
|
- update_config
|
|
|
|
@ -36,7 +36,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
- name: "Stop {{ inventory_hostname }}"
|
|
|
|
- name: "Stop {{ inventory_hostname }}"
|
|
|
|
community.docker.docker_compose:
|
|
|
|
community.docker.docker_compose:
|
|
|
|
project_src: '{{ service_base_path }}/{{ inventory_hostname }}'
|
|
|
|
project_src: "{{ service_base_path }}/{{ inventory_hostname }}"
|
|
|
|
state: absent
|
|
|
|
state: absent
|
|
|
|
when: check_docker_compose_file.stat.exists
|
|
|
|
when: check_docker_compose_file.stat.exists
|
|
|
|
tags:
|
|
|
|
tags:
|
|
|
|
@ -58,7 +58,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
- name: "Update {{ inventory_hostname }}"
|
|
|
|
- name: "Update {{ inventory_hostname }}"
|
|
|
|
community.docker.docker_compose:
|
|
|
|
community.docker.docker_compose:
|
|
|
|
project_src: '{{ service_base_path }}/{{ inventory_hostname }}'
|
|
|
|
project_src: "{{ service_base_path }}/{{ inventory_hostname }}"
|
|
|
|
state: present
|
|
|
|
state: present
|
|
|
|
pull: yes
|
|
|
|
pull: yes
|
|
|
|
tags:
|
|
|
|
tags:
|
|
|
|
@ -69,40 +69,88 @@
|
|
|
|
tags:
|
|
|
|
tags:
|
|
|
|
- update_config
|
|
|
|
- update_config
|
|
|
|
|
|
|
|
|
|
|
|
- name: "Wait for {{ http_s }}://{{ inventory_hostname }}-grafana.{{ domain }}"
|
|
|
|
- name: Create or update Grafana users
|
|
|
|
|
|
|
|
community.grafana.grafana_user:
|
|
|
|
|
|
|
|
url: "{{ http_s }}://{{ grafana_id }}.{{ domain }}"
|
|
|
|
|
|
|
|
url_username: "{{ grafana_admin_username }}"
|
|
|
|
|
|
|
|
url_password: "{{ grafana_admin_password }}"
|
|
|
|
|
|
|
|
name: "{{ item.name }}"
|
|
|
|
|
|
|
|
email: "{{ item.email }}"
|
|
|
|
|
|
|
|
login: "{{ item.login }}"
|
|
|
|
|
|
|
|
password: "{{ item.password }}"
|
|
|
|
|
|
|
|
is_admin: false
|
|
|
|
|
|
|
|
state: present
|
|
|
|
|
|
|
|
loop: "{{ grafana_users }}"
|
|
|
|
|
|
|
|
tags:
|
|
|
|
|
|
|
|
- grafana-user-update
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: "Get all Dashboard uids from {{ http_s }}://{{ inventory_hostname }}-grafana.{{ domain }}"
|
|
|
|
uri:
|
|
|
|
uri:
|
|
|
|
url: "{{ http_s }}://{{ grafana_id }}.{{ domain }}/api/admin/stats"
|
|
|
|
url: "{{ http_s }}://{{ grafana_id }}.{{ domain }}/api/search"
|
|
|
|
url_username: "{{ grafana_admin_username }}"
|
|
|
|
url_username: "{{ grafana_admin_username }}"
|
|
|
|
url_password: "{{ grafana_admin_password }}"
|
|
|
|
url_password: "{{ grafana_admin_password }}"
|
|
|
|
force_basic_auth: yes
|
|
|
|
force_basic_auth: yes
|
|
|
|
method: GET
|
|
|
|
method: GET
|
|
|
|
status_code: 200
|
|
|
|
status_code: 200
|
|
|
|
return_content: yes
|
|
|
|
return_content: yes
|
|
|
|
register: grafana_stats
|
|
|
|
register: grafana_dashboards
|
|
|
|
until: grafana_stats.status == 200
|
|
|
|
until: grafana_dashboards.status == 200
|
|
|
|
retries: 10
|
|
|
|
retries: 10
|
|
|
|
delay: 60
|
|
|
|
delay: 60
|
|
|
|
|
|
|
|
tags:
|
|
|
|
|
|
|
|
- grafana-user-update
|
|
|
|
|
|
|
|
|
|
|
|
- name: Create grafana users
|
|
|
|
- name: "Get all existing Dashboard uids"
|
|
|
|
|
|
|
|
set_fact:
|
|
|
|
|
|
|
|
grafana_dashboards_uids: "{{ grafana_dashboards.json | json_query('[].uid') }}"
|
|
|
|
|
|
|
|
tags:
|
|
|
|
|
|
|
|
- grafana-user-update
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: "Printing Grafana Dashboard IDs"
|
|
|
|
|
|
|
|
debug:
|
|
|
|
|
|
|
|
msg: "{{ grafana_dashboards_uids }}"
|
|
|
|
|
|
|
|
tags:
|
|
|
|
|
|
|
|
- grafana-user-update
|
|
|
|
|
|
|
|
when:
|
|
|
|
|
|
|
|
- debug
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: Restrict admin dashboard permissions
|
|
|
|
uri:
|
|
|
|
uri:
|
|
|
|
url: "{{ http_s }}://{{ grafana_id }}.{{ domain }}/api/admin/users"
|
|
|
|
url: "{{ http_s }}://{{ grafana_id }}.{{ domain }}/api/dashboards/uid/{{ item }}/permissions"
|
|
|
|
url_username: "{{ grafana_admin_username }}"
|
|
|
|
url_username: "{{ grafana_admin_username }}"
|
|
|
|
url_password: "{{ grafana_admin_password }}"
|
|
|
|
url_password: "{{ grafana_admin_password }}"
|
|
|
|
force_basic_auth: yes
|
|
|
|
force_basic_auth: yes
|
|
|
|
method: POST
|
|
|
|
method: POST
|
|
|
|
status_code: 200
|
|
|
|
headers:
|
|
|
|
|
|
|
|
Content-Type: application/json
|
|
|
|
body_format: json
|
|
|
|
body_format: json
|
|
|
|
body: "{\"name\":\"{{ item.name }}\", \"email\":\"{{ item.email }}\", \"login\":\"{{ item.login }}\", \"password\":\"{{ item.password }}\" }"
|
|
|
|
body:
|
|
|
|
|
|
|
|
items:
|
|
|
|
|
|
|
|
- role: Admin
|
|
|
|
|
|
|
|
permission: 4
|
|
|
|
|
|
|
|
return_content: yes
|
|
|
|
|
|
|
|
loop: "{{ grafana_dashboards_uids | difference(grafana_dashboard_whitelist) | list }}"
|
|
|
|
|
|
|
|
tags:
|
|
|
|
|
|
|
|
- grafana-user-update
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- name: Allow viewer dashboard permissions
|
|
|
|
|
|
|
|
uri:
|
|
|
|
|
|
|
|
url: "{{ http_s }}://{{ grafana_id }}.{{ domain }}/api/dashboards/uid/{{ item }}/permissions"
|
|
|
|
|
|
|
|
url_username: "{{ grafana_admin_username }}"
|
|
|
|
|
|
|
|
url_password: "{{ grafana_admin_password }}"
|
|
|
|
|
|
|
|
force_basic_auth: yes
|
|
|
|
|
|
|
|
method: POST
|
|
|
|
headers:
|
|
|
|
headers:
|
|
|
|
Content-Type: application/json
|
|
|
|
Content-Type: application/json
|
|
|
|
loop:
|
|
|
|
body_format: json
|
|
|
|
- {
|
|
|
|
body:
|
|
|
|
name: "{{ grafana_user_smardigo_login }}",
|
|
|
|
items:
|
|
|
|
login: "{{ grafana_user_smardigo_login }}",
|
|
|
|
- role: Viewer
|
|
|
|
password: "{{ grafana_user_smardigo_password }}",
|
|
|
|
permission: 1
|
|
|
|
email: "smardigo@netgo.de"
|
|
|
|
return_content: yes
|
|
|
|
}
|
|
|
|
loop: "{{ grafana_dashboard_whitelist }}"
|
|
|
|
when: grafana_stats.json.users == 1
|
|
|
|
tags:
|
|
|
|
|
|
|
|
- grafana-user-update
|
|
|
|
|
|
|
|
|
|
|
|
- name: "Create digitalocean api metric script from template"
|
|
|
|
- name: "Create digitalocean api metric script from template"
|
|
|
|
template:
|
|
|
|
template:
|
|
|
|
|