+++ /dev/null
----
-- name: enable service
- # We use the systemd module here so we can use the daemon_reload feature,
- # since we're shipping the .service file ourselves
- systemd:
- name: grafana-server
- daemon_reload: true
- enabled: true
- /etc/grafana
- /var/lib/grafana
-- name: make sure the grafana-server service is down
- service:
- name: grafana-server
- state: stopped
- failed_when: false
-
-# Make sure we re-create the container
-- name: remove old grafana-server container
- command: "{{ container_binary }} rm -f grafana-server"
- changed_when: false
- failed_when: false
-
-- name: create grafana-server container
- shell: |
- {{ container_binary }} create --name grafana-server \
- -v "/etc/grafana:/etc/grafana:Z" \
- -v "/var/lib/grafana:/var/lib/grafana:Z" \
- "--net=host" \
- "--cpu-period={{ grafana_container_cpu_period }}" \
- "--cpu-quota={{ grafana_container_cpu_period * grafana_container_cpu_cores }}" \
- "--memory={{ grafana_container_memory }}GB" \
- "--memory-swap={{ grafana_container_memory * 2 }}GB" \
- -e "GF_INSTALL_PLUGINS={{ grafana_plugins|join(',') }}" \
- "{{ grafana_container_image }}"
-
- name: ship systemd service
template:
src: grafana-server.service.j2
owner: root
group: root
mode: 0644
- notify: enable service
+
+- name: start the grafana-server service
+ systemd:
+ name: grafana-server
+ state: started
+ enabled: yes
+ daemon_reload: yes
+ failed_when: false
\ No newline at end of file
-# This file is managed by ansible, don't make changes here - they will be
-# overwritten.
-[Unit]
-Description=grafana-server
-{% if container_binary == 'docker' %}
-After=docker.service
-{% endif %}
+# This file is managed by ansible, don't make changes here - they will be
+# overwritten.
+[Unit]
+Description=grafana-server
+{% if container_binary == 'docker' %}
+After=docker.service
+{% endif %}
- [Service]
-EnvironmentFile=-/etc/environment
-ExecStart=/usr/bin/{{ container_binary }} start --attach grafana-server
-ExecStop=-/usr/bin/{{ container_binary }} stop grafana-server
-Restart=always
-RestartSec=10s
-TimeoutStartSec=120
-TimeoutStopSec=15
+[Service]
+EnvironmentFile=-/etc/environment
+ExecStartPre=-/usr/bin/{{ container_binary }} stop grafana-server
+ExecStartPre=-/usr/bin/{{ container_binary }} rm grafana-server
+ExecStart=/usr/bin/{{ container_binary }} run --rm --name=grafana-server \
+ -v /etc/grafana:/etc/grafana:Z \
+ -v /var/lib/grafana:/var/lib/grafana:Z \
+ --net=host \
+ --cpu-period={{ grafana_container_cpu_period }} \
+ --cpu-quota={{ grafana_container_cpu_period * grafana_container_cpu_cores }} \
+ --memory={{ grafana_container_memory }}GB \
+ --memory-swap={{ grafana_container_memory * 2 }}GB \
+ -e GF_INSTALL_PLUGINS={{ grafana_plugins|join(',') }} \
+ {{ grafana_container_image }}
+ExecStop=-/usr/bin/{{ container_binary }} stop grafana-server
+Restart=always
+RestartSec=10s
+TimeoutStartSec=120
+TimeoutStopSec=15
- [Install]
-WantedBy=multi-user.target
\ No newline at end of file
+[Install]
+WantedBy=multi-user.target
set_fact:
_rbd_target_api_handler_called: False
listen: "restart ceph rbd-target-api"
-
- - name: restart node-exporter service
- listen: "restart node-exporter service"
- # We use the systemd module here so we can use the daemon_reload feature,
- # since we're shipping the .service file ourselves
- systemd:
- name: 'node_exporter'
- daemon_reload: true
- enabled: true
- state: restarted
---
-- name: make sure the node_exporter service is down
- service:
- name: node_exporter
- state: stopped
- failed_when: false
-
-# Make sure we re-create the container
-- name: remove old node-exporter container
- command: "{{ container_binary }} rm -f node-exporter"
- changed_when: false
- failed_when: false
-
-- name: start node-exporter container
- shell: |
- {{ container_binary }} run --detach --name node-exporter \
- -v /proc:/host/proc:ro -v /sys:/host/sys:ro \
- --net=host \
- {{ node_exporter_container_image }} \
- '--path.procfs=/host/proc' \
- '--path.sysfs=/host/sys' \
- '--no-collector.timex'
- notify: restart node-exporter service
-
- name: ship systemd service
template:
src: node_exporter.service.j2
owner: root
group: root
mode: 0644
- notify: restart node-exporter service
+
+- name: start the node_exporter service
+ systemd:
+ name: node_exporter
+ state: started
+ enabled: yes
+ daemon_reload: yes
+ failed_when: false
\ No newline at end of file
[Service]
EnvironmentFile=-/etc/environment
-ExecStart=/usr/bin/{{ container_binary }} start --attach node-exporter
+ExecStartPre=-/usr/bin/{{ container_binary }} rm -f node-exporter
+ExecStart=/usr/bin/{{ container_binary }} run --name=node-exporter \
+ -v /proc:/host/proc:ro -v /sys:/host/sys:ro \
+ --net=host \
+ --path.procfs=/host/proc \
+ --path.sysfs=/host/sys \
+ --no-collector.timex \
+ {{ node_exporter_container_image }}
# Make sure the cfg80211 is loaded before running the container, the node
# exporter needs this module loaded to test for presence of wi-fi devices
ExecStartPre=/usr/sbin/modprobe cfg80211
state: restarted
with_items:
- 'alertmanager'
- - 'prometheus'
+ - 'prometheus'
\ No newline at end of file
---
-- name: make sure the alertmanager service is down
- service:
- name: alertmanager
- state: stopped
- failed_when: false
-
-# Make sure we re-create the container
-- name: remove old alertmanager container
- command: "{{ container_binary }} rm -f alertmanager"
- changed_when: false
- failed_when: false
-
-- name: start alertmanager container
- 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"
- notify: service handler
-
-- name: make sure the prometheus service is down
- service:
- name: prometheus
- state: stopped
- failed_when: false
-
-# 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/"
- notify: service handler
-
- name: ship systemd services
template:
src: "{{ item }}.j2"
- 'alertmanager.service'
- 'prometheus.service'
notify: service handler
+
+- name: start prometheus services
+ systemd:
+ name: "{{ item }}"
+ daemon_reload: true
+ enabled: true
+ state: started
+ with_items:
+ - prometheus
+ - alertmanager
[Service]
EnvironmentFile=-/etc/environment
-ExecStart=/usr/bin/{{ container_binary }} start --attach alertmanager
+ExecStartPre=-/usr/bin/{{ container_binary }} rm -f alertmanager
+ExecStart=/usr/bin/{{ container_binary }} run --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"
ExecStop=/usr/bin/{{ container_binary }} stop alertmanager
Restart=always
RestartSec=10s
[Service]
EnvironmentFile=-/etc/environment
-ExecStart=/usr/bin/{{ container_binary }} start --attach prometheus
+ExecStartPre=-/usr/bin/{{ container_binary }} rm -f prometheus
+ExecStart=/usr/bin/{{ container_binary }} run --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/"
ExecStop=/usr/bin/{{ container_binary }} stop prometheus
Restart=always
RestartSec=10s