forked from ungleich-public/cdist
Merge branch 'master' into __jail
This commit is contained in:
commit
5989fedb3e
43 changed files with 637 additions and 221 deletions
|
@ -200,11 +200,13 @@ def emulator():
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
# Sys is needed for sys.exit()
|
||||||
|
import sys
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import sys
|
|
||||||
|
|
||||||
cdistpythonversion = '3.2'
|
cdistpythonversion = '3.2'
|
||||||
if sys.version < cdistpythonversion:
|
if sys.version < cdistpythonversion:
|
||||||
|
@ -228,7 +230,7 @@ if __name__ == "__main__":
|
||||||
else:
|
else:
|
||||||
commandline()
|
commandline()
|
||||||
|
|
||||||
except KeyboardInterrupt:
|
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
sys.exit(0)
|
except KeyboardInterrupt:
|
||||||
|
sys.exit(0)
|
||||||
|
|
1
build
1
build
|
@ -130,6 +130,7 @@ case "$1" in
|
||||||
git push --mirror
|
git push --mirror
|
||||||
git push --mirror github
|
git push --mirror github
|
||||||
git push --mirror sf
|
git push --mirror sf
|
||||||
|
git push --mirror ethz
|
||||||
;;
|
;;
|
||||||
|
|
||||||
clean)
|
clean)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
cdist-type__user(7)
|
cdist-type__package(7)
|
||||||
===================
|
======================
|
||||||
Steven Armstrong <steven-cdist--@--armstrong.cc>
|
Steven Armstrong <steven-cdist--@--armstrong.cc>
|
||||||
|
|
||||||
|
|
||||||
|
@ -17,22 +17,23 @@ It dispatches the actual work to the package system dependant types.
|
||||||
REQUIRED PARAMETERS
|
REQUIRED PARAMETERS
|
||||||
-------------------
|
-------------------
|
||||||
state::
|
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
|
OPTIONAL PARAMETERS
|
||||||
-------------------
|
-------------------
|
||||||
name::
|
name::
|
||||||
The name of the package to install. Default is to use the object_id as the
|
The name of the package to install. Default is to use the object_id as the
|
||||||
package name.
|
package name.
|
||||||
version::
|
version::
|
||||||
The version of the package to install. Default is to install the version
|
The version of the package to install. Default is to install the version
|
||||||
choosen by the local package manager.
|
choosen by the local package manager.
|
||||||
type::
|
type::
|
||||||
The package type to use. Default is determined based on the $os explorer
|
The package type to use. Default is determined based on the $os explorer
|
||||||
variable.
|
variable.
|
||||||
e.g. __package_apt for Debian
|
e.g. __package_apt for Debian
|
||||||
__package_emerge for Gentoo
|
__package_emerge for Gentoo
|
||||||
|
|
||||||
|
|
||||||
EXAMPLES
|
EXAMPLES
|
||||||
|
@ -40,13 +41,13 @@ EXAMPLES
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
# Install the package vim on the target
|
# Install the package vim on the target
|
||||||
__package vim --state installed
|
__package vim --state present
|
||||||
|
|
||||||
# Same but install specific version
|
# 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
|
# 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
|
#!/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.
|
# This file is part of cdist.
|
||||||
#
|
#
|
||||||
|
@ -28,11 +28,11 @@ else
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Except dpkg failing, if package is not known / installed
|
# 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
|
for p in $packages; do
|
||||||
if [ -n "$(dpkg -s "$p" 2>/dev/null | grep "^Status: install ok installed$")" ]; then
|
if [ -n "$(dpkg -s "$p" 2>/dev/null | grep "^Status: install ok installed$")" ]; then
|
||||||
echo "installed $p"
|
echo "present $p"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
echo "removed"
|
echo absent
|
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/sh
|
#!/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.
|
# This file is part of cdist.
|
||||||
#
|
#
|
||||||
|
@ -28,28 +28,41 @@ else
|
||||||
fi
|
fi
|
||||||
|
|
||||||
state_should="$(cat "$__object/parameter/state")"
|
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: ${__object_name}: $state_should is deprecated and will be removed in cdist 2.1. Please change to present/absent." >&2
|
||||||
|
state_should="present"
|
||||||
|
;;
|
||||||
|
removed)
|
||||||
|
echo "WARNING: ${__object_name}: $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
|
case "$state_is" in
|
||||||
installed*)
|
present*)
|
||||||
name="$(echo "$state_is" | cut -d ' ' -f 2)"
|
name="$(echo "$state_is" | cut -d ' ' -f 2)"
|
||||||
state_is="installed"
|
state_is="present"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
aptget="DEBIAN_FRONTEND=noninteractive apt-get --quiet --yes"
|
aptget="DEBIAN_FRONTEND=noninteractive apt-get --quiet --yes"
|
||||||
|
|
||||||
if [ "$state_is" != "$state_should" ]; then
|
[ "$state_is" = "$state_should" ] && exit 0
|
||||||
case "$state_should" in
|
|
||||||
installed)
|
|
||||||
echo $aptget install \"$name\"
|
|
||||||
;;
|
|
||||||
removed)
|
|
||||||
echo $aptget remove \"$name\"
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
echo "Unknown state: $state" >&2
|
|
||||||
exit 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
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
|
REQUIRED PARAMETERS
|
||||||
-------------------
|
-------------------
|
||||||
state::
|
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
|
OPTIONAL PARAMETERS
|
||||||
|
@ -31,13 +32,13 @@ EXAMPLES
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
# Ensure zsh in installed
|
# 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
|
# 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
|
# Remove obsolete package
|
||||||
__package_apt puppet --state removed
|
__package_apt puppet --state absent
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -24,29 +24,43 @@
|
||||||
|
|
||||||
|
|
||||||
if [ -f "$__object/parameter/name" ]; then
|
if [ -f "$__object/parameter/name" ]; then
|
||||||
name="$(cat "$__object/parameter/name")"
|
name="$(cat "$__object/parameter/name")"
|
||||||
else
|
else
|
||||||
name="$__object_id"
|
name="$__object_id"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
state="$(cat "$__object/parameter/state")"
|
state_should="$(cat "$__object/parameter/state")"
|
||||||
is_installed="$(grep "(installed)" "$__object/explorer/pkg_status" || true)"
|
# Correct pre 2.1 naming - FIXME in 2.1
|
||||||
|
case "$state_should" in
|
||||||
case "$state" in
|
installed)
|
||||||
installed)
|
echo "WARNING: ${__object_name}: $state_should is deprecated and will be removed in cdist 2.1. Please change to present/absent." >&2
|
||||||
# Install only if non-existent
|
state_should="present"
|
||||||
if [ -z "$is_installed" ]; then
|
;;
|
||||||
echo luarocks install \"$name\"
|
removed)
|
||||||
fi
|
echo "WARNING: ${__object_name}: $state_should is deprecated and will be removed in cdist 2.1. Please change to present/absent." >&2
|
||||||
;;
|
state_should="absent"
|
||||||
removed)
|
;;
|
||||||
# Remove only if existent
|
esac
|
||||||
if [ -n "$is_installed" ]; then
|
|
||||||
echo luarocks remove \"$name\"
|
|
||||||
fi
|
if grep -q "(installed)" "$__object/explorer/pkg_status"; then
|
||||||
;;
|
state_is="present"
|
||||||
*)
|
else
|
||||||
echo "Unknown state: $state" >&2
|
state_is="absent"
|
||||||
exit 1
|
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
|
esac
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
cdist-type__package_luarocks(7)
|
cdist-type__package_luarocks(7)
|
||||||
==============================
|
===============================
|
||||||
Christian G. Warden <cwarden@xerus.org>
|
Christian G. Warden <cwarden@xerus.org>
|
||||||
|
|
||||||
|
|
||||||
|
@ -16,13 +16,14 @@ LuaRocks is a deployment and management system for Lua modules.
|
||||||
REQUIRED PARAMETERS
|
REQUIRED PARAMETERS
|
||||||
-------------------
|
-------------------
|
||||||
state::
|
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
|
OPTIONAL PARAMETERS
|
||||||
-------------------
|
-------------------
|
||||||
name::
|
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
|
EXAMPLES
|
||||||
|
@ -30,10 +31,10 @@ EXAMPLES
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
# Ensure luasocket is installed
|
# Ensure luasocket is installed
|
||||||
__package_luarocks luasocket --state installed
|
__package_luarocks luasocket --state present
|
||||||
|
|
||||||
# Remove package
|
# Remove package
|
||||||
__package_luarocks luasocket --state removed
|
__package_luarocks luasocket --state absent
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/sh
|
#!/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.
|
# This file is part of cdist.
|
||||||
#
|
#
|
||||||
|
@ -18,7 +18,7 @@
|
||||||
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
|
# 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
|
if [ -f "$__object/parameter/name" ]; then
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/sh
|
#!/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.
|
# This file is part of cdist.
|
||||||
#
|
#
|
||||||
|
@ -33,24 +33,37 @@ 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: ${__object_name}: $state_should is deprecated and will be removed in cdist 2.1. Please change to present/absent." >&2
|
||||||
|
state_should="present"
|
||||||
|
;;
|
||||||
|
removed)
|
||||||
|
echo "WARNING: ${__object_name}: $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")"
|
pkg_version="$(cat "$__object/explorer/pkg_version")"
|
||||||
|
if [ -z "$pkg_version" ]; then
|
||||||
|
state_is="absent"
|
||||||
|
else
|
||||||
|
state_is="present"
|
||||||
|
fi
|
||||||
|
|
||||||
case "$state" in
|
# Exit if nothing is needed to be done
|
||||||
installed)
|
[ "$state_is" = "$state_should" ] && exit 0
|
||||||
|
|
||||||
# Empty? Not installed.
|
case "$state_should" in
|
||||||
if [ -z "$pkg_version" ]; then
|
present)
|
||||||
echo pacman "$pacopts" -S \"$name\"
|
echo pacman "$pacopts" -S \"$name\"
|
||||||
fi
|
|
||||||
;;
|
;;
|
||||||
removed)
|
absent)
|
||||||
if [ "$pkg_version" ]; then
|
|
||||||
echo pacman "$pacopts" -R \"$name\"
|
echo pacman "$pacopts" -R \"$name\"
|
||||||
fi
|
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Unknown state: $state" >&2
|
echo "Unknown state: $state_should" >&2
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
|
@ -17,13 +17,14 @@ packages.
|
||||||
REQUIRED PARAMETERS
|
REQUIRED PARAMETERS
|
||||||
-------------------
|
-------------------
|
||||||
state::
|
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
|
OPTIONAL PARAMETERS
|
||||||
-------------------
|
-------------------
|
||||||
name::
|
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
|
EXAMPLES
|
||||||
|
@ -31,13 +32,13 @@ EXAMPLES
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
# Ensure zsh in installed
|
# 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
|
# 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
|
# Remove obsolete package
|
||||||
__package_pacman puppet --state removed
|
__package_pacman puppet --state absent
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
@ -49,5 +50,5 @@ SEE ALSO
|
||||||
|
|
||||||
COPYING
|
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).
|
granted under the terms of the GNU General Public License version 3 (GPLv3).
|
||||||
|
|
|
@ -47,4 +47,8 @@ case "$state_should" in
|
||||||
absent)
|
absent)
|
||||||
echo $pip uninstall -q -y pyro
|
echo $pip uninstall -q -y pyro
|
||||||
;;
|
;;
|
||||||
|
*)
|
||||||
|
echo "Unknown state: $state_should" >&2
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
|
@ -23,10 +23,10 @@ state::
|
||||||
OPTIONAL PARAMETERS
|
OPTIONAL PARAMETERS
|
||||||
-------------------
|
-------------------
|
||||||
name::
|
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::
|
pip::
|
||||||
Instead of using pip from PATH, use the specific pip path.
|
Instead of using pip from PATH, use the specific pip path.
|
||||||
|
|
||||||
|
|
||||||
EXAMPLES
|
EXAMPLES
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
#
|
#
|
||||||
# 2011 Andi Brönnimann (andi-cdist at v-net.ch)
|
# 2011 Andi Brönnimann (andi-cdist at v-net.ch)
|
||||||
|
# 2012 Nico Schottelius (nico-cdist at schottelius.org)
|
||||||
#
|
#
|
||||||
# This file is part of cdist.
|
# This file is part of cdist.
|
||||||
#
|
#
|
||||||
|
@ -28,7 +29,6 @@
|
||||||
os_version="$(cat "$__global/explorer/os_version")"
|
os_version="$(cat "$__global/explorer/os_version")"
|
||||||
machine="$(cat "$__global/explorer/machine")"
|
machine="$(cat "$__global/explorer/machine")"
|
||||||
|
|
||||||
|
|
||||||
if [ -f "$__object/parameter/flavor" ]; then
|
if [ -f "$__object/parameter/flavor" ]; then
|
||||||
flavor="$(cat "$__object/parameter/flavor")"
|
flavor="$(cat "$__object/parameter/flavor")"
|
||||||
fi
|
fi
|
||||||
|
@ -42,44 +42,60 @@ else
|
||||||
name="$__object_id"
|
name="$__object_id"
|
||||||
fi
|
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: ${__object_name}: $state_should is deprecated and will be removed in cdist 2.1. Please change to present/absent." >&2
|
||||||
|
state_should="present"
|
||||||
|
;;
|
||||||
|
removed)
|
||||||
|
echo "WARNING: ${__object_name}: $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")"
|
pkg_version="$(cat "$__object/explorer/pkg_version")"
|
||||||
|
|
||||||
# TODO: Shouldn't be hardcoded
|
# TODO: Shouldn't be hardcoded
|
||||||
echo export PKG_PATH=ftp://ftp.openbsd.org/pub/OpenBSD/$os_version/packages/$machine/
|
echo export PKG_PATH=ftp://ftp.openbsd.org/pub/OpenBSD/$os_version/packages/$machine/
|
||||||
|
|
||||||
case "$state" in
|
if [ "$pkg_version" ]; then
|
||||||
installed)
|
state_is="present"
|
||||||
# Empty? Not installed.
|
else
|
||||||
if [ -z "$pkg_version" ]; then
|
state_is="absent"
|
||||||
# use this because pkg_add doesn't properly handle errors
|
fi
|
||||||
cat << eof
|
|
||||||
status=\$(pkg_add "$pkgopts" "$name--$flavor")
|
|
||||||
|
|
||||||
# no error
|
[ "$state_is" = "$state_should" ] && exit 0
|
||||||
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")
|
|
||||||
|
|
||||||
# no error
|
case "$state_should" in
|
||||||
if [ -n "\$status" ]; then
|
present)
|
||||||
echo "Error: \$status"
|
# use this because pkg_add doesn't properly handle errors
|
||||||
exit 1
|
cat << eof
|
||||||
fi
|
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
|
eof
|
||||||
fi
|
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Unknown state: $state" >&2
|
echo "Unknown state: $state_should" >&2
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
|
@ -16,16 +16,17 @@ This type is usually used on OpenBSD to manage packages.
|
||||||
REQUIRED PARAMETERS
|
REQUIRED PARAMETERS
|
||||||
-------------------
|
-------------------
|
||||||
state::
|
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
|
OPTIONAL PARAMETERS
|
||||||
-------------------
|
-------------------
|
||||||
name::
|
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::
|
flavor::
|
||||||
If supplied, use to avoid ambiguity.
|
If supplied, use to avoid ambiguity.
|
||||||
|
|
||||||
|
|
||||||
EXAMPLES
|
EXAMPLES
|
||||||
|
@ -33,16 +34,16 @@ EXAMPLES
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
# Ensure zsh is installed
|
# Ensure zsh is installed
|
||||||
__package_pkg_openbsd zsh --state installed
|
__package_pkg_openbsd zsh --state present
|
||||||
|
|
||||||
# Ensure vim is installed, use flavor no_x11
|
# 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
|
# 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
|
# Remove obsolete package
|
||||||
__package_pkg_openbsd puppet --state removed
|
__package_pkg_openbsd puppet --state absent
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -21,31 +21,42 @@
|
||||||
# Manage Rubygem packages
|
# Manage Rubygem packages
|
||||||
#
|
#
|
||||||
|
|
||||||
|
|
||||||
if [ -f "$__object/parameter/name" ]; then
|
if [ -f "$__object/parameter/name" ]; then
|
||||||
name="$(cat "$__object/parameter/name")"
|
name="$(cat "$__object/parameter/name")"
|
||||||
else
|
else
|
||||||
name="$__object_id"
|
name="$__object_id"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
state="$(cat "$__object/parameter/state")"
|
state_should="$(cat "$__object/parameter/state")"
|
||||||
is_installed="$(grep "true" "$__object/explorer/pkg_status" || true)"
|
# Correct pre 2.1 naming - FIXME in 2.1
|
||||||
|
case "$state_should" in
|
||||||
case "$state" in
|
installed)
|
||||||
installed)
|
echo "WARNING: ${__object_name}: $state_should is deprecated and will be removed in cdist 2.1. Please change to present/absent." >&2
|
||||||
# Install only if non-existent
|
state_should="present"
|
||||||
if [ -z "$is_installed" ]; then
|
;;
|
||||||
echo gem install \"$name\" --no-ri --no-rdoc
|
removed)
|
||||||
fi
|
echo "WARNING: ${__object_name}: $state_should is deprecated and will be removed in cdist 2.1. Please change to present/absent." >&2
|
||||||
;;
|
state_should="absent"
|
||||||
removed)
|
;;
|
||||||
# Remove only if existent
|
esac
|
||||||
if [ -n "$is_installed" ]; then
|
|
||||||
echo gem uninstall \"$name\"
|
if grep -q true "$__object/explorer/pkg_status"; then
|
||||||
fi
|
state_is="present"
|
||||||
;;
|
else
|
||||||
*)
|
state_is="absent"
|
||||||
echo "Unknown state: $state" >&2
|
fi
|
||||||
exit 1
|
|
||||||
;;
|
[ "$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
|
esac
|
||||||
|
|
|
@ -16,13 +16,14 @@ Rubygems is the default package management system for the Ruby programming langu
|
||||||
REQUIRED PARAMETERS
|
REQUIRED PARAMETERS
|
||||||
-------------------
|
-------------------
|
||||||
state::
|
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
|
OPTIONAL PARAMETERS
|
||||||
-------------------
|
-------------------
|
||||||
name::
|
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
|
EXAMPLES
|
||||||
|
@ -30,10 +31,10 @@ EXAMPLES
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
# Ensure sinatra is installed
|
# Ensure sinatra is installed
|
||||||
__package_rubygem sinatra --state installed
|
__package_rubygem sinatra --state present
|
||||||
|
|
||||||
# Remove package
|
# Remove package
|
||||||
__package_rubygem rails --state removed
|
__package_rubygem rails --state absent
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -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: ${__object_name}: $state_should is deprecated and will be removed in cdist 2.1. Please change to present/absent." >&2
|
||||||
|
state_should="present"
|
||||||
|
;;
|
||||||
|
removed)
|
||||||
|
echo "WARNING: ${__object_name}: $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
|
||||||
echo yum $opts install \"$name\"
|
state_is="present"
|
||||||
fi
|
fi
|
||||||
;;
|
|
||||||
removed)
|
[ "$state_is" = "$state_should" ] && exit 0
|
||||||
if ! grep -q "$not_installed" "$__object/explorer/pkg_version"; then
|
|
||||||
echo yum $opts remove \"$name\"
|
case "$state_should" in
|
||||||
fi
|
present)
|
||||||
;;
|
echo yum $opts install \"$name\"
|
||||||
*)
|
;;
|
||||||
echo "Unknown state: $state" >&2
|
absent)
|
||||||
exit 1
|
echo yum $opts remove \"$name\"
|
||||||
;;
|
;;
|
||||||
|
*)
|
||||||
|
echo "Unknown state: $state_should" >&2
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
|
@ -18,13 +18,14 @@ slightly confusing error message "Error: Nothing to do".
|
||||||
REQUIRED PARAMETERS
|
REQUIRED PARAMETERS
|
||||||
-------------------
|
-------------------
|
||||||
state::
|
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
|
OPTIONAL PARAMETERS
|
||||||
-------------------
|
-------------------
|
||||||
name::
|
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
|
EXAMPLES
|
||||||
|
@ -32,13 +33,13 @@ EXAMPLES
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
# Ensure zsh in installed
|
# 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
|
# 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
|
# Remove obsolete package
|
||||||
__package_yum puppet --state removed
|
__package_yum puppet --state absent
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/sh
|
#!/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.
|
# This file is part of cdist.
|
||||||
#
|
#
|
||||||
|
@ -25,33 +25,44 @@ else
|
||||||
name="$__object_id"
|
name="$__object_id"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
runs="$(cat "$__object/explorer/runs")"
|
|
||||||
state_should="$(cat "$__object/parameter/state")"
|
state_should="$(cat "$__object/parameter/state")"
|
||||||
|
case "$state_should" in
|
||||||
|
running)
|
||||||
|
echo "WARNING: ${__object_name}: $state_should is deprecated and will be removed in cdist 2.1. Please change to present/absent." >&2
|
||||||
|
state_should="present"
|
||||||
|
;;
|
||||||
|
stopped)
|
||||||
|
echo "WARNING: ${__object_name}: $state_should is deprecated and will be removed in cdist 2.1. Please change to present/absent." >&2
|
||||||
|
state_should="absent"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
runs="$(cat "$__object/explorer/runs")"
|
||||||
|
if [ "$runs" ]; then
|
||||||
|
state_is="present"
|
||||||
|
else
|
||||||
|
state_is="absent"
|
||||||
|
fi
|
||||||
|
|
||||||
|
[ "$state_is" = "$state_should" ] && exit 0
|
||||||
|
|
||||||
case "$state_should" in
|
case "$state_should" in
|
||||||
running|present)
|
present)
|
||||||
# Does not run, start it!
|
if [ -f "$__object/parameter/start" ]; then
|
||||||
if [ -z "$runs" ]; then
|
|
||||||
if [ -f "$__object/parameter/start" ]; then
|
|
||||||
cat "$__object/parameter/start"
|
cat "$__object/parameter/start"
|
||||||
else
|
else
|
||||||
echo "$name"
|
echo "$name"
|
||||||
fi
|
fi
|
||||||
fi
|
;;
|
||||||
;;
|
absent)
|
||||||
stopped|absent)
|
|
||||||
# Runs, kill it!
|
|
||||||
if [ "$runs" ]; then
|
|
||||||
if [ -f "$__object/parameter/stop" ]; then
|
if [ -f "$__object/parameter/stop" ]; then
|
||||||
cat "$__object/parameter/stop"
|
cat "$__object/parameter/stop"
|
||||||
else
|
else
|
||||||
echo kill "${runs}"
|
echo kill "${runs}"
|
||||||
fi
|
fi
|
||||||
fi
|
;;
|
||||||
;;
|
*)
|
||||||
*)
|
echo "Unknown state: $state_should" >&2
|
||||||
echo "Unknown state: $state_should" >&2
|
exit 1
|
||||||
exit 1
|
;;
|
||||||
;;
|
|
||||||
|
|
||||||
esac
|
esac
|
||||||
|
|
|
@ -16,7 +16,9 @@ This cdist type allows you to define the state of a process.
|
||||||
REQUIRED PARAMETERS
|
REQUIRED PARAMETERS
|
||||||
-------------------
|
-------------------
|
||||||
state::
|
state::
|
||||||
State of the process: Either stopped or running.
|
State of the process: Either present or absent
|
||||||
|
(old values "stopped" and "running" are deprecated and will be removed in
|
||||||
|
cdist 2.1).
|
||||||
|
|
||||||
|
|
||||||
OPTIONAL PARAMETERS
|
OPTIONAL PARAMETERS
|
||||||
|
@ -40,23 +42,23 @@ EXAMPLES
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
# Start if not running
|
# Start if not running
|
||||||
__process /usr/sbin/syslog-ng --state running
|
__process /usr/sbin/syslog-ng --state present
|
||||||
|
|
||||||
# Start if not running with a different binary
|
# Start if not running with a different binary
|
||||||
__process /usr/sbin/nginx --state running --start "/etc/rc.d/nginx start"
|
__process /usr/sbin/nginx --state present --start "/etc/rc.d/nginx start"
|
||||||
|
|
||||||
# Stop the process using kill (the type default) - DO NOT USE THIS
|
# Stop the process using kill (the type default) - DO NOT USE THIS
|
||||||
__process /usr/sbin/sshd --state stopped
|
__process /usr/sbin/sshd --state absent
|
||||||
|
|
||||||
# Stop the process using /etc/rc.d/sshd stop - THIS ONE NOT AS WELL
|
# Stop the process using /etc/rc.d/sshd stop - THIS ONE NOT AS WELL
|
||||||
__process /usr/sbin/sshd --state stopped --stop "/etc/rc.d/sshd stop"
|
__process /usr/sbin/sshd --state absent --stop "/etc/rc.d/sshd stop"
|
||||||
|
|
||||||
# Ensure cups is running, which runs with -C ...:
|
# Ensure cups is running, which runs with -C ...:
|
||||||
__process cups --start "/etc/rc.d/cups start" --state running \
|
__process cups --start "/etc/rc.d/cups start" --state present \
|
||||||
--name "/usr/sbin/cupsd -C /etc/cups/cupsd.conf"
|
--name "/usr/sbin/cupsd -C /etc/cups/cupsd.conf"
|
||||||
|
|
||||||
# Ensure rpc.statd is running (which usually runs with -L) using a regexp
|
# Ensure rpc.statd is running (which usually runs with -L) using a regexp
|
||||||
__process rpcstatd --state running --start "/etc/init.d/statd start" \
|
__process rpcstatd --state present --start "/etc/init.d/statd start" \
|
||||||
--name "rpc.statd.*"
|
--name "rpc.statd.*"
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -68,5 +70,5 @@ SEE ALSO
|
||||||
|
|
||||||
COPYING
|
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).
|
granted under the terms of the GNU General Public License version 3 (GPLv3).
|
||||||
|
|
|
@ -4,11 +4,17 @@ Changelog
|
||||||
* Changes are always commented with their author in (braces)
|
* Changes are always commented with their author in (braces)
|
||||||
* Exception: No braces means author == Nico Schottelius
|
* Exception: No braces means author == Nico Schottelius
|
||||||
|
|
||||||
2.0.8:
|
2.0.8: 2012-02-20
|
||||||
|
* Bugfix core: Remove another nasty traceback when sending SIGINT (aka Ctrl-C)
|
||||||
* Cleanup: Better hint to source of error
|
* Cleanup: Better hint to source of error
|
||||||
* Cleanup: Do not output failing script, but path to script only
|
* Cleanup: Do not output failing script, but path to script only
|
||||||
* Cleanup: Remove support for __debug variable in manifests (Type != Core
|
* Cleanup: Remove support for __debug variable in manifests (Type != Core
|
||||||
debugging)
|
debugging)
|
||||||
|
* Cleanup: Change __package_* to support absent/present (default state
|
||||||
|
name now). The values removed/installed will be removed in cdist 2.1.
|
||||||
|
* Cleanup: Change __process to support absent/present (default state
|
||||||
|
name now). The values running/stopped will be removed in cdist 2.1.
|
||||||
|
* Feature Core: Support boolean parameters (Steven Armstrong)
|
||||||
|
|
||||||
2.0.7: 2012-02-13
|
2.0.7: 2012-02-13
|
||||||
* Bugfix __file: Use chmod after chown/chgrp (Matt Coddington)
|
* Bugfix __file: Use chmod after chown/chgrp (Matt Coddington)
|
||||||
|
|
48
doc/dev/logs/2012-02-17.keyboardirq
Normal file
48
doc/dev/logs/2012-02-17.keyboardirq
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
Somewhere there is still a race condition:
|
||||||
|
|
||||||
|
INFO: monitoring03: Running manifest and explorers for __file/etc/yum.repos.d/epel.repo
|
||||||
|
^C^CTraceback (most recent call last):
|
||||||
|
File "./bin/cdist", line 204, in <module>
|
||||||
|
import logging
|
||||||
|
File "/usr/lib/python3.2/logging/__init__.py", line 27, in <module>
|
||||||
|
from string import Template
|
||||||
|
File "/usr/lib/python3.2/string.py", line 178, in <module>
|
||||||
|
class Formatter:
|
||||||
|
File "/usr/lib/python3.2/string.py", line 179, in Formatter
|
||||||
|
def format(self, format_string, *args, **kwargs):
|
||||||
|
KeyboardInterrupt
|
||||||
|
|
||||||
|
During handling of the above exception, another exception occurred:
|
||||||
|
|
||||||
|
Traceback (most recent call last):
|
||||||
|
File "./bin/cdist", line 232, in <module>
|
||||||
|
sys.exit(0)
|
||||||
|
NameError: name 'sys' is not defined
|
||||||
|
^C^CFatal Python error: Py_Initialize: can't initialize sys standard streams
|
||||||
|
Traceback (most recent call last):
|
||||||
|
File "/usr/lib/python3.2/encodings/latin_1.py", line 8, in <module>
|
||||||
|
"""
|
||||||
|
KeyboardInterrupt
|
||||||
|
^C% [12:19] brief:cdist%
|
||||||
|
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
[13:50] brief:cdist% ./bin/cdist config -vp monitoring02
|
||||||
|
INFO: monitoring02: Running global explorers
|
||||||
|
INFO: monitoring02: Running initial manifest /home/users/nico/privat/firmen/local.ch/vcs/cdist/conf/manifest
|
||||||
|
INFO: monitoring02: Running object manifests and type explorers
|
||||||
|
INFO: monitoring02: Running manifest and explorers for __localch_shinken/singleton
|
||||||
|
^CTraceback (most recent call last):
|
||||||
|
File "/usr/lib/python3.2/site.py", line 58, in <module>
|
||||||
|
import traceback
|
||||||
|
File "/usr/lib/python3.2/traceback.py", line 3, in <module>
|
||||||
|
import linecache
|
||||||
|
File "/usr/lib/python3.2/linecache.py", line 10, in <module>
|
||||||
|
import tokenize
|
||||||
|
File "/usr/lib/python3.2/tokenize.py", line 49, in <module>
|
||||||
|
class TokenInfo(collections.namedtuple('TokenInfo', 'type string start end line')):
|
||||||
|
File "/usr/lib/python3.2/collections.py", line 363, in namedtuple
|
||||||
|
exec(class_definition, namespace)
|
||||||
|
File "<string>", line 1, in <module>
|
||||||
|
KeyboardInterrupt
|
||||||
|
|
26
doc/dev/logs/2012-02-20.error-does-not-contain-host
Normal file
26
doc/dev/logs/2012-02-20.error-does-not-contain-host
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
- errors do not contain host
|
||||||
|
- it's not logged which hosts failed!
|
||||||
|
|
||||||
|
INFO: monitoring02: Running manifest and explorers for __directory/opt/local.ch/sys/shinken/host.d
|
||||||
|
INFO: monitoring03: Running manifest and explorers for __file/usr/sbin/iptables-rebuild
|
||||||
|
INFO: monitoring03: Running manifest and explorers for __git/opt/local.ch/sys/shinken/shinken
|
||||||
|
INFO: monitoring02: Running manifest and explorers for __file/etc/iptables.d/005_start
|
||||||
|
INFO: monitoring03: Running manifest and explorers for __localch_rsyncd/singleton
|
||||||
|
ERROR: Object __localch_iptables/xensnmp already exists with conflicting parameters:
|
||||||
|
/home/users/nico/privat/firmen/local.ch/vcs/cdist/conf/manifest/init: {'rule': '-A RH-Firewall-1-INPUT -p tcp --dport 161 -j ACCEPT'}
|
||||||
|
/home/users/nico/privat/firmen/local.ch/vcs/cdist/conf/type/__localch_rsyncd/manifest: {'rule': '-A RH-Firewall-1-INPUT -p tcp --dport 873 -j ACCEPT'}
|
||||||
|
ERROR: Command failed: /bin/sh -e /home/users/nico/privat/firmen/local.ch/vcs/cdist/conf/type/__localch_rsyncd/manifest
|
||||||
|
INFO: monitoring02: Running manifest and explorers for __file/etc/iptables.d/500_xensnmp
|
||||||
|
INFO: monitoring02: Running manifest and explorers for __file/etc/iptables.d/995_end
|
||||||
|
INFO: monitoring02: Running manifest and explorers for __file/etc/rsyncd.conf
|
||||||
|
INFO: monitoring02: Running manifest and explorers for __file/etc/yum.repos.d/epel.repo
|
||||||
|
INFO: monitoring02: Running manifest and explorers for __file/etc/yum.repos.d/rpmforge.repo
|
||||||
|
INFO: monitoring02: Running manifest and explorers for __file/usr/sbin/iptables-rebuild
|
||||||
|
INFO: monitoring02: Running manifest and explorers for __git/opt/local.ch/sys/shinken/shinken
|
||||||
|
INFO: monitoring02: Running manifest and explorers for __localch_rsyncd/singleton
|
||||||
|
ERROR: Object __localch_iptables/xensnmp already exists with conflicting parameters:
|
||||||
|
/home/users/nico/privat/firmen/local.ch/vcs/cdist/conf/manifest/init: {'rule': '-A RH-Firewall-1-INPUT -p tcp --dport 161 -j ACCEPT'}
|
||||||
|
/home/users/nico/privat/firmen/local.ch/vcs/cdist/conf/type/__localch_rsyncd/manifest: {'rule': '-A RH-Firewall-1-INPUT -p tcp --dport 873 -j ACCEPT'}
|
||||||
|
ERROR: Command failed: /bin/sh -e /home/users/nico/privat/firmen/local.ch/vcs/cdist/conf/type/__localch_rsyncd/manifest
|
||||||
|
INFO: Total processing time for 2 host(s): 14.245397090911865
|
||||||
|
[16:53] brief:cdist%
|
|
@ -37,3 +37,4 @@ TYPES
|
||||||
- Add testing framework (proposed by Evax Software)
|
- Add testing framework (proposed by Evax Software)
|
||||||
- __user
|
- __user
|
||||||
add option to include --create-home
|
add option to include --create-home
|
||||||
|
- Merge __addifnosuchline and __removeline into __line + --state present|absent
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
- introduce default parameters
|
- introduce default parameters
|
||||||
|
- valid for optional parameters only
|
||||||
|
- stored in parameter/default/$name
|
||||||
|
|
||||||
|
- when/where to save? in emulator?
|
||||||
|
- read vi fsproperty?
|
||||||
|
|
||||||
- cleanup object_id handling
|
- cleanup object_id handling
|
||||||
- have a look at singletons
|
- have a look at singletons
|
||||||
|
|
||||||
- ensure that all types, which support --state support
|
|
||||||
present and absent (consistent look and feel)
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
- update/create docs
|
- update/create docs
|
||||||
- cdist-cache::
|
- cdist-cache::
|
||||||
How to get use information about the hosts we have been working on [advanced]
|
How to get use information about the hosts we have been working on [advanced]
|
||||||
|
|
|
@ -101,12 +101,15 @@ conf/type/<name>/gencode-local::
|
||||||
conf/type/<name>/gencode-remote::
|
conf/type/<name>/gencode-remote::
|
||||||
Used to generate code to be executed on the client.
|
Used to generate code to be executed on the client.
|
||||||
|
|
||||||
conf/type/<name>/parameters/required::
|
conf/type/<name>/parameter/required::
|
||||||
Parameters required by type, \n seperated list.
|
Parameters required by type, \n seperated list.
|
||||||
|
|
||||||
conf/type/<name>/parameters/optional::
|
conf/type/<name>/parameter/optional::
|
||||||
Parameters optionally accepted by type, \n seperated list.
|
Parameters optionally accepted by type, \n seperated list.
|
||||||
|
|
||||||
|
conf/type/<name>/parameter/boolean::
|
||||||
|
Boolean parameters accepted by type, \n seperated list.
|
||||||
|
|
||||||
conf/type/<name>/explorer::
|
conf/type/<name>/explorer::
|
||||||
Location of the type specific explorers.
|
Location of the type specific explorers.
|
||||||
This directory is referenced by the variable __type_explorer (see below).
|
This directory is referenced by the variable __type_explorer (see below).
|
||||||
|
|
|
@ -72,15 +72,42 @@ To begin a new type, just create the directory **conf/type/__NAME**.
|
||||||
|
|
||||||
DEFINING PARAMETERS
|
DEFINING PARAMETERS
|
||||||
-------------------
|
-------------------
|
||||||
Every type consists of optional and required parameters, which must
|
Every type consists of required, optional and boolean parameters, which must
|
||||||
be created in a newline seperated file in ***parameters/required*** and
|
be created in a newline seperated file in ***parameter/required***,
|
||||||
***parameters/optional***. If either or both missing, the type will have
|
***parameter/optional*** and ***parameter/boolean***. If either is missing,
|
||||||
no required, no optional or no parameters at all.
|
the type will have no required, no optional, no boolean or no parameters at
|
||||||
|
all.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
echo servername >> conf/type/__nginx_vhost/parameter/required
|
echo servername >> conf/type/__nginx_vhost/parameter/required
|
||||||
echo logdirectory >> conf/type/__nginx_vhost/parameter/optional
|
echo logdirectory >> conf/type/__nginx_vhost/parameter/optional
|
||||||
|
echo use_ssl >> conf/type/__nginx_vhost/parameter/boolean
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
USING PARAMETERS
|
||||||
|
----------------
|
||||||
|
The parameters given to a type can be accessed and used in all type scripts
|
||||||
|
(e.g manifest, gencode-*, explorer/*). Note that boolean parameters are
|
||||||
|
represented by file existence. File exists -> True,
|
||||||
|
file does not exist -> False
|
||||||
|
|
||||||
|
Example: (e.g. in conf/type/__nginx_vhost/manifest)
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
# required parameter
|
||||||
|
servername="$(cat "$__object/parameter/servername")"
|
||||||
|
|
||||||
|
# optional parameter
|
||||||
|
if [ -f "$__object/parameter/logdirectory" ]; then
|
||||||
|
logdirectory="$(cat "$__object/parameter/logdirectory")"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# boolean parameter
|
||||||
|
if [ -f "$__object/parameter/use_ssl" ]; then
|
||||||
|
# file exists -> True
|
||||||
|
# do some fancy ssl stuff
|
||||||
|
fi
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
|
|
||||||
VERSION = "2.0.7"
|
VERSION = "2.0.8"
|
||||||
|
|
||||||
BANNER = """
|
BANNER = """
|
||||||
.. . .x+=:. s
|
.. . .x+=:. s
|
||||||
|
|
|
@ -82,6 +82,7 @@ class CdistType(object):
|
||||||
self.__explorers = None
|
self.__explorers = None
|
||||||
self.__required_parameters = None
|
self.__required_parameters = None
|
||||||
self.__optional_parameters = None
|
self.__optional_parameters = None
|
||||||
|
self.__boolean_parameters = None
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return '<CdistType %s>' % self.name
|
return '<CdistType %s>' % self.name
|
||||||
|
@ -144,3 +145,19 @@ class CdistType(object):
|
||||||
finally:
|
finally:
|
||||||
self.__optional_parameters = parameters
|
self.__optional_parameters = parameters
|
||||||
return self.__optional_parameters
|
return self.__optional_parameters
|
||||||
|
|
||||||
|
@property
|
||||||
|
def boolean_parameters(self):
|
||||||
|
"""Return a list of boolean parameters"""
|
||||||
|
if not self.__boolean_parameters:
|
||||||
|
parameters = []
|
||||||
|
try:
|
||||||
|
with open(os.path.join(self.absolute_path, "parameter", "boolean")) as fd:
|
||||||
|
for line in fd:
|
||||||
|
parameters.append(line.strip())
|
||||||
|
except EnvironmentError:
|
||||||
|
# error ignored
|
||||||
|
pass
|
||||||
|
finally:
|
||||||
|
self.__boolean_parameters = parameters
|
||||||
|
return self.__boolean_parameters
|
||||||
|
|
|
@ -87,7 +87,7 @@ class Emulator(object):
|
||||||
def commandline(self):
|
def commandline(self):
|
||||||
"""Parse command line"""
|
"""Parse command line"""
|
||||||
|
|
||||||
parser = argparse.ArgumentParser(add_help=False)
|
parser = argparse.ArgumentParser(add_help=False, argument_default=argparse.SUPPRESS)
|
||||||
|
|
||||||
for parameter in self.cdist_type.optional_parameters:
|
for parameter in self.cdist_type.optional_parameters:
|
||||||
argument = "--" + parameter
|
argument = "--" + parameter
|
||||||
|
@ -95,6 +95,9 @@ class Emulator(object):
|
||||||
for parameter in self.cdist_type.required_parameters:
|
for parameter in self.cdist_type.required_parameters:
|
||||||
argument = "--" + parameter
|
argument = "--" + parameter
|
||||||
parser.add_argument(argument, dest=parameter, action='store', required=True)
|
parser.add_argument(argument, dest=parameter, action='store', required=True)
|
||||||
|
for parameter in self.cdist_type.boolean_parameters:
|
||||||
|
argument = "--" + parameter
|
||||||
|
parser.add_argument(argument, dest=parameter, action='store_const', const='')
|
||||||
|
|
||||||
# If not singleton support one positional parameter
|
# If not singleton support one positional parameter
|
||||||
if not self.cdist_type.is_singleton:
|
if not self.cdist_type.is_singleton:
|
||||||
|
|
|
@ -126,7 +126,7 @@ class AutoRequireEmulatorTestCase(test.CdistTestCase):
|
||||||
self.assertEqual(sorted(cdist_object.requirements), sorted(expected))
|
self.assertEqual(sorted(cdist_object.requirements), sorted(expected))
|
||||||
|
|
||||||
|
|
||||||
class ArgumentsWithDashesTestCase(test.CdistTestCase):
|
class ArgumentsTestCase(test.CdistTestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.temp_dir = self.mkdtemp()
|
self.temp_dir = self.mkdtemp()
|
||||||
|
@ -159,3 +159,59 @@ class ArgumentsWithDashesTestCase(test.CdistTestCase):
|
||||||
cdist_type = core.CdistType(self.local.type_path, '__arguments_with_dashes')
|
cdist_type = core.CdistType(self.local.type_path, '__arguments_with_dashes')
|
||||||
cdist_object = core.CdistObject(cdist_type, self.local.object_path, 'some-id')
|
cdist_object = core.CdistObject(cdist_type, self.local.object_path, 'some-id')
|
||||||
self.assertTrue('with-dash' in cdist_object.parameters)
|
self.assertTrue('with-dash' in cdist_object.parameters)
|
||||||
|
|
||||||
|
def test_boolean(self):
|
||||||
|
type_name = '__arguments_boolean'
|
||||||
|
object_id = 'some-id'
|
||||||
|
argv = [type_name, object_id, '--boolean1']
|
||||||
|
os.environ.update(self.env)
|
||||||
|
emu = emulator.Emulator(argv)
|
||||||
|
emu.run()
|
||||||
|
|
||||||
|
cdist_type = core.CdistType(self.local.type_path, type_name)
|
||||||
|
cdist_object = core.CdistObject(cdist_type, self.local.object_path, object_id)
|
||||||
|
self.assertTrue('boolean1' in cdist_object.parameters)
|
||||||
|
self.assertFalse('boolean2' in cdist_object.parameters)
|
||||||
|
# empty file -> True
|
||||||
|
self.assertTrue(cdist_object.parameters['boolean1'] == '')
|
||||||
|
|
||||||
|
def test_required(self):
|
||||||
|
type_name = '__arguments_required'
|
||||||
|
object_id = 'some-id'
|
||||||
|
value = 'some value'
|
||||||
|
argv = [type_name, object_id, '--required1', value, '--required2', value]
|
||||||
|
os.environ.update(self.env)
|
||||||
|
emu = emulator.Emulator(argv)
|
||||||
|
emu.run()
|
||||||
|
|
||||||
|
cdist_type = core.CdistType(self.local.type_path, type_name)
|
||||||
|
cdist_object = core.CdistObject(cdist_type, self.local.object_path, object_id)
|
||||||
|
self.assertTrue('required1' in cdist_object.parameters)
|
||||||
|
self.assertTrue('required2' in cdist_object.parameters)
|
||||||
|
self.assertEqual(cdist_object.parameters['required1'], value)
|
||||||
|
self.assertEqual(cdist_object.parameters['required2'], value)
|
||||||
|
|
||||||
|
# def test_required_missing(self):
|
||||||
|
# type_name = '__arguments_required'
|
||||||
|
# object_id = 'some-id'
|
||||||
|
# value = 'some value'
|
||||||
|
# argv = [type_name, object_id, '--required1', value]
|
||||||
|
# os.environ.update(self.env)
|
||||||
|
# emu = emulator.Emulator(argv)
|
||||||
|
#
|
||||||
|
# self.assertRaises(SystemExit, emu.run)
|
||||||
|
|
||||||
|
def test_optional(self):
|
||||||
|
type_name = '__arguments_optional'
|
||||||
|
object_id = 'some-id'
|
||||||
|
value = 'some value'
|
||||||
|
argv = [type_name, object_id, '--optional1', value]
|
||||||
|
os.environ.update(self.env)
|
||||||
|
emu = emulator.Emulator(argv)
|
||||||
|
emu.run()
|
||||||
|
|
||||||
|
cdist_type = core.CdistType(self.local.type_path, type_name)
|
||||||
|
cdist_object = core.CdistObject(cdist_type, self.local.object_path, object_id)
|
||||||
|
self.assertTrue('optional1' in cdist_object.parameters)
|
||||||
|
self.assertFalse('optional2' in cdist_object.parameters)
|
||||||
|
self.assertEqual(cdist_object.parameters['optional1'], value)
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
boolean1
|
||||||
|
boolean2
|
|
@ -0,0 +1 @@
|
||||||
|
optional1
|
|
@ -0,0 +1,2 @@
|
||||||
|
required1
|
||||||
|
required2
|
|
@ -145,3 +145,14 @@ class TypeTestCase(test.CdistTestCase):
|
||||||
base_path = fixtures
|
base_path = fixtures
|
||||||
cdist_type = core.CdistType(base_path, '__without_optional_parameters')
|
cdist_type = core.CdistType(base_path, '__without_optional_parameters')
|
||||||
self.assertEqual(cdist_type.optional_parameters, [])
|
self.assertEqual(cdist_type.optional_parameters, [])
|
||||||
|
|
||||||
|
def test_with_boolean_parameters(self):
|
||||||
|
base_path = fixtures
|
||||||
|
cdist_type = core.CdistType(base_path, '__with_boolean_parameters')
|
||||||
|
self.assertEqual(cdist_type.boolean_parameters, ['boolean1', 'boolean2'])
|
||||||
|
|
||||||
|
def test_without_boolean_parameters(self):
|
||||||
|
base_path = fixtures
|
||||||
|
cdist_type = core.CdistType(base_path, '__without_boolean_parameters')
|
||||||
|
self.assertEqual(cdist_type.boolean_parameters, [])
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
boolean1
|
||||||
|
boolean2
|
|
@ -0,0 +1,6 @@
|
||||||
|
This type is not much of use, as any type can issue code to be executed.
|
||||||
|
Thus you can implement the code directly in the calling type.
|
||||||
|
Or if you need to reuse it, create a type on its own.
|
||||||
|
|
||||||
|
Because this seems to be a common misunderstanding when people come from "non managed areas",
|
||||||
|
where script iexecution is the main focus, I documented this in cdist-hacker to clearify.
|
26
other/types_submitted_for_inclusion/__run_command/gencode-remote
Executable file
26
other/types_submitted_for_inclusion/__run_command/gencode-remote
Executable file
|
@ -0,0 +1,26 @@
|
||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# 2012 Benedikt Koeppel (code at benediktkoeppel.ch)
|
||||||
|
#
|
||||||
|
# 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 [ -f "$__object/parameter/command" ]; then
|
||||||
|
cat "$__object/parameter/command"
|
||||||
|
else
|
||||||
|
echo "$name"
|
||||||
|
fi
|
70
other/types_submitted_for_inclusion/__run_command/man.text
Normal file
70
other/types_submitted_for_inclusion/__run_command/man.text
Normal file
|
@ -0,0 +1,70 @@
|
||||||
|
cdist-type__run_command(7)
|
||||||
|
==========================
|
||||||
|
Benedikt Koeppel <code--@--benediktkoeppel.ch>
|
||||||
|
|
||||||
|
|
||||||
|
NAME
|
||||||
|
----
|
||||||
|
cdist-type__run_command - Run a command
|
||||||
|
|
||||||
|
|
||||||
|
DESCRIPTION
|
||||||
|
-----------
|
||||||
|
This cdist type allows you to run a specific command once at installation time.
|
||||||
|
|
||||||
|
|
||||||
|
REQUIRED PARAMETERS
|
||||||
|
-------------------
|
||||||
|
|
||||||
|
|
||||||
|
OPTIONAL PARAMETERS
|
||||||
|
-------------------
|
||||||
|
command::
|
||||||
|
Command (with arguments) to run.
|
||||||
|
|
||||||
|
If no command is give, then the object_id is executed.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
EXAMPLES
|
||||||
|
--------
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
# Run a command
|
||||||
|
__run_command "/etc/init.d/mysql restart"
|
||||||
|
# runs `/etc/init.d/mysql restart` (the "object_id")
|
||||||
|
|
||||||
|
# Run the same command:
|
||||||
|
__run_command restart-mysql --command "/etc/init.d/mysql restart"
|
||||||
|
# runs `/etc/init.d/mysql restart` (the --command argument)
|
||||||
|
# additionally, it can easily be referenced (for example in a require="..."
|
||||||
|
#as __run_command/restart-mysql
|
||||||
|
|
||||||
|
# Run a script:
|
||||||
|
__run_command install-pear --command "$(cat <<-EOF
|
||||||
|
/usr/bin/pear install --force Auth
|
||||||
|
/usr/bin/pear install --force HTML_Template_IT-1.2.1
|
||||||
|
/usr/bin/pear install --force MDB2
|
||||||
|
/usr/bin/pear install --force MDB2#mysql
|
||||||
|
/usr/bin/pear config-set preferred_state beta;
|
||||||
|
/usr/bin/pear install --force --alldeps Spreadsheet_Excel_Writer;
|
||||||
|
/usr/bin/pear config-set preferred_state stable
|
||||||
|
/usr/bin/pear install --force HTTP_Request
|
||||||
|
/usr/bin/pear install --force Mail
|
||||||
|
/usr/bin/pear install --force Auth_HTTP
|
||||||
|
/usr/bin/pear install --force XML_RPC
|
||||||
|
EOF
|
||||||
|
)"
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
SEE ALSO
|
||||||
|
--------
|
||||||
|
- cdist-type(7)
|
||||||
|
|
||||||
|
|
||||||
|
COPYING
|
||||||
|
-------
|
||||||
|
Copyright \(C) 2012 Benedikt Koeppel. Free use of this software is
|
||||||
|
granted under the terms of the GNU General Public License version 3 (GPLv3).
|
|
@ -0,0 +1 @@
|
||||||
|
command
|
Loading…
Reference in a new issue