diff --git a/README b/README
index 3ab11928..965138c4 100644
--- a/README
+++ b/README
@@ -50,10 +50,11 @@ UNIX, simplicity, familar environment | cdist is configured in POSIX shell
### Documentation
-The cdist documentation is included as manpages in the distribution.
+The cdist documentation is included as manpages in the distribution.
+You can browse the documentation online as well:
- * You can [browse the documentation of the latest version online](man) as well.
- * Have a look at the [given speeches](speeches)
+ * [latest version](man/latest)
+ * [all versions (>= 2.0.4)](man)
### OS support
@@ -88,7 +89,7 @@ cdist was tested or is know to run on at least
## Installation
-### Preperation
+### Preparation
Ensure you have Python 3.2 installed on the machine you use to **deploy to the targets**
(the ***source host***).
@@ -135,7 +136,13 @@ If you want to ensure nothing breaks you must set back the python version to wha
#### Max OS X
-Ensure you have port installed and configured (http://www.macports.org/install.php).
+You can choose between Homebrew and Macports, either way works:
+
+[Homebrew](http://mxcl.github.com/homebrew/) variant:
+
+ brew install python3
+
+[Macports](http://www.macports.org/install.php) variant:
port install python32
ln -s /opt/local/bin/python3.2 /opt/local/bin/python3
diff --git a/build b/build
index 5cc59b6d..b994ce00 100755
--- a/build
+++ b/build
@@ -85,7 +85,7 @@ case "$1" in
;;
release)
- "$0" clean && "$0" man && "$0" web
+ ./doc/dev/releasechecklist
;;
speeches)
@@ -99,7 +99,7 @@ case "$1" in
webmain)
cp README ${WEBPAGE}
- cd ${WEBDIR} && git commit -m "cdist update" ${WEBPAGE}
+ cd ${WEBDIR} && git commit -m "cdist main update" ${WEBPAGE}
cd ${WEBDIR} && make pub
;;
@@ -119,6 +119,11 @@ case "$1" in
cd ${WEBDIR} && git add ${WEBBASE}
cd ${WEBDIR} && git commit -m "cdist update" ${WEBBASE} ${WEBPAGE}
cd ${WEBDIR} && make pub
+
+ # Fix ikiwiki, which does not like symlinks for pseudo security
+ ssh tee.schottelius.org \
+ "cd /home/services/www/nico/www.nico.schottelius.org/www/software/cdist/man &&
+ rm -f latest && ln -sf "$version" latest"
;;
p|pu|pub)
diff --git a/conf/explorer/os b/conf/explorer/os
index 1aafb468..3f3ce266 100755
--- a/conf/explorer/os
+++ b/conf/explorer/os
@@ -18,13 +18,14 @@
# along with cdist. If not, see .
#
#
-# All os variables are lower case
-#
+# All os variables are lower case. Keep this file in alphabetical
+# order by os variable except in cases where order otherwise matters,
+# in which case keep the primary os and its derivatives together in
+# a block (see Debian and Redhat examples below).
#
-# Ubuntu is also Debian, thus return if Ubuntu was found
-if grep -q ^DISTRIB_ID=Ubuntu /etc/lsb-release 2>/dev/null; then
- echo ubuntu
+if grep -q ^Amazon /etc/system-release 2>/dev/null; then
+ echo amazon
exit 0
fi
@@ -33,45 +34,52 @@ if [ -f /etc/arch-release ]; then
exit 0
fi
+if [ -f /etc/cdist-preos ]; then
+ echo cdist-preos
+ exit 0
+fi
+
+### Debian and derivatives
+if grep -q ^DISTRIB_ID=Ubuntu /etc/lsb-release 2>/dev/null; then
+ echo ubuntu
+ exit 0
+fi
+
if [ -f /etc/debian_version ]; then
echo debian
exit 0
fi
+###
if [ -f /etc/gentoo-release ]; then
echo gentoo
exit 0
fi
-# Fedora is also Redhat, thus return before redhat!
-if grep -q ^Fedora /etc/redhat-release 2>/dev/null; then
- echo fedora
- exit 0
-fi
-
-# CentOS is also based on Redhat, thus return before redhat!
-if grep -q ^CentOS /etc/redhat-release 2>/dev/null; then
- echo centos
- exit 0
-fi
-
-if [ -f /etc/redhat-release ]; then
- echo redhat
- exit 0
-fi
-
-if [ -f /etc/SuSE-release ]; then
- echo suse
- exit 0
-fi
-
if [ -f /etc/owl-release ]; then
echo owl
exit 0
fi
-if [ -f /etc/cdist-preos ]; then
- echo cdist-preos
+### Redhat and derivatives
+if grep -q ^CentOS /etc/redhat-release 2>/dev/null; then
+ echo centos
+ exit 0
+fi
+
+if grep -q ^Fedora /etc/redhat-release 2>/dev/null; then
+ echo fedora
+ exit 0
+fi
+
+if [ -f /etc/redhat-release ]; then
+ echo redhat
+ exit 0
+fi
+###
+
+if [ -f /etc/SuSE-release ]; then
+ echo suse
exit 0
fi
diff --git a/conf/explorer/os_version b/conf/explorer/os_version
index ef80e8fc..73d3ecd7 100755
--- a/conf/explorer/os_version
+++ b/conf/explorer/os_version
@@ -23,6 +23,9 @@
#
case "$($__explorer/os)" in
+ amazon)
+ cat /etc/system-release
+ ;;
archlinux)
# empty, but well...
cat /etc/arch-release
diff --git a/conf/type/__file/gencode-remote b/conf/type/__file/gencode-remote
index 9e700934..2b4c7e45 100755
--- a/conf/type/__file/gencode-remote
+++ b/conf/type/__file/gencode-remote
@@ -34,11 +34,6 @@ case "$state_should" in
fi
fi
- # Mode settings
- if [ -f "$__object/parameter/mode" ]; then
- echo chmod \"$(cat "$__object/parameter/mode")\" \"$destination\"
- fi
-
# Group
if [ -f "$__object/parameter/group" ]; then
echo chgrp \"$(cat "$__object/parameter/group")\" \"$destination\"
@@ -48,6 +43,12 @@ case "$state_should" in
if [ -f "$__object/parameter/owner" ]; then
echo chown \"$(cat "$__object/parameter/owner")\" \"$destination\"
fi
+
+ # Mode - needs to happen last as a chown/chgrp can alter mode by
+ # clearing S_ISUID and S_ISGID bits (see chown(2))
+ if [ -f "$__object/parameter/mode" ]; then
+ echo chmod \"$(cat "$__object/parameter/mode")\" \"$destination\"
+ fi
;;
absent)
diff --git a/conf/type/__group/gencode-remote b/conf/type/__group/gencode-remote
index 20e08738..cf26a437 100755
--- a/conf/type/__group/gencode-remote
+++ b/conf/type/__group/gencode-remote
@@ -29,7 +29,7 @@ if grep -q "^${name}:" "$__object/explorer/group"; then
for property in $(ls .); do
new_value="$(cat "$property")"
- case "$key" in
+ case "$property" in
password)
current_value="$(awk -F: '{ print $2 }' < "$__object/explorer/gshadow")"
;;
diff --git a/conf/type/__key_value/explorer/state b/conf/type/__key_value/explorer/state
new file mode 100755
index 00000000..94a5ea7f
--- /dev/null
+++ b/conf/type/__key_value/explorer/state
@@ -0,0 +1,53 @@
+#!/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 .
+#
+
+key="$(cat "$__object/parameter/key" 2>/dev/null \
+ || echo "$__object_id")"
+state="$(cat "$__object/parameter/state" 2>/dev/null \
+ || echo "present")"
+file="$(cat "$__object/parameter/file")"
+delimiter="$(cat "$__object/parameter/delimiter")"
+value="$(cat "$__object/parameter/value" 2>/dev/null \
+ || echo "__CDIST_NOTSET__")"
+
+case "$state" in
+ absent)
+ if grep -q -E "^$key$delimiter+" "$file"; then
+ # if the key exists, with whatever value, we will have to remove it
+ # so report it as present
+ echo present
+ else
+ # key does not exist
+ echo absent
+ fi
+ ;;
+ present)
+ if grep -q -E "^$key$delimiter+$value$" "$file"; then
+ # key exists and value is same
+ echo present
+ elif grep -q -E "^$key$delimiter+" "$file"; then
+ # key exists, but value is empty or different
+ echo wrongvalue
+ else
+ # key does not exist
+ echo absent
+ fi
+ ;;
+esac
diff --git a/conf/type/__key_value/gencode-remote b/conf/type/__key_value/gencode-remote
index eff0925c..0846dca1 100755
--- a/conf/type/__key_value/gencode-remote
+++ b/conf/type/__key_value/gencode-remote
@@ -18,35 +18,40 @@
# along with cdist. If not, see .
#
-value_is="$(cat "$__object/explorer/value")"
-value_should="$(cat "$__object/parameter/value")"
-
key="$(cat "$__object/parameter/key")"
file="$(cat "$__object/parameter/file")"
delimiter="$(cat "$__object/parameter/delimiter")"
+value="$(cat "$__object/parameter/value")"
-if [ "$value_is" != "$value_should" ]; then
- case "$value_is" in
- __NOTSET__)
- # add key and value
- echo "echo \"${key}${delimiter}${value_should}\" >> \"$file\""
- ;;
- *)
- if [ "$value_should" = '__NOTSET__' ]; then
- # remove key and value
- cat << DONE
-sed -i '/^${key}/d' "$file"
-DONE
- else
- # change value
- cat << DONE
-awk -F "$delimiter" '
-/${key}${delimiter}*/{gsub("$value_is", "$value_should")};{print}' "$file" > "${file}+" \
-&& mv "${file}+" "$file"
+state_is="$(cat "$__object/explorer/state")"
+state_should="$(cat "$__object/parameter/state")"
-DONE
- fi
- ;;
- esac
+if [ "$state_is" = "$state_should" ]; then
+ # nothing to do
+ exit 0
fi
+case "$state_should" in
+ absent)
+ # remove lines starting with key
+ echo "sed -i '/^$key\($delimiter\+\)/d' \"$file\""
+ ;;
+ present)
+ case "$state_is" in
+ absent)
+ # add new key and value
+ echo "echo \"${key}${delimiter}${value}\" >> \"$file\""
+ ;;
+ wrongvalue)
+ # change exisiting value
+ echo "sed -i \"s|^$key\($delimiter\+\).*|$key\1$value|\" \"$file\""
+ ;;
+ *)
+ echo "Unknown explorer state: $state_is" >&2
+ exit 1
+ esac
+ ;;
+ *)
+ echo "Unknown state: $state_should" >&2
+ exit 1
+esac
diff --git a/conf/type/__key_value/man.text b/conf/type/__key_value/man.text
index 3e4e8013..1423fc7d 100644
--- a/conf/type/__key_value/man.text
+++ b/conf/type/__key_value/man.text
@@ -16,9 +16,6 @@ file.
REQUIRED PARAMETERS
-------------------
-value::
- The value for the key. Setting the value to `__NOTSET__` will remove the key
- from the file.
file::
The file to operate on.
delimiter::
@@ -27,8 +24,13 @@ delimiter::
OPTIONAL PARAMETERS
-------------------
+state::
+ present or absent, defaults to present. If present, sets the key to value,
+ if absent, removes the key from the file.
key::
The key to change. Defaults to object_id.
+value::
+ The value for the key. Optional if state=absent, required otherwise.
EXAMPLES
@@ -45,6 +47,9 @@ __key_value my-fancy-id --file /etc/login.defs --key SYS_UID_MAX --value 666 \
# Enable packet forwarding
__key_value net.ipv4.ip_forward --file /etc/sysctl.conf --value 1 \
--delimiter '='
+
+# Remove existing key/value
+__key_value LEGACY_KEY --file /etc/somefile --state absent --delimiter '='
--------------------------------------------------------------------------------
diff --git a/conf/type/__key_value/manifest b/conf/type/__key_value/manifest
index 706b0b0d..2e75e175 100755
--- a/conf/type/__key_value/manifest
+++ b/conf/type/__key_value/manifest
@@ -18,9 +18,13 @@
# along with cdist. If not, see .
#
-if [ -f "$__object/parameter/key" ]; then
- key="$(cat "$__object/parameter/key")"
-else
- echo "$__object_id" > "$__object/parameter/key"
-fi
+# 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")"
+if [ "$state" = "present" -a ! -f "$__object/parameter/value" ]; then
+ echo "Missing required parameter 'value'" >&2
+ exit 1
+fi
diff --git a/conf/type/__key_value/parameter/optional b/conf/type/__key_value/parameter/optional
index 06bfde49..483e3192 100644
--- a/conf/type/__key_value/parameter/optional
+++ b/conf/type/__key_value/parameter/optional
@@ -1 +1,3 @@
key
+value
+state
diff --git a/conf/type/__key_value/parameter/required b/conf/type/__key_value/parameter/required
index 8f4aa53c..3ae10da3 100644
--- a/conf/type/__key_value/parameter/required
+++ b/conf/type/__key_value/parameter/required
@@ -1,3 +1,2 @@
-value
file
delimiter
diff --git a/conf/type/__link/explorer/state b/conf/type/__link/explorer/state
new file mode 100755
index 00000000..a9220a3c
--- /dev/null
+++ b/conf/type/__link/explorer/state
@@ -0,0 +1,62 @@
+#!/bin/sh
+#
+# 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 .
+#
+
+destination="/$__object_id"
+type="$(cat "$__object/parameter/type")"
+source="$(cat "$__object/parameter/source")"
+
+# no destination? -> state is absent
+if [ ! -e "$destination" ]; then
+ echo absent
+ exit 0
+fi
+
+destination_dir="${destination%/*}"
+
+case "$type" in
+ symbolic)
+ cd "$destination_dir"
+ source_is=$(ls -l "$destination" | sed 's/.*-> //g')
+ if [ -h "$destination" -a "$source_is" = "$source" ]; then
+ echo present
+ else
+ echo absent
+ fi
+ ;;
+ hard)
+ cd "$destination_dir"
+ # check source relative to destination_dir
+ if [ ! -e "$source" ]; then
+ echo sourcemissing
+ exit 0
+ fi
+ destination_inode=$(ls -i "$destination" | awk '{print $1}')
+ source_inode=$(ls -i "$source" | awk '{print $1}')
+ if [ "$destination_inode" -eq "$source_inode" ]; then
+ echo present
+ else
+ echo absent
+ fi
+ ;;
+ *)
+ echo "Unknown type: $type" >&2
+ exit 1
+ ;;
+esac
diff --git a/conf/type/__link/gencode-remote b/conf/type/__link/gencode-remote
index 0a367654..8d4cc3d5 100755
--- a/conf/type/__link/gencode-remote
+++ b/conf/type/__link/gencode-remote
@@ -39,7 +39,14 @@ case "$type" in
;;
esac
+state_is="$(cat "$__object/explorer/state")"
state_should="$(cat "$__object/parameter/state")"
+
+if [ "$state_should" = "$state_is" ]; then
+ # nothing to do
+ exit 0
+fi
+
case "$state_should" in
present)
echo ln ${lnopt} -f \"$source\" \"$destination\"
diff --git a/conf/type/__package/manifest b/conf/type/__package/manifest
index 48818dd8..181da077 100755
--- a/conf/type/__package/manifest
+++ b/conf/type/__package/manifest
@@ -33,7 +33,7 @@ else
archlinux) type="pacman" ;;
debian|ubuntu) type="apt" ;;
gentoo) type="emerge" ;;
- fedora|redhat|centos) type="yum" ;;
+ amazon|centos|fedora|redhat) type="yum" ;;
*)
echo "Don't know how to manage packages on: $os" >&2
exit 1
diff --git a/conf/type/__package_pip/explorer/state b/conf/type/__package_pip/explorer/state
new file mode 100644
index 00000000..5be07280
--- /dev/null
+++ b/conf/type/__package_pip/explorer/state
@@ -0,0 +1,49 @@
+#!/bin/sh
+#
+# 2012 Nico Schottelius (nico-cdist at schottelius.org)
+#
+# 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 .
+#
+#
+# Development supported by Local AG (www.local.ch)
+#
+
+nameparam="$__object/parameter/name"
+if [ -f "$nameparam" ]; then
+ name=$(cat "$nameparam")
+else
+ name="$__object_id"
+fi
+
+pipparam="$__object/parameter/pip"
+if [ -f "$pipparam" ]; then
+ pip=$(cat "$pipparam")
+else
+ pip="pip"
+fi
+
+# If there is no pip, it may get created from somebody else.
+# If it will be created, there is probably no package installed.
+if ! command -v "$pip" >/dev/null 2>&1; then
+ echo absent
+else
+
+ if "$pip" freeze | grep -i -q "^$name=="; then
+ echo present
+ else
+ echo absent
+ fi
+fi
diff --git a/conf/type/__key_value/explorer/value b/conf/type/__package_pip/gencode-remote
old mode 100755
new mode 100644
similarity index 52%
rename from conf/type/__key_value/explorer/value
rename to conf/type/__package_pip/gencode-remote
index 3afc7cc5..e60d74c5
--- a/conf/type/__key_value/explorer/value
+++ b/conf/type/__package_pip/gencode-remote
@@ -1,6 +1,6 @@
#!/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,20 +18,33 @@
# along with cdist. If not, see .
#
#
-# Get the current value of key or __NOTSET__ if the key doesn't exist.
+# Development supported by Local AG (www.local.ch)
#
-if [ -f "$__object/parameter/key" ]; then
- key="$(cat "$__object/parameter/key")"
+state_is=$(cat "$__object/explorer/state")
+state_should=$(cat "$__object/parameter/state")
+
+[ "$state_is" = "$state_should" ] && exit 0
+
+nameparam="$__object/parameter/name"
+if [ -f "$nameparam" ]; then
+ name=$(cat "$nameparam")
else
- key="$__object_id"
+ name="$__object_id"
fi
-file="$(cat "$__object/parameter/file")"
-delimiter="$(cat "$__object/parameter/delimiter")"
-awk -F "$delimiter" '
-BEGIN { found=0 }
-/^'$key'/ { print $2; found=1 }
-END { if (found) exit 0; else exit 1 }' "$file" \
-|| echo "__NOTSET__"
+pipparam="$__object/parameter/pip"
+if [ -f "$pipparam" ]; then
+ pip=$(cat "$pipparam")
+else
+ pip="pip"
+fi
+case "$state_should" in
+ present)
+ echo $pip install -q pyro
+ ;;
+ absent)
+ echo $pip uninstall -q -y pyro
+ ;;
+esac
diff --git a/conf/type/__package_pip/man.text b/conf/type/__package_pip/man.text
new file mode 100644
index 00000000..5ce45c50
--- /dev/null
+++ b/conf/type/__package_pip/man.text
@@ -0,0 +1,53 @@
+cdist-type__package_pip(7)
+==========================
+Nico Schottelius
+
+
+NAME
+----
+cdist-type__package_pip - Manage packages with pip
+
+
+DESCRIPTION
+-----------
+Pip is used in Python environments to install packages.
+It is also included in the python virtualenv environment.
+
+
+REQUIRED PARAMETERS
+-------------------
+state::
+ Either "present" or "absent".
+
+
+OPTIONAL PARAMETERS
+-------------------
+name::
+ If supplied, use the name and not the object id as the package name.
+
+pip::
+ Instead of using pip from PATH, use the specific pip path.
+
+
+EXAMPLES
+--------
+
+--------------------------------------------------------------------------------
+# Install a package
+__package_pip pyro --state present
+
+# Use pip in a virtualenv located at /root/shinken_virtualenv
+__package_pip pyro --state present --pip /root/shinken_virtualenv/bin/pip
+--------------------------------------------------------------------------------
+
+
+SEE ALSO
+--------
+- cdist-type(7)
+- cdist-type__package(7)
+
+
+COPYING
+-------
+Copyright \(C) 2012 Nico Schottelius. Free use of this software is
+granted under the terms of the GNU General Public License version 3 (GPLv3).
diff --git a/conf/type/__package_pip/parameter/optional b/conf/type/__package_pip/parameter/optional
new file mode 100644
index 00000000..a1b589e3
--- /dev/null
+++ b/conf/type/__package_pip/parameter/optional
@@ -0,0 +1 @@
+pip
diff --git a/conf/type/__package_pip/parameter/required b/conf/type/__package_pip/parameter/required
new file mode 100644
index 00000000..ff72b5c7
--- /dev/null
+++ b/conf/type/__package_pip/parameter/required
@@ -0,0 +1 @@
+state
diff --git a/conf/type/__package_yum/gencode-remote b/conf/type/__package_yum/gencode-remote
index e43712f8..b24ed220 100755
--- a/conf/type/__package_yum/gencode-remote
+++ b/conf/type/__package_yum/gencode-remote
@@ -29,7 +29,7 @@ fi
state="$(cat "$__object/parameter/state")"
-if grep -q -E "(centos|redhat)" "$__global/explorer/os"; then
+if grep -q -E "(centos|redhat|amazon)" "$__global/explorer/os"; then
opts="-y --quiet"
else
opts="--assumeyes --quiet"
diff --git a/conf/type/__user/gencode-remote b/conf/type/__user/gencode-remote
index ce50359b..8979c56e 100755
--- a/conf/type/__user/gencode-remote
+++ b/conf/type/__user/gencode-remote
@@ -28,6 +28,7 @@ cd "$__object/parameter"
if grep -q "^${name}:" "$__object/explorer/passwd"; then
for property in $(ls .); do
new_value="$(cat "$property")"
+ unset current_value
file="$__object/explorer/passwd"
@@ -36,13 +37,20 @@ if grep -q "^${name}:" "$__object/explorer/passwd"; then
if $(echo "$new_value" | grep -q '^[0-9][0-9]*$'); then
field=4
else
- # group name
- file="$__object/explorer/group"
- field=1
+ # We were passed a group name. Compare the gid in
+ # the user's /etc/passwd entry with the gid of the
+ # group returned by the group explorer.
+ gid_from_group=$(awk -F: '{ print $3 }' "$__object/explorer/group")
+ gid_from_passwd=$(awk -F: '{ print $4 }' "$file")
+ if [ "$gid_from_group" != "$gid_from_passwd" ]; then
+ current_value="$gid_from_passwd"
+ else
+ current_value="$new_value"
+ fi
fi
;;
password)
- field=3
+ field=2
file="$__object/explorer/shadow"
;;
comment) field=5 ;;
@@ -51,8 +59,12 @@ if grep -q "^${name}:" "$__object/explorer/passwd"; then
uid) field=3 ;;
esac
- export field
- current_value="$(awk -F: '{ print $ENVIRON["field"] }' < "$file")"
+ # If we haven't already set $current_value above, pull it from the
+ # appropriate file/field.
+ if [ -z "$current_value" ]; then
+ export field
+ current_value="$(awk -F: '{ print $ENVIRON["field"] }' < "$file")"
+ fi
if [ "$new_value" != "$current_value" ]; then
set -- "$@" "--$property" \'$new_value\'
diff --git a/doc/changelog b/doc/changelog
index d5a2fd7a..2d2d7a48 100644
--- a/doc/changelog
+++ b/doc/changelog
@@ -1,15 +1,37 @@
-2.0.6:
+Changelog
+---------
+
+ * Changes are always commented with their author in (braces)
+ * Exception: No braces means author == Nico Schottelius
+
+2.0.8:
+ * Cleanup: Better hint to source of error
+ * Cleanup: Remove support for __debug variable in manifests (Type != Core
+ debugging)
+
+2.0.7: 2012-02-13
+ * Bugfix __file: Use chmod after chown/chgrp (Matt Coddington)
+ * Bugfix __user: Correct shadow field in explorer (Matt Coddington)
+ * Bugfix __link: Properly handle existing links (Steven Armstrong)
+ * Bugfix __key_value: More robust implementation (Steven Armstrong)
+ * Bugfix __user: Fix for changing a user's group by name (Matt Coddington)
+ * New Type: __package_pip
+ * Bugfix/Cleanup: Correctly allow Object ID to start and end with /, but
+ not contain //.
+
+2.0.6: 2012-01-28
* Bugfix __apt_ppa:
Also remove the [ppa-name].list file, if empty. (Tim Kersten)
+ * Bugfix __group:
+ Referenced wrong variable name (Matt Coddington)
* Feature __package_apt:
Initial support for virtual packages (Evax Software)
+ * Feature Core: Added new dependency resolver (Steven Armstrong)
+ * Feature Explorer, __package_yum: Support Amazon Linux (Matt Coddington)
* New Type: __rvm (Evax Software)
* New Type: __rvm_gem (Evax Software)
* New Type: __rvm_gemset (Evax Software)
* New Type: __rvm_ruby (Evax Software)
- * New Explorer: runlevel
- * Documentation: Update of reference (environment variables)
- * Feature core: Added new dependency resolver (Steven Armstrong)
2.0.5: 2012-01-18
* Bugfix __key_value: Use correct delimiters
diff --git a/doc/dev/logs/2012-02-08.explorer-depends-on-another-type b/doc/dev/logs/2012-02-08.explorer-depends-on-another-type
new file mode 100644
index 00000000..c76626d5
--- /dev/null
+++ b/doc/dev/logs/2012-02-08.explorer-depends-on-another-type
@@ -0,0 +1,36 @@
+If a type explorer depends on a command that will be generated by another type,
+the operation fails, as can be seen below.
+
+This may be a corner case, but is hapenning with __package_pip and
+__python_virtualenv.
+
+[19:10] brief:cdist% ./bin/cdist config -v loch
+INFO: loch: Running global explorers
+INFO: loch: Running initial manifest /home/users/nico/privat/firmen/local.ch/vcs/cdist/conf/manifest
+INFO: loch: Running object manifests and type explorers
+INFO: loch: Running manifest and explorers for __git/root/shinken
+INFO: loch: Running manifest and explorers for __package_pip/pyro
+/var/lib/cdist/conf/type/__package_pip/explorer/state: line 38: /root/shinken_virtualenv/bin/pip: No such file or directory
+INFO: loch: Running manifest and explorers for __python_virtualenv/root/shinken_virtualenv
+INFO: loch: Running manifest and explorers for __directory/pyro
+INFO: loch: Running manifest and explorers for __directory/root/shinken
+INFO: loch: Running manifest and explorers for __directory/root/shinken_virtualenv
+INFO: loch: Running manifest and explorers for __package/git
+INFO: loch: Running manifest and explorers for __package/python-virtualenv
+INFO: loch: Running manifest and explorers for __package_pacman/git
+INFO: loch: Running manifest and explorers for __package_pacman/python-virtualenv
+INFO: loch: Generating and executing code
+INFO: loch: Generating and executing code for __package_pacman/git
+INFO: loch: Generating and executing code for __package/git
+INFO: loch: Generating and executing code for __directory/root/shinken
+INFO: loch: Generating and executing code for __git/root/shinken
+fatal: write error: No space left on device
+fatal: index-pack failed
+ERROR: loch: Code that raised the error:
+git clone --quiet "git://github.com/naparuba/shinken.git" "/root/shinken"
+
+ERROR: Remote script execution failed: ssh -o User=root -q loch /bin/sh -e /var/lib/cdist/object/__git/root/shinken/.cdist/code-remote
+WARNING: Failed to deploy to the following hosts: loch
+INFO: Total processing time for 1 host(s): 340.62370681762695
+[19:17] brief:cdist% ./bin/cdist config -v loch
+
diff --git a/doc/dev/logs/2012-02-10.object_id-and-slashes b/doc/dev/logs/2012-02-10.object_id-and-slashes
new file mode 100644
index 00000000..de46a1f8
--- /dev/null
+++ b/doc/dev/logs/2012-02-10.object_id-and-slashes
@@ -0,0 +1,18 @@
+__typename /foo/bar # possible, usual use case
+require="__a//b" __typename /foo/bar # possible and happens often for __a/$id in loops
+
+__typename /foo/bar/ # trailing slash will be stripped, can be documented
+
+__typename /foo//bar//baz # // will be converted to / implicitly through fs; error prone; disallow
+
+require="__a//b//c" __typename # // will be converted to / implicitly through fs; error prone; disallow
+
+
+Solution:
+
+ 1) allow require __a//b: type __a, object id /b
+ => strip first slash of object id, as we do in non-dep-mode
+ 2) allow _one_ trailing /: __type /foo/bar/ and require="__foo/abc/"
+ => strip one leading slash of object id
+ 3) disallow // within object id
+ 4) disallow starting or ending / after 1) and 2)
diff --git a/doc/dev/logs/2012-02-13.dependencies b/doc/dev/logs/2012-02-13.dependencies
new file mode 100644
index 00000000..3b0f3f21
--- /dev/null
+++ b/doc/dev/logs/2012-02-13.dependencies
@@ -0,0 +1,23 @@
+possible dependencies:
+
+ - unix pattern __foo/*
+ - object: __foo//bar, __foo/bar
+ - singleton with object_id: __foo/singleton
+ - singleton without object_id: __foo/
+
+solving dependencies:
+
+ solve_dep(object, run_list):
+ - list = [me]
+ - if status == IN_DEPENDENCY:
+ fail: circular dependency
+ - status = IN_DEPENDENCY
+ - create_list_of_deps(object)
+ - try pattern expansion
+ - for each dependency:
+ if object does not exist:
+ fail
+ else:
+ list.append(solve_dep(object, run_list)):
+ - status == IN_LIST
+ - return [me, dependencies [, dependencies of dependencies]]
diff --git a/doc/dev/releasechecklist b/doc/dev/releasechecklist
index cb6d610d..eba81dc0 100755
--- a/doc/dev/releasechecklist
+++ b/doc/dev/releasechecklist
@@ -11,15 +11,25 @@ echo "Testing documentation..."
./build clean && ./build man || exit 1
# get version
-changelog_version=$(head -n1 doc/changelog | sed 's/:.*//')
+changelog_version=$(grep '^[[:digit:]]' doc/changelog | head -n1 | sed 's/:.*//')
#git_version=$(git describe)
lib_version=$(grep ^VERSION lib/cdist/__init__.py | sed -e 's/.*= //' -e 's/"//g')
+# get date
+date_today="$(date +%Y-%m-%d)"
+date_changelog=$(grep '^[[:digit:]]' doc/changelog | head -n1 | sed 's/.*: //')
+
echo "Ensure you fixed/prepared version files: $files"
echo "changelog: $changelog_version"
#echo "git: $git_version"
echo "lib: $lib_version"
+if [ "$date_today" != "$date_changelog" ]; then
+ echo "Messed up date, not releasing:"
+ echo "Changelog: $date_changelog"
+ exit 1
+fi
+
if [ "$lib_version" != "$changelog_version" ]; then
echo "Messed up versions, not releasing"
exit 1
diff --git a/doc/dev/todo/TAKEME b/doc/dev/todo/TAKEME
index abcd5097..b40936f6 100644
--- a/doc/dev/todo/TAKEME
+++ b/doc/dev/todo/TAKEME
@@ -34,7 +34,6 @@ USER INTERFACE
TYPES
------
+- Add testing framework (proposed by Evax Software)
- __user
add option to include --create-home
-- ensure that all types, which support --state support
- present and absent (consistent look and feel)
diff --git a/doc/dev/todo/niconext b/doc/dev/todo/niconext
index 4543b32a..f81c7570 100644
--- a/doc/dev/todo/niconext
+++ b/doc/dev/todo/niconext
@@ -1,9 +1,17 @@
-- __init_script?
- to enable/disable startup of init stuff
- http://linuxhelp.blogspot.com/2006/04/enabling-and-disabling-services-during_01.html
+2.0.8 features / cleanups:
+
+- cleanup object_id handling
+ - have a look at singletons
+
+- remove useless
+ ERROR: monitoring02: Code that raised the error:
+
+- ensure that all types, which support --state support
+ present and absent (consistent look and feel)
+
+--------------------------------------------------------------------------------
- update/create docs
- - document __remote_copy and __remote_exec
- cdist-cache::
How to get use information about the hosts we have been working on [advanced]
- cdist-scaling-tuning::
@@ -17,3 +25,4 @@
- exec flag is not true for manifest anymore
- SSH HINTS - ssh agent
+
diff --git a/doc/man/cdist-reference.text.sh b/doc/man/cdist-reference.text.sh
index c6016333..abef255f 100755
--- a/doc/man/cdist-reference.text.sh
+++ b/doc/man/cdist-reference.text.sh
@@ -49,10 +49,10 @@ The following global explorers are available:
eof
(
- cd ../../conf/explorer
- for explorer in *; do
- echo "- $explorer"
- done
+ cd ../../conf/explorer
+ for explorer in *; do
+ echo "- $explorer"
+ done
)
cat << eof
@@ -62,77 +62,77 @@ PATHS
If not specified otherwise, all paths are relative to the checkout directory.
conf/::
- Contains the (static) configuration like manifests, types and explorers.
+ Contains the (static) configuration like manifests, types and explorers.
conf/manifest/init::
- This is the central entry point used by cdist-manifest-init(1).
- It is an executable (+x bit set) shell script that can use
- values from the explorers to decide which configuration to create
- for the specified target host.
- It should be primary used to define mapping from configurations to hosts.
+ This is the central entry point used by cdist-manifest-init(1).
+ It is an executable (+x bit set) shell script that can use
+ values from the explorers to decide which configuration to create
+ for the specified target host.
+ It should be primary used to define mapping from configurations to hosts.
conf/manifest/*::
- All other files in this directory are not directly used by cdist, but you
- can seperate configuration mappings, if you have a lot of code in the
- manifest/init file. This may also be helpful to have different admins
- maintain different groups of hosts.
+ All other files in this directory are not directly used by cdist, but you
+ can seperate configuration mappings, if you have a lot of code in the
+ manifest/init file. This may also be helpful to have different admins
+ maintain different groups of hosts.
conf/explorer/::
- Contains explorers to be run on the target hosts, see cdist-explorer(7).
+ Contains explorers to be run on the target hosts, see cdist-explorer(7).
conf/type/::
- Contains all available types, which are used to provide
- some kind of functionality. See cdist-type(7).
+ Contains all available types, which are used to provide
+ some kind of functionality. See cdist-type(7).
conf/type//::
- Home of the type .
+ Home of the type .
- This directory is referenced by the variable __type (see below).
+ This directory is referenced by the variable __type (see below).
conf/type//man.text::
- Manpage in Asciidoc format (required for inclusion into upstream)
+ Manpage in Asciidoc format (required for inclusion into upstream)
conf/type//manifest::
- Used to generate additional objects from a type.
+ Used to generate additional objects from a type.
conf/type//gencode-local::
- Used to generate code to be executed on the server.
+ Used to generate code to be executed on the server.
conf/type//gencode-remote::
- Used to generate code to be executed on the client.
+ Used to generate code to be executed on the client.
conf/type//parameters/required::
- Parameters required by type, \n seperated list.
+ Parameters required by type, \n seperated list.
conf/type//parameters/optional::
- Parameters optionally accepted by type, \n seperated list.
+ Parameters optionally accepted by type, \n seperated list.
conf/type//explorer::
- Location of the type specific explorers.
- This directory is referenced by the variable __type_explorer (see below).
- See cdist-explorer(7).
+ Location of the type specific explorers.
+ This directory is referenced by the variable __type_explorer (see below).
+ See cdist-explorer(7).
out/::
- This directory contains output of cdist and is usually located
- in a temporary directory and thus will be removed after the run.
- This directory is referenced by the variable __global (see below).
+ This directory contains output of cdist and is usually located
+ in a temporary directory and thus will be removed after the run.
+ This directory is referenced by the variable __global (see below).
out/explorer::
- Output of general explorers.
+ Output of general explorers.
out/object::
- Objects created for the host.
+ Objects created for the host.
out/object/