forked from ISTI-ansible-roles/ansible-roles
systemd unit for the prometheus server. Also, do not overwrite the configuration file.
This commit is contained in:
parent
6e6850d139
commit
f5b5e06629
|
@ -1,6 +1,6 @@
|
||||||
---
|
---
|
||||||
prometheus_install: True
|
prometheus_install: True
|
||||||
prometheus_version: 2.1.0
|
prometheus_version: 2.2.1
|
||||||
prometheus_dir: 'prometheus-{{ prometheus_version }}.linux-amd64'
|
prometheus_dir: 'prometheus-{{ prometheus_version }}.linux-amd64'
|
||||||
prometheus_file: '{{ prometheus_dir }}.tar.gz'
|
prometheus_file: '{{ prometheus_dir }}.tar.gz'
|
||||||
prometheus_download_url: 'https://github.com/prometheus/prometheus/releases/download/v{{ prometheus_version }}/{{ prometheus_file }}'
|
prometheus_download_url: 'https://github.com/prometheus/prometheus/releases/download/v{{ prometheus_version }}/{{ prometheus_file }}'
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
[Unit]
|
||||||
|
Description=Prometheus - Prometheus metrics collector.
|
||||||
|
Documentation=https://prometheus.io/docs/introduction/overview/
|
||||||
|
After=network.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
User={{ prometheus_user }}
|
||||||
|
Group={{ prometheus_user }}
|
||||||
|
EnvironmentFile=/etc/default/prometheus
|
||||||
|
ExecStart=${PROMETHEUS_CMD} --config.file=${PROMETHEUS_CONF} --storage.tsdb.path=${PROMETHEUS_DATADIR} --log.level=${PROMETHEUS_LOGLEVEL} ${PROMETHEUS_OPTS}
|
||||||
|
Restart=on-failure
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
||||||
|
|
|
@ -26,15 +26,21 @@
|
||||||
notify: Restart prometheus
|
notify: Restart prometheus
|
||||||
|
|
||||||
- name: Install the prometheus configuration
|
- name: Install the prometheus configuration
|
||||||
template: src=prometheus.yml.j2 dest={{ prometheus_confdir }}/prometheus.yml
|
template: src=prometheus.yml.j2 dest={{ prometheus_confdir }}/prometheus.yml force=no
|
||||||
notify: Reload prometheus
|
notify: Reload prometheus
|
||||||
|
|
||||||
- name: Install the prometheus upstart script
|
|
||||||
copy: src=prometheus.upstart dest=/etc/init/prometheus.conf mode=0644 owner=root group=root
|
|
||||||
|
|
||||||
- name: Install the prometheus defaults
|
- name: Install the prometheus defaults
|
||||||
template: src=prometheus.default.j2 dest=/etc/default/prometheus mode=0644 owner=root group=root
|
template: src=prometheus.default.j2 dest=/etc/default/prometheus mode=0644 owner=root group=root
|
||||||
|
|
||||||
|
- name: Install the prometheus upstart script
|
||||||
|
copy: src=prometheus.upstart dest=/etc/init/prometheus.conf mode=0644 owner=root group=root
|
||||||
|
when: ansible_service_mgr != 'systemd'
|
||||||
|
|
||||||
|
- name: Install the prometheus server systemd unit
|
||||||
|
copy: src=prometheus.systemd dest=/etc/systemd/system/prometheus.service mode=0644 owner=root group=root
|
||||||
|
when: ansible_service_mgr == 'systemd'
|
||||||
|
notify: systemd reload
|
||||||
|
|
||||||
- name: Ensure that prometheus is started and enabled
|
- name: Ensure that prometheus is started and enabled
|
||||||
service: name=prometheus state=started enabled=yes
|
service: name=prometheus state=started enabled=yes
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue