Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
prometheus: Add basic Prometheus role
- Loading branch information
Per Lundberg
committed
Jun 8, 2021
1 parent
b51d246
commit 1d9e360
Showing
5 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
- name: Runs the prometheus role | ||
hosts: all | ||
|
||
pre_tasks: | ||
- import_tasks: include/common_pre_tasks.yml | ||
|
||
roles: | ||
- role: prometheus | ||
|
||
module_defaults: | ||
apt: | ||
force_apt_get: yes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
prometheus_etc_prometheus_path: '{{ inventory_dir }}/overrides/{{ inventory_hostname }}/prometheus/etc/prometheus' | ||
|
||
# | ||
# Variables below this line typically do not have to be modified. | ||
# | ||
prometheus_yml_path: '{{ prometheus_etc_prometheus_path }}/prometheus.yml' | ||
prometheus_alerting_rules_yaml_path: '{{ prometheus_etc_prometheus_path }}/alerting_rules.yaml' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
- name: Reload or start the Prometheus service | ||
systemd: | ||
name: prometheus.service | ||
state: reloaded | ||
listen: reload_prometheus | ||
become: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
- name: Install/update Prometheus | ||
ansible.builtin.package: | ||
name: | ||
- prometheus | ||
|
||
# Deliberately not using 'state: latest' to avoid unexpected surprises when | ||
# e.g. deploying updated configuration. | ||
state: present | ||
become: true | ||
|
||
- name: Copy prometheus.yml to /etc/prometheus | ||
ansible.builtin.copy: | ||
src: '{{ prometheus_yml_path }}' | ||
dest: /etc/prometheus/prometheus.yml | ||
owner: root | ||
group: root | ||
mode: 0644 | ||
become: true | ||
notify: reload_prometheus | ||
|
||
- name: Copy alerting_rules.yaml to /etc/prometheus | ||
ansible.builtin.copy: | ||
src: '{{ prometheus_alerting_rules_yaml_path }}' | ||
dest: /etc/prometheus/alerting_rules.yaml | ||
owner: root | ||
group: root | ||
mode: 0644 | ||
become: true | ||
notify: reload_prometheus |