diff --git a/bin/cdist b/bin/cdist
index 5a6ce92f..dfe4fa00 100755
--- a/bin/cdist
+++ b/bin/cdist
@@ -26,4 +26,8 @@ dir=${0%/*}
# Ensure version is present - the bundled/shipped version contains a static version,
# the git version contains a dynamic version
"$dir/../build" version
-PYTHONPATH="${dir}/../" "$dir/../scripts/cdist" "$@"
+
+libdir=$(cd "${dir}/../" && pwd -P)
+export PYTHONPATH="${libdir}"
+
+"$dir/../scripts/cdist" "$@"
diff --git a/build b/build
index 9d7284d7..baad93be 100755
--- a/build
+++ b/build
@@ -35,6 +35,7 @@ A2XH="a2x -f xhtml --no-xmllint -a encoding=UTF-8"
# Developer webbase
WEBDIR=$HOME/niconetz
+WEBBLOG=$WEBDIR/blog
WEBBASE=$WEBDIR/software/cdist
WEBMAN=$WEBBASE/man/$version
WEBPAGE=${WEBBASE}.mdwn
@@ -108,7 +109,14 @@ case "$1" in
$0 pub
- $0 dist-post
+ $0 dist-blog
+ $0 dist-freecode
+ $0 dist-ml
+ $0 dist-manual
+ ;;
+
+ changelog-changes)
+ awk -F: 'BEGIN { start=0 } { if ($0 ~ /^[[:digit:]]/) { if(start == 0) {start = 1 } else { exit } } else { if(start==1) {print $0 }} }' "$basedir/docs/changelog"
;;
changelog-version)
@@ -142,15 +150,78 @@ case "$1" in
;;
- dist-post)
+ blog)
+ version=$($0 changelog-version)
+ blogfile=$WEBBLOG/cdist-${version}-released.mdwn
+ cat << eof > "$blogfile"
+[[!meta title="Cdist $version released"]]
+
+Here's a short overview about the changes found in this release:
+
+eof
+
+ $0 changelog-changes >> "$blogfile"
+
+ cat << eof >> "$blogfile"
+For more information visit the [[cdist homepage|software/cdist]].
+
+[[!tag cdist config unix]]
+eof
+ ;;
+
+ dist-blog)
+ $0 blog
+ version=$($0 changelog-version)
+ file=cdist-${version}-released.mdwn
+ cd "$WEBBLOG"
+ git add "$file"
+ git commit -m "New cdist version (blogentry): $version" "$file"
+ git push
+ ;;
+
+ dist-ml)
+ $0 blog
+ version=$($0 changelog-version)
+ to_a=cdist
+ to_d=l.schottelius.org
+ to=${to_a}@${to_d}
+
+ from_a=nico-cdist
+ from_d=schottelius.org
+ from=${from_a}@${from_d}
+
+ (
+ cat << eof
+From: Nico -telmich- Schottelius <$from>
+To: cdist mailing list <$to>
+Subject: cdist $version released
+
+Hello .*,
+
+cdist $version has been released with the following changes:
+
+eof
+
+ "$0" changelog-changes
+ cat << eof
+
+Cheers,
+
+Nico
+
+--
+Automatisation at its best level. With cdist.
+eof
+ ) | /usr/sbin/sendmail -f "$from" "$to"
+ ;;
+
+
+ dist-manual)
cat << notes
To be done manually...
- - freecode release
- - blog entry
- linkedin entry
- - mailinglist update
notes
;;
@@ -214,13 +285,13 @@ eof
printf "Press enter to submit to freecode> "
read dummy
- cat << eof | cfreecode-api release cdist
+ cat << eof | cfreecode-api release-add cdist
{
"auth_code": "$api_token",
"release": {
- "tag_list": "REPLACEME",
+ "tag_list": "$taglist",
"version": "$version",
- "changelog": "REPLACEMETOO",
+ "changelog": "$changelog",
"hidden_from_frontpage": false
}
}
@@ -302,6 +373,7 @@ eof
test)
shift # skip t
+ export PYTHONPATH="$(pwd -P)"
if [ $# -lt 1 ]; then
python3 -m cdist.test
diff --git a/cdist/conf/type/__apt_ppa/manifest b/cdist/conf/type/__apt_ppa/manifest
index 04c66ce0..e7ad0c26 100755
--- a/cdist/conf/type/__apt_ppa/manifest
+++ b/cdist/conf/type/__apt_ppa/manifest
@@ -20,7 +20,7 @@
name="$__object_id"
-__package python-software-properties --state installed
+__package python-software-properties --state present
require="__package/python-software-properties" \
__file /usr/local/bin/remove-apt-repository \
diff --git a/cdist/conf/type/__apt_update_index/gencode-remote b/cdist/conf/type/__apt_update_index/gencode-remote
index e66ff7a3..61ce11a9 100755
--- a/cdist/conf/type/__apt_update_index/gencode-remote
+++ b/cdist/conf/type/__apt_update_index/gencode-remote
@@ -20,7 +20,7 @@
# run 'apt-get update' if anything in /etc/apt is newer then /var/lib/apt/lists
cat << DONE
-if find /etc/apt -cnewer /var/lib/apt/lists | grep . > /dev/null; then
+if find /etc/apt -mindepth 1 -cnewer /var/lib/apt/lists | grep . > /dev/null; then
apt-get update || apt-get update
fi
DONE
diff --git a/cdist/conf/type/__autofs_map/manifest b/cdist/conf/type/__autofs_map/manifest
deleted file mode 100755
index d86ea799..00000000
--- a/cdist/conf/type/__autofs_map/manifest
+++ /dev/null
@@ -1,42 +0,0 @@
-#!/bin/sh
-#
-# 2011 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 .
-#
-
-name="/$__object_id"
-map="$(cat "$__object/parameter/map")"
-
-if [ -f "$__object/parameter/type" ]; then
- type="$(cat "$__object/parameter/type")"
-else
- type="file"
- echo "$type" > "$__object/parameter/type"
-fi
-
-# Generate entry for use in auto.master
-entry="${name} ${type}:${map}"
-if [ -f "$__object/parameter/options" ]; then
- entry="$entry $(cat "$__object/parameter/options")"
-fi
-if [ -f "$__object/parameter/comment" ]; then
- echo "# $(cat "$__object/parameter/comment")" > "$__object/parameter/entry"
-fi
-echo "$entry" >> "$__object/parameter/entry"
-
-require="$__object_name" __autofs_master
-
diff --git a/cdist/conf/type/__autofs_master/files/auto.master.header b/cdist/conf/type/__autofs_master/files/auto.master.header
deleted file mode 100644
index 53590257..00000000
--- a/cdist/conf/type/__autofs_master/files/auto.master.header
+++ /dev/null
@@ -1,3 +0,0 @@
-# Generated from cdist __autofs_master
-# Do not change this file. Changes will be overwritten.
-
diff --git a/cdist/conf/type/__autofs_master/parameter/optional b/cdist/conf/type/__autofs_master/parameter/optional
deleted file mode 100644
index 8e83f898..00000000
--- a/cdist/conf/type/__autofs_master/parameter/optional
+++ /dev/null
@@ -1 +0,0 @@
-header
diff --git a/cdist/conf/type/__file/explorer/cksum b/cdist/conf/type/__file/explorer/cksum
index dcad99ba..335e4e7a 100755
--- a/cdist/conf/type/__file/explorer/cksum
+++ b/cdist/conf/type/__file/explorer/cksum
@@ -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.
#
@@ -24,11 +24,11 @@
destination="/$__object_id"
if [ -e "$destination" ]; then
- if [ -f "$destination" ]; then
- cksum < "$destination"
- else
- echo "NO REGULAR FILE"
- fi
+ if [ -f "$destination" ]; then
+ cksum < "$destination"
+ else
+ echo "NO REGULAR FILE"
+ fi
else
- echo "NO FILE FOUND, NO CHECKSUM CALCULATED."
+ echo "NO FILE FOUND, NO CHECKSUM CALCULATED."
fi
diff --git a/cdist/conf/type/__file/explorer/exists b/cdist/conf/type/__file/explorer/exists
index f8b85671..c319cb5d 100755
--- a/cdist/conf/type/__file/explorer/exists
+++ b/cdist/conf/type/__file/explorer/exists
@@ -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.
#
@@ -24,7 +24,7 @@
destination="/$__object_id"
if [ -e "$destination" ]; then
- echo yes
+ echo yes
else
- echo no
+ echo no
fi
diff --git a/cdist/conf/type/__file/gencode-local b/cdist/conf/type/__file/gencode-local
index b74893fb..087011c4 100755
--- a/cdist/conf/type/__file/gencode-local
+++ b/cdist/conf/type/__file/gencode-local
@@ -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.
#
@@ -22,12 +22,13 @@
#
destination="/$__object_id"
-state_should="$(cat "$__object/parameter/state")"
+state_should=present
+[ -f "$__object/parameter/state" ] && state_should="$(cat "$__object/parameter/state")"
exists="$(cat "$__object/explorer/exists")"
[ "$state_should" = "exists" -a "$exists" = "yes" ] && exit 0 # nothing to do
-if [ "$state_should" = "present" ]; then
+if [ "$state_should" = "present" -o "$state_should" = "exists" ]; then
if [ -f "$__object/parameter/source" ]; then
source="$(cat "$__object/parameter/source")"
if [ "$source" = "-" ]; then
diff --git a/cdist/conf/type/__file/gencode-remote b/cdist/conf/type/__file/gencode-remote
index 2b4c7e45..8b03e919 100755
--- a/cdist/conf/type/__file/gencode-remote
+++ b/cdist/conf/type/__file/gencode-remote
@@ -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.
#
@@ -22,11 +22,12 @@
#
destination="/$__object_id"
-state_should="$(cat "$__object/parameter/state")"
+state_should=present
+[ -f "$__object/parameter/state" ] && state_should="$(cat "$__object/parameter/state")"
exists="$(cat "$__object/explorer/exists")"
case "$state_should" in
- present)
+ present|exists)
# No source? Create empty file
if [ ! -f "$__object/parameter/source" ]; then
if [ "$exists" = "no" ]; then
diff --git a/cdist/conf/type/__issue/manifest b/cdist/conf/type/__issue/manifest
index eff6b808..d2720f2d 100755
--- a/cdist/conf/type/__issue/manifest
+++ b/cdist/conf/type/__issue/manifest
@@ -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.
#
@@ -24,17 +24,16 @@ destination=/etc/issue
os="$(cat "$__global/explorer/os")"
if [ -f "$__object/parameter/source" ]; then
- source="$(cat "$__object/parameter/source")"
- echo using $source
+ source="$(cat "$__object/parameter/source")"
else
- case "$os" in
- archlinux|redhat)
- source="$__type/files/$os"
- ;;
- *)
- source="$__type/files/default"
- ;;
- esac
+ case "$os" in
+ archlinux|redhat)
+ source="$__type/files/$os"
+ ;;
+ *)
+ source="$__type/files/default"
+ ;;
+ esac
fi
__file "$destination" --source "$source"
diff --git a/cdist/conf/type/__key_value/gencode-remote b/cdist/conf/type/__key_value/gencode-remote
index b3ffeb46..5fa24d5b 100755
--- a/cdist/conf/type/__key_value/gencode-remote
+++ b/cdist/conf/type/__key_value/gencode-remote
@@ -1,6 +1,7 @@
#!/bin/sh
#
# 2011 Steven Armstrong (steven-cdist at armstrong.cc)
+# 2012 Nico Schottelius (nico-cdist at schottelius.org)
#
# This file is part of cdist.
#
@@ -18,42 +19,42 @@
# along with cdist. If not, see .
#
-key="$(cat "$__object/parameter/key")"
+key="$__object_id"
+[ -f "$__object/parameter/key" ] && key="$(cat "$__object/parameter/key")"
+state_should=present
+[ -f "$__object/parameter/state" ] && state_should="$(cat "$__object/parameter/state")"
+
file="$(cat "$__object/parameter/file")"
delimiter="$(cat "$__object/parameter/delimiter")"
value="$(cat "$__object/parameter/value")"
state_is="$(cat "$__object/explorer/state")"
-state_should="$(cat "$__object/parameter/state")"
-if [ "$state_is" = "$state_should" ]; then
- # nothing to do
- exit 0
-fi
+[ "$state_is" = "$state_should" ] && exit 0
case "$state_should" in
- absent)
- # remove lines starting with key
- echo "sed '/^$key\($delimiter\+\)/d' \"$file\" > \"$file.cdist-tmp\""
- echo "mv \"$file.cdist-tmp\" \"$file\""
- ;;
- present)
- case "$state_is" in
- absent)
- # add new key and value
- echo "echo \"${key}${delimiter}${value}\" >> \"$file\""
- ;;
- wrongvalue)
- # change exisiting value
- echo "sed \"s|^$key\($delimiter\+\).*|$key\1$value|\" \"$file\" > \"$file.cdist-tmp\""
- echo "mv \"$file.cdist-tmp\" \"$file\""
- ;;
- *)
- echo "Unknown explorer state: $state_is" >&2
- exit 1
- esac
- ;;
- *)
- echo "Unknown state: $state_should" >&2
- exit 1
+ absent)
+ # remove lines starting with key
+ echo "sed '/^$key\($delimiter\+\)/d' \"$file\" > \"$file.cdist-tmp\""
+ echo "mv \"$file.cdist-tmp\" \"$file\""
+ ;;
+ present)
+ case "$state_is" in
+ absent)
+ # add new key and value
+ echo "echo \"${key}${delimiter}${value}\" >> \"$file\""
+ ;;
+ wrongvalue)
+ # change exisiting value
+ echo "sed \"s|^$key\($delimiter\+\).*|$key\1$value|\" \"$file\" > \"$file.cdist-tmp\""
+ echo "mv \"$file.cdist-tmp\" \"$file\""
+ ;;
+ *)
+ echo "Unknown explorer state: $state_is" >&2
+ exit 1
+ esac
+ ;;
+ *)
+ echo "Unknown state: $state_should" >&2
+ exit 1
esac
diff --git a/cdist/conf/type/__key_value/manifest b/cdist/conf/type/__key_value/manifest
index 2e75e175..8ed9cc9c 100755
--- a/cdist/conf/type/__key_value/manifest
+++ b/cdist/conf/type/__key_value/manifest
@@ -1,6 +1,7 @@
#!/bin/sh
#
# 2011 Steven Armstrong (steven-cdist at armstrong.cc)
+# 2012 Nico Schottelius (nico-cdist at schottelius.org)
#
# This file is part of cdist.
#
@@ -18,13 +19,10 @@
# along with cdist. If not, see .
#
-# set defaults
-key="$(cat "$__object/parameter/key" 2>/dev/null \
- || echo "$__object_id" | tee "$__object/parameter/key")"
-state="$(cat "$__object/parameter/state" 2>/dev/null \
- || echo "present" | tee "$__object/parameter/state")"
+state_should=present
+[ -f "$__object/parameter/state" ] && state_should="$(cat "$__object/parameter/state")"
-if [ "$state" = "present" -a ! -f "$__object/parameter/value" ]; then
+if [ "$state_should" = "present" -a ! -f "$__object/parameter/value" ]; then
echo "Missing required parameter 'value'" >&2
exit 1
fi
diff --git a/cdist/conf/type/__link/gencode-remote b/cdist/conf/type/__link/gencode-remote
index 8d4cc3d5..2975ef69 100755
--- a/cdist/conf/type/__link/gencode-remote
+++ b/cdist/conf/type/__link/gencode-remote
@@ -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.
#
@@ -27,35 +27,33 @@ type="$(cat "$__object/parameter/type")"
source="$(cat "$__object/parameter/source")"
case "$type" in
- symbolic)
- lnopt="-s"
- ;;
- hard)
- lnopt=""
- ;;
- *)
- echo "Unknown type: $type" >&2
- exit 1
- ;;
+ symbolic)
+ lnopt="-s"
+ ;;
+ hard)
+ lnopt=""
+ ;;
+ *)
+ echo "Unknown link type: $type" >&2
+ exit 1
+ ;;
esac
state_is="$(cat "$__object/explorer/state")"
-state_should="$(cat "$__object/parameter/state")"
+state_should=present
+[ -f "$__object/parameter/state" ] && state_should="$(cat "$__object/parameter/state")"
-if [ "$state_should" = "$state_is" ]; then
- # nothing to do
- exit 0
-fi
+[ "$state_should" = "$state_is" ] && exit 0
case "$state_should" in
- present)
- echo ln ${lnopt} -f \"$source\" \"$destination\"
- ;;
- absent)
- echo rm -f \"$destination\"
- ;;
- *)
- echo "Unknown state: $state_should" >&2
- exit 1
- ;;
+ present)
+ echo ln ${lnopt} -f \"$source\" \"$destination\"
+ ;;
+ absent)
+ echo rm -f \"$destination\"
+ ;;
+ *)
+ echo "Unknown state: $state_should" >&2
+ exit 1
+ ;;
esac
diff --git a/cdist/conf/type/__mkfs/gencode-remote b/cdist/conf/type/__mkfs/gencode-remote
deleted file mode 100755
index b3561bad..00000000
--- a/cdist/conf/type/__mkfs/gencode-remote
+++ /dev/null
@@ -1,38 +0,0 @@
-#!/bin/sh
-#
-# 2011 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 .
-#
-
-device="$(cat "$__object/parameter/device")"
-type="$(cat "$__object/parameter/type")"
-
-if [ "$type" = "swap" ]; then
- echo "mkswap $device"
-else
- command="mkfs -t $type -q"
- if [ -f "$__object/parameter/options" ]; then
- options="$(cat "$__object/parameter/options")"
- command="$command $options"
- fi
- command="$command $device"
- if [ -f "$__object/parameter/blocks" ]; then
- blocks="$(cat "$__object/parameter/blocks")"
- command="$command $blocks"
- fi
- echo "$command"
-fi
diff --git a/cdist/conf/type/__mkfs/install b/cdist/conf/type/__mkfs/install
deleted file mode 100644
index e69de29b..00000000
diff --git a/cdist/conf/type/__mkfs/man.text b/cdist/conf/type/__mkfs/man.text
deleted file mode 100644
index 4320c639..00000000
--- a/cdist/conf/type/__mkfs/man.text
+++ /dev/null
@@ -1,57 +0,0 @@
-cdist-type__mkfs(7)
-===================
-Steven Armstrong
-
-
-NAME
-----
-cdist-type__mkfs - build a linux file system
-
-
-DESCRIPTION
------------
-This cdist type is a wrapper for the mkfs command.
-
-
-REQUIRED PARAMETERS
--------------------
-type::
- The filesystem type to use. Same as mkfs -t.
-
-
-OPTIONAL PARAMETERS
--------------------
-device::
- defaults to object_id
-
-options::
- file system-specific options to be passed to the mkfs command
-
-blocks::
- the number of blocks to be used for the file system
-
-
-EXAMPLES
---------
-
---------------------------------------------------------------------------------
-# reiserfs /dev/sda5
-__mkfs /dev/sda5 --type reiserfs
-# same thing with explicit device
-__mkfs whatever --device /dev/sda5 --type reiserfs
-
-# jfs with journal on /dev/sda2
-__mkfs /dev/sda1 --type jfs --options "-j /dev/sda2"
---------------------------------------------------------------------------------
-
-
-SEE ALSO
---------
-- cdist-type(7)
-- mkfs(8)
-
-
-COPYING
--------
-Copyright \(C) 2011 Steven Armstrong. Free use of this software is
-granted under the terms of the GNU General Public License version 3 (GPLv3).
diff --git a/cdist/conf/type/__mkfs/parameter/optional b/cdist/conf/type/__mkfs/parameter/optional
deleted file mode 100644
index 86aeae30..00000000
--- a/cdist/conf/type/__mkfs/parameter/optional
+++ /dev/null
@@ -1,3 +0,0 @@
-device
-options
-blocks
diff --git a/cdist/conf/type/__mkfs/parameter/required b/cdist/conf/type/__mkfs/parameter/required
deleted file mode 100644
index aa80e646..00000000
--- a/cdist/conf/type/__mkfs/parameter/required
+++ /dev/null
@@ -1 +0,0 @@
-type
diff --git a/cdist/conf/type/__package/man.text b/cdist/conf/type/__package/man.text
index 69ecf0ad..b656c890 100644
--- a/cdist/conf/type/__package/man.text
+++ b/cdist/conf/type/__package/man.text
@@ -34,7 +34,7 @@ type::
__package_emerge for Gentoo
state::
- The state the package should be in, either "present" or "absent"
+ Either "present" or "absent", defaults to "present"
EXAMPLES
diff --git a/cdist/conf/type/__package_apt/man.text b/cdist/conf/type/__package_apt/man.text
index 35c34d33..5d4656c1 100644
--- a/cdist/conf/type/__package_apt/man.text
+++ b/cdist/conf/type/__package_apt/man.text
@@ -25,7 +25,7 @@ name::
If supplied, use the name and not the object id as the package name.
state::
- The state the package should be in, either "present" or "absent"
+ Either "present" or "absent", defaults to "present"
EXAMPLES
diff --git a/cdist/conf/type/__package_luarocks/man.text b/cdist/conf/type/__package_luarocks/man.text
index 18a80a79..657f68e5 100644
--- a/cdist/conf/type/__package_luarocks/man.text
+++ b/cdist/conf/type/__package_luarocks/man.text
@@ -24,7 +24,7 @@ name::
If supplied, use the name and not the object id as the package name.
state::
- The state the package should be in, either "present" or "absent"
+ Either "present" or "absent", defaults to "present"
EXAMPLES
diff --git a/cdist/conf/type/__package_opkg/man.text b/cdist/conf/type/__package_opkg/man.text
index 3d02d1ce..aeb0a1c5 100644
--- a/cdist/conf/type/__package_opkg/man.text
+++ b/cdist/conf/type/__package_opkg/man.text
@@ -24,7 +24,7 @@ name::
If supplied, use the name and not the object id as the package name.
state::
- The state the package should be in, either "present" or "absent"
+ Either "present" or "absent", defaults to "present"
EXAMPLES
diff --git a/cdist/conf/type/__package_pacman/man.text b/cdist/conf/type/__package_pacman/man.text
index 17c2037a..2e24ecd9 100644
--- a/cdist/conf/type/__package_pacman/man.text
+++ b/cdist/conf/type/__package_pacman/man.text
@@ -10,8 +10,7 @@ cdist-type__package_pacman - Manage packages with pacman
DESCRIPTION
-----------
-Pacman is usually used on the Archlinux distribution to manage
-packages.
+Pacman is usually used on the Archlinux distribution to manage packages.
REQUIRED PARAMETERS
@@ -25,7 +24,7 @@ name::
If supplied, use the name and not the object id as the package name.
state::
- The state the package should be in, either "present" or "absent"
+ Either "present" or "absent", defaults to "present"
EXAMPLES
diff --git a/cdist/conf/type/__package_pip/man.text b/cdist/conf/type/__package_pip/man.text
index 21d4f9fd..5f619871 100644
--- a/cdist/conf/type/__package_pip/man.text
+++ b/cdist/conf/type/__package_pip/man.text
@@ -28,7 +28,7 @@ pip::
Instead of using pip from PATH, use the specific pip path.
state::
- Either "present" or "absent".
+ Either "present" or "absent", defaults to "present"
EXAMPLES
diff --git a/cdist/conf/type/__package_pkg_freebsd/man.text b/cdist/conf/type/__package_pkg_freebsd/man.text
index f1589037..71387148 100644
--- a/cdist/conf/type/__package_pkg_freebsd/man.text
+++ b/cdist/conf/type/__package_pkg_freebsd/man.text
@@ -21,19 +21,19 @@ None
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.
version::
- If supplied, use to install a specific version of the package named.
+ If supplied, use to install a specific version of the package named.
pkgsite::
- If supplied, use to install from a specific package repository.
+ If supplied, use to install from a specific package repository.
state::
- Either "present" or "absent".
+ Either "present" or "absent", defaults to "present"
EXAMPLES
diff --git a/cdist/conf/type/__package_pkg_openbsd/man.text b/cdist/conf/type/__package_pkg_openbsd/man.text
index 8fcc3216..f523a892 100644
--- a/cdist/conf/type/__package_pkg_openbsd/man.text
+++ b/cdist/conf/type/__package_pkg_openbsd/man.text
@@ -27,7 +27,7 @@ flavor::
If supplied, use to avoid ambiguity.
state::
- The state the package should be in, either "present" or "absent"
+ Either "present" or "absent", defaults to "present"
EXAMPLES
diff --git a/cdist/conf/type/__package_rubygem/man.text b/cdist/conf/type/__package_rubygem/man.text
index feefe699..a808c2aa 100644
--- a/cdist/conf/type/__package_rubygem/man.text
+++ b/cdist/conf/type/__package_rubygem/man.text
@@ -24,7 +24,7 @@ name::
If supplied, use the name and not the object id as the package name.
state::
- The state the package should be in, either "present" or "absent"
+ Either "present" or "absent", defaults to "present"
EXAMPLES
diff --git a/cdist/conf/type/__package_yum/man.text b/cdist/conf/type/__package_yum/man.text
index 9aabf7fb..d958dd1e 100644
--- a/cdist/conf/type/__package_yum/man.text
+++ b/cdist/conf/type/__package_yum/man.text
@@ -26,8 +26,7 @@ name::
If supplied, use the name and not the object id as the package name.
state::
- The state the package should be in, either "present" or "absent"
- (the old values "installed" or "removed" will be removed in cdist 2.1).
+ Either "present" or "absent", defaults to "present"
EXAMPLES
diff --git a/cdist/conf/type/__package_zypper/man.text b/cdist/conf/type/__package_zypper/man.text
index 702d51e5..e2261d33 100644
--- a/cdist/conf/type/__package_zypper/man.text
+++ b/cdist/conf/type/__package_zypper/man.text
@@ -24,7 +24,7 @@ name::
If supplied, use the name and not the object id as the package name.
state::
- The state the package should be in, either "present" or "absent"
+ Either "present" or "absent", defaults to "present"
EXAMPLES
diff --git a/cdist/conf/type/__partition_msdos/install b/cdist/conf/type/__partition_msdos/install
deleted file mode 100644
index e69de29b..00000000
diff --git a/cdist/conf/type/__partition_msdos/man.text b/cdist/conf/type/__partition_msdos/man.text
deleted file mode 100644
index 78220ee0..00000000
--- a/cdist/conf/type/__partition_msdos/man.text
+++ /dev/null
@@ -1,62 +0,0 @@
-cdist-type__partition_msdos(7)
-==============================
-Steven Armstrong
-
-
-NAME
-----
-cdist-type__partition_msdos - creates msdos partitions
-
-
-DESCRIPTION
------------
-This cdist type allows you to create msdos paritions.
-
-
-REQUIRED PARAMETERS
--------------------
-type::
- the partition type used in fdisk (such as 82 or 83) or "extended"
-
-
-OPTIONAL PARAMETERS
--------------------
-partition::
- defaults to object_id
-bootable::
- mark partition as bootable, true or false, defaults to false
-size::
- the size of the partition (such as 32M or 15G, whole numbers
- only), '+' for remaining space, or 'n%' for percentage of remaining
- (these should only be used after all specific partition sizes are
- specified). Defaults to +.
-
-
-EXAMPLES
---------
-
---------------------------------------------------------------------------------
-# 128MB, linux, bootable
-__partition_msdos /dev/sda1 --type 83 --size 128M --bootable true
-# 512MB, swap
-__partition_msdos /dev/sda2 --type 82 --size 512M
-# 100GB, extended
-__partition_msdos /dev/sda3 --type extended --size 100G
-# 10GB, linux
-__partition_msdos /dev/sda5 --type 83 --size 10G
-# 50% of the free space of the extended partition, linux
-__partition_msdos /dev/sda6 --type 83 --size 50%
-# rest of the extended partition, linux
-__partition_msdos /dev/sda7 --type 83 --size +
---------------------------------------------------------------------------------
-
-
-SEE ALSO
---------
-- cdist-type(7)
-
-
-COPYING
--------
-Copyright \(C) 2011 Steven Armstrong. Free use of this software is
-granted under the terms of the GNU General Public License version 3 (GPLv3).
diff --git a/cdist/conf/type/__partition_msdos/manifest b/cdist/conf/type/__partition_msdos/manifest
deleted file mode 100755
index 21e43856..00000000
--- a/cdist/conf/type/__partition_msdos/manifest
+++ /dev/null
@@ -1,41 +0,0 @@
-#!/bin/sh
-#
-# 2011 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 .
-#
-
-# set defaults
-if [ -f "$__object/parameter/partition" ]; then
- partition="(cat "$__object/parameter/partition")"
-else
- partition="/$__object_id"
- echo "$partition" > "$__object/parameter/partition"
-fi
-device="$(echo "$partition" | sed 's/[0-9]//g')"
-echo "$device" > "$__object/parameter/device"
-minor="$(echo "$partition" | sed 's/[^0-9]//g')"
-echo "$minor" > "$__object/parameter/minor"
-
-if [ ! -f "$__object/parameter/bootable" ]; then
- echo "false" > "$__object/parameter/bootable"
-fi
-if [ ! -f "$__object/parameter/size" ]; then
- echo "+" > "$__object/parameter/size"
-fi
-
-# pull in the type that actually does something with the above parameters
-require="$__object_name" __partition_msdos_apply
diff --git a/cdist/conf/type/__partition_msdos/parameter/optional b/cdist/conf/type/__partition_msdos/parameter/optional
deleted file mode 100644
index b2b0a4c2..00000000
--- a/cdist/conf/type/__partition_msdos/parameter/optional
+++ /dev/null
@@ -1,3 +0,0 @@
-partition
-bootable
-size
diff --git a/cdist/conf/type/__partition_msdos/parameter/required b/cdist/conf/type/__partition_msdos/parameter/required
deleted file mode 100644
index aa80e646..00000000
--- a/cdist/conf/type/__partition_msdos/parameter/required
+++ /dev/null
@@ -1 +0,0 @@
-type
diff --git a/cdist/conf/type/__partition_msdos_apply/explorer/partitions b/cdist/conf/type/__partition_msdos_apply/explorer/partitions
deleted file mode 100755
index 6be61af4..00000000
--- a/cdist/conf/type/__partition_msdos_apply/explorer/partitions
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/sh
-
-cat /proc/partitions
diff --git a/cdist/conf/type/__partition_msdos_apply/files/lib.sh b/cdist/conf/type/__partition_msdos_apply/files/lib.sh
deleted file mode 100644
index 5767ea43..00000000
--- a/cdist/conf/type/__partition_msdos_apply/files/lib.sh
+++ /dev/null
@@ -1,61 +0,0 @@
-die() {
- echo "[__partition_msdos_apply] $@" >&2
- exit 1
-}
-debug() {
- #echo "[__partition_msdos_apply] $@" >&2
- :
-}
-
-fdisk_command() {
- local device="$1"
- local cmd="$2"
-
- debug fdisk_command "running fdisk command '${cmd}' on device ${device}"
- printf "${cmd}\nw\n" | fdisk -c -u "$device"
- # give disk some time
- sleep 1
- return $?
-}
-
-create_disklabel() {
- local device=$1
-
- debug create_disklabel "creating new msdos disklabel"
- fdisk_command ${device} "o"
- return $?
-}
-
-create_partition() {
- local device="$1"
- local minor="$2"
- local size="$3"
- local type="$4"
- local primary_count="$5"
-
- if [ "$type" = "extended" -o "$type" = "5" ]; then
- # Extended partition
- primary_extended="e\n"
- first_minor="${minor}\n"
- [ "${minor}" = "4" ] && first_minor=""
- type_minor="${minor}\n"
- [ "${minor}" = "1" ] && type_minor=""
- type="5"
- elif [ "${minor}" -lt "5" ]; then
- primary_extended="p\n"
- first_minor="${minor}\n"
- [ "${minor}" = "4" ] && first_minor=""
- type_minor="${minor}\n"
- [ "${minor}" = "1" ] && type_minor=""
- else
- # Logical partitions
- first_minor="${minor}\n"
- type_minor="${minor}\n"
- primary_extended="l\n"
- [ "$primary_count" -gt "3" ] && primary_extended=""
- fi
- [ -n "${size}" ] && size="+${size}M"
- fdisk_command ${device} "n\n${primary_extended}${first_minor}\n${size}\nt\n${type_minor}${type}\n"
- return $?
-}
-
diff --git a/cdist/conf/type/__partition_msdos_apply/gencode-remote b/cdist/conf/type/__partition_msdos_apply/gencode-remote
deleted file mode 100755
index 5dab7070..00000000
--- a/cdist/conf/type/__partition_msdos_apply/gencode-remote
+++ /dev/null
@@ -1,138 +0,0 @@
-#!/bin/sh
-#
-# 2011 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 .
-#
-
-die() {
- echo "[__partition_msdos_apply] $@" >&2
- exit 1
-}
-debug() {
- #echo "[__partition_msdos_apply] $@" >&2
- :
-}
-
-# Convert a size specifier 1G 100M or 50% into the corresponding numeric MB.
-size_to_mb() {
- local size=$1
- local available_size="$2"
-
- local number_suffix="$(echo ${size} | sed -e 's:\.[0-9]\+::' -e 's:\([0-9]\+\)\([MmGg%]\)[Bb]\?:\1|\2:')"
- local number="$(echo ${number_suffix} | cut -d '|' -f1)"
- local suffix="$(echo ${number_suffix} | cut -d '|' -f2)"
-
- case "$suffix" in
- M|m)
- size="$number"
- ;;
- G|g)
- size="$(( $number * 1024 ))"
- ;;
- %)
- size="$(( $available_size * $number / 100 ))"
- ;;
- *)
- size="-1"
- esac
- echo "$size"
-}
-
-# include function library for use on target
-cat "$__type/files/lib.sh"
-
-partitions="$__object/explorer/partitions"
-objects=$(find "$__global/object/__partition_msdos" -path "*.cdist")
-current_device=""
-available_device_size=
-available_extended_size=
-available_size=
-primary_count=0
-for object in $objects; do
- device="$(cat "$object/parameter/device")"
- if [ "$current_device" != "$device" ]; then
- echo "create_disklabel \"$device\" || die 'Failed to create disklabel for $device'"
- current_device="$device"
- device_name=$(echo ${device} | sed -e 's:^/dev/::;s:/:\\/:g')
- available_device_size=$(( $(awk "/${device_name}\$/ { print \$3; }" "$partitions") / 1024))
- # make sure we don't go past the end of the drive
- available_device_size=$((available_device_size - 2))
- available_extended_size=0
- primary_count=0
- debug "----- $device"
- debug "current_device=$current_device"
- debug "available_device_size=$available_device_size"
- fi
-
- type="$(cat "$object/parameter/type")"
- partition="$(cat "$object/parameter/partition")"
- minor="$(cat "$object/parameter/minor")"
-
- bootable="$(cat "$object/parameter/bootable")"
- size="$(cat "$object/parameter/size")"
-
-
- if [ "${minor}" -lt "5" ]; then
- # Primary partitions
- primary_count=$(( $primary_count + 1 ))
- available_size=$available_device_size
- else
- # Logical partitions
- available_size=$available_extended_size
- fi
-
- if [ "$size" = "+" ]; then
- # use rest of device
- partition_size=""
- available_size=0
- else
- partition_size=$(size_to_mb "$size" "$available_size")
- available_size="$(( $available_size - $partition_size ))"
- fi
-
- if [ "${minor}" -lt "5" ]; then
- # Primary partitions
- available_device_size=$available_size
- if [ "$type" = "extended" -o "$type" = "5" ]; then
- # Extended partition
- available_extended_size=$partition_size
- fi
- else
- # Logical paritions
- available_extended_size=$available_size
- fi
-
- [ "$partition_size" = "-1" ] && die "could not translate size '$size' to a usable value"
- debug "----- $partition"
- debug "primary_count=$primary_count"
- debug "current_device=$current_device"
- debug "device=$device"
- debug "type=$type"
- debug "partition=$partition"
- debug "minor=$minor"
- debug "bootable=$bootable"
- debug "size=$size"
- debug "partition_size=$partition_size"
- debug "available_size=$available_size"
- debug "available_device_size=$available_device_size"
- debug "available_extended_size=$available_extended_size"
- debug "----------"
-
- echo "create_partition '$device' '$minor' '$partition_size' '$type' '$primary_count' \
- || die 'Failed to create partition: $partition'"
-done
-
diff --git a/cdist/conf/type/__partition_msdos_apply/install b/cdist/conf/type/__partition_msdos_apply/install
deleted file mode 100644
index e69de29b..00000000
diff --git a/cdist/conf/type/__pf_ruleset/man.text b/cdist/conf/type/__pf_ruleset/man.text
index 5c368e77..0dc07f71 100644
--- a/cdist/conf/type/__pf_ruleset/man.text
+++ b/cdist/conf/type/__pf_ruleset/man.text
@@ -26,6 +26,7 @@ source::
Note that this type is almost useless without a ruleset defined, but it's technically not
needed, e.g. for the case of disabling the firewall temporarily.
+
EXAMPLES
--------
diff --git a/cdist/conf/type/__postgres_database/man.text b/cdist/conf/type/__postgres_database/man.text
index 06cb736f..d01ca8f6 100644
--- a/cdist/conf/type/__postgres_database/man.text
+++ b/cdist/conf/type/__postgres_database/man.text
@@ -36,6 +36,7 @@ __postgres_database mydbname --state present --owner mydbusername
SEE ALSO
--------
- cdist-type(7)
+- cdist-type__postgres_role(7)
COPYING
diff --git a/cdist/conf/type/__postgres_role/gencode-remote b/cdist/conf/type/__postgres_role/gencode-remote
index a3280c09..c9de4707 100755
--- a/cdist/conf/type/__postgres_role/gencode-remote
+++ b/cdist/conf/type/__postgres_role/gencode-remote
@@ -22,33 +22,28 @@ name="$__object_id"
state_is="$(cat "$__object/explorer/state")"
state_should="$(cat "$__object/parameter/state")"
-if [ "$state_is" != "$state_should" ]; then
- case "$state_should" in
- present)
- optional="password
- login
- createdb
- createrole
- superuser"
- for parameter in $optional; do
- if [ -f "$__object/parameter/$parameter" ]; then
- value="$(cat "$__object/parameter/$parameter")"
- eval $parameter=$value
+[ "$state_is" = "$state_should" ] && exit 0
+
+case "$state_should" in
+ present)
+ if [ -f "$__object/parameter/password" ]; then
+ password="$(cat "$__object/parameter/$parameter")"
+ fi
+ booleans=""
+ for boolean in login createdb createrole superuser; do
+ if [ ! -f "$__object/parameter/$boolean" ]; then
+ boolean="no${boolean}"
fi
- done
+ upper=$(echo $boolean | tr '[a-z]' '[A-Z]')
+ booleans="$booleans $upper"
+ done
[ -n "$password" ] && password="PASSWORD '$password'"
- [ "$login" = "true" ] && login="LOGIN" || login="NOLOGIN"
- [ "$createdb" = "true" ] && createdb="CREATEDB" || createdb="NOCREATEDB"
- [ "$createrole" = "true" ] && createrole="CREATEROLE" || createrole="NOCREATEROLE"
- [ "$superuser" = "true" ] && superuser="SUPERUSER" || superuser="NOSUPERUSER"
- [ "$inherit" = "true" ] && inherit="INHERIT" || inherit="NOINHERIT"
- cmd="CREATE ROLE $name WITH $password $login $createdb $createrole $superuser $inherit"
+ cmd="CREATE ROLE $name WITH $password $booleans"
echo "su - postgres -c \"psql -c \\\"$cmd\\\"\""
- ;;
- absent)
- echo "su - postgres -c \"dropuser \\\"$name\\\"\""
- ;;
- esac
-fi
+ ;;
+ absent)
+ echo "su - postgres -c \"dropuser \\\"$name\\\"\""
+ ;;
+esac
diff --git a/cdist/conf/type/__postgres_role/man.text b/cdist/conf/type/__postgres_role/man.text
index bcc7b5d7..904f0831 100644
--- a/cdist/conf/type/__postgres_role/man.text
+++ b/cdist/conf/type/__postgres_role/man.text
@@ -16,22 +16,27 @@ This cdist type allows you to create or drop postgres roles.
REQUIRED PARAMETERS
-------------------
state::
- either 'present' or 'absent'
+ Either "present" or "absent", defaults to "present"
OPTIONAL PARAMETERS
-------------------
-All optional parameter map directly to the corresponding postgres createrole
+All parameter map directly to the corresponding postgres createrole
parameters.
password::
+
+BOOLEAN PARAMETERS
+------------------
+All parameter map directly to the corresponding postgres createrole
+parameters.
+
login::
createdb::
createrole::
superuser::
inherit::
-
EXAMPLES
--------
@@ -40,15 +45,16 @@ __postgres_role myrole --state present
__postgres_role myrole --state present --password 'secret'
-__postgres_role admin --state present --password 'very-secret' --superuser true
+__postgres_role admin --state present --password 'very-secret' --superuser
-__postgres_role dbcustomer --state present --password 'bla' --createdb true
+__postgres_role dbcustomer --state present --password 'bla' --createdb
--------------------------------------------------------------------------------
SEE ALSO
--------
- cdist-type(7)
+- cdist-type__postgres_database(7)
- http://www.postgresql.org/docs/current/static/sql-createrole.html
diff --git a/cdist/conf/type/__postgres_role/parameter/boolean b/cdist/conf/type/__postgres_role/parameter/boolean
new file mode 100644
index 00000000..a581b3fd
--- /dev/null
+++ b/cdist/conf/type/__postgres_role/parameter/boolean
@@ -0,0 +1,5 @@
+login
+createdb
+createrole
+superuser
+inherit
diff --git a/cdist/conf/type/__postgres_role/parameter/optional b/cdist/conf/type/__postgres_role/parameter/optional
index c5abb57f..f3097ab1 100644
--- a/cdist/conf/type/__postgres_role/parameter/optional
+++ b/cdist/conf/type/__postgres_role/parameter/optional
@@ -1,6 +1 @@
password
-login
-createdb
-createrole
-superuser
-inherit
diff --git a/cdist/conf/type/__process/explorer/runs b/cdist/conf/type/__process/explorer/runs
index 240ebef9..561e2fe9 100755
--- a/cdist/conf/type/__process/explorer/runs
+++ b/cdist/conf/type/__process/explorer/runs
@@ -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.
#
@@ -22,9 +22,9 @@
#
if [ -f "$__object/parameter/name" ]; then
- name="$(cat "$__object/parameter/name")"
+ name="$(cat "$__object/parameter/name")"
else
- name="$__object_id"
+ name="$__object_id"
fi
pgrep -x -f "$name" || true
diff --git a/cdist/conf/type/__process/gencode-remote b/cdist/conf/type/__process/gencode-remote
index e4519f3c..fdb6033a 100755
--- a/cdist/conf/type/__process/gencode-remote
+++ b/cdist/conf/type/__process/gencode-remote
@@ -20,9 +20,9 @@
#
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_should="$(cat "$__object/parameter/state")"
diff --git a/cdist/conf/type/__process/man.text b/cdist/conf/type/__process/man.text
index 961a7f9a..0d457ead 100644
--- a/cdist/conf/type/__process/man.text
+++ b/cdist/conf/type/__process/man.text
@@ -16,25 +16,23 @@ This cdist type allows you to define the state of a process.
REQUIRED PARAMETERS
-------------------
state::
- State of the process: Either present or absent
- (old values "stopped" and "running" are deprecated and will be removed in
- cdist 2.1).
+ Either "present" or "absent", defaults to "present"
OPTIONAL PARAMETERS
-------------------
name::
- Process name to match on when using pgrep -f -x.
+ Process name to match on when using pgrep -f -x.
- This is useful, if the name starts with a "/",
- because the leading slash is stripped away from
- the object id by cdist.
+ This is useful, if the name starts with a "/",
+ because the leading slash is stripped away from
+ the object id by cdist.
stop::
- Executable to use for stopping the process.
+ Executable to use for stopping the process.
start::
- Executable to use for starting the process.
+ Executable to use for starting the process.
EXAMPLES
@@ -66,6 +64,7 @@ __process rpcstatd --state present --start "/etc/init.d/statd start" \
SEE ALSO
--------
- cdist-type(7)
+- cdist-type__start_on_boot(7)
COPYING
diff --git a/cdist/conf/type/__qemu_img/gencode-remote b/cdist/conf/type/__qemu_img/gencode-remote
index acadcef0..e5ff1b4f 100644
--- a/cdist/conf/type/__qemu_img/gencode-remote
+++ b/cdist/conf/type/__qemu_img/gencode-remote
@@ -2,7 +2,8 @@
# State: absent is handled by manifest - we need only to do stuff if image is
# not existing and state != absent
#
-[ -f "$__object/parameter/state" ] && state="$(cat "$__object/parameter/state")"
+state="present"
+[ -f "$__object/parameter/state" ] state="$(cat "$__object/parameter/state")"
[ "$state" = "absent" ] && exit 0
exists="$(cat "$__object/explorer/exists")"
@@ -15,6 +16,6 @@ exists="$(cat "$__object/explorer/exists")"
format=qcow2
[ -f "$__object/parameter/format" ] && format="$(cat "$__object/parameter/format")"
size="$(cat "$__object/parameter/size")"
-vm="/$__object_id"
+diskimage="/$__object_id"
-echo qemu-img create -f \"$format\" \"$vm\" \"$size\"
+echo qemu-img create -f \"$format\" \"$diskimage\" \"$size\"
diff --git a/cdist/conf/type/__qemu_img/man.text b/cdist/conf/type/__qemu_img/man.text
index 3e16f957..39188ab0 100644
--- a/cdist/conf/type/__qemu_img/man.text
+++ b/cdist/conf/type/__qemu_img/man.text
@@ -24,8 +24,7 @@ size::
OPTIONAL PARAMETERS
-------------------
state::
- The state of the image file: either "present" or "absent".
- Defaults to "present".
+ Either "present" or "absent", defaults to "present"
EXAMPLES
diff --git a/cdist/conf/type/__qemu_img/manifest b/cdist/conf/type/__qemu_img/manifest
index d343e188..b835301d 100644
--- a/cdist/conf/type/__qemu_img/manifest
+++ b/cdist/conf/type/__qemu_img/manifest
@@ -3,12 +3,13 @@
#
format=qcow2
+state=present
[ -f "$__object/parameter/format" ] && format="$(cat "$__object/parameter/format")"
[ -f "$__object/parameter/state" ] && state="$(cat "$__object/parameter/state")"
-vm="/$__object_id"
+diskimage="/$__object_id"
# Absent is ensured by __file, present by gencode-remote
if [ "$state" = "absent" ]; then
- __file "$vm" --state absent
+ __file "$diskimage" --state absent
fi
diff --git a/cdist/conf/type/__rvm/gencode-remote b/cdist/conf/type/__rvm/gencode-remote
index aa6ef647..dbc6ba60 100755
--- a/cdist/conf/type/__rvm/gencode-remote
+++ b/cdist/conf/type/__rvm/gencode-remote
@@ -1,6 +1,7 @@
#!/bin/sh
#
# 2012 Evax Software
+# 2012 Nico Schottelius (nico-cdist at schottelius.org)
#
# This file is part of cdist.
#
@@ -21,20 +22,20 @@
user="$__object_id"
state_is="$(cat "$__object/explorer/state")"
state_should="$(cat "$__object/parameter/state")"
-if [ "$state_is" != "$state_should" ]; then
- case "$state_should" in
- present)
- cat << DONE
+
+[ "$state_is" = "$state_should" ] && exit 0
+
+case "$state_should" in
+ present)
+ cat << DONE
su - $user -c "unset rvm_path; unset rvm_bin_path; unset rvm_prefix; unset rvm_version; curl -L get.rvm.io | bash -s stable"
DONE
- ;;
- absent)
- cat << DONE
+ ;;
+ absent)
+ cat << DONE
su - $user -c "rm -Rf \"\\\$HOME/.rvm\";
sed '/rvm\/scripts\/rvm/d' \"\\\$HOME/.bashrc\" > \"\\\$HOME/.bashrc.cdist-tmp\"
mv \"\\\$HOME/.bashrc.cdist-tmp\" \"\\\$HOME/.bashrc\""
-
DONE
- ;;
- esac
-fi
+ ;;
+esac
diff --git a/cdist/conf/type/__rvm/man.text b/cdist/conf/type/__rvm/man.text
index 0a355dc6..c1f83e60 100644
--- a/cdist/conf/type/__rvm/man.text
+++ b/cdist/conf/type/__rvm/man.text
@@ -16,7 +16,7 @@ RVM is the Ruby enVironment Manager for the Ruby programming language.
REQUIRED PARAMETERS
-------------------
state::
- Either "present" or "absent".
+ Either "present" or "absent".
EXAMPLES
diff --git a/cdist/conf/type/__rvm_gem/explorer/state b/cdist/conf/type/__rvm_gem/explorer/state
index 09509a2e..4146d666 100755
--- a/cdist/conf/type/__rvm_gem/explorer/state
+++ b/cdist/conf/type/__rvm_gem/explorer/state
@@ -1,6 +1,7 @@
#!/bin/sh
#
# 2012 Evax Software
+# 2012 Nico Schottelius (nico-cdist at schottelius.org)
#
# This file is part of cdist.
#
@@ -30,8 +31,8 @@ fi
if su - "$user" -c "source \"\$HOME/.rvm/scripts/rvm\"
rvm list | grep -q $ruby"; then
if su - "$user" -c "source \"\$HOME/.rvm/scripts/rvm\"
-rvm use $ruby > /dev/null; rvm gemset list | grep -q $gemsetname &&
-rvm use $gemset > /dev/null && gem list | grep -q $gem"; then
+rvm use $ruby > /dev/null 2>&1; rvm gemset list | grep -q $gemsetname &&
+rvm use $gemset > /dev/null 2>&1 && gem list | grep -q $gem"; then
echo "present"
exit 0
fi
diff --git a/cdist/conf/type/__rvm_gem/gencode-remote b/cdist/conf/type/__rvm_gem/gencode-remote
index 34a69624..1fe6e78e 100755
--- a/cdist/conf/type/__rvm_gem/gencode-remote
+++ b/cdist/conf/type/__rvm_gem/gencode-remote
@@ -1,6 +1,6 @@
-#!/bin/sh
-#
+#!/bin/sh #
# 2012 Evax Software
+# 2012 Nico Schottelius (nico-cdist at schottelius.org)
#
# This file is part of cdist.
#
@@ -25,19 +25,18 @@ gemsetname="$(echo "$gemset" | cut -d '@' -f 2)"
state_is="$(cat "$__object/explorer/state")"
user="$(cat "$__object/parameter/user")"
state_should="$(cat "$__object/parameter/state")"
-if [ "$state_is" != "$state_should" ]; then
- case "$state_should" in
- present)
- cat << DONE
-su - "$user" -c "source \"\\\$HOME/.rvm/scripts/rvm\"
-rvm use $gemset; gem install $gem"
+
+[ "$state_is" = "$state_should" ] && exit 0
+
+case "$state_should" in
+ present)
+ cat << DONE
+su - "$user" -c 'source ~/.rvm/scripts/rvm; rvm use "$gemset"; gem install "$gem"'
DONE
- ;;
- absent)
- cat << DONE
-su - "$user" -c "source \"\\\$HOME/.rvm/scripts/rvm\"
-rvm use $gemset; gem uninstall $gem"
+ ;;
+ absent)
+ cat << DONE
+su - "$user" -c 'source ~/.rvm/scripts/rvm; rvm use "$gemset"; gem uninstall "$gem"'
DONE
- ;;
- esac
-fi
+ ;;
+esac
diff --git a/cdist/conf/type/__rvm_gem/man.text b/cdist/conf/type/__rvm_gem/man.text
index 85b52d65..fbf9a622 100644
--- a/cdist/conf/type/__rvm_gem/man.text
+++ b/cdist/conf/type/__rvm_gem/man.text
@@ -16,16 +16,16 @@ RVM is the Ruby enVironment Manager for the Ruby programming language.
REQUIRED PARAMETERS
-------------------
user::
- The remote user account to use
+ The remote user account to use
gemset::
- The gemset to use
+ The gemset to use
state::
- Either "present" or "absent".
+ Either "present" or "absent"
OPTIONAL PARAMETERS
-------------------
default::
- Make the selected gemset the default
+ Make the selected gemset the default
EXAMPLES
--------
diff --git a/cdist/conf/type/__rvm_gem/manifest b/cdist/conf/type/__rvm_gem/manifest
deleted file mode 100755
index a551472d..00000000
--- a/cdist/conf/type/__rvm_gem/manifest
+++ /dev/null
@@ -1,38 +0,0 @@
-#!/bin/sh
-#
-# 2012 Evax Software
-#
-# 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 .
-#
-
-gem="$__object_id"
-gemset="$(cat "$__object/parameter/gemset")"
-ruby="$(echo "$gemset" | cut -d '@' -f 1)"
-gemsetname="$(echo "$gemset" | cut -d '@' -f 2)"
-user="$(cat "$__object/parameter/user")"
-state="$(cat "$__object/explorer/state")"
-if [ -f "$__object/parameter/default" ]; then
- default="$(cat "$__object/parameter/default")"
-else
- default="no"
- echo $default > "$__object/parameter/default"
-fi
-
-__rvm "$user" --state present
-require="__rvm/$user" \
- __rvm_ruby $ruby --user "$user" --state present --default $default
-require="__rvm_ruby/$ruby" \
- __rvm_gemset $gemset --user "$user" --state present --default $default
diff --git a/cdist/conf/type/__rvm_gemset/explorer/state b/cdist/conf/type/__rvm_gemset/explorer/state
index fbf11830..fa643a6e 100755
--- a/cdist/conf/type/__rvm_gemset/explorer/state
+++ b/cdist/conf/type/__rvm_gemset/explorer/state
@@ -22,14 +22,14 @@ gemset="$__object_id"
ruby="$(echo "$gemset" | cut -d '@' -f 1)"
gemsetname="$(echo "$gemset" | cut -d '@' -f2)"
user="$(cat "$__object/parameter/user")"
-if su - "$user" -c "[ ! -d \"\$HOME/.rvm\" ]" ; then
+
+if [ ! -e "~$user/.rvm/scripts/rvm" ] ; then
echo "absent"
exit 0
fi
-if su - "$user" -c "source \"\$HOME/.rvm/scripts/rvm\"
-rvm list | grep -q $ruby"; then
- if su - "$user" -c "source \"\$HOME/.rvm/scripts/rvm\"
-rvm use $ruby > /dev/null; rvm gemset list | grep -q $gemsetname"; then
+
+if su - "$user" -c 'source ~/.rvm/scripts/rvm; rvm list strings | grep -q "^$ruby\$"'; then
+ if su - "$user" -c 'source ~/.rvm/scripts/rvm; rvm use "$ruby" > /dev/null; rvm gemset list strings | cut -f 1 -d " " | grep -q "^$gemsetname\$"'; then
echo "present"
exit 0
fi
diff --git a/cdist/conf/type/__rvm_gemset/gencode-remote b/cdist/conf/type/__rvm_gemset/gencode-remote
index 1604538d..1fd14061 100755
--- a/cdist/conf/type/__rvm_gemset/gencode-remote
+++ b/cdist/conf/type/__rvm_gemset/gencode-remote
@@ -1,6 +1,7 @@
#!/bin/sh
#
# 2012 Evax Software
+# 2012 Nico Schottelius (nico-cdist at schottelius.org)
#
# This file is part of cdist.
#
@@ -25,29 +26,27 @@ state_is="$(cat "$__object/explorer/state")"
user="$(cat "$__object/parameter/user")"
default="$(cat "$__object/parameter/default" 2>/dev/null || true)"
state_should="$(cat "$__object/parameter/state")"
-if [ "$state_is" != "$state_should" ]; then
- case "$state_should" in
- present)
- cat << DONE
-su - "$user" -c "source \"\\\$HOME/.rvm/scripts/rvm\"
-rvm $gemset --create"
+
+[ "$state_is" = "$state_should" ] && exit 0
+
+case "$state_should" in
+ present)
+ cat << DONE
+su - "$user" -c "source ~/.rvm/scripts/rvm; rvm $gemset --create"
DONE
- case "$default" in
+ case "$default" in
no)
;;
*)
- cat << DONE
-su - "$user" -c "source \"\\\$HOME/.rvm/scripts/rvm\"
-rvm use --default $gemset"
+ cat << DONE
+su - "$user" -c "source ~/.rvm/scripts/rvm; rvm use --default $gemset"
DONE
;;
- esac
- ;;
- absent)
- cat << DONE
-su - "$user" -c "source \"\\\$HOME/.rvm/scripts/rvm\"
-rvm use $ruby; rvm --force gemset delete $gemsetname"
+ esac
+ ;;
+ absent)
+ cat << DONE
+su - "$user" -c "source ~/.rvm/scripts/rvm; rvm use $ruby; rvm --force gemset delete $gemsetname"
DONE
- ;;
- esac
-fi
+ ;;
+esac
diff --git a/cdist/conf/type/__rvm_gemset/man.text b/cdist/conf/type/__rvm_gemset/man.text
index 10b6b411..26e866ba 100644
--- a/cdist/conf/type/__rvm_gemset/man.text
+++ b/cdist/conf/type/__rvm_gemset/man.text
@@ -16,14 +16,14 @@ RVM is the Ruby enVironment Manager for the Ruby programming language.
REQUIRED PARAMETERS
-------------------
user::
- The remote user account to use
+ The remote user account to use
state::
- Either "present" or "absent".
+ Either "present" or "absent".
OPTIONAL PARAMETERS
-------------------
default::
- If set to anything but "no" (the default), set the given gemset as default.
+ If set to anything but "no" (the default), set the given gemset as default.
EXAMPLES
--------
diff --git a/cdist/conf/type/__rvm_gemset/manifest b/cdist/conf/type/__rvm_gemset/manifest
deleted file mode 100755
index b69395ea..00000000
--- a/cdist/conf/type/__rvm_gemset/manifest
+++ /dev/null
@@ -1,36 +0,0 @@
-#!/bin/sh
-#
-# 2012 Evax Software
-#
-# 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 .
-#
-
-gemset="$__object_id"
-ruby="$(echo "$gemset" | cut -d '@' -f 1)"
-gemsetname="$(echo "$gemset" | cut -d '@' -f 2)"
-user="$(cat "$__object/parameter/user")"
-state="$(cat "$__object/explorer/state")"
-if [ -f "$__object/parameter/default" ]; then
- default="$(cat "$__object/parameter/default")"
-else
- default="no"
- echo $default > "$__object/parameter/default"
-fi
-
-__rvm "$user" --state present
-require="__rvm/$user" \
- __rvm_ruby $ruby --user "$user" --state present --default $default
-
diff --git a/cdist/conf/type/__rvm_ruby/gencode-remote b/cdist/conf/type/__rvm_ruby/gencode-remote
index 0003cfe7..f1de3906 100755
--- a/cdist/conf/type/__rvm_ruby/gencode-remote
+++ b/cdist/conf/type/__rvm_ruby/gencode-remote
@@ -24,23 +24,24 @@ user="$(cat "$__object/parameter/user")"
default="$(cat "$__object/parameter/default" 2>/dev/null || true)"
state_should="$(cat "$__object/parameter/state")"
-if [ "$state_is" != "$state_should" ]; then
- case "$state_should" in
- present)
- echo "su - \"$user\" -c \"source \\\$HOME/.rvm/scripts/rvm;"\
- "rvm install $ruby\""
- case "$default" in
- no)
- ;;
- *)
- echo "su - \"$user\" -c \"source \\\$HOME/.rvm/scripts/rvm;"\
- "rvm use --default $ruby\""
- ;;
- esac
- ;;
- absent)
- echo "su - \"$user\" -c \"source \\\$HOME/.rvm/scripts/rvm;"\
- "rvm remove $ruby\""
- ;;
- esac
-fi
+[ "$state_is" = "$state_should" ] && exit 0
+
+case "$state_should" in
+ present)
+ echo "su - \"$user\" -c \"source \\\$HOME/.rvm/scripts/rvm;"\
+ "rvm install $ruby\""
+ if [ -f "$__object/parameter/default" ]; then
+ echo "su - \"$user\" -c \"source \\\$HOME/.rvm/scripts/rvm;"\
+ "rvm use --default $ruby\""
+ fi
+ ;;
+ absent)
+ echo "su - \"$user\" -c \"source \\\$HOME/.rvm/scripts/rvm;"\
+ "rvm remove $ruby\""
+ ;;
+
+ *)
+ echo "Unknown state $state_should" >&2
+ exit 1
+ ;;
+esac
diff --git a/cdist/conf/type/__rvm_ruby/man.text b/cdist/conf/type/__rvm_ruby/man.text
index c558cfe3..dbbab85e 100644
--- a/cdist/conf/type/__rvm_ruby/man.text
+++ b/cdist/conf/type/__rvm_ruby/man.text
@@ -16,14 +16,14 @@ RVM is the Ruby enVironment Manager for the Ruby programming language.
REQUIRED PARAMETERS
-------------------
user::
- The remote user account to use
+ The remote user account to use
state::
- Either "present" or "absent".
+ Either "present" or "absent".
-OPTIONAL PARAMETERS
--------------------
+BOOLEAN PARAMETERS
+------------------
default:
- If set to anything but "no" (the default), set the given version as default
+ Set the given version as default
EXAMPLES
--------
@@ -33,7 +33,7 @@ EXAMPLES
__rvm_ruby ruby-1.9.3-p0 --user thelonious --state present
# Install ruby 1.9.3 through rvm for user ornette and make it the default
-__rvm_ruby ruby-1.9.3-p0 --user ornette --state present --default yes
+__rvm_ruby ruby-1.9.3-p0 --user ornette --state present --default
# Remove ruby 1.9.3 for user john
__rvm_ruby ruby-1.9.3-p0 --user john --state absent
diff --git a/cdist/conf/type/__rvm_ruby/manifest b/cdist/conf/type/__rvm_ruby/manifest
index 581e98a8..db8fd830 100755
--- a/cdist/conf/type/__rvm_ruby/manifest
+++ b/cdist/conf/type/__rvm_ruby/manifest
@@ -1,6 +1,6 @@
#!/bin/sh
#
-# 2012 Evax Software
+# 2012 Nico Schottelius (nico-cdist at schottelius.org)
#
# This file is part of cdist.
#
@@ -17,67 +17,9 @@
# You should have received a copy of the GNU General Public License
# along with cdist. If not, see .
#
+#
-if [ -f "$__object/parameter/default" ]; then
- default="$(cat "$__object/parameter/default")"
-else
- default="no"
- echo "$default" > "$__object/parameter/default"
-fi
-
-ruby="$__object_id"
-user="$(cat "$__object/parameter/user")"
-state="$(cat "$__object/explorer/state")"
-
-apt_ruby="build-essential openssl libreadline6 libreadline6-dev curl git-core
-zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3
-libxml2-dev libxslt-dev autoconf libc6-dev ncurses-dev automake libtool bison
-subversion"
-apt_jruby="curl g++ openjdk-6-jre-headless"
-apt_jruby_head="ant openjdk-6-jdk"
-apt_ironruby="curl mono-2.0-devel"
-
-emerge_ruby="libiconv readline zlib openssl curl git libyaml sqlite libxslt
-libtool gcc autoconf automake bison m4"
-emerge_jruby="dev-java/sun-jdk dev-java/sun-jre-bin"
-emerge_ironruby="dev-lang/mono"
-
-pacman_ruby="gcc patch curl zlib readline libxml2 libxslt git autoconf
-diffutils make libtool bison subversion"
-pacman_jruby="jdk jre curl"
-pacman_ironruby="mono"
-
-yum_ruby="gcc-c++ patch readline readline-devel zlib zlib-devel libyaml-devel
-libffi-devel openssl-devel make bzip2 autoconf automake libtool bison
-iconv-devel"
-yum_jruby="java"
-
-os="$(cat "$__global/explorer/os")"
-case "$os" in
- archlinux) type="pacman" ;;
- debian|ubuntu) type="apt" ;;
- gentoo) type="emerge" ;;
- fedora|redhat|centos) type="yum" ;;
- *);;
-esac
-case "$ruby" in
- ruby-head*)
- deps_list="${type}_ruby_head"
- ;;
- ruby*)
- deps_list="${type}_ruby"
- ;;
- jruby-head*)
- deps_list="${type}_jruby_head"
- ;;
- jruby*)
- deps_list="${type}_jruby"
- ;;
- ironruby*)
- deps_list="${type}_ironruby"
- ;;
-esac
-deps=$(eval echo \$$deps_list)
-for p in $deps; do __package_${type} $p --state present; done
-
-__rvm "$user" --state present
+# Required packages for building ruby
+for package in bzip2 gcc make; do
+ __package "$package" --state present
+done
diff --git a/cdist/conf/type/__rvm_ruby/parameter/optional b/cdist/conf/type/__rvm_ruby/parameter/boolean
similarity index 100%
rename from cdist/conf/type/__rvm_ruby/parameter/optional
rename to cdist/conf/type/__rvm_ruby/parameter/boolean
diff --git a/cdist/conf/type/__ssh_authorized_key/manifest b/cdist/conf/type/__ssh_authorized_key/manifest
index d9db9c78..86c58740 100755
--- a/cdist/conf/type/__ssh_authorized_key/manifest
+++ b/cdist/conf/type/__ssh_authorized_key/manifest
@@ -21,7 +21,7 @@
# This type allows to send a public ssh key from a user to the
# authorized_keys of another
#
-#require="__package openssh-server --state installed"
+#require="__package openssh-server --state present"
# Get option srcuser if defined
if [ -f "$__object/parameter/srcuser" ]; then
srcuser=`cat "$__object/parameter/srcuser"`
@@ -64,4 +64,3 @@ require="__directory${sshpath}" \
# the line added depends on authorized_keys existence
require="__file${sshpath}/authorized_keys" __addifnosuchline sshkey --file \
"$sshpath/authorized_keys" --line "$rsa"
-
diff --git a/cdist/conf/type/__start_on_boot/man.text b/cdist/conf/type/__start_on_boot/man.text
index 0e75c9ab..6d804884 100644
--- a/cdist/conf/type/__start_on_boot/man.text
+++ b/cdist/conf/type/__start_on_boot/man.text
@@ -24,7 +24,7 @@ None.
OPTIONAL PARAMETERS
-------------------
state::
- 'present' or 'absent', defaults to 'present'
+ Either "present" or "absent", defaults to "present"
EXAMPLES
@@ -45,6 +45,7 @@ __start_on_boot puppet --state absent
SEE ALSO
--------
- cdist-type(7)
+- cdist-type__process(7)
COPYING
diff --git a/cdist/conf/type/__autofs_master/gencode-local b/cdist/conf/type/__timezone/gencode-remote
similarity index 66%
rename from cdist/conf/type/__autofs_master/gencode-local
rename to cdist/conf/type/__timezone/gencode-remote
index 701f97a8..b4782d4b 100755
--- a/cdist/conf/type/__autofs_master/gencode-local
+++ b/cdist/conf/type/__timezone/gencode-remote
@@ -1,6 +1,6 @@
#!/bin/sh
#
-# 2011 Steven Armstrong (steven-cdist at armstrong.cc)
+# 2012 Steven Armstrong (steven-cdist at armstrong.cc)
#
# This file is part of cdist.
#
@@ -18,9 +18,13 @@
# along with cdist. If not, see .
#
#
-# Generate auto.master config based on all defined __autofs_map ojbects.
-#
+# This type allows to configure the desired localtime timezone.
-auto_master="$__object/files/auto.master"
-cat "$(cat "$__object/parameter/header")" > "$auto_master"
-find "$__global/object/__autofs_map" -path "*.cdist/parameter/entry" | xargs cat >> "$auto_master"
+timezone="$__object_id"
+os=$(cat "$__global/explorer/os")
+
+case "$os" in
+ ubuntu|debian)
+ echo "echo \"$timezone\" > /etc/timezone"
+ ;;
+esac
diff --git a/cdist/conf/type/__timezone/manifest b/cdist/conf/type/__timezone/manifest
index b0bae209..81de0217 100755
--- a/cdist/conf/type/__timezone/manifest
+++ b/cdist/conf/type/__timezone/manifest
@@ -1,6 +1,8 @@
#!/bin/sh
#
# 2011 Ramon Salvadó (rsalvado at gnuine dot com)
+# 2012 Steven Armstrong (steven-cdist at armstrong.cc)
+# 2012 Nico Schottelius (nico-cdist at schottelius.org)
#
# This file is part of cdist.
#
@@ -21,8 +23,17 @@
# This type allows to configure the desired localtime timezone.
timezone="$__object_id"
-
-__package tzdata --state installed
-require="__package/tzdata" __link /etc/localtime \
- --source "/usr/share/zoneinfo/${timezone}" \
- --type symbolic
+os=$(cat "$__global/explorer/os")
+
+case "$os" in
+ archlinux|debian|ubuntu)
+ __package tzdata --state present
+ require="__package/tzdata" __link /etc/localtime \
+ --source "/usr/share/zoneinfo/${timezone}" \
+ --type symbolic
+ ;;
+ *)
+ echo "Unsupported OS $os" >&2
+ exit 1
+ ;;
+esac
diff --git a/cdist/conf/type/__user/man.text b/cdist/conf/type/__user/man.text
index e571c7c5..7be2c2f2 100644
--- a/cdist/conf/type/__user/man.text
+++ b/cdist/conf/type/__user/man.text
@@ -54,6 +54,7 @@ __user foobar --uid 1001 --shell /bin/zsh --home /home/foobar
SEE ALSO
--------
- cdist-type(7)
+- usermod(8) or pw(8)
COPYING
diff --git a/cdist/config_install.py b/cdist/config_install.py
index b7804a10..2c1edc44 100644
--- a/cdist/config_install.py
+++ b/cdist/config_install.py
@@ -79,7 +79,6 @@ class ConfigInstall(object):
def stage_prepare(self):
"""Do everything for a deploy, minus the actual code stage"""
- self.local.link_emulator(self.context.exec_path)
self.explorer.run_global_explorers(self.local.global_explorer_out_path)
self.manifest.run_initial_manifest(self.context.initial_manifest)
diff --git a/cdist/context.py b/cdist/context.py
index 5fec530f..767b17a8 100644
--- a/cdist/context.py
+++ b/cdist/context.py
@@ -1,7 +1,7 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
-# 2010-2011 Nico Schottelius (nico-cdist at schottelius.org)
+# 2010-2012 Nico Schottelius (nico-cdist at schottelius.org)
#
# This file is part of cdist.
#
@@ -38,7 +38,7 @@ class Context(object):
remote_copy,
remote_exec,
initial_manifest=False,
- conf_dirs=[],
+ add_conf_dirs=[],
exec_path=sys.argv[0],
debug=False):
@@ -59,7 +59,7 @@ class Context(object):
self.temp_dir = tempfile.mkdtemp()
self.out_path = os.path.join(self.temp_dir, "out")
- self.local = local.Local(self.target_host, conf_dirs, self.out_path)
+ self.local = local.Local(self.target_host, self.out_path, self.exec_path, add_conf_dirs=add_conf_dirs)
self.initial_manifest = (initial_manifest or
os.path.join(self.local.manifest_path, "init"))
@@ -87,6 +87,6 @@ class Context(object):
def filter(self, record):
"""Add hostname to logs via logging Filter"""
- record.msg = self.target_host + ": " + record.msg
+ record.msg = self.target_host + ": " + str(record.msg)
return True
diff --git a/cdist/core/cdist_type.py b/cdist/core/cdist_type.py
index 86f3ced1..44e192fc 100644
--- a/cdist/core/cdist_type.py
+++ b/cdist/core/cdist_type.py
@@ -24,7 +24,6 @@ import os
import cdist
-
class NoSuchTypeError(cdist.Error):
def __init__(self, type_path, type_absolute_path):
self.type_path = type_path
diff --git a/cdist/core/manifest.py b/cdist/core/manifest.py
index 5faeccd1..19639618 100644
--- a/cdist/core/manifest.py
+++ b/cdist/core/manifest.py
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
#
# 2011 Steven Armstrong (steven-cdist at armstrong.cc)
-# 2011 Nico Schottelius (nico-cdist at schottelius.org)
+# 2011-2012 Nico Schottelius (nico-cdist at schottelius.org)
#
# This file is part of cdist.
#
@@ -57,6 +57,29 @@ type manifeste is:
creates: new objects through type emulator
'''
+class NoInitialManifestError(cdist.Error):
+ """
+ Display missing initial manifest:
+ - Display path if user given
+ - try to resolve link if it is a link
+ - Omit path if default (is a linked path in temp directory without
+ much help)
+ """
+
+ def __init__(self, manifest_path, user_supplied):
+ msg_header = "Initial manifest missing"
+
+ if user_supplied:
+ if os.path.islink(manifest_path):
+ self.message = "%s: %s -> %s" % (msg_header, manifest_path, os.path.realpath(manifest_path))
+ else:
+ self.message = "%s: %s" % (msg_header, manifest_path)
+ else:
+ self.message = "%s" % (msg_header)
+
+ def __str__(self):
+ return repr(self.message)
+
class Manifest(object):
"""Executes cdist manifests.
@@ -70,33 +93,52 @@ class Manifest(object):
self.env = {
'PATH': "%s:%s" % (self.local.bin_path, os.environ['PATH']),
- '__target_host': self.target_host,
- '__global': self.local.out_path,
'__cdist_type_base_path': self.local.type_path, # for use in type emulator
+ '__global': self.local.out_path,
+ '__target_host': self.target_host,
}
if self.log.getEffectiveLevel() == logging.DEBUG:
self.env.update({'__cdist_debug': "yes" })
- def run_initial_manifest(self, script):
+ def env_initial_manifest(self, initial_manifest):
env = os.environ.copy()
env.update(self.env)
+ env['__cdist_manifest'] = initial_manifest
env['__manifest'] = self.local.manifest_path
- env['__cdist_manifest'] = script
- self.log.info("Running initial manifest " + self.local.manifest_path)
- self.local.run_script(script, env=env)
+
+ return env
+
+ def run_initial_manifest(self, initial_manifest=None):
+ if not initial_manifest:
+ initial_manifest = self.local.initial_manifest
+ user_supplied = False
+ else:
+ user_supplied = True
+
+ self.log.info("Running initial manifest " + initial_manifest)
+
+ if not os.path.isfile(initial_manifest):
+ raise NoInitialManifestError(initial_manifest, user_supplied)
+
+ self.local.run_script(initial_manifest, env=self.env_initial_manifest(initial_manifest))
+
+ def env_type_manifest(self, cdist_object):
+ type_manifest = os.path.join(self.local.type_path, cdist_object.cdist_type.manifest_path)
+ env = os.environ.copy()
+ env.update(self.env)
+ env.update({
+ '__cdist_manifest': type_manifest,
+ '__manifest': self.local.manifest_path,
+ '__object': cdist_object.absolute_path,
+ '__object_id': cdist_object.object_id,
+ '__object_name': cdist_object.name,
+ '__type': cdist_object.cdist_type.absolute_path,
+ })
+
+ return env
def run_type_manifest(self, cdist_object):
- script = os.path.join(self.local.type_path, cdist_object.cdist_type.manifest_path)
- if os.path.isfile(script):
- env = os.environ.copy()
- env.update(self.env)
- env.update({
- '__manifest': self.local.manifest_path,
- '__object': cdist_object.absolute_path,
- '__object_id': cdist_object.object_id,
- '__object_name': cdist_object.name,
- '__type': cdist_object.cdist_type.absolute_path,
- '__cdist_manifest': script,
- })
- self.local.run_script(script, env=env)
+ type_manifest = os.path.join(self.local.type_path, cdist_object.cdist_type.manifest_path)
+ if os.path.isfile(type_manifest):
+ self.local.run_script(type_manifest, env=self.env_type_manifest(cdist_object))
diff --git a/cdist/emulator.py b/cdist/emulator.py
index dedb52ed..e54bd0dc 100644
--- a/cdist/emulator.py
+++ b/cdist/emulator.py
@@ -29,16 +29,19 @@ import cdist
from cdist import core
class Emulator(object):
- def __init__(self, argv):
+ def __init__(self, argv, stdin=sys.stdin, env=os.environ):
self.argv = argv
+ self.stdin = stdin
+ self.env = env
+
self.object_id = False
- self.global_path = os.environ['__global']
- self.target_host = os.environ['__target_host']
+ self.global_path = self.env['__global']
+ self.target_host = self.env['__target_host']
# Internally only
- self.object_source = os.environ['__cdist_manifest']
- self.type_base_path = os.environ['__cdist_type_base_path']
+ self.object_source = self.env['__cdist_manifest']
+ self.type_base_path = self.env['__cdist_type_base_path']
self.object_base_path = os.path.join(self.global_path, "object")
@@ -62,7 +65,7 @@ class Emulator(object):
def run(self):
"""Emulate type commands (i.e. __file and co)"""
- if '__install' in os.environ:
+ if '__install' in self.env:
if not self.cdist_type.is_install:
self.log.debug("Running in install mode, ignoring non install type")
return True
@@ -79,7 +82,7 @@ class Emulator(object):
logformat = '%(levelname)s: %(message)s'
logging.basicConfig(format=logformat)
- if '__cdist_debug' in os.environ:
+ if '__cdist_debug' in self.env:
logging.root.setLevel(logging.DEBUG)
else:
logging.root.setLevel(logging.INFO)
@@ -146,32 +149,27 @@ class Emulator(object):
# Record / Append source
self.cdist_object.source.append(self.object_source)
- chunk_size = 8192
- def _read_stdin(self):
- return sys.stdin.buffer.read(self.chunk_size)
def save_stdin(self):
"""If something is written to stdin, save it in the object as
$__object/stdin so it can be accessed in manifest and gencode-*
scripts.
"""
- if not sys.stdin.isatty():
+ if not self.stdin.isatty():
try:
# go directly to file instead of using CdistObject's api
# as that does not support streaming
+ # FIXME: no streaming needed anymore - use a raw file (not yet there?)
path = os.path.join(self.cdist_object.absolute_path, 'stdin')
- with open(path, 'wb') as fd:
- chunk = self._read_stdin()
- while chunk:
- fd.write(chunk)
- chunk = self._read_stdin()
+ with open(path, 'w') as fd:
+ fd.write(self.stdin.read())
except EnvironmentError as e:
raise cdist.Error('Failed to read from stdin: %s' % e)
def record_requirements(self):
"""record requirements"""
- if "require" in os.environ:
- requirements = os.environ['require']
+ if "require" in self.env:
+ requirements = self.env['require']
self.log.debug("reqs = " + requirements)
for requirement in requirements.split(" "):
# Ignore empty fields - probably the only field anyway
@@ -191,7 +189,7 @@ class Emulator(object):
"""An object shall automatically depend on all objects that it defined in it's type manifest.
"""
# __object_name is the name of the object whose type manifest is currently executed
- __object_name = os.environ.get('__object_name', None)
+ __object_name = self.env.get('__object_name', None)
if __object_name:
# The object whose type manifest is currently run
parent = self.cdist_object.object_from_name(__object_name)
diff --git a/cdist/exec/local.py b/cdist/exec/local.py
index d0ff1765..7ef11458 100644
--- a/cdist/exec/local.py
+++ b/cdist/exec/local.py
@@ -37,24 +37,30 @@ class Local(object):
Directly accessing the local side from python code is a bug.
"""
- def __init__(self, target_host, conf_dirs, out_path, cache_dir=None):
+ def __init__(self, target_host, out_path, exec_path, add_conf_dirs=[], cache_dir=None):
self.target_host = target_host
- self.add_conf_dirs = conf_dirs
self.out_path = out_path
+ self.exec_path = exec_path
+
+ self._add_conf_dirs = add_conf_dirs
self._init_log()
self._init_permissions()
- self._init_home_dir()
self._init_paths()
self._init_cache_dir(cache_dir)
self._init_conf_dirs()
- def _init_home_dir(self):
+ @property
+ def dist_conf_dir(self):
+ return os.path.abspath(os.path.join(os.path.dirname(cdist.__file__), "conf"))
+
+ @property
+ def home_dir(self):
if 'HOME' in os.environ:
- self.home_dir = os.environ['HOME']
+ return os.path.join(os.environ['HOME'], ".cdist")
else:
- self.home_dir = None
+ return None
def _init_log(self):
self.log = logging.getLogger(self.target_host)
@@ -79,17 +85,16 @@ class Local(object):
self.conf_dirs = []
# Comes with the distribution
- system_conf_dir = os.path.join(os.path.dirname(cdist.__file__), "conf")
+ system_conf_dir = os.path.abspath(os.path.join(os.path.dirname(cdist.__file__), "conf"))
self.conf_dirs.append(system_conf_dir)
# Is the default place for user created explorer, type and manifest
if self.home_dir:
- user_conf_dir = os.path.join(self.home_dir, ".cdist")
- self.conf_dirs.append(user_conf_dir)
+ self.conf_dirs.append(self.home_dir)
# Add user supplied directories
- if self.add_conf_dirs:
- self.conf_dirs.extend(self.add_conf_dirs)
+ if self._add_conf_dirs:
+ self.conf_dirs.extend(self._add_conf_dirs)
def _init_cache_dir(self, cache_dir):
if cache_dir:
@@ -146,16 +151,16 @@ class Local(object):
def create_files_dirs(self):
self._create_context_dirs()
self._create_conf_path_and_link_conf_dirs()
+ self._link_types_for_emulator()
def _create_context_dirs(self):
self.mkdir(self.out_path)
+
self.mkdir(self.conf_path)
self.mkdir(self.global_explorer_out_path)
self.mkdir(self.bin_path)
def _create_conf_path_and_link_conf_dirs(self):
- self.mkdir(self.conf_path)
-
# Link destination directories
for sub_dir in [ "explorer", "manifest", "type" ]:
self.mkdir(os.path.join(self.conf_path, sub_dir))
@@ -185,9 +190,9 @@ class Local(object):
except OSError as e:
raise cdist.Error("Linking %s %s to %s failed: %s" % (sub_dir, src, dst, e.__str__()))
- def link_emulator(self, exec_path):
+ def _link_types_for_emulator(self):
"""Link emulator to types"""
- src = os.path.abspath(exec_path)
+ src = os.path.abspath(self.exec_path)
for cdist_type in core.CdistType.list_types(self.type_path):
dst = os.path.join(self.bin_path, cdist_type.name)
self.log.debug("Linking emulator: %s to %s", src, dst)
diff --git a/cdist/exec/remote.py b/cdist/exec/remote.py
index 07c6614b..d4d2cb2b 100644
--- a/cdist/exec/remote.py
+++ b/cdist/exec/remote.py
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
#
# 2011 Steven Armstrong (steven-cdist at armstrong.cc)
-# 2011 Nico Schottelius (nico-cdist at schottelius.org)
+# 2011-2012 Nico Schottelius (nico-cdist at schottelius.org)
#
# This file is part of cdist.
#
diff --git a/cdist/test/__init__.py b/cdist/test/__init__.py
index faa9dc2d..ab767699 100644
--- a/cdist/test/__init__.py
+++ b/cdist/test/__init__.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
#
-# 2011 Nico Schottelius (nico-cdist at schottelius.org)
+# 2011-2012 Nico Schottelius (nico-cdist at schottelius.org)
#
# This file is part of cdist.
#
@@ -24,13 +24,19 @@ import unittest
import tempfile
cdist_base_path = os.path.abspath(
- os.path.join(os.path.dirname(os.path.realpath(__file__)), "../../../"))
+ os.path.join(os.path.dirname(os.path.realpath(__file__)), "../../"))
-cdist_exec_path = os.path.join(cdist_base_path, "bin/cdist")
+cdist_exec_path = os.path.join(cdist_base_path, "scripts/cdist")
+global_fixtures_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), "fixtures"))
class CdistTestCase(unittest.TestCase):
+ remote_exec = os.path.join(global_fixtures_dir, "remote", "exec")
+ remote_copy = os.path.join(global_fixtures_dir, "remote", "copy")
+
+ target_host = 'cdisttesthost'
+
def mkdtemp(self, **kwargs):
return tempfile.mkdtemp(prefix='tmp.cdist.test.', **kwargs)
diff --git a/cdist/test/autorequire/__init__.py b/cdist/test/autorequire/__init__.py
index 2263cbf9..2a647954 100644
--- a/cdist/test/autorequire/__init__.py
+++ b/cdist/test/autorequire/__init__.py
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
#
# 2010-2011 Steven Armstrong (steven-cdist at armstrong.cc)
+# 2012 Nico Schottelius (nico-cdist at schottelius.org)
#
# This file is part of cdist.
#
@@ -34,23 +35,29 @@ import cdist.context
import os.path as op
my_dir = op.abspath(op.dirname(__file__))
fixtures = op.join(my_dir, 'fixtures')
-local_base_path = fixtures
-
+add_conf_dir = op.join(fixtures, 'conf')
class AutorequireTestCase(test.CdistTestCase):
def setUp(self):
self.orig_environ = os.environ
os.environ = os.environ.copy()
- self.target_host = 'localhost'
self.temp_dir = self.mkdtemp()
- os.environ['__cdist_out_dir'] = self.temp_dir
+
+ self.out_dir = os.path.join(self.temp_dir, "out")
+ self.remote_out_dir = os.path.join(self.temp_dir, "remote")
+
+ os.environ['__cdist_out_dir'] = self.out_dir
+ os.environ['__cdist_remote_out_dir'] = self.remote_out_dir
self.context = cdist.context.Context(
target_host=self.target_host,
- base_path=local_base_path,
+ remote_copy=self.remote_copy,
+ remote_exec=self.remote_exec,
+ add_conf_dirs=[add_conf_dir],
exec_path=test.cdist_exec_path,
debug=False)
+
self.config = config.Config(self.context)
def tearDown(self):
diff --git a/cdist/test/code/__init__.py b/cdist/test/code/__init__.py
index 8a8583d7..284ef9c0 100644
--- a/cdist/test/code/__init__.py
+++ b/cdist/test/code/__init__.py
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
#
# 2011 Steven Armstrong (steven-cdist at armstrong.cc)
+# 2012 Nico Schottelius (nico-cdist at schottelius.org)
#
# This file is part of cdist.
#
@@ -19,10 +20,9 @@
#
#
+import getpass
import os
import shutil
-import getpass
-import logging
import cdist
from cdist import core
@@ -34,23 +34,27 @@ from cdist.core import code
import os.path as op
my_dir = op.abspath(op.dirname(__file__))
fixtures = op.join(my_dir, 'fixtures')
-local_base_path = fixtures
+conf_dir = op.join(fixtures, 'conf')
class CodeTestCase(test.CdistTestCase):
def setUp(self):
self.target_host = 'localhost'
- self.local_base_path = local_base_path
self.out_path = self.mkdtemp()
- self.local = local.Local(self.target_host, self.local_base_path, self.out_path)
- self.local.create_directories()
+
+ self.local = local.Local(
+ target_host=self.target_host,
+ out_path = self.out_path,
+ exec_path = cdist.test.cdist_exec_path,
+ add_conf_dirs=[conf_dir])
+ self.local.create_files_dirs()
self.remote_base_path = self.mkdtemp()
- self.user = getpass.getuser()
- remote_exec = "ssh -o User=%s -q" % self.user
- remote_copy = "scp -o User=%s -q" % self.user
+ remote_exec = self.remote_exec
+ remote_copy = self.remote_copy
self.remote = remote.Remote(self.target_host, self.remote_base_path, remote_exec, remote_copy)
+ self.remote.create_files_dirs()
self.code = code.Code(self.target_host, self.local, self.remote)
@@ -58,8 +62,6 @@ class CodeTestCase(test.CdistTestCase):
self.cdist_object = core.CdistObject(self.cdist_type, self.local.object_path, 'whatever')
self.cdist_object.create()
- self.log = logging.getLogger("cdist")
-
def tearDown(self):
shutil.rmtree(self.out_path)
shutil.rmtree(self.remote_base_path)
diff --git a/cdist/test/emulator/__init__.py b/cdist/test/emulator/__init__.py
index ff18fe87..fc0b6695 100644
--- a/cdist/test/emulator/__init__.py
+++ b/cdist/test/emulator/__init__.py
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
#
# 2010-2011 Steven Armstrong (steven-cdist at armstrong.cc)
+# 2012 Nico Schottelius (nico-cdist at schottelius.org)
#
# This file is part of cdist.
#
@@ -19,6 +20,7 @@
#
#
+import io
import os
import shutil
import string
@@ -33,89 +35,80 @@ from cdist import core
from cdist import config
import cdist.context
-local_base_path = test.cdist_base_path
+import os.path as op
+my_dir = op.abspath(op.dirname(__file__))
+fixtures = op.join(my_dir, 'fixtures')
+conf_dir = op.join(fixtures, 'conf')
class EmulatorTestCase(test.CdistTestCase):
def setUp(self):
- self.orig_environ = os.environ
- os.environ = os.environ.copy()
self.temp_dir = self.mkdtemp()
handle, self.script = self.mkstemp(dir=self.temp_dir)
os.close(handle)
- self.target_host = 'localhost'
out_path = self.temp_dir
- self.local = local.Local(self.target_host, local_base_path, out_path)
- self.local.create_directories()
- self.env = {
- 'PATH': "%s:%s" % (self.local.bin_path, os.environ['PATH']),
- '__target_host': self.target_host,
- '__global': self.local.out_path,
- '__cdist_type_base_path': self.local.type_path, # for use in type emulator
- '__manifest': self.local.manifest_path,
- '__cdist_manifest': self.script,
- }
+
+ self.local = local.Local(
+ target_host=self.target_host,
+ out_path=out_path,
+ exec_path=test.cdist_exec_path,
+ add_conf_dirs=[conf_dir])
+ self.local.create_files_dirs()
+
+ self.manifest = core.Manifest(self.target_host, self.local)
+ self.env = self.manifest.env_initial_manifest(self.script)
def tearDown(self):
- os.environ = self.orig_environ
shutil.rmtree(self.temp_dir)
def test_nonexistent_type_exec(self):
argv = ['__does-not-exist']
- os.environ.update(self.env)
- self.assertRaises(core.NoSuchTypeError, emulator.Emulator, argv)
+ self.assertRaises(core.NoSuchTypeError, emulator.Emulator, argv, env=self.env)
def test_nonexistent_type_requirement(self):
argv = ['__file', '/tmp/foobar']
- os.environ.update(self.env)
- os.environ['require'] = '__does-not-exist/some-id'
- emu = emulator.Emulator(argv)
+ self.env['require'] = '__does-not-exist/some-id'
+ emu = emulator.Emulator(argv, env=self.env)
self.assertRaises(core.NoSuchTypeError, emu.run)
def test_illegal_object_id_requirement(self):
argv = ['__file', '/tmp/foobar']
- os.environ.update(self.env)
- os.environ['require'] = '__file/bad/id/with/.cdist/inside'
- emu = emulator.Emulator(argv)
+ self.env['require'] = '__file/bad/id/with/.cdist/inside'
+ emu = emulator.Emulator(argv, env=self.env)
self.assertRaises(core.IllegalObjectIdError, emu.run)
def test_missing_object_id_requirement(self):
argv = ['__file', '/tmp/foobar']
- os.environ.update(self.env)
- os.environ['require'] = '__file'
- emu = emulator.Emulator(argv)
+ self.env['require'] = '__file'
+ emu = emulator.Emulator(argv, env=self.env)
self.assertRaises(core.IllegalObjectIdError, emu.run)
def test_singleton_object_requirement(self):
argv = ['__file', '/tmp/foobar']
- os.environ.update(self.env)
- os.environ['require'] = '__issue'
- emu = emulator.Emulator(argv)
+ self.env['require'] = '__issue'
+ emu = emulator.Emulator(argv, env=self.env)
emu.run()
# if we get here all is fine
def test_requirement_pattern(self):
argv = ['__file', '/tmp/foobar']
- os.environ.update(self.env)
- os.environ['require'] = '__file/etc/*'
- emu = emulator.Emulator(argv)
+ self.env['require'] = '__file/etc/*'
+ emu = emulator.Emulator(argv, env=self.env)
# if we get here all is fine
-import os.path as op
-my_dir = op.abspath(op.dirname(__file__))
-fixtures = op.join(my_dir, 'fixtures')
-
class AutoRequireEmulatorTestCase(test.CdistTestCase):
def setUp(self):
self.temp_dir = self.mkdtemp()
- self.target_host = 'localhost'
- out_path = self.temp_dir
- _local_base_path = fixtures
- self.local = local.Local(self.target_host, _local_base_path, out_path)
- self.local.create_directories()
- self.local.link_emulator(cdist.test.cdist_exec_path)
+ out_path = os.path.join(self.temp_dir, "out")
+
+ self.local = local.Local(
+ target_host=self.target_host,
+ out_path=out_path,
+ exec_path=test.cdist_exec_path,
+ add_conf_dirs=[conf_dir])
+ self.local.create_files_dirs()
self.manifest = core.Manifest(self.target_host, self.local)
def tearDown(self):
@@ -135,22 +128,19 @@ class ArgumentsTestCase(test.CdistTestCase):
def setUp(self):
self.temp_dir = self.mkdtemp()
- self.target_host = 'localhost'
out_path = self.temp_dir
handle, self.script = self.mkstemp(dir=self.temp_dir)
os.close(handle)
- _local_base_path = fixtures
- self.local = local.Local(self.target_host, _local_base_path, out_path)
- self.local.create_directories()
- self.local.link_emulator(test.cdist_exec_path)
- self.env = {
- 'PATH': "%s:%s" % (self.local.bin_path, os.environ['PATH']),
- '__target_host': self.target_host,
- '__global': self.local.out_path,
- '__cdist_type_base_path': self.local.type_path, # for use in type emulator
- '__manifest': self.local.manifest_path,
- '__cdist_manifest': self.script,
- }
+
+ self.local = local.Local(
+ target_host=self.target_host,
+ out_path=out_path,
+ exec_path=test.cdist_exec_path,
+ add_conf_dirs=[conf_dir])
+ self.local.create_files_dirs()
+
+ self.manifest = core.Manifest(self.target_host, self.local)
+ self.env = self.manifest.env_initial_manifest(self.script)
def tearDown(self):
shutil.rmtree(self.temp_dir)
@@ -203,7 +193,7 @@ class ArgumentsTestCase(test.CdistTestCase):
# 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):
@@ -227,40 +217,59 @@ class StdinTestCase(test.CdistTestCase):
def setUp(self):
self.orig_environ = os.environ
os.environ = os.environ.copy()
- self.target_host = 'localhost'
- self.temp_dir = self.mkdtemp()
- os.environ['__cdist_out_dir'] = self.temp_dir
- local_base_path = fixtures
- self.context = cdist.context.Context(
+ self.temp_dir = self.mkdtemp()
+ out_path = os.path.join(self.temp_dir, "out")
+
+ self.local = local.Local(
target_host=self.target_host,
- remote_copy='scp -o User=root -q',
- remote_exec='ssh -o User=root -q',
- base_path=local_base_path,
+ out_path=out_path,
exec_path=test.cdist_exec_path,
- debug=False)
- self.config = config.Config(self.context)
+ add_conf_dirs=[conf_dir])
+
+ self.local.create_files_dirs()
+
+ self.manifest = core.Manifest(
+ target_host=self.target_host,
+ local = self.local)
def tearDown(self):
os.environ = self.orig_environ
shutil.rmtree(self.temp_dir)
def test_file_from_stdin(self):
- handle, destination = self.mkstemp(dir=self.temp_dir)
- os.close(handle)
- source_handle, source = self.mkstemp(dir=self.temp_dir)
- candidates = string.ascii_letters+string.digits
- with os.fdopen(source_handle, 'w') as fd:
- for x in range(100):
- fd.write(''.join(random.sample(candidates, len(candidates))))
+ """
+ Test whether reading from stdin works
+ """
- handle, initial_manifest = self.mkstemp(dir=self.temp_dir)
- with os.fdopen(handle, 'w') as fd:
- fd.write('__file_from_stdin %s --source %s\n' % (destination, source))
- self.context.initial_manifest = initial_manifest
- self.config.stage_prepare()
+ ######################################################################
+ # Create string with random content
+ random_string = str(random.sample(range(1000), 800))
+ random_buffer = io.BytesIO(bytes(random_string, 'utf-8'))
- cdist_type = core.CdistType(self.config.local.type_path, '__file')
- cdist_object = core.CdistObject(cdist_type, self.config.local.object_path, destination)
- # Test weither stdin has been stored correctly
- self.assertTrue(filecmp.cmp(source, os.path.join(cdist_object.absolute_path, 'stdin')))
+ ######################################################################
+ # Prepare required args and environment for emulator
+ type_name = '__file'
+ object_id = "cdist-test-id"
+ argv = [type_name, object_id]
+
+ initial_manifest_path = "/cdist-test/path/that/does/not/exist"
+ env = self.manifest.env_initial_manifest(initial_manifest_path)
+
+ ######################################################################
+ # Create path where stdin should reside at
+ cdist_type = core.CdistType(self.local.type_path, type_name)
+ cdist_object = core.CdistObject(cdist_type, self.local.object_path, object_id)
+ stdin_out_path = os.path.join(cdist_object.absolute_path, 'stdin')
+
+ ######################################################################
+ # Run emulator
+ emu = emulator.Emulator(argv, stdin=random_buffer, env=env)
+ emu.run()
+
+ ######################################################################
+ # Read where emulator should have placed stdin
+ with open(stdin_out_path, 'r') as fd:
+ stdin_saved_by_emulator = fd.read()
+
+ self.assertEqual(random_string, stdin_saved_by_emulator)
diff --git a/cdist/test/emulator/fixtures/conf/type/__file b/cdist/test/emulator/fixtures/conf/type/__file
deleted file mode 120000
index 1ed684b9..00000000
--- a/cdist/test/emulator/fixtures/conf/type/__file
+++ /dev/null
@@ -1 +0,0 @@
-../../../../../conf/type/__file
\ No newline at end of file
diff --git a/cdist/test/exec/local.py b/cdist/test/exec/local.py
index e6f2c2b0..687c13a5 100644
--- a/cdist/test/exec/local.py
+++ b/cdist/test/exec/local.py
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
#
# 2010-2011 Steven Armstrong (steven-cdist at armstrong.cc)
+# 2012 Nico Schottelius (nico-cdist at schottelius.org)
#
# This file is part of cdist.
#
@@ -25,9 +26,6 @@ import shutil
import string
import random
-#import logging
-#logging.basicConfig(level=logging.DEBUG, format='%(levelname)s: %(message)s')
-
import cdist
from cdist import test
from cdist.exec import local
@@ -35,17 +33,23 @@ from cdist.exec import local
import os.path as op
my_dir = op.abspath(op.dirname(__file__))
fixtures = op.join(my_dir, 'fixtures')
-local_base_path = fixtures
-
+conf_dir = op.join(fixtures, "conf")
class LocalTestCase(test.CdistTestCase):
def setUp(self):
- self.temp_dir = self.mkdtemp()
+
target_host = 'localhost'
+ self.temp_dir = self.mkdtemp()
self.out_path = self.temp_dir
- self.base_path = local_base_path
- self.local = local.Local(target_host, self.base_path, self.out_path)
+
+ self.local = local.Local(
+ target_host=target_host,
+ out_path=self.out_path,
+ exec_path=test.cdist_exec_path
+ )
+
+ self.home_dir = os.path.join(os.environ['HOME'], ".cdist")
def tearDown(self):
shutil.rmtree(self.temp_dir)
@@ -53,19 +57,10 @@ class LocalTestCase(test.CdistTestCase):
### test api
def test_cache_path(self):
- self.assertEqual(self.local.cache_path, os.path.join(self.base_path, "cache"))
+ self.assertEqual(self.local.cache_path, os.path.join(self.home_dir, "cache"))
def test_conf_path(self):
- self.assertEqual(self.local.conf_path, os.path.join(self.base_path, "conf"))
-
- def test_global_explorer_path(self):
- self.assertEqual(self.local.global_explorer_path, os.path.join(self.base_path, "conf", "explorer"))
-
- def test_manifest_path(self):
- self.assertEqual(self.local.manifest_path, os.path.join(self.base_path, "conf", "manifest"))
-
- def test_type_path(self):
- self.assertEqual(self.local.type_path, os.path.join(self.base_path, "conf", "type"))
+ self.assertEqual(self.local.conf_path, os.path.join(self.out_path, "conf"))
def test_out_path(self):
self.assertEqual(self.local.out_path, self.out_path)
@@ -81,6 +76,53 @@ class LocalTestCase(test.CdistTestCase):
### /test api
+ ### test internal implementation
+
+ def test_global_explorer_path(self):
+ self.assertEqual(self.local.global_explorer_path, os.path.join(self.out_path, "conf", "explorer"))
+
+ def test_manifest_path(self):
+ self.assertEqual(self.local.manifest_path, os.path.join(self.out_path, "conf", "manifest"))
+
+ def test_type_path(self):
+ self.assertEqual(self.local.type_path, os.path.join(self.out_path, "conf", "type"))
+
+ def test_dist_conf_dir_linking(self):
+ """Ensure that links are correctly created for types included in distribution"""
+
+ test_type="__file"
+
+ link_test_local = local.Local(
+ target_host='localhost',
+ out_path=self.out_path,
+ exec_path=test.cdist_exec_path,
+ )
+
+ link_test_local._create_conf_path_and_link_conf_dirs()
+
+ our_type_dir = os.path.join(link_test_local.type_path, test_type)
+
+ self.assertTrue(os.path.isdir(our_type_dir))
+
+ def test_added_conf_dir_linking(self):
+ """Ensure that links are correctly created for types in added conf directories"""
+
+ test_type="__cdist_test_type"
+
+ link_test_local = local.Local(
+ target_host='localhost',
+ out_path=self.out_path,
+ exec_path=test.cdist_exec_path,
+ add_conf_dirs=[conf_dir]
+ )
+
+ link_test_local._create_conf_path_and_link_conf_dirs()
+
+ our_type_dir = os.path.join(link_test_local.type_path, test_type)
+
+ self.assertTrue(os.path.isdir(our_type_dir))
+
+ ### other tests
def test_run_success(self):
self.local.run(['/bin/true'])
@@ -98,7 +140,7 @@ class LocalTestCase(test.CdistTestCase):
handle, script = self.mkstemp(dir=self.temp_dir)
with os.fdopen(handle, "w") as fd:
fd.writelines(["#!/bin/sh\n", "/bin/false"])
- self.assertRaises(local.LocalScriptError, self.local.run_script, script)
+ self.assertRaises(cdist.Error, self.local.run_script, script)
def test_run_script_get_output(self):
handle, script = self.mkstemp(dir=self.temp_dir)
@@ -117,7 +159,8 @@ class LocalTestCase(test.CdistTestCase):
self.local.rmdir(temp_dir)
self.assertFalse(os.path.isdir(temp_dir))
- def test_create_directories(self):
- self.local.create_directories()
+ def test_create_files_dirs(self):
+ self.local.create_files_dirs()
self.assertTrue(os.path.isdir(self.local.out_path))
self.assertTrue(os.path.isdir(self.local.bin_path))
+ self.assertTrue(os.path.isdir(self.local.conf_path))
diff --git a/cdist/test/explorer/__init__.py b/cdist/test/explorer/__init__.py
index 257ad8a9..a97b538a 100644
--- a/cdist/test/explorer/__init__.py
+++ b/cdist/test/explorer/__init__.py
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
#
# 2010-2011 Steven Armstrong (steven-cdist at armstrong.cc)
-# 2011 Nico Schottelius (nico-cdist at schottelius.org)
+# 2011-2012 Nico Schottelius (nico-cdist at schottelius.org)
#
# This file is part of cdist.
#
@@ -23,7 +23,6 @@
import os
import shutil
import getpass
-import logging
import cdist
from cdist import core
@@ -35,35 +34,45 @@ from cdist.core import explorer
import os.path as op
my_dir = op.abspath(op.dirname(__file__))
fixtures = op.join(my_dir, 'fixtures')
-local_base_path = fixtures
+conf_dir = op.join(fixtures, "conf")
class ExplorerClassTestCase(test.CdistTestCase):
def setUp(self):
self.target_host = 'localhost'
- self.local_base_path = local_base_path
- self.out_path = self.mkdtemp()
- self.local = local.Local(self.target_host, self.local_base_path, self.out_path)
- self.local.create_directories()
+ self.temp_dir = self.mkdtemp()
+ self.out_path = os.path.join(self.temp_dir, "out")
+ self.remote_base_path = os.path.join(self.temp_dir, "remote")
+ os.makedirs(self.remote_base_path)
- self.remote_base_path = self.mkdtemp()
- self.user = getpass.getuser()
- remote_exec = "ssh -o User=%s -q" % self.user
- remote_copy = "scp -o User=%s -q" % self.user
- self.remote = remote.Remote(self.target_host, self.remote_base_path, remote_exec, remote_copy)
+ self.local = local.Local(
+ target_host=self.target_host,
+ out_path=self.out_path,
+ exec_path=test.cdist_exec_path,
+ add_conf_dirs=[conf_dir])
- self.explorer = explorer.Explorer(self.target_host, self.local, self.remote)
+ self.local.create_files_dirs()
- self.log = logging.getLogger(self.target_host)
+ self.remote = remote.Remote(
+ self.target_host,
+ self.remote_base_path,
+ self.remote_exec,
+ self.remote_copy)
+ self.remote.create_files_dirs()
+
+ self.explorer = explorer.Explorer(
+ self.target_host,
+ self.local,
+ self.remote)
def tearDown(self):
- shutil.rmtree(self.out_path)
- shutil.rmtree(self.remote_base_path)
+ shutil.rmtree(self.temp_dir)
def test_list_global_explorer_names(self):
- expected = ['foobar', 'global']
- self.assertEqual(self.explorer.list_global_explorer_names(), expected)
+ names = self.explorer.list_global_explorer_names()
+ self.assertIn("foobar", names)
+ self.assertIn("global", names)
def test_transfer_global_explorers(self):
self.explorer.transfer_global_explorers()
@@ -72,14 +81,20 @@ class ExplorerClassTestCase(test.CdistTestCase):
self.assertEqual(sorted(os.listdir(source)), sorted(os.listdir(destination)))
def test_run_global_explorer(self):
+ """Checkt that running ONE global explorer works"""
self.explorer.transfer_global_explorers()
output = self.explorer.run_global_explorer('global')
self.assertEqual(output, 'global\n')
def test_run_global_explorers(self):
+ """Ensure output is created for every global explorer"""
out_path = self.mkdtemp()
+
self.explorer.run_global_explorers(out_path)
- self.assertEqual(sorted(os.listdir(out_path)), sorted(['foobar', 'global']))
+ names = sorted(self.explorer.list_global_explorer_names())
+ output = sorted(os.listdir(out_path))
+
+ self.assertEqual(names, output)
shutil.rmtree(out_path)
def test_list_type_explorer_names(self):
diff --git a/cdist/test/fixtures/remote b/cdist/test/fixtures/remote
new file mode 120000
index 00000000..c5db6358
--- /dev/null
+++ b/cdist/test/fixtures/remote
@@ -0,0 +1 @@
+../../../other/examples/remote/local
\ No newline at end of file
diff --git a/cdist/test/manifest/__init__.py b/cdist/test/manifest/__init__.py
index a9846b1d..727017e7 100644
--- a/cdist/test/manifest/__init__.py
+++ b/cdist/test/manifest/__init__.py
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
#
# 2010-2011 Steven Armstrong (steven-cdist at armstrong.cc)
+# 2012 Nico Schottelius (nico-cdist at schottelius.org)
#
# This file is part of cdist.
#
@@ -37,8 +38,7 @@ from cdist.core import manifest
import os.path as op
my_dir = op.abspath(op.dirname(__file__))
fixtures = op.join(my_dir, 'fixtures')
-local_base_path = fixtures
-
+conf_dir = op.join(fixtures, 'conf')
class ManifestTestCase(test.CdistTestCase):
@@ -48,9 +48,13 @@ class ManifestTestCase(test.CdistTestCase):
self.temp_dir = self.mkdtemp()
self.target_host = 'localhost'
out_path = self.temp_dir
- self.local = local.Local(self.target_host, local_base_path, out_path)
- self.local.create_directories()
- self.local.link_emulator(cdist.test.cdist_exec_path)
+ self.local = local.Local(
+ target_host=self.target_host,
+ out_path=out_path,
+ exec_path = cdist.test.cdist_exec_path,
+ add_conf_dirs=[conf_dir])
+ self.local.create_files_dirs()
+
self.manifest = manifest.Manifest(self.target_host, self.local)
self.log = logging.getLogger(self.target_host)
@@ -103,6 +107,8 @@ class ManifestTestCase(test.CdistTestCase):
self.assertEqual(output_dict['__object_name'], cdist_object.name)
def test_debug_env_setup(self):
+ current_level = self.log.getEffectiveLevel()
self.log.setLevel(logging.DEBUG)
manifest = cdist.core.manifest.Manifest(self.target_host, self.local)
self.assertTrue("__cdist_debug" in manifest.env)
+ self.log.setLevel(current_level)
diff --git a/docs/changelog b/docs/changelog
index d76f65bb..df5c1b2b 100644
--- a/docs/changelog
+++ b/docs/changelog
@@ -4,6 +4,30 @@ Changelog
* Changes are always commented with their author in (braces)
* Exception: No braces means author == Nico Schottelius
+2.1.0pre8:
+ * Type cleanup: __apt_ppa, __apt_ppa_update_index, __file,
+ __ssh_authorized_key, __timezone, all install types (Steven Armstrong)
+ * Types: Remove all parameter changing code
+ * Type __rvm_ruby: Change parameter "default" to be boolean
+
+2.1.0pre7: 2012-11-07
+ * Core: All unit tests restored back to working
+ * Core: Print error message on missing initial manifest
+
+2.1.0pre6: 2012-11-05
+ * New Example: Turn remote calls into local calls (used for unittesting)
+ * Core: Export PYTHONPATH, it's also needed by emulator
+ * Bugfix Type __rvm_ruby: Add clean package dependencies
+ * Bugfix Type __rvm_gem: Run rvm as user, not as root
+ * Cleanup Type __rvm, __rvm_gemset: Use shortcut version
+ * Bugfix __rvm_gemset: Correctly check for gemsets
+ * Cleanup Type __postgres_database, __postgres_role: Reference each other
+ in documentation
+ * Cleanp Type __postgres_role: Use boolean parameters where appropriate
+ * Cleanp Type __postgres_role: Use shortcut version
+
+2.1.0pre5: 2012-11-01
+ * Core: First round of tests updated to work with multiple configuration directories
2.1.0pre4: 2012-10-31
* Dist: PyPi: Moved cdist.py to script/cdist to avoid double import
@@ -27,7 +51,7 @@ Changelog
Parameter state accepts only "present" and "absent"
* Dist: Initial support for pypi packaging
-2.0.15:
+2.0.15: 2012-11-02
* Core: Make variable __object_name available in type explorers (Steven Armtrong)
* New Type: __qemu_img
* New Type: __line
diff --git a/docs/dev/logs/2012-05-23.urls b/docs/dev/logs/2012-05-23.urls
new file mode 100644
index 00000000..e37407b3
--- /dev/null
+++ b/docs/dev/logs/2012-05-23.urls
@@ -0,0 +1,5 @@
+http://nu-ex.com/cv.html
+
+https://lists.metalab.at/pipermail/devops/2012-January/000089.html
+
+http://www.ir0nik.com/wordpress/?p=121
diff --git a/docs/dev/logs/2012-11-02.migration_to_2.1 b/docs/dev/logs/2012-11-02.migration_to_2.1
new file mode 100644
index 00000000..6c736a5c
--- /dev/null
+++ b/docs/dev/logs/2012-11-02.migration_to_2.1
@@ -0,0 +1,47 @@
+create a new branch to ensure nothing breaks
+
+ % git checkout -b 2.1_merge
+
+fetch latest upstream changes (change origin if you use another
+remote name for upstream cdist)
+
+ % git fetch -v origin
+
+Now try to merge upstream into the new branch.
+
+
+ % git merge origin/2.1
+
+fix any conflicts that may have been occurred due to local changes
+and then **git add** and *git commit** those changes.
+
+As the types have a new location, **cdist/conf/** now, you have to move
+your own types there as well:
+
+ % git mv conf/type/* cdist/conf/
+
+The manifest location also changed, so move this one as well:
+
+ % git mv conf/manifest/* cdist/conf/manifest/
+
+Use **git status** to review the changes and ensure they
+are in the git database:
+
+ % git commit -m "Move types and manifests for 2.1 migration"
+
+This should be everything necessary for a 2.1 migration. Test the result
+by running cdist on one of your staging hosts:
+
+ % ./bin/cdist config -v staging-host
+
+
+You can now cleanup the empty conf/ directory:
+
+ % rmdir conf/* && rmdir conf
+
+
+
+--------------------------------------------------------------------------------
+
+Boolean parameter introduced:
+ __directory /path/to --parents yes => __directory /path/to --parents
diff --git a/docs/man/man7/cdist-quickstart.text b/docs/man/man7/cdist-quickstart.text
index 51943d41..b718da64 100644
--- a/docs/man/man7/cdist-quickstart.text
+++ b/docs/man/man7/cdist-quickstart.text
@@ -77,7 +77,7 @@ git clone git://git.schottelius.org/cdist
# Create manifest (maps configuration to host(s)
cd cdist
-echo '__file /etc/cdist-configured' > conf/manifest/init
+echo '__file /etc/cdist-configured' > cdist/conf/manifest/init
# Configure localhost in verbose mode
./bin/cdist config -v localhost
diff --git a/other/archived_types/.README.unmaintained b/other/archived_types/.README.unmaintained
new file mode 100644
index 00000000..e9795911
--- /dev/null
+++ b/other/archived_types/.README.unmaintained
@@ -0,0 +1 @@
+This type is not maintained by anymore and has thus been removed from cdist.
diff --git a/other/archived_types/README b/other/archived_types/README
new file mode 100644
index 00000000..32cd1f3d
--- /dev/null
+++ b/other/archived_types/README
@@ -0,0 +1,3 @@
+This directory contains types that used to be included with
+cdist, but are not in use anymore. Have a look at the README
+file in each type, to find out why it was removed.
diff --git a/other/archived_types/__autofs/README b/other/archived_types/__autofs/README
new file mode 120000
index 00000000..7495e43b
--- /dev/null
+++ b/other/archived_types/__autofs/README
@@ -0,0 +1 @@
+../.README.unmaintained
\ No newline at end of file
diff --git a/cdist/conf/type/__partition_msdos_apply/man.text b/other/archived_types/__autofs/man.text
similarity index 60%
rename from cdist/conf/type/__partition_msdos_apply/man.text
rename to other/archived_types/__autofs/man.text
index 6cc53b77..9b343309 100644
--- a/cdist/conf/type/__partition_msdos_apply/man.text
+++ b/other/archived_types/__autofs/man.text
@@ -1,21 +1,21 @@
-cdist-type__partition_msdos_apply(7)
-====================================
+cdist-type__autofs(7)
+=====================
Steven Armstrong
NAME
----
-cdist-type__partition_msdos_apply - Apply dos partition settings
+cdist-type__autofs - install and start autofs
DESCRIPTION
-----------
-Create the partitions defined with __partition_msdos
+This space intentionally left blank.
REQUIRED PARAMETERS
-------------------
-None
+None.
OPTIONAL PARAMETERS
@@ -27,16 +27,16 @@ EXAMPLES
--------
--------------------------------------------------------------------------------
-__partition_msdos_apply
+__autofs
--------------------------------------------------------------------------------
SEE ALSO
--------
- cdist-type(7)
-- cdist-type__partition_msdos_apply(7)
+
COPYING
-------
-Copyright \(C) 2011 Steven Armstrong. Free use of this software is
+Copyright \(C) 2012 Steven Armstrong. Free use of this software is
granted under the terms of the GNU General Public License version 3 (GPLv3).
diff --git a/cdist/conf/type/__mkfs/manifest b/other/archived_types/__autofs/manifest
similarity index 65%
rename from cdist/conf/type/__mkfs/manifest
rename to other/archived_types/__autofs/manifest
index e9d275a4..4a726c0a 100755
--- a/cdist/conf/type/__mkfs/manifest
+++ b/other/archived_types/__autofs/manifest
@@ -1,6 +1,7 @@
#!/bin/sh
#
-# 2011 Steven Armstrong (steven-cdist at armstrong.cc)
+# 2012 Steven Armstrong (steven-cdist at armstrong.cc)
+# 2012 Nico Schottelius (nico-cdist at schottelius.org)
#
# This file is part of cdist.
#
@@ -18,14 +19,16 @@
# along with cdist. If not, see .
#
-# set defaults
-if [ -f "$__object/parameter/device" ]; then
- device="(cat "$__object/parameter/device")"
-else
- device="/$__object_id"
- echo "$device" > "$__object/parameter/device"
-fi
-type="(cat "$__object/parameter/type")"
+os=$(cat "$__global/explorer/os")
-options="(cat "$__object/parameter/options")"
+case "$os" in
+ ubuntu|debian|archlinux)
+ __package autofs --state present
+ __start_on_boot autofs --state present
+ ;;
+ *)
+ echo "Unsupported OS: $os" >&2
+ exit 1
+ ;;
+esac
diff --git a/cdist/conf/type/__autofs_master/singleton b/other/archived_types/__autofs/singleton
similarity index 100%
rename from cdist/conf/type/__autofs_master/singleton
rename to other/archived_types/__autofs/singleton
diff --git a/other/archived_types/__autofs_map/README b/other/archived_types/__autofs_map/README
new file mode 120000
index 00000000..7495e43b
--- /dev/null
+++ b/other/archived_types/__autofs_map/README
@@ -0,0 +1 @@
+../.README.unmaintained
\ No newline at end of file
diff --git a/other/archived_types/__autofs_map/explorer/entry b/other/archived_types/__autofs_map/explorer/entry
new file mode 100755
index 00000000..7aa26518
--- /dev/null
+++ b/other/archived_types/__autofs_map/explorer/entry
@@ -0,0 +1,50 @@
+#!/bin/sh
+#
+# 2011 - 2012 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 .
+#
+
+candidates="/etc/auto.master /etc/autofs/auto.master"
+find_auto_master() {
+ # get the path of the auto.master file
+ for candidate in $candidates; do
+ if [ -f "$candidate" ]; then
+ echo "$candidate"
+ return
+ fi
+ done
+}
+
+auto_master="$(find_auto_master)"
+
+# no auto.master, nothing we could do
+[ -f "$auto_master" ] || exit 0
+
+# NOTE: keep variables in sync in manifest/explorer/gencode-*
+prefix="#cdist:$__object_name"
+suffix="#/cdist:$__object_name"
+awk -v prefix="$prefix" -v suffix="$suffix" '{
+ if (index($0,prefix)) {
+ triggered=1
+ }
+ if (triggered) {
+ if (index($0,suffix)) {
+ triggered=0
+ }
+ print
+ }
+}' "$auto_master"
diff --git a/other/archived_types/__autofs_map/gencode-remote b/other/archived_types/__autofs_map/gencode-remote
new file mode 100755
index 00000000..fa6acffb
--- /dev/null
+++ b/other/archived_types/__autofs_map/gencode-remote
@@ -0,0 +1,93 @@
+#!/bin/sh
+#
+# 2011 - 2012 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 .
+#
+
+entry="$__object/files/entry"
+state_should="$(cat "$__object/parameter/state" 2>/dev/null || echo present)"
+if [ ! -s "$__object/explorer/entry" ]; then
+ state_is='absent'
+else
+ state_is=$(diff -q "$entry" "$__object/explorer/entry" >/dev/null \
+ && echo present \
+ || echo changed
+ )
+fi
+
+if [ "$state_should" = "$state_is" ]; then
+ # Nothing to do, move along
+ exit 0
+fi
+
+cat << DONE
+candidates="/etc/auto.master /etc/autofs/auto.master"
+find_auto_master() {
+ # get the path of the auto.master file
+ for candidate in \$candidates; do
+ if [ -f "\$candidate" ]; then
+ echo "\$candidate"
+ return
+ fi
+ done
+}
+
+auto_master="\$(find_auto_master)"
+
+if [ ! -f "\$auto_master" ]; then
+ echo "Could not determine auto.master location, tried: \$candidates" >&2
+ exit 1
+fi
+DONE
+
+remove_entry() {
+ # NOTE: keep variables in sync in manifest/explorer/gencode-*
+ prefix="#cdist:$__object_name"
+ suffix="#/cdist:$__object_name"
+ cat << DONE
+awk -v prefix="$prefix" -v suffix="$suffix" '
+{
+ if (index(\$0,prefix)) {
+ triggered=1
+ }
+ if (triggered) {
+ if (index(\$0,suffix)) {
+ triggered=0
+ }
+ } else {
+ print
+ }
+}' "\$auto_master" > "\$auto_master"+
+mv -f "\$auto_master"+ "\$auto_master"
+DONE
+}
+
+case "$state_should" in
+ present)
+ if [ "$state_is" = "changed" ]; then
+ remove_entry
+ fi
+ cat << DONE
+cat >> "\$auto_master" << EOC
+$(cat "$entry")
+EOC
+DONE
+ ;;
+ absent)
+ remove_entry
+ ;;
+esac
diff --git a/cdist/conf/type/__autofs_map/man.text b/other/archived_types/__autofs_map/man.text
similarity index 72%
rename from cdist/conf/type/__autofs_map/man.text
rename to other/archived_types/__autofs_map/man.text
index 941e22da..50ce2fa8 100644
--- a/cdist/conf/type/__autofs_map/man.text
+++ b/other/archived_types/__autofs_map/man.text
@@ -36,25 +36,35 @@ comment::
auto.master.
+BOOLEAN PARAMETERS
+------------------
+noreload::
+ don't reload autofs after the entry has been changed
+
+
EXAMPLES
--------
--------------------------------------------------------------------------------
-# Add auto mounter at /net
+# Add auto mounter at /net and reload
__autofs_map /net --map /etc/auto.net --type program
-# Add auto mounter at /pub
-__autofs_map /pub --map /etc/auto.pub \
- --type file --options nosuid,rw,bg,hard,intr --ghost
+# Add auto mounter at /pub and don't reload
+__autofs_map /pub \
+ --map /etc/auto.pub \
+ --type file \
+ --options "nosuid,rw,bg,hard,intr --ghost" \
+ --noreload
--------------------------------------------------------------------------------
SEE ALSO
--------
- cdist-type(7)
+- cdist-type__autofs_reload(7)
COPYING
-------
-Copyright \(C) 2011 Steven Armstrong. Free use of this software is
+Copyright \(C) 2012 Steven Armstrong. Free use of this software is
granted under the terms of the GNU General Public License version 3 (GPLv3).
diff --git a/other/archived_types/__autofs_map/manifest b/other/archived_types/__autofs_map/manifest
new file mode 100755
index 00000000..58dc0f98
--- /dev/null
+++ b/other/archived_types/__autofs_map/manifest
@@ -0,0 +1,55 @@
+#!/bin/sh
+#
+# 2011 - 2012 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 .
+#
+
+name="/$__object_id"
+map="$(cat "$__object/parameter/map")"
+type="$(cat "$__object/parameter/type" 2>/dev/null || echo "file")"
+options="$(cat "$__object/parameter/options" 2>/dev/null || true)"
+
+# NOTE: keep variables in sync in manifest/explorer/gencode-*
+prefix="#cdist:$__object_name"
+suffix="#/cdist:$__object_name"
+
+mkdir "$__object/files"
+
+# Generate entry for inclusion in auto.master
+entry="$__object/files/entry"
+echo "$prefix" > "$entry"
+if [ -f "$__object/parameter/comment" ]; then
+ echo "# $(cat "$__object/parameter/comment")" >> "$entry"
+fi
+echo "$name $type:$map $options" >> $entry
+echo "$suffix" >> "$entry"
+
+# Reload autofs after changes if the user wishes this
+if [ ! -f "$__object/parameter/noreload" ]; then
+ state_should="$(cat "$__object/parameter/state" 2>/dev/null || echo present)"
+ if [ ! -s "$__object/explorer/entry" ]; then
+ state_is='absent'
+ else
+ state_is=$(diff -q "$entry" "$__object/explorer/entry" >/dev/null \
+ && echo present \
+ || echo changed
+ )
+ fi
+ if [ "$state_is" != "$state_should" ]; then
+ require="$__object_name" __autofs_reload
+ fi
+fi
diff --git a/other/archived_types/__autofs_map/parameter/boolean b/other/archived_types/__autofs_map/parameter/boolean
new file mode 100644
index 00000000..862edc87
--- /dev/null
+++ b/other/archived_types/__autofs_map/parameter/boolean
@@ -0,0 +1 @@
+noreload
diff --git a/cdist/conf/type/__autofs_map/parameter/optional b/other/archived_types/__autofs_map/parameter/optional
similarity index 100%
rename from cdist/conf/type/__autofs_map/parameter/optional
rename to other/archived_types/__autofs_map/parameter/optional
diff --git a/cdist/conf/type/__autofs_map/parameter/required b/other/archived_types/__autofs_map/parameter/required
similarity index 100%
rename from cdist/conf/type/__autofs_map/parameter/required
rename to other/archived_types/__autofs_map/parameter/required
diff --git a/other/archived_types/__autofs_reload/README b/other/archived_types/__autofs_reload/README
new file mode 120000
index 00000000..7495e43b
--- /dev/null
+++ b/other/archived_types/__autofs_reload/README
@@ -0,0 +1 @@
+../.README.unmaintained
\ No newline at end of file
diff --git a/cdist/conf/type/__autofs_master/manifest b/other/archived_types/__autofs_reload/gencode-remote
similarity index 62%
rename from cdist/conf/type/__autofs_master/manifest
rename to other/archived_types/__autofs_reload/gencode-remote
index e429842e..883602e2 100755
--- a/cdist/conf/type/__autofs_master/manifest
+++ b/other/archived_types/__autofs_reload/gencode-remote
@@ -1,6 +1,6 @@
#!/bin/sh
#
-# 2011 Steven Armstrong (steven-cdist at armstrong.cc)
+# 2012 Steven Armstrong (steven-cdist at armstrong.cc)
#
# This file is part of cdist.
#
@@ -19,13 +19,19 @@
#
-if [ ! -f "$__object/parameter/header" ]; then
- echo "$__type/files/auto.master.header" > "$__object/parameter/header"
-fi
+os=$(cat "$__global/explorer/os")
-[ -d "$__object/files" ] || mkdir "$__object/files"
-require="$__object_name" __file /etc/auto.master --source "$__object/files/auto.master" \
- --mode 644 \
- --owner root \
- --group root
+not_supported() {
+ echo "Your operating system ($os) is currently not supported by this type (${__type##*/})." >&2
+ echo "Please contribute an implementation for it if you can." >&2
+ exit 1
+}
+case "$os" in
+ ubuntu|debian|archlinux)
+ echo "pkill -HUP automount"
+ ;;
+ *)
+ not_supported
+ ;;
+esac
diff --git a/cdist/conf/type/__autofs_master/man.text b/other/archived_types/__autofs_reload/man.text
similarity index 51%
rename from cdist/conf/type/__autofs_master/man.text
rename to other/archived_types/__autofs_reload/man.text
index 641c8393..d2085a98 100644
--- a/cdist/conf/type/__autofs_master/man.text
+++ b/other/archived_types/__autofs_reload/man.text
@@ -1,38 +1,33 @@
-cdist-type__autofs_master(7)
+cdist-type__autofs_reload(7)
============================
Steven Armstrong
NAME
----
-cdist-type__autofs_master - Generate the auto.master file
+cdist-type__autofs_reload - tell automounter to reload config file
DESCRIPTION
-----------
-This cdist type generates a auto.master configuration from given __autofs_map
-definitions. See cdist-type__auto_map(7).
+This space intentionally left blank.
REQUIRED PARAMETERS
-------------------
-None
+None.
+
OPTIONAL PARAMETERS
-------------------
-header::
- Absolute path to a file used as the header for the generated auto.master
- file.
+None.
+
EXAMPLES
--------
--------------------------------------------------------------------------------
-# auto.master with default header
-__autofs_master
-
-# auto.master with custom header
-__autofs_master --header /path/to/header
+__autofs_reload
--------------------------------------------------------------------------------
@@ -43,5 +38,5 @@ SEE ALSO
COPYING
-------
-Copyright \(C) 2011 Steven Armstrong. Free use of this software is
+Copyright \(C) 2012 Steven Armstrong. Free use of this software is
granted under the terms of the GNU General Public License version 3 (GPLv3).
diff --git a/cdist/conf/type/__partition_msdos_apply/singleton b/other/archived_types/__autofs_reload/singleton
similarity index 100%
rename from cdist/conf/type/__partition_msdos_apply/singleton
rename to other/archived_types/__autofs_reload/singleton
diff --git a/other/examples/remote/local/README b/other/examples/remote/local/README
new file mode 100644
index 00000000..cfd350f9
--- /dev/null
+++ b/other/examples/remote/local/README
@@ -0,0 +1,3 @@
+This effectively turns remote calling into local calling.
+
+Probably most useful for the unittesting.
diff --git a/cdist/conf/type/__link/manifest b/other/examples/remote/local/copy
similarity index 73%
rename from cdist/conf/type/__link/manifest
rename to other/examples/remote/local/copy
index 6b5e1ca7..644fee15 100755
--- a/cdist/conf/type/__link/manifest
+++ b/other/examples/remote/local/copy
@@ -1,7 +1,6 @@
#!/bin/sh
#
-# 2011 Steven Armstrong (steven-cdist at armstrong.cc)
-# 2012 Nico Schottelius (nico-cdist at schottelius.org)
+# 2012 Nico Schottelius (nico-cdist schottelius.org)
#
# This file is part of cdist.
#
@@ -18,7 +17,11 @@
# You should have received a copy of the GNU General Public License
# along with cdist. If not, see .
#
+#
-# set default: present, if not setup
-statefile="$__object/parameter/state"
-[ -f "$statefile" ] || echo present > "$statefile"
+recursive=$1; shift
+src=$1; shift
+dst=$1; shift
+
+dst=$(echo $dst | sed "s/^${__target_host}://")
+cp "$recursive" "$src" "$dst"
diff --git a/cdist/conf/type/__file/manifest b/other/examples/remote/local/exec
similarity index 73%
rename from cdist/conf/type/__file/manifest
rename to other/examples/remote/local/exec
index 6b5e1ca7..838513a9 100755
--- a/cdist/conf/type/__file/manifest
+++ b/other/examples/remote/local/exec
@@ -1,7 +1,6 @@
#!/bin/sh
#
-# 2011 Steven Armstrong (steven-cdist at armstrong.cc)
-# 2012 Nico Schottelius (nico-cdist at schottelius.org)
+# 2012 Nico Schottelius (nico-cdist schottelius.org)
#
# This file is part of cdist.
#
@@ -18,7 +17,7 @@
# You should have received a copy of the GNU General Public License
# along with cdist. If not, see .
#
+#
-# set default: present, if not setup
-statefile="$__object/parameter/state"
-[ -f "$statefile" ] || echo present > "$statefile"
+target_host=$1; shift
+echo "$@" | /bin/sh
diff --git a/scripts/cdist b/scripts/cdist
index d5ea06d0..fd18933a 100755
--- a/scripts/cdist
+++ b/scripts/cdist
@@ -172,7 +172,7 @@ def configinstall_onehost(host, args, mode, parallel):
remote_copy=args.remote_copy,
remote_exec=args.remote_exec,
initial_manifest=args.manifest,
- conf_dirs=args.conf_dir,
+ add_conf_dirs=args.conf_dir,
exec_path=sys.argv[0],
debug=args.debug)
@@ -181,9 +181,9 @@ def configinstall_onehost(host, args, mode, parallel):
context.cleanup()
except cdist.Error as e:
+ context.log.error(e)
# We are running in our own process here, need to sys.exit!
if parallel:
- log.error(e)
sys.exit(1)
else:
raise