2018-12-06 02:59:47 +08:00
|
|
|
---
|
|
|
|
- name: make sure the alertmanager service is down
|
|
|
|
service:
|
|
|
|
name: alertmanager
|
|
|
|
state: stopped
|
|
|
|
failed_when: false
|
|
|
|
|
2019-04-08 21:40:25 +08:00
|
|
|
# Make sure we re-create the container
|
|
|
|
- name: remove old alertmanager container
|
|
|
|
command: "{{ container_binary }} rm -f alertmanager"
|
|
|
|
changed_when: false
|
|
|
|
failed_when: false
|
|
|
|
|
2018-12-06 02:59:47 +08:00
|
|
|
- name: start alertmanager container
|
2019-04-08 21:40:25 +08:00
|
|
|
shell: |
|
|
|
|
{{ container_binary }} run --detach --name alertmanager \
|
|
|
|
-v "{{ alertmanager_conf_dir }}:/etc/alertmanager:Z" \
|
|
|
|
-v "{{ alertmanager_data_dir }}:/alertmanager:Z" \
|
|
|
|
"--net=host" \
|
|
|
|
"--cpu-period={{ alertmanager_container_cpu_period }}" \
|
|
|
|
"--cpu-quota={{ alertmanager_container_cpu_period * alertmanager_container_cpu_cores }}" \
|
|
|
|
"--memory={{ alertmanager_container_memory }}GB" \
|
|
|
|
"--memory-swap={{ alertmanager_container_memory * 2 }}GB" \
|
|
|
|
"{{ alertmanager_container_image }}" \
|
|
|
|
"--config.file=/etc/alertmanager/alertmanager.yml" \
|
|
|
|
"--storage.path=/alertmanager"
|
2018-12-06 02:59:47 +08:00
|
|
|
notify: service handler
|
|
|
|
|
|
|
|
- name: make sure the prometheus service is down
|
|
|
|
service:
|
|
|
|
name: prometheus
|
|
|
|
state: stopped
|
|
|
|
failed_when: false
|
|
|
|
|
2019-04-08 21:40:25 +08:00
|
|
|
# Make sure we re-create the container
|
|
|
|
- name: remove old prometheus container
|
|
|
|
command: "{{ container_binary }} rm -f prometheus"
|
|
|
|
changed_when: false
|
|
|
|
failed_when: false
|
|
|
|
|
|
|
|
- name: start prometheus container
|
|
|
|
shell: |
|
|
|
|
{{ container_binary }} run --detach --name prometheus \
|
|
|
|
-v "{{ prometheus_conf_dir }}:/etc/prometheus:Z" \
|
|
|
|
-v "{{ prometheus_data_dir }}:/prometheus:Z" \
|
|
|
|
"--net=host" \
|
|
|
|
"--user={{ prometheus_user_id }}" \
|
|
|
|
"--cpu-period={{ prometheus_container_cpu_period }}" \
|
|
|
|
"--cpu-quota={{ prometheus_container_cpu_period * prometheus_container_cpu_cores }}" \
|
|
|
|
"--memory={{ prometheus_container_memory }}GB" \
|
|
|
|
"--memory-swap={{ prometheus_container_memory * 2 }}GB" \
|
|
|
|
"{{ prometheus_container_image }}" \
|
|
|
|
"--config.file=/etc/prometheus/prometheus.yml" \
|
|
|
|
"--storage.tsdb.path=/prometheus" \
|
|
|
|
"--web.external-url=http://{{ inventory_hostname }}:9090/"
|
2018-12-06 02:59:47 +08:00
|
|
|
notify: service handler
|
|
|
|
|
|
|
|
- name: ship systemd services
|
2019-04-08 21:40:25 +08:00
|
|
|
template:
|
2019-05-13 22:21:16 +08:00
|
|
|
src: "{{ item }}.j2"
|
|
|
|
dest: "/etc/systemd/system/{{ item }}"
|
2018-12-06 02:59:47 +08:00
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: 0644
|
|
|
|
with_items:
|
|
|
|
- 'alertmanager.service'
|
|
|
|
- 'prometheus.service'
|
|
|
|
notify: service handler
|