diff --git a/bin/build-helper b/bin/build-helper index 1de2eb94..93401d3b 100755 --- a/bin/build-helper +++ b/bin/build-helper @@ -175,7 +175,7 @@ eof release-git-tag) target_version=$($0 changelog-version) - if git rev-parse --verify refs/tags/$target_version; then + if git rev-parse --verify refs/tags/$target_version 2>/dev/null; then echo "Tag for $target_version exists, aborting" exit 1 fi diff --git a/cdist/conf/type/__rbenv/man.text b/cdist/conf/type/__rbenv/man.text new file mode 100644 index 00000000..c6ed5de2 --- /dev/null +++ b/cdist/conf/type/__rbenv/man.text @@ -0,0 +1,49 @@ +cdist-type__rbenv(7) +==================== +Nico Schottelius + + +NAME +---- +cdist-type__rbenv - Manage rbenv installation + + +DESCRIPTION +----------- +This cdist type allows you to manage rbenv installations. +It also installs ruby-build. + + +OPTIONAL PARAMETERS +------------------- +state:: + Either "present" or "absent", defaults to "present" + +owner:: + Which user should own the rbenv installation, defaults to root + + +EXAMPLES +-------- + +-------------------------------------------------------------------------------- +# Install rbenv including ruby-build for nico +__rbenv /home/nico + +# Install rbenv including ruby-build for nico +__rbenv /home/nico --owner nico + +# Bastian does not need rbenv anymore, he began to code C99 +__rbenv /home/bastian --state absent +-------------------------------------------------------------------------------- + + +SEE ALSO +-------- +- cdist-type(7) + + +COPYING +------- +Copyright \(C) 2012-2014 Nico Schottelius. 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/__rbenv/manifest b/cdist/conf/type/__rbenv/manifest new file mode 100644 index 00000000..767abdba --- /dev/null +++ b/cdist/conf/type/__rbenv/manifest @@ -0,0 +1,38 @@ +#!/bin/sh +# +# 2012-2014 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 . +# +# + +homedir="$__object_id" + +state_should="$(cat "$__object/parameter/state")" +owner="$(cat "$__object/parameter/owner")" + +rbenvdir="$homedir/.rbenv" +rubybuilddir="$rbenvdir/plugins/ruby-build" + +__git "$rbenvdir" \ + --source git://github.com/sstephenson/rbenv.git \ + --owner "$owner" \ + --state "$state_should" + +require="__git/$rbenvdir" __git "$rubybuilddir" \ + --source git://github.com/sstephenson/ruby-build.git \ + --owner "$owner" \ + --state "$state_should" diff --git a/cdist/conf/type/__rbenv/parameter/default/state b/cdist/conf/type/__rbenv/parameter/default/state new file mode 100644 index 00000000..e7f6134f --- /dev/null +++ b/cdist/conf/type/__rbenv/parameter/default/state @@ -0,0 +1 @@ +present diff --git a/cdist/conf/type/__rbenv/parameter/optional b/cdist/conf/type/__rbenv/parameter/optional new file mode 100644 index 00000000..ff72b5c7 --- /dev/null +++ b/cdist/conf/type/__rbenv/parameter/optional @@ -0,0 +1 @@ +state diff --git a/cdist/conf/type/__rbenv/parameter/required b/cdist/conf/type/__rbenv/parameter/required new file mode 100644 index 00000000..7ee3bde8 --- /dev/null +++ b/cdist/conf/type/__rbenv/parameter/required @@ -0,0 +1 @@ +owner diff --git a/cdist/conf/type/__ssh_authorized_keys/manifest b/cdist/conf/type/__ssh_authorized_keys/manifest index efcd2d7a..1c9df208 100755 --- a/cdist/conf/type/__ssh_authorized_keys/manifest +++ b/cdist/conf/type/__ssh_authorized_keys/manifest @@ -58,6 +58,7 @@ if [ ! -f "$__object/parameter/noparent" -o ! -f "$__object/parameter/nofile" ]; fi # Remove legacy blocks created by old versions of this type +# FIXME: remove me in 3.2+ __block "$__object_name" \ --file "$file" \ --prefix "#cdist:$__object_name" \ diff --git a/cdist/core/code.py b/cdist/core/code.py index f128697f..5374bcdf 100644 --- a/cdist/core/code.py +++ b/cdist/core/code.py @@ -2,6 +2,7 @@ # # 2011 Steven Armstrong (steven-cdist at armstrong.cc) # 2011-2013 Nico Schottelius (nico-cdist at schottelius.org) +# 2014 Daniel Heule (hda at sfs.biz) # # This file is part of cdist. # @@ -123,15 +124,27 @@ class Code(object): self.remote.mkdir(destination) self.remote.transfer(source, destination) - def _run_code(self, cdist_object, which): + def _run_code(self, cdist_object, which, env=None): which_exec = getattr(self, which) script = os.path.join(which_exec.object_path, getattr(cdist_object, 'code_%s_path' % which)) - return which_exec.run_script(script) + return which_exec.run_script(script, env=env) def run_code_local(self, cdist_object): """Run the code-local script for the given cdist object.""" - return self._run_code(cdist_object, 'local') + # Put some env vars, to allow read only access to the parameters over $__object + env = os.environ.copy() + env.update(self.env) + env.update({ + '__object': cdist_object.absolute_path, + '__object_id': cdist_object.object_id, + }) + return self._run_code(cdist_object, 'local', env=env) def run_code_remote(self, cdist_object): """Run the code-remote script for the given cdist object on the remote side.""" - return self._run_code(cdist_object, 'remote') + # Put some env vars, to allow read only access to the parameters over $__object which is already on the remote side + env = { + '__object': os.path.join(self.remote.object_path, cdist_object.path), + '__object_id': cdist_object.object_id, + } + return self._run_code(cdist_object, 'remote', env=env) diff --git a/docs/changelog b/docs/changelog index e7ac935d..7db43304 100644 --- a/docs/changelog +++ b/docs/changelog @@ -5,14 +5,18 @@ Changelog * Exception: No braces means author == Nico Schottelius -next: - * Type __git: Pass onwer/group/mode values to __directory - * Type __ssh_authorized_keys: Allow managing existing keys (Steven Armstrong) - * Type __iptable_rule: Fix example documentation (Antoine Catton) - * Type __file: Enhance OpenBSD Support (og) - * Type __package_pkg_openbsd: Allow to change PKG_PATH (og) - * Type __user: Enhance OpenBSD Support (og) +3.1.1: + * Core: Make __object and __object available to code (Daniel Heule) +3.1.0: 2014-03-19 + * New Type: __rbenv + * Type __file: Enhance OpenBSD Support (og) + * Type __git: Pass onwer/group/mode values to __directory + * Type __iptable_rule: Fix example documentation (Antoine Catton) + * Type __key_value: Add messaging support + * Type __package_pkg_openbsd: Allow to change PKG_PATH (og) + * Type __ssh_authorized_keys: Allow managing existing keys (Steven Armstrong) + * Type __user: Enhance OpenBSD Support (og) 3.0.9: 2014-02-14 * Core: Ignore order dependencies if override is set (Daniel Heule) diff --git a/docs/dev/logs/2013-01-03.dependency-issue b/docs/dev/logs/2013-01-03.dependency-issue new file mode 100644 index 00000000..91db9425 --- /dev/null +++ b/docs/dev/logs/2013-01-03.dependency-issue @@ -0,0 +1,27 @@ + +Problem shown by using __rbenv: + +__rbenv/nicotest + __git /home/nico/.rbenv + __package git + __directory /home/nico/.rbenv + + require="__git/home/nico/.rbenv" + __git /home/nico/.rbenv/plugins/ruby-build + __package git + __directory /home/nico/.rbenv/plugins/ruby-build + + +1) if children do NOT automatically depend on their parents requiremnts + + __directory /home/nico/.rbenv/plugins/ruby-build fails: + because __directory /home/nico/.rbenv/plugins is created by + __git /home/nico/.rbenv, but __directory /home/nico/.rbenv/plugins/ruby-build + does not depend on __git /home/nico/.rbenv + +2) if children DO automatically depend on their parents requiremnts + __package git from __git /home/nico/.rbenv/plugins/ruby-build depends on __git /home/nico/.rbenv. + + __git /home/nico/.rbenv depends on __package git (via autorequire) + + => circular dependency, they depend on each other diff --git a/docs/man/cdist-reference.text.sh b/docs/man/cdist-reference.text.sh index 62614c55..cff0f9c7 100755 --- a/docs/man/cdist-reference.text.sh +++ b/docs/man/cdist-reference.text.sh @@ -1,6 +1,7 @@ #!/bin/sh # # 2010-2013 Nico Schottelius (nico-cdist at schottelius.org) +# 2014 Daniel Heule (hda at sfs.biz) # # This file is part of cdist. # @@ -209,10 +210,10 @@ __messages_out:: Available for: initial manifest, type manifest, type gencode __object:: Directory that contains the current object. - Available for: type manifest, type explorer, type gencode + Available for: type manifest, type explorer, type gencode and code scripts __object_id:: The type unique object id. - Available for: type manifest, type explorer, type gencode + Available for: type manifest, type explorer, type gencode and code scripts Note: The leading and the trailing "/" will always be stripped (caused by the filesystem database and ensured by the core). Note: Double slashes ("//") will not be fixed and result in an error. diff --git a/docs/man/man7/cdist-type.text b/docs/man/man7/cdist-type.text index 8415f991..06026542 100644 --- a/docs/man/man7/cdist-type.text +++ b/docs/man/man7/cdist-type.text @@ -252,6 +252,27 @@ echo "touch /etc/cdist-configured" -------------------------------------------------------------------------------- +VARIABLE ACCESS FROM THE GENERATED SCRIPTS +------------------------------------------ +In the generated scripts, you have access to the following cdist variables + +- __object +- __object_id + +but only for read operations, means there is no back copy of this +files after the script execution. + +So when you generate a script with the following content, it will work: + +-------------------------------------------------------------------------------- +if [ -f "$__object/parameter/name" ]; then + name="$(cat "$__object/parameter/name")" +else + name="$__object_id" +fi +-------------------------------------------------------------------------------- + + HINTS FOR TYPEWRITERS ---------------------- It must be assumed that the target is pretty dumb and thus does not have high diff --git a/docs/web/cdist/update.mdwn b/docs/web/cdist/update.mdwn index 2e3e9b92..28f41da7 100644 --- a/docs/web/cdist/update.mdwn +++ b/docs/web/cdist/update.mdwn @@ -55,6 +55,11 @@ To upgrade to the lastet version do ## General Update Instructions +### Updating from 3.0 to 3.1 + +The type **\_\_ssh_authorized_keys** now also manages existing keys, +not only the ones added by cdist. + ### Updating from 2.3 to 3.0 The **changed** attribute of objects has been removed.