From 5d148a58d2ed93c88c3700bc87d98b3cd766bc65 Mon Sep 17 00:00:00 2001 From: Kamila Souckova Date: Thu, 15 Jun 2017 11:13:39 +0200 Subject: [PATCH] fix missing dependencies in __prometheus_*, __go_get --- cdist/conf/type/__daemontools/man.rst | 2 +- .../parameter/default/install-init-script | 0 .../type/__daemontools_service/explorer/svc | 2 +- cdist/conf/type/__go_get/manifest | 1 + .../type/__prometheus_alertmanager/man.rst | 9 +++++---- .../type/__prometheus_alertmanager/manifest | 12 +++--------- cdist/conf/type/__prometheus_server/man.rst | 9 +++++---- cdist/conf/type/__prometheus_server/manifest | 19 +++++++------------ .../__prometheus_server/parameter/boolean | 1 - .../parameter/default/with-daemontools | 0 10 files changed, 23 insertions(+), 32 deletions(-) delete mode 100644 cdist/conf/type/__daemontools/parameter/default/install-init-script delete mode 100644 cdist/conf/type/__prometheus_server/parameter/boolean delete mode 100644 cdist/conf/type/__prometheus_server/parameter/default/with-daemontools diff --git a/cdist/conf/type/__daemontools/man.rst b/cdist/conf/type/__daemontools/man.rst index 2e012cb5..a8e81e54 100644 --- a/cdist/conf/type/__daemontools/man.rst +++ b/cdist/conf/type/__daemontools/man.rst @@ -24,7 +24,7 @@ from-package BOOLEAN PARAMETERS ------------------ install-init-script - Add an init script and set it to start on boot. Default yes. + Add an init script and set it to start on boot. EXAMPLES -------- diff --git a/cdist/conf/type/__daemontools/parameter/default/install-init-script b/cdist/conf/type/__daemontools/parameter/default/install-init-script deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/conf/type/__daemontools_service/explorer/svc b/cdist/conf/type/__daemontools_service/explorer/svc index 4a867485..d33fcea4 100644 --- a/cdist/conf/type/__daemontools_service/explorer/svc +++ b/cdist/conf/type/__daemontools_service/explorer/svc @@ -1 +1 @@ -command -v svc +command -v svc || true diff --git a/cdist/conf/type/__go_get/manifest b/cdist/conf/type/__go_get/manifest index cfeb6396..04e6a09a 100644 --- a/cdist/conf/type/__go_get/manifest +++ b/cdist/conf/type/__go_get/manifest @@ -15,3 +15,4 @@ case $os in ;; esac +__package git diff --git a/cdist/conf/type/__prometheus_alertmanager/man.rst b/cdist/conf/type/__prometheus_alertmanager/man.rst index f218254e..ba99e7c8 100644 --- a/cdist/conf/type/__prometheus_alertmanager/man.rst +++ b/cdist/conf/type/__prometheus_alertmanager/man.rst @@ -10,6 +10,9 @@ DESCRIPTION ----------- Install and configure Prometheus Alertmanager (https://prometheus.io/docs/alerting/alertmanager/). +This type create a daemontools-compatible service directory under /service/prometheus. +Daemontools (or something compatible) must be installed (in particular, the command `svc` must be executable). + REQUIRED PARAMETERS ------------------- @@ -27,10 +30,7 @@ storage-path BOOLEAN PARAMETERS ------------------ -with-daemontools - Create a daemontools service directory under /service/prometheus. Default: yes. - Note: If you do not use this, Alertmanager will not be launched, and will not reload config on change. - If you use this, daemontools (or something compatible) must be installed. +None EXAMPLES @@ -44,6 +44,7 @@ EXAMPLES __golang_from_vendor --version 1.8.1 # required for prometheus and many exporters require="__daemontools __golang_from_vendor" __prometheus_alertmanager \ + --with-daemontools \ --config "$__manifest/files/alertmanager.yml" \ --storage-path /data/alertmanager \ --listen-address "[::]:$ALERTPORT" diff --git a/cdist/conf/type/__prometheus_alertmanager/manifest b/cdist/conf/type/__prometheus_alertmanager/manifest index 61ac2d20..d885f2ed 100644 --- a/cdist/conf/type/__prometheus_alertmanager/manifest +++ b/cdist/conf/type/__prometheus_alertmanager/manifest @@ -11,12 +11,6 @@ config="$(cat "$__object/parameter/config")" storage_path="$(cat "$__object/parameter/storage-path")" listen_address="$(cat "$__object/parameter/listen-address")" -ONCHANGE="" -if [ -f "$__object/parameter/with-daemontools" ]; then - __daemontools_service prometheus --run "setuidgid prometheus $GOBIN/prometheus $REAL_FLAGS" - ONCHANGE="svc -h /service/prometheus" -fi - FLAGS="config.file '$CONF' storage.path '$storage_path' web.listen-address '$listen_address' @@ -27,12 +21,12 @@ REAL_FLAGS="$(echo "$FLAGS" | sed -nE 's/^([^#]+).*/ --\1 \\/p')" __go_get github.com/prometheus/alertmanager/cmd/... __user prometheus --system -__directory "$storage_path" --owner prometheus -__directory "$CONF_DIR" --owner prometheus +require="__user/prometheus" __directory "$storage_path" --owner prometheus +require="__user/prometheus" __directory "$CONF_DIR" --owner prometheus __daemontools_service alertmanager --run "setuidgid prometheus $GOBIN/alertmanager $REAL_FLAGS" -require="$require __directory/$storage_path" \ +require="$require __directory/$storage_path __user/prometheus" \ __config_file $CONF \ --source $config \ --group prometheus --mode 640 \ diff --git a/cdist/conf/type/__prometheus_server/man.rst b/cdist/conf/type/__prometheus_server/man.rst index c03a71d5..fadebd3f 100644 --- a/cdist/conf/type/__prometheus_server/man.rst +++ b/cdist/conf/type/__prometheus_server/man.rst @@ -10,6 +10,9 @@ DESCRIPTION ----------- Install and configure Prometheus (https://prometheus.io/). +This type creates a daemontools-compatible service directory under /service/prometheus. +Daemontools (or something compatible) must be installed (in particular, the command `svc` must be executable). + REQUIRED PARAMETERS ------------------- @@ -35,10 +38,7 @@ target-heap-size BOOLEAN PARAMETERS ------------------ -with-daemontools - Create a daemontools service directory under /service/prometheus. Default: yes. - Note: If you do not use this, Prometheus will not be launched, and will not reload config on change. - If you use this, daemontools (or something compatible) must be installed. +None EXAMPLES @@ -53,6 +53,7 @@ EXAMPLES __golang_from_vendor --version 1.8.1 # required for prometheus and many exporters require="__daemontools __golang_from_vendor" __prometheus_server \ + --with-daemontools \ --config "$__manifest/files/prometheus.yml" \ --retention-days 14 \ --storage-path /data/prometheus \ diff --git a/cdist/conf/type/__prometheus_server/manifest b/cdist/conf/type/__prometheus_server/manifest index dd81701d..3c5f16e3 100644 --- a/cdist/conf/type/__prometheus_server/manifest +++ b/cdist/conf/type/__prometheus_server/manifest @@ -16,11 +16,6 @@ rule_files="$(cat "$__object/parameter/rule-files")" # explorer in kB => convert; by default we go with 1/2 RAM [ "$target_heap_size" = "auto" ] && target_heap_size=$(($(cat $__global/explorer/memory)*1024/2)) -ONCHANGE="" -if [ -f "$__object/parameter/with-daemontools" ]; then - __daemontools_service prometheus --run "setuidgid prometheus $GOBIN/prometheus $REAL_FLAGS" - ONCHANGE="&& svc -h /service/prometheus" -fi FLAGS="config.file '$CONF' storage.local.path '$storage_path' @@ -35,23 +30,23 @@ REAL_FLAGS="$(echo "$FLAGS" | sed -nE 's/^([^#]+).*/ --\1 \\/p')" __go_get github.com/prometheus/prometheus/cmd/... __user prometheus --system -__directory "$storage_path" --owner prometheus -__directory "$CONF_DIR" --owner prometheus +require="__user/prometheus" __directory "$storage_path" --owner prometheus +require="__user/prometheus" __directory "$CONF_DIR" --owner prometheus +__daemontools_service prometheus --run "setuidgid prometheus $GOBIN/prometheus $REAL_FLAGS" - -require="$require __directory/$storage_path" \ +require="$require __directory/$storage_path __user/prometheus" \ __config_file $CONF \ --source $config \ --group prometheus --mode 640 \ - --onchange "$GOBIN/promtool check-config $CONF $ONCHANGE" + --onchange "$GOBIN/promtool check-config $CONF && svc -h /service/prometheus" for file in $rule_files; do dest=$CONF_DIR/$(basename $file) - require="$require __directory/$CONF_DIR" \ + require="$require __directory/$CONF_DIR __user/prometheus" \ __config_file "$dest" \ --source "$file" \ --owner prometheus \ - --onchange "$GOBIN/promtool check-rules '$dest' $ONCHANGE" + --onchange "$GOBIN/promtool check-rules '$dest' && svc -h /service/prometheus" done diff --git a/cdist/conf/type/__prometheus_server/parameter/boolean b/cdist/conf/type/__prometheus_server/parameter/boolean deleted file mode 100644 index de4eefdd..00000000 --- a/cdist/conf/type/__prometheus_server/parameter/boolean +++ /dev/null @@ -1 +0,0 @@ -with-daemontools diff --git a/cdist/conf/type/__prometheus_server/parameter/default/with-daemontools b/cdist/conf/type/__prometheus_server/parameter/default/with-daemontools deleted file mode 100644 index e69de29b..00000000