forked from ungleich-public/cdist
add new type __xymon_apache
as a helper for __xymon_server
Details in `man.rst`
This commit is contained in:
parent
7d235fb013
commit
f35a1b9cdf
8 changed files with 207 additions and 0 deletions
22
cdist/conf/type/__xymon_apache/explorer/active-conf
Executable file
22
cdist/conf/type/__xymon_apache/explorer/active-conf
Executable file
|
@ -0,0 +1,22 @@
|
|||
#!/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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
if [ -d /etc/apache2/mods-enabled ]; then
|
||||
ls -1 /etc/apache2/conf-enabled/
|
||||
fi
|
5
cdist/conf/type/__xymon_apache/explorer/active-modules
Executable file
5
cdist/conf/type/__xymon_apache/explorer/active-modules
Executable file
|
@ -0,0 +1,5 @@
|
|||
#!/bin/sh -e
|
||||
|
||||
if [ -d /etc/apache2/mods-enabled ]; then
|
||||
/usr/sbin/apachectl -t -D DUMP_MODULES | awk '/.*_module/ { gsub(/_module.*$/, ""); gsub(/^ /, ""); print }'
|
||||
fi
|
56
cdist/conf/type/__xymon_apache/gencode-remote
Executable file
56
cdist/conf/type/__xymon_apache/gencode-remote
Executable file
|
@ -0,0 +1,56 @@
|
|||
#!/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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
state=$(cat "$__object/parameter/state")
|
||||
|
||||
os=$(cat "$__global/explorer/os")
|
||||
case "$os" in
|
||||
debian|ubuntu)
|
||||
:
|
||||
;;
|
||||
*)
|
||||
echo "Your operating system ($os) is currently not supported by this type (${__type##*/})." >&2
|
||||
echo "Please contribute an implementation for it if you can." >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ "$state" = "present" ]; then
|
||||
if ! grep -q ^rewrite "$__object/explorer/active-modules"; then
|
||||
echo "a2enmod rewrite >/dev/null"
|
||||
echo "mod:rewrite enabled" >> "$__messages_out"
|
||||
fi
|
||||
if ! grep -q "^cgi$" "$__object/explorer/active-modules"; then
|
||||
echo "a2enmod cgi >/dev/null"
|
||||
echo "mod:cgi enabled" >> "$__messages_out"
|
||||
fi
|
||||
|
||||
if ! grep -q ^xymon.conf "$__object/explorer/active-conf"; then
|
||||
echo "a2enconf xymon >/dev/null"
|
||||
echo "conf:xymon enabled" >> "$__messages_out"
|
||||
fi
|
||||
fi
|
||||
|
||||
if grep -q "^mod:.* enabled" "$__messages_out"; then
|
||||
echo "systemctl restart apache2.service"
|
||||
echo "apache restarted" >> "$__messages_out"
|
||||
elif grep -q "^conf:xymon enabled" "$__messages_out"; then
|
||||
echo "systemctl reload apache2.service"
|
||||
echo "apache reloaded" >> "$__messages_out"
|
||||
fi
|
79
cdist/conf/type/__xymon_apache/man.rst
Normal file
79
cdist/conf/type/__xymon_apache/man.rst
Normal file
|
@ -0,0 +1,79 @@
|
|||
cdist-type__xymon_apache(7)
|
||||
===========================
|
||||
|
||||
NAME
|
||||
----
|
||||
cdist-type__xymon_apache - Configure apache2-webserver for Xymon
|
||||
|
||||
|
||||
DESCRIPTION
|
||||
-----------
|
||||
This cdist type installs and configures apache2 to be used "exclusively" (in
|
||||
the sense that no other use is taken care of) with Xymon (the systems and
|
||||
network monitor).
|
||||
|
||||
It depends on `__xymon_server`.
|
||||
|
||||
|
||||
REQUIRED PARAMETERS
|
||||
-------------------
|
||||
None.
|
||||
|
||||
|
||||
OPTIONAL PARAMETERS
|
||||
-------------------
|
||||
state
|
||||
'present', 'absent', defaults to 'present'.
|
||||
|
||||
ipacl
|
||||
IP(-ranges) that have access to the Xymon webpages and CGIs. Apache2-style
|
||||
syntax suitable for `Require ip ...`. Example: `192.168.1.0/24 10.0.0.0/8`
|
||||
|
||||
|
||||
MESSAGES
|
||||
--------
|
||||
mod:rewrite enabled
|
||||
apache module enabled
|
||||
conf:xymon enabled
|
||||
apache config for xymon enabled
|
||||
apache restarted
|
||||
apache2.service was reloaded
|
||||
apache reloaded
|
||||
apache2.service was restarted
|
||||
|
||||
|
||||
EXPLORERS
|
||||
---------
|
||||
active-conf
|
||||
lists apache2 `conf-enabled`
|
||||
active-modules
|
||||
lists active apache2-modules
|
||||
|
||||
|
||||
EXAMPLES
|
||||
--------
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
# minmal, only localhost-access:
|
||||
__xymon_apache
|
||||
# allow more IPs to access the Xymon-webinterface:
|
||||
__xymon_apache --ipacl "192.168.0.0/16 10.0.0.0/8" --state "present"
|
||||
|
||||
|
||||
SEE ALSO
|
||||
--------
|
||||
:strong:`cdist__xymon_server`\ (7)
|
||||
|
||||
|
||||
AUTHORS
|
||||
-------
|
||||
Thomas Eckert <tom--@--it-eckert.de>
|
||||
|
||||
|
||||
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.
|
42
cdist/conf/type/__xymon_apache/manifest
Executable file
42
cdist/conf/type/__xymon_apache/manifest
Executable file
|
@ -0,0 +1,42 @@
|
|||
#!/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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
state=$(cat "$__object/parameter/state")
|
||||
|
||||
os=$(cat "$__global/explorer/os")
|
||||
case "$os" in
|
||||
debian|ubuntu)
|
||||
:
|
||||
;;
|
||||
*)
|
||||
echo "Your operating system ($os) is currently not supported by this type (${__type##*/})." >&2
|
||||
echo "Please contribute an implementation for it if you can." >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
__package apache2 --state "$state"
|
||||
|
||||
## edit xymon.conf IP-ranges
|
||||
if [ -f "$__object/parameter/ipacl" ]; then
|
||||
require="__package/xymon" __line /etc/apache2/conf-available/xymon.conf \
|
||||
--line " Require ip $(cat "$__object/parameter/ipacl")" \
|
||||
--after "^[[:space:]]*Require local" \
|
||||
--state "present"
|
||||
fi
|
1
cdist/conf/type/__xymon_apache/parameter/default/state
Normal file
1
cdist/conf/type/__xymon_apache/parameter/default/state
Normal file
|
@ -0,0 +1 @@
|
|||
present
|
2
cdist/conf/type/__xymon_apache/parameter/optional
Normal file
2
cdist/conf/type/__xymon_apache/parameter/optional
Normal file
|
@ -0,0 +1,2 @@
|
|||
state
|
||||
ipacl
|
0
cdist/conf/type/__xymon_apache/singleton
Normal file
0
cdist/conf/type/__xymon_apache/singleton
Normal file
Loading…
Reference in a new issue