3f4b563352b2515e386c45dd5e61a7db206b058c
[csit.git] / fdio.infra.ansible / roles / prometheus_exporter / tasks / main.yaml
1 ---
2 # file: roles/prometheus_exporter/tasks/main.yaml
3
4 - name: Inst - Update Package Cache (APT)
5   apt:
6     update_cache: yes
7     cache_valid_time: 3600
8   when:
9     - ansible_distribution|lower == 'ubuntu'
10   tags:
11     - prometheus-inst
12
13 - name: Inst - Prerequisites
14   package:
15     name: "{{ packages | flatten(levels=1) }}"
16     state: latest
17   tags:
18     - prometheus-inst
19
20 - name: Inst - Start a NodeExporter container
21   docker_container:
22     name: "NodeExporter"
23     image: "{{ ne_image }}"
24     state: "started"
25     restart_policy: "unless-stopped"
26     detach: yes
27     ports:
28      - "9100:9100"
29     privileged: yes
30     command:
31       - "--path.procfs=/host/proc"
32       - "--path.rootfs=/rootfs"
33       - "--path.sysfs=/host/sys"
34       - "--collector.filesystem.mount-points-exclude=^/(sys|proc|dev|host|etc)($$|/)"
35     volumes:
36       - "/:/rootfs:ro"
37       - "/proc:/host/proc:ro"
38       - "/sys:/host/sys:ro"
39   tags:
40     - prometheus-inst
41
42 - name: Inst - Create a Config Directory
43   ansible.builtin.file:
44     path: "/etc/prometheus/"
45     state: "directory"
46     mode: "0755"
47   tags:
48     - prometheus-conf-blackbox-exporter
49
50 - name: Conf - Prometheus Blackbox Exporter
51   copy:
52    src: "files/blackbox.yml"
53    dest: "/etc/prometheus/blackbox.yml"
54   tags:
55     - prometheus-conf-blackbox-exporter
56
57 - name: Inst - Start a BlackBoxExporter container
58   docker_container:
59     name: "BlackBoxExporter"
60     image: "{{ be_image }}"
61     state: "started"
62     restart_policy: "unless-stopped"
63     detach: yes
64     ports:
65      - "9115:9115"
66     privileged: yes
67     command:
68       - "--config.file=/config/blackbox.yml"
69     volumes:
70       - "/etc/prometheus/blackbox.yml:/config/blackbox.yml:ro"
71   tags:
72     - prometheus-inst