]> git.apps.os.sepia.ceph.com Git - ceph-ansible.git/commitdiff
dashboard: Support podman
authorBoris Ranto <branto@redhat.com>
Mon, 8 Apr 2019 13:40:25 +0000 (15:40 +0200)
committerGuillaume Abrioux <gabrioux@redhat.com>
Fri, 17 May 2019 14:05:58 +0000 (16:05 +0200)
This adds support for podman in dashboard-related roles. It also drops
the creation of custom network for the dashboard-related roles as this
functionality works in a different way with podman.

Signed-off-by: Boris Ranto <branto@redhat.com>
(cherry picked from commit b4d1c3693bba386f73c9bc1bedf772d07827ecb1)

17 files changed:
group_vars/all.yml.sample
group_vars/rhcs.yml.sample
roles/ceph-defaults/defaults/main.yml
roles/ceph-grafana/files/grafana-server.service [deleted file]
roles/ceph-grafana/tasks/setup_container.yml
roles/ceph-grafana/templates/datasources-ceph-dashboard.yml
roles/ceph-grafana/templates/grafana-server.service [new file with mode: 0644]
roles/ceph-node-exporter/files/node_exporter.service [deleted file]
roles/ceph-node-exporter/tasks/setup_container.yml
roles/ceph-node-exporter/templates/node_exporter.service [new file with mode: 0644]
roles/ceph-prometheus/defaults/main.yml
roles/ceph-prometheus/files/alertmanager.service [deleted file]
roles/ceph-prometheus/files/prometheus.service [deleted file]
roles/ceph-prometheus/tasks/setup_container.yml
roles/ceph-prometheus/templates/alertmanager.service [new file with mode: 0644]
roles/ceph-prometheus/templates/prometheus.service [new file with mode: 0644]
roles/ceph-prometheus/templates/prometheus.yml

index f20886e18339321298955f75d51828778a1a76d6..8e8743c61ba0f96f698fd78090b0ca69d4b46fca 100644 (file)
@@ -692,7 +692,6 @@ dummy:
 # DASHBOARD #
 #############
 #dashboard_enabled: False
-#dashboard_network_name: ceph-dashboard
 # Choose http or https
 # For https, you should set dashboard.crt/key and grafana.crt/key
 #dashboard_protocol: http
index c4a3ce23c5de78fbd316f794cf4ade73496db826..8b132571abfd904bc507e4280fa4a39f0df5e04e 100644 (file)
@@ -692,7 +692,6 @@ ceph_docker_registry: "registry.access.redhat.com"
 # DASHBOARD #
 #############
 #dashboard_enabled: False
-#dashboard_network_name: ceph-dashboard
 # Choose http or https
 # For https, you should set dashboard.crt/key and grafana.crt/key
 #dashboard_protocol: http
index 4236d01b2c04a42dddc35091571cee4abaa6a036..ec5c9d4fa575c377094955384348f1cce0ddee3e 100644 (file)
@@ -684,7 +684,6 @@ openstack_keys:
 # DASHBOARD #
 #############
 dashboard_enabled: False
-dashboard_network_name: ceph-dashboard
 # Choose http or https
 # For https, you should set dashboard.crt/key and grafana.crt/key
 dashboard_protocol: http
diff --git a/roles/ceph-grafana/files/grafana-server.service b/roles/ceph-grafana/files/grafana-server.service
deleted file mode 100644 (file)
index fab8f51..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-# This file is managed by ansible, don't make changes here - they will be
-# overwritten.
-[Unit]
-Description=grafana-server
-After=docker.service
-
-[Service]
-EnvironmentFile=-/etc/environment
-ExecStart=/usr/bin/docker start --attach grafana-server
-ExecStop=-/usr/bin/docker stop grafana-server
-Restart=always
-RestartSec=10s
-TimeoutStartSec=120
-TimeoutStopSec=15
-
-[Install]
-WantedBy=multi-user.target
index f0c164028a30c94f453863b09b2bffee2ce6059f..3bb8dfcc24aa5f25127d623e12733ac46fe961cc 100644 (file)
     state: stopped
   failed_when: false
 
