forked from ungleich-public/cdist
Merge branch 'master' of https://github.com/telmich/cdist into bugfix_type__key_value
New functionality for remote __object is needed
This commit is contained in:
commit
807e2902ea
13 changed files with 176 additions and 14 deletions
|
@ -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
|
||||
|
|
49
cdist/conf/type/__rbenv/man.text
Normal file
49
cdist/conf/type/__rbenv/man.text
Normal file
|
@ -0,0 +1,49 @@
|
|||
cdist-type__rbenv(7)
|
||||
====================
|
||||
Nico Schottelius <nico-cdist--@--schottelius.org>
|
||||
|
||||
|
||||
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).
|
38
cdist/conf/type/__rbenv/manifest
Normal file
38
cdist/conf/type/__rbenv/manifest
Normal file
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
#
|
||||
|
||||
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"
|
1
cdist/conf/type/__rbenv/parameter/default/state
Normal file
1
cdist/conf/type/__rbenv/parameter/default/state
Normal file
|
@ -0,0 +1 @@
|
|||
present
|
1
cdist/conf/type/__rbenv/parameter/optional
Normal file
1
cdist/conf/type/__rbenv/parameter/optional
Normal file
|
@ -0,0 +1 @@
|
|||
state
|
1
cdist/conf/type/__rbenv/parameter/required
Normal file
1
cdist/conf/type/__rbenv/parameter/required
Normal file
|
@ -0,0 +1 @@
|
|||
owner
|
|
@ -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" \
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
27
docs/dev/logs/2013-01-03.dependency-issue
Normal file
27
docs/dev/logs/2013-01-03.dependency-issue
Normal file
|
@ -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
|
|
@ -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.
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in a new issue