Merge branch 'master' of git://git.schottelius.org/cdist

This commit is contained in:
Daniel Roth 2011-03-14 13:11:14 +01:00
commit ce05cb2e92
22 changed files with 385 additions and 29 deletions

4
.gitignore vendored
View file

@ -1,4 +1,8 @@
# -vim
.*.swp
# Ignore generated manpages
doc/man/*.[1-9]
doc/man/.marker
doc/man/man*/
conf/type/*/*.7

View file

@ -1,5 +1,20 @@
[[!meta title="cdist - configuration management"]]
.. . .x+=:. s
dF @88> z` ^% :8
'88bu. %8P . <k .88
. '*88888bu . .@8Ned8" :888ooo
.udR88N ^"*8888N .@88u .@^%8888" -*8888888
<888'888k beWE "888L ''888E` x88: `)8b. 8888
9888 'Y" 888E 888E 888E 8888N=*8888 8888
9888 888E 888E 888E %8" R88 8888
9888 888E 888F 888E @8Wou 9% .8888Lu=
?8888u../ .888N..888 888& .888888P` ^%888*
"8888P' `"888*"" R888" ` ^"F 'Y"
"P' "" ""
[[!toc levels=2]]
## Introduction
@ -79,7 +94,7 @@ To install cdist, execute the following commands:
cd cdist
export PATH=$PATH:$(pwd -P)/bin
# If you want the manpages
# If you want the manpages (requires asciidoc to be installed)
make man
export MANPATH=$MANPATH:$(pwd -P)/doc/man
@ -129,3 +144,28 @@ You can join the development ***IRC channel***
Bug reports, questions, patches, etc. should be send to the
[cdist mailing list](http://l.schottelius.org/mailman/listinfo/cdist).
## Used by
If you're using cdist, feel free to send a report to the mailing list.
Interesting information are for instance
* Which services do you manage?
* How many machines do you manage?
* What are the pros/cons you see in cdist?
* General comments/critics
### Nico Schottelius, Systems Group ETH Zurich
Yes, I'm actually eating my own dogfood and currently managing
* [plone](http://plone.org/) (cms)
* [moinmoin](http://moinmo.in/) (wiki)
* [apache](http://httpd.apache.org/) (webserver)
* [kerberos (mit)](http://web.mit.edu/kerberos/) (authentication)
* [ircd-hybrid](http://www.ircd-hybrid.org/) (chat)
* [stunnel](http://stunnel.mirt.net/) (SSL tunnel)
with cdist on a total of **3** production servers of the
[Systems Group](http://www.systems.ethz.ch) at the
[ETH Zurich](http://www.ethz.ch).

View file

@ -19,7 +19,9 @@
#
#
# Fail if something bogus is going on and export all variables
__cdist_version="1.0.3"
# Fail if something bogus is going on
set -u
################################################################################
@ -31,8 +33,6 @@ __cdist_abs_mydir="$(cd "$__cdist_mydir" && pwd -P)"
__cdist_myname=${0##*/};
__cdist_abs_myname="$__cdist_abs_mydir/$__cdist_myname"
: ${__cdist_version:="$(cd "$__cdist_abs_mydir/.." && git describe)"}
################################################################################
# Names / Constants
#

33
bin/cdist-env Executable file
View file

