Merge branch '__package_absent_present'
This commit is contained in:
commit
2a8c764f78
18 changed files with 266 additions and 172 deletions
|
@ -1,5 +1,5 @@
|
|||
cdist-type__user(7)
|
||||
===================
|
||||
cdist-type__package(7)
|
||||
======================
|
||||
Steven Armstrong <steven-cdist--@--armstrong.cc>
|
||||
|
||||
|
||||
|
@ -17,22 +17,23 @@ It dispatches the actual work to the package system dependant types.
|
|||
REQUIRED PARAMETERS
|
||||
-------------------
|
||||
state::
|
||||
The state the package should be in, either "installed" or "removed"
|
||||
The state the package should be in, either "present" or "absent"
|
||||
(the old values "installed" or "removed" will be removed in cdist 2.1).
|
||||
|
||||
|
||||
OPTIONAL PARAMETERS
|
||||
-------------------
|
||||
name::
|
||||
The name of the package to install. Default is to use the object_id as the
|
||||
package name.
|
||||
The name of the package to install. Default is to use the object_id as the
|
||||
package name.
|
||||
version::
|
||||
The version of the package to install. Default is to install the version
|
||||
choosen by the local package manager.
|
||||
The version of the package to install. Default is to install the version
|
||||
choosen by the local package manager.
|
||||
type::
|
||||
The package type to use. Default is determined based on the $os explorer
|
||||
variable.
|
||||
e.g. __package_apt for Debian
|
||||
__package_emerge for Gentoo
|
||||
The package type to use. Default is determined based on the $os explorer
|
||||
variable.
|
||||
e.g. __package_apt for Debian
|
||||
__package_emerge for Gentoo
|
||||
|
||||
|
||||
EXAMPLES
|
||||
|
@ -40,13 +41,13 @@ EXAMPLES
|
|||
|
||||
--------------------------------------------------------------------------------
|
||||
# Install the package vim on the target
|
||||
__package vim --state installed
|
||||
__package vim --state present
|
||||
|
||||
# Same but install specific version
|
||||
__package vim --state installed --version 7.3.50
|
||||
__package vim --state present --version 7.3.50
|
||||
|
||||
# Force use of a specific package type
|
||||
__package vim --state installed --type __package_apt
|
||||
__package vim --state present --type __package_apt
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# 2011 Nico Schottelius (nico-cdist at schottelius.org)
|
||||
# 2011-2012 Nico Schottelius (nico-cdist at schottelius.org)
|
||||
#
|
||||
# This file is part of cdist.
|
||||
#
|
||||
|
@ -28,11 +28,11 @@ else
|
|||
fi
|
||||
|
||||
# Except dpkg failing, if package is not known / installed
|
||||
packages="$(apt-cache showpkg "$name" | sed -e "1,/Reverse Provides:/d" | cut -d ' ' -f 1) $name"
|
||||
packages="$(apt-cache showpkg "$name" | sed -e "1,/Reverse Provides:/d" | cut -d ' ' -f 1) $name"
|
||||
for p in $packages; do
|
||||
if [ -n "$(dpkg -s "$p" 2>/dev/null | grep "^Status: install ok installed$")" ]; then
|
||||
echo "installed $p"
|
||||
echo "present $p"
|
||||
exit 0
|
||||
fi
|
||||
done
|
||||
echo "removed"
|
||||
echo absent
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# 2011 Nico Schottelius (nico-cdist at schottelius.org)
|
||||
# 2011-2012 Nico Schottelius (nico-cdist at schottelius.org)
|
||||
#
|
||||
# This file is part of cdist.
|
||||
#
|
||||
|
@ -28,28 +28,41 @@ else
|
|||
fi
|
||||
|
||||
state_should="$(cat "$__object/parameter/state")"
|
||||
state_is="$(cat "$__object/explorer/pkg_status")"
|
||||
|
||||
# Correct pre 2.1 naming - FIXME in 2.1
|
||||
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
|
||||
|
||||
# FIXME: use grep directly, state is a list, not a line!
|
||||
state_is="$(cat "$__object/explorer/state")"
|
||||
case "$state_is" in
|
||||
installed*)
|
||||
present*)
|
||||
name="$(echo "$state_is" | cut -d ' ' -f 2)"
|
||||
state_is="installed"
|
||||
state_is="present"
|
||||
;;
|
||||
esac
|
||||
|
||||
aptget="DEBIAN_FRONTEND=noninteractive apt-get --quiet --yes"
|
||||
|
||||
if [ "$state_is" != "$state_should" ]; then
|
||||
case "$state_should" in
|
||||
installed)
|
||||
echo $aptget install \"$name\"
|
||||
;;
|
||||
removed)
|
||||
echo $aptget remove \"$name\"
|
||||
;;
|
||||
*)
|
||||
echo "Unknown state: $state" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
[ "$state_is" = "$state_should" ] && exit 0
|
||||
|
||||
case "$state_should" in
|
||||
present)
|
||||
echo $aptget install \"$name\"
|
||||
;;
|
||||
absent)
|
||||
echo $aptget remove \"$name\"
|
||||
;;
|
||||
*)
|
||||
echo "Unknown state: $state_should" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
|
|
@ -17,7 +17,8 @@ manage packages.
|
|||
REQUIRED PARAMETERS
|
||||
-------------------
|
||||
state::
|
||||
Either "installed" or "removed".
|
||||
The state the package should be in, either "present" or "absent"
|
||||
(the old values "installed" or "removed" will be removed in cdist 2.1).
|
||||
|
||||
|
||||
OPTIONAL PARAMETERS
|
||||
|
@ -31,13 +32,13 @@ EXAMPLES
|
|||
|
||||
--------------------------------------------------------------------------------
|
||||
# Ensure zsh in installed
|
||||
__package_apt zsh --state installed
|
||||
__package_apt zsh --state present
|
||||
|
||||
# In case you only want *a* webserver, but don't care which one
|
||||
__package_apt webserver --state installed --name nginx
|
||||
__package_apt webserver --state present --name nginx
|
||||
|
||||
# Remove obsolete package
|
||||
__package_apt puppet --state removed
|
||||
__package_apt puppet --state absent
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
|
|
@ -24,29 +24,43 @@
|
|||
|
||||
|
||||
if [ -f "$__object/parameter/name" ]; then
|
||||
name="$(cat "$__object/parameter/name")"
|
||||
name="$(cat "$__object/parameter/name")"
|
||||
else
|
||||
name="$__object_id"
|
||||
name="$__object_id"
|
||||
fi
|
||||
|
||||
state="$(cat "$__object/parameter/state")"
|
||||
is_installed="$(grep "(installed)" "$__object/explorer/pkg_status" || true)"
|
||||
|
||||
case "$state" in
|
||||
installed)
|
||||
# Install only if non-existent
|
||||
if [ -z "$is_installed" ]; then
|
||||
echo luarocks install \"$name\"
|
||||
fi
|
||||
;;
|
||||
removed)
|
||||
# Remove only if existent
|
||||
if [ -n "$is_installed" ]; then
|
||||
echo luarocks remove \"$name\"
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
echo "Unknown state: $state" >&2
|
||||
exit 1
|
||||
;;
|
||||
state_should="$(cat "$__object/parameter/state")"
|
||||
# Correct pre 2.1 naming - FIXME in 2.1
|
||||
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 "(installed)" "$__object/explorer/pkg_status"; then
|
||||
state_is="present"
|
||||
else
|
||||
state_is="absent"
|
||||
fi
|
||||
|
||||
# Leave if nothing is to be done
|
||||
[ "$state_is" = "$state_should" ] && exit 0
|
||||
|
||||
case "$state_should" in
|
||||
present)
|
||||
echo luarocks install \"$name\"
|
||||
;;
|
||||
absent)
|
||||
echo luarocks remove \"$name\"
|
||||
;;
|
||||
*)
|
||||
echo "Unknown state: $state_should" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
cdist-type__package_luarocks(7)
|
||||
==============================
|
||||
===============================
|
||||
Christian G. Warden <cwarden@xerus.org>
|
||||
|
||||
|
||||
|
@ -16,13 +16,14 @@ LuaRocks is a deployment and management system for Lua modules.
|
|||
REQUIRED PARAMETERS
|
||||
-------------------
|
||||
state::
|
||||
Either "installed" or "removed".
|
||||
The state the package should be in, either "present" or "absent"
|
||||
(the old values "installed" or "removed" will be removed in cdist 2.1).
|
||||
|
||||
|
||||
OPTIONAL PARAMETERS
|
||||
-------------------
|
||||
name::
|
||||
If supplied, use the name and not the object id as the package name.
|
||||
If supplied, use the name and not the object id as the package name.
|
||||
|
||||
|
||||
EXAMPLES
|
||||
|
@ -30,10 +31,10 @@ EXAMPLES
|
|||
|
||||
--------------------------------------------------------------------------------
|
||||
# Ensure luasocket is installed
|
||||
__package_luarocks luasocket --state installed
|
||||
__package_luarocks luasocket --state present
|
||||
|
||||
# Remove package
|
||||
__package_luarocks luasocket --state removed
|
||||
__package_luarocks luasocket --state absent
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# 2011 Nico Schottelius (nico-cdist at schottelius.org)
|
||||
# 2011-2012 Nico Schottelius (nico-cdist at schottelius.org)
|
||||
#
|
||||
# This file is part of cdist.
|
||||
#
|
||||
|
@ -18,7 +18,7 @@
|
|||
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#
|
||||
# Retrieve the status of a package - parsed dpkg output
|
||||
# Retrieve the status of a package - parsed pacman output
|
||||
#
|
||||
|
||||
if [ -f "$__object/parameter/name" ]; then
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# 2011 Nico Schottelius (nico-cdist at schottelius.org)
|
||||
# 2011-2012 Nico Schottelius (nico-cdist at schottelius.org)
|
||||
#
|
||||
# This file is part of cdist.
|
||||
#
|
||||
|
@ -33,24 +33,37 @@ else
|
|||
name="$__object_id"
|
||||
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
|
||||
|
||||
pkg_version="$(cat "$__object/explorer/pkg_version")"
|
||||
if [ -z "$pkg_version" ]; then
|
||||
state_is="absent"
|
||||
else
|
||||
state_is="present"
|
||||
fi
|
||||
|
||||
case "$state" in
|
||||
installed)
|
||||
# Exit if nothing is needed to be done
|
||||
[ "$state_is" = "$state_should" ] && exit 0
|
||||
|
||||
# Empty? Not installed.
|
||||
if [ -z "$pkg_version" ]; then
|
||||
case "$state_should" in
|
||||
present)
|
||||
echo pacman "$pacopts" -S \"$name\"
|
||||
fi
|
||||
;;
|
||||
removed)
|
||||
if [ "$pkg_version" ]; then
|
||||
absent)
|
||||
echo pacman "$pacopts" -R \"$name\"
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
echo "Unknown state: $state" >&2
|
||||
echo "Unknown state: $state_should" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
|
|
@ -17,13 +17,14 @@ packages.
|
|||
REQUIRED PARAMETERS
|
||||
-------------------
|
||||
state::
|
||||
Either "installed" or "removed".
|
||||
The state the package should be in, either "present" or "absent"
|
||||
(the old values "installed" or "removed" will be removed in cdist 2.1).
|
||||
|
||||
|
||||
OPTIONAL PARAMETERS
|
||||
-------------------
|
||||
name::
|
||||
If supplied, use the name and not the object id as the package name.
|
||||
If supplied, use the name and not the object id as the package name.
|
||||
|
||||
|
||||
EXAMPLES
|
||||
|
@ -31,13 +32,13 @@ EXAMPLES
|
|||
|
||||
--------------------------------------------------------------------------------
|
||||
# Ensure zsh in installed
|
||||
__package_pacman zsh --state installed
|
||||
__package_pacman zsh --state present
|
||||
|
||||
# If you don't want to follow pythonX packages, but always use python
|
||||
__package_pacman python --state installed --name python2
|
||||
__package_pacman python --state present --name python2
|
||||
|
||||
# Remove obsolete package
|
||||
__package_pacman puppet --state removed
|
||||
__package_pacman puppet --state absent
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
@ -49,5 +50,5 @@ SEE ALSO
|
|||
|
||||
COPYING
|
||||
-------
|
||||
Copyright \(C) 2011 Nico Schottelius. Free use of this software is
|
||||
Copyright \(C) 2011-2012 Nico Schottelius. Free use of this software is
|
||||
granted under the terms of the GNU General Public License version 3 (GPLv3).
|
||||
|
|
|
@ -47,4 +47,8 @@ case "$state_should" in
|
|||
absent)
|
||||
echo $pip uninstall -q -y pyro
|
||||
;;
|
||||
*)
|
||||
echo "Unknown state: $state_should" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
|
|
@ -23,10 +23,10 @@ state::
|
|||
OPTIONAL PARAMETERS
|
||||
-------------------
|
||||
name::
|
||||
If supplied, use the name and not the object id as the package name.
|
||||
If supplied, use the name and not the object id as the package name.
|
||||
|
||||
pip::
|
||||
Instead of using pip from PATH, use the specific pip path.
|
||||
Instead of using pip from PATH, use the specific pip path.
|
||||
|
||||
|
||||
EXAMPLES
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# 2011 Andi Brönnimann (andi-cdist at v-net.ch)
|
||||
# 2012 Nico Schottelius (nico-cdist at schottelius.org)
|
||||
#
|
||||
# This file is part of cdist.
|
||||
#
|
||||
|
@ -28,7 +29,6 @@
|
|||
os_version="$(cat "$__global/explorer/os_version")"
|
||||
machine="$(cat "$__global/explorer/machine")"
|
||||
|
||||
|
||||
if [ -f "$__object/parameter/flavor" ]; then
|
||||
flavor="$(cat "$__object/parameter/flavor")"
|
||||
fi
|
||||
|
@ -42,44 +42,60 @@ else
|
|||
name="$__object_id"
|
||||
fi
|
||||
|
||||
state="$(cat "$__object/parameter/state")"
|
||||
state_should="$(cat "$__object/parameter/state")"
|
||||
# Correct pre 2.1 naming - FIXME in 2.1
|
||||
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
|
||||
|
||||
pkg_version="$(cat "$__object/explorer/pkg_version")"
|
||||
|
||||
# TODO: Shouldn't be hardcoded
|
||||
echo export PKG_PATH=ftp://ftp.openbsd.org/pub/OpenBSD/$os_version/packages/$machine/
|
||||
|
||||
case "$state" in
|
||||
installed)
|
||||
# Empty? Not installed.
|
||||
if [ -z "$pkg_version" ]; then
|
||||
# use this because pkg_add doesn't properly handle errors
|
||||
cat << eof
|
||||
status=\$(pkg_add "$pkgopts" "$name--$flavor")
|
||||
if [ "$pkg_version" ]; then
|
||||
state_is="present"
|
||||
else
|
||||
state_is="absent"
|
||||
fi
|
||||
|
||||
# no error
|
||||
if [ -n "\$status" ]; then
|
||||
echo "Error: \$status"
|
||||
exit 1
|
||||
fi
|
||||
eof
|
||||
fi
|
||||
;;
|
||||
removed)
|
||||
if [ "$pkg_version" ]; then
|
||||
# use this because pkg_add doesn't properly handle errors
|
||||
cat << eof
|
||||
status=\$(pkg_delete "$pkgopts" "$name--$flavor")
|
||||
[ "$state_is" = "$state_should" ] && exit 0
|
||||
|
||||
# no error
|
||||
if [ -n "\$status" ]; then
|
||||
echo "Error: \$status"
|
||||
exit 1
|
||||
fi
|
||||
case "$state_should" in
|
||||
present)
|
||||
# use this because pkg_add doesn't properly handle errors
|
||||
cat << eof
|
||||
status=\$(pkg_add "$pkgopts" "$name--$flavor")
|
||||
|
||||
# no error
|
||||
if [ -n "\$status" ]; then
|
||||
echo "Error: \$status"
|
||||
exit 1
|
||||
fi
|
||||
eof
|
||||
;;
|
||||
|
||||
absent)
|
||||
# use this because pkg_add doesn't properly handle errors
|
||||
cat << eof
|
||||
status=\$(pkg_delete "$pkgopts" "$name--$flavor")
|
||||
|
||||
# no error
|
||||
if [ -n "\$status" ]; then
|
||||
echo "Error: \$status"
|
||||
exit 1
|
||||
fi
|
||||
eof
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
echo "Unknown state: $state" >&2
|
||||
echo "Unknown state: $state_should" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
|
|
@ -16,16 +16,17 @@ This type is usually used on OpenBSD to manage packages.
|
|||
REQUIRED PARAMETERS
|
||||
-------------------
|
||||
state::
|
||||
Either "installed" or "removed".
|
||||
The state the package should be in, either "present" or "absent"
|
||||
(the old values "installed" or "removed" will be removed in cdist 2.1).
|
||||
|
||||
|
||||
OPTIONAL PARAMETERS
|
||||
-------------------
|
||||
name::
|
||||
If supplied, use the name and not the object id as the package name.
|
||||
If supplied, use the name and not the object id as the package name.
|
||||
|
||||
flavor::
|
||||
If supplied, use to avoid ambiguity.
|
||||
If supplied, use to avoid ambiguity.
|
||||
|
||||
|
||||
EXAMPLES
|
||||
|
@ -33,16 +34,16 @@ EXAMPLES
|
|||
|
||||
--------------------------------------------------------------------------------
|
||||
# Ensure zsh is installed
|
||||
__package_pkg_openbsd zsh --state installed
|
||||
__package_pkg_openbsd zsh --state present
|
||||
|
||||
# Ensure vim is installed, use flavor no_x11
|
||||
__package_pkg_openbsd vim --state installed --flavor no_x11
|
||||
__package_pkg_openbsd vim --state present --flavor no_x11
|
||||
|
||||
# If you don't want to follow pythonX packages, but always use python
|
||||
__package_pkg_openbsd python --state installed --name python2
|
||||
__package_pkg_openbsd python --state present --name python2
|
||||
|
||||
# Remove obsolete package
|
||||
__package_pkg_openbsd puppet --state removed
|
||||
__package_pkg_openbsd puppet --state absent
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
|
|
@ -21,31 +21,42 @@
|
|||
# Manage Rubygem packages
|
||||
#
|
||||
|
||||
|
||||
if [ -f "$__object/parameter/name" ]; then
|
||||
name="$(cat "$__object/parameter/name")"
|
||||
name="$(cat "$__object/parameter/name")"
|
||||
else
|
||||
name="$__object_id"
|
||||
name="$__object_id"
|
||||
fi
|
||||
|
||||
state="$(cat "$__object/parameter/state")"
|
||||
is_installed="$(grep "true" "$__object/explorer/pkg_status" || true)"
|
||||
|
||||
case "$state" in
|
||||
installed)
|
||||
# Install only if non-existent
|
||||
if [ -z "$is_installed" ]; then
|
||||
echo gem install \"$name\" --no-ri --no-rdoc
|
||||
fi
|
||||
;;
|
||||
removed)
|
||||
# Remove only if existent
|
||||
if [ -n "$is_installed" ]; then
|
||||
echo gem uninstall \"$name\"
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
echo "Unknown state: $state" >&2
|
||||
exit 1
|
||||
;;
|
||||
state_should="$(cat "$__object/parameter/state")"
|
||||
# Correct pre 2.1 naming - FIXME in 2.1
|
||||
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 true "$__object/explorer/pkg_status"; then
|
||||
state_is="present"
|
||||
else
|
||||
state_is="absent"
|
||||
fi
|
||||
|
||||
[ "$state_is" = "$state_should ] && exit 0
|
||||
|
||||
case "$state_should" in
|
||||
present)
|
||||
echo gem install \"$name\" --no-ri --no-rdoc
|
||||
;;
|
||||
absent)
|
||||
echo gem uninstall \"$name\"
|
||||
;;
|
||||
*)
|
||||
echo "Unknown state: $state_should" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
|
|
@ -16,13 +16,14 @@ Rubygems is the default package management system for the Ruby programming langu
|
|||
REQUIRED PARAMETERS
|
||||
-------------------
|
||||
state::
|
||||
Either "installed" or "removed".
|
||||
The state the package should be in, either "present" or "absent"
|
||||
(the old values "installed" or "removed" will be removed in cdist 2.1).
|
||||
|
||||
|
||||
OPTIONAL PARAMETERS
|
||||
-------------------
|
||||
name::
|
||||
If supplied, use the name and not the object id as the package name.
|
||||
If supplied, use the name and not the object id as the package name.
|
||||
|
||||
|
||||
EXAMPLES
|
||||
|
@ -30,10 +31,10 @@ EXAMPLES
|
|||
|
||||
--------------------------------------------------------------------------------
|
||||
# Ensure sinatra is installed
|
||||
__package_rubygem sinatra --state installed
|
||||
__package_rubygem sinatra --state present
|
||||
|
||||
# Remove package
|
||||
__package_rubygem rails --state removed
|
||||
__package_rubygem rails --state absent
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
|
|
@ -27,7 +27,17 @@ else
|
|||
name="$__object_id"
|
||||
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
|
||||
opts="-y --quiet"
|
||||
|
@ -37,19 +47,23 @@ fi
|
|||
|
||||
not_installed="^no package provides"
|
||||
|
||||
case "$state" in
|
||||
installed)
|
||||
if grep -q "$not_installed" "$__object/explorer/pkg_version"; then
|
||||
echo yum $opts install \"$name\"
|
||||
fi
|
||||
;;
|
||||
removed)
|
||||
if ! grep -q "$not_installed" "$__object/explorer/pkg_version"; then
|
||||
echo yum $opts remove \"$name\"
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
echo "Unknown state: $state" >&2
|
||||
exit 1
|
||||
;;
|
||||
if grep -q "$not_installed" "$__object/explorer/pkg_version"; then
|
||||
state_is="absent"
|
||||
else
|
||||
state_is="present"
|
||||
fi
|
||||
|
||||
[ "$state_is" = "$state_should ] && exit 0
|
||||
|
||||
case "$state_should" in
|
||||
present)
|
||||
echo yum $opts install \"$name\"
|
||||
;;
|
||||
absent)
|
||||
echo yum $opts remove \"$name\"
|
||||
;;
|
||||
*)
|
||||
echo "Unknown state: $state_should" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
|
|
@ -18,13 +18,14 @@ slightly confusing error message "Error: Nothing to do".
|
|||
REQUIRED PARAMETERS
|
||||
-------------------
|
||||
state::
|
||||
Either "installed" or "removed".
|
||||
The state the package should be in, either "present" or "absent"
|
||||
(the old values "installed" or "removed" will be removed in cdist 2.1).
|
||||
|
||||
|
||||
OPTIONAL PARAMETERS
|
||||
-------------------
|
||||
name::
|
||||
If supplied, use the name and not the object id as the package name.
|
||||
If supplied, use the name and not the object id as the package name.
|
||||
|
||||
|
||||
EXAMPLES
|
||||
|
@ -32,13 +33,13 @@ EXAMPLES
|
|||
|
||||
--------------------------------------------------------------------------------
|
||||
# Ensure zsh in installed
|
||||
__package_yum zsh --state installed
|
||||
__package_yum zsh --state present
|
||||
|
||||
# If you don't want to follow pythonX packages, but always use python
|
||||
__package_yum python --state installed --name python2
|
||||
__package_yum python --state present --name python2
|
||||
|
||||
# Remove obsolete package
|
||||
__package_yum puppet --state removed
|
||||
__package_yum puppet --state absent
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
|
|
@ -9,6 +9,8 @@ Changelog
|
|||
* Cleanup: Do not output failing script, but path to script only
|
||||
* Cleanup: Remove support for __debug variable in manifests (Type != Core
|
||||
debugging)
|
||||
* Cleanup: Change __package_* to support absent/present (default state
|
||||
name now). The values removed/installed will be removed in cdist 2.1.
|
||||
* Feature Core: Support boolean parameters (Steven Armstrong)
|
||||
|
||||
2.0.7: 2012-02-13
|
||||
|
|
Loading…
Reference in a new issue