-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathmain.yml
More file actions
92 lines (82 loc) · 2.06 KB
/
main.yml
File metadata and controls
92 lines (82 loc) · 2.06 KB
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
---
- name: Create prometheus group
become: true
ansible.builtin.group:
name: prometheus
state: present
- name: Add ubuntu to prometheus group
become: true
ansible.builtin.user:
name: ubuntu
group: prometheus
- name: Reset connection for group changes
ansible.builtin.meta: reset_connection
- name: Create a prometheus user
become: true
ansible.builtin.user:
name: prometheus
create_home: false
group: prometheus
system: true
- name: Download and extract Prometheus
become: true
ansible.builtin.unarchive:
src: " https://github.com/prometheus/prometheus/releases/download/v{{ prometheus_version }}/prometheus-{{ prometheus_version }}.linux-amd64.tar.gz "
dest: /tmp
remote_src: true
creates: "/opt/prometheus"
mode: "0774"
notify:
- Move Prometheus binaries
- Start Prometheus
- name: Flush handlers to move binaries
ansible.builtin.meta: flush_handlers
- name: Set permissions on volume
become: true
ansible.builtin.file:
path: /var/stack/prometheus/data
state: directory
owner: prometheus
group: prometheus
mode: "0774"
recurse: true
- name: Copy prometheus service file
become: true
ansible.builtin.copy:
src: prometheus.service
dest: /etc/systemd/system/prometheus.service
owner: prometheus
group: prometheus
mode: "0774"
notify:
- Start Prometheus
- name: Copy prometheus rules file
become: true
ansible.builtin.copy:
src: rules.yml
dest: /opt/prometheus/rules.yml
owner: prometheus
group: prometheus
mode: "0774"
notify:
- Restart Prometheus
- name: Template prometheus config
become: true
ansible.builtin.template:
src: "{{ item }}"
dest: "/opt/prometheus/{{ item[:-3] }}"
owner: prometheus
group: prometheus
mode: "0774"
notify:
- Restart Prometheus
loop:
- prometheus.yml.j2
- web.yml.j2
- name: Create Prometheus log directory
ansible.builtin.file:
path: /var/log/prometheus
state: directory
owner: prometheus
group: prometheus
mode: "0770"