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.
193 lines
5.0 KiB
YAML
193 lines
5.0 KiB
YAML
---
|
|
|
|
### tags:
|
|
### update_config
|
|
### update_deployment
|
|
|
|
- name: "Setup DNS configuration for {{ inventory_hostname }} prometheus"
|
|
include_role:
|
|
name: _digitalocean
|
|
tasks_from: domain
|
|
vars:
|
|
record_data: "{{ stage_server_ip }}"
|
|
record_name: "{{ inventory_hostname }}-prometheus"
|
|
|
|
- name: "Setup DNS configuration for {{ inventory_hostname }} grafana"
|
|
include_role:
|
|
name: _digitalocean
|
|
tasks_from: domain
|
|
vars:
|
|
record_data: "{{ stage_server_ip }}"
|
|
record_name: "{{ inventory_hostname }}-grafana"
|
|
|
|
- name: "Setup DNS configuration for {{ inventory_hostname }} alertmanager"
|
|
include_role:
|
|
name: _digitalocean
|
|
tasks_from: domain
|
|
vars:
|
|
record_data: "{{ stage_server_ip }}"
|
|
record_name: "{{ inventory_hostname }}-alertmanager"
|
|
|
|
- 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 }}"
|
|
shell: docker-compose down
|
|
args:
|
|
chdir: '{{ service_base_path }}/{{ inventory_hostname }}'
|
|
when: check_docker_compose_file.stat.exists
|
|
ignore_errors: yes
|
|
tags:
|
|
- update_deployment
|
|
|
|
- name: "Deploy docker templates for {{ inventory_hostname }}"
|
|
include_role:
|
|
name: _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_config
|
|
|
|
- name: "Reading current server groups from hetzner"
|
|
include_role:
|
|
name: hcloud
|
|
tasks_from: _read_server_names
|
|
with_items: [
|
|
{
|
|
name: "all",
|
|
label_selector: "stage={{ stage }}",
|
|
},
|
|
{
|
|
name: "awx",
|
|
label_selector: "stage={{ stage }},service=awx",
|
|
},
|
|
{
|
|
name: "connect",
|
|
label_selector: "stage={{ stage }},service=connect",
|
|
},
|
|
{
|
|
name: "elastic",
|
|
label_selector: "stage={{ stage }},service=elastic",
|
|
},
|
|
{
|
|
name: "harbor",
|
|
label_selector: "stage={{ stage }},service=harbor",
|
|
},
|
|
{
|
|
name: "iam",
|
|
label_selector: "stage={{ stage }},service=iam",
|
|
},
|
|
{
|
|
name: "keycloak",
|
|
label_selector: "stage={{ stage }},service=keycloak",
|
|
},
|
|
{
|
|
name: "kibana",
|
|
label_selector: "stage={{ stage }},service=kibana",
|
|
},
|
|
{
|
|
name: "logstash",
|
|
label_selector: "stage={{ stage }},service=logstash",
|
|
},
|
|
{
|
|
name: "maria",
|
|
label_selector: "stage={{ stage }},service=maria",
|
|
},
|
|
{
|
|
name: "mail",
|
|
label_selector: "stage={{ stage }},service=mail",
|
|
},
|
|
{
|
|
name: "postfix",
|
|
label_selector: "stage={{ stage }},service=postfix",
|
|
},
|
|
{
|
|
name: "postgres",
|
|
label_selector: "stage={{ stage }},service=postgres",
|
|
},
|
|
{
|
|
name: "webdav",
|
|
label_selector: "stage={{ stage }},service=webdav",
|
|
}
|
|
]
|
|
loop_control:
|
|
loop_var: current_server_group
|
|
tags:
|
|
- update_config
|
|
|
|
- name: "Deploy service templates for {{ inventory_hostname }}"
|
|
include_role:
|
|
name: _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 }}"
|
|
shell: docker-compose pull
|
|
args:
|
|
chdir: '{{ service_base_path }}/{{ inventory_hostname }}'
|
|
tags:
|
|
- update_deployment
|
|
|
|
- name: "Start {{ inventory_hostname }}"
|
|
shell: |
|
|
docker-compose down
|
|
docker-compose up -d
|
|
args:
|
|
chdir: '{{ service_base_path }}/{{ inventory_hostname }}'
|
|
tags:
|
|
- update_config
|
|
- update_deployment
|
|
|
|
- name: "Wait for {{ http_s }}://{{ inventory_hostname }}-grafana.{{ domain }}"
|
|
uri:
|
|
url: "{{ http_s }}://{{ inventory_hostname }}-grafana.{{ 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 }}://{{ inventory_hostname }}-grafana.{{ 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
|