diff --git a/roles/prometheus/handlers/main.yml b/roles/prometheus/handlers/main.yml new file mode 100644 index 0000000..e69de29 diff --git a/roles/prometheus/prometheus-config.yml b/roles/prometheus/prometheus-config.yml index 64a609b..652ad6d 100644 --- a/roles/prometheus/prometheus-config.yml +++ b/roles/prometheus/prometheus-config.yml @@ -7,4 +7,4 @@ scrape_configs: scrape_interval: 5s static_configs: - - targets: ['localhost:9090'] + - targets: {{ prom_targets }} diff --git a/roles/prometheus/tasks/main.yml b/roles/prometheus/tasks/main.yml index 1123105..6007264 100644 --- a/roles/prometheus/tasks/main.yml +++ b/roles/prometheus/tasks/main.yml @@ -1,7 +1,22 @@ +- name: Install Prometheus node exporter + apt: + name: prometheus-node-exporter + state: present + +- name: Run Prometheus node exporter + service: + name: prometheus-node-exporter + state: started + +- name: Create Prometheus directory + file: + path: /home/{{ docker_user }}/prometheus + state: directory + - name: Install Prometheus configuration template: src: prometheus-config.yml - dest: /home/{{ docker_user }}/prometheus.yml + dest: /home/{{ docker_user }}/prometheus/prometheus.yml - name: Start Prometheus container docker_container: @@ -10,6 +25,13 @@ state: started restart_policy: always volumes: - - /home/{{ docker_user }}/prometheus.yml:/etc/prometheus/prometheus.yml + - /home/{{ docker_user }}/prometheus:/etc/prometheus ports: - "80:9090" + +- name: Start Grafana container + docker_container: + name: grafana + image: grafana/grafana:latest + ports: + - "3000:3000"