From e9289abfabc2ac2dfd9c3466ab1592eb7033d8e1 Mon Sep 17 00:00:00 2001 From: Thomas Eckert Date: Tue, 8 Oct 2019 18:55:37 +0200 Subject: [PATCH] add new type `__xymon_config` to configure xymon-servers This allows configuration of a xymon-server. The server can be installed with `__xymon_server` or manually. In the latter case the `ext/`-dir symlink has to be added. --- cdist/conf/type/__xymon_config/files/.keep | 0 cdist/conf/type/__xymon_config/gencode-remote | 23 ++++++++ cdist/conf/type/__xymon_config/man.rst | 57 +++++++++++++++++++ cdist/conf/type/__xymon_config/manifest | 24 ++++++++ .../type/__xymon_config/parameter/required | 1 + cdist/conf/type/__xymon_config/singleton | 0 6 files changed, 105 insertions(+) create mode 100644 cdist/conf/type/__xymon_config/files/.keep create mode 100644 cdist/conf/type/__xymon_config/gencode-remote create mode 100644 cdist/conf/type/__xymon_config/man.rst create mode 100644 cdist/conf/type/__xymon_config/manifest create mode 100644 cdist/conf/type/__xymon_config/parameter/required create mode 100644 cdist/conf/type/__xymon_config/singleton diff --git a/cdist/conf/type/__xymon_config/files/.keep b/cdist/conf/type/__xymon_config/files/.keep new file mode 100644 index 00000000..e69de29b diff --git a/cdist/conf/type/__xymon_config/gencode-remote b/cdist/conf/type/__xymon_config/gencode-remote new file mode 100644 index 00000000..b25a0fda --- /dev/null +++ b/cdist/conf/type/__xymon_config/gencode-remote @@ -0,0 +1,23 @@ +#!/bin/sh -e +# +# 2018-2019 Thomas Eckert (tom at it-eckert.de) +# +# This file is part of cdist. +# +# cdist is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# cdist is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with cdist. If not, see . + +## to speed up config-reload we send a HUP to the server process: +cat <<-EOT + pkill -HUP xymond || { echo "HUPing xymond failed" >&2; exit 1; } +EOT diff --git a/cdist/conf/type/__xymon_config/man.rst b/cdist/conf/type/__xymon_config/man.rst new file mode 100644 index 00000000..8b427ca0 --- /dev/null +++ b/cdist/conf/type/__xymon_config/man.rst @@ -0,0 +1,57 @@ +cdist-type__xymon_config(7) +=========================== + +NAME +---- +cdist-type__xymon_config - Deploy a Xymon configuration-directory + + +DESCRIPTION +----------- +This cdist type deploys a full Xymon configuration directory from the files-dir +to the host. This type requires an installed Xymon server, e.g. deployed by +`__xymon_server`. + +WARNING: This type _replaces_ the `/etc/xymon/`-directory! The previous +contents is replaced/deleted! + + +REQUIRED PARAMETERS +------------------- +confdir + The directory in `./files/` that contains the `/etc/xymon/`-content to be + deployed. + + +REQUIRED FILES +-------------- +The directory specified by `confdir` has to contain a valid xymon-configuration +(`/etc/xymon/`) _plus_ the `ext/`-directory that normally resides in +`/usr/lib/xymon/server/`. + + +EXAMPLES +-------- + +.. code-block:: sh + + __xymon_config --confdir=xymon.example.com + # this will replace /etc/xymon/ on the target host with + # the contents from __xymon_config/files/xymon.example.com/ + + +SEE ALSO +-------- +:strong:`cdist__xymon_server`\ (7), :strong:`xymon`\ (7) + +AUTHORS +------- +Thomas Eckert + + +COPYING +------- +Copyright \(C) 2018-2019 Thomas Eckert. You can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation, either version 3 of the +License, or (at your option) any later version. diff --git a/cdist/conf/type/__xymon_config/manifest b/cdist/conf/type/__xymon_config/manifest new file mode 100644 index 00000000..fb1bce54 --- /dev/null +++ b/cdist/conf/type/__xymon_config/manifest @@ -0,0 +1,24 @@ +#!/bin/sh -e +# +# 2018-2019 Thomas Eckert (tom at it-eckert.de) +# +# This file is part of cdist. +# +# cdist is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# cdist is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with cdist. If not, see . + +confdir=$(cat "$__object/parameter/confdir") + +__rsync /etc/xymon/ \ + --source "$__type/files/$confdir/" \ + --rsync-opts "delete" diff --git a/cdist/conf/type/__xymon_config/parameter/required b/cdist/conf/type/__xymon_config/parameter/required new file mode 100644 index 00000000..43222f13 --- /dev/null +++ b/cdist/conf/type/__xymon_config/parameter/required @@ -0,0 +1 @@ +confdir diff --git a/cdist/conf/type/__xymon_config/singleton b/cdist/conf/type/__xymon_config/singleton new file mode 100644 index 00000000..e69de29b