Signed-off-by: Steven Armstrong <steven@icarus.ethz.ch>remotes/origin/no-dot-cdist
parent
e3ae9a09bb
commit
041569b41c
@ -0,0 +1,34 @@ |
||||
#!/bin/sh |
||||
# |
||||
# 2015 Steven Armstrong (steven-cdist at armstrong.cc) |
||||
# |
||||
# 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/>. |
||||
# |
||||
|
||||
destination="$__object_id" |
||||
state="$(cat "$__object/parameter/state")" |
||||
|
||||
if [ "$state" = "absent" ]; then |
||||
# nothing to do |
||||
exit 0 |
||||
fi |
||||
|
||||
if [ -f "$__object/parameter/onchange" ]; then |
||||
if grep -q "^__file/${destination}" "$__messages_in"; then |
||||
cat "$__object/parameter/onchange" |
||||
fi |
||||
fi |
||||
|
@ -0,0 +1,60 @@ |
||||
cdist-type__config_file(7) |
||||
========================== |
||||
Steven Armstrong <steven-cdist--@--armstrong.cc> |
||||
|
||||
|
||||
NAME |
||||
---- |
||||
cdist-type__config_file - manages config files |
||||
|
||||
|
||||
DESCRIPTION |
||||
----------- |
||||
Deploy config files using the file type. |
||||
Run the given code if the files changes. |
||||
|
||||
|
||||
REQUIRED PARAMETERS |
||||
------------------- |
||||
None. |
||||
|
||||
|
||||
OPTIONAL PARAMETERS |
||||
------------------- |
||||
group:: |
||||
see cdist-type__file |
||||
mode:: |
||||
see cdist-type__file |
||||
onchange:: |
||||
the code to run if the file changes |
||||
owner:: |
||||
see cdist-type__file |
||||
source:: |
||||
Path to the config file. |
||||
If source is '-' (dash), take what was written to stdin as the config file content. |
||||
state:: |
||||
see cdist-type__file |
||||
|
||||
|
||||
EXAMPLES |
||||
-------- |
||||
|
||||
-------------------------------------------------------------------------------- |
||||
__config_file /etc/consul/conf.d/watch_foo.json \ |
||||
--owner root --group consul --mode 640 \ |
||||
--source "$__type/files/watch_foo.json" \ |
||||
--state present \ |
||||
--onchange 'service consul status >/dev/null && service consul reload || true' |
||||
-------------------------------------------------------------------------------- |
||||
|
||||
|
||||
SEE ALSO |
||||
-------- |
||||
- cdist-type(7) |
||||
- cdist-type__file(7) |
||||
|
||||
|
||||
COPYING |
||||
------- |
||||
Copyright \(C) 2015 Steven Armstrong. Free use of this software is |
||||
granted under the terms of the GNU General Public License version 3 (GPLv3). |
@ -0,0 +1,41 @@ |
||||
#!/bin/sh |
||||
# |
||||
# 2015 Steven Armstrong (steven-cdist at armstrong.cc) |
||||
# |
||||
# 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/>. |
||||
# |
||||
|
||||
set -- "/${__object_id}" |
||||
for param in $(ls "$__object/parameter/"); do |
||||
case "$param" in |
||||
source) |
||||
source="$(cat "$__object/parameter/source")" |
||||
if [ "$source" = "-" ]; then |
||||
source="$__object/stdin" |
||||
fi |
||||
set -- "$@" --source "$source" |
||||
;; |
||||
owner|group|mode|state) |
||||
set -- "$@" "--${param}" "$(cat "$__object/parameter/$param")" |
||||
;; |
||||
*) |
||||
# ignore unknown parameters |
||||
: |
||||
;; |
||||
esac |
||||
done |
||||
|
||||
__file "$@" |
@ -0,0 +1 @@ |
||||
present |
@ -0,0 +1,6 @@ |
||||
group |
||||
mode |
||||
onchange |
||||
owner |
||||
source |
||||
state |
Loading…
Reference in new issue