fix linter errors
This commit is contained in:
@@ -17,9 +17,9 @@ prometheus_version: 3.2.1 # prometheus version
|
||||
prometheus_dir: "/etc/prometheus" # where to install prometheus
|
||||
prometheus_user: prometheus # user name
|
||||
prometheus_group: prometheus # groups name
|
||||
config_dir: "/etc/prometheus/conf" # where to place prometheus config
|
||||
db_dir: "/var/lib/prometheus" # where to store prometheus db
|
||||
config_source_dir: prometheus # path to config files on source
|
||||
prometheus_config_dir: "/etc/prometheus/conf" # where to place prometheus config
|
||||
prometheus_db_dir: "/var/lib/prometheus" # where to store prometheus db
|
||||
prometheus_config_source_dir: prometheus # path to config files on source
|
||||
alertrules_source_dir: prometheus/rules # path to rule files on source
|
||||
```
|
||||
|
||||
@@ -34,7 +34,7 @@ Example Playbook
|
||||
```yaml
|
||||
roles:
|
||||
- role: genlab.prometheus
|
||||
config_source_dir: mydir/configs
|
||||
prometheus_config_source_dir: mydir/configs
|
||||
alertrules_source_dir: mydir/configs/rules
|
||||
prometheus_version: 3.2.1
|
||||
```
|
||||
|
||||
@@ -3,5 +3,5 @@ prometheus_version: 3.2.1
|
||||
prometheus_dir: "/etc/prometheus"
|
||||
prometheus_user: prometheus
|
||||
prometheus_group: prometheus
|
||||
config_dir: "/etc/prometheus/conf"
|
||||
db_dir: "/var/lib/prometheus"
|
||||
prometheus_config_dir: "/etc/prometheus/conf"
|
||||
prometheus_db_dir: "/var/lib/prometheus"
|
||||
|
||||
@@ -3,6 +3,6 @@
|
||||
hosts: all
|
||||
|
||||
roles:
|
||||
- role: genlab.prometheus
|
||||
config_source_dir: prometheus
|
||||
- role: genlab.common.prometheus
|
||||
prometheus_config_source_dir: prometheus
|
||||
alertrules_source_dir: prometheus/rules
|
||||
|
||||
@@ -14,11 +14,11 @@
|
||||
- name: "Check if Prometheus is installed"
|
||||
changed_when: false
|
||||
ansible.builtin.command: "prometheus --version"
|
||||
register: prom_installed_version
|
||||
register: prometheus_installed_version
|
||||
|
||||
- name: "Check Prometheus version"
|
||||
ansible.builtin.assert:
|
||||
that: "prom_installed_version.stdout is regex('{{ prometheus_version }}')"
|
||||
that: "prometheus_installed_version.stdout is regex('{{ prometheus_version }}')"
|
||||
success_msg: "Prometheus version {{ prometheus_version }} is installed and working"
|
||||
fail_msg: "Prometheus version {{ prometheus_version }} is not installed or not working correctly"
|
||||
|
||||
@@ -30,11 +30,11 @@
|
||||
status_code: 200
|
||||
method: GET
|
||||
body_format: json
|
||||
register: prom_health
|
||||
register: prometheus_health
|
||||
|
||||
- name: "Debug Prometheus health status"
|
||||
ansible.builtin.assert:
|
||||
that: "prom_health.content | trim == 'Prometheus Server is Healthy.'"
|
||||
that: "prometheus_health.content | trim == 'Prometheus Server is Healthy.'"
|
||||
success_msg: "Prometheus is healthy"
|
||||
fail_msg: "Prometheus is not healthy"
|
||||
|
||||
@@ -46,10 +46,10 @@
|
||||
status_code: 200
|
||||
method: GET
|
||||
body_format: json
|
||||
register: prom_ready
|
||||
register: prometheus_ready
|
||||
|
||||
- name: "Debug Prometheus readiness status"
|
||||
ansible.builtin.assert:
|
||||
that: "prom_ready.content | trim == 'Prometheus Server is Ready.'"
|
||||
that: "prometheus_ready.content | trim == 'Prometheus Server is Ready.'"
|
||||
success_msg: "Prometheus is ready"
|
||||
fail_msg: "Prometheus is not ready"
|
||||
|
||||
@@ -3,19 +3,19 @@
|
||||
notify: "(Re)start Prometheus service"
|
||||
ansible.builtin.copy:
|
||||
src: "{{ item }}"
|
||||
dest: "{{ config_dir }}/{{ item | basename }}"
|
||||
dest: "{{ prometheus_config_dir }}/{{ item | basename }}"
|
||||
owner: "{{ prometheus_user }}"
|
||||
group: "{{ prometheus_group }}"
|
||||
mode: "0660"
|
||||
with_fileglob:
|
||||
- "{{ config_source_dir }}/*.yml"
|
||||
- "{{ prometheus_config_source_dir }}/*.yml"
|
||||
|
||||
- name: "Copy alert rules"
|
||||
notify: "(Re)start Prometheus service"
|
||||
when: alertrules_source_dir is defined
|
||||
ansible.builtin.copy:
|
||||
src: "{{ item }}"
|
||||
dest: "{{ config_dir }}/{{ item | basename }}"
|
||||
dest: "{{ prometheus_config_dir }}/{{ item | basename }}"
|
||||
owner: "{{ prometheus_user }}"
|
||||
group: "{{ prometheus_group }}"
|
||||
mode: "0660"
|
||||
|
||||
@@ -37,9 +37,9 @@
|
||||
group: "{{ prometheus_group }}"
|
||||
mode: "0755"
|
||||
with_items:
|
||||
- "{{ config_dir }}"
|
||||
- "{{ prometheus_config_dir }}"
|
||||
- "{{ prometheus_dir }}"
|
||||
- "{{ db_dir }}"
|
||||
- "{{ prometheus_db_dir }}"
|
||||
|
||||
- name: "Download Prometheus binary"
|
||||
ansible.builtin.get_url:
|
||||
|
||||
@@ -9,12 +9,12 @@ User=prometheus
|
||||
Group=prometheus
|
||||
Type=simple
|
||||
ExecStart=/usr/local/bin/prometheus \
|
||||
--config.file {{ config_dir }}/prometheus.yml \
|
||||
--storage.tsdb.path {{ db_dir }} \
|
||||
--config.file {{ prometheus_config_dir }}/prometheus.yml \
|
||||
--storage.tsdb.path {{ prometheus_db_dir }} \
|
||||
--storage.tsdb.retention.time=30d
|
||||
|
||||
# Security hardening
|
||||
ReadWritePaths={{ db_dir }}
|
||||
ReadWritePaths={{ prometheus_db_dir }}
|
||||
ProtectSystem=strict
|
||||
NoNewPrivileges=true
|
||||
PrivateTmp=true
|
||||
|
||||
Reference in New Issue
Block a user