-- name: create docker container
-  docker_container:
-    name: grafana-server
-    image: "{{ grafana_container_image }}"
-    state: present
-    # restart to allow updates
-    restart: true
-    restart_policy: no
-    force_kill: yes
-    published_ports: '3000:3000'
-    detach: true
-    volumes:
-      - "/etc/grafana:/etc/grafana:Z"
-      - "/var/lib/grafana:/var/lib/grafana:Z"
-    networks:
-      - name: "{{ dashboard_network_name }}"
-    keep_volumes: true
-    pull: true
-    cpu_period: "{{ grafana_container_cpu_period }}"
-    # As of ansible-2.5.2, this module doesn't support the equivalent of the
-    # --cpus flag, so we must use period/quota for now
-    cpu_quota: "{{ grafana_container_cpu_period * grafana_container_cpu_cores }}"
-    memory: "{{ grafana_container_memory }}GB"
-    memory_swap: "{{ grafana_container_memory * 2 }}GB"
-    env:
-      GF_INSTALL_PLUGINS: "{{ grafana_plugins|join(',') }}"
+# 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
-  copy:
+  template:
     src: grafana-server.service
     dest: "/etc/systemd/system/"
     owner: root
index b2947b72a18d7db8d0e5de5370f4ef1a0b203c99..5d5ab0125374f8e40a50ebefe03f6855b7ef98a9 100644 (file)
@@ -17,7 +17,7 @@ datasources:
   # <int> org id. will default to orgId 1 if not specified
   orgId: 1
   # <string> url
-  url: 'http://prometheus:9090'
+  url: 'http://{{ groups["grafana-server"][0] }}:9090'
   # <bool> enable/disable basic auth
   basicAuth: false
   # <bool> mark as default datasource. Max one per org
diff --git a/roles/ceph-grafana/templates/grafana-server.service b/roles/ceph-grafana/templates/grafana-server.service
new file mode 100644 (file)
index 0000000..b242a18
--- /dev/null
@@ -0,0 +1,19 @@
+# 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
+
+[Install]
+WantedBy=multi-user.target
diff --git a/roles/ceph-node-exporter/files/node_exporter.service b/roles/ceph-node-exporter/files/node_exporter.service
deleted file mode 100644 (file)
index ebf57b1..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-# This file is managed by ansible, don't make changes here - they will be
-# overwritten.
-[Unit]
-Description=Node Exporter
-After=docker.service
-
-[Service]
-EnvironmentFile=-/etc/environment
-ExecStart=/usr/bin/docker start --attach node-exporter
-# 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
-ExecStop=-/usr/bin/docker stop node-exporter
-Restart=always
-RestartSec=10s
-TimeoutStartSec=120
-TimeoutStopSec=15
-
-[Install]
-WantedBy=multi-user.target
index 09035e28f79c12a76adb84be7fc1319377afbc72..a72e5c20c1cff9bc1c7d578c2cedee5b8ad4b9c7 100644 (file)
     state: stopped
   failed_when: false
 
-- name: start docker container
-  docker_container:
-    name: node-exporter
-    image: "{{ node_exporter_container_image }}"
-    state: started
-    command:
-      - '--path.procfs=/host/proc'
-      - '--path.sysfs=/host/sys'
-      - '--no-collector.timex'
-    # restart to allow updates
-    restart: true
-    restart_policy: no
-    force_kill: yes
-    detach: true
-    volumes:
-      - '/proc:/host/proc:ro'
-      - '/sys:/host/sys:ro'
-    network_mode: host
-    keep_volumes: true
-    pull: true
+# 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
-  copy:
+  template:
     src: node_exporter.service
     dest: "/etc/systemd/system/"
     owner: root
