You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
153 lines
4.3 KiB
YAML
153 lines
4.3 KiB
YAML
---
|
|
|
|
### tags:
|
|
### update_config
|
|
### update_deployment
|
|
|
|
- name: "Create/Resize LVM for datadir"
|
|
include_role:
|
|
name: lvm_with_hetzner_volumes
|
|
vars:
|
|
lvm_with_hetzner_volumes__volprefix: prometheus_datadir
|
|
lvm_with_hetzner_volumes__volsize: "{{ prometheus_lvm_hcloudvol_size }}"
|
|
lvm_with_hetzner_volumes__volcount: "{{ prometheus_lvm_hcloudvol_count }}"
|
|
lvm_with_hetzner_volumes__mountpath: "{{ prometheus_lvm_hcloudvol_mountpath }}"
|
|
|
|
- name: "Setup DNS configuration for <{{ inventory_hostname }}>"
|
|
include_role:
|
|
name: sma_digitalocean
|
|
tasks_from: domain
|
|
vars:
|
|
record_data: "{{ stage_server_ip }}"
|
|
record_name: "{{ item }}"
|
|
loop:
|
|
- "{{ prometheus_id }}"
|
|
- "{{ grafana_id }}"
|
|
- "{{ alertmanager_id }}"
|
|
|
|
- name: "Check if {{ inventory_hostname }}/docker-compose.yml exists"
|
|
stat:
|
|
path: '{{ service_base_path }}/{{ inventory_hostname }}/docker-compose.yml'
|
|
register: check_docker_compose_file
|
|
tags:
|
|
- update_config
|
|
- update_deployment
|
|
|
|
- name: "Stop {{ inventory_hostname }}"
|
|
community.docker.docker_compose:
|
|
project_src: '{{ service_base_path }}/{{ inventory_hostname }}'
|
|
state: absent
|
|
when: check_docker_compose_file.stat.exists
|
|
tags:
|
|
- update_deployment
|
|
|
|
- name: "Deploy docker templates for {{ inventory_hostname }}"
|
|
include_role:
|
|
name: sma_deploy
|
|
tasks_from: templates
|
|
vars:
|
|
current_config: "_docker"
|
|
current_base_path: "{{ service_base_path }}"
|
|
current_destination: "{{ inventory_hostname }}"
|
|
current_owner: "{{ docker_owner }}"
|
|
current_group: "{{ docker_group }}"
|
|
current_docker: "{{ prometheus_docker }}"
|
|
tags:
|
|
- update_deployment
|
|
|
|
- name: "Deploy service templates for {{ inventory_hostname }}"
|
|
include_role:
|
|
name: sma_deploy
|
|
tasks_from: templates
|
|
vars:
|
|
current_config: "prometheus"
|
|
current_base_path: "{{ service_base_path }}"
|
|
current_destination: "{{ inventory_hostname }}"
|
|
current_owner: "{{ docker_owner }}"
|
|
current_group: "{{ docker_group }}"
|
|
tags:
|
|
- update_config
|
|
|
|
- name: "Update {{ inventory_hostname }}"
|
|
community.docker.docker_compose:
|
|
project_src: '{{ service_base_path }}/{{ inventory_hostname }}'
|
|
state: present
|
|
pull: yes
|
|
tags:
|
|
- update_deployment
|
|
|
|
- name: "Wait for <{{ http_s }}://{{ prometheus_id }}.{{ domain }}>"
|
|
uri:
|
|
url: "{{ http_s }}://{{ prometheus_id }}.{{ domain }}"
|
|
method: GET
|
|
status_code: 200
|
|
return_content: yes
|
|
register: prometheus_stats
|
|
until: prometheus_stats.status == 200
|
|
retries: 10
|
|
delay: 60
|
|
tags:
|
|
- update_config
|
|
|
|
- name: "Reload prometheus configuration"
|
|
uri:
|
|
url: "{{ http_s }}://{{ prometheus_id }}.{{ domain }}/-/reload"
|
|
method: POST
|
|
timeout: 300 # blocks until reload configuration is complete
|
|
status_code: 200
|
|
tags:
|
|
- update_config
|
|
|
|
- name: "Wait for {{ http_s }}://{{ inventory_hostname }}-grafana.{{ domain }}"
|
|
uri:
|
|
url: "{{ http_s }}://{{ grafana_id }}.{{ domain }}/api/admin/stats"
|
|
url_username: "{{ grafana_admin_username }}"
|
|
url_password: "{{ grafana_admin_password }}"
|
|
force_basic_auth: yes
|
|
method: GET
|
|
status_code: 200
|
|
return_content: yes
|
|
register: grafana_stats
|
|
until: grafana_stats.status == 200
|
|
retries: 10
|
|
delay: 60
|
|
|
|
- name: Create grafana users
|
|
uri:
|
|
url: "{{ http_s }}://{{ grafana_id }}.{{ domain }}/api/admin/users"
|
|
url_username: "{{ grafana_admin_username }}"
|
|
url_password: "{{ grafana_admin_password }}"
|
|
force_basic_auth: yes
|
|
method: POST
|
|
status_code: 200
|
|
body_format: json
|
|
body: "{\"name\":\"{{ item.name }}\", \"email\":\"{{ item.email }}\", \"login\":\"{{ item.login }}\", \"password\":\"{{ item.password }}\" }"
|
|
headers:
|
|
Content-Type: application/json
|
|
loop:
|
|
- {
|
|
name: "{{ grafana_user_smardigo_login }}",
|
|
login: "{{ grafana_user_smardigo_login }}",
|
|
password: "{{ grafana_user_smardigo_password }}",
|
|
email: "smardigo@netgo.de"
|
|
}
|
|
when: grafana_stats.json.users == 1
|
|
|
|
- name: "Create DO-metrics script from template"
|
|
template:
|
|
src: do_too_many_req_metrics.sh.j2
|
|
dest: /root/do_too_many_req_metrics.sh
|
|
mode: 0700
|
|
owner: root
|
|
group: root
|
|
tags:
|
|
- update-do-metrics
|
|
|
|
- name: "Create cronjob to exec DO-metrics script"
|
|
ansible.builtin.cron:
|
|
name: "update replication table"
|
|
minute: "*"
|
|
job: /root/do_too_many_req_metrics.sh
|
|
tags:
|
|
- update-do-metrics
|