@ -0,0 +1,33 @@
#!/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/>.
#
#
# Setup environment for use with cdist
#
. cdist-config
[ $# -eq 0 ] || __cdist_usage "no arguments"
# Allow access to unset variables like PATH and MANPATH
set +u
echo export PATH=$__cdist_abs_mydir:$PATH
cd "$__cdist_abs_mydir/../doc/man"
echo export MANPATH=$(pwd -P):$MANPATH

View file

@ -0,0 +1,38 @@
#!/bin/sh
#
# 2010-2011 Daniel Roth (dani-cdist@d-roth.li)
#
# 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/>.
#
#
if [ -f "$__object/parameter/file" ]; then
file=$(cat "$__object/parameter/file")
else
file="/$__object_id"
fi
regex=$(cat "$__object/parameter/line")
if [ -f "$file" ]; then
grep -q "^$regex\$" "$file"
if [ $? -eq 1 ]; then
echo "NOTFOUND"
else
echo "FOUND"
fi
else
echo "NOTFOUND"
fi

View file

@ -0,0 +1,33 @@
#!/bin/sh
#
# 2010-2011 Daniel Roth (dani-cdist@d-roth.li)
#
# 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/>.
#
#
if [ -f "$__object/parameter/file" ]; then
file=$(cat "$__object/parameter/file")
else
file="/$__object_id"
fi
result=$(cat "$__object/explorer/findline")
if [ "$result" = "NOTFOUND" ]; then
line=$(cat "$__object/parameter/line")
echo "echo $line >> $file"
fi

View file

@ -0,0 +1 @@
file

View file

@ -0,0 +1 @@
line

View file

@ -79,6 +79,9 @@ case "$type" in
# Probably describe it in cdist-quickstart...
scp "$source" "root@${__target_host}:${destination}"
fi
else
echo "Source \"$source\" does not exist." >&2
exit 1
fi
else
if [ no = "$(cat "$__object/explorer/exists")" ]; then

View file

@ -1 +0,0 @@
Manage /etc/issue

View file

@ -0,0 +1,41 @@
cdist-type__issue(7)
===================
Nico Schottelius <nico-cdist--@--schottelius.org>
NAME
----
cdist-type__issue - Manage issue
DESCRIPTION
-----------
This cdist type allows you to easily setup /etc/issue.
REQUIRED PARAMETERS
-------------------
None.
OPTIONAL PARAMETERS
-------------------
None
EXAMPLES
--------
--------------------------------------------------------------------------------
__issue
--------------------------------------------------------------------------------
SEE ALSO
--------
- cdist-type(7)
COPYING
-------
Copyright \(C) 2011 Nico Schottelius. Free use of this software is
granted under the terms of the GNU General Public License version 3 (GPLv3).

View file

@ -0,0 +1,16 @@
.. . .x+=:. s
dF @88> z` ^% :8
'88bu. %8P . <k .88
. '*88888bu . .@8Ned8" :888ooo
.udR88N ^"*8888N .@88u .@^%8888" -*8888888
<888'888k beWE "888L ''888E` x88: `)8b. 8888
9888 'Y" 888E 888E 888E 8888N=*8888 8888
9888 888E 888E 888E %8" R88 8888
9888 888E 888F 888E @8Wou 9% .8888Lu=
?8888u../ .888N..888 888& .888888P` ^%888*
"8888P' `"888*"" R888" ` ^"F 'Y"
"P' "" ""
Welcome to a cdist automated system!

48
conf/type/__motd/man.text Normal file
View file

@ -0,0 +1,48 @@
cdist-type__motd(7)
===================
Nico Schottelius <nico-cdist--@--schottelius.org>
NAME
----
cdist-type__motd - Manage message of the day
DESCRIPTION
-----------
This cdist type allows you to easily setup /etc/motd.
REQUIRED PARAMETERS
-------------------
None.
OPTIONAL PARAMETERS
-------------------
source::
If supplied, copy this file from the host running cdist to the target.
If not supplied, a default message will be placed onto the target.
EXAMPLES
--------
--------------------------------------------------------------------------------
# Use cdist defaults
__motd
# Supply source file from a different type
__file --source "$__type/files/my-motd"
--------------------------------------------------------------------------------
SEE ALSO
--------
- cdist-type(7)
COPYING
-------
Copyright \(C) 2011 Nico Schottelius. Free use of this software is
granted under the terms of the GNU General Public License version 3 (GPLv3).

31
conf/type/__motd/manifest Executable file
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/>.
#
#
destination=/etc/motd
# Select motd source
if [ -f "$__object/parameter/source" ]; then
source="$(cat "$__object/parameter/source")"
else
source="$__type/files/motd"
fi
__file "$destination" --source "$source" --type file

View file

@ -1,7 +1,12 @@
1.0.3: upcoming
1.0.4:
* New type __motd
* New type __addifnosuchline
* Document type __issue
1.0.3: 2011-03-11
* Update regexp used for sane characters
* Allow types without parameters
* Allow type to be singleton (DOCUMENTATION MISSING)
* Allow type to be singleton
* Type __file learned --type symlink
1.0.2: 2011-03-09

2
doc/dev/todo/daninext Normal file
View file

@ -0,0 +1,2 @@
file-edit
- add_line_to_file_if_not_existing

View file

@ -1,3 +0,0 @@
- Support singletons (see types/issue for a good reason)
- add documentation!

View file

@ -1,25 +1,32 @@
Type handler:
- add dependency parameters to core available for every type
--requires
--excludes?
Stage 5 (code execution):
- check return codes
- abort on first error?
- dependencies
Dependencies:
- Add meta parameters like --requires --excludes --depends?
- Build dependency tree
- Exit on any error
- Check return codes
Types to be written/extended:
- __ssh-keys (host/user)
- __service
- __user
- __file_edit
- add_line_to_file_if_not_existing
- delete_line_from_file
- regexp replace (can probably cover all?)
- __file:
- template == [shell script] stdout
- cron
- __file: think about splitting
__file
source
mode
owner
__directory
parents
mode
owner
__link
type symbolic | hard
- __issue: add --source
Documentation:
- Describe Multi master setups
@ -58,9 +65,3 @@ Documentation:
- cdist-type-build-emulation
- cdist-type-emulator
- Ensure html output of manpages are published on the web
--------------------------------------------------------------------------------
Fix:
Running initial manifest for sgv-wiki-01 ...
/tmp/cdist.VfhjaH8LP3GE/out/type_bin/__ethz_systems_wiki: Zeile 87: /home/users/nico/privat/firmen/ethz/vcs/cdist/conf/type/__ethz_systems_wiki/parameter/required: Datei oder Verzeichnis nicht gefunden
/tmp/cdist.VfhjaH8LP3GE/out/type_bin/__ethz_systems_wiki: Zeile 94: /home/users/nico/privat/firmen/ethz/vcs/cdist/conf/type/__ethz_systems_wiki/parameter/optional: Datei oder Verzeichnis nicht gefunden

View file

@ -10,7 +10,9 @@ cdist-type - Functionality bundled
SYNOPSIS
--------
Other languages name this module or class
__TYPE ID --parameter value [--parameter value ...]
__TYPE --parameter value [--parameter value ...] (for singletons)
DESCRIPTION
@ -37,7 +39,23 @@ Internally cdist-type-emulator(1) will be called from cdist-manifest-run(1) to
save the given parameters into a cconfig database, so they can be accessed by
the manifest and gencode scripts of the type (see below).
A list of supported types can be found in the cdist-type-listing(7) manpage.
A list of supported types can be found in the cdist-reference(7) manpage.
SINGLETON TYPES
---------------
If a type is flagged as a singleton, it may me used only once. This
is useful for types which can be used only once on a system. If a type
can only be used once, it does not take an
Example:
--------------------------------------------------------------------------------
# __issue type manages /etc/issue
__issue
# Probably your own type - singletons may use parameters
__myfancysingleton --colour green
--------------------------------------------------------------------------------
HOW TO WRITE A NEW TYPE
@ -46,6 +64,7 @@ A type consists of
- parameter (optional)
- manifest (optional)
- singleton (optional)
- explorer (optional)
- gencode (optional)
@ -98,6 +117,20 @@ Always ensure the manifest is executable, otherwise cdist will not be able
to execute it.
SINGLETON - ONLY INSTANCE ONLY
------------------------------
If you want to ensure that a type can only be used once per target, you can
mark it as a singleton: Just create the (empty) file "singleton" in your type
directory. This will also change the way your type must be called:
--------------------------------------------------------------------------------
__YOURTYPE --parameter value
--------------------------------------------------------------------------------
As you can see, the ID is omitted, because it does not make any sense, if your
type can be used only once.
THE TYPE EXPLORERS
------------------
If a type needs to explore specific details, it can provide type specific

View file

@ -0,0 +1,30 @@
cdist-type-addifnosuchline(1)
======================
Daniel Roth <dani-cdist--@--d-roth.li>
NAME
----
cdist-type-addifnosuchline
SYNOPSIS
--------
cdist-type-addifnosuchline Add if no such line
DESCRIPTION
-----------
cdist-type-addifnosuchline can be used to check a file for existence of a
specific line and adding that if not found
SEE ALSO
--------
cdist(7)
COPYING
-------
Copyright \(C) 2011 Daniel Roth. Free use of this software is
granted under the terms of the GNU General Public License version 3 (GPLv3).