diff --git a/roles/ceph-node-exporter/templates/node_exporter.service b/roles/ceph-node-exporter/templates/node_exporter.service
new file mode 100644 (file)
index 0000000..489ba72
--- /dev/null
@@ -0,0 +1,22 @@
+# This file is managed by ansible, don't make changes here - they will be
+# overwritten.
+[Unit]
+Description=Node Exporter
+{% if container_binary == 'docker' %}
+After=docker.service
+{% endif %}
+
+[Service]
+EnvironmentFile=-/etc/environment
+ExecStart=/usr/bin/{{ container_binary }} start --attach node-exporter
+# 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
+ExecStop=-/usr/bin/{{ container_binary }} stop node-exporter
+Restart=always
+RestartSec=10s
+TimeoutStartSec=120
+TimeoutStopSec=15
+
+[Install]
+WantedBy=multi-user.target
index 4e92142d07f71087bec9b9fcd4745258e8ad1b34..e1fc51ce0d1838aef03d3d68fc6263479bebd6fa 100644 (file)
@@ -6,7 +6,7 @@ prometheus_container_cpu_cores: 2
 prometheus_container_memory: 4
 prometheus_data_dir: /var/lib/prometheus
 prometheus_conf_dir: /etc/prometheus
-prometheus_user_id: '65534'  # This is the UID used by the prom/prometheus docker image
+prometheus_user_id: '65534'  # This is the UID used by the prom/prometheus container image
 
 alertmanager_container_image: prom/alertmanager:latest
 alertmanager_container_cpu_period: 100000
diff --git a/roles/ceph-prometheus/files/alertmanager.service b/roles/ceph-prometheus/files/alertmanager.service
deleted file mode 100644 (file)
index 2683c23..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-# This file is managed by ansible, don't make changes here - they will be
-# overwritten.
-[Unit]
-Description=alertmanager
-After=docker.service
-
-[Service]
-EnvironmentFile=-/etc/environment
-ExecStart=/usr/bin/docker start --attach alertmanager
-ExecStop=/usr/bin/docker stop alertmanager
-Restart=always
-RestartSec=10s
-TimeoutStartSec=120
-TimeoutStopSec=15
-
-[Install]
-WantedBy=multi-user.target
diff --git a/roles/ceph-prometheus/files/prometheus.service b/roles/ceph-prometheus/files/prometheus.service
deleted file mode 100644 (file)
index 1470935..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-# This file is managed by ansible, don't make changes here - they will be
-# overwritten.
-[Unit]
-Description=prometheus
-After=docker.service
-
-[Service]
-EnvironmentFile=-/etc/environment
-ExecStart=/usr/bin/docker start --attach prometheus
-ExecStop=/usr/bin/docker stop prometheus
-Restart=always
-RestartSec=10s
-TimeoutStartSec=120
-TimeoutStopSec=15
-
-[Install]
-WantedBy=multi-user.target
index 2574ab4f85b007299df29262fe574f4f31e66b1c..fddbed7d4647d9586ae2b9e505ceb1f66291654e 100644 (file)
     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
-  docker_container:
-    name: alertmanager
-    image: "{{ alertmanager_container_image }}"
-    state: started
-    command:
-      - '--config.file=/etc/alertmanager/alertmanager.yml'
-      - '--storage.path=/alertmanager'
-    # restart to allow updates
-    restart: true
-    restart_policy: no
-    force_kill: yes
-    published_ports: '9093:9093'
-    detach: true
-    volumes:
-      - "{{ alertmanager_conf_dir }}:/etc/alertmanager:Z"
-      - "{{ alertmanager_data_dir }}:/alertmanager:Z"
-    networks:
-      - name: "{{ dashboard_network_name }}"
-    keep_volumes: true
-    pull: true
-    cpu_period: "{{ alertmanager_container_cpu_period }}"
-    # As of ansible-2.5.2, this module doesn't support the equivalent of the
-    # --cpus flag, so we must use period/quota for now
-    cpu_quota: "{{ alertmanager_container_cpu_period * alertmanager_container_cpu_cores }}"
-    #memory: 0
-    #memory_swap: 0
-    memory: "{{ alertmanager_container_memory }}GB"
-    memory_swap: "{{ alertmanager_container_memory * 2 }}GB"
+  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
     state: stopped
   failed_when: false
 
