blob: 9227617f33c81668daa2c504a7a8661fa125f572 [file] [log] [blame]
- name: Check if Prometheus binary needs to be downloaded.
stat:
path:
"{{ all.repo_root }}/skolo/build/{{ ansible_facts['system'] }}/{{
ansible_facts['architecture'] }}/prometheus-{{ all.prometheus.version
}}.linux-amd64/prometheus"
register: prometheus_binary
- name: Download Prometheus binary.
delegate_to: 127.0.0.1
throttle: 1
make:
chdir: '{{ all.repo_root }}/skolo/'
target:
"download_prometheus_{{ ansible_facts['architecture'] }}_{{
ansible_facts['system'] }}"
params:
PROMETHEUS_VERSION: '{{ all.prometheus.version }}'
when: not prometheus_binary.stat.exists
- name: Copy over service file.
become: true
template:
src: templates/prometheus.service
dest: /etc/systemd/system/prometheus.service
owner: root
group: root
mode: '0644'
- name: Copy over prometheus executable.
become: true
copy:
src:
"{{ all.repo_root }}/skolo/build/{{ ansible_facts['system'] }}/{{
ansible_facts['architecture'] }}/prometheus-{{ all.prometheus.version
}}.linux-amd64/prometheus"
dest: /usr/local/bin/prometheus
owner: root
group: root
mode: '0755'
- name: Copy over promtool executable.
become: true
copy:
src:
"{{ all.repo_root }}/skolo/build/{{ ansible_facts['system'] }}/{{
ansible_facts['architecture'] }}/prometheus-{{ all.prometheus.version
}}.linux-amd64/promtool"
dest: /usr/local/bin/promtool
owner: root
group: root
mode: '0755'
- name: Ensure /etc/prometheus directory exists.
become: true
file:
path: /etc/prometheus
state: directory
owner: chrome-bot
group: chrome-bot
mode: '0755'
- name: Copy over prometheus config file.
template:
src: templates/prometheus.yml
dest: /etc/prometheus/prometheus.yml
owner: chrome-bot
group: chrome-bot
mode: '0644'
- name: Copy over alerts file.
copy:
src: files/alerts.yml
dest: /etc/prometheus/alerts.yml
owner: chrome-bot
group: chrome-bot
mode: '0644'
- name: Ensure tsdb directory exists.
become: true
file:
path: /var/lib/prometheus/tsdb
state: directory
owner: chrome-bot
group: chrome-bot
mode: '0755'
- name: Load alert_to_pubsub_ansible executables.
import_role:
name: get_ansible_binaries
vars:
get_ansible_binaries_application: alert_to_pubsub_ansible
get_ansible_binaries_version: '{{ alert_to_pubsub_ansible_version }}'
- name: Copy over alert_to_pubsub service file.
become: true
template:
src: templates/alert_to_pubsub.service
dest: /etc/systemd/system/alert_to_pubsub.service
owner: root
group: root
mode: '0644'
- name: Copy over alert_to_pubsub_ansible executable.
become: true
copy:
src:
"{{ get_ansible_binaries_directory.path }}/build/{{
ansible_facts['system'] }}/{{ ansible_facts['architecture']
}}/alert_to_pubsub_ansible"
dest: /usr/local/bin/alert_to_pubsub_ansible
owner: root
group: root
mode: '0755'
- name: restart_prometheus
become: true
systemd:
enabled: true
state: restarted
name: prometheus
daemon_reload: true
- name: restart_alert_to_pubsub
become: true
systemd:
enabled: true
state: restarted
name: alert_to_pubsub
daemon_reload: true
- name: validate_prometheus_config
command: /usr/local/bin/promtool check config /etc/prometheus/prometheus.yml
- name: validate_prometheus_rules
command: /usr/local/bin/promtool check rules /etc/prometheus/alerts.yml