forked from ungleich-public/cdist
Compare commits
2 commits
master
...
key_value-
Author | SHA1 | Date | |
---|---|---|---|
c388d28673 | |||
5ad85d1d1e |
4 changed files with 15 additions and 3 deletions
|
@ -23,13 +23,14 @@
|
||||||
|
|
||||||
state_should="$(cat "$__object/parameter/state")"
|
state_should="$(cat "$__object/parameter/state")"
|
||||||
state_is="$(cat "$__object/explorer/state")"
|
state_is="$(cat "$__object/explorer/state")"
|
||||||
|
fire_onchange=''
|
||||||
|
|
||||||
if [ "$state_is" = "$state_should" ]; then
|
if [ "$state_is" = "$state_should" ]; then
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# here we check only if the states are valid,
|
# here we check only if the states are valid,
|
||||||
# emmit messages and
|
# emit messages and
|
||||||
# let awk do the work ...
|
# let awk do the work ...
|
||||||
case "$state_should" in
|
case "$state_should" in
|
||||||
absent)
|
absent)
|
||||||
|
@ -39,6 +40,7 @@ case "$state_should" in
|
||||||
;;
|
;;
|
||||||
wrongformat|wrongvalue|present)
|
wrongformat|wrongvalue|present)
|
||||||
echo "remove" >> "$__messages_out"
|
echo "remove" >> "$__messages_out"
|
||||||
|
fire_onchange=1
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Unknown explorer state: $state_is" >&2
|
echo "Unknown explorer state: $state_is" >&2
|
||||||
|
@ -50,12 +52,15 @@ case "$state_should" in
|
||||||
case "$state_is" in
|
case "$state_is" in
|
||||||
nosuchfile)
|
nosuchfile)
|
||||||
echo "create" >> "$__messages_out"
|
echo "create" >> "$__messages_out"
|
||||||
|
fire_onchange=1
|
||||||
;;
|
;;
|
||||||
absent)
|
absent)
|
||||||
echo "insert" >> "$__messages_out"
|
echo "insert" >> "$__messages_out"
|
||||||
|
fire_onchange=1
|
||||||
;;
|
;;
|
||||||
wrongformated|wrongvalue)
|
wrongformated|wrongvalue)
|
||||||
echo "change" >> "$__messages_out"
|
echo "change" >> "$__messages_out"
|
||||||
|
fire_onchange=1
|
||||||
;;
|
;;
|
||||||
present)
|
present)
|
||||||
# nothing to do
|
# nothing to do
|
||||||
|
@ -67,9 +72,13 @@ case "$state_should" in
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Unknown state: $state_should" >&2
|
echo "Unknown state: $state_should" >&2
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
cat "$__type/files/remote_script.sh"
|
cat "$__type/files/remote_script.sh"
|
||||||
|
|
||||||
|
if [ -n "$fire_onchange" ]; then
|
||||||
|
cat "$__object/parameter/onchange"
|
||||||
|
fi
|
||||||
|
|
|
@ -34,6 +34,8 @@ comment
|
||||||
but only if the key or value must be changed.
|
but only if the key or value must be changed.
|
||||||
You need to ensure yourself that the line is prefixed with the correct
|
You need to ensure yourself that the line is prefixed with the correct
|
||||||
comment sign. (for example # or ; or wathever ..)
|
comment sign. (for example # or ; or wathever ..)
|
||||||
|
onchange
|
||||||
|
The code to run if the key or value changes (i.e. is inserted, removed or replaced).
|
||||||
|
|
||||||
|
|
||||||
BOOLEAN PARAMETERS
|
BOOLEAN PARAMETERS
|
||||||
|
|
0
cdist/conf/type/__key_value/parameter/default/onchange
Normal file
0
cdist/conf/type/__key_value/parameter/default/onchange
Normal file
|
@ -2,3 +2,4 @@ key
|
||||||
value
|
value
|
||||||
state
|
state
|
||||||
comment
|
comment
|
||||||
|
onchange
|
||||||
|
|
Loading…
Reference in a new issue