-- name: start prometheus docker container
-  docker_container:
-    name: prometheus
-    image: "{{ prometheus_container_image }}"
-    state: started
-    command:
-      - '--config.file=/etc/prometheus/prometheus.yml'
-      - '--storage.tsdb.path=/prometheus'
-      - '--web.external-url=http://{{ inventory_hostname }}:9090/'
-    # restart to allow updates
-    restart: true
-    restart_policy: no
-    force_kill: yes
-    published_ports: '9090:9090'
-    detach: true
-    volumes:
-      - "{{ prometheus_conf_dir }}:/etc/prometheus:Z"
-      - "{{ prometheus_data_dir }}:/prometheus:Z"
-    networks:
-      - name: "{{ dashboard_network_name }}"
-    user: "{{ prometheus_user_id }}"
-    keep_volumes: true
-    pull: true
-    cpu_period: "{{ prometheus_container_cpu_period }}"
-    # As of ansible-2.5.2, this module doesn't support the equivalent of the
-    # --cpus flag, so we must use period/quota for now
-    cpu_quota: "{{ prometheus_container_cpu_period * prometheus_container_cpu_cores }}"
-    #memory: 0
-    #memory_swap: 0
-    memory: "{{ prometheus_container_memory }}GB"
-    memory_swap: "{{ prometheus_container_memory * 2 }}GB"
+# 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
-  copy:
+  template:
     src: "{{ item }}"
     dest: "/etc/systemd/system/"
     owner: root
diff --git a/roles/ceph-prometheus/templates/alertmanager.service b/roles/ceph-prometheus/templates/alertmanager.service
new file mode 100644 (file)
index 0000000..80eb573
--- /dev/null
@@ -0,0 +1,19 @@
+# This file is managed by ansible, don't make changes here - they will be
+# overwritten.
+[Unit]
+Description=alertmanager
+{% if container_binary == 'docker' %}
+After=docker.service
+{% endif %}
+
+[Service]
+EnvironmentFile=-/etc/environment
+ExecStart=/usr/bin/{{ container_binary }} start --attach alertmanager
+ExecStop=/usr/bin/{{ container_binary }} stop alertmanager
+Restart=always
+RestartSec=10s
+TimeoutStartSec=120
+TimeoutStopSec=15
+
+[Install]
+WantedBy=multi-user.target
diff --git a/roles/ceph-prometheus/templates/prometheus.service b/roles/ceph-prometheus/templates/prometheus.service
new file mode 100644 (file)
index 0000000..6971ead
--- /dev/null
@@ -0,0 +1,19 @@
+# This file is managed by ansible, don't make changes here - they will be
+# overwritten.
+[Unit]
+Description=prometheus
+{% if container_binary == 'docker' %}
+After=docker.service
+{% endif %}
+
+[Service]
+EnvironmentFile=-/etc/environment
+ExecStart=/usr/bin/{{ container_binary }} start --attach prometheus
+ExecStop=/usr/bin/{{ container_binary }} stop prometheus
+Restart=always
+RestartSec=10s
+TimeoutStartSec=120
+TimeoutStopSec=15
+
+[Install]
+WantedBy=multi-user.target
index 70262e4edfff45acacff34855b7e4d865f7c7f3c..71dcbb6a1b21018930688703a592fd05d770fe11 100644 (file)
@@ -44,4 +44,4 @@ alerting:
   alertmanagers:
   - scheme: http
     static_configs:
-    - targets: ['alertmanager:9093']
+    - targets: ['{{ groups["grafana-server"][0] }}:9093']