Merge remote-tracking branch 'telmich/master'

This commit is contained in:
Steven Armstrong 2011-10-19 15:11:33 +02:00
commit 9f21273f4e
15 changed files with 227 additions and 87 deletions

View file

@ -20,26 +20,10 @@
#
#
import argparse
import logging
import multiprocessing
import os
import re
import sys
import time
log = logging.getLogger("cdist")
# Ensure our /lib/ is included into PYTHON_PATH
sys.path.insert(0, os.path.abspath(
os.path.join(os.path.dirname(os.path.realpath(__file__)), '../lib')))
import cdist
TYPE_PREFIX = "__"
def commandline():
"""Parse command line"""
import argparse
import cdist.banner
import cdist.config
import cdist.install
@ -117,6 +101,9 @@ def install(args):
def configinstall(args, mode):
"""Configure or install remote system"""
import multiprocessing
import time
try:
process = {}
failed_hosts = []
@ -203,9 +190,22 @@ def emulator():
if __name__ == "__main__":
try:
import logging
import os
import re
import sys
import cdist
log = logging.getLogger("cdist")
# Ensure our /lib/ is included into PYTHON_PATH
sys.path.insert(0, os.path.abspath(
os.path.join(os.path.dirname(os.path.realpath(__file__)), '../lib')))
logging.basicConfig(format='%(levelname)s: %(message)s')
if re.match(TYPE_PREFIX, os.path.basename(sys.argv[0])):
if re.match("__", os.path.basename(sys.argv[0])):
emulator()
else:
commandline()

3
build
View file

@ -144,8 +144,9 @@ case "$1" in
echo ''
echo 'Here are the possible targets:'
echo ''
echo ' man: Build manpages (requires Asciidoc)'
echo ' clean: Remove build stuff'
echo ' man: Build manpages (requires Asciidoc)'
echo ' test: Run tests'
echo ''
echo ''
echo "Unknown target, \"$1\"" >&2

View file

@ -27,13 +27,6 @@ else
name="$__object_id"
fi
# Check for preseeding and add preseed as here document
if [ -f "$__object/parameter/preseed" ]; then
echo "debconf-set-selections << __file-eof"
cat "$(cat "$__object/parameter/preseed")"
echo "__file-eof"
fi
state="$(cat "$__object/parameter/state")"
is_installed="$(grep "^Status: install ok installed" "$__object/explorer/pkg_status" || true)"

View file

@ -1,3 +1,6 @@
2.0.4:
* Bugfix core: Remove traceback when sending SIGINT (aka Ctrl-C)
2.0.3: 2011-10-18
* Improved logging, added --verbose, by more quiet by default
* Bugfix __user: Correct quoting (Steven Armstrong)

View file

@ -2,60 +2,6 @@
- sanity checks: implement tests
stage_run()
- ensure that for every object in
cdist.core.Object.list_objects() is passed into
self.object_run()
- instantiate + overwrite + test
object_prepare():
- calls (in this order):
self.run_type_explorer(cdist_object)
self.run_type_manifest(cdist_object)
cdist_object.prepared = True
- object is prepared after function call
stage_prepare():
- calls (in this order):
self.link_emulator()
self.run_global_explorers()
self.run_initial_manifest()
- ensure that all objects are created :-)
- as defined in inital manifest + type manifests
deploy_to()
- ensure self.stage_prepare() and self.stage_run() are
run. [ORDER]
- instantiate + overwrite + test
deploy_and_cleanup()
- ensure self.deploy_to() + self.cleanup() are are run
run. [ORDER]
- instantiate + overwrite + test
transfer_object_parameter()
- check that object parameters are transferred
- paths are setup correctly
- test via mock of remote_mkdir and transfer_path
- ensure self.remote_mkdir, self.transfer_path are run. [ORDER]
- instantiate + overwrite + test
transfer_global_explorers()
- paths are setup correctly
- test via mock of self.remote_mkdir() and self.transfer_path()
- ensure self.remote_mkdir, self.transfer_path are run. [ORDER]
- instantiate + overwrite + test
transfer_type_explorers():
- Explorers are not transferred twice
- paths are setup correctly
- test via mock of self.remote_mkdir() and self.transfer_path()
- Explorers are transferred
- test via mock of self.remote_mkdir() and self.transfer_path()
--------------------------------------------------------------------------------
- insert prefix into logger to distinguish between modules

View file

@ -133,7 +133,6 @@ out/object/<object>/explorers::
tmp_dir::
A tempdir and a tempfile is used by cdist internally,
which will be removed when the scripts end automatically.
See cdist-config(1).
TYPES
-----
@ -166,11 +165,6 @@ changed::
ENVIRONMENT VARIABLES
---------------------
__debug::
If this variable is setup, cdist runs in debug mode.
You can use this information, to only output stuff in debug
mode as well.
Available for: initial manifest, type manifest, gencode, code
__explorer::
Directory that contains all global explorers.
Available for: explorer
@ -186,6 +180,7 @@ __object::
__object_id::
The type unique object id.
Available for: type manifest, type explorer, type gencode
__self::
__object_fq::
The full qualified name of the current object.
Available for: type manifest, type explorer, type gencode

View file

@ -6,6 +6,101 @@ Nico Schottelius <nico-cdist--@--schottelius.org>
NAME
----
cdist-tutorial - a guided introduction into cdist
YOUR FIRST CONFIGURATION
------------------------
DEFINE STATE IN THE INITAL MANIFEST
-----------------------------------
The initial manifest is used to map
configurations to a host.
USING SOME BASIC TYPES
----------------------
what is a type, how to use it,
CREATING YOUR FIRST OWN TYPE
----------------------------
<with object id? or signleton here already>
USE A TYPE TO BUNDLE FUNCTIONALITY
----------------------------------
USING EXPLORERS
---------------
global, type explorer
DEBUGGING YOUR TYPES
--------------------
__debug::
If this variable is setup, cdist runs in debug mode.
You can use this information, to only output stuff in debug
mode as well.
Available for: initial manifest, type manifest, gencode, code
INTRODUCTION

View file

@ -0,0 +1,2 @@
Configure sudoers file to be included. Different types may do so,
this one simply uses the "nico" file to store the configuration.

View file

@ -0,0 +1,13 @@
#
# Cdist managed file
#
# Personal one: nico, shared one: lyni
User_Alias NICO = nico, lyni
Defaults timestamp_timeout=5
Defaults !tty_tickets
# Give out permissions
NICO ALL=(ALL) ALL
NICO ALL=(ALL) NOPASSWD: /usr/sbin/pm-suspend

View file

@ -0,0 +1,30 @@
#!/bin/sh
#
# 2011 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/>.
#
#
destination=/etc/sudoers.d/nico
source="$__type/files/sudo-nico"
__package sudo --state installed
__directory /etc/sudoers.d --parents yes
require="__directory/etc/sudoers.d" \
__file "$destination" --source "$source" --mode 0440

View file

@ -0,0 +1,31 @@
#!/bin/sh
#
# 2011 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/>.
#
#
# USEFUL DESCRIPTION
#
#
# This file should generate code on stdout, which will be collected by cdist
# and run on the target.
#
# To tell cdist to make use of it, you need to make it executable (chmod +x)
#
#

View file

@ -0,0 +1,31 @@
#!/bin/sh
#
# 2011 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/>.
#
#
# USEFUL DESCRIPTION
#
#
# This is the manifest, which can be used to create other objects like this:
# __file /path/to/destination --source /from/where/
#
# To tell cdist to make use of it, you need to make it executable (chmod +x)
#
#