From 8549e74f45d631b3e5627b4f2527839601163a07 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 8 Mar 2011 21:25:35 +0100 Subject: [PATCH 01/41] name type manpages differently Signed-off-by: Nico Schottelius --- doc/man/cdist-type.text | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/doc/man/cdist-type.text b/doc/man/cdist-type.text index ad051585..3c7a1317 100644 --- a/doc/man/cdist-type.text +++ b/doc/man/cdist-type.text @@ -151,8 +151,7 @@ If you think your type may be useful for others, ensure it works with the current master branch of cdist and submit the git url containing the type for inclusion to the mailinglist **cdist at cdist -- at -- l.schottelius.org**. -Ensure a corresponding manpage named cdist-type-NAME (without -underscores) is included. +Ensure a corresponding manpage named cdist-type__NAME is included. SEE ALSO From 4bb7fb5c59c412d34503a295b78a294a2365d58f Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 8 Mar 2011 21:27:57 +0100 Subject: [PATCH 02/41] add template for manpage of __file type Signed-off-by: Nico Schottelius --- doc/man/cdist-type__file.text | 166 ++++++++++++++++++++++++++++++++++ 1 file changed, 166 insertions(+) create mode 100644 doc/man/cdist-type__file.text diff --git a/doc/man/cdist-type__file.text b/doc/man/cdist-type__file.text new file mode 100644 index 00000000..3c7a1317 --- /dev/null +++ b/doc/man/cdist-type__file.text @@ -0,0 +1,166 @@ +cdist-type(7) +============= +Nico Schottelius + + +NAME +---- +cdist-type - Functionality bundled + + +SYNOPSIS +-------- +Other languages name this module or class + + +DESCRIPTION +----------- +Types are the main component of cdist and define functionality. If you +use cdist, you'll write a type for every functionality you would like +to use. + + +HOW TO USE A TYPE +----------------- +You can use types from the initial manifest or the type manifest like a +normal command: + +-------------------------------------------------------------------------------- +# Creates empty file /etc/cdist-configured +__file /etc/cdist-configured --type file + +# Ensure tree is installed +__package tree --state installed +-------------------------------------------------------------------------------- + +Internally cdist-type-emulator(1) will be called from cdist-manifest-run(1) to +save the given parameters into a cconfig database, so they can be accessed by +the manifest and gencode scripts of the type (see below). + + +HOW TO WRITE A NEW TYPE +----------------------- +A type consists of + +- parameter (optional) +- manifest (optional) +- explorer (optional) +- gencode (optional) + +Types are stored below conf/type/. Their name should always be prefixed with +two underscores (__) to prevent collisions with other binaries in $PATH. + +To begin a new type from a template, execute "cdist-type-template __NAME" +and cd conf/type/__NAME. + + +DEFINING PARAMETERS +------------------- +Every type consists of optional and required parameters, which must +be created in a newline seperated file in parameters/required and +parameters/optional. If either or both missing, the type will have +no required, no optional or no parameters at all. + +Example: +-------------------------------------------------------------------------------- +echo servername >> conf/type/__nginx_vhost/parameter/required +echo logdirectory >> conf/type/__nginx_vhost/parameter/optional +-------------------------------------------------------------------------------- + + +WRITING THE MANIFEST +-------------------- +In the manifest of a type you can use other types, so your type extends +their functionality. A good example is the __package type, which in +a shortened version looks like this: + +-------------------------------------------------------------------------------- +os="$(cat "$__global/explorer/os")" +case "$os" in + archlinux) type="pacman" ;; + debian|ubuntu) type="apt" ;; + gentoo) type="emerge" ;; + *) + echo "Don't know how to manage packages on: $os" >&2 + exit 1 + ;; +esac + +__package_$type "$@" +-------------------------------------------------------------------------------- + +As you can see, the type can reference different environment variables, +which are documented in cdist-environment-variables(7). + +Always ensure the manifest is executable, otherwise cdist will not be able +to execute it. + + +THE TYPE EXPLORERS +------------------ +If a type needs to explore specific details, it can provide type specific +explorers, which will be executed on the target for every created object. + +The explorers are stored under the "explorer" directory below the type. +It could for instance contain code to check the md5sum of a file on the +client, like this (shortened version from real type __file): + +-------------------------------------------------------------------------------- +if [ -f "$__object/parameter/destination" ]; then + destination="$(cat "$__object/parameter/destination")" +else + destination="/$__object_id" +fi + +if [ -e "$destination" ]; then + md5sum < "$destination" +fi +-------------------------------------------------------------------------------- + + +WRITING THE GENCODE SCRIPT +-------------------------- +The gencode script can make use of the parameters, the global explorers +and the type specific explorers. The output (stdout) of this script is +saved by cdist and will be executed on the target. + +If the gencode script encounters an error, it should print diagnostic +messages to stderr and exit non-zero. If you need to debug the gencode +script, you can write to stderr: + +-------------------------------------------------------------------------------- +# Debug output to stderr +echo "My fancy debug line" >&2 + +# Output to be saved by cdist for execution on the target +echo "touch /etc/cdist-configured" +-------------------------------------------------------------------------------- + + +HINTS FOR TYPEWRITERS +---------------------- +It must be assumed that the target is pretty dumb and thus does not have high +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. + + +HOW TO INCLUDE A TYPE INTO UPSTREAM CDIST +----------------------------------------- +If you think your type may be useful for others, ensure it works with the +current master branch of cdist and submit the git url containing the type for +inclusion to the mailinglist **cdist at cdist -- at -- l.schottelius.org**. + +Ensure a corresponding manpage named cdist-type__NAME is included. + + +SEE ALSO +-------- +- cdist-manifest-run(1) +- cdist-stages(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). From a095b1a3c323b7a58db4bc999e2cffeb13785ded Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 8 Mar 2011 21:47:08 +0100 Subject: [PATCH 03/41] finish manpage for cdist-type__file Signed-off-by: Nico Schottelius --- Makefile | 1 + doc/man/cdist-type__file.text | 173 +++++++--------------------------- 2 files changed, 34 insertions(+), 140 deletions(-) diff --git a/Makefile b/Makefile index deefbafd..e003c0c6 100644 --- a/Makefile +++ b/Makefile @@ -23,6 +23,7 @@ MANSRC=$(MANDIR)/cdist.text \ $(MANDIR)/cdist-stages.text \ $(MANDIR)/cdist-type.text \ $(MANDIR)/cdist-type-template.text \ + $(MANDIR)/cdist-type__file.text \ ################################################################################ diff --git a/doc/man/cdist-type__file.text b/doc/man/cdist-type__file.text index 3c7a1317..04e0ffc3 100644 --- a/doc/man/cdist-type__file.text +++ b/doc/man/cdist-type__file.text @@ -1,163 +1,56 @@ -cdist-type(7) -============= +cdist-type__file(7) +=================== Nico Schottelius NAME ---- -cdist-type - Functionality bundled - - -SYNOPSIS --------- -Other languages name this module or class +cdist-type__file - Create files DESCRIPTION ----------- -Types are the main component of cdist and define functionality. If you -use cdist, you'll write a type for every functionality you would like -to use. +This cdist type allows you to create files on the target. -HOW TO USE A TYPE ------------------ -You can use types from the initial manifest or the type manifest like a -normal command: +REQUIRED PARAMETERS +------------------- +type:: + Specifies the type of file to be created. Either "directory" or "file" + + +OPTIONAL PARAMETERS +------------------- +destination:: + If supplied, use this as the destination on the target. Otherwise the + object_id is used. + +mode:: + Unix permissions, suitable for chmod. + +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. + + +EXAMPLES +-------- -------------------------------------------------------------------------------- -# Creates empty file /etc/cdist-configured +# Create /etc/cdist-configured as an empty file __file /etc/cdist-configured --type file -# Ensure tree is installed -__package tree --state installed +# Same but with a different object id +__file cdist-marker --type file --destination /etc/cdist-configured + +# Use __file from another type +__file /etc/issue --source "$__type/files/archlinux" --type file -------------------------------------------------------------------------------- -Internally cdist-type-emulator(1) will be called from cdist-manifest-run(1) to -save the given parameters into a cconfig database, so they can be accessed by -the manifest and gencode scripts of the type (see below). - - -HOW TO WRITE A NEW TYPE ------------------------ -A type consists of - -- parameter (optional) -- manifest (optional) -- explorer (optional) -- gencode (optional) - -Types are stored below conf/type/. Their name should always be prefixed with -two underscores (__) to prevent collisions with other binaries in $PATH. - -To begin a new type from a template, execute "cdist-type-template __NAME" -and cd conf/type/__NAME. - - -DEFINING PARAMETERS -------------------- -Every type consists of optional and required parameters, which must -be created in a newline seperated file in parameters/required and -parameters/optional. If either or both missing, the type will have -no required, no optional or no parameters at all. - -Example: --------------------------------------------------------------------------------- -echo servername >> conf/type/__nginx_vhost/parameter/required -echo logdirectory >> conf/type/__nginx_vhost/parameter/optional --------------------------------------------------------------------------------- - - -WRITING THE MANIFEST --------------------- -In the manifest of a type you can use other types, so your type extends -their functionality. A good example is the __package type, which in -a shortened version looks like this: - --------------------------------------------------------------------------------- -os="$(cat "$__global/explorer/os")" -case "$os" in - archlinux) type="pacman" ;; - debian|ubuntu) type="apt" ;; - gentoo) type="emerge" ;; - *) - echo "Don't know how to manage packages on: $os" >&2 - exit 1 - ;; -esac - -__package_$type "$@" --------------------------------------------------------------------------------- - -As you can see, the type can reference different environment variables, -which are documented in cdist-environment-variables(7). - -Always ensure the manifest is executable, otherwise cdist will not be able -to execute it. - - -THE TYPE EXPLORERS ------------------- -If a type needs to explore specific details, it can provide type specific -explorers, which will be executed on the target for every created object. - -The explorers are stored under the "explorer" directory below the type. -It could for instance contain code to check the md5sum of a file on the -client, like this (shortened version from real type __file): - --------------------------------------------------------------------------------- -if [ -f "$__object/parameter/destination" ]; then - destination="$(cat "$__object/parameter/destination")" -else - destination="/$__object_id" -fi - -if [ -e "$destination" ]; then - md5sum < "$destination" -fi --------------------------------------------------------------------------------- - - -WRITING THE GENCODE SCRIPT --------------------------- -The gencode script can make use of the parameters, the global explorers -and the type specific explorers. The output (stdout) of this script is -saved by cdist and will be executed on the target. - -If the gencode script encounters an error, it should print diagnostic -messages to stderr and exit non-zero. If you need to debug the gencode -script, you can write to stderr: - --------------------------------------------------------------------------------- -# Debug output to stderr -echo "My fancy debug line" >&2 - -# Output to be saved by cdist for execution on the target -echo "touch /etc/cdist-configured" --------------------------------------------------------------------------------- - - -HINTS FOR TYPEWRITERS ----------------------- -It must be assumed that the target is pretty dumb and thus does not have high -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. - - -HOW TO INCLUDE A TYPE INTO UPSTREAM CDIST ------------------------------------------ -If you think your type may be useful for others, ensure it works with the -current master branch of cdist and submit the git url containing the type for -inclusion to the mailinglist **cdist at cdist -- at -- l.schottelius.org**. - -Ensure a corresponding manpage named cdist-type__NAME is included. - SEE ALSO -------- -- cdist-manifest-run(1) -- cdist-stages(7) +- cdist-type(7) COPYING From 43a4dd49ca87581404a85ee7fdd83bb9c27d5280 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 8 Mar 2011 21:51:58 +0100 Subject: [PATCH 04/41] define how to use manpages Signed-off-by: Nico Schottelius --- REAL_README | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/REAL_README b/REAL_README index 10b1b812..ab070b38 100644 --- a/REAL_README +++ b/REAL_README @@ -79,6 +79,10 @@ To install cdist, execute the following commands: cd cdist export PATH=$PATH:$(pwd -P)/bin + # If you want the manpages + make man + export MANPATH=$MANPATH:$(pwd -P)/doc/man + Afterwards you can run ***cdist-quickstart*** to get an impression on how to use cdist. @@ -105,6 +109,11 @@ 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. From 4c5069e0cdfe14c2bc87ecd2baad4587863d6183 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 8 Mar 2011 22:04:32 +0100 Subject: [PATCH 05/41] begin manpage to include all types Signed-off-by: Nico Schottelius --- doc/man/cdist-type-supported.text.sh | 203 +++++++++++++++++++++++++++ 1 file changed, 203 insertions(+) create mode 100644 doc/man/cdist-type-supported.text.sh diff --git a/doc/man/cdist-type-supported.text.sh b/doc/man/cdist-type-supported.text.sh new file mode 100644 index 00000000..78c04a43 --- /dev/null +++ b/doc/man/cdist-type-supported.text.sh @@ -0,0 +1,203 @@ +#!/bin/sh +# +# 2010-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 . +# +# +# Generate manpage that lists available types +# + +__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" + +filename="${__cdist_myname%.sh}" +dest="$__cdist_abs_mydir/$filename" + +exit 0 + +cat << eof > "$dest" +cdist-type-listing(7) +===================== +Nico Schottelius + + +NAME +---- +cdist-type-listing - Available types in cdist + + +SYNOPSIS +-------- +Types that are included in cdist $(git describe). + + +DESCRIPTION +----------- +Types are the main component of cdist and define functionality. If you +use cdist, you'll write a type for every functionality you would like +to use. + + +HOW TO USE A TYPE +----------------- +You can use types from the initial manifest or the type manifest like a +normal command: + +-------------------------------------------------------------------------------- +# Creates empty file /etc/cdist-configured +__file /etc/cdist-configured --type file + +# Ensure tree is installed +__package tree --state installed +-------------------------------------------------------------------------------- + +Internally cdist-type-emulator(1) will be called from cdist-manifest-run(1) to +save the given parameters into a cconfig database, so they can be accessed by +the manifest and gencode scripts of the type (see below). + + +HOW TO WRITE A NEW TYPE +----------------------- +A type consists of + +- parameter (optional) +- manifest (optional) +- explorer (optional) +- gencode (optional) + +Types are stored below conf/type/. Their name should always be prefixed with +two underscores (__) to prevent collisions with other binaries in $PATH. + +To begin a new type from a template, execute "cdist-type-template __NAME" +and cd conf/type/__NAME. + + +DEFINING PARAMETERS +------------------- +Every type consists of optional and required parameters, which must +be created in a newline seperated file in parameters/required and +parameters/optional. If either or both missing, the type will have +no required, no optional or no parameters at all. + +Example: +-------------------------------------------------------------------------------- +echo servername >> conf/type/__nginx_vhost/parameter/required +echo logdirectory >> conf/type/__nginx_vhost/parameter/optional +-------------------------------------------------------------------------------- + + +WRITING THE MANIFEST +-------------------- +In the manifest of a type you can use other types, so your type extends +their functionality. A good example is the __package type, which in +a shortened version looks like this: + +-------------------------------------------------------------------------------- +os="$(cat "$__global/explorer/os")" +case "$os" in + archlinux) type="pacman" ;; + debian|ubuntu) type="apt" ;; + gentoo) type="emerge" ;; + *) + echo "Don't know how to manage packages on: $os" >&2 + exit 1 + ;; +esac + +__package_$type "$@" +-------------------------------------------------------------------------------- + +As you can see, the type can reference different environment variables, +which are documented in cdist-environment-variables(7). + +Always ensure the manifest is executable, otherwise cdist will not be able +to execute it. + + +THE TYPE EXPLORERS +------------------ +If a type needs to explore specific details, it can provide type specific +explorers, which will be executed on the target for every created object. + +The explorers are stored under the "explorer" directory below the type. +It could for instance contain code to check the md5sum of a file on the +client, like this (shortened version from real type __file): + +-------------------------------------------------------------------------------- +if [ -f "$__object/parameter/destination" ]; then + destination="$(cat "$__object/parameter/destination")" +else + destination="/$__object_id" +fi + +if [ -e "$destination" ]; then + md5sum < "$destination" +fi +-------------------------------------------------------------------------------- + + +WRITING THE GENCODE SCRIPT +-------------------------- +The gencode script can make use of the parameters, the global explorers +and the type specific explorers. The output (stdout) of this script is +saved by cdist and will be executed on the target. + +If the gencode script encounters an error, it should print diagnostic +messages to stderr and exit non-zero. If you need to debug the gencode +script, you can write to stderr: + +-------------------------------------------------------------------------------- +# Debug output to stderr +echo "My fancy debug line" >&2 + +# Output to be saved by cdist for execution on the target +echo "touch /etc/cdist-configured" +-------------------------------------------------------------------------------- + + +HINTS FOR TYPEWRITERS +---------------------- +It must be assumed that the target is pretty dumb and thus does not have high +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. + + +HOW TO INCLUDE A TYPE INTO UPSTREAM CDIST +----------------------------------------- +If you think your type may be useful for others, ensure it works with the +current master branch of cdist and submit the git url containing the type for +inclusion to the mailinglist **cdist at cdist -- at -- l.schottelius.org**. + +Ensure a corresponding manpage named cdist-type__NAME is included. + + +SEE ALSO +-------- +- cdist-manifest-run(1) +- cdist-stages(7) + + +COPYING +------- +Copyright \(C) 2011-$(date +%Y) Nico Schottelius. Free use of this software is +granted under the terms of the GNU General Public License version 3 (GPLv3). + +eof From 0e52bfcc4032477b8d152e0fa7683c26b6355992 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 8 Mar 2011 22:04:49 +0100 Subject: [PATCH 06/41] and name it type-listing Signed-off-by: Nico Schottelius --- .../{cdist-type-supported.text.sh => cdist-type-listing.text.sh} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename doc/man/{cdist-type-supported.text.sh => cdist-type-listing.text.sh} (100%) diff --git a/doc/man/cdist-type-supported.text.sh b/doc/man/cdist-type-listing.text.sh similarity index 100% rename from doc/man/cdist-type-supported.text.sh rename to doc/man/cdist-type-listing.text.sh From 7a4ab2efd8ea6e42a46177c85220ae0ca6f8804a Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 9 Mar 2011 08:53:19 +0100 Subject: [PATCH 07/41] integrate the first type manpage into cdist Signed-off-by: Nico Schottelius --- Makefile | 13 ++- doc/changelog | 2 +- doc/man/.gitignore | 1 + doc/man/cdist-type-listing.text.sh | 160 ++++------------------------- 4 files changed, 34 insertions(+), 142 deletions(-) mode change 100644 => 100755 doc/man/cdist-type-listing.text.sh diff --git a/Makefile b/Makefile index e003c0c6..5d099260 100644 --- a/Makefile +++ b/Makefile @@ -16,6 +16,8 @@ MANSRC=$(MANDIR)/cdist-config-layout.text \ $(MANDIR)/cdist-stages.text \ $(MANDIR)/cdist-terms.text \ +MANGENERATED=$(MANDIR)/cdist-type-listing.text + MANSRC=$(MANDIR)/cdist.text \ $(MANDIR)/cdist-bin-transfer.text \ $(MANDIR)/cdist-deploy-to.text \ @@ -23,7 +25,7 @@ MANSRC=$(MANDIR)/cdist.text \ $(MANDIR)/cdist-stages.text \ $(MANDIR)/cdist-type.text \ $(MANDIR)/cdist-type-template.text \ - $(MANDIR)/cdist-type__file.text \ + $(MANDIR)/cdist-type__file.text \ ################################################################################ @@ -43,11 +45,16 @@ all: man: doc/man/.marker -doc/man/.marker: $(MANSRC) - for mansrc in $(MANSRC); do $(A2X) $$mansrc; done +doc/man/.marker: $(MANSRC) $(MANGENERATED) + for mansrc in $^; do $(A2X) $$mansrc; done for manpage in $(MANDIR)/*.[1-9]; do cat=$${manpage##*.}; mandir=$(MANDIR)/man$$cat; mkdir -p $$mandir; mv $$manpage $$mandir; done touch $@ +# Only depends on cdist-type__*.text in reality +$(MANDIR)/cdist-type-listing.text: $(MANSRC) $(MANDIR)/cdist-type-listing.text.sh + $(MANDIR)/cdist-type-listing.text.sh + + clean: rm -rf doc/man/*.html doc/man/*.[1-9] doc/man/man[1-9] diff --git a/doc/changelog b/doc/changelog index b0087c36..528b7e86 100644 --- a/doc/changelog +++ b/doc/changelog @@ -1,5 +1,5 @@ 1.0.2: upcoming - * Add manpages: cdist-type + * Add manpages: cdist-type, cdist-type__file * Make doc/man/ usable as MANPATH entry 1.0.1: 2011-03-08 diff --git a/doc/man/.gitignore b/doc/man/.gitignore index 22d0a62d..299485e8 100644 --- a/doc/man/.gitignore +++ b/doc/man/.gitignore @@ -1,3 +1,4 @@ cdist.7 *.html cdist-design.7 +cdist-type-listing.text diff --git a/doc/man/cdist-type-listing.text.sh b/doc/man/cdist-type-listing.text.sh old mode 100644 new mode 100755 index 78c04a43..d1da1477 --- a/doc/man/cdist-type-listing.text.sh +++ b/doc/man/cdist-type-listing.text.sh @@ -30,9 +30,11 @@ __cdist_abs_myname="$__cdist_abs_mydir/$__cdist_myname" filename="${__cdist_myname%.sh}" dest="$__cdist_abs_mydir/$filename" -exit 0 +cd "$__cdist_abs_mydir" -cat << eof > "$dest" +exec > "$dest" + +cat << eof cdist-type-listing(7) ===================== Nico Schottelius @@ -50,150 +52,32 @@ Types that are included in cdist $(git describe). DESCRIPTION ----------- -Types are the main component of cdist and define functionality. If you -use cdist, you'll write a type for every functionality you would like -to use. +The following types are available: +eof +for type in cdist-type__*.text; do + name_1="${type#cdist-type}" + name_2="${name_1%.text}" -HOW TO USE A TYPE ------------------ -You can use types from the initial manifest or the type manifest like a -normal command: + name="$name_2" + echo "- $name" +done --------------------------------------------------------------------------------- -# Creates empty file /etc/cdist-configured -__file /etc/cdist-configured --type file - -# Ensure tree is installed -__package tree --state installed --------------------------------------------------------------------------------- - -Internally cdist-type-emulator(1) will be called from cdist-manifest-run(1) to -save the given parameters into a cconfig database, so they can be accessed by -the manifest and gencode scripts of the type (see below). - - -HOW TO WRITE A NEW TYPE ------------------------ -A type consists of - -- parameter (optional) -- manifest (optional) -- explorer (optional) -- gencode (optional) - -Types are stored below conf/type/. Their name should always be prefixed with -two underscores (__) to prevent collisions with other binaries in $PATH. - -To begin a new type from a template, execute "cdist-type-template __NAME" -and cd conf/type/__NAME. - - -DEFINING PARAMETERS -------------------- -Every type consists of optional and required parameters, which must -be created in a newline seperated file in parameters/required and -parameters/optional. If either or both missing, the type will have -no required, no optional or no parameters at all. - -Example: --------------------------------------------------------------------------------- -echo servername >> conf/type/__nginx_vhost/parameter/required -echo logdirectory >> conf/type/__nginx_vhost/parameter/optional --------------------------------------------------------------------------------- - - -WRITING THE MANIFEST --------------------- -In the manifest of a type you can use other types, so your type extends -their functionality. A good example is the __package type, which in -a shortened version looks like this: - --------------------------------------------------------------------------------- -os="$(cat "$__global/explorer/os")" -case "$os" in - archlinux) type="pacman" ;; - debian|ubuntu) type="apt" ;; - gentoo) type="emerge" ;; - *) - echo "Don't know how to manage packages on: $os" >&2 - exit 1 - ;; -esac - -__package_$type "$@" --------------------------------------------------------------------------------- - -As you can see, the type can reference different environment variables, -which are documented in cdist-environment-variables(7). - -Always ensure the manifest is executable, otherwise cdist will not be able -to execute it. - - -THE TYPE EXPLORERS ------------------- -If a type needs to explore specific details, it can provide type specific -explorers, which will be executed on the target for every created object. - -The explorers are stored under the "explorer" directory below the type. -It could for instance contain code to check the md5sum of a file on the -client, like this (shortened version from real type __file): - --------------------------------------------------------------------------------- -if [ -f "$__object/parameter/destination" ]; then - destination="$(cat "$__object/parameter/destination")" -else - destination="/$__object_id" -fi - -if [ -e "$destination" ]; then - md5sum < "$destination" -fi --------------------------------------------------------------------------------- - - -WRITING THE GENCODE SCRIPT --------------------------- -The gencode script can make use of the parameters, the global explorers -and the type specific explorers. The output (stdout) of this script is -saved by cdist and will be executed on the target. - -If the gencode script encounters an error, it should print diagnostic -messages to stderr and exit non-zero. If you need to debug the gencode -script, you can write to stderr: - --------------------------------------------------------------------------------- -# Debug output to stderr -echo "My fancy debug line" >&2 - -# Output to be saved by cdist for execution on the target -echo "touch /etc/cdist-configured" --------------------------------------------------------------------------------- - - -HINTS FOR TYPEWRITERS ----------------------- -It must be assumed that the target is pretty dumb and thus does not have high -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. - - -HOW TO INCLUDE A TYPE INTO UPSTREAM CDIST ------------------------------------------ -If you think your type may be useful for others, ensure it works with the -current master branch of cdist and submit the git url containing the type for -inclusion to the mailinglist **cdist at cdist -- at -- l.schottelius.org**. - -Ensure a corresponding manpage named cdist-type__NAME is included. +cat << eof SEE ALSO -------- -- cdist-manifest-run(1) -- cdist-stages(7) +- cdist-type(7) +eof +for type in cdist-type__*.text; do + name_2="${type%.text}" + name="$name_2" + echo "- ${name}(7)" +done + +cat < Date: Wed, 9 Mar 2011 08:54:52 +0100 Subject: [PATCH 08/41] lesstodo and add pointer to type manpages Signed-off-by: Nico Schottelius --- doc/dev/todo/niconext | 2 +- doc/man/cdist-type.text | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/dev/todo/niconext b/doc/dev/todo/niconext index 636cd561..3f7c91d5 100644 --- a/doc/dev/todo/niconext +++ b/doc/dev/todo/niconext @@ -1,4 +1,4 @@ Documentation cleanup - document environment variables - - Reference all types somewhere (on the webpage?) - how to debug explorer + => 1.0.2 diff --git a/doc/man/cdist-type.text b/doc/man/cdist-type.text index 3c7a1317..b5097a5c 100644 --- a/doc/man/cdist-type.text +++ b/doc/man/cdist-type.text @@ -37,6 +37,8 @@ Internally cdist-type-emulator(1) will be called from cdist-manifest-run(1) to save the given parameters into a cconfig database, so they can be accessed by the manifest and gencode scripts of the type (see below). +A list of supported types can be found in the cdist-type-listing(7) manpage. + HOW TO WRITE A NEW TYPE ----------------------- From 75d8abc339f56b3427207e35088627249975d232 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 9 Mar 2011 08:56:31 +0100 Subject: [PATCH 09/41] remove generated manpages Signed-off-by: Nico Schottelius --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 5d099260..6a880c48 100644 --- a/Makefile +++ b/Makefile @@ -56,7 +56,7 @@ $(MANDIR)/cdist-type-listing.text: $(MANSRC) $(MANDIR)/cdist-type-listing.text.s clean: - rm -rf doc/man/*.html doc/man/*.[1-9] doc/man/man[1-9] + rm -rf doc/man/*.html doc/man/*.[1-9] doc/man/man[1-9] $(MANGENERATED) ################################################################################ # Developer targets From 1048c42c6dde27abe41ea0b790aaf745981e74c5 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 9 Mar 2011 09:15:34 +0100 Subject: [PATCH 10/41] merge cdist-config-layout into cdist-reference Signed-off-by: Nico Schottelius --- doc/dev/todo/niconext | 1 + doc/man/cdist.text | 11 +- doc/man/to_check/cdist-config-layout.text | 108 ---------- .../to_check/cdist-environment-variables.text | 197 +++++++++++++++++- 4 files changed, 193 insertions(+), 124 deletions(-) delete mode 100644 doc/man/to_check/cdist-config-layout.text diff --git a/doc/dev/todo/niconext b/doc/dev/todo/niconext index 3f7c91d5..f7acbe88 100644 --- a/doc/dev/todo/niconext +++ b/doc/dev/todo/niconext @@ -1,4 +1,5 @@ Documentation cleanup - document environment variables + - and merge with config-layout! - how to debug explorer => 1.0.2 diff --git a/doc/man/cdist.text b/doc/man/cdist.text index b6fd808b..570b6b95 100644 --- a/doc/man/cdist.text +++ b/doc/man/cdist.text @@ -29,12 +29,11 @@ pull mechanism (client requests configuration). SEE ALSO -------- -Website: http://www.nico.schottelius.org/cdist/[], -cdist-deploy-to(1), -cdist-manifest(7), -cdist-quickstart(1), -cdist-type(7), -cdist-type-inclusion(7) +- Website: http://www.nico.schottelius.org/cdist/[] +- cdist-deploy-to(1) +- cdist-manifest(7) +- cdist-quickstart(1) +- cdist-type(7) COPYING diff --git a/doc/man/to_check/cdist-config-layout.text b/doc/man/to_check/cdist-config-layout.text deleted file mode 100644 index d6be10df..00000000 --- a/doc/man/to_check/cdist-config-layout.text +++ /dev/null @@ -1,108 +0,0 @@ -cdist-config-layout(7) -====================== -Nico Schottelius - - -NAME ----- -cdist-config-layout - Usage of paths in cdist - - -DESCRIPTION ------------ -If not specified otherwise, all paths are relative to the configuration -directory, which is normally /etc/cdist (but can be changed using environment -variables, see cdist-environment(7)). - -- conf_dir/: - Contains the (static) configuration like manifests, types and - explorers. - -- conf_dir/manifest/init: - This is the central entry point used by cdist-manifest-init(1). - It is an executable (+x bit set) shell script that can use - values from the explorers to decide which configuration to create - for the specified target host. - - It should be primary used to define mapping from configurations to hosts. - -- conf_dir/manifest/*: - All other files in this directory are not directly used by Cdist, but you - can seperate configuration mappings, if you have a lot of code in the - manifest/init file. This may also be very helpful to have different admins - maintain different groups of hosts. - -- conf_dir/explorer/ - Contains explorers to be run on the target hosts, see cdist-explorers(7). - -- conf_dir/type/ - Contains all available types, which are used to provide - some kind of functionality. See cdist-stages(7). - -- conf_dir/type//manifest: - Used to generate additional objects from a type. - See cdist-stages(7), cdist-types(7). - -- conf_dir/type//gencode: - Used to generate code to be executed on the client. - See cdist-types(7). - -- conf_dir/type//parameters/required: - Parameters required by type, \n seperated list. - See cdist-types(7). - -- conf_dir/type//parameters/optional: - Parameters optionally accepted by type, \n seperated list. - See cdist-types(7). - -- conf_dir/type//explorer: - Location of the type specific explorers. - See cdist-explorers(7). - -- out_dir/ - This directory contains output of cdist and is mirrored into the - cache after a successful run. This directory may be placed below - the tmpdir or at any other location and is also available on the - target. - -- out_dir/explorer: - Output of general explorers. - -- out_dir/object: - Objects created for the host. - -- out_dir/object//explorers: - Output of type specific explorers, per object. - -- tmp_dir: Temporary storage - A tempdir and a tempfile is provided by cdist-config(1), which - will be removed when the scripts ends automatically. - - -FUTURE ------- -The following functionality may be implemented in one of the next releases: - -- cache_dir/ - The cache contains the out_dir from previous runs, which - may also be used in types to gather information about other hosts - (like ssh-keys). - -- cache_dir/host/: - Contains the last out_dir of the specific host. - - -AUTHOR ------- -Nico Schottelius - - -RESOURCES ---------- -Main web site: http://www.nico.schottelius.org/cdist/[] - - -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-environment-variables.text b/doc/man/to_check/cdist-environment-variables.text index c91a2ae0..f39366f0 100644 --- a/doc/man/to_check/cdist-environment-variables.text +++ b/doc/man/to_check/cdist-environment-variables.text @@ -1,14 +1,191 @@ -Update on env: +cdist-reference(7) +================== +Nico Schottelius - general explorer: __explorer - initial manifest: __manifest, __global - type manifests __object, __object_id, __global - type explorers: __object, __object_id, __type_explorers, __global - type codegen: __object, __object_id, __global - type code: - +NAME +---- +cdist-reference - Variables, paths and types offered by cdist -- __object: Path to the object that we are working on -- __object_id: type unique object id -- __global: contains global information (see cdist-env +DESCRIPTION +----------- +Various scripts which are not in the core need information on how +to find information. This manpage summarises the available environment +variables and clearifies with part may access with variables. +PATHS +----- + + +-------------------------------------------------------------------------------- +cdist-config-layout(7) +====================== +Nico Schottelius + + +NAME +---- +cdist-config-layout - Usage of paths in cdist + + +DESCRIPTION +----------- +If not specified otherwise, all paths are relative to the configuration +directory, which is normally /etc/cdist (but can be changed using environment +variables, see cdist-environment(7)). + +- conf_dir/: + Contains the (static) configuration like manifests, types and + explorers. + +- conf_dir/manifest/init: + This is the central entry point used by cdist-manifest-init(1). + It is an executable (+x bit set) shell script that can use + values from the explorers to decide which configuration to create + for the specified target host. + + It should be primary used to define mapping from configurations to hosts. + +- conf_dir/manifest/*: + All other files in this directory are not directly used by Cdist, but you + can seperate configuration mappings, if you have a lot of code in the + manifest/init file. This may also be very helpful to have different admins + maintain different groups of hosts. + +- conf_dir/explorer/ + Contains explorers to be run on the target hosts, see cdist-explorers(7). + +- conf_dir/type/ + Contains all available types, which are used to provide + some kind of functionality. See cdist-stages(7). + +- conf_dir/type//manifest: + Used to generate additional objects from a type. + See cdist-stages(7), cdist-types(7). + +- conf_dir/type//gencode: + Used to generate code to be executed on the client. + See cdist-types(7). + +- conf_dir/type//parameters/required: + Parameters required by type, \n seperated list. + See cdist-types(7). + +- conf_dir/type//parameters/optional: + Parameters optionally accepted by type, \n seperated list. + See cdist-types(7). + +- conf_dir/type//explorer: + Location of the type specific explorers. + See cdist-explorers(7). + +- out_dir/ + This directory contains output of cdist and is mirrored into the + cache after a successful run. This directory may be placed below + the tmpdir or at any other location and is also available on the + target. + +- out_dir/explorer: + Output of general explorers. + +- out_dir/object: + Objects created for the host. + +- out_dir/object//explorers: + Output of type specific explorers, per object. + +- tmp_dir: Temporary storage + A tempdir and a tempfile is provided by cdist-config(1), which + will be removed when the scripts ends automatically. + + +FUTURE +------ +The following functionality may be implemented in one of the next releases: + +- cache_dir/ + The cache contains the out_dir from previous runs, which + may also be used in types to gather information about other hosts + (like ssh-keys). + +- cache_dir/host/: + Contains the last out_dir of the specific host. + + +AUTHOR +------ +Nico Schottelius + + +RESOURCES +--------- +Main web site: http://www.nico.schottelius.org/cdist/[] + + +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). +-------------------------------------------------------------------------------- + + + +VARIABLES +--------- +__explorer:: + Directory that contains all explorers +__manifest:: + Directory that contains the initial manifest +__global:: + Directory that contains generic output like explorer +__object:: + Directory that contains the current object +__object_id:: + The type unique object id +__type_explorers:: + Directory that contains the type explorers + + +EXPLORER +-------- +- __explorer + + +INITIAL MANIFEST +---------------- +- __manifest +- __global + + +TYPE MANIFEST +------------- +- __object +- __object_id +- __global + + +TYPE EXPLORER +------------- +- __object +- __object_id +- __type_explorers +- __global + + +TYPE CODEGEN +------------ +- __object +- __object_id +- __global + + + +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). From ef761b73df0cbafd6fdc039b427aae9815181283 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 9 Mar 2011 09:34:53 +0100 Subject: [PATCH 11/41] finish first version of cdist-reference Signed-off-by: Nico Schottelius --- Makefile | 1 + doc/man/cdist-reference.text | 131 ++++++++++++ .../to_check/cdist-environment-variables.text | 191 ------------------ 3 files changed, 132 insertions(+), 191 deletions(-) create mode 100644 doc/man/cdist-reference.text delete mode 100644 doc/man/to_check/cdist-environment-variables.text diff --git a/Makefile b/Makefile index 6a880c48..689b4a5a 100644 --- a/Makefile +++ b/Makefile @@ -22,6 +22,7 @@ MANSRC=$(MANDIR)/cdist.text \ $(MANDIR)/cdist-bin-transfer.text \ $(MANDIR)/cdist-deploy-to.text \ $(MANDIR)/cdist-manifest.text \ + $(MANDIR)/cdist-reference.text \ $(MANDIR)/cdist-stages.text \ $(MANDIR)/cdist-type.text \ $(MANDIR)/cdist-type-template.text \ diff --git a/doc/man/cdist-reference.text b/doc/man/cdist-reference.text new file mode 100644 index 00000000..72ee4f48 --- /dev/null +++ b/doc/man/cdist-reference.text @@ -0,0 +1,131 @@ +cdist-reference(7) +================== +Nico Schottelius + +NAME +---- +cdist-reference - Variable, path and type reference + + +DESCRIPTION +----------- +Various scripts which are not in the core need information on how +to find information. This manpage summarises the available environment +variables and paths and clearifies with part may access with variables. + + +PATHS +----- +If not specified otherwise, all paths are relative to the checkout directory. + +conf/:: + Contains the (static) configuration like manifests, types and explorers. + +conf/manifest/init:: + This is the central entry point used by cdist-manifest-init(1). + It is an executable (+x bit set) shell script that can use + values from the explorers to decide which configuration to create + for the specified target host. + + It should be primary used to define mapping from configurations to hosts. + +conf/manifest/*:: + All other files in this directory are not directly used by Cdist, but you + can seperate configuration mappings, if you have a lot of code in the + manifest/init file. This may also be very helpful to have different admins + maintain different groups of hosts. + +conf/explorer/: + Contains explorers to be run on the target hosts, see cdist-explorer(7). + +conf/type/: + Contains all available types, which are used to provide + some kind of functionality. See cdist-type(7). + +conf/type//:: + Home of the type . + + This directory is referenced by the variable __type (see below). + +conf/type//manifest:: + Used to generate additional objects from a type. + +conf/type//gencode:: + Used to generate code to be executed on the client. + +conf/type//parameters/required:: + Parameters required by type, \n seperated list. + +conf/type//parameters/optional:: + Parameters optionally accepted by type, \n seperated list. + +conf/type//explorer:: + Location of the type specific explorers. + + This directory is referenced by the variable __type_explorer (see below). + + See cdist-explorer(7). + +out/: + This directory contains output of cdist and is usually located + in a temporary directory and thus will be removed after the run. + + This directory is referenced by the variable __global (see below). + +out/explorer:: + Output of general explorers. + +out/object:: + Objects created for the host. + +out/object/:: + Contains all object specific information. + + This directory is referenced by the variable __object (see below). + +out/object//explorers:: + Output of type specific explorers, per object. + +tmp_dir: Temporary storage: + A tempdir and a tempfile is used by cdist internally, + which will be removed when the scripts end automatically. + See cdist-config(1). + + +VARIABLES +--------- +__explorer:: + Directory that contains all explorers + Available for: explorer +__manifest:: + Directory that contains the initial manifest + Available for: initial manifest +__global:: + Directory that contains generic output like explorer + Available for: initial manifest, type manifest, type explorer, type codegen +__object:: + Directory that contains the current object + Available for: type manifest, type explorer, type codegen +__object_id:: + The type unique object id + Available for: type manifest, type explorer, type codegen +__target_host:: + The host we are deploying to. + Available for: initial manifest, type manifest, type codegen +__type:: + Path to the current type + Available for: type manifest +__type_explorers:: + Directory that contains the type explorers + Available for: type explorer + + +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/to_check/cdist-environment-variables.text b/doc/man/to_check/cdist-environment-variables.text deleted file mode 100644 index f39366f0..00000000 --- a/doc/man/to_check/cdist-environment-variables.text +++ /dev/null @@ -1,191 +0,0 @@ -cdist-reference(7) -================== -Nico Schottelius - -NAME ----- -cdist-reference - Variables, paths and types offered by cdist - - -DESCRIPTION ------------ -Various scripts which are not in the core need information on how -to find information. This manpage summarises the available environment -variables and clearifies with part may access with variables. - -PATHS ------ - - --------------------------------------------------------------------------------- -cdist-config-layout(7) -====================== -Nico Schottelius - - -NAME ----- -cdist-config-layout - Usage of paths in cdist - - -DESCRIPTION ------------ -If not specified otherwise, all paths are relative to the configuration -directory, which is normally /etc/cdist (but can be changed using environment -variables, see cdist-environment(7)). - -- conf_dir/: - Contains the (static) configuration like manifests, types and - explorers. - -- conf_dir/manifest/init: - This is the central entry point used by cdist-manifest-init(1). - It is an executable (+x bit set) shell script that can use - values from the explorers to decide which configuration to create - for the specified target host. - - It should be primary used to define mapping from configurations to hosts. - -- conf_dir/manifest/*: - All other files in this directory are not directly used by Cdist, but you - can seperate configuration mappings, if you have a lot of code in the - manifest/init file. This may also be very helpful to have different admins - maintain different groups of hosts. - -- conf_dir/explorer/ - Contains explorers to be run on the target hosts, see cdist-explorers(7). - -- conf_dir/type/ - Contains all available types, which are used to provide - some kind of functionality. See cdist-stages(7). - -- conf_dir/type//manifest: - Used to generate additional objects from a type. - See cdist-stages(7), cdist-types(7). - -- conf_dir/type//gencode: - Used to generate code to be executed on the client. - See cdist-types(7). - -- conf_dir/type//parameters/required: - Parameters required by type, \n seperated list. - See cdist-types(7). - -- conf_dir/type//parameters/optional: - Parameters optionally accepted by type, \n seperated list. - See cdist-types(7). - -- conf_dir/type//explorer: - Location of the type specific explorers. - See cdist-explorers(7). - -- out_dir/ - This directory contains output of cdist and is mirrored into the - cache after a successful run. This directory may be placed below - the tmpdir or at any other location and is also available on the - target. - -- out_dir/explorer: - Output of general explorers. - -- out_dir/object: - Objects created for the host. - -- out_dir/object//explorers: - Output of type specific explorers, per object. - -- tmp_dir: Temporary storage - A tempdir and a tempfile is provided by cdist-config(1), which - will be removed when the scripts ends automatically. - - -FUTURE ------- -The following functionality may be implemented in one of the next releases: - -- cache_dir/ - The cache contains the out_dir from previous runs, which - may also be used in types to gather information about other hosts - (like ssh-keys). - -- cache_dir/host/: - Contains the last out_dir of the specific host. - - -AUTHOR ------- -Nico Schottelius - - -RESOURCES ---------- -Main web site: http://www.nico.schottelius.org/cdist/[] - - -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). --------------------------------------------------------------------------------- - - - -VARIABLES ---------- -__explorer:: - Directory that contains all explorers -__manifest:: - Directory that contains the initial manifest -__global:: - Directory that contains generic output like explorer -__object:: - Directory that contains the current object -__object_id:: - The type unique object id -__type_explorers:: - Directory that contains the type explorers - - -EXPLORER --------- -- __explorer - - -INITIAL MANIFEST ----------------- -- __manifest -- __global - - -TYPE MANIFEST -------------- -- __object -- __object_id -- __global - - -TYPE EXPLORER -------------- -- __object -- __object_id -- __type_explorers -- __global - - -TYPE CODEGEN ------------- -- __object -- __object_id -- __global - - - -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). From 2277880e4b75868300f7c958e50a289ae917c831 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 9 Mar 2011 09:52:43 +0100 Subject: [PATCH 12/41] in theory finish type-listing to reference migration Signed-off-by: Nico Schottelius --- Makefile | 6 +- ...reference.text => cdist-reference.text.sh} | 74 ++++++++++++++-- doc/man/cdist-type-listing.text.sh | 87 ------------------- 3 files changed, 70 insertions(+), 97 deletions(-) rename doc/man/{cdist-reference.text => cdist-reference.text.sh} (67%) mode change 100644 => 100755 delete mode 100755 doc/man/cdist-type-listing.text.sh diff --git a/Makefile b/Makefile index 689b4a5a..9e3460f7 100644 --- a/Makefile +++ b/Makefile @@ -16,7 +16,7 @@ MANSRC=$(MANDIR)/cdist-config-layout.text \ $(MANDIR)/cdist-stages.text \ $(MANDIR)/cdist-terms.text \ -MANGENERATED=$(MANDIR)/cdist-type-listing.text +MANGENERATED=$(MANDIR)/cdist-reference.text MANSRC=$(MANDIR)/cdist.text \ $(MANDIR)/cdist-bin-transfer.text \ @@ -52,8 +52,8 @@ doc/man/.marker: $(MANSRC) $(MANGENERATED) touch $@ # Only depends on cdist-type__*.text in reality -$(MANDIR)/cdist-type-listing.text: $(MANSRC) $(MANDIR)/cdist-type-listing.text.sh - $(MANDIR)/cdist-type-listing.text.sh +$(MANDIR)/cdist-reference.text: $(MANSRC) $(MANDIR)/cdist-reference.text.sh + $(MANDIR)/cdist-reference.text.sh clean: diff --git a/doc/man/cdist-reference.text b/doc/man/cdist-reference.text.sh old mode 100644 new mode 100755 similarity index 67% rename from doc/man/cdist-reference.text rename to doc/man/cdist-reference.text.sh index 72ee4f48..c8a49abd --- a/doc/man/cdist-reference.text +++ b/doc/man/cdist-reference.text.sh @@ -1,17 +1,53 @@ +#!/bin/sh +# +# 2010-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 . +# +# +# Generate manpage that lists available types +# + +__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" + +filename="${__cdist_myname%.sh}" +dest="$__cdist_abs_mydir/$filename" + +cd "$__cdist_abs_mydir" + +# exec > "$dest" +cat << eof cdist-reference(7) ================== Nico Schottelius NAME ---- -cdist-reference - Variable, path and type reference +cdist-reference - Variable, path and type reference for cdist $(git describe) DESCRIPTION ----------- Various scripts which are not in the core need information on how to find information. This manpage summarises the available environment -variables and paths and clearifies with part may access with variables. +variables, types and paths and clearifies with part may access which variables. PATHS @@ -30,15 +66,15 @@ conf/manifest/init:: It should be primary used to define mapping from configurations to hosts. conf/manifest/*:: - All other files in this directory are not directly used by Cdist, but you + All other files in this directory are not directly used by cdist, but you can seperate configuration mappings, if you have a lot of code in the manifest/init file. This may also be very helpful to have different admins maintain different groups of hosts. -conf/explorer/: +conf/explorer/:: Contains explorers to be run on the target hosts, see cdist-explorer(7). -conf/type/: +conf/type/:: Contains all available types, which are used to provide some kind of functionality. See cdist-type(7). @@ -66,7 +102,7 @@ conf/type//explorer:: See cdist-explorer(7). -out/: +out/:: This directory contains output of cdist and is usually located in a temporary directory and thus will be removed after the run. @@ -86,11 +122,26 @@ out/object/:: out/object//explorers:: Output of type specific explorers, per object. -tmp_dir: Temporary storage: +tmp_dir:: A tempdir and a tempfile is used by cdist internally, which will be removed when the scripts end automatically. See cdist-config(1). +TYPES +----- +The following types are available: + +eof +for type in cdist-type__*.text; do + name_1="${type#cdist-type}" + name_2="${name_1%.text}" + + name="$name_2" + echo "- $name" +done + +cat << eof + VARIABLES --------- @@ -123,9 +174,18 @@ __type_explorers:: SEE ALSO -------- - cdist(7) +eof +for type in cdist-type__*.text; do + name_2="${type%.text}" + name="$name_2" + echo "- ${name}(7)" +done + +cat <. -# -# -# Generate manpage that lists available types -# - -__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" - -filename="${__cdist_myname%.sh}" -dest="$__cdist_abs_mydir/$filename" - -cd "$__cdist_abs_mydir" - -exec > "$dest" - -cat << eof -cdist-type-listing(7) -===================== -Nico Schottelius - - -NAME ----- -cdist-type-listing - Available types in cdist - - -SYNOPSIS --------- -Types that are included in cdist $(git describe). - - -DESCRIPTION ------------ -The following types are available: - -eof -for type in cdist-type__*.text; do - name_1="${type#cdist-type}" - name_2="${name_1%.text}" - - name="$name_2" - echo "- $name" -done - -cat << eof - - -SEE ALSO --------- -- cdist-type(7) -eof -for type in cdist-type__*.text; do - name_2="${type%.text}" - - name="$name_2" - echo "- ${name}(7)" -done - -cat < Date: Wed, 9 Mar 2011 10:01:14 +0100 Subject: [PATCH 13/41] update pointers to cdist-reference Signed-off-by: Nico Schottelius --- Makefile | 1 - doc/changelog | 2 +- doc/man/.gitignore | 2 +- doc/man/cdist-deploy-to.text | 8 ++++---- doc/man/cdist-reference.text.sh | 16 ++++++++-------- doc/man/cdist-stages.text | 13 +++++++------ 6 files changed, 21 insertions(+), 21 deletions(-) diff --git a/Makefile b/Makefile index 9e3460f7..96924c4c 100644 --- a/Makefile +++ b/Makefile @@ -22,7 +22,6 @@ MANSRC=$(MANDIR)/cdist.text \ $(MANDIR)/cdist-bin-transfer.text \ $(MANDIR)/cdist-deploy-to.text \ $(MANDIR)/cdist-manifest.text \ - $(MANDIR)/cdist-reference.text \ $(MANDIR)/cdist-stages.text \ $(MANDIR)/cdist-type.text \ $(MANDIR)/cdist-type-template.text \ diff --git a/doc/changelog b/doc/changelog index 528b7e86..b39c512d 100644 --- a/doc/changelog +++ b/doc/changelog @@ -1,5 +1,5 @@ 1.0.2: upcoming - * Add manpages: cdist-type, cdist-type__file + * Add manpages: cdist-type, cdist-type__file, cdist-reference * Make doc/man/ usable as MANPATH entry 1.0.1: 2011-03-08 diff --git a/doc/man/.gitignore b/doc/man/.gitignore index 299485e8..8ed9d1e1 100644 --- a/doc/man/.gitignore +++ b/doc/man/.gitignore @@ -1,4 +1,4 @@ cdist.7 *.html cdist-design.7 -cdist-type-listing.text +cdist-reference.text diff --git a/doc/man/cdist-deploy-to.text b/doc/man/cdist-deploy-to.text index e09cba0a..acbb915a 100644 --- a/doc/man/cdist-deploy-to.text +++ b/doc/man/cdist-deploy-to.text @@ -30,10 +30,10 @@ variables are handled by cdist-config. SEE ALSO -------- -cdist(7), -cdist-config(1), -cdist-config-layout(7), -cdist-stages(7) +- cdist(7) +- cdist-config(1) +- cdist-reference(7) +- cdist-stages(7) COPYING diff --git a/doc/man/cdist-reference.text.sh b/doc/man/cdist-reference.text.sh index c8a49abd..2453c216 100755 --- a/doc/man/cdist-reference.text.sh +++ b/doc/man/cdist-reference.text.sh @@ -32,7 +32,7 @@ dest="$__cdist_abs_mydir/$filename" cd "$__cdist_abs_mydir" -# exec > "$dest" +exec > "$dest" cat << eof cdist-reference(7) ================== @@ -146,28 +146,28 @@ cat << eof VARIABLES --------- __explorer:: - Directory that contains all explorers + Directory that contains all explorers. Available for: explorer __manifest:: - Directory that contains the initial manifest + Directory that contains the initial manifest. Available for: initial manifest __global:: - Directory that contains generic output like explorer + Directory that contains generic output like explorer. Available for: initial manifest, type manifest, type explorer, type codegen __object:: - Directory that contains the current object + Directory that contains the current object. Available for: type manifest, type explorer, type codegen __object_id:: - The type unique object id + The type unique object id. Available for: type manifest, type explorer, type codegen __target_host:: The host we are deploying to. Available for: initial manifest, type manifest, type codegen __type:: - Path to the current type + Path to the current type. Available for: type manifest __type_explorers:: - Directory that contains the type explorers + Directory that contains the type explorers. Available for: type explorer diff --git a/doc/man/cdist-stages.text b/doc/man/cdist-stages.text index da6f4e02..4ab93cff 100644 --- a/doc/man/cdist-stages.text +++ b/doc/man/cdist-stages.text @@ -46,10 +46,9 @@ no conflicts may occur, i.e. no object of the same type with the same id may be created. Related manpages: + - cdist-manifest(7) - cdist-manifest-run(1) - cdist-manifest-run-init(1) - - cdist-manifest(7) - - cdist-config-layout(7) STAGE 3: EXECUTION OF TYPES @@ -67,9 +66,9 @@ may occur during the merge. A conflict would mean that two different objects try to create the same object, which indicates a broken configuration. Related manpages: - - cdist-type(7) - cdist-manifest-run(1) - cdist-manifest-run-all(1) + - cdist-type(7) STAGE 4: CODE GENERATION @@ -81,9 +80,9 @@ on stdout. If the gencode executable fails, it must print diagnostic messages on stderr and exit non-zero. Related manpages: - - cdist-types-gencode(7) - cdist-gencode(1) - cdist-gencode-all(1) + - cdist-type(7) STAGE 5: CODE EXECUTION @@ -92,8 +91,8 @@ The resulting code from the previous stage is transferred to the target host and executed there to apply the configuration changes, Related manpages: - - cdist-exec-transfer(1) - cdist-exec-run(1) + - cdist-exec-transfer(1) SUMMARY @@ -106,7 +105,9 @@ in correct order. SEE ALSO -------- -cdist(7), cdist-deploy-to(1), cdist-config-layout(7) +- cdist(7) +- cdist-deploy-to(1) +- cdist-reference(7) COPYING From a8c5f225b2b6427704fabffefb467e812312fb35 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 9 Mar 2011 10:03:06 +0100 Subject: [PATCH 14/41] --todo Signed-off-by: Nico Schottelius --- Makefile | 2 ++ doc/dev/todo/niconext | 5 +---- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 96924c4c..ca86ac4d 100644 --- a/Makefile +++ b/Makefile @@ -9,6 +9,7 @@ WEBDIR=$$HOME/niconetz WEBPAGE=software/cdist.mdwn MANDIR=doc/man +# Unchecked MANSRC=$(MANDIR)/cdist-config-layout.text \ $(MANDIR)/cdist-config.text \ $(MANDIR)/cdist-explorer.text \ @@ -16,6 +17,7 @@ MANSRC=$(MANDIR)/cdist-config-layout.text \ $(MANDIR)/cdist-stages.text \ $(MANDIR)/cdist-terms.text \ +# Clean documentation MANGENERATED=$(MANDIR)/cdist-reference.text MANSRC=$(MANDIR)/cdist.text \ diff --git a/doc/dev/todo/niconext b/doc/dev/todo/niconext index f7acbe88..55598bfd 100644 --- a/doc/dev/todo/niconext +++ b/doc/dev/todo/niconext @@ -1,5 +1,2 @@ Documentation cleanup - - document environment variables - - and merge with config-layout! - - how to debug explorer - => 1.0.2 + - how to debug explorer => 1.0.2 From 19d3b52d73b05b735994221eae8582b2047800e7 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 9 Mar 2011 10:16:46 +0100 Subject: [PATCH 15/41] finish manpage cdist-explorer Signed-off-by: Nico Schottelius --- Makefile | 2 +- doc/changelog | 2 +- doc/man/cdist-explorer.text | 66 ++++++++++++++++++++++++++++ doc/man/to_check/cdist-explorer.text | 43 ------------------ 4 files changed, 68 insertions(+), 45 deletions(-) create mode 100644 doc/man/cdist-explorer.text delete mode 100644 doc/man/to_check/cdist-explorer.text diff --git a/Makefile b/Makefile index ca86ac4d..adf03e31 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,6 @@ MANDIR=doc/man # Unchecked MANSRC=$(MANDIR)/cdist-config-layout.text \ $(MANDIR)/cdist-config.text \ - $(MANDIR)/cdist-explorer.text \ $(MANDIR)/cdist-quickstart.text \ $(MANDIR)/cdist-stages.text \ $(MANDIR)/cdist-terms.text \ @@ -23,6 +22,7 @@ MANGENERATED=$(MANDIR)/cdist-reference.text MANSRC=$(MANDIR)/cdist.text \ $(MANDIR)/cdist-bin-transfer.text \ $(MANDIR)/cdist-deploy-to.text \ + $(MANDIR)/cdist-explorer.text \ $(MANDIR)/cdist-manifest.text \ $(MANDIR)/cdist-stages.text \ $(MANDIR)/cdist-type.text \ diff --git a/doc/changelog b/doc/changelog index b39c512d..4c356111 100644 --- a/doc/changelog +++ b/doc/changelog @@ -1,5 +1,5 @@ 1.0.2: upcoming - * Add manpages: cdist-type, cdist-type__file, cdist-reference + * Add manpages: cdist-type, cdist-type__file, cdist-reference, cdist-explorer * Make doc/man/ usable as MANPATH entry 1.0.1: 2011-03-08 diff --git a/doc/man/cdist-explorer.text b/doc/man/cdist-explorer.text new file mode 100644 index 00000000..9e40ca4b --- /dev/null +++ b/doc/man/cdist-explorer.text @@ -0,0 +1,66 @@ +cdist-explorer(7) +================= +Nico Schottelius + + +NAME +---- +cdist-explorer - Explore the target systems + + +DESCRIPTION +----------- +Explorer are small shell scripts, which will be executed on the target +host. The aim of the explorer is to give hints to types on how to act on the +target system. An explorer outputs the result to stdout, which is usually +a one liner, but may be empty or multi line especially in the case of +type explorers. + +There are general explorers, which are run in an early stage, and +type explorers. Both work almost exactly the same way, with the difference +that the values of the general explorers are stored in a general location and +the type specific below the object. + +Explorers can reuse other explorers on the target system by calling +$__explorer/ (general and type explorer) or +$__type_explorer/ (type explorer). + +In case of significant errors, the explorer may exit non-zero and return an +error message on stderr, which will cause the cdist run to abort. + + +EXAMPLES +-------- +A very simple explorer may look like this: + +-------------------------------------------------------------------------------- +hostname +-------------------------------------------------------------------------------- + +Which is in practise the "hostname" explorer. + +A type explorer, which could check for the status of a package may look like this: + +-------------------------------------------------------------------------------- +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 +-------------------------------------------------------------------------------- + + +SEE ALSO +-------- +- cdist(7) +- cdist-reference(7) +- cdist-stages(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). diff --git a/doc/man/to_check/cdist-explorer.text b/doc/man/to_check/cdist-explorer.text deleted file mode 100644 index 659a01e1..00000000 --- a/doc/man/to_check/cdist-explorer.text +++ /dev/null @@ -1,43 +0,0 @@ -cdist-explorer(7) -================= -Nico Schottelius - - -NAME ----- -cdist-explorer - Explore the target systems - - -DESCRIPTION ------------ -Cdist explorer are small shell scripts, which will be executed -on the target host. The aim of the explorer is to give hints -to types on how to act on the target system. -The explorer output the result of its investigation -to stdout and should be a one-liner. The output may be empty, -though. - -Cdist knows about general explorers, which are run in an early -stage and type specific explorers. Both work exactly the same way, -with the difference that the values of the general explorers -are stored in a general location and the type specific below -the types. - -Explorers can reuse other explorers on the target system -by calling ./ (i.e. explorers are run -from their location). - -In case of significant errors, the shell script may exit -non-zero and return an error message on stderr, which -will cause the cdist run to abort. - - -SEE ALSO --------- -cdist(7), cdist-config-layout(7), cdist-stages(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). From adb9ed9ca506400da3f5c0adecc08e2499771efe Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 9 Mar 2011 10:17:43 +0100 Subject: [PATCH 16/41] hint on debug / explorer Signed-off-by: Nico Schottelius --- doc/dev/todo/niconext | 1 - doc/man/cdist-explorer.text | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/dev/todo/niconext b/doc/dev/todo/niconext index 55598bfd..04dfc21b 100644 --- a/doc/dev/todo/niconext +++ b/doc/dev/todo/niconext @@ -1,2 +1 @@ Documentation cleanup - - how to debug explorer => 1.0.2 diff --git a/doc/man/cdist-explorer.text b/doc/man/cdist-explorer.text index 9e40ca4b..63c7a5c9 100644 --- a/doc/man/cdist-explorer.text +++ b/doc/man/cdist-explorer.text @@ -28,6 +28,8 @@ $__type_explorer/ (type explorer). In case of significant errors, the explorer may exit non-zero and return an error message on stderr, which will cause the cdist run to abort. +You can also use stderr for debugging purposes while developing a new +explorer. EXAMPLES -------- From 579d58625bcc3694ae61d5fbabafa7dbca3ebdf4 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 9 Mar 2011 10:36:58 +0100 Subject: [PATCH 17/41] setup date in changelog Signed-off-by: Nico Schottelius --- doc/changelog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/changelog b/doc/changelog index 4c356111..4ec2c47f 100644 --- a/doc/changelog +++ b/doc/changelog @@ -1,4 +1,4 @@ -1.0.2: upcoming +1.0.2: 2011-03-09 * Add manpages: cdist-type, cdist-type__file, cdist-reference, cdist-explorer * Make doc/man/ usable as MANPATH entry From d88f4afc8722d4e3bdca3c318ee51474b3198b66 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 9 Mar 2011 12:01:54 +0100 Subject: [PATCH 18/41] +logfile Signed-off-by: Nico Schottelius --- doc/dev/logs/2011-03-09 | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 doc/dev/logs/2011-03-09 diff --git a/doc/dev/logs/2011-03-09 b/doc/dev/logs/2011-03-09 new file mode 100644 index 00000000..4666ccb3 --- /dev/null +++ b/doc/dev/logs/2011-03-09 @@ -0,0 +1,3 @@ +Steven & Nico: +- types are closed in themselves +- manpage will be stored in conf/type/NAME/man.text From 1c45e4fe174995206c06ae6abc4b01e0cb3200aa Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 9 Mar 2011 13:06:23 +0100 Subject: [PATCH 19/41] begin the manpage integration with man.text Signed-off-by: Nico Schottelius --- Makefile | 33 ++++++++++++++----- .../type/__file/man.text | 0 doc/man/cdist-reference.text.sh | 14 +++++--- doc/man/cdist-type.text | 3 +- 4 files changed, 36 insertions(+), 14 deletions(-) rename doc/man/cdist-type__file.text => conf/type/__file/man.text (100%) diff --git a/Makefile b/Makefile index adf03e31..115fa5f8 100644 --- a/Makefile +++ b/Makefile @@ -27,7 +27,6 @@ MANSRC=$(MANDIR)/cdist.text \ $(MANDIR)/cdist-stages.text \ $(MANDIR)/cdist-type.text \ $(MANDIR)/cdist-type-template.text \ - $(MANDIR)/cdist-type__file.text \ ################################################################################ @@ -47,16 +46,34 @@ all: man: doc/man/.marker -doc/man/.marker: $(MANSRC) $(MANGENERATED) - for mansrc in $^; do $(A2X) $$mansrc; done - for manpage in $(MANDIR)/*.[1-9]; do cat=$${manpage##*.}; mandir=$(MANDIR)/man$$cat; mkdir -p $$mandir; mv $$manpage $$mandir; done +doc/man/.marker: touch $@ -# Only depends on cdist-type__*.text in reality -$(MANDIR)/cdist-reference.text: $(MANSRC) $(MANDIR)/cdist-reference.text.sh - $(MANDIR)/cdist-reference.text.sh - +# Manual from core +mancore: $(MANSRC) + for mansrc in $^; do $(A2X) $$mansrc; done +# Manuals from types +mantype: + for man in conf/type/*/man.text; do $(A2X) $$man; done + +# Move into manpath directories +manmove: mantype mancore + for manpage in $(MANDIR)/*.[1-9] conf/type/*/*.7; do \ + cat=$${manpage##*.}; \ + echo $$cat; \ + mandir=$(MANDIR)/man$$cat; \ + mkdir -p $$mandir; \ + mv $$manpage $$mandir; \ + done + +# Reference +$(MANDIR)/cdist-reference.text: manmove $(MANDIR)/cdist-reference.text.sh + $(MANDIR)/cdist-reference.text.sh + $(A2X) $(MANDIR)/cdist-reference.text + # Move us to the destination as well + make manmove + clean: rm -rf doc/man/*.html doc/man/*.[1-9] doc/man/man[1-9] $(MANGENERATED) diff --git a/doc/man/cdist-type__file.text b/conf/type/__file/man.text similarity index 100% rename from doc/man/cdist-type__file.text rename to conf/type/__file/man.text diff --git a/doc/man/cdist-reference.text.sh b/doc/man/cdist-reference.text.sh index 2453c216..f900e35e 100755 --- a/doc/man/cdist-reference.text.sh +++ b/doc/man/cdist-reference.text.sh @@ -83,6 +83,9 @@ conf/type//:: This directory is referenced by the variable __type (see below). +conf/type//man.text:: + Manpage in Asciidoc format (nequired for inclusion into upstream) + conf/type//manifest:: Used to generate additional objects from a type. @@ -132,9 +135,9 @@ TYPES The following types are available: eof -for type in cdist-type__*.text; do - name_1="${type#cdist-type}" - name_2="${name_1%.text}" +for type in man7/cdist-type__*; do + name_1="${type#man7/cdist-type}" + name_2="${name_1%.7}" name="$name_2" echo "- $name" @@ -175,8 +178,9 @@ SEE ALSO -------- - cdist(7) eof -for type in cdist-type__*.text; do - name_2="${type%.text}" +for type in man7/cdist-type__*; do + name_1="${type#man7/}" + name_2="${name_1%.7}" name="$name_2" echo "- ${name}(7)" diff --git a/doc/man/cdist-type.text b/doc/man/cdist-type.text index b5097a5c..2835815e 100644 --- a/doc/man/cdist-type.text +++ b/doc/man/cdist-type.text @@ -153,7 +153,8 @@ If you think your type may be useful for others, ensure it works with the current master branch of cdist and submit the git url containing the type for inclusion to the mailinglist **cdist at cdist -- at -- l.schottelius.org**. -Ensure a corresponding manpage named cdist-type__NAME is included. +Ensure a corresponding manpage named man.text in asciidoc format with +the manpage-name "cdist-type__NAME" is included in the type directory. SEE ALSO From 719419d364feb2173e861d9e85b9fd1dd8b77b33 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 9 Mar 2011 13:08:56 +0100 Subject: [PATCH 20/41] finish (kind of ugly) manpage generation in makefile Signed-off-by: Nico Schottelius --- Makefile | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 115fa5f8..a6d78aeb 100644 --- a/Makefile +++ b/Makefile @@ -46,7 +46,7 @@ all: man: doc/man/.marker -doc/man/.marker: +doc/man/.marker: $(MANDIR)/cdist-reference.text touch $@ # Manual from core @@ -61,13 +61,12 @@ mantype: manmove: mantype mancore for manpage in $(MANDIR)/*.[1-9] conf/type/*/*.7; do \ cat=$${manpage##*.}; \ - echo $$cat; \ mandir=$(MANDIR)/man$$cat; \ mkdir -p $$mandir; \ mv $$manpage $$mandir; \ done -# Reference +# Reference depends on conf/type/*/man.text - HOWTO with posix make? $(MANDIR)/cdist-reference.text: manmove $(MANDIR)/cdist-reference.text.sh $(MANDIR)/cdist-reference.text.sh $(A2X) $(MANDIR)/cdist-reference.text From 8ac043e95f98ac47a4b18a27e4f536fe748241c0 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 9 Mar 2011 20:22:02 +0100 Subject: [PATCH 21/41] comment the initial manifest Signed-off-by: Nico Schottelius --- conf/manifest/init | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/conf/manifest/init b/conf/manifest/init index e6cf47d5..ab366540 100755 --- a/conf/manifest/init +++ b/conf/manifest/init @@ -3,8 +3,10 @@ # # This is debug and should not be in a production environment -echo "We could access other manifests in $__manifest" +# echo "We could access other manifests in $__manifest" +# Every machine becomes a marker, so sysadmins know that automatic +# configurations are happening __file /etc/cdist-configured --type file case "$__target_host" in @@ -13,22 +15,34 @@ case "$__target_host" in __file test --type file --destination /tmp/cdist-testfile ;; + # + # Examples using different types + # + # Alias in /etc/hosts for localhost cdist-archlinux) - __package_pacman django --state deinstalled - __package_pacman wireshark-cli --state installed + # This is the specific package type for pacman __package_pacman zsh --state installed + + # The __package type autoselect the right type based on the os + __package vim --state installed ;; + # This is how it would look like on gentoo cdist-gentoo) + # Same stuff for gentoo __package tree --state installed ;; + cdist-debian) + __package_apt atop --state installed + __package apache2 --state deinstalled + ;; - # Real machines - ikq*) - __package_apt zsh --state installed - __package_apt apache2 --state deinstalled - ;; - kr) - __issue iddoesnotmatterhere - ;; + # Real machines may be used with their hostname or fqdn, + # depending on how you call cdist-deploy-to + # machine) + # ... + # ;; + # machine.example.org) + # ... + # ;; esac From b7dd337ea58c550598afe9d40077f427d4ee9423 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 9 Mar 2011 21:27:47 +0100 Subject: [PATCH 22/41] currently no need for a parallel cdist-deploy-to Signed-off-by: Nico Schottelius --- doc/dev/todo/post-1.0 | 2 -- 1 file changed, 2 deletions(-) diff --git a/doc/dev/todo/post-1.0 b/doc/dev/todo/post-1.0 index 9d6031b4..d11a482b 100644 --- a/doc/dev/todo/post-1.0 +++ b/doc/dev/todo/post-1.0 @@ -1,8 +1,6 @@ Core: - Support singletons (see types/issue for a good reason) - probably name them only_once and use that as the internal id! - - cdist-deploy-to: Configure more than one host - - plus parallel mode like in ccollect Type handler: - add dependency parameters to core available for every type From a3f2bc5fbb738684bf2b293e4b7b5e86be5fec3d Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 9 Mar 2011 21:54:13 +0100 Subject: [PATCH 23/41] even less todo Signed-off-by: Nico Schottelius --- doc/dev/todo/post-1.0 | 10 ---------- doc/man/cdist-manifest.text | 8 ++++---- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/doc/dev/todo/post-1.0 b/doc/dev/todo/post-1.0 index d11a482b..6331435c 100644 --- a/doc/dev/todo/post-1.0 +++ b/doc/dev/todo/post-1.0 @@ -34,8 +34,6 @@ Documentation: - cdist-trigger after first run from /var/lib/cdist/out/bin? - Different environments (production, integration, development) - via version control - - Define how to raise errors in types - - Check all references in manpages, ensure all manpages exist, generic ones: + cdist + cdist-deploy-to @@ -45,10 +43,6 @@ Documentation: - install packages only if not existent - copy file only if different - DOC document that $type/manifest is executed for every object/instance - - category 7: - - cdist-manifest(7) - - cdist-explorer - - cdist-config-layout - ensure every file in bin/ has a correspondent manpage - cdist-code-run-all - cdist-config @@ -67,8 +61,4 @@ Documentation: - cdist-run-remote - cdist-type-build-emulation - cdist-type-emulator - - Cleanup READMEs - Ensure html output of manpages are published on the web - -- Makefile: - - Include manpage generation diff --git a/doc/man/cdist-manifest.text b/doc/man/cdist-manifest.text index 40ab2c4e..efa5a8eb 100644 --- a/doc/man/cdist-manifest.text +++ b/doc/man/cdist-manifest.text @@ -43,10 +43,10 @@ __file /etc/nologin --type file --source "$__type/files/default.nologin" SEE ALSO -------- -cdist-manifest-run(1), -cdist-manifest-run-all(1), -cdist-manifest-run-init(1), -cdist-type(7) +- cdist-manifest-run(1) +- cdist-manifest-run-all(1) +- cdist-manifest-run-init(1) +- cdist-type(7) COPYING From 4fdfac292b75fad973da28209e18683ca37e2b05 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 9 Mar 2011 21:55:32 +0100 Subject: [PATCH 24/41] nexttodo / nico Signed-off-by: Nico Schottelius --- doc/dev/todo/niconext | 5 ++++- doc/dev/todo/post-1.0 | 4 ---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/doc/dev/todo/niconext b/doc/dev/todo/niconext index 04dfc21b..c0dd742f 100644 --- a/doc/dev/todo/niconext +++ b/doc/dev/todo/niconext @@ -1 +1,4 @@ -Documentation cleanup +Core: + - Support singletons (see types/issue for a good reason) + - probably name them only_once and use that as the internal id! + diff --git a/doc/dev/todo/post-1.0 b/doc/dev/todo/post-1.0 index 6331435c..e5326a25 100644 --- a/doc/dev/todo/post-1.0 +++ b/doc/dev/todo/post-1.0 @@ -1,7 +1,3 @@ -Core: - - Support singletons (see types/issue for a good reason) - - probably name them only_once and use that as the internal id! - Type handler: - add dependency parameters to core available for every type --requires From 41d82ea89a9713e85fc3c7e79aee1d52a6c497e8 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 9 Mar 2011 21:58:34 +0100 Subject: [PATCH 25/41] add only once to __issue Signed-off-by: Nico Schottelius --- conf/type/__issue/only_once | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 conf/type/__issue/only_once diff --git a/conf/type/__issue/only_once b/conf/type/__issue/only_once new file mode 100644 index 00000000..e69de29b From 70485e3516011a7cb10868db9285b6f0b9e8568f Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 9 Mar 2011 22:09:44 +0100 Subject: [PATCH 26/41] extend cdist-type-emulator with singleton type Signed-off-by: Nico Schottelius --- bin/cdist-config | 11 ++++++----- bin/cdist-type-emulator | 10 ++++++++-- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/bin/cdist-config b/bin/cdist-config index 7f68ca67..bebf449c 100755 --- a/bin/cdist-config +++ b/bin/cdist-config @@ -57,6 +57,7 @@ __cdist_abs_myname="$__cdist_abs_mydir/$__cdist_myname" : ${__cdist_name_parameter:=parameter} : ${__cdist_name_parameter_required:=required} : ${__cdist_name_parameter_optional:=optional} +: ${__cdist_name_singleton:=singleton} : ${__cdist_name_target_host:=target_host} : ${__cdist_name_type:=type} : ${__cdist_name_type_bin:=type_bin} @@ -162,11 +163,6 @@ __cdist_init_deploy() ln -sf "$__cdist_conf_dir" "$__cdist_local_base_dir/$__cdist_name_conf_dir" } -# __cdist_cache_host() -# { -# echo "${__cdist_cache_hosts}/${__cdist_target_host}" -# } - __cdist_type_has_explorer() { # We only create output, if there's at least one explorer @@ -196,6 +192,11 @@ __cdist_type_gencode() echo "${__cdist_type_dir}/$1/${__cdist_name_gencode}" } +__cdist_type_singleton() +{ + echo "${__cdist_type_dir}/$1/${__cdist_name_singleton}" +} + __cdist_type_parameter_dir() { echo "$(__cdist_type_dir "$1")/${__cdist_name_parameter}" diff --git a/bin/cdist-type-emulator b/bin/cdist-type-emulator index 69be9405..9c54c714 100755 --- a/bin/cdist-type-emulator +++ b/bin/cdist-type-emulator @@ -25,12 +25,18 @@ # . cdist-config -[ $# -ge 1 ] || __cdist_usage " " set -eu -__cdist_object_id="$1"; shift +# Find out whether type is a singleton or regular type __cdist_type="$__cdist_myname" +if [ -f "$(__cdist_type_singleton "$__cdist_type")" ]; then + __cdist_object_id="singleton" +else + [ $# -ge 1 ] || __cdist_usage " " + __cdist_object_id="$1"; shift +fi + echo "$__cdist_object_id" | grep -q "^${__cdist_sane_regexp}\$" || \ __cdist_usage "Insane object id, ${__cdist_object_id}." From a67073a45bac6de17e36765815b2adb26ab60989 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 9 Mar 2011 22:21:39 +0100 Subject: [PATCH 27/41] add example for singleton Signed-off-by: Nico Schottelius --- conf/manifest/init | 4 ++++ conf/type/__issue/manifest | 2 +- conf/type/__issue/{only_once => singleton} | 0 3 files changed, 5 insertions(+), 1 deletion(-) rename conf/type/__issue/{only_once => singleton} (100%) diff --git a/conf/manifest/init b/conf/manifest/init index ab366540..8a2428ce 100755 --- a/conf/manifest/init +++ b/conf/manifest/init @@ -12,6 +12,7 @@ __file /etc/cdist-configured --type file case "$__target_host" in # Everybody has this localhost) + # Usual example __file test --type file --destination /tmp/cdist-testfile ;; @@ -26,6 +27,9 @@ case "$__target_host" in # The __package type autoselect the right type based on the os __package vim --state installed + + # If the type is a singleton, it does not take an object id + __issue ;; # This is how it would look like on gentoo cdist-gentoo) diff --git a/conf/type/__issue/manifest b/conf/type/__issue/manifest index a79544ee..3f741e89 100755 --- a/conf/type/__issue/manifest +++ b/conf/type/__issue/manifest @@ -20,7 +20,7 @@ # destination=/etc/issue -os="$(cat "out/explorer/os")" +Zs="$(cat "out/explorer/os")" case "$os" in archlinux) diff --git a/conf/type/__issue/only_once b/conf/type/__issue/singleton similarity index 100% rename from conf/type/__issue/only_once rename to conf/type/__issue/singleton From 9ccaa85102696fc7c7b50f66d5445363bc195962 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 9 Mar 2011 22:22:04 +0100 Subject: [PATCH 28/41] todo++ Signed-off-by: Nico Schottelius --- doc/dev/todo/niconext | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/doc/dev/todo/niconext b/doc/dev/todo/niconext index c0dd742f..87b61b47 100644 --- a/doc/dev/todo/niconext +++ b/doc/dev/todo/niconext @@ -1,4 +1,3 @@ -Core: - - Support singletons (see types/issue for a good reason) - - probably name them only_once and use that as the internal id! +- Support singletons (see types/issue for a good reason) + - add documentation! From 70704b16a961f8cbae1eaad7660008210fa37e65 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 10 Mar 2011 13:21:21 +0100 Subject: [PATCH 29/41] +comment Signed-off-by: Nico Schottelius --- bin/cdist-type-emulator | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/cdist-type-emulator b/bin/cdist-type-emulator index 9c54c714..d79fb68a 100755 --- a/bin/cdist-type-emulator +++ b/bin/cdist-type-emulator @@ -27,9 +27,9 @@ . cdist-config set -eu -# Find out whether type is a singleton or regular type __cdist_type="$__cdist_myname" +# Find out whether type is a singleton or regular type if [ -f "$(__cdist_type_singleton "$__cdist_type")" ]; then __cdist_object_id="singleton" else From 637163d4af0ec4c10327a73a83aed3fd39eecf00 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 10 Mar 2011 13:31:00 +0100 Subject: [PATCH 30/41] only md5sum if file is a regular file (not a directory) Signed-off-by: Nico Schottelius --- conf/type/__file/explorer/md5sum | 6 +++++- conf/type/__file/gencode | 20 +++++++++++--------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/conf/type/__file/explorer/md5sum b/conf/type/__file/explorer/md5sum index b2867385..4ac0e1b9 100755 --- a/conf/type/__file/explorer/md5sum +++ b/conf/type/__file/explorer/md5sum @@ -41,7 +41,11 @@ esac # No output if file does not exist - does definitely not match the md5sum :-) if [ -e "$destination" ]; then - $md5sum < "$destination" + if [ -f "$destination" ]; then + $md5sum < "$destination" + else + echo "NO REGULAR FILE" + fi else echo "NO FILE FOUND, NO CHECKSUM CALCULATED." fi diff --git a/conf/type/__file/gencode b/conf/type/__file/gencode index 0f3b1bf8..43104f6f 100755 --- a/conf/type/__file/gencode +++ b/conf/type/__file/gencode @@ -55,16 +55,18 @@ esac if [ -f "$__object/parameter/source" ]; then source="$(cat "$__object/parameter/source")" - local_md5sum="$($md5sum < "$source")" - remote_md5sum="$(cat "$__object/explorer/md5sum")" + if [ -f "$source" ]; then + local_md5sum="$($md5sum < "$source")" + remote_md5sum="$(cat "$__object/explorer/md5sum")" - # 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}" + # 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 fi # No source? Create empty file/dir else From 62c64464120b101aff59e927d7ea6d81cbb5223e Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 10 Mar 2011 13:36:58 +0100 Subject: [PATCH 31/41] exit true in case packet is not installed Signed-off-by: Nico Schottelius --- conf/type/__package_apt/gencode | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/type/__package_apt/gencode b/conf/type/__package_apt/gencode index b451eb9f..413562d5 100755 --- a/conf/type/__package_apt/gencode +++ b/conf/type/__package_apt/gencode @@ -29,7 +29,7 @@ fi state="$(cat "$__object/parameter/state")" -is_installed="$(grep "^Status: install ok installed" "$__object/explorer/pkg_status")" +is_installed="$(grep "^Status: install ok installed" "$__object/explorer/pkg_status" || true)" case "$state" in installed) From e48458f27ff57c357f5c4514f42646cd4bbaf1ef Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 10 Mar 2011 13:38:12 +0100 Subject: [PATCH 32/41] add explorer to find out whether file exists Signed-off-by: Nico Schottelius --- conf/type/__file/explorer/exists | 34 ++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100755 conf/type/__file/explorer/exists diff --git a/conf/type/__file/explorer/exists b/conf/type/__file/explorer/exists new file mode 100755 index 00000000..b0be82fc --- /dev/null +++ b/conf/type/__file/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 From 03502567e3c6f5e1f3c907865718b107c1295738 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 10 Mar 2011 13:40:05 +0100 Subject: [PATCH 33/41] check for existence before (re-)creation Signed-off-by: Nico Schottelius --- conf/type/__file/gencode | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/conf/type/__file/gencode b/conf/type/__file/gencode index 43104f6f..9ad956fe 100755 --- a/conf/type/__file/gencode +++ b/conf/type/__file/gencode @@ -70,20 +70,23 @@ if [ -f "$__object/parameter/source" ]; then fi # No source? Create empty file/dir else - case "$type" in - directory) - echo mkdir \"$destination\" - ;; + # Only touch / create if it does not exist + if [ no = "$(cat "$__object/explorer/exists")" ]; then + case "$type" in + directory) + echo mkdir \"$destination\" + ;; - file) - echo touch \"$destination\" - ;; + file) + echo touch \"$destination\" + ;; - *) - echo "Unsupported type: \"$type\"" >&2 - exit 1 - ;; - esac + *) + echo "Unsupported type: \"$type\"" >&2 + exit 1 + ;; + esac + fi fi if [ -f "$__object/parameter/mode" ]; then From 5ababb12495f30dfb7aff8388517fa6de9e6e2d8 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 10 Mar 2011 17:09:04 +0100 Subject: [PATCH 34/41] correct manifest of __issue Signed-off-by: Nico Schottelius --- conf/type/__issue/manifest | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/type/__issue/manifest b/conf/type/__issue/manifest index 3f741e89..aa6f7629 100755 --- a/conf/type/__issue/manifest +++ b/conf/type/__issue/manifest @@ -20,7 +20,7 @@ # destination=/etc/issue -Zs="$(cat "out/explorer/os")" +source="$(cat "out/explorer/os")" case "$os" in archlinux) From 96af3939428338f29798ab4dc73aab8b39f5ee45 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 10 Mar 2011 17:11:51 +0100 Subject: [PATCH 35/41] ++todo Signed-off-by: Nico Schottelius --- doc/dev/todo/post-1.0 | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/doc/dev/todo/post-1.0 b/doc/dev/todo/post-1.0 index e5326a25..8ea11dd4 100644 --- a/doc/dev/todo/post-1.0 +++ b/doc/dev/todo/post-1.0 @@ -58,3 +58,9 @@ Documentation: - cdist-type-build-emulation - cdist-type-emulator - Ensure html output of manpages are published on the web +-------------------------------------------------------------------------------- +Fix: +Running initial manifest for sgv-wiki-01 ... +/tmp/cdist.VfhjaH8LP3GE/out/type_bin/__ethz_systems_wiki: Zeile 87: /home/users/nico/privat/firmen/ethz/vcs/cdist/conf/type/__ethz_systems_wiki/parameter/required: Datei oder Verzeichnis nicht gefunden +/tmp/cdist.VfhjaH8LP3GE/out/type_bin/__ethz_systems_wiki: Zeile 94: /home/users/nico/privat/firmen/ethz/vcs/cdist/conf/type/__ethz_systems_wiki/parameter/optional: Datei oder Verzeichnis nicht gefunden + From 99e6b9e6b1e7101fdb164c5b1cd6660a9cf5aaa0 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 10 Mar 2011 17:19:25 +0100 Subject: [PATCH 36/41] update regexp for sane characters Signed-off-by: Nico Schottelius --- bin/cdist-config | 4 ++-- doc/changelog | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/bin/cdist-config b/bin/cdist-config index bebf449c..850f2a2b 100755 --- a/bin/cdist-config +++ b/bin/cdist-config @@ -63,8 +63,8 @@ __cdist_abs_myname="$__cdist_abs_mydir/$__cdist_myname" : ${__cdist_name_type_bin:=type_bin} : ${__cdist_name_type_explorer:=type_explorer} -# Used for IDs -: ${__cdist_sane_regexp:=[A-Za-z0-9/]*[-A-Za-z0-9_/]*} +# Used for IDs: Allow everything not starting with - and . +: ${__cdist_sane_regexp:=^[^-\.]} # Default remote user : ${__cdist_remote_user:=root} diff --git a/doc/changelog b/doc/changelog index 4ec2c47f..41073e2c 100644 --- a/doc/changelog +++ b/doc/changelog @@ -1,3 +1,6 @@ +1.0.3: upcoming + * Update regexp used for sane characters + 1.0.2: 2011-03-09 * Add manpages: cdist-type, cdist-type__file, cdist-reference, cdist-explorer * Make doc/man/ usable as MANPATH entry From c67807af7641463d0ddc536d89eab6e573c0e65e Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 10 Mar 2011 17:23:47 +0100 Subject: [PATCH 37/41] make regexp usable in the middle of an expression 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 850f2a2b..625e0c3c 100755 --- a/bin/cdist-config +++ b/bin/cdist-config @@ -64,7 +64,7 @@ __cdist_abs_myname="$__cdist_abs_mydir/$__cdist_myname" : ${__cdist_name_type_explorer:=type_explorer} # Used for IDs: Allow everything not starting with - and . -: ${__cdist_sane_regexp:=^[^-\.]} +: ${__cdist_sane_regexp:=^[^-\.].*} # Default remote user : ${__cdist_remote_user:=root} From dc2a49afe8a5d3d971dac9142a9f35d78507ec00 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 10 Mar 2011 17:25:24 +0100 Subject: [PATCH 38/41] -^ 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 625e0c3c..837bccb6 100755 --- a/bin/cdist-config +++ b/bin/cdist-config @@ -64,7 +64,7 @@ __cdist_abs_myname="$__cdist_abs_mydir/$__cdist_myname" : ${__cdist_name_type_explorer:=type_explorer} # Used for IDs: Allow everything not starting with - and . -: ${__cdist_sane_regexp:=^[^-\.].*} +: ${__cdist_sane_regexp:=[^-\.].*} # Default remote user : ${__cdist_remote_user:=root} From e1a5a26cbfb4038c91475e81247ccf4a30be1a60 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 10 Mar 2011 17:41:08 +0100 Subject: [PATCH 39/41] allow parameters to be missing, if not used Signed-off-by: Nico Schottelius --- bin/cdist-config | 11 +++++++++++ bin/cdist-type-emulator | 26 +++++++++++++++----------- 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/bin/cdist-config b/bin/cdist-config index 837bccb6..c7e671ef 100755 --- a/bin/cdist-config +++ b/bin/cdist-config @@ -207,6 +207,17 @@ __cdist_type_parameter_file() echo "$(__cdist_type_parameter_dir "$1")/$2" } +# Shorthand for required and optional +__cdist_type_parameter_required() +{ + __cdist_type_parameter_file "$1/$__cdist_name_parameter_required" +} + +__cdist_type_parameter_optional() +{ + __cdist_type_parameter_file "$1/$__cdist_name_parameter_optional" +} + __cdist_type_from_object() { echo "${1%%/*}" diff --git a/bin/cdist-type-emulator b/bin/cdist-type-emulator index d79fb68a..a4f66e5b 100755 --- a/bin/cdist-type-emulator +++ b/bin/cdist-type-emulator @@ -78,20 +78,24 @@ while [ $# -gt 0 ]; do done # Ensure required parameters are given -while read required; do - if [ ! -f "${tempparameter}/${required}" ]; then - __cdist_usage "Missing required parameter $required" - fi +if [ -f "$(__cdist_type_parameter_required "$__cdist_type")" ]; then + while read required; do + if [ ! -f "${tempparameter}/${required}" ]; then + __cdist_usage "Missing required parameter $required" + fi - mv "${tempparameter}/${required}" "${__cdist_parameter_dir}" -done < "$(__cdist_type_parameter_file "$__cdist_type" "$__cdist_name_parameter_required")" + mv "${tempparameter}/${required}" "${__cdist_parameter_dir}" + done < "$(__cdist_type_parameter_required "$__cdist_type")" +fi # Allow optional parameters -while read optional; do - if [ -f "${tempparameter}/${optional}" ]; then - mv "${tempparameter}/${optional}" "${__cdist_parameter_dir}" - fi -done < "$(__cdist_type_parameter_file "$__cdist_type" "$__cdist_name_parameter_optional")" +if [ -f "$(__cdist_type_parameter_optional "$__cdist_type")" ]; then + while read optional; do + if [ -f "${tempparameter}/${optional}" ]; then + mv "${tempparameter}/${optional}" "${__cdist_parameter_dir}" + fi + done < "$(__cdist_type_parameter_optional "$__cdist_type")" +fi # Error out on other paramaters cd "${tempparameter}" From 24200865c90b5cf6ed2d8366fc716c1eb02d3f79 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 10 Mar 2011 17:44:16 +0100 Subject: [PATCH 40/41] remove __cdist_type_parameter_file in favor for new variants Signed-off-by: Nico Schottelius --- bin/cdist-config | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/bin/cdist-config b/bin/cdist-config index c7e671ef..54984eaf 100755 --- a/bin/cdist-config +++ b/bin/cdist-config @@ -202,20 +202,15 @@ __cdist_type_parameter_dir() echo "$(__cdist_type_dir "$1")/${__cdist_name_parameter}" } -__cdist_type_parameter_file() -{ - echo "$(__cdist_type_parameter_dir "$1")/$2" -} - # Shorthand for required and optional __cdist_type_parameter_required() { - __cdist_type_parameter_file "$1/$__cdist_name_parameter_required" + echo "$(__cdist_type_parameter_dir "$1")/$__cdist_name_parameter_required" } __cdist_type_parameter_optional() { - __cdist_type_parameter_file "$1/$__cdist_name_parameter_optional" + echo "$(__cdist_type_parameter_dir "$1")/$__cdist_name_parameter_optional" } __cdist_type_from_object() From 9e7a4303729db8f1db6badb3ed8da97e79711b2f Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 10 Mar 2011 17:45:15 +0100 Subject: [PATCH 41/41] more upcoming changes Signed-off-by: Nico Schottelius --- doc/changelog | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/changelog b/doc/changelog index 41073e2c..2f528b90 100644 --- a/doc/changelog +++ b/doc/changelog @@ -1,5 +1,7 @@ 1.0.3: upcoming * Update regexp used for sane characters + * Allow types without parameters + * Allow type to be singleton (DOCUMENTATION MISSING) 1.0.2: 2011-03-09 * Add manpages: cdist-type, cdist-type__file, cdist-reference, cdist-explorer