diff --git a/Makefile b/Makefile index a6d78aeb..3842e47f 100644 --- a/Makefile +++ b/Makefile @@ -8,22 +8,19 @@ A2X=a2x -f manpage --no-xmllint WEBDIR=$$HOME/niconetz WEBPAGE=software/cdist.mdwn +# Documentation MANDIR=doc/man -# Unchecked -MANSRC=$(MANDIR)/cdist-config-layout.text \ - $(MANDIR)/cdist-config.text \ - $(MANDIR)/cdist-quickstart.text \ - $(MANDIR)/cdist-stages.text \ - $(MANDIR)/cdist-terms.text \ - -# Clean documentation MANGENERATED=$(MANDIR)/cdist-reference.text MANSRC=$(MANDIR)/cdist.text \ $(MANDIR)/cdist-bin-transfer.text \ + $(MANDIR)/cdist-config.text \ + $(MANDIR)/cdist-dir.text \ + $(MANDIR)/cdist-env.text \ $(MANDIR)/cdist-deploy-to.text \ $(MANDIR)/cdist-explorer.text \ $(MANDIR)/cdist-manifest.text \ + $(MANDIR)/cdist-quickstart.text \ $(MANDIR)/cdist-stages.text \ $(MANDIR)/cdist-type.text \ $(MANDIR)/cdist-type-template.text \ @@ -39,7 +36,7 @@ all: @echo '' @echo 'Here are the possible targets:' @echo '' - @echo ' man: Build manpages' + @echo ' man: Build manpages (requires Asciidoc (a2x binary))' @echo ' clean: Remove build stuff' @echo '' @echo '' @@ -89,9 +86,10 @@ test: .rsync nicosc@ru3.inf.ethz.ch:cdist web: - cp REAL_README $(WEBDIR)/$(WEBPAGE) + cp README $(WEBDIR)/$(WEBPAGE) cd $(WEBDIR) && git commit -m "cdist update" $(WEBPAGE) cd $(WEBDIR) && make pub pub: git push --mirror + git push --mirror github diff --git a/README b/README deleted file mode 120000 index ace36209..00000000 --- a/README +++ /dev/null @@ -1 +0,0 @@ -REAL_README \ No newline at end of file diff --git a/README b/README new file mode 100644 index 00000000..dbf3d89a --- /dev/null +++ b/README @@ -0,0 +1,198 @@ +[[!meta title="cdist - configuration management"]] + + + .. . .x+=:. s + dF @88> z` ^% :8 + '88bu. %8P . origin/ + + # Stay on version 1.1 + git checkout -b 1.1 origin/1.1 + +### Mirrors + + * git://github.com/telmich/cdist.git ([github](https://github.com/telmich/cdist)) + * git://git.sans.ethz.ch/cdist ([sans](http://git.sans.ethz.ch/?p=cdist;a=summary)) + +## Update + +To upgrade cdist in the current branch use + + git pull + + # Also update the manpages + make man + export MANPATH=$MANPATH:$(pwd -P)/doc/man + +If you stay on a version branche (i.e. 1.0, 1.1., ...), nothing should break. +The master branch on the other hand is the development branch and may not be +working, break your setup or eat the tree in your garden. + +### Upgrading from 1.0 to 1.1 + +In 1.1 the type **\_\_file** was split into **\_\_directory**, **\_\_file** and +**\_\_link**. The parameter **--type** was removed from **\_\_file**. Thus you +need to replace **\_\_file** calls in your manifests: + + * Remove --type from all \_\_file calls + * If type was symlink, use \_\_link and --type symbolic + * If type was directory, use \_\_directory + + +## Support + +### IRC + +You can join the development ***IRC channel*** +[#cLinux on irc.freenode.org](irc://irc.freenode.org/#cLinux). + +### Mailing list + +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) + * [mercurial-server](http://www.lshift.net/mercurial-server.html) (version control) + * [xfce](http://www.xfce.org/) (lightweight desktop environment) + * [slim](http://slim.berlios.de/) (graphical login manager for X11) + +with cdist on a total of **5** production machines of the +[Systems Group](http://www.systems.ethz.ch) at the +[ETH Zurich](http://www.ethz.ch). diff --git a/REAL_README b/REAL_README deleted file mode 100644 index 0938289f..00000000 --- a/REAL_README +++ /dev/null @@ -1,171 +0,0 @@ -[[!meta title="cdist - configuration management"]] - - - .. . .x+=:. s - dF @88> z` ^% :8 - '88bu. %8P . origin/ - - # Stay on version 1.0 - git checkout -b 1.0 origin/1.0 - -### Update - -To upgrade cdist in the current branch use - - git pull - - # Also update the manpages - make man - export MANPATH=$MANPATH:$(pwd -P)/doc/man - - -The version branches are designed to change if there are incompatibilities. -Or the other way round: As long as you stay on 1.0 and do git pull, nothing -should break. - -## Support - -### IRC - -You can join the development ***IRC channel*** -[#cLinux on irc.freenode.org](irc://irc.freenode.org/#cLinux). - -### Mailing list - -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). diff --git a/bin/cdist-config b/bin/cdist-config index 0d0fd152..3e418c77 100755 --- a/bin/cdist-config +++ b/bin/cdist-config @@ -19,7 +19,7 @@ # # -__cdist_version="1.0.3" +__cdist_version="1.1.0" # Fail if something bogus is going on set -u diff --git a/bin/cdist-deploy-to b/bin/cdist-deploy-to index 35c058d9..d006dd2d 100755 --- a/bin/cdist-deploy-to +++ b/bin/cdist-deploy-to @@ -67,4 +67,4 @@ cdist-dir push "$__cdist_target_host" "$__cdist_out_object_dir" \ # And finally - execute the code cdist-code-run-all "$__cdist_target_host" -echo "Configuration successfully finished for $__cdist_target_host" +echo "cdist $__cdist_version: Successfully finished run on $__cdist_target_host" diff --git a/bin/cdist-env b/bin/cdist-env index e95e078b..3a477e85 100755 --- a/bin/cdist-env +++ b/bin/cdist-env @@ -18,16 +18,26 @@ # along with cdist. If not, see . # # -# Setup environment for use with cdist +# Setup environment for use with cdist - must be standalone! # -. cdist-config -[ $# -eq 0 ] || __cdist_usage "no arguments" +__cdist_pwd="$(pwd -P)" +__cdist_mydir="${0%/*}"; +__cdist_abs_mydir="$(cd "$__cdist_mydir" && pwd -P)" +__cdist_myname=${0##*/}; +__cdist_abs_myname="$__cdist_abs_mydir/$__cdist_myname" -# Allow access to unset variables like PATH and MANPATH -set +u - -echo export PATH=$__cdist_abs_mydir:$PATH +shell_binary=${SHELL##*/} +NEWPATH="$__cdist_abs_mydir:$PATH" cd "$__cdist_abs_mydir/../doc/man" -echo export MANPATH=$(pwd -P):$MANPATH +NEWMANPATH="$(pwd -P):$MANPATH" + +# Match csh, tcsh to handle differently +if [ "$(echo $shell_binary | grep 'csh$')" ]; then + echo setenv PATH $NEWPATH \; + echo setenv MANPATH $NEWMANPATH +else + echo export PATH=$NEWPATH + echo export MANPATH=$NEWMANPATH +fi diff --git a/conf/manifest/init b/conf/manifest/init index 0a1dca50..85a9a359 100755 --- a/conf/manifest/init +++ b/conf/manifest/init @@ -7,13 +7,14 @@ # Every machine becomes a marker, so sysadmins know that automatic # configurations are happening -__file /etc/cdist-configured --type file +__file /etc/cdist-configured case "$__target_host" in # Everybody has this localhost) - # Usual example - __file test --type symlink --source /etc/cdist-configured --destination /tmp/cdist-testfile + __link /tmp/cdist-testfile --source /etc/cdist-configured --type symbolic + __directory /tmp/cdist-test-dir --mode 4777 + __file /tmp/cdist-test-file --mode 0750 --owner nobody --group root ;; # @@ -36,11 +37,17 @@ case "$__target_host" in # Same stuff for gentoo __package tree --state installed ;; + cdist-debian) __package_apt atop --state installed __package apache2 --state deinstalled ;; + cdist-redhat) + __issue + __motd + ;; + # Real machines may be used with their hostname or fqdn, # depending on how you call cdist-deploy-to # machine) diff --git a/conf/type/__addifnosuchline/man.text b/conf/type/__addifnosuchline/man.text new file mode 100644 index 00000000..722a3080 --- /dev/null +++ b/conf/type/__addifnosuchline/man.text @@ -0,0 +1,50 @@ +cdist-type__addifnosuchline(7) +============================== +Daniel Roth + + +NAME +---- +cdist-type__addifnosuchline - Add a line (if not existing already) + + +DESCRIPTION +----------- +This type can be used to check a file for existence of a +specific line and adding it, if it was not found. + + +REQUIRED PARAMETERS +------------------- +line:: + Specifies the content which shall be added if not existing. + + +OPTIONAL PARAMETERS +------------------- +file:: + If supplied, use this as the destination file. + Otherwise the object_id is used. + + +EXAMPLES +-------- + +-------------------------------------------------------------------------------- +# Creates or appends the line specifiend in "include_www" to the file "lighttpd.conf" +__addifnosuchline www --file /etc/lighttpd.conf --line include_www + +# Adds the line "include_git" to the file "lighttpd.conf" +__addifnosuchline /etc/lighttpd.conf --line include_git +-------------------------------------------------------------------------------- + + +SEE ALSO +-------- +- cdist-type(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). diff --git a/conf/type/__directory/explorer/exists b/conf/type/__directory/explorer/exists new file mode 100755 index 00000000..b0be82fc --- /dev/null +++ b/conf/type/__directory/explorer/exists @@ -0,0 +1,34 @@ +#!/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 . +# +# +# Check whether file exists or not +# + +if [ -f "$__object/parameter/destination" ]; then + destination="$(cat "$__object/parameter/destination")" +else + destination="/$__object_id" +fi + +if [ -e "$destination" ]; then + echo yes +else + echo no +fi diff --git a/conf/type/__directory/gencode b/conf/type/__directory/gencode new file mode 100755 index 00000000..6d226aae --- /dev/null +++ b/conf/type/__directory/gencode @@ -0,0 +1,57 @@ +#!/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 . +# +# +# Handle directories +# +# +# __directory /etc [--mode --owner --group --parents [yes|no] ] +# + +destination="/$__object_id" + +# Include parent directories? +if [ -f "$__object/parameter/parents" ]; then + parents="$(cat "$__object/parameter/parents")" + if [ yes = "$parents" ]; then + mkdiropt="-p" + else + mkdiropt="" + fi +fi + +# Only create if not already existent +if [ no = "$(cat "$__object/explorer/exists")" ]; then + echo mkdir $mkdiropt \"$destination\" +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\" +fi + +# Owner +if [ -f "$__object/parameter/owner" ]; then + echo chown \"$(cat "$__object/parameter/owner")\" \"$destination\" +fi diff --git a/conf/type/__directory/man.text b/conf/type/__directory/man.text new file mode 100644 index 00000000..f7272df9 --- /dev/null +++ b/conf/type/__directory/man.text @@ -0,0 +1,56 @@ +cdist-type__directory(7) +======================== +Nico Schottelius + + +NAME +---- +cdist-type__directory - Create a directory + + +DESCRIPTION +----------- +This cdist type allows you to create directories on the target. + + +REQUIRED PARAMETERS +------------------- +None. + + +OPTIONAL PARAMETERS +------------------- +group:: + Group to chgrp to. + +mode:: + Unix permissions, suitable for chmod. + +owner:: + User to chown to. + +parents:: + Whether to create parents as well (mkdir -p behaviour) + + +EXAMPLES +-------- + +-------------------------------------------------------------------------------- +# A silly example +__directory /tmp/foobar + +# Ensure /etc exists correctly +__file /etc --owner root --group root --mode 0755 +-------------------------------------------------------------------------------- + + +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). diff --git a/conf/type/__directory/parameter/optional b/conf/type/__directory/parameter/optional new file mode 100644 index 00000000..752c3989 --- /dev/null +++ b/conf/type/__directory/parameter/optional @@ -0,0 +1,4 @@ +group +mode +owner +parents diff --git a/conf/type/__file/explorer/md5sum b/conf/type/__file/explorer/cksum similarity index 71% rename from conf/type/__file/explorer/md5sum rename to conf/type/__file/explorer/cksum index 4ac0e1b9..dcad99ba 100755 --- a/conf/type/__file/explorer/md5sum +++ b/conf/type/__file/explorer/cksum @@ -21,28 +21,11 @@ # Retrieve the md5sum of a file to be created, if it is already existing. # -if [ -f "$__object/parameter/destination" ]; then - destination="$(cat "$__object/parameter/destination")" -else - destination="/$__object_id" -fi +destination="/$__object_id" -os="$(cat $__global/explorer/os)" - -case "$os" in - macosx) - md5sum="md5" - ;; - - *) - md5sum="md5sum" - ;; -esac - -# No output if file does not exist - does definitely not match the md5sum :-) if [ -e "$destination" ]; then if [ -f "$destination" ]; then - $md5sum < "$destination" + cksum < "$destination" else echo "NO REGULAR FILE" fi diff --git a/conf/type/__file/explorer/exists b/conf/type/__file/explorer/exists index b0be82fc..f8b85671 100755 --- a/conf/type/__file/explorer/exists +++ b/conf/type/__file/explorer/exists @@ -21,11 +21,7 @@ # Check whether file exists or not # -if [ -f "$__object/parameter/destination" ]; then - destination="$(cat "$__object/parameter/destination")" -else - destination="/$__object_id" -fi +destination="/$__object_id" if [ -e "$destination" ]; then echo yes diff --git a/conf/type/__file/gencode b/conf/type/__file/gencode index 5f386349..ef8c5501 100755 --- a/conf/type/__file/gencode +++ b/conf/type/__file/gencode @@ -18,97 +18,47 @@ # along with cdist. If not, see . # # -# __file is a very basic type and should be able to be used as an -# example for typewrites later +# __file is a very basic type, which will probably be reused quite often # -# If destination was specified, do not use the id -if [ -f "$__object/parameter/destination" ]; then - destination="$(cat "$__object/parameter/destination")" -else - # If no destination has been supplied, the id is the destination - # Prepend /, which got lost in the object id (and relative paths - # don't make sense) - destination="/$__object_id" -fi +destination="/$__object_id" -# Ensure we have an absolute path -if ! $(echo "$destination" | grep -q ^/); then - echo "Error: Destination ($destination) of $__object_id is not absolute." >&2 - exit 1 -fi +if [ -f "$__object/parameter/source" ]; then + source="$(cat "$__object/parameter/source")" -# Use correct md5sum binary - MacOSx is different here -case "$os" in - macosx) - md5sum="md5" - ;; + if [ -f "$source" ]; then + local_cksum="$(cksum < "$source")" + remote_cksum="$(cat "$__object/explorer/cksum")" - *) - md5sum="md5sum" - ;; -esac - -type="$(cat "$__object/parameter/type")" - -case "$type" in - directory) - if [ -f "$__object/parameter/source" ]; then - echo "Source not supported for directory currently - FIXME" >&2 - exit 1 - else - if [ no = "$(cat "$__object/explorer/exists")" ]; then - echo mkdir \"$destination\" - fi + if [ "$local_cksum" != "$remote_cksum" ]; then + # FIXME: The username is ugly and hardcoded, replace after 1.0! + # Probably a better aproach is to have the user configured + # ~/.ssh/config to contain the right username + # Probably describe it in cdist-quickstart... + scp "$source" "root@${__target_host}:${destination}" fi - ;; - - file) - if [ -f "$__object/parameter/source" ]; then - source="$(cat "$__object/parameter/source")" - - if [ -f "$source" ]; then - local_md5sum="$($md5sum < "$source")" - remote_md5sum="$(cat "$__object/explorer/md5sum")" - - # FIXME: Is md5sum the right approach? - if [ "$local_md5sum" != "$remote_md5sum" ]; then - # FIXME: This is ugly and hardcoded, replace after 1.0! - # Probably a better aproach is to have the user configured - # ~/.ssh/config to contain the right username - # 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 - echo touch \"$destination\" - fi - fi - ;; - - symlink) - if [ ! -f "$__object/parameter/source" ]; then - echo "Source required for symlink" >&2 - exit 1 - fi - source="$(cat "$__object/parameter/source")" - - # FIXME: handle directories or document & ignore? - echo ln -sf \"$source\" \"$destination\" - ;; - - *) - echo "Unsupported type: \"$type\"" >&2 + else + echo "Source \"$source\" does not exist." >&2 exit 1 - ;; -esac + fi +else + if [ no = "$(cat "$__object/explorer/exists")" ]; then + echo touch \"$destination\" + fi +fi + # Mode settings if [ -f "$__object/parameter/mode" ]; then - mode="$(cat "$__object/parameters/mode")" - echo chmod \"$mode\" \"$destination\" + echo chmod \"$(cat "$__object/parameter/mode")\" \"$destination\" +fi + +# Group +if [ -f "$__object/parameter/group" ]; then + echo chgrp \"$(cat "$__object/parameter/group")\" \"$destination\" +fi + +# Owner +if [ -f "$__object/parameter/owner" ]; then + echo chown \"$(cat "$__object/parameter/owner")\" \"$destination\" fi diff --git a/conf/type/__file/man.text b/conf/type/__file/man.text index 04e0ffc3..67ab53d1 100644 --- a/conf/type/__file/man.text +++ b/conf/type/__file/man.text @@ -15,19 +15,20 @@ This cdist type allows you to create files on the target. REQUIRED PARAMETERS ------------------- -type:: - Specifies the type of file to be created. Either "directory" or "file" +None. OPTIONAL PARAMETERS ------------------- -destination:: - If supplied, use this as the destination on the target. Otherwise the - object_id is used. +group:: + Group to chgrp to. mode:: Unix permissions, suitable for chmod. +owner:: + User to chown to. + source:: If supplied, copy this file from the host running cdist to the target. If not supplied, an empty file or directory will be created. @@ -38,13 +39,14 @@ EXAMPLES -------------------------------------------------------------------------------- # Create /etc/cdist-configured as an empty file -__file /etc/cdist-configured --type file - -# Same but with a different object id -__file cdist-marker --type file --destination /etc/cdist-configured +__file /etc/cdist-configured # Use __file from another type -__file /etc/issue --source "$__type/files/archlinux" --type file +__file /etc/issue --source "$__type/files/archlinux" + +# Supply some more settings +__file /etc/shadow --source "$__type/files/shadow" \ + --owner root --group shadow --mode 0640 -------------------------------------------------------------------------------- diff --git a/conf/type/__file/parameter/optional b/conf/type/__file/parameter/optional index de17ffff..06120518 100644 --- a/conf/type/__file/parameter/optional +++ b/conf/type/__file/parameter/optional @@ -1,3 +1,4 @@ +group mode +owner source -destination diff --git a/conf/type/__file/parameter/required b/conf/type/__file/parameter/required deleted file mode 100644 index aa80e646..00000000 --- a/conf/type/__file/parameter/required +++ /dev/null @@ -1 +0,0 @@ -type diff --git a/conf/type/__issue/files/redhat b/conf/type/__issue/files/redhat new file mode 100644 index 00000000..d93372b0 --- /dev/null +++ b/conf/type/__issue/files/redhat @@ -0,0 +1,3 @@ +Red Hat Enterprise Linux Server (cdist-automated) +Kernel \r on an \m + diff --git a/conf/type/__issue/man.text b/conf/type/__issue/man.text index 57ece530..18d88947 100644 --- a/conf/type/__issue/man.text +++ b/conf/type/__issue/man.text @@ -1,5 +1,5 @@ cdist-type__issue(7) -=================== +==================== Nico Schottelius diff --git a/conf/type/__issue/manifest b/conf/type/__issue/manifest index aa6f7629..1fab9a07 100755 --- a/conf/type/__issue/manifest +++ b/conf/type/__issue/manifest @@ -23,12 +23,12 @@ destination=/etc/issue source="$(cat "out/explorer/os")" case "$os" in - archlinux) - source="$__type/files/archlinux" + archlinux|redhat) + source="$__type/files/$os" ;; *) source="$__type/files/default" ;; esac -__file "$destination" --source "$source" --type file +__file "$destination" --source "$source" diff --git a/conf/type/__link/gencode b/conf/type/__link/gencode new file mode 100755 index 00000000..2e13755c --- /dev/null +++ b/conf/type/__link/gencode @@ -0,0 +1,43 @@ +#!/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 . +# +# +# __file is a very basic type and should be able to be used as an +# example for typewrites later +# + +destination="/$__object_id" + +type="$(cat "$__object/parameter/type")" +source="$(cat "$__object/parameter/source")" + +case "$type" in + symbolic) + lnopt="-s" + ;; + hard) + lnopt="" + ;; + *) + echo "Unknown type: $type" >&2 + exit 1 + ;; +esac + +echo ln ${lnopt} -f \"$source\" \"$destination\" diff --git a/conf/type/__link/man.text b/conf/type/__link/man.text new file mode 100644 index 00000000..fb914298 --- /dev/null +++ b/conf/type/__link/man.text @@ -0,0 +1,56 @@ +cdist-type__link(7) +=================== +Nico Schottelius + + +NAME +---- +cdist-type__link - Create links + + +DESCRIPTION +----------- +This cdist type allows you to hard and symoblic links. The given +object id is the destination for the link. + + +REQUIRED PARAMETERS +------------------- +source:: + Specifies the link source. + +type:: + Specifies the link type: Either hard or symoblic. + + +OPTIONAL PARAMETERS +------------------- +None. + + +EXAMPLES +-------- + +-------------------------------------------------------------------------------- +# Create hard link of /etc/shadow +__link /root/shadow --source /etc/shadow --type hard + +# Relative symbolic link +__link /etc/apache2/sites-enabled/www.test.ch \ + --source ../sites-available/www.test.ch \ + --type symbolic + +# Absolute symbolic link +__link /opt/plone --source /home/services/plone --type symbolic +-------------------------------------------------------------------------------- + + +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). diff --git a/conf/type/__link/parameter/required b/conf/type/__link/parameter/required new file mode 100644 index 00000000..f7facfb8 --- /dev/null +++ b/conf/type/__link/parameter/required @@ -0,0 +1,2 @@ +source +type diff --git a/conf/type/__motd/man.text b/conf/type/__motd/man.text index 1fca60d3..a4ca80b5 100644 --- a/conf/type/__motd/man.text +++ b/conf/type/__motd/man.text @@ -33,7 +33,7 @@ EXAMPLES __motd # Supply source file from a different type -__file --source "$__type/files/my-motd" +__motd --source "$__type/files/my-motd" -------------------------------------------------------------------------------- diff --git a/conf/type/__motd/manifest b/conf/type/__motd/manifest index 594977b9..4716f530 100755 --- a/conf/type/__motd/manifest +++ b/conf/type/__motd/manifest @@ -19,8 +19,6 @@ # # -destination=/etc/motd - # Select motd source if [ -f "$__object/parameter/source" ]; then source="$(cat "$__object/parameter/source")" @@ -28,4 +26,16 @@ else source="$__type/files/motd" fi -__file "$destination" --source "$source" --type file +os=$(cat $__global/explorer/os) + + +case "$os" in + debian|ubuntu) + destination=/etc/motd.tail + ;; + *) + destination=/etc/motd + ;; +esac + +__file "$destination" --source "$source" --mode 0644 diff --git a/conf/type/__package_apt/man.text b/conf/type/__package_apt/man.text new file mode 100644 index 00000000..0780124d --- /dev/null +++ b/conf/type/__package_apt/man.text @@ -0,0 +1,53 @@ +cdist-type__package_apt(7) +========================== +Nico Schottelius + + +NAME +---- +cdist-type__package_apt - Manage packages with apt-get + + +DESCRIPTION +----------- +apt-get is usually used on Debian and variants (like Ubuntu) to +manage packages. + + +REQUIRED PARAMETERS +------------------- +state:: + Either "installed" or "deinstalled". + + +OPTIONAL PARAMETERS +------------------- +name:: + If supplied, use the name and not the object id as the package name. + + +EXAMPLES +-------- + +-------------------------------------------------------------------------------- +# Ensure zsh in installed +__package_apt zsh --state installed + +# In case you only want *a* webserver, but don't care which one +__package_apt webserver --state installed --name nginx + +# Remove obsolete package +__package_apt puppet --state deinstalled +-------------------------------------------------------------------------------- + + +SEE ALSO +-------- +- cdist-type(7) +- cdist-type__package(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). diff --git a/conf/type/__package_pacman/man.text b/conf/type/__package_pacman/man.text new file mode 100644 index 00000000..35a7e44c --- /dev/null +++ b/conf/type/__package_pacman/man.text @@ -0,0 +1,53 @@ +cdist-type__package_pacman(7) +============================= +Nico Schottelius + + +NAME +---- +cdist-type__package_pacman - Manage packages with pacman + + +DESCRIPTION +----------- +Pacman is usually used on the Archlinux distribution to manage +packages. + + +REQUIRED PARAMETERS +------------------- +state:: + Either "installed" or "deinstalled". + + +OPTIONAL PARAMETERS +------------------- +name:: + If supplied, use the name and not the object id as the package name. + + +EXAMPLES +-------- + +-------------------------------------------------------------------------------- +# Ensure zsh in installed +__package_pacman zsh --state installed + +# If you don't want to follow pythonX packages, but always use python +__package_pacman python --state installed --name python2 + +# Remove obsolete package +__package_pacman puppet --state deinstalled +-------------------------------------------------------------------------------- + + +SEE ALSO +-------- +- cdist-type(7) +- cdist-type__package(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). diff --git a/doc/changelog b/doc/changelog index 534f4c3e..fae5607a 100644 --- a/doc/changelog +++ b/doc/changelog @@ -1,10 +1,19 @@ -1.0.4: +1.1.0: 2011-03-16 + * Replace type __file with __file, __directory, __link + * Document cdist-env + * Document cdist-config + * Document cdist-dir + * Document cdist-quickstart + +1.0.4: 2011-03-15 * New type __motd - * New type __addifnosuchline + * New type __addifnosuchline (Daniel Roth) * Document type __issue * New type __user * Document type __package - * Document type __package_emerge + * Document type __package_pacman + * Document type __package_apt + * New parameter for __file: --owner and --group 1.0.3: 2011-03-11 * Update regexp used for sane characters diff --git a/doc/dev/logs/2011-03-15 b/doc/dev/logs/2011-03-15 new file mode 100644 index 00000000..66de8aed --- /dev/null +++ b/doc/dev/logs/2011-03-15 @@ -0,0 +1,27 @@ +Steven, Nico + +How to handle dependencies: + +1) Add --require parameter for all types + - Special handling in cdist-type-emulator + + Everything on one line + +2) Add __require type + + No change in core + - Type influences core + - Additional line + - Core needs to know about requirements + +3) cdist-require as a seperate executable + + No change in cdist-type-emulator + - new behaviour + - first time cdist-xxx dependency in types + +4) require="" environment variable for cdist-type-emulator + + on one line / same context + + special handling is ok for special case + + doesn't touch parameters (i.e. type still has full control) + +-------------------------------------------------------------------------------- + +Result: Use version 4. diff --git a/doc/dev/logs/2011-03-15.file_directory_link b/doc/dev/logs/2011-03-15.file_directory_link new file mode 100644 index 00000000..9044bc33 --- /dev/null +++ b/doc/dev/logs/2011-03-15.file_directory_link @@ -0,0 +1,7 @@ +Proposal for new types, which replace __file: + +x __directory /etc [--mode --owner --group --parents [yes|no] ] + +x __link /destination --source abc --type [symbolic|hard] + +x __file /etc/passwd [--source] --mode --owner --group diff --git a/doc/dev/todo/post-1.0-cache b/doc/dev/todo/cache similarity index 100% rename from doc/dev/todo/post-1.0-cache rename to doc/dev/todo/cache diff --git a/doc/dev/todo/niconext b/doc/dev/todo/niconext index e69de29b..7ce8da49 100644 --- a/doc/dev/todo/niconext +++ b/doc/dev/todo/niconext @@ -0,0 +1 @@ +Release 1.1.0 diff --git a/doc/dev/todo/post-1.0 b/doc/dev/todo/post-1.1 similarity index 68% rename from doc/dev/todo/post-1.0 rename to doc/dev/todo/post-1.1 index 49c6f8b0..8556f253 100644 --- a/doc/dev/todo/post-1.0 +++ b/doc/dev/todo/post-1.1 @@ -1,3 +1,7 @@ +Core: + - write test case: test.sh + - probably remove grep -q (solaris does not have it) + Dependencies: - Add meta parameters like --requires --excludes --depends? - Build dependency tree @@ -9,22 +13,9 @@ Types to be written/extended: - __service - __user - __file_edit - - delete_line_from_file + - __deleteline - 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 @@ -41,16 +32,8 @@ Documentation: + cdist + cdist-deploy-to + cdist-manifest - - cdist-type [IMPORTANT] - - only do necessary work [TYPE IMPLEMENTATION HINTS] - - install packages only if not existent - - copy file only if different - - DOC document that $type/manifest is executed for every object/instance - ensure every file in bin/ has a correspondent manpage - cdist-code-run-all - - cdist-config - - cdist-deploy-to - - cdist-dir - cdist-explorer-run-init - cdist-manifest-run - cdist-manifest-run-all @@ -58,7 +41,6 @@ Documentation: - cdist-object-codegen - cdist-object-codegen-all - cdist-object-explorer-all - - cdist-quickstart - cdist-remote-code-run-all - cdist-remote-explorer-run - cdist-run-remote diff --git a/doc/man/to_check/cdist-config.text b/doc/man/cdist-config.text similarity index 54% rename from doc/man/to_check/cdist-config.text rename to doc/man/cdist-config.text index 969be9cc..9d147988 100644 --- a/doc/man/to_check/cdist-config.text +++ b/doc/man/cdist-config.text @@ -10,18 +10,14 @@ cdist-config - Read basic cdist configuration DESCRIPTION ----------- -Cdist-config is sourced by all helper programs and provides -hints on where to find the library. Cdist-config needs to be -in the path. - -AUTHOR ------- -Nico Schottelius +Cdist-config is sourced by cdist programs and provides hints on where to find +types, manifests, etc. Generally speaking, it's just usable from within the +core and is only of interest for cdist-developers. -RESOURCES ---------- -Main web site: http://www.nico.schottelius.org/cdist/[] +SEE ALSO +-------- +cdist(7) COPYING diff --git a/doc/man/cdist-dir.text b/doc/man/cdist-dir.text new file mode 100644 index 00000000..223bc779 --- /dev/null +++ b/doc/man/cdist-dir.text @@ -0,0 +1,38 @@ +cdist-dir(1) +============ +Nico Schottelius + + +NAME +---- +cdist-dir - Poor man's directory synchronisation + + +SYNOPSIS +-------- +cdist-dir TARGET_HOST SRC_DIR DST_DIR + + +DESCRIPTION +----------- +cdist-dir either pushes a local directory to the target host +or pulls a remote directory from a target host to the local host. + +In the push case SRC_DIR is local, in the pull case remote. +In the push case DST_DIR is remote, in the pull case local. + +cdist-dir does not cleanup DST_DIR and thus it may contain old +stuff if used multiple times. + +cdist-dir does not rely on rsync or other high level tools, because +it cannot expect its existence on the local or target host. + +SEE ALSO +-------- +cdist(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). diff --git a/doc/man/cdist-env.text b/doc/man/cdist-env.text new file mode 100644 index 00000000..8d10aa85 --- /dev/null +++ b/doc/man/cdist-env.text @@ -0,0 +1,46 @@ +cdist-env(1) +============ +Nico Schottelius + + +NAME +---- +cdist-env - Setup environment for using cdist + + +SYNOPSIS +-------- +cdist-env + + +DESCRIPTION +----------- +cdist-env outputs two strings suitable for usage in your current shell, +so you can use cdist from the checkout. cdist-env essentially helps you +to easily setup PATH and MANPATH. + +If you've multiple checkouts of cdist and run cdist-env from the various +checkouts, a new run will prepend the last directory, thus ensures you +can run it multiple times and does what one expects. + +EXAMPLES +-------- +For use in bourne shell variants (like dash, bash, ksh) as well as +in csh variants (csh, tcsh): + +-------------------------------------------------------------------------------- +eval `./bin/cdist-env` +-------------------------------------------------------------------------------- + +Replace "./" with the checkout directory of cdist. + + +SEE ALSO +-------- +cdist(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). diff --git a/doc/man/cdist-quickstart.text b/doc/man/cdist-quickstart.text new file mode 100644 index 00000000..ddcbbccc --- /dev/null +++ b/doc/man/cdist-quickstart.text @@ -0,0 +1,51 @@ +cdist-quickstart(1) +=================== +Nico Schottelius + +NAME +---- +cdist-quickstart - Make use of cinit in 5 minutes + + +SYNOPSIS +-------- +cdist-quickstart + + +DESCRIPTION +----------- +cdist-quickstart is an interactive guide to cdist. It should be one +of the first tools you use when you begin with cdist. + + +EXAMPLES +-------- + +To use cdist-quickstart, add the bin directory to your PATH, +execute cdist-quickstart and enjoy cdist: + + +-------------------------------------------------------------------------------- +# Bourne shell example +export PATH=$(pwd -P)/bin:$PATH + +# Alternatively, usable for csh and bsh, set's up PATH and MANPATH +eval `./bin/cdist-env` + +# Let's go! +cdist-quickstart +-------------------------------------------------------------------------------- + + + +SEE ALSO +-------- +- cdist(7) +- cdist-env(1) + + +COPYING +------- +Copyright \(C) 2010-2011 Nico Schottelius. Free use of this software is +granted under the terms of the GNU General Public License version 3 (GPLv3). +## How to use cdist? diff --git a/doc/man/cdist-type.text b/doc/man/cdist-type.text index 7c8b49f3..f8811a16 100644 --- a/doc/man/cdist-type.text +++ b/doc/man/cdist-type.text @@ -179,6 +179,14 @@ level tools like ruby installed. If a type requires specific tools to be present on the target, there must be another type that provides this tool and the first type should create an object of the specific type. +If your type wants to save temporay data, that may be used by other types +later on (for instance __file), you can save them in the subdirectory +"files" below $__object (but you must create it yourself). cdist will not touch +this directory. + +If your type contains static files, it's also recommened to place them in +a folder named "files" within the type (again, because cdist guarantees to +never ever touch this folder). HOW TO INCLUDE A TYPE INTO UPSTREAM CDIST ----------------------------------------- diff --git a/doc/man/to_check/cdist-quickstart.text b/doc/man/to_check/cdist-quickstart.text deleted file mode 100644 index 570aa310..00000000 --- a/doc/man/to_check/cdist-quickstart.text +++ /dev/null @@ -1,42 +0,0 @@ -cdist-quickstart(1) -=================== -Nico Schottelius - -NAME ----- -cdist-quickstart - Make use of cinit in 5 minutes - - -DESCRIPTION ------------ -This document helps you to take the first steps with cdist. -We'll begin to configure the host "localhost" to have two files -in place, /etc/DO-NOT-CHANGE and /root/CDIST-ENABLED-HOST, which -both are used to warn other sysadmins that this system is managed -by configuration management and manual changes may get overwritten. - -Begin to execute cdist-quickstart, it will show you the steps it -takes and explains what it does: - -% cdist-quickstart - -mkdir -p /etc/cdist/manifests - -# Create - -Cdist uses -kgives you an impression of - 0. Create a host specification (/etc/cdist/hosts/**hostname**) - 0. Add functionalilty to add - 0. Run ***cdist-apply*** - -SEE ALSO --------- -cdist-config-layout(7) - - -COPYING -------- -Copyright \(C) 2010-2011 Nico Schottelius. Free use of this software is -granted under the terms of the GNU General Public License version 3 (GPLv3). -## How to use cdist? diff --git a/doc/man/to_check/cdist-terms.text b/doc/man/to_check/cdist-terms.text deleted file mode 100644 index 530c4762..00000000 --- a/doc/man/to_check/cdist-terms.text +++ /dev/null @@ -1,26 +0,0 @@ -cdist-terms(7) -============== -Nico Schottelius - - -NAME ----- -cdist-terms - Describe terms used in cdist - - -DESCRIPTION ------------ -provider: Provides functionality. -object: Instance with provider unique id of a provider. -manifest: Define which objects to create [on hosts] -server: The machine that configures all targets. -target: Host that should be configured. - -SEE ALSO --------- - - -COPYING -------- -Copyright \(C) 2010-2011 Nico Schottelius. Free use of this software is -granted under the terms of the GNU General Public License version 3 (GPLv3). diff --git a/doc/man/to_check/cdist-type-addifnosuchline.text b/doc/man/to_check/cdist-type-addifnosuchline.text deleted file mode 100644 index 09618dc3..00000000 --- a/doc/man/to_check/cdist-type-addifnosuchline.text +++ /dev/null @@ -1,30 +0,0 @@ -cdist-type-addifnosuchline(1) -====================== -Daniel Roth - - -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). diff --git a/doc/man/to_check/cdist-type-manifest.text b/doc/man/to_check/cdist-type-manifest.text deleted file mode 100644 index 7573df6b..00000000 --- a/doc/man/to_check/cdist-type-manifest.text +++ /dev/null @@ -1,24 +0,0 @@ -cdist-type-manifest(7) -====================== -Nico Schottelius - - -NAME ----- -cdist-type-manifest - Manifest of a type - - -DESCRIPTION ------------ -CWD = object directory -ARGV = target host, basedir -ENV = - -SEE ALSO --------- - - -COPYING -------- -Copyright \(C) 2010-2011 Nico Schottelius. Free use of this software is -granted under the terms of the GNU General Public License version 3 (GPLv3).