From 552860b9cd801af0dc3cd63969f935dca1e54491 Mon Sep 17 00:00:00 2001 From: Thomas Eckert Date: Wed, 20 Nov 2019 15:49:25 +0100 Subject: [PATCH] add parameters for ownership and generic rsync-options (__xymon_config) --- cdist/conf/type/__xymon_config/man.rst | 23 ++++++++++++++++++- cdist/conf/type/__xymon_config/manifest | 21 ++++++++++++++++- .../type/__xymon_config/parameter/optional | 2 ++ .../parameter/optional_multiple | 1 + 4 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 cdist/conf/type/__xymon_config/parameter/optional create mode 100644 cdist/conf/type/__xymon_config/parameter/optional_multiple diff --git a/cdist/conf/type/__xymon_config/man.rst b/cdist/conf/type/__xymon_config/man.rst index 8b427ca0..8adfbe1f 100644 --- a/cdist/conf/type/__xymon_config/man.rst +++ b/cdist/conf/type/__xymon_config/man.rst @@ -23,6 +23,21 @@ confdir deployed. +OPTIONAL PARAMETERS +------------------- +owner + passed as-is as `--owner` to `__rsync` + +group + passed as-is as `--group` to `__rsync` + + +OPTIONAL MULTIPLE PARAMETERS +---------------------------- +rsync-opts + identical to __rsync type, only `--`-options are supported + + REQUIRED FILES -------------- The directory specified by `confdir` has to contain a valid xymon-configuration @@ -39,10 +54,16 @@ EXAMPLES # this will replace /etc/xymon/ on the target host with # the contents from __xymon_config/files/xymon.example.com/ + ## the same but set ownership to `xymon:xymon` and exclude + ## the `netrc`-file: + __xymon_config --confdir=xymon.example.com \ + --owner xymon --group xymon \ + --rsync-opts "exclude=netrc" + SEE ALSO -------- -:strong:`cdist__xymon_server`\ (7), :strong:`xymon`\ (7) +:strong:`cdist__xymon_server`\ (7), :strong:`cdist__rsync`\ (7), :strong:`xymon`\ (7) AUTHORS ------- diff --git a/cdist/conf/type/__xymon_config/manifest b/cdist/conf/type/__xymon_config/manifest index fb1bce54..4a5fb6c9 100644 --- a/cdist/conf/type/__xymon_config/manifest +++ b/cdist/conf/type/__xymon_config/manifest @@ -18,7 +18,26 @@ # along with cdist. If not, see . confdir=$(cat "$__object/parameter/confdir") +set -- +if [ -f "$__object/parameter/owner" ]; then + owner=$(cat "$__object/parameter/owner") + set -- "$@" "--owner $owner" +fi +if [ -f "$__object/parameter/group" ]; then + group=$(cat "$__object/parameter/group") + set -- "$@" "--group $group" +fi +## pass `--rsync-opts` as-is to `__rsync`: +if [ -f "$__object/parameter/rsync-opts" ]; then + while read -r opts; do + # shellcheck disable=SC2089 + set -- "$@" "--rsync-opts '$opts'" + done < "$__object/parameter/rsync-opts" +fi + +# shellcheck disable=SC2068,SC2090 __rsync /etc/xymon/ \ --source "$__type/files/$confdir/" \ - --rsync-opts "delete" + --rsync-opts "delete" \ + $@ diff --git a/cdist/conf/type/__xymon_config/parameter/optional b/cdist/conf/type/__xymon_config/parameter/optional new file mode 100644 index 00000000..866b4bde --- /dev/null +++ b/cdist/conf/type/__xymon_config/parameter/optional @@ -0,0 +1,2 @@ +owner +group diff --git a/cdist/conf/type/__xymon_config/parameter/optional_multiple b/cdist/conf/type/__xymon_config/parameter/optional_multiple new file mode 100644 index 00000000..fdb7cd88 --- /dev/null +++ b/cdist/conf/type/__xymon_config/parameter/optional_multiple @@ -0,0 +1 @@ +rsync-opts