This repository has been archived by the owner on Aug 18, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 31
/
prometheus.yml
119 lines (106 loc) · 5.7 KB
/
prometheus.yml
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
110
111
112
113
114
115
116
117
118
119
---
- block:
- name: Include role mesaguy.prometheus setup task
include_tasks: _setup.yml
when: prometheus_setup_task_executed is undefined
- name: Starting prometheus install
set_fact:
prometheus_exporter: false
prometheus_software_author: prometheus
prometheus_software_binary_name: prometheus
prometheus_software_config: '{{ prometheus_server_cfg | default(lookup("file", "files/defaults/prometheus.yml") | from_yaml) }}'
prometheus_software_files:
- prometheus
- promtool
prometheus_software_makefile_make_command: make build
prometheus_software_name: prometheus
prometheus_software_description: Prometheus
prometheus_software_documentation: 'https://github.com/prometheus/prometheus'
prometheus_storage_directory: '{{ prometheus_storage_dir | default(prometheus_var_dir + "/prometheus") }}'
prometheus_software_supports_reload: true
# Software has no tgroup name:
prometheus_prometheus_jobname: ""
# The following allow specifying Prometheus service variables without
# prefixing with 'prometheus_prometheus_'. _setup_software_facts.yml
# prefixes 'prometheus_' to all variables it looks for
prometheus_prometheus_env_vars: '{{ lookup("vars", "prometheus_env_vars", default=omit) }}'
prometheus_prometheus_extra_opts: '{{ lookup("vars", "prometheus_extra_opts", default=omit) }}'
prometheus_prometheus_fallback_to_build: '{{ lookup("vars", "prometheus_fallback_to_build", default=omit) }}'
prometheus_prometheus_host: '{{ lookup("vars", "prometheus_host", default=omit) }}'
prometheus_prometheus_port: '{{ lookup("vars", "prometheus_port", default=omit) }}'
prometheus_prometheus_runas: '{{ lookup("vars", "prometheus_runas", default=omit) }}'
prometheus_prometheus_use_prerelease: '{{ lookup("vars", "prometheus_use_prerelease", default=omit) }}'
prometheus_prometheus_version: '{{ lookup("vars", "prometheus_version", default=omit) }}'
- name: Include task to setup {{ prometheus_software_name }} facts
include_tasks: _setup_software_facts.yml
- name: Set {{ prometheus_software_name }}-{{ prometheus_software_version }} prometheus_software_install_dir
# This is a one-off need as Prometheus uses configurations files
# distributed with Prometheus. This variable is needed in the fact
# specifications below
set_fact:
prometheus_software_install_dir: '{{ prometheus_root_dir }}/{{ prometheus_software_name }}/{{ prometheus_software_version }}'
- name: Set {{ prometheus_software_name_version }} facts
set_fact:
prometheus_software_config_name: '{{ prometheus_software_name }}'
prometheus_software_opts:
- '--config.file={{ prometheus_etc_dir }}/prometheus.yml'
- '--storage.tsdb.path={{ prometheus_storage_directory }}'
- '--web.listen-address={{ prometheus_software_host }}:{{ prometheus_software_port }}'
- '--web.console.libraries={{ prometheus_web_console_libraries_dir | default(prometheus_software_install_dir + "/console_libraries") }}'
- '--web.console.templates={{ prometheus_web_console_templates_dir | default(prometheus_software_install_dir + "/consoles") }}'
prometheus_software_url:
"https://github.com/{{ prometheus_software_author }}/{{ prometheus_software_name }}/releases/download/{{ prometheus_software_version }}/\
{{ prometheus_software_name }}-{{ prometheus_software_version | regex_replace('^(v)?') }}.{{ prometheus_software_architecture }}.tar.gz"
prometheus_software_validation_command: '{{ prometheus_software_install_dir }}/promtool check config {{ prometheus_etc_dir }}/prometheus.yml'
- name: 'Create {{ prometheus_software_name_version }} storage directory: {{ prometheus_storage_directory }}'
become: true
file:
path: '{{ prometheus_storage_directory }}'
state: directory
owner: '{{ prometheus_user }}'
group: '{{ prometheus_group }}'
mode: 0750
- name: 'Create {{ prometheus_software_name_version }} tgroup directory: {{ prometheus_tgroup_dir }}'
become: true
file:
path: '{{ prometheus_tgroup_dir }}'
state: directory
owner: '{{ prometheus_tgroup_owner }}'
group: '{{ prometheus_tgroup_group }}'
mode: '{{ prometheus_tgroup_mode }}'
- name: Include task to perform installation of {{ prometheus_software_name_version }}
include_tasks: _install.yml
- name: Symlink {{ prometheus_software_name_version }}{{ prometheus_software_install_dir }}/promtool to /usr/local/bin/promtool
become: true
file:
state: link
src: '{{ prometheus_software_install_dir }}/promtool'
dest: /usr/local/bin/promtool
force: true
owner: root
group: '{{ prometheus_group }}'
when: prometheus_symlink_tools | bool
- name: Setup {{ prometheus_software_name_version }} configuration file
become: true
template:
src: 'templates/generic-config.yml.j2'
dest: '{{ prometheus_etc_dir }}/prometheus.yml'
owner: root
group: '{{ prometheus_group }}'
mode: 0640
backup: true
validate: '{{ prometheus_software_install_dir }}/promtool check config %s'
notify:
- Reload Prometheus service
- name: Include task to setup Prometheus rules
include_tasks: _rules.yml
when: prometheus_manage_rules | default(false) | bool
- name: Set {{ prometheus_software_name }}-{{ prometheus_software_version }} validation facts
set_fact:
# Needed in the event the software is built and the
# 'prometheus_software_install_dir' changes
prometheus_software_validation_command: '{{ prometheus_software_install_dir }}/promtool check config {{ prometheus_etc_dir }}/prometheus.yml'
- name: Include task to setup {{ prometheus_software_name_version }} service
include_tasks: _service.yml
- name: Include task to perform post install cleanup of {{ prometheus_software_name_version }}
include_tasks: _post_install_cleanup.yml