aboutsummaryrefslogtreecommitdiffstats
path: root/fdio.infra.ansible/roles/prometheus_exporter/tasks/main.yaml
blob: 3f4b563352b2515e386c45dd5e61a7db206b058c (plain)
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
64
65
66
67
68
69
70
71
72
---
# file: roles/prometheus_exporter/tasks/main.yaml

- name: Inst - Update Package Cache (APT)
  apt:
    update_cache: yes
    cache_valid_time: 3600
  when:
    - ansible_distribution|lower == 'ubuntu'
  tags:
    - prometheus-inst

- name: Inst - Prerequisites
  package:
    name: "{{ packages | flatten(levels=1) }}"
    state: latest
  tags:
    - prometheus-inst

- name: Inst - Start a NodeExporter container
  docker_container:
    name: "NodeExporter"
    image: "{{ ne_image }}"
    state: "started"
    restart_policy: "unless-stopped"
    detach: yes
    ports:
     - "9100:9100"
    privileged: yes
    command:
      - "--path.procfs=/host/proc"
      - "--path.rootfs=/rootfs"
      - "--path.sysfs=/host/sys"
      - "--collector.filesystem.mount-points-exclude=^/(sys|proc|dev|host|etc)($$|/)"
    volumes:
      - "/:/rootfs:ro"
      - "/proc:/host/proc:ro"
      - "/sys:/host/sys:ro"
  tags:
    - prometheus-inst

- name: Inst - Create a Config Directory
  ansible.builtin.file:
    path: "/etc/prometheus/"
    state: "directory"
    mode: "0755"
  tags:
    - prometheus-conf-blackbox-exporter

- name: Conf - Prometheus Blackbox Exporter
  copy:
   src: "files/blackbox.yml"
   dest: "/etc/prometheus/blackbox.yml"
  tags:
    - prometheus-conf-blackbox-exporter

- name: Inst - Start a BlackBoxExporter container
  docker_container:
    name: "BlackBoxExporter"
    image: "{{ be_image }}"
    state: "started"
    restart_policy: "unless-stopped"
    detach: yes
    ports:
     - "9115:9115"
    privileged: yes
    command:
      - "--config.file=/config/blackbox.yml"
    volumes:
      - "/etc/prometheus/blackbox.yml:/config/blackbox.yml:ro"
  tags:
    - prometheus-inst