Merge pull request #747 from 4nd3r/__check_messages

new type: __check_messages
This commit is contained in:
Darko Poljak 2019-04-04 06:19:59 +02:00 committed by GitHub
commit 6e56de4580
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 81 additions and 0 deletions

View File

@ -0,0 +1,27 @@
#!/bin/sh -e
#
# 2019 Ander Punnar (ander-at-kvlt-dot-ee)
#
# 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 grep -Eq \
"$( cat "$__object/parameter/pattern" )" \
"$__messages_in"
then
cat "$__object/parameter/execute" \
| tee "$__messages_out"
fi

View File

@ -0,0 +1,52 @@
cdist-type__check_messages(7)
=============================
NAME
----
cdist-type__check_messages - Check messages for pattern and execute command on match.
DESCRIPTION
-----------
Check messages for pattern and execute command on match.
This type is useful if you chain together multiple related types using
dependencies and want to restart service if at least one type changes
something.
For more information about messages see `cdist messaging <cdist-messaging.html>`_.
For more information about dependencies and execution order see
`cdist manifest <cdist-manifest.html#dependencies>`_ documentation.
REQUIRED PARAMETERS
-------------------
pattern
Extended regular expression pattern for search (passed to ``grep -E``).
execute
Command to execute on pattern match.
EXAMPLES
--------
.. code-block:: sh
__check_messages munin \
--pattern '^__(file|link|line)/etc/munin/' \
--execute 'service munin-node restart'
AUTHORS
-------
Ander Punnar <ander-at-kvlt-dot-ee>
COPYING
-------
Copyright \(C) 2019 Ander Punnar. 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.

View File

@ -0,0 +1,2 @@
pattern
execute