summaryrefslogtreecommitdiff
path: root/roles/monitoring/landingpage/tasks/main.yml
blob: b2e3959f390e16a71993e012b55db05702e66ac5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
---
- name: create nginx document root directory
  file:
    path: "/var/www/landingpage"
    state: directory

- name: copy index.html
  template:
    src: index.html.j2
    dest: "/var/www/landingpage/index.html"

- name: compute nginx vhost config
  vars:
    monitoring_landingpage_vhost_base:
      name: landingpage
      mode: "0600"
      template: generic
      hostnames: "{{ monitoring_landingpage_hostnames }}"
      locations:
        '/':
          root: /var/www/landingpage
    monitoring_landingpage_vhost_override__yaml: |
      {% if monitoring_landingpage_tls is defined %}
      tls:
        {{ monitoring_landingpage_tls | to_nice_yaml(indent=2) | indent(2) }}
      {% endif %}
      {% if monitoring_landingpage_vhost_extra_directives is defined %}
      extra_directives: |
        {{ monitoring_landingpage_vhost_extra_directives | indent(2) }}
      {% endif %}
      locations:
      {% if 'prometheus' in monitoring_landingpage_services %}
        '/prometheus/':
          proxy_pass: "http://{{ prometheus_server_web_listen_address | default('127.0.0.1:9090')  }}"
      {%   if 'prometheus' in monitoring_landingpage_service_extra_directives %}
          extra_directives: |
            {{ monitoring_landingpage_service_extra_directives['prometheus'] | indent(6) }}
      {%   endif %}
      {% endif %}
      {% if 'alertmanager' in monitoring_landingpage_services %}
        '/alertmanager/':
          proxy_pass: "http://{{ prometheus_alertmanager_web_listen_address | default('127.0.0.1:9093') }}"
      {%   if 'alertmanager' in monitoring_landingpage_service_extra_directives %}
          extra_directives: |
            {{ monitoring_landingpage_service_extra_directives['alertmanager'] | indent(6) }}
      {%   endif %}
      {% endif %}
      {% if 'grafana' in monitoring_landingpage_services %}
        '/grafana/':
          proxy_pass: "http://{{ grafana_config_server.http_addr | default('127.0.0.1') }}:{{ grafana_config_server.http_port | default(3000) }}"
      {%   if 'grafana' in monitoring_landingpage_service_extra_directives %}
          extra_directives: |
            {{ monitoring_landingpage_service_extra_directives['grafana'] | indent(6) }}
      {%   endif %}
      {% endif %}
  set_fact:
    monitoring_landingpage_vhost: "{{ monitoring_landingpage_vhost_base | combine(monitoring_landingpage_vhost_override__yaml | from_yaml, recursive=True) }}"

- name: configure nginx vhost
  vars:
    nginx_vhost: "{{ monitoring_landingpage_vhost }}"
  include_role:
    name: nginx/vhost