forked from ungleich-public/cdist
support absent/present in __package_yum
Signed-off-by: Nico Schottelius <nico@brief.schottelius.org>
This commit is contained in:
parent
e4aafe0af9
commit
2f01fd6ce0
1 changed files with 30 additions and 16 deletions
|
@ -27,7 +27,17 @@ else
|
||||||
name="$__object_id"
|
name="$__object_id"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
state="$(cat "$__object/parameter/state")"
|
state_should="$(cat "$__object/parameter/state")"
|
||||||
|
case "$state_should" in
|
||||||
|
installed)
|
||||||
|
echo "WARNING: $state_should is deprecated and will be removed in cdist 2.1. Please change to present/absent." >&2
|
||||||
|
state_should="present"
|
||||||
|
;;
|
||||||
|
removed)
|
||||||
|
echo "WARNING: $state_should is deprecated and will be removed in cdist 2.1. Please change to present/absent." >&2
|
||||||
|
state_should="absent"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
if grep -q -E "(centos|redhat|amazon)" "$__global/explorer/os"; then
|
if grep -q -E "(centos|redhat|amazon)" "$__global/explorer/os"; then
|
||||||
opts="-y --quiet"
|
opts="-y --quiet"
|
||||||
|
@ -37,19 +47,23 @@ fi
|
||||||
|
|
||||||
not_installed="^no package provides"
|
not_installed="^no package provides"
|
||||||
|
|
||||||
case "$state" in
|
if grep -q "$not_installed" "$__object/explorer/pkg_version"; then
|
||||||
installed)
|
state_is="absent"
|
||||||
if grep -q "$not_installed" "$__object/explorer/pkg_version"; then
|
else
|
||||||
|
state_is="present"
|
||||||
|
fi
|
||||||
|
|
||||||
|
[ "$state_is" = "$state_should ] && exit 0
|
||||||
|
|
||||||
|
case "$state_should" in
|
||||||
|
present)
|
||||||
echo yum $opts install \"$name\"
|
echo yum $opts install \"$name\"
|
||||||
fi
|
|
||||||
;;
|
;;
|
||||||
removed)
|
absent)
|
||||||
if ! grep -q "$not_installed" "$__object/explorer/pkg_version"; then
|
|
||||||
echo yum $opts remove \"$name\"
|
echo yum $opts remove \"$name\"
|
||||||
fi
|
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Unknown state: $state" >&2
|
echo "Unknown state: $state_should" >&2
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
Loading…
Reference in a new issue