blob: d55f3c10420566e83936591f584c5ebd33ab113a (
plain) (
blame)
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
---
- name: Install prometheus package
package:
name: prometheus
state: present
tags:
- role::prometheus
- name: Create directories for Prometheus versions and tarballs
ansible.builtin.file:
path: "{{ item }}"
state: directory
owner: root
group: prometheus
mode: "0750"
tags:
- role::prometheus
loop:
- "{{ prometheus_base_directory }}"
- "{{ prometheus_installation_directory }}"
- "{{ prometheus_base_release_dest }}"
- name: Download Prometheus from GitHub
ansible.builtin.get_url:
url: "{{ prometheus_release_url }}"
checksum: sha256:{{ prometheus_release_sha256sum_url }}
dest: "{{ prometheus_release_tarball_dest }}"
owner: prometheus
group: prometheus
mode: "0400"
tags:
- role::prometheus
- name: Uncompress Prometheus archive
ansible.builtin.unarchive:
src: "{{ prometheus_release_tarball_dest }}"
dest: "{{ prometheus_installation_directory }}"
owner: prometheus
group: prometheus
remote_src: true
tags:
- role::prometheus
- name: Configure prometheus command line options
lineinfile:
path: /etc/default/prometheus
regexp: ^ARGS.*
line: ARGS="{{ prometheus_cmdline_options }}"
tags:
- role::prometheus
when:
- prometheus_cmdline_options is defined
notify:
- Restart the prometheus service
- name: Deploy prometheus general config
copy:
content: |
# Ansible managed
{{ prometheus_configuration }}
dest: /etc/prometheus/prometheus.yml
owner: prometheus
group: prometheus
mode: "0400"
tags:
- role::prometheus
notify:
- Reload the prometheus service
- name: Configure prometheus rules
copy:
content: |
# Ansible managed
{{ prometheus_rules }}
dest: /etc/prometheus/rules.yml
owner: prometheus
group: prometheus
mode: "0400"
tags:
- role::prometheus
notify:
- Reload the prometheus service
- name: Create service override directory
ansible.builtin.file:
path: /etc/systemd/system/prometheus.service.d
state: directory
owner: root
group: root
mode: "0755"
tags:
- role::prometheus
- name: Create service dropin
ansible.builtin.copy:
content: |
# Ansible managed
[Service]
ExecStart =
ExecStart = {{ prometheus_installation_directory }}/{{ prometheus_release_name }}/prometheus $ARGS
dest: /etc/systemd/system/prometheus.service.d/override.conf
owner: root
group: root
mode: "0444"
tags:
- role::prometheus
notify:
- Reload the systemd daemon
- Restart the prometheus service
|