From 8828a69d608505d7c52fd6d9f942dcbe259ede46 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 1 Apr 2011 11:04:31 +0200 Subject: [PATCH 01/41] unignore doc/man and update cdist-best-practice.text Signed-off-by: Nico Schottelius --- .gitignore | 4 +++- doc/man/man7/cdist-best-practice.text | 14 ++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 68f829dc..89dba856 100644 --- a/.gitignore +++ b/.gitignore @@ -3,7 +3,9 @@ # Ignore generated manpages doc/man/.marker -doc/man/man*/ +doc/man/man1/*.1 +doc/man/man7/*.7 +doc/man/man*/*.html # Ignore cache for version control cache/ diff --git a/doc/man/man7/cdist-best-practice.text b/doc/man/man7/cdist-best-practice.text index febe8f36..666dd414 100644 --- a/doc/man/man7/cdist-best-practice.text +++ b/doc/man/man7/cdist-best-practice.text @@ -60,6 +60,20 @@ machine-a % git clone git://your-git-server/cdist machine-b % git clone git://your-git-server/cdist -------------------------------------------------------------------------------- +SEPERATING WORK BY GROUPS +------------------------- +If you are working with different groups on one cdist-configuration, +you can delegate to other manifests and have the groups edit only +their manifests. You can use the following snippet in +**conf/manifests/init**: + +-------------------------------------------------------------------------------- +# Include other groups +sh -e "$__manifest/systems" + +sh -e "$__manifest/cbrg" +-------------------------------------------------------------------------------- + SEE ALSO -------- From afb1bf2373ce93b996681e0e5d5945848a894633 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 1 Apr 2011 11:22:35 +0200 Subject: [PATCH 02/41] ignore type manpages and docbook stuff Signed-off-by: Nico Schottelius --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 89dba856..57950f3b 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,8 @@ doc/man/.marker doc/man/man1/*.1 doc/man/man7/*.7 doc/man/man*/*.html +doc/man/man7/cdist-type__*.text +doc/man/man*/docbook-xsl.css # Ignore cache for version control cache/ From 422bfd57d4664ab803461d4e45aaa70855f6c978 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 1 Apr 2011 11:30:55 +0200 Subject: [PATCH 03/41] document multiple configuration workflow Signed-off-by: Nico Schottelius --- doc/man/man7/cdist-best-practice.text | 31 +++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/doc/man/man7/cdist-best-practice.text b/doc/man/man7/cdist-best-practice.text index 666dd414..aa499790 100644 --- a/doc/man/man7/cdist-best-practice.text +++ b/doc/man/man7/cdist-best-practice.text @@ -75,6 +75,37 @@ sh -e "$__manifest/cbrg" -------------------------------------------------------------------------------- +MAINTAINING MULTIPLE CONFIGURATIONS +----------------------------------- +When you need to manage multiple sites with cdist, like company_a, company_b +and private for instance, you can easily use git for this purpose. +Including a possible common base that is reused accross the different sites: + +-------------------------------------------------------------------------------- +# create branches +git branch company_a company_b common private + +# make stuff for company a +git checkout company_a +# work, commit, etc. + +# make stuff for company b +git checkout company_b +# work, commit, etc. + +# make stuff relevant for all sites +git checkout common +# work, commit, etc. + +# change to private and include latest common stuff +git checkout private +git merge common +-------------------------------------------------------------------------------- + +Have a look at git-remote(1) to adjust the remote configuration, which allows +you to push certain branches to certain remotes. + + SEE ALSO -------- - cdist(7) From 2c3d71a7e7e43a7af275a93c991dadc51fd95a15 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 1 Apr 2011 12:11:30 +0200 Subject: [PATCH 04/41] update todos Signed-off-by: Nico Schottelius --- doc/dev/todo/TAKEME | 4 ---- doc/dev/todo/niconext | 3 ++- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/doc/dev/todo/TAKEME b/doc/dev/todo/TAKEME index 67afba55..7a8c4583 100644 --- a/doc/dev/todo/TAKEME +++ b/doc/dev/todo/TAKEME @@ -45,7 +45,3 @@ Cache: - export variable $__cache -> for current host -> add function to cdist-config, import from cdist-cache - - -remove --preseed from package_apt and add debconf_set_selection or similar - -> much cleaner! diff --git a/doc/dev/todo/niconext b/doc/dev/todo/niconext index 29229d64..e7f2c72f 100644 --- a/doc/dev/todo/niconext +++ b/doc/dev/todo/niconext @@ -1 +1,2 @@ -Release 1.5.0 correctly :-) +remove --preseed from package_apt and add debconf_set_selection or similar + -> much cleaner! From 48a96591d14910748744e256975c3fb55795f055 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 1 Apr 2011 12:11:50 +0200 Subject: [PATCH 05/41] add template for type __debconf_set_selections/ Signed-off-by: Nico Schottelius --- .../explorer/pkg_status | 31 ++++++++++ .../__debconf_set_selections/gencode-remote | 53 +++++++++++++++++ conf/type/__debconf_set_selections/man.text | 59 +++++++++++++++++++ .../parameter/optional | 3 + .../parameter/required | 1 + 5 files changed, 147 insertions(+) create mode 100755 conf/type/__debconf_set_selections/explorer/pkg_status create mode 100755 conf/type/__debconf_set_selections/gencode-remote create mode 100644 conf/type/__debconf_set_selections/man.text create mode 100644 conf/type/__debconf_set_selections/parameter/optional create mode 100644 conf/type/__debconf_set_selections/parameter/required diff --git a/conf/type/__debconf_set_selections/explorer/pkg_status b/conf/type/__debconf_set_selections/explorer/pkg_status new file mode 100755 index 00000000..86b94825 --- /dev/null +++ b/conf/type/__debconf_set_selections/explorer/pkg_status @@ -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 . +# +# +# Retrieve the status of a package - parsed dpkg output +# + +if [ -f "$__object/parameter/name" ]; then + name="$(cat "$__object/parameter/name")" +else + name="$__object_id" +fi + +# Except dpkg failing, if package is not known / installed +dpkg -s "$name" 2>/dev/null || exit 0 diff --git a/conf/type/__debconf_set_selections/gencode-remote b/conf/type/__debconf_set_selections/gencode-remote new file mode 100755 index 00000000..b2c7179d --- /dev/null +++ b/conf/type/__debconf_set_selections/gencode-remote @@ -0,0 +1,53 @@ +#!/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 . +# +# +# Manage packages on Debian and co. +# + +if [ -f "$__object/parameter/name" ]; then + name="$(cat "$__object/parameter/name")" +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)" + +case "$state" in + installed) + # Install only if non-existent + if [ -z "$is_installed" ]; then + echo apt-get --quiet --yes install \"$name\" + fi + ;; + uninstalled) + # Remove only if existent + if [ -n "$is_installed" ]; then + echo apt-get --quiet --yes remove \"$name\" + fi + ;; +esac diff --git a/conf/type/__debconf_set_selections/man.text b/conf/type/__debconf_set_selections/man.text new file mode 100644 index 00000000..8b7476b4 --- /dev/null +++ b/conf/type/__debconf_set_selections/man.text @@ -0,0 +1,59 @@ +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. + +preseed:: + If supplied, use the given filename as input for debconf-set-selections(1) + + +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 + +# Install package with defaults (from a type) +__package_apt postfix --state installed --preseed "$__type/files/postfix-seed" + +# 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/__debconf_set_selections/parameter/optional b/conf/type/__debconf_set_selections/parameter/optional new file mode 100644 index 00000000..2dae648e --- /dev/null +++ b/conf/type/__debconf_set_selections/parameter/optional @@ -0,0 +1,3 @@ +name +preseed +version diff --git a/conf/type/__debconf_set_selections/parameter/required b/conf/type/__debconf_set_selections/parameter/required new file mode 100644 index 00000000..ff72b5c7 --- /dev/null +++ b/conf/type/__debconf_set_selections/parameter/required @@ -0,0 +1 @@ +state From 0db21eb308135cbc824675bce833a2924f6b6ead Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 1 Apr 2011 12:47:48 +0200 Subject: [PATCH 06/41] document, cleanup and theoretically finish __debconf_set_selections Signed-off-by: Nico Schottelius --- .../explorer/pkg_status | 31 ---------------- .../__debconf_set_selections/gencode-remote | 35 +++--------------- conf/type/__debconf_set_selections/man.text | 36 ++++++------------- .../parameter/optional | 3 -- .../parameter/required | 2 +- 5 files changed, 15 insertions(+), 92 deletions(-) delete mode 100755 conf/type/__debconf_set_selections/explorer/pkg_status delete mode 100644 conf/type/__debconf_set_selections/parameter/optional diff --git a/conf/type/__debconf_set_selections/explorer/pkg_status b/conf/type/__debconf_set_selections/explorer/pkg_status deleted file mode 100755 index 86b94825..00000000 --- a/conf/type/__debconf_set_selections/explorer/pkg_status +++ /dev/null @@ -1,31 +0,0 @@ -#!/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 . -# -# -# Retrieve the status of a package - parsed dpkg output -# - -if [ -f "$__object/parameter/name" ]; then - name="$(cat "$__object/parameter/name")" -else - name="$__object_id" -fi - -# Except dpkg failing, if package is not known / installed -dpkg -s "$name" 2>/dev/null || exit 0 diff --git a/conf/type/__debconf_set_selections/gencode-remote b/conf/type/__debconf_set_selections/gencode-remote index b2c7179d..156fc9f3 100755 --- a/conf/type/__debconf_set_selections/gencode-remote +++ b/conf/type/__debconf_set_selections/gencode-remote @@ -18,36 +18,9 @@ # along with cdist. If not, see . # # -# Manage packages on Debian and co. +# Setup selections # -if [ -f "$__object/parameter/name" ]; then - name="$(cat "$__object/parameter/name")" -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)" - -case "$state" in - installed) - # Install only if non-existent - if [ -z "$is_installed" ]; then - echo apt-get --quiet --yes install \"$name\" - fi - ;; - uninstalled) - # Remove only if existent - if [ -n "$is_installed" ]; then - echo apt-get --quiet --yes remove \"$name\" - fi - ;; -esac +echo "debconf-set-selections << __file-eof" +cat "$__object/parameter/file" +echo "__file-eof" diff --git a/conf/type/__debconf_set_selections/man.text b/conf/type/__debconf_set_selections/man.text index 8b7476b4..b6b2ad18 100644 --- a/conf/type/__debconf_set_selections/man.text +++ b/conf/type/__debconf_set_selections/man.text @@ -1,31 +1,22 @@ -cdist-type__package_apt(7) -========================== +cdist-type__debconf_set_selections(7) +===================================== Nico Schottelius NAME ---- -cdist-type__package_apt - Manage packages with apt-get +cdist-type__debconf_set_selections - Setup debconf selections DESCRIPTION ----------- -apt-get is usually used on Debian and variants (like Ubuntu) to -manage packages. +On Debian and alike systems debconf-set-selections(1) can be used +to setup configuration parameters. REQUIRED PARAMETERS ------------------- -state:: - Either "installed" or "deinstalled". - - -OPTIONAL PARAMETERS -------------------- -name:: - If supplied, use the name and not the object id as the package name. - -preseed:: +file:: If supplied, use the given filename as input for debconf-set-selections(1) @@ -33,24 +24,17 @@ EXAMPLES -------- -------------------------------------------------------------------------------- -# Ensure zsh in installed -__package_apt zsh --state installed +# Setup configuration for nslcd +__debconf_set_selections nslcd --file /path/to/file -# In case you only want *a* webserver, but don't care which one -__package_apt webserver --state installed --name nginx - -# Install package with defaults (from a type) -__package_apt postfix --state installed --preseed "$__type/files/postfix-seed" - -# Remove obsolete package -__package_apt puppet --state deinstalled +# Setup configuration for nslcd from another type +__debconf_set_selections nslcd --file "$__type/files/preseed/nslcd" -------------------------------------------------------------------------------- SEE ALSO -------- - cdist-type(7) -- cdist-type__package(7) COPYING diff --git a/conf/type/__debconf_set_selections/parameter/optional b/conf/type/__debconf_set_selections/parameter/optional deleted file mode 100644 index 2dae648e..00000000 --- a/conf/type/__debconf_set_selections/parameter/optional +++ /dev/null @@ -1,3 +0,0 @@ -name -preseed -version diff --git a/conf/type/__debconf_set_selections/parameter/required b/conf/type/__debconf_set_selections/parameter/required index ff72b5c7..f73f3093 100644 --- a/conf/type/__debconf_set_selections/parameter/required +++ b/conf/type/__debconf_set_selections/parameter/required @@ -1 +1 @@ -state +file From e21283c579ef4e5da7d590a2b0338668cd2f16fc Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 1 Apr 2011 13:08:47 +0200 Subject: [PATCH 07/41] remove preseeding support from __package_apt Signed-off-by: Nico Schottelius --- conf/type/__package_apt/man.text | 6 ------ conf/type/__package_apt/parameter/optional | 1 - 2 files changed, 7 deletions(-) diff --git a/conf/type/__package_apt/man.text b/conf/type/__package_apt/man.text index 8b7476b4..0780124d 100644 --- a/conf/type/__package_apt/man.text +++ b/conf/type/__package_apt/man.text @@ -25,9 +25,6 @@ OPTIONAL PARAMETERS name:: If supplied, use the name and not the object id as the package name. -preseed:: - If supplied, use the given filename as input for debconf-set-selections(1) - EXAMPLES -------- @@ -39,9 +36,6 @@ __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 -# Install package with defaults (from a type) -__package_apt postfix --state installed --preseed "$__type/files/postfix-seed" - # Remove obsolete package __package_apt puppet --state deinstalled -------------------------------------------------------------------------------- diff --git a/conf/type/__package_apt/parameter/optional b/conf/type/__package_apt/parameter/optional index 2dae648e..a52167d3 100644 --- a/conf/type/__package_apt/parameter/optional +++ b/conf/type/__package_apt/parameter/optional @@ -1,3 +1,2 @@ name -preseed version From 1b87fc7c3f0a6d3e6135d59f8a0452b7cdf3f907 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 1 Apr 2011 13:10:41 +0200 Subject: [PATCH 08/41] changes for 1.6.0 Signed-off-by: Nico Schottelius --- doc/changelog | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/doc/changelog b/doc/changelog index 2fcb8b46..1b9ede30 100644 --- a/doc/changelog +++ b/doc/changelog @@ -1,3 +1,7 @@ +1.6.0: + * Removed --preseed support from __package_apt + * New type __debconf_set_selections which allows to preseed debian packages + 1.5.0: 2011-04-01 * Add basic cache functionality * New type __process From cee51f00880919638eab04c40dc988c3adf9f81f Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 1 Apr 2011 13:12:00 +0200 Subject: [PATCH 09/41] make __package_apt use DEBIAN_FRONTEND=noninteractive Signed-off-by: Nico Schottelius --- conf/type/__package_apt/gencode-remote | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/conf/type/__package_apt/gencode-remote b/conf/type/__package_apt/gencode-remote index b2c7179d..e38653e9 100755 --- a/conf/type/__package_apt/gencode-remote +++ b/conf/type/__package_apt/gencode-remote @@ -37,17 +37,19 @@ fi state="$(cat "$__object/parameter/state")" is_installed="$(grep "^Status: install ok installed" "$__object/explorer/pkg_status" || true)" +aptget="DEBIAN_FRONTEND=noninteractive apt-get --quiet --yes" + case "$state" in installed) # Install only if non-existent if [ -z "$is_installed" ]; then - echo apt-get --quiet --yes install \"$name\" + echo $aptget install \"$name\" fi ;; uninstalled) # Remove only if existent if [ -n "$is_installed" ]; then - echo apt-get --quiet --yes remove \"$name\" + echo $aptget remove \"$name\" fi ;; esac From e700437b01f7bebb6496aba9d55b6a0894319ccd Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 2 Apr 2011 01:20:24 +0200 Subject: [PATCH 10/41] also detect fedora Signed-off-by: Nico Schottelius --- conf/explorer/os | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/conf/explorer/os b/conf/explorer/os index f7481193..b636d980 100755 --- a/conf/explorer/os +++ b/conf/explorer/os @@ -43,6 +43,12 @@ if [ -f /etc/gentoo-release ]; then exit 0 fi +# Fedora is also Redhat, thus return before redhat! +if grep -q ^Fedora /etc/redhat-release 2>/dev/null; then + echo fedora + exit 0 +fi + if [ -f /etc/redhat-release ]; then echo redhat exit 0 From bcfba18e6f15a13bbb7533d9106ad7e65aa0e24d Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 2 Apr 2011 01:22:09 +0200 Subject: [PATCH 11/41] more upcoming changes Signed-off-by: Nico Schottelius --- doc/changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/changelog b/doc/changelog index 1b9ede30..c54a5358 100644 --- a/doc/changelog +++ b/doc/changelog @@ -1,6 +1,7 @@ 1.6.0: * Removed --preseed support from __package_apt * New type __debconf_set_selections which allows to preseed debian packages + * Explorer/os: Support Fedora 1.5.0: 2011-04-01 * Add basic cache functionality From afc16667f40945b42a493d6610e49495fc13e330 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 2 Apr 2011 01:25:57 +0200 Subject: [PATCH 12/41] more production machines Signed-off-by: Nico Schottelius --- README | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README b/README index 1fd28ffd..18352d5a 100644 --- a/README +++ b/README @@ -230,7 +230,7 @@ Yes, I'm actually eating my own dogfood and currently managing * [xfce](http://www.xfce.org/) (lightweight desktop environment) * [slim](http://slim.berlios.de/) (graphical login manager for X11) -with cdist on a total of **9** production machines of the +with cdist on a total of **20** production machines of the [Systems Group](http://www.systems.ethz.ch) at the [ETH Zurich](http://www.ethz.ch) as well at home. From c617dc0e8fc9e1e1949c40b2eb167957da969991 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 2 Apr 2011 01:49:52 +0200 Subject: [PATCH 13/41] cleanup readme Signed-off-by: Nico Schottelius --- README | 65 +++++++++++++++++++--------------------------------------- 1 file changed, 21 insertions(+), 44 deletions(-) diff --git a/README b/README index 18352d5a..bb370b35 100644 --- a/README +++ b/README @@ -24,57 +24,34 @@ other configuration management systems like [cfengine](http://www.cfengine.org/), [bcfg2](http://trac.mcs.anl.gov/projects/bcfg2), [chef](http://wiki.opscode.com/display/chef/) -and [puppet](http://www.puppetlabs.com/), but -it ticks differently: +and [puppet](http://www.puppetlabs.com/), but it ticks differently. +Here are some features that makes it unique: - * cdist sticks completly to the KISS (keep it simple and stupid) paradigma - * cdist's core is very small (< 1k lines of code) - * There is only one type to extend cdist called ***type***. - * One main development target: ***It must be incredible easy to add new types.*** - * cdist is UNIX - * It reuses existing tools like cat, find, mv, ... - * cdist's documentation is bundled as manpages - * cdist is written in POSIX shell - * No special requirements like high level interpreters needed on server or target +[[!table data=""" +Simplicity | There is only one type to extend cdist called ***type*** +Design | Type and core cleanly seperated +Design | cdist sticks completly to the KISS (keep it simple and stupid) paradigma +Design | Meaningful error messages - do not lose time debugging error messages +Design | Consistency in behaviour, naming and documentation +Design | No surprise factor: Only do what is obviously clear, no magic +Design | Define target state, do not focus on methods or scripts +Small core | cdist's core is very small - less code, less bugs +Fast development | Focus on straightforwardness of type creation is a main development objective +Requirements, Scalability | No central server needed, cdist operates in push mode and can be run from any computer +Requirements, Scalability, Upgrade | cdist only needs to be updated on the master, not on the target hosts +Requirements | cdist requires only SSH and a shell on the target +Requirements | +UNIX | Reuse of existing tools like cat, find, mv, ... +UNIX, familar environment, documentation | Is available as manpages and HTML +UNIX, simplicity, familar environment | cdist is written in POSIX shell +UNIX, simplicity, familar environment | cdist is configured in POSIX shell +"""]] ### Documentation The cdist documentation is included as manpages in the distribution. You can [browse the documentation for the latest version online](man) as well. -### Architecture - - * Push mode (server pushes configuration) - * User defines configuration in shell scripts (called ***manifests***) - * Generates internal configuration (cconfig style) - * Uses ***types*** to generate code be executed on the target - * And finally executes the code on the target / applies the configuration - -### Features - - * Elegant code and clean design - * Type and core cleanly seperated - * Small codebase in core - * Good documentation (man pages) - * Consistency in behaviour, naming and documentation - * Meaningful error messages - * Either standard error messages from tools or added description for clearification - * The no surprise factor - * No magic guessing of what the user wants - * Simple and well-known DSL - * Posix shell - * Easy integration into bare metal installations - * requires only ssh + sh - * Easy upgrade - * ***There is no need to update cdist on target hosts!*** - * cdist only needs to be updated on the master server(s) - * Very easy to extend - * Can be done via types, which can be stacked on top of others - * Reuse of existing functionality - * sh, ssh, find, rm, mv, ... - * Very easy to debug - * Just add set -x in the scripts - ### OS support cdist was tested or is know to run on at least From 77766d29a21da7b7ba0e4a1e00fe1cd42578698f Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 2 Apr 2011 01:50:45 +0200 Subject: [PATCH 14/41] +header Signed-off-by: Nico Schottelius --- README | 1 + 1 file changed, 1 insertion(+) diff --git a/README b/README index bb370b35..26cd1ef2 100644 --- a/README +++ b/README @@ -28,6 +28,7 @@ and [puppet](http://www.puppetlabs.com/), but it ticks differently. Here are some features that makes it unique: [[!table data=""" +Keywords | Description Simplicity | There is only one type to extend cdist called ***type*** Design | Type and core cleanly seperated Design | cdist sticks completly to the KISS (keep it simple and stupid) paradigma From e19c079f24113f46cd006e37e47730ccf014c948 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 2 Apr 2011 02:00:20 +0200 Subject: [PATCH 15/41] add template for new type __package_yum Signed-off-by: Nico Schottelius --- conf/type/__package_yum/explorer/pkg_version | 30 +++++++++++ conf/type/__package_yum/gencode-remote | 52 +++++++++++++++++++ conf/type/__package_yum/man.text | 53 ++++++++++++++++++++ conf/type/__package_yum/parameter/optional | 1 + conf/type/__package_yum/parameter/required | 1 + 5 files changed, 137 insertions(+) create mode 100755 conf/type/__package_yum/explorer/pkg_version create mode 100755 conf/type/__package_yum/gencode-remote create mode 100644 conf/type/__package_yum/man.text create mode 100644 conf/type/__package_yum/parameter/optional create mode 100644 conf/type/__package_yum/parameter/required diff --git a/conf/type/__package_yum/explorer/pkg_version b/conf/type/__package_yum/explorer/pkg_version new file mode 100755 index 00000000..4f612423 --- /dev/null +++ b/conf/type/__package_yum/explorer/pkg_version @@ -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 . +# +# +# Retrieve the status of a package - parsed dpkg output +# + +if [ -f "$__object/parameter/name" ]; then + name="$(cat "$__object/parameter/name")" +else + name="$__object_id" +fi + +pacman -Q "$name" 2>/dev/null | awk '{ print $2 }' diff --git a/conf/type/__package_yum/gencode-remote b/conf/type/__package_yum/gencode-remote new file mode 100755 index 00000000..536b7708 --- /dev/null +++ b/conf/type/__package_yum/gencode-remote @@ -0,0 +1,52 @@ +#!/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 . +# +# +# Manage packages with Pacman (mostly archlinux) +# + +# Debug +# exec >&2 +# set -x + +pacopts="--noconfirm --noprogressbar" + +if [ -f "$__object/parameter/name" ]; then + name="$__object/parameter/name" +else + name="$__object_id" +fi + +state="$(cat "$__object/parameter/state")" +pkg_version="$(cat "$__object/explorer/pkg_version")" + +case "$state" in + installed) + + # Empty? Not installed. + if [ -z "$pkg_version" ]; then + echo pacman "$pacopts" -S \"$name\" + fi + ;; + uninstalled) + if [ "$pkg_version" ]; then + echo pacman "$pacopts" -R \"$name\" + fi + ;; +esac diff --git a/conf/type/__package_yum/man.text b/conf/type/__package_yum/man.text new file mode 100644 index 00000000..35a7e44c --- /dev/null +++ b/conf/type/__package_yum/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/conf/type/__package_yum/parameter/optional b/conf/type/__package_yum/parameter/optional new file mode 100644 index 00000000..f121bdbf --- /dev/null +++ b/conf/type/__package_yum/parameter/optional @@ -0,0 +1 @@ +name diff --git a/conf/type/__package_yum/parameter/required b/conf/type/__package_yum/parameter/required new file mode 100644 index 00000000..ff72b5c7 --- /dev/null +++ b/conf/type/__package_yum/parameter/required @@ -0,0 +1 @@ +state From d9e2493eb996e164a27826779477ce93a84cdda3 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 2 Apr 2011 02:13:44 +0200 Subject: [PATCH 16/41] add fedora support to __package Signed-off-by: Nico Schottelius --- conf/type/__package/manifest | 1 + 1 file changed, 1 insertion(+) diff --git a/conf/type/__package/manifest b/conf/type/__package/manifest index d8b55814..f41cceac 100755 --- a/conf/type/__package/manifest +++ b/conf/type/__package/manifest @@ -33,6 +33,7 @@ else archlinux) type="pacman" ;; debian|ubuntu) type="apt" ;; gentoo) type="emerge" ;; + fedora) type="yum" ;; *) echo "Don't know how to manage packages on: $os" >&2 exit 1 From 981df12e9a341c38b279726c62832f1150a2e1f0 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 2 Apr 2011 02:15:26 +0200 Subject: [PATCH 17/41] document changes Signed-off-by: Nico Schottelius --- doc/changelog | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/doc/changelog b/doc/changelog index c54a5358..fe22e838 100644 --- a/doc/changelog +++ b/doc/changelog @@ -1,7 +1,9 @@ 1.6.0: + * New Type __package_yum + * New type __debconf_set_selections + * Type __package gained Fedora support * Removed --preseed support from __package_apt - * New type __debconf_set_selections which allows to preseed debian packages - * Explorer/os: Support Fedora + * explorer/os: gained Fedora support 1.5.0: 2011-04-01 * Add basic cache functionality From bcc7d0e795360489b61568f6ff108f8799ea2488 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 2 Apr 2011 02:19:30 +0200 Subject: [PATCH 18/41] cleanup of gencode-remote Signed-off-by: Nico Schottelius --- conf/type/__package_yum/gencode-remote | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/conf/type/__package_yum/gencode-remote b/conf/type/__package_yum/gencode-remote index 536b7708..e20e0001 100755 --- a/conf/type/__package_yum/gencode-remote +++ b/conf/type/__package_yum/gencode-remote @@ -18,15 +18,9 @@ # along with cdist. If not, see . # # -# Manage packages with Pacman (mostly archlinux) +# Manage packages with yum (mostly Fedora) # -# Debug -# exec >&2 -# set -x - -pacopts="--noconfirm --noprogressbar" - if [ -f "$__object/parameter/name" ]; then name="$__object/parameter/name" else @@ -34,19 +28,17 @@ else fi state="$(cat "$__object/parameter/state")" -pkg_version="$(cat "$__object/explorer/pkg_version")" +opts="--assumeyes --quiet" case "$state" in installed) - - # Empty? Not installed. - if [ -z "$pkg_version" ]; then - echo pacman "$pacopts" -S \"$name\" + if grep -q "is not installed\$" "$__object/explorer/pkg_version"; then + echo yum $opts install \"$name\" fi ;; uninstalled) - if [ "$pkg_version" ]; then - echo pacman "$pacopts" -R \"$name\" + if ! grep -q "is not installed\$" "$__object/explorer/pkg_version"; then + echo yum $opts remove \"$name\" fi ;; esac From a778dee9fcdbc4d97f15b6a1832e3e1fe97b4ed1 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 2 Apr 2011 02:19:47 +0200 Subject: [PATCH 19/41] use rpm -q to get status Signed-off-by: Nico Schottelius --- conf/type/__package_yum/explorer/pkg_version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/type/__package_yum/explorer/pkg_version b/conf/type/__package_yum/explorer/pkg_version index 4f612423..66f76f12 100755 --- a/conf/type/__package_yum/explorer/pkg_version +++ b/conf/type/__package_yum/explorer/pkg_version @@ -27,4 +27,4 @@ else name="$__object_id" fi -pacman -Q "$name" 2>/dev/null | awk '{ print $2 }' +rpm -q "$name" 2>/dev/null || true From 740d279753e09c9178cdcc43f4302a86a1d331ba Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 2 Apr 2011 02:20:19 +0200 Subject: [PATCH 20/41] add fedora to readme Signed-off-by: Nico Schottelius --- README | 1 + 1 file changed, 1 insertion(+) diff --git a/README b/README index 26cd1ef2..e8f6e0bf 100644 --- a/README +++ b/README @@ -59,6 +59,7 @@ cdist was tested or is know to run on at least * [Archlinux](http://www.archlinux.org/) * [Debian](http://www.debian.org/) + * [Fedora](http://fedoraproject.org/) * [Gentoo](http://www.gentoo.org/) * [Mac OS X](http://www.apple.com/macosx/) * [OpenBSD](http://www.openbsd.org) From c532a2ccd3d19ebd36466be9231c68be7a68bbb7 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 2 Apr 2011 02:22:08 +0200 Subject: [PATCH 21/41] remove one Error of Error: Error: /home/users/nico/oeffentlich/rechner/projekte/cdist-used/conf/type/__nico_desktop/manifest exited non-zero. Signed-off-by: Nico Schottelius --- bin/cdist-config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/cdist-config b/bin/cdist-config index fac1b5c6..026d8419 100755 --- a/bin/cdist-config +++ b/bin/cdist-config @@ -158,7 +158,7 @@ __cdist_debug_echo() __cdist_exec_fail_on_error() { sh -e "$@" - [ "$?" -eq 0 ] || __cdist_exit_err "Error: $1 exited non-zero." + [ "$?" -eq 0 ] || __cdist_exit_err "$1 exited non-zero." } __cdist_exit_err() From 13f4140b3df9e6204451d444bdb6f504fd81771b Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 2 Apr 2011 02:26:42 +0200 Subject: [PATCH 22/41] update manpage for __package_yum Signed-off-by: Nico Schottelius --- conf/type/__package_yum/man.text | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/conf/type/__package_yum/man.text b/conf/type/__package_yum/man.text index 35a7e44c..262068c6 100644 --- a/conf/type/__package_yum/man.text +++ b/conf/type/__package_yum/man.text @@ -1,17 +1,16 @@ -cdist-type__package_pacman(7) -============================= +cdist-type__package_yum(7) +========================== Nico Schottelius NAME ---- -cdist-type__package_pacman - Manage packages with pacman +cdist-type__package_yum - Manage packages with yum DESCRIPTION ----------- -Pacman is usually used on the Archlinux distribution to manage -packages. +Yum is usually used on the Fedora distribution to manage packages. REQUIRED PARAMETERS @@ -31,13 +30,13 @@ EXAMPLES -------------------------------------------------------------------------------- # Ensure zsh in installed -__package_pacman zsh --state installed +__package_yum zsh --state installed # If you don't want to follow pythonX packages, but always use python -__package_pacman python --state installed --name python2 +__package_yum python --state installed --name python2 # Remove obsolete package -__package_pacman puppet --state deinstalled +__package_yum puppet --state deinstalled -------------------------------------------------------------------------------- From 44b11b99198ecdef188fb6819a9ff3a3de7b9d8b Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 2 Apr 2011 02:34:35 +0200 Subject: [PATCH 23/41] yum is funny Signed-off-by: Nico Schottelius --- doc/dev/logs/2011-04-02.yum | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 doc/dev/logs/2011-04-02.yum diff --git a/doc/dev/logs/2011-04-02.yum b/doc/dev/logs/2011-04-02.yum new file mode 100644 index 00000000..dd3687c8 --- /dev/null +++ b/doc/dev/logs/2011-04-02.yum @@ -0,0 +1,9 @@ +Fun with yum: + +[root@brett ~]# yum --assumeyes --quiet install "vim" +Package 2:vim-enhanced-7.3.056-1.fc14.x86_64 already installed and latest version +[root@brett ~]# rpm -q vim +package vim is not installed +[root@brett ~]# + +(Me || yum) == dumb? From aedbc263d7325381a8bed03e24c31dbcf810e7d0 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 2 Apr 2011 02:49:57 +0200 Subject: [PATCH 24/41] need to use --whatprovides This ensure we also check for other packages which are used instead of the requested one, which does not work with rpm -q: [root@brett ~]# rpm -q vim package vim is not installed [root@brett ~]# yum --assumeyes --quiet install "vim" Package 2:vim-enhanced-7.3.056-1.fc14.x86_64 already installed and latest version [root@brett ~]# rpm -q --whatprovides vim vim-enhanced-7.3.056-1.fc14.x86_64 Signed-off-by: Nico Schottelius --- conf/type/__package_yum/explorer/pkg_version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/type/__package_yum/explorer/pkg_version b/conf/type/__package_yum/explorer/pkg_version index 66f76f12..0e078f68 100755 --- a/conf/type/__package_yum/explorer/pkg_version +++ b/conf/type/__package_yum/explorer/pkg_version @@ -27,4 +27,4 @@ else name="$__object_id" fi -rpm -q "$name" 2>/dev/null || true +rpm -q --whatprovides "$name" 2>/dev/null || true From 0b7024a2cc3449e2610fdd63dd57731ad1ebded5 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 2 Apr 2011 02:53:07 +0200 Subject: [PATCH 25/41] adjust grep string Signed-off-by: Nico Schottelius --- conf/type/__package_yum/gencode-remote | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/conf/type/__package_yum/gencode-remote b/conf/type/__package_yum/gencode-remote index e20e0001..7d0d60b8 100755 --- a/conf/type/__package_yum/gencode-remote +++ b/conf/type/__package_yum/gencode-remote @@ -29,15 +29,20 @@ fi state="$(cat "$__object/parameter/state")" +cat "$__object/explorer/pkg_version" + opts="--assumeyes --quiet" + +not_installed="^no package provides" + case "$state" in installed) - if grep -q "is not installed\$" "$__object/explorer/pkg_version"; then + if grep -q "$not_installed" "$__object/explorer/pkg_version"; then echo yum $opts install \"$name\" fi ;; uninstalled) - if ! grep -q "is not installed\$" "$__object/explorer/pkg_version"; then + if ! grep -q "$not_installed" "$__object/explorer/pkg_version"; then echo yum $opts remove \"$name\" fi ;; From 4ab1fdceff36c983f07960d2a151560d668ecb60 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 2 Apr 2011 02:57:02 +0200 Subject: [PATCH 26/41] remove evil debug Signed-off-by: Nico Schottelius --- conf/type/__package_yum/gencode-remote | 2 -- 1 file changed, 2 deletions(-) diff --git a/conf/type/__package_yum/gencode-remote b/conf/type/__package_yum/gencode-remote index 7d0d60b8..033298b1 100755 --- a/conf/type/__package_yum/gencode-remote +++ b/conf/type/__package_yum/gencode-remote @@ -29,8 +29,6 @@ fi state="$(cat "$__object/parameter/state")" -cat "$__object/explorer/pkg_version" - opts="--assumeyes --quiet" not_installed="^no package provides" From 5f0ecb0831157bf0b5112afc6c4344adfc05cc3a Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 2 Apr 2011 03:12:31 +0200 Subject: [PATCH 27/41] yum confuses me, document it, so others are saved Signed-off-by: Nico Schottelius --- conf/type/__package_yum/man.text | 2 ++ 1 file changed, 2 insertions(+) diff --git a/conf/type/__package_yum/man.text b/conf/type/__package_yum/man.text index 262068c6..b2f57606 100644 --- a/conf/type/__package_yum/man.text +++ b/conf/type/__package_yum/man.text @@ -11,6 +11,8 @@ cdist-type__package_yum - Manage packages with yum DESCRIPTION ----------- Yum is usually used on the Fedora distribution to manage packages. +If you specify an unknown package, yum will display the +slightly confusing error message "Error: Nothing to do". REQUIRED PARAMETERS From 762fa52638c2bd6c080396121377ab3eec005ac4 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 2 Apr 2011 03:30:35 +0200 Subject: [PATCH 28/41] fixup cdist-reference: match only on .7 now, otherwise .html and .text is shown in manpage Signed-off-by: Nico Schottelius --- doc/man/cdist-reference.text.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/man/cdist-reference.text.sh b/doc/man/cdist-reference.text.sh index 6358db9c..936e0bba 100755 --- a/doc/man/cdist-reference.text.sh +++ b/doc/man/cdist-reference.text.sh @@ -187,7 +187,7 @@ SEE ALSO -------- - cdist(7) eof -for type in man7/cdist-type__*; do +for type in man7/cdist-type__*.7; do name_1="${type#man7/}" name_2="${name_1%.7}" From 21aacd44b44c70e319c2c4991f9ee998666dfa92 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 2 Apr 2011 03:36:41 +0200 Subject: [PATCH 29/41] remove double information from reference Signed-off-by: Nico Schottelius --- doc/man/cdist-reference.text.sh | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/doc/man/cdist-reference.text.sh b/doc/man/cdist-reference.text.sh index 936e0bba..8fb24362 100755 --- a/doc/man/cdist-reference.text.sh +++ b/doc/man/cdist-reference.text.sh @@ -135,19 +135,8 @@ tmp_dir:: TYPES ----- -The following types are available: - -eof -for type in man7/cdist-type__*; do - name_1="${type#man7/cdist-type}" - name_2="${name_1%.7}" - - name="$name_2" - echo "- $name" -done - -cat << eof - +The available types are listed in the SEE ALSO section +and are referenced as cdist-type__TYPENAME. VARIABLES --------- From 18e433dd859644a8d69c07ff2a22e14c2091d963 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 2 Apr 2011 14:24:20 +0200 Subject: [PATCH 30/41] import corrected __group from nico/nico Signed-off-by: Nico Schottelius --- conf/type/__group/gencode-remote | 45 ++++++++++++++++---------------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/conf/type/__group/gencode-remote b/conf/type/__group/gencode-remote index 527a6079..ac7e0ebb 100755 --- a/conf/type/__group/gencode-remote +++ b/conf/type/__group/gencode-remote @@ -1,6 +1,7 @@ #!/bin/sh # # 2011 Steven Armstrong (steven-cdist at armstrong.cc) +# 2011 Nico Schottelius (nico-cdist at schottelius.org) # # This file is part of cdist. # @@ -23,16 +24,6 @@ name="$__object_id" -command= -if grep -q "^$name" "$__object/explorer/group"; then - # group exists - command="groupmod" -else - # group does not exist - command="groupadd" -fi - - get_current_value() { local key="$1" local index @@ -46,21 +37,29 @@ get_current_value() { cut -d':' -f $index "$__object/explorer/group" } - set -- "$@" cd "$__object/parameter" -for property in $(ls .); do - current_value=$(get_current_value "$property") - new_value="$(cat "$property")" - if [ "$new_value" != "$current_value" ]; then - # Shedule changed properties for update - set -- "$@" "--$property" \"$new_value\" + +if grep -q "^$name" "$__object/explorer/group"; then + # group exists, only change changed values + for property in $(ls .); do + current_value=$(get_current_value "$property") + new_value="$(cat "$property")" + if [ "$new_value" != "$current_value" ]; then + # Shedule changed properties for update + set -- "$@" "--$property" \"$new_value\" + fi + done + + if [ $# -gt 0 ]; then + # Update changed properties + echo groupmod $@ $name fi -done +else + for property in $(ls .); do + new_value="$(cat "$property")" + set -- "$@" "--$property" \"$new_value\" + done - -if [ $# -gt 0 ]; then - # Update changed properties - echo $command $@ $name + echo groupadd "$@" "$name" fi - From 69a17d0b0e6d9f12cbf743ce739aaef3caf93d65 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 2 Apr 2011 14:25:00 +0200 Subject: [PATCH 31/41] remove unecessary set -- "$@" Signed-off-by: Nico Schottelius --- conf/type/__group/gencode-remote | 2 -- 1 file changed, 2 deletions(-) diff --git a/conf/type/__group/gencode-remote b/conf/type/__group/gencode-remote index ac7e0ebb..35df5424 100755 --- a/conf/type/__group/gencode-remote +++ b/conf/type/__group/gencode-remote @@ -37,9 +37,7 @@ get_current_value() { cut -d':' -f $index "$__object/explorer/group" } -set -- "$@" cd "$__object/parameter" - if grep -q "^$name" "$__object/explorer/group"; then # group exists, only change changed values for property in $(ls .); do From 252b511da7c4157b8950364cebc0ad6747965463 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 2 Apr 2011 14:31:50 +0200 Subject: [PATCH 32/41] done++ Signed-off-by: Nico Schottelius --- doc/changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/changelog b/doc/changelog index fe22e838..a1f218e8 100644 --- a/doc/changelog +++ b/doc/changelog @@ -1,6 +1,7 @@ 1.6.0: * New Type __package_yum * New type __debconf_set_selections + * Fix Type __group in case of __group NAME syntax * Type __package gained Fedora support * Removed --preseed support from __package_apt * explorer/os: gained Fedora support From 1310a1e42b3f0af84e7e5b8bb3299bd928ea60a8 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 2 Apr 2011 14:40:31 +0200 Subject: [PATCH 33/41] ++todo Signed-off-by: Nico Schottelius --- doc/dev/todo/TAKEME | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/doc/dev/todo/TAKEME b/doc/dev/todo/TAKEME index 7a8c4583..ad6561a6 100644 --- a/doc/dev/todo/TAKEME +++ b/doc/dev/todo/TAKEME @@ -26,13 +26,14 @@ CORE TYPES ------ -Types to be written/extended: - - __ssh-keys (host/user) - - Think about __service - necessary? - - __file_edit - - regexp replace (can probably cover all?) - -> aka sed. - - __cron +- __ssh-keys (host/user) +- __file_edit + - regexp replace (can probably cover all?) + -> aka sed. +- __cron +- __user: + add option to include --create-home + fix __user NAME case (same issue as __group) DOCUMENTATION -------------- From de879bf5215db28d82631fc3ec495233aad84c8f Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 4 Apr 2011 09:45:25 +0200 Subject: [PATCH 34/41] emphasise SSH Signed-off-by: Nico Schottelius --- README | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README b/README index e8f6e0bf..aba67707 100644 --- a/README +++ b/README @@ -31,7 +31,7 @@ Here are some features that makes it unique: Keywords | Description Simplicity | There is only one type to extend cdist called ***type*** Design | Type and core cleanly seperated -Design | cdist sticks completly to the KISS (keep it simple and stupid) paradigma +Design | Sticks completly to the KISS (keep it simple and stupid) paradigma Design | Meaningful error messages - do not lose time debugging error messages Design | Consistency in behaviour, naming and documentation Design | No surprise factor: Only do what is obviously clear, no magic @@ -40,8 +40,8 @@ Small core | cdist's core is very small - less code, less bugs Fast development | Focus on straightforwardness of type creation is a main development objective Requirements, Scalability | No central server needed, cdist operates in push mode and can be run from any computer Requirements, Scalability, Upgrade | cdist only needs to be updated on the master, not on the target hosts -Requirements | cdist requires only SSH and a shell on the target -Requirements | +Requirements, Security | Uses well-know [SSH](http://www.openssh.com/) as transport protocol +Requirements, Simplicity | Requires only shell and SSH server on the target UNIX | Reuse of existing tools like cat, find, mv, ... UNIX, familar environment, documentation | Is available as manpages and HTML UNIX, simplicity, familar environment | cdist is written in POSIX shell From 674e1f58f8ff8924efe5d322d062451a1fa4b1e2 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 4 Apr 2011 09:45:52 +0200 Subject: [PATCH 35/41] todo for 1.6 Signed-off-by: Nico Schottelius --- doc/dev/todo/1.6 | 1 + 1 file changed, 1 insertion(+) create mode 100644 doc/dev/todo/1.6 diff --git a/doc/dev/todo/1.6 b/doc/dev/todo/1.6 new file mode 100644 index 00000000..1be7274f --- /dev/null +++ b/doc/dev/todo/1.6 @@ -0,0 +1 @@ +- adjust documentation / stages From 4b76d8a7e087fe280cc11d8d91b99359b6fbac89 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 4 Apr 2011 10:45:41 +0200 Subject: [PATCH 36/41] __user: remove =~, cleanup and beautify, replace cut with awk Signed-off-by: Nico Schottelius --- conf/type/__user/gencode-remote | 96 +++++++++++++++------------------ 1 file changed, 43 insertions(+), 53 deletions(-) diff --git a/conf/type/__user/gencode-remote b/conf/type/__user/gencode-remote index c53d8c40..c7dbac41 100755 --- a/conf/type/__user/gencode-remote +++ b/conf/type/__user/gencode-remote @@ -23,60 +23,50 @@ name="$__object_id" -command= -if grep -q "^$name" "$__object/explorer/passwd"; then - # user exists - command="usermod" -else - # user does not exist - command="useradd" -fi - - -get_current_value() { - local key="$1" - local new_value="$2" - - local explorer="$__object/explorer/passwd" - local index - case "$key" in - password) - explorer="$__object/explorer/shadow" - index=2 - ;; - uid) index=3;; - gid) - if [[ $new_value =~ ^[0-9]+$ ]]; then - # numeric gid - index=4 - else - # group name - explorer="$__object/explorer/group" - index=1 - fi - ;; - comment) index=5;; - home) index=6;; - shell) index=7;; - esac - cut -d':' -f $index "$explorer" -} - - -set -- "$@" cd "$__object/parameter" -for property in $(ls .); do - new_value="$(cat "$property")" - current_value=$(get_current_value "$property" "$new_value") - if [ "$new_value" != "$current_value" ]; then - # Shedule changed properties for update - set -- "$@" "--$property" \"$new_value\" +if grep -q "^${name}:" "$__object/explorer/passwd"; then + for property in $(ls .); do + new_value="$(cat "$property")" + + file="$__object/explorer/passwd" + + case "$key" in + password) + field=3 + file="$__object/explorer/shadow" + ;; + gid) + if $(echo "$new_value" | grep -q '^[0-9][0-9]*$'); then + field=4 + else + # group name + file="$__object/explorer/group" + field=1 + fi + ;; + uid) field=3 ;; + comment) field=5 ;; + home) field=6 ;; + shell) field=7 ;; + esac + + current_value="$(awk -F: '{ print $ENVIRON["field"] }' < "$file")" + + if [ "$new_value" != "$current_value" ]; then + # Shedule changed properties for update + set -- "$@" "--$property" \"$new_value\" + fi + done + + if [ $# -gt 0 ]; then + # Update changed properties + echo usermod "$@" "$name" fi -done +else + for property in $(ls .); do + new_value="$(cat "$property")" + set -- "$@" "--$property" \"$new_value\" + done - -if [ $# -gt 0 ]; then - # Update changed properties - echo $command $@ $name + echo useradd "$@" "$name" fi - From db425d39254c35c8fa8ba85678dafced87ef64ba Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 4 Apr 2011 10:59:04 +0200 Subject: [PATCH 37/41] use property, not key anymore Signed-off-by: Nico Schottelius --- conf/type/__user/gencode-remote | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/conf/type/__user/gencode-remote b/conf/type/__user/gencode-remote index c7dbac41..8f4222c3 100755 --- a/conf/type/__user/gencode-remote +++ b/conf/type/__user/gencode-remote @@ -1,6 +1,7 @@ #!/bin/sh # # 2011 Steven Armstrong (steven-cdist at armstrong.cc) +# 2011 Nico Schottelius (nico-cdist at schottelius.org) # # This file is part of cdist. # @@ -30,7 +31,7 @@ if grep -q "^${name}:" "$__object/explorer/passwd"; then file="$__object/explorer/passwd" - case "$key" in + case "$property" in password) field=3 file="$__object/explorer/shadow" @@ -50,18 +51,15 @@ if grep -q "^${name}:" "$__object/explorer/passwd"; then shell) field=7 ;; esac + export field current_value="$(awk -F: '{ print $ENVIRON["field"] }' < "$file")" if [ "$new_value" != "$current_value" ]; then - # Shedule changed properties for update set -- "$@" "--$property" \"$new_value\" fi done - if [ $# -gt 0 ]; then - # Update changed properties - echo usermod "$@" "$name" - fi + [ $# -gt 0 ] && echo usermod "$@" "$name" else for property in $(ls .); do new_value="$(cat "$property")" From d49e481a87d920fab6dc157e663cdf6d324c61fd Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 4 Apr 2011 11:00:15 +0200 Subject: [PATCH 38/41] match on name: not name, may be invalid Signed-off-by: Nico Schottelius --- conf/type/__group/gencode-remote | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/type/__group/gencode-remote b/conf/type/__group/gencode-remote index 35df5424..a8a8397d 100755 --- a/conf/type/__group/gencode-remote +++ b/conf/type/__group/gencode-remote @@ -38,7 +38,7 @@ get_current_value() { } cd "$__object/parameter" -if grep -q "^$name" "$__object/explorer/group"; then +if grep -q "^${name}:" "$__object/explorer/group"; then # group exists, only change changed values for property in $(ls .); do current_value=$(get_current_value "$property") From e464c5aaa223f3cfe80f20c3d42a1eb2b928adad Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 4 Apr 2011 11:04:00 +0200 Subject: [PATCH 39/41] simplify Signed-off-by: Nico Schottelius --- conf/type/__group/gencode-remote | 31 +++++++++++-------------------- 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/conf/type/__group/gencode-remote b/conf/type/__group/gencode-remote index a8a8397d..4cb05762 100755 --- a/conf/type/__group/gencode-remote +++ b/conf/type/__group/gencode-remote @@ -24,35 +24,26 @@ name="$__object_id" -get_current_value() { - local key="$1" - local index - case "$key" in - password) - cut -d':' -f 2 "$__object/explorer/gshadow" - break - ;; - gid) index=3;; - esac - cut -d':' -f $index "$__object/explorer/group" -} - cd "$__object/parameter" if grep -q "^${name}:" "$__object/explorer/group"; then - # group exists, only change changed values for property in $(ls .); do - current_value=$(get_current_value "$property") new_value="$(cat "$property")" + + case "$key" in + password) + current_value="$(awk -F: '{ print $2 }' < "$__object/explorer/gshadow")" + ;; + gid) + current_value="$(awk -F: '{ print $3 }' < "$__object/explorer/group")" + ;; + esac + if [ "$new_value" != "$current_value" ]; then - # Shedule changed properties for update set -- "$@" "--$property" \"$new_value\" fi done - if [ $# -gt 0 ]; then - # Update changed properties - echo groupmod $@ $name - fi + [ $# -gt 0 ] && echo groupmod $@ $name else for property in $(ls .); do new_value="$(cat "$property")" From 324fc13927b06ab201042e0e19912dd2e025dcd6 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 4 Apr 2011 11:07:15 +0200 Subject: [PATCH 40/41] +changes Signed-off-by: Nico Schottelius --- doc/changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/changelog b/doc/changelog index a1f218e8..f0641509 100644 --- a/doc/changelog +++ b/doc/changelog @@ -5,6 +5,7 @@ * Type __package gained Fedora support * Removed --preseed support from __package_apt * explorer/os: gained Fedora support + * Simplified types __user and __group 1.5.0: 2011-04-01 * Add basic cache functionality From 74e3447c40cb0497f13ec22f2faf38f80a5be7fe Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 4 Apr 2011 12:04:10 +0200 Subject: [PATCH 41/41] add example multi branch .git/config Signed-off-by: Nico Schottelius --- doc/man/man7/cdist-best-practice.text | 33 +++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/doc/man/man7/cdist-best-practice.text b/doc/man/man7/cdist-best-practice.text index aa499790..5ec01d5f 100644 --- a/doc/man/man7/cdist-best-practice.text +++ b/doc/man/man7/cdist-best-practice.text @@ -102,6 +102,39 @@ git checkout private git merge common -------------------------------------------------------------------------------- +The following **.git/config** is taken from a a real world scenario: +-------------------------------------------------------------------------------- +# Track upstream, merge from time to time +[remote "upstream"] + url = git://git.schottelius.org/cdist + fetch = +refs/heads/*:refs/remotes/upstream/* + +# Same as upstream, but works when being offline +[remote "local"] + fetch = +refs/heads/*:refs/remotes/local/* + url = /home/users/nico/p/cdist + +# Remote containing various ETH internal branches +[remote "eth"] + url = sans.ethz.ch:/home/services/sans/git/cdist-eth + fetch = +refs/heads/*:refs/remotes/eth/* + +# Public remote that contains my private changes to cdist upstream +[remote "nico"] + url = git.schottelius.org:/home/services/git/cdist-nico + fetch = +refs/heads/*:refs/remotes/nico/* + +# The "nico" branch will be synced with the remote nico, branch master +[branch "nico"] + remote = nico + merge = refs/heads/master + +# ETH stable contains rock solid configurations used in various places +[branch "eth-stable"] + remote = eth + merge = refs/heads/stable +-------------------------------------------------------------------------------- + Have a look at git-remote(1) to adjust the remote configuration, which allows you to push certain branches to certain remotes.