diff --git a/.gitignore b/.gitignore index 63f8076a..baf9b6f2 100644 --- a/.gitignore +++ b/.gitignore @@ -30,3 +30,4 @@ build .lock-* .git-current-branch .lock* +.pypi-release diff --git a/Makefile b/Makefile index 5910ab2e..1962c96e 100644 --- a/Makefile +++ b/Makefile @@ -175,10 +175,12 @@ freecode-release: $(FREECODE_FILE) ################################################################################ # pypi # -pypi-release: man $(PYTHON_VERSION) +PYPI_FILE=.pypi-release +$(PYPI_FILE): man $(PYTHON_VERSION) python3 setup.py sdist upload touch $@ +pypi-release: $(PYPI_FILE) ################################################################################ # archlinux # diff --git a/bin/build-helper b/bin/build-helper index b97528f1..bfd7d31c 100755 --- a/bin/build-helper +++ b/bin/build-helper @@ -205,19 +205,30 @@ eof fi # Ensure we are on the master branch + masterbranch=yes if [ "$(git rev-parse --abbrev-ref HEAD)" != "master" ]; then echo "Releases are happening from the master branch, aborting" - exit 1 + + echo "Enter the magic word to release anyway" + read magicword + + if [ "$magicword" = "iknowwhatido" ]; then + masterbranch=no + else + exit 1 + fi fi - # Ensure version branch exists - if ! git rev-parse --verify refs/heads/$target_branch 2>/dev/null; then - git branch "$target_branch" - fi + if [ "$masterbranch" = yes ]; then + # Ensure version branch exists + if ! git rev-parse --verify refs/heads/$target_branch 2>/dev/null; then + git branch "$target_branch" + fi - # Merge master branch into version branch - git checkout "$target_branch" - git merge master + # Merge master branch into version branch + git checkout "$target_branch" + git merge master + fi # Verify that after the merge everything works "$0" check-date @@ -236,8 +247,10 @@ eof "$0" release-git-tag # Also merge back the version branch - git checkout master - git merge "$target_branch" + if [ "$masterbranch" = yes ]; then + git checkout master + git merge "$target_branch" + fi # Publish git changes make pub diff --git a/cdist/conf/explorer/hostname b/cdist/conf/explorer/hostname index 881c910a..7715c6b0 100755 --- a/cdist/conf/explorer/hostname +++ b/cdist/conf/explorer/hostname @@ -1,6 +1,6 @@ #!/bin/sh # -# 2010-2011 Nico Schottelius (nico-cdist at schottelius.org) +# 2010-2014 Nico Schottelius (nico-cdist at schottelius.org) # 2012 Steven Armstrong (steven-cdist at armstrong.cc) # # This file is part of cdist. @@ -20,6 +20,6 @@ # # -if command -v hostname >/dev/null; then - hostname -f +if command -v uname >/dev/null; then + uname -n fi diff --git a/cdist/conf/type/__apt_key/explorer/state b/cdist/conf/type/__apt_key/explorer/state new file mode 100755 index 00000000..f7940741 --- /dev/null +++ b/cdist/conf/type/__apt_key/explorer/state @@ -0,0 +1,32 @@ +#!/bin/sh +# +# 2011-2014 Steven Armstrong (steven-cdist at armstrong.cc) +# +# 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 . +# +# +# Get the current state of the apt key. +# + +if [ -f "$__object/parameter/keyid" ]; then + keyid="$(cat "$__object/parameter/keyid")" +else + keyid="$__object_id" +fi + +apt-key export "$keyid" | head -n 1 | grep -Fqe "BEGIN PGP PUBLIC KEY BLOCK" \ + && echo present \ + || echo absent diff --git a/cdist/conf/type/__apt_key/gencode-remote b/cdist/conf/type/__apt_key/gencode-remote new file mode 100755 index 00000000..c6ead91c --- /dev/null +++ b/cdist/conf/type/__apt_key/gencode-remote @@ -0,0 +1,42 @@ +#!/bin/sh +# +# 2011-2014 Steven Armstrong (steven-cdist at armstrong.cc) +# +# 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 . +# + +if [ -f "$__object/parameter/keyid" ]; then + keyid="$(cat "$__object/parameter/keyid")" +else + keyid="$__object_id" +fi +state_should="$(cat "$__object/parameter/state")" +state_is="$(cat "$__object/explorer/state")" + +if [ "$state_should" = "$state_is" ]; then + # nothing to do + exit 0 +fi + +case "$state_should" in + present) + keyserver="$(cat "$__object/parameter/keyserver")" + echo "apt-key adv --keyserver \"$keyserver\" --recv-keys \"$keyid\"" + ;; + absent) + echo "apt-key del \"$keyid\"" + ;; +esac diff --git a/cdist/conf/type/__apt_key/man.text b/cdist/conf/type/__apt_key/man.text new file mode 100644 index 00000000..1a33e732 --- /dev/null +++ b/cdist/conf/type/__apt_key/man.text @@ -0,0 +1,61 @@ +cdist-type__apt_key(7) +====================== +Steven Armstrong + + +NAME +---- +cdist-type__apt_key - manage the list of keys used by apt + + +DESCRIPTION +----------- +Manages the list of keys used by apt to authenticate packages. + + +REQUIRED PARAMETERS +------------------- +None. + + +OPTIONAL PARAMETERS +------------------- +state:: + 'present' or 'absent'. Defaults to 'present' + +keyid:: + the id of the key to add. Defaults to __object_id + +keyserver:: + the keyserver from which to fetch the key. If omitted the default set in + ./parameter/default/keyserver is used. + + +EXAMPLES +-------- + +-------------------------------------------------------------------------------- +# Add Ubuntu Archive Automatic Signing Key +__apt_key 437D05B5 +# Same thing +__apt_key 437D05B5 --state present +# Get rid of it +__apt_key 437D05B5 --state absent + +# same thing with human readable name and explicit keyid +__apt_key UbuntuArchiveKey --keyid 437D05B5 + +# same thing with other keyserver +__apt_key UbuntuArchiveKey --keyid 437D05B5 --keyserver keyserver.ubuntu.com +-------------------------------------------------------------------------------- + + +SEE ALSO +-------- +- cdist-type(7) + + +COPYING +------- +Copyright \(C) 2011-2014 Steven Armstrong. Free use of this software is +granted under the terms of the GNU General Public License version 3 (GPLv3). diff --git a/cdist/conf/type/__apt_key/parameter/default/keyserver b/cdist/conf/type/__apt_key/parameter/default/keyserver new file mode 100644 index 00000000..f851282c --- /dev/null +++ b/cdist/conf/type/__apt_key/parameter/default/keyserver @@ -0,0 +1 @@ +subkeys.pgp.net diff --git a/cdist/conf/type/__apt_key/parameter/default/state b/cdist/conf/type/__apt_key/parameter/default/state new file mode 100644 index 00000000..e7f6134f --- /dev/null +++ b/cdist/conf/type/__apt_key/parameter/default/state @@ -0,0 +1 @@ +present diff --git a/cdist/conf/type/__apt_key/parameter/optional b/cdist/conf/type/__apt_key/parameter/optional new file mode 100644 index 00000000..18cf2586 --- /dev/null +++ b/cdist/conf/type/__apt_key/parameter/optional @@ -0,0 +1,3 @@ +state +keyid +keyserver diff --git a/cdist/conf/type/__apt_key_uri/explorer/state b/cdist/conf/type/__apt_key_uri/explorer/state new file mode 100755 index 00000000..15d6e653 --- /dev/null +++ b/cdist/conf/type/__apt_key_uri/explorer/state @@ -0,0 +1,32 @@ +#!/bin/sh +# +# 2011-2014 Steven Armstrong (steven-cdist at armstrong.cc) +# +# 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 . +# +# +# Get the current state of the apt key. +# + +if [ -f "$__object/parameter/name" ]; then + name="$(cat "$__object/parameter/name")" +else + name="$__object_id" +fi + +apt-key list | grep -Fqe "$name" \ + && echo present \ + || echo absent diff --git a/cdist/conf/type/__apt_key_uri/gencode-remote b/cdist/conf/type/__apt_key_uri/gencode-remote new file mode 100755 index 00000000..078b8695 --- /dev/null +++ b/cdist/conf/type/__apt_key_uri/gencode-remote @@ -0,0 +1,45 @@ +#!/bin/sh +# +# 2011-2014 Steven Armstrong (steven-cdist at armstrong.cc) +# +# 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 . +# + +if [ -f "$__object/parameter/name" ]; then + name="$(cat "$__object/parameter/name")" +else + name="$__object_id" +fi +state_should="$(cat "$__object/parameter/state")" +state_is="$(cat "$__object/explorer/state")" + +if [ "$state_should" = "$state_is" ]; then + # nothing to do + exit 0 +fi + +case "$state_should" in + present) + uri="$(cat "$__object/parameter/uri")" + printf 'curl -s -L "%s" | apt-key add -\n' "$uri" + ;; + absent) + cat << DONE +keyid=\$(apt-key list | grep -B1 "$name" | awk '/pub/ { print \$2 }' | cut -d'/' -f 2) +apt-key del \$keyid +DONE + ;; +esac diff --git a/cdist/conf/type/__apt_key_uri/man.text b/cdist/conf/type/__apt_key_uri/man.text new file mode 100644 index 00000000..fe9c3a25 --- /dev/null +++ b/cdist/conf/type/__apt_key_uri/man.text @@ -0,0 +1,51 @@ +cdist-type__apt_key_uri(7) +========================== +Steven Armstrong + + +NAME +---- +cdist-type__apt_key_uri - add apt key from uri + + +DESCRIPTION +----------- +Download a key from an uri and add it to the apt keyring. + + +REQUIRED PARAMETERS +------------------- +uri:: + the uri from which to download the key + + +OPTIONAL PARAMETERS +------------------- +state:: + 'present' or 'absent', defaults to 'present' + +name:: + a name for this key, used when testing if it is already installed. + Defaults to __object_id + + +EXAMPLES +-------- + +-------------------------------------------------------------------------------- +__apt_key_uri rabbitmq \ + --name 'RabbitMQ Release Signing Key ' \ + --uri http://www.rabbitmq.com/rabbitmq-signing-key-public.asc \ + --state present +-------------------------------------------------------------------------------- + + +SEE ALSO +-------- +- cdist-type(7) + + +COPYING +------- +Copyright \(C) 2011-2014 Steven Armstrong. Free use of this software is +granted under the terms of the GNU General Public License version 3 (GPLv3). diff --git a/cdist/conf/type/__apt_key_uri/manifest b/cdist/conf/type/__apt_key_uri/manifest new file mode 100755 index 00000000..8dddde56 --- /dev/null +++ b/cdist/conf/type/__apt_key_uri/manifest @@ -0,0 +1,21 @@ +#!/bin/sh +# +# 2013-2014 Steven Armstrong (steven-cdist at armstrong.cc) +# +# 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 . +# + +__package curl diff --git a/cdist/conf/type/__apt_key_uri/parameter/default/state b/cdist/conf/type/__apt_key_uri/parameter/default/state new file mode 100644 index 00000000..e7f6134f --- /dev/null +++ b/cdist/conf/type/__apt_key_uri/parameter/default/state @@ -0,0 +1 @@ +present diff --git a/cdist/conf/type/__apt_key_uri/parameter/optional b/cdist/conf/type/__apt_key_uri/parameter/optional new file mode 100644 index 00000000..72c84b88 --- /dev/null +++ b/cdist/conf/type/__apt_key_uri/parameter/optional @@ -0,0 +1,2 @@ +state +name diff --git a/cdist/conf/type/__apt_key_uri/parameter/required b/cdist/conf/type/__apt_key_uri/parameter/required new file mode 100644 index 00000000..c7954952 --- /dev/null +++ b/cdist/conf/type/__apt_key_uri/parameter/required @@ -0,0 +1 @@ +uri diff --git a/cdist/conf/type/__apt_norecommends/man.text b/cdist/conf/type/__apt_norecommends/man.text new file mode 100644 index 00000000..3b65e72f --- /dev/null +++ b/cdist/conf/type/__apt_norecommends/man.text @@ -0,0 +1,42 @@ +cdist-type__apt_norecommends(7) +=============================== +Steven Armstrong + + +NAME +---- +cdist-type__apt_norecommends - configure apt to not install recommended packages + + +DESCRIPTION +----------- +Configure apt to not install any recommended or suggested packages. + + +REQUIRED PARAMETERS +------------------- +None. + + +OPTIONAL PARAMETERS +------------------- +None. + + +EXAMPLES +-------- + +-------------------------------------------------------------------------------- +__apt_norecommends +-------------------------------------------------------------------------------- + + +SEE ALSO +-------- +- cdist-type(7) + + +COPYING +------- +Copyright \(C) 2014 Steven Armstrong. Free use of this software is +granted under the terms of the GNU General Public License version 3 (GPLv3). diff --git a/cdist/conf/type/__apt_norecommends/manifest b/cdist/conf/type/__apt_norecommends/manifest new file mode 100755 index 00000000..881c2427 --- /dev/null +++ b/cdist/conf/type/__apt_norecommends/manifest @@ -0,0 +1,42 @@ +#!/bin/sh +# +# 2014 Steven Armstrong (steven-cdist at armstrong.cc) +# +# 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 . +# + + +os=$(cat "$__global/explorer/os") + +case "$os" in + ubuntu|debian) + # No stinking recommends thank you very much. + # If I want something installed I will do so myself. + __file /etc/apt/apt.conf.d/99-no-recommends \ + --owner root --group root --mode 644 \ + --source - << DONE +APT::Install-Recommends "0"; +APT::Install-Suggests "0"; +DONE + ;; + *) + cat >&2 << DONE +The developer of this type (${__type##*/}) did not think your operating system +($os) would have any use for it. If you think otherwise please submit a patch. +DONE + exit 1 + ;; +esac diff --git a/cdist/conf/type/__apt_norecommends/singleton b/cdist/conf/type/__apt_norecommends/singleton new file mode 100644 index 00000000..e69de29b diff --git a/cdist/conf/type/__apt_ppa/man.text b/cdist/conf/type/__apt_ppa/man.text index 6a5990d5..da18e9f0 100644 --- a/cdist/conf/type/__apt_ppa/man.text +++ b/cdist/conf/type/__apt_ppa/man.text @@ -16,7 +16,8 @@ This cdist type allows manage ubuntu ppa repositories. REQUIRED PARAMETERS ------------------- state:: - The state the ppa should be in, either "present" or "absent". + The state the ppa should be in, either 'present' or 'absent'. + Defaults to 'present' OPTIONAL PARAMETERS @@ -29,6 +30,8 @@ EXAMPLES -------------------------------------------------------------------------------- # Enable a ppa repository +__apt_ppa ppa:sans-intern/missing-bits +# same as __apt_ppa ppa:sans-intern/missing-bits --state present # Disable a ppa repository @@ -43,5 +46,5 @@ SEE ALSO COPYING ------- -Copyright \(C) 2011 Steven Armstrong. Free use of this software is +Copyright \(C) 2011-2014 Steven Armstrong. Free use of this software is granted under the terms of the GNU General Public License version 3 (GPLv3). diff --git a/cdist/conf/type/__apt_ppa/manifest b/cdist/conf/type/__apt_ppa/manifest index e7ad0c26..1d90e9c4 100755 --- a/cdist/conf/type/__apt_ppa/manifest +++ b/cdist/conf/type/__apt_ppa/manifest @@ -1,6 +1,6 @@ #!/bin/sh # -# 2011 Steven Armstrong (steven-cdist at armstrong.cc) +# 2011-2014 Steven Armstrong (steven-cdist at armstrong.cc) # # This file is part of cdist. # @@ -20,9 +20,10 @@ name="$__object_id" -__package python-software-properties --state present +__package software-properties-common +__package python-software-properties -require="__package/python-software-properties" \ +require="__package/software-properties-common __package/python-software-properties" \ __file /usr/local/bin/remove-apt-repository \ --source "$__type/files/remove-apt-repository" \ --mode 0755 diff --git a/cdist/conf/type/__apt_ppa/parameter/default/state b/cdist/conf/type/__apt_ppa/parameter/default/state new file mode 100644 index 00000000..e7f6134f --- /dev/null +++ b/cdist/conf/type/__apt_ppa/parameter/default/state @@ -0,0 +1 @@ +present diff --git a/cdist/conf/type/__apt_ppa/parameter/required b/cdist/conf/type/__apt_ppa/parameter/optional similarity index 100% rename from cdist/conf/type/__apt_ppa/parameter/required rename to cdist/conf/type/__apt_ppa/parameter/optional diff --git a/cdist/conf/type/__apt_source/files/source.list.template b/cdist/conf/type/__apt_source/files/source.list.template new file mode 100755 index 00000000..d4420e96 --- /dev/null +++ b/cdist/conf/type/__apt_source/files/source.list.template @@ -0,0 +1,15 @@ +#!/bin/sh +set -u + +entry="$uri $distribution $component" +cat << DONE +# Created by cdist ${__type##*/} +# Do not change. Changes will be overwritten. +# + +# $name +deb ${forcedarch} $entry +DONE +if [ -f "$__object/parameter/include-src" ]; then + echo "deb-src $entry" +fi diff --git a/cdist/conf/type/__apt_source/man.text b/cdist/conf/type/__apt_source/man.text new file mode 100644 index 00000000..03b2b311 --- /dev/null +++ b/cdist/conf/type/__apt_source/man.text @@ -0,0 +1,69 @@ +cdist-type__apt_source(7) +========================= +Steven Armstrong + + +NAME +---- +cdist-type__apt_source - manage apt sources + + +DESCRIPTION +----------- +This cdist type allows you to manage apt sources. + + +REQUIRED PARAMETERS +------------------- +uri:: + the uri to the apt repository + + +OPTIONAL PARAMETERS +------------------- +arch:: + set this if you need to force and specific arch (ubuntu specific) + +state:: + 'present' or 'absent', defaults to 'present' + +distribution:: + the distribution codename to use. Defaults to DISTRIB_CODENAME from + the targets /etc/lsb-release + +component:: + space delimited list of components to enable. Defaults to an empty string. + + +BOOLEAN PARAMETERS +------------------ +include-src:: + include deb-src entries + + +EXAMPLES +-------- + +-------------------------------------------------------------------------------- +__apt_source rabbitmq \ + --uri http://www.rabbitmq.com/debian/ \ + --distribution testing \ + --component main \ + --include-src \ + --state present + +__apt_source canonical_partner \ + --uri http://archive.canonical.com/ \ + --component partner --state present +-------------------------------------------------------------------------------- + + +SEE ALSO +-------- +- cdist-type(7) + + +COPYING +------- +Copyright \(C) 2011-2014 Steven Armstrong. Free use of this software is +granted under the terms of the GNU General Public License version 3 (GPLv3). diff --git a/cdist/conf/type/__apt_source/manifest b/cdist/conf/type/__apt_source/manifest new file mode 100755 index 00000000..0e782716 --- /dev/null +++ b/cdist/conf/type/__apt_source/manifest @@ -0,0 +1,56 @@ +#!/bin/sh +# +# 2011-2013 Steven Armstrong (steven-cdist at armstrong.cc) +# +# 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 . +# + +name="$__object_id" +state="$(cat "$__object/parameter/state")" +uri="$(cat "$__object/parameter/uri")" + +if [ -f "$__object/parameter/distribution" ]; then + distribution="$(cat "$__object/parameter/distribution")" +else + distribution="$(cat "$__global/explorer/lsb_codename")" +fi +if [ -f "$__object/parameter/component" ]; then + component="$(cat "$__object/parameter/component")" +else + component="" +fi +if [ -f "$__object/parameter/arch" ]; then + forcedarch="[arch=$(cat "$__object/parameter/arch")]" +else + forcedarch="" +fi + +# export variables for use in template +export name +export uri +export distribution +export component +export forcedarch + +# generate file from template +mkdir "$__object/files" +"$__type/files/source.list.template" > "$__object/files/source.list" +__file "/etc/apt/sources.list.d/${name}.list" \ + --source "$__object/files/source.list" \ + --owner root --group root --mode 0644 \ + --state "$state" + +require="$__object_name" __apt_update_index diff --git a/cdist/conf/type/__apt_source/parameter/boolean b/cdist/conf/type/__apt_source/parameter/boolean new file mode 100644 index 00000000..8fa49177 --- /dev/null +++ b/cdist/conf/type/__apt_source/parameter/boolean @@ -0,0 +1 @@ +include-src diff --git a/cdist/conf/type/__apt_source/parameter/default/state b/cdist/conf/type/__apt_source/parameter/default/state new file mode 100644 index 00000000..e7f6134f --- /dev/null +++ b/cdist/conf/type/__apt_source/parameter/default/state @@ -0,0 +1 @@ +present diff --git a/cdist/conf/type/__apt_source/parameter/optional b/cdist/conf/type/__apt_source/parameter/optional new file mode 100644 index 00000000..87537335 --- /dev/null +++ b/cdist/conf/type/__apt_source/parameter/optional @@ -0,0 +1,4 @@ +state +distribution +component +arch \ No newline at end of file diff --git a/cdist/conf/type/__apt_source/parameter/required b/cdist/conf/type/__apt_source/parameter/required new file mode 100644 index 00000000..c7954952 --- /dev/null +++ b/cdist/conf/type/__apt_source/parameter/required @@ -0,0 +1 @@ +uri diff --git a/cdist/conf/type/__ccollect_source/explorer/cksum b/cdist/conf/type/__ccollect_source/explorer/cksum new file mode 100755 index 00000000..335e4e7a --- /dev/null +++ b/cdist/conf/type/__ccollect_source/explorer/cksum @@ -0,0 +1,34 @@ +#!/bin/sh +# +# 2011-2012 Nico Schottelius (nico-cdist at schottelius.org) +# +# This file is part of cdist. +# +# cdist is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# cdist is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with cdist. If not, see . +# +# +# Retrieve the md5sum of a file to be created, if it is already existing. +# + +destination="/$__object_id" + +if [ -e "$destination" ]; then + if [ -f "$destination" ]; then + cksum < "$destination" + else + echo "NO REGULAR FILE" + fi +else + echo "NO FILE FOUND, NO CHECKSUM CALCULATED." +fi diff --git a/cdist/conf/type/__ccollect_source/explorer/stat b/cdist/conf/type/__ccollect_source/explorer/stat new file mode 100755 index 00000000..298221b7 --- /dev/null +++ b/cdist/conf/type/__ccollect_source/explorer/stat @@ -0,0 +1,47 @@ +#!/bin/sh +# +# 2013 Steven Armstrong (steven-cdist armstrong.cc) +# +# 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 . +# + +destination="/$__object_id" + +# nothing to work with, nothing we could do +[ -e "$destination" ] || exit 0 + +os=$("$__explorer/os") +case "$os" in + "freebsd") + # FIXME: should be something like this based on man page, but can not test + stat -f "type: %ST +owner: %Du %Su +group: %Dg %Sg +mode: %Op %Sp +size: %Dz +links: %Dl +" "$destination" + ;; + *) + stat --printf="type: %F +owner: %u %U +group: %g %G +mode: %a %A +size: %s +links: %h +" "$destination" + ;; +esac diff --git a/cdist/conf/type/__ccollect_source/explorer/type b/cdist/conf/type/__ccollect_source/explorer/type new file mode 100755 index 00000000..e723047c --- /dev/null +++ b/cdist/conf/type/__ccollect_source/explorer/type @@ -0,0 +1,33 @@ +#!/bin/sh +# +# 2013 Steven Armstrong (steven-cdist armstrong.cc) +# +# 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 . +# + +destination="/$__object_id" + +if [ ! -e "$destination" ]; then + echo none +elif [ -h "$destination" ]; then + echo symlink +elif [ -f "$destination" ]; then + echo file +elif [ -d "$destination" ]; then + echo directory +else + echo unknown +fi diff --git a/cdist/conf/type/__ccollect_source/gencode-remote b/cdist/conf/type/__ccollect_source/gencode-remote new file mode 100755 index 00000000..c41b5179 --- /dev/null +++ b/cdist/conf/type/__ccollect_source/gencode-remote @@ -0,0 +1,93 @@ +#!/bin/sh +# +# 2014 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 . +# + +destination="/$__object_id" +state_should="$(cat "$__object/parameter/state")" +type="$(cat "$__object/explorer/type")" +stat_file="$__object/explorer/stat" + + +get_current_value() { + if [ -s "$stat_file" ]; then + _name="$1" + _value="$2" + case "$_value" in + [0-9]*) + _index=2 + ;; + *) + _index=3 + ;; + esac + awk '/'"$_name"':/ { print $'$_index' }' "$stat_file" + unset _name _value _index + fi +} + +set_group() { + echo chgrp \"$1\" \"$destination\" + echo chgrp $1 >> "$__messages_out" +} + +set_owner() { + echo chown \"$1\" \"$destination\" + echo chown $1 >> "$__messages_out" +} + +set_mode() { + echo chmod \"$1\" \"$destination\" + echo chmod $1 >> "$__messages_out" +} + +set_attributes= +case "$state_should" in + present|exists) + # Note: Mode - needs to happen last as a chown/chgrp can alter mode by + # clearing S_ISUID and S_ISGID bits (see chown(2)) + for attribute in group owner mode; do + if [ -f "$__object/parameter/$attribute" ]; then + value_should="$(cat "$__object/parameter/$attribute")" + + # change 0xxx format to xxx format => same as stat returns + if [ "$attribute" = mode ]; then + value_should="$(echo $value_should | sed 's/^0\(...\)/\1/')" + fi + + value_is="$(get_current_value "$attribute" "$value_should")" + if [ -f "$__object/files/set-attributes" -o "$value_should" != "$value_is" ]; then + "set_$attribute" "$value_should" + fi + fi + done + + ;; + + absent) + if [ "$type" = "file" ]; then + echo rm -f \"$destination\" + echo remove >> "$__messages_out" + fi + ;; + + *) + echo "Unknown state: $state_should" >&2 + exit 1 + ;; +esac diff --git a/cdist/conf/type/__ccollect_source/man.text b/cdist/conf/type/__ccollect_source/man.text new file mode 100644 index 00000000..32a7467e --- /dev/null +++ b/cdist/conf/type/__ccollect_source/man.text @@ -0,0 +1,64 @@ +cdist-type__ccollect_source(7) +============================== +Nico Schottelius + + +NAME +---- +cdist-type__ccollect_source - Manage ccollect sources + + +DESCRIPTION +----------- +This cdist type allows you to create or delete ccollect sources. + +REQUIRED PARAMETERS +------------------- +source:: + The source from which to backup +destination:: + The destination directory + + +OPTIONAL PARAMETERS +------------------- +state:: + 'present' or 'absent', defaults to 'present' +ccollectconf:: + The CCOLLECT_CONF directory. Defaults to /etc/ccollect. + + +OPTIONAL MULTIPLE PARAMETERS +---------------------------- +exclude:: + Paths to exclude of backup + +BOOLEAN PARAMETERS +------------------ +verbose:: + Whether to report backup verbosely + +EXAMPLES +-------- + +-------------------------------------------------------------------------------- +__ccollect_source doc.ungleich.ch \ + --source doc.ungleich.ch:/ \ + --destination /backup/doc.ungleich.ch \ + --exclude '/proc/*' --exclude '/sys/*' \ + --verbose + +-------------------------------------------------------------------------------- + + +SEE ALSO +-------- +- cdist-type(7) +- ccollect(1) +- http://www.nico.schottelius.org/software/ccollect/ + + +COPYING +------- +Copyright \(C) 2014 Nico Schottelius. Free use of this software is +granted under the terms of the GNU General Public License version 3 (GPLv3). diff --git a/cdist/conf/type/__ccollect_source/manifest b/cdist/conf/type/__ccollect_source/manifest new file mode 100755 index 00000000..89c2ef2b --- /dev/null +++ b/cdist/conf/type/__ccollect_source/manifest @@ -0,0 +1,53 @@ +#!/bin/sh +# +# 2014 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 . +# + +name="$__object_id" +state="$(cat "$__object/parameter/state")" +source="$(cat "$__object/parameter/source")" +destination="$(cat "$__object/parameter/destination")" +ccollectconf="$(cat "$__object/parameter/ccollectconf" | sed 's,/$,,')" + +sourcedir="$ccollectconf/sources" +basedir="$sourcedir/$name" + +destination_file="$basedir/destination" +source_file="$basedir/source" +exclude_file="$basedir/exclude" +verbose_file="$basedir/verbose" + +__directory "$basedir" --state "$state" + +export require="__directory$basedir" +echo "$destination" | __file "$destination_file" --source - --state "$state" +echo "$source" | __file "$source_file" --source - --state "$state" + +################################################################################ +# Booleans +if [ -f "$__object/parameter/verbose" ]; then + verbosestate="present" +else + verbosestate="absent" +fi +__file "$verbose_file" --state "$verbosestate" + +if [ -f "$__object/parameter/exclude" ]; then + __file "$exclude_file" --source - --state "$state" \ + < "$__object/parameter/exclude" +fi diff --git a/cdist/conf/type/__ccollect_source/parameter/boolean b/cdist/conf/type/__ccollect_source/parameter/boolean new file mode 100644 index 00000000..c00ee94a --- /dev/null +++ b/cdist/conf/type/__ccollect_source/parameter/boolean @@ -0,0 +1 @@ +verbose diff --git a/cdist/conf/type/__ccollect_source/parameter/default/ccollectconf b/cdist/conf/type/__ccollect_source/parameter/default/ccollectconf new file mode 100644 index 00000000..a9fda009 --- /dev/null +++ b/cdist/conf/type/__ccollect_source/parameter/default/ccollectconf @@ -0,0 +1 @@ +/etc/ccollect diff --git a/cdist/conf/type/__ccollect_source/parameter/default/state b/cdist/conf/type/__ccollect_source/parameter/default/state new file mode 100644 index 00000000..e7f6134f --- /dev/null +++ b/cdist/conf/type/__ccollect_source/parameter/default/state @@ -0,0 +1 @@ +present diff --git a/cdist/conf/type/__ccollect_source/parameter/optional b/cdist/conf/type/__ccollect_source/parameter/optional new file mode 100644 index 00000000..0249d11e --- /dev/null +++ b/cdist/conf/type/__ccollect_source/parameter/optional @@ -0,0 +1,2 @@ +ccollectconf +state diff --git a/cdist/conf/type/__ccollect_source/parameter/optional_multiple b/cdist/conf/type/__ccollect_source/parameter/optional_multiple new file mode 100644 index 00000000..9ba870ea --- /dev/null +++ b/cdist/conf/type/__ccollect_source/parameter/optional_multiple @@ -0,0 +1 @@ +exclude diff --git a/cdist/conf/type/__ccollect_source/parameter/required b/cdist/conf/type/__ccollect_source/parameter/required new file mode 100644 index 00000000..9239646e --- /dev/null +++ b/cdist/conf/type/__ccollect_source/parameter/required @@ -0,0 +1,2 @@ +source +destination diff --git a/cdist/conf/type/__cdist/manifest b/cdist/conf/type/__cdist/manifest index 44d62f6c..7c0ae60e 100755 --- a/cdist/conf/type/__cdist/manifest +++ b/cdist/conf/type/__cdist/manifest @@ -27,23 +27,11 @@ else shell="" fi -if [ -f "$__object/parameter/username" ]; then - username="$(cat "$__object/parameter/username")" -else - username="cdist" -fi +username="$(cat "$__object/parameter/username")" -if [ -f "$__object/parameter/branch" ]; then - branch="$(cat "$__object/parameter/branch")" -else - branch="master" -fi +branch="$(cat "$__object/parameter/branch")" -if [ -f "$__object/parameter/source" ]; then - source="$(cat "$__object/parameter/source")" -else - source="git://github.com/telmich/cdist.git" -fi +source="$(cat "$__object/parameter/source")" # Currently hardcoded - if anyone cares, make a parameter # out of it diff --git a/cdist/conf/type/__cdist/parameter/default/branch b/cdist/conf/type/__cdist/parameter/default/branch new file mode 100644 index 00000000..1f7391f9 --- /dev/null +++ b/cdist/conf/type/__cdist/parameter/default/branch @@ -0,0 +1 @@ +master diff --git a/cdist/conf/type/__cdist/parameter/default/source b/cdist/conf/type/__cdist/parameter/default/source new file mode 100644 index 00000000..d669308f --- /dev/null +++ b/cdist/conf/type/__cdist/parameter/default/source @@ -0,0 +1 @@ +git://github.com/telmich/cdist.git diff --git a/cdist/conf/type/__cdist/parameter/default/username b/cdist/conf/type/__cdist/parameter/default/username new file mode 100644 index 00000000..a585e141 --- /dev/null +++ b/cdist/conf/type/__cdist/parameter/default/username @@ -0,0 +1 @@ +cdist diff --git a/cdist/conf/type/__debconf_set_selections/gencode-remote b/cdist/conf/type/__debconf_set_selections/gencode-remote index 62be6a12..bb719c46 100755 --- a/cdist/conf/type/__debconf_set_selections/gencode-remote +++ b/cdist/conf/type/__debconf_set_selections/gencode-remote @@ -1,6 +1,6 @@ #!/bin/sh # -# 2011 Nico Schottelius (nico-cdist at schottelius.org) +# 2011-2014 Nico Schottelius (nico-cdist at schottelius.org) # # This file is part of cdist. # @@ -21,6 +21,12 @@ # Setup selections # +filename="$(cat "$__object/parameter/file")" + +if [ "$filename" = "-" ]; then + filename="$__object/stdin" +fi + echo "debconf-set-selections << __file-eof" -cat "$(cat "$__object/parameter/file")" +cat "$filename" echo "__file-eof" diff --git a/cdist/conf/type/__debconf_set_selections/man.text b/cdist/conf/type/__debconf_set_selections/man.text index f1e13a8e..e36ebaa3 100644 --- a/cdist/conf/type/__debconf_set_selections/man.text +++ b/cdist/conf/type/__debconf_set_selections/man.text @@ -18,6 +18,7 @@ REQUIRED PARAMETERS ------------------- file:: Use the given filename as input for debconf-set-selections(1) + If filename is "-", read from stdin. EXAMPLES @@ -29,6 +30,10 @@ __debconf_set_selections nslcd --file /path/to/file # Setup configuration for nslcd from another type __debconf_set_selections nslcd --file "$__type/files/preseed/nslcd" + +__debconf_set_selections nslcd --file - << eof +gitolite gitolite/gituser string git +eof -------------------------------------------------------------------------------- @@ -41,5 +46,5 @@ SEE ALSO COPYING ------- -Copyright \(C) 2011-2013 Nico Schottelius. Free use of this software is +Copyright \(C) 2011-2014 Nico Schottelius. Free use of this software is granted under the terms of the GNU General Public License version 3 (GPLv3). diff --git a/cdist/conf/type/__hostname/explorer/has_hostnamectl b/cdist/conf/type/__hostname/explorer/has_hostnamectl new file mode 100755 index 00000000..9040023d --- /dev/null +++ b/cdist/conf/type/__hostname/explorer/has_hostnamectl @@ -0,0 +1,24 @@ +#!/bin/sh +# +# 2014 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 system has hostnamectl +# + +command -v hostnamectl || true diff --git a/cdist/conf/type/__hostname/explorer/hostname_file b/cdist/conf/type/__hostname/explorer/hostname_file new file mode 100755 index 00000000..ed28c8a8 --- /dev/null +++ b/cdist/conf/type/__hostname/explorer/hostname_file @@ -0,0 +1,26 @@ +#!/bin/sh +# +# 2014 Nico Schottelius (nico-cdist at schottelius.org) +# +# This file is part of cdist. +# +# cdist is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# cdist is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with cdist. If not, see . +# +# +# Retrieve the contents of /etc/hostname +# + +if [ -f /etc/hostname ]; then + cat /etc/hostname +fi diff --git a/cdist/conf/type/__hostname/gencode-remote b/cdist/conf/type/__hostname/gencode-remote new file mode 100755 index 00000000..3d208cbe --- /dev/null +++ b/cdist/conf/type/__hostname/gencode-remote @@ -0,0 +1,50 @@ +#!/bin/sh +# +# 2014 Steven Armstrong (steven-cdist at armstrong.cc) +# 2014 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 . +# + +if [ -f "$__object/parameter/name" ]; then + name_should="$(cat "$__object/parameter/name")" +else + name_should="$(echo "${__target_host%%.*}")" +fi + +os=$(cat "$__global/explorer/os") +name_running=$(cat "$__global/explorer/hostname") +name_config=$(cat "$__object/explorer/hostname_file") +has_hostnamectl=$(cat "$__object/explorer/has_hostnamectl") + +################################################################################ +# If everything is ok -> exit +# +if [ "$name_config" = "$name_should" -a "$name_running" = "$name_should" ]; then + exit 0 +fi + +################################################################################ +# Setup hostname +# +echo changed >> "$__messages_out" + +if [ "$has_hostnamectl" ]; then + echo "hostnamectl set-hostname '$name_should'" +else + echo "hostname '$name_should'" + echo "printf '%s\n' '$name_should' > /etc/hostname" +fi diff --git a/cdist/conf/type/__hostname/man.text b/cdist/conf/type/__hostname/man.text new file mode 100644 index 00000000..ac44d426 --- /dev/null +++ b/cdist/conf/type/__hostname/man.text @@ -0,0 +1,52 @@ +cdist-type__hostname(7) +======================= +Steven Armstrong + + +NAME +---- +cdist-type__hostname - set the hostname + + +DESCRIPTION +----------- +Set's the hostname on various operating systems. + + +REQUIRED PARAMETERS +------------------- +None. + +OPTIONAL PARAMETERS +------------------- +name:: + The hostname to set. Defaults to the first segment of __target_host + (${__target_host%%.*}) + + +MESSAGES +-------- +changed:: + Changed the hostname + +EXAMPLES +-------- + +-------------------------------------------------------------------------------- +# take hostname from __target_host +__hostname + +# set hostname explicitly +__hostname --name some-static-hostname +-------------------------------------------------------------------------------- + + +SEE ALSO +-------- +- cdist-type(7) + + +COPYING +------- +Copyright \(C) 2012 Steven Armstrong. Free use of this software is +granted under the terms of the GNU General Public License version 3 (GPLv3). diff --git a/cdist/conf/type/__ssh_authorized_keys/explorer/entry b/cdist/conf/type/__hostname/manifest similarity index 51% rename from cdist/conf/type/__ssh_authorized_keys/explorer/entry rename to cdist/conf/type/__hostname/manifest index 9992d32d..0544a6f9 100755 --- a/cdist/conf/type/__ssh_authorized_keys/explorer/entry +++ b/cdist/conf/type/__hostname/manifest @@ -1,6 +1,7 @@ #!/bin/sh # # 2012 Steven Armstrong (steven-cdist at armstrong.cc) +# 2014 Nico Schottelius (nico-cdist at schottelius.org) # # This file is part of cdist. # @@ -18,28 +19,20 @@ # along with cdist. If not, see . # -owner="$(cat "$__object/parameter/owner" 2>/dev/null || echo "$__object_id")" -if [ -f "$__object/parameter/file" ]; then - file="$(cat "$__object/parameter/file")" -else - home="$("$__type_explorer/passwd" | cut -d':' -f 6)" - file="$home/.ssh/authorized_keys" -fi +os=$(cat "$__global/explorer/os") -# no authorized_keys file, nothing we could do -[ -f "$file" ] || exit 0 +not_supported() { + echo "Your operating system ($os) is currently not supported by this type (${__type##*/})." >&2 + echo "Please contribute an implementation for it if you can." >&2 + exit 1 +} -# NOTE: keep variables in sync in manifest/explorer/gencode-* -prefix="#cdist:$__object_name" -suffix="#/cdist:$__object_name" -awk -v prefix="$prefix" -v suffix="$suffix" '{ - if (index($0,prefix)) { - triggered=1 - } - if (triggered) { - if (index($0,suffix)) { - triggered=0 - } - print - } -}' "$file" +case "$os" in + archlinux|debian|ubuntu) + # handled in gencode-remote + : + ;; + *) + not_supported + ;; +esac diff --git a/cdist/conf/type/__hostname/parameter/optional b/cdist/conf/type/__hostname/parameter/optional new file mode 100644 index 00000000..f121bdbf --- /dev/null +++ b/cdist/conf/type/__hostname/parameter/optional @@ -0,0 +1 @@ +name diff --git a/cdist/conf/type/__hostname/singleton b/cdist/conf/type/__hostname/singleton new file mode 100644 index 00000000..e69de29b diff --git a/cdist/conf/type/__jail/gencode-local b/cdist/conf/type/__jail/gencode-local index 075a6ef1..d6384156 100755 --- a/cdist/conf/type/__jail/gencode-local +++ b/cdist/conf/type/__jail/gencode-local @@ -23,7 +23,7 @@ # if [ -f "$__object/parameter/jaildir" ]; then - jaildir="$(cat "$__object/parameter/name")" + jaildir="$(cat "$__object/parameter/jaildir")" else jaildir="/usr/jail" fi diff --git a/cdist/conf/type/__jail/gencode-remote b/cdist/conf/type/__jail/gencode-remote index b044e4b0..afbb81a5 100755 --- a/cdist/conf/type/__jail/gencode-remote +++ b/cdist/conf/type/__jail/gencode-remote @@ -85,7 +85,7 @@ if [ -f "$__object/parameter/onboot" ]; then fi if [ -f "$__object/parameter/jaildir" ]; then - jaildir="$(cat "$__object/parameter/name")" + jaildir="$(cat "$__object/parameter/jaildir")" else jaildir="/usr/jail" fi diff --git a/cdist/conf/type/__jail/manifest b/cdist/conf/type/__jail/manifest index 0570d62d..cf5b7938 100755 --- a/cdist/conf/type/__jail/manifest +++ b/cdist/conf/type/__jail/manifest @@ -34,7 +34,7 @@ if [ ! "$os" = "freebsd" ]; then fi if [ -f "$__object/parameter/jaildir" ]; then - jaildir="$(cat "$__object/parameter/name")" + jaildir="$(cat "$__object/parameter/jaildir")" else jaildir="/usr/jail" fi diff --git a/cdist/conf/type/__key_value/gencode-remote b/cdist/conf/type/__key_value/gencode-remote index ec91894f..b79d9688 100755 --- a/cdist/conf/type/__key_value/gencode-remote +++ b/cdist/conf/type/__key_value/gencode-remote @@ -21,8 +21,8 @@ key="$__object_id" [ -f "$__object/parameter/key" ] && key="$(cat "$__object/parameter/key")" -state_should=present -[ -f "$__object/parameter/state" ] && state_should="$(cat "$__object/parameter/state")" + +state_should="$(cat "$__object/parameter/state")" file="$(cat "$__object/parameter/file")" delimiter="$(cat "$__object/parameter/delimiter")" diff --git a/cdist/conf/type/__key_value/manifest b/cdist/conf/type/__key_value/manifest index 8ed9cc9c..56f4c874 100755 --- a/cdist/conf/type/__key_value/manifest +++ b/cdist/conf/type/__key_value/manifest @@ -19,8 +19,7 @@ # along with cdist. If not, see . # -state_should=present -[ -f "$__object/parameter/state" ] && state_should="$(cat "$__object/parameter/state")" +state_should="$(cat "$__object/parameter/state")" if [ "$state_should" = "present" -a ! -f "$__object/parameter/value" ]; then echo "Missing required parameter 'value'" >&2 diff --git a/cdist/conf/type/__key_value/parameter/default/state b/cdist/conf/type/__key_value/parameter/default/state new file mode 100644 index 00000000..e7f6134f --- /dev/null +++ b/cdist/conf/type/__key_value/parameter/default/state @@ -0,0 +1 @@ +present diff --git a/cdist/conf/type/__line/gencode-remote b/cdist/conf/type/__line/gencode-remote index d4796965..1fadf454 100755 --- a/cdist/conf/type/__line/gencode-remote +++ b/cdist/conf/type/__line/gencode-remote @@ -58,7 +58,7 @@ case "$state_should" in # Only replace ' with '"'"' and keep \ as they are line_sanitised=$(cat "$__object/parameter/line" | sed -e "s/'/'\"'\"'/g") - echo "printf '%s\n' '$line_sanitised' >> $file" + printf '%s' "printf '%s\n' '$line_sanitised' >> $file" ;; absent) diff --git a/cdist/conf/type/__mount/manifest b/cdist/conf/type/__mount/manifest index ff891bb8..8a1fa234 100755 --- a/cdist/conf/type/__mount/manifest +++ b/cdist/conf/type/__mount/manifest @@ -26,9 +26,9 @@ if [ ! -f "$__object/parameter/nofstab" ]; then ( printf "%s" "$(cat "$__object/parameter/device")" printf " %s" "$path" -type="$(cat "$__object/parameter/type" || echo "auto")" +type="$(cat "$__object/parameter/type" 2>/dev/null || echo "auto")" printf " %s" "$type" -options="$(cat "$__object/parameter/options" || echo "defaults")" +options="$(cat "$__object/parameter/options" 2>/dev/null || echo "defaults")" printf " %s" "$options" printf " %s" "$(cat "$__object/parameter/dump")" printf " %s\n" "$(cat "$__object/parameter/pass")" diff --git a/cdist/conf/type/__process/gencode-remote b/cdist/conf/type/__process/gencode-remote index 41bc5381..639940d9 100755 --- a/cdist/conf/type/__process/gencode-remote +++ b/cdist/conf/type/__process/gencode-remote @@ -1,6 +1,7 @@ #!/bin/sh # # 2011-2012 Nico Schottelius (nico-cdist at schottelius.org) +# 2014 Steven Armstrong (steven-cdist at armstrong.cc) # # This file is part of cdist. # @@ -17,7 +18,6 @@ # You should have received a copy of the GNU General Public License # along with cdist. If not, see . # -# if [ -f "$__object/parameter/name" ]; then name="$(cat "$__object/parameter/name")" @@ -25,21 +25,18 @@ else name="$__object_id" fi -parameter_state="$__object/parameter/state" -if [ -f "$_parameter_state" ]; then - state_should=$(cat "$__object/parameter/state") -else - state_should="present" -fi +state_should="$(cat "$__object/parameter/state")" -runs="$(cat "$__object/explorer/runs")" -if [ "$runs" ]; then +if [ -s "$__object/explorer/runs" ]; then state_is="present" else state_is="absent" fi -[ "$state_is" = "$state_should" ] && exit 0 +if [ "$state_is" = "$state_should" ]; then + # nothing to do + exit 0 +fi case "$state_should" in present) diff --git a/cdist/conf/type/__process/parameter/default/state b/cdist/conf/type/__process/parameter/default/state new file mode 100644 index 00000000..e7f6134f --- /dev/null +++ b/cdist/conf/type/__process/parameter/default/state @@ -0,0 +1 @@ +present diff --git a/cdist/conf/type/__qemu_img/gencode-remote b/cdist/conf/type/__qemu_img/gencode-remote index 2a76cf8f..6e4bb4d0 100644 --- a/cdist/conf/type/__qemu_img/gencode-remote +++ b/cdist/conf/type/__qemu_img/gencode-remote @@ -2,8 +2,7 @@ # State: absent is handled by manifest - we need only to do stuff if image is # not existing and state != absent # -state="present" -[ -f "$__object/parameter/state" ] && state="$(cat "$__object/parameter/state")" +state="$(cat "$__object/parameter/state")" [ "$state" = "absent" ] && exit 0 exists="$(cat "$__object/explorer/exists")" @@ -13,8 +12,7 @@ exists="$(cat "$__object/explorer/exists")" # Still there? Create image # -format=qcow2 -[ -f "$__object/parameter/format" ] && format="$(cat "$__object/parameter/format")" +format="$(cat "$__object/parameter/format")" size="$(cat "$__object/parameter/size")" diskimage="/$__object_id" diff --git a/cdist/conf/type/__qemu_img/manifest b/cdist/conf/type/__qemu_img/manifest index b835301d..6d50037f 100644 --- a/cdist/conf/type/__qemu_img/manifest +++ b/cdist/conf/type/__qemu_img/manifest @@ -2,10 +2,8 @@ # Default settings # -format=qcow2 -state=present -[ -f "$__object/parameter/format" ] && format="$(cat "$__object/parameter/format")" -[ -f "$__object/parameter/state" ] && state="$(cat "$__object/parameter/state")" +format="$(cat "$__object/parameter/format")" +state="$(cat "$__object/parameter/state")" diskimage="/$__object_id" diff --git a/cdist/conf/type/__qemu_img/parameter/default/format b/cdist/conf/type/__qemu_img/parameter/default/format new file mode 100644 index 00000000..e0a90ab9 --- /dev/null +++ b/cdist/conf/type/__qemu_img/parameter/default/format @@ -0,0 +1 @@ +qcow2 diff --git a/cdist/conf/type/__qemu_img/parameter/default/state b/cdist/conf/type/__qemu_img/parameter/default/state new file mode 100644 index 00000000..e7f6134f --- /dev/null +++ b/cdist/conf/type/__qemu_img/parameter/default/state @@ -0,0 +1 @@ +present diff --git a/cdist/conf/type/__qemu_img/parameter/optional b/cdist/conf/type/__qemu_img/parameter/optional index 0e8469e7..71b9a32b 100644 --- a/cdist/conf/type/__qemu_img/parameter/optional +++ b/cdist/conf/type/__qemu_img/parameter/optional @@ -1 +1,2 @@ format +state diff --git a/cdist/conf/type/__ssh_authorized_keys/gencode-remote b/cdist/conf/type/__ssh_authorized_keys/gencode-remote deleted file mode 100755 index 7fcb59c6..00000000 --- a/cdist/conf/type/__ssh_authorized_keys/gencode-remote +++ /dev/null @@ -1,84 +0,0 @@ -#!/bin/sh -# -# 2012-2013 Steven Armstrong (steven-cdist at armstrong.cc) -# -# 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 . -# - -owner="$(cat "$__object/parameter/owner" 2>/dev/null || echo "$__object_id")" -if [ -f "$__object/parameter/file" ]; then - file="$(cat "$__object/parameter/file")" -else - home="$(cut -d':' -f 6 "$__object/explorer/passwd")" - file="$home/.ssh/authorized_keys" -fi - -entry="$__object/files/entry" -if [ ! -s "$__object/explorer/entry" ]; then - state_is='absent' -else - state_is=$(diff -q "$entry" "$__object/explorer/entry" >/dev/null \ - && echo present \ - || echo changed - ) -fi - -state_should="$(cat "$__object/parameter/state" 2>/dev/null || echo present)" -if [ "$state_should" = "$state_is" ]; then - # Nothing to do, move along - exit 0 -fi - -remove_entry() { - # NOTE: keep variables in sync in manifest/explorer/gencode-* - prefix="#cdist:$__object_name" - suffix="#/cdist:$__object_name" - cat << DONE -tmpfile=\$(mktemp ${file}.cdist.XXXXXXXXXX) -# preserve ownership and permissions by copying existing file over tmpfile -cp -p "$file" "\$tmpfile" -awk -v prefix="$prefix" -v suffix="$suffix" ' -{ - if (index(\$0,prefix)) { - triggered=1 - } - if (triggered) { - if (index(\$0,suffix)) { - triggered=0 - } - } else { - print - } -}' "$file" > "\$tmpfile" -mv -f "\$tmpfile" "$file" -DONE -} - -case "$state_should" in - present) - if [ "$state_is" = "changed" ]; then - remove_entry - fi - cat << DONE -cat >> "$file" << ${__type##*/}_DONE -$(cat "$entry") -${__type##*/}_DONE -DONE - ;; - absent) - remove_entry - ;; -esac diff --git a/cdist/conf/type/__ssh_authorized_keys/manifest b/cdist/conf/type/__ssh_authorized_keys/manifest index 47cdf746..5a9cfbb3 100755 --- a/cdist/conf/type/__ssh_authorized_keys/manifest +++ b/cdist/conf/type/__ssh_authorized_keys/manifest @@ -19,7 +19,7 @@ # owner="$(cat "$__object/parameter/owner" 2>/dev/null || echo "$__object_id")" -state="$(cat "$__object/parameter/state" 2>/dev/null || echo "present")" +state="$(cat "$__object/parameter/state" 2>/dev/null)" if [ -f "$__object/parameter/file" ]; then file="$(cat "$__object/parameter/file")" else @@ -39,7 +39,7 @@ if [ ! -f "$__object/parameter/noparent" -o ! -f "$__object/parameter/nofile" ]; fi if [ ! -f "$__object/parameter/noparent" ]; then - # Ensure that the directory in which the authorized_keys shall be exists and + # Ensure that the directory in which the authorized_keys shall be exists and # has the right permissions. ssh_directory="${file%/*}" __directory "$ssh_directory" --state present --parents \ @@ -56,19 +56,16 @@ if [ ! -f "$__object/parameter/noparent" -o ! -f "$__object/parameter/nofile" ]; fi fi -# NOTE: keep variables in sync in manifest/explorer/gencode-* -prefix="#cdist:$__object_name" -suffix="#/cdist:$__object_name" - -mkdir "$__object/files" - # Generate entry for inclusion in authorized_keys file -entry="$__object/files/entry" -echo "$prefix" > "$entry" +( if [ -f "$__object/parameter/comment" ]; then - echo "# $(cat "$__object/parameter/comment")" >> "$entry" + echo "# $(cat "$__object/parameter/comment")" fi -cat "$__object/parameter/key" >> "$entry" -# ensure we have a newline after keys -echo >> "$entry" -echo "$suffix" >> "$entry" +cat "$__object/parameter/key" +) | \ +__block "$__object_name" \ + --file "$file" \ + --prefix "#cdist:$__object_name" \ + --suffix "#/cdist:$__object_name" \ + --state "$state" \ + --text - diff --git a/cdist/conf/type/__ssh_authorized_keys/parameter/default/state b/cdist/conf/type/__ssh_authorized_keys/parameter/default/state new file mode 100644 index 00000000..e7f6134f --- /dev/null +++ b/cdist/conf/type/__ssh_authorized_keys/parameter/default/state @@ -0,0 +1 @@ +present diff --git a/cdist/conf/type/__zypper_repo/gencode-remote b/cdist/conf/type/__zypper_repo/gencode-remote index 4d834c47..f678552b 100644 --- a/cdist/conf/type/__zypper_repo/gencode-remote +++ b/cdist/conf/type/__zypper_repo/gencode-remote @@ -45,11 +45,7 @@ else id="$__object_id" fi -if [ -f "$__object/parameter/state" ]; then - state="$(cat "$__object/parameter/state")" -else - state="present" -fi +state="$(cat "$__object/parameter/state")" repo_id="$(cat "$__object/explorer/repo_id")" diff --git a/cdist/conf/type/__zypper_service/gencode-remote b/cdist/conf/type/__zypper_service/gencode-remote index d11749ae..df8d1660 100644 --- a/cdist/conf/type/__zypper_service/gencode-remote +++ b/cdist/conf/type/__zypper_service/gencode-remote @@ -39,17 +39,8 @@ else uri="$__object_id" fi -if [ -f "$__object/parameter/state" ]; then - state_should="$(cat "$__object/parameter/state")" -else - state_should="present" -fi - -if [ -f "$__object/parameter/type" ]; then - stype="$(cat "$__object/parameter/type")" -else - stype="ris" -fi +state_should="$(cat "$__object/parameter/state")" +stype="$(cat "$__object/parameter/type")" exp_uri="$(cat "$__object/explorer/service_uri")" exp_id="$(cat "$__object/explorer/service_id")" diff --git a/cdist/conf/type/__zypper_service/manifest b/cdist/conf/type/__zypper_service/manifest index d8773605..aa4a39a3 100644 --- a/cdist/conf/type/__zypper_service/manifest +++ b/cdist/conf/type/__zypper_service/manifest @@ -33,11 +33,7 @@ else uri="$__object_id" fi -if [ -f "$__object/parameter/state" ]; then - state_should="$(cat "$__object/parameter/state")" -else - state_should="present" -fi +state_should="$(cat "$__object/parameter/state")" exp_uri="$(cat "$__object/explorer/service_uri")" diff --git a/cdist/config.py b/cdist/config.py index 3f8a7fc6..73ba4710 100644 --- a/cdist/config.py +++ b/cdist/config.py @@ -163,7 +163,11 @@ class Config(object): """Short name for object list retrieval""" for cdist_object in core.CdistObject.list_objects(self.local.object_path, self.local.type_path): - yield cdist_object + if cdist_object.cdist_type.is_install: + self.log.debug("Running in config mode, ignoring install object: {0}".format(cdist_object)) + else: + yield cdist_object + def iterate_once(self): """ diff --git a/cdist/core/cdist_object.py b/cdist/core/cdist_object.py index 45b5e3ff..b17bd339 100644 --- a/cdist/core/cdist_object.py +++ b/cdist/core/cdist_object.py @@ -2,6 +2,7 @@ # # 2011 Steven Armstrong (steven-cdist at armstrong.cc) # 2011-2013 Nico Schottelius (nico-cdist at schottelius.org) +# 2014 Daniel Heule (hda at sfs.biz) # # This file is part of cdist. # @@ -211,13 +212,13 @@ class CdistObject(object): """Checks wether this cdist object exists on the file systems.""" return os.path.exists(self.absolute_path) - def create(self): + def create(self, allow_overwrite=False): """Create this cdist object on the filesystem. """ try: - os.makedirs(self.absolute_path, exist_ok=False) + os.makedirs(self.absolute_path, exist_ok=allow_overwrite) absolute_parameter_path = os.path.join(self.base_path, self.parameter_path) - os.makedirs(absolute_parameter_path, exist_ok=False) + os.makedirs(absolute_parameter_path, exist_ok=allow_overwrite) except EnvironmentError as error: raise cdist.Error('Error creating directories for cdist object: %s: %s' % (self, error)) diff --git a/cdist/core/cdist_type.py b/cdist/core/cdist_type.py index 46e126f9..ff1ebaec 100644 --- a/cdist/core/cdist_type.py +++ b/cdist/core/cdist_type.py @@ -101,6 +101,11 @@ class CdistType(object): """Check whether a type is a singleton.""" return os.path.isfile(os.path.join(self.absolute_path, "singleton")) + @property + def is_install(self): + """Check whether a type is used for installation (if not: for configuration)""" + return os.path.isfile(os.path.join(self.absolute_path, "install")) + @property def explorers(self): """Return a list of available explorers""" diff --git a/cdist/emulator.py b/cdist/emulator.py index eeb441aa..2c3c12a4 100644 --- a/cdist/emulator.py +++ b/cdist/emulator.py @@ -2,6 +2,7 @@ # # 2011-2013 Nico Schottelius (nico-cdist at schottelius.org) # 2012 Steven Armstrong (steven-cdist at armstrong.cc) +# 2014 Daniel Heule (hda at sfs.biz) # # This file is part of cdist. # @@ -145,13 +146,17 @@ class Emulator(object): if value is not None: self.parameters[key] = value - if self.cdist_object.exists: + if self.cdist_object.exists and not 'CDIST_ALLOW_OVERRIDE' in os.environ: if self.cdist_object.parameters != self.parameters: raise cdist.Error("Object %s already exists with conflicting parameters:\n%s: %s\n%s: %s" % (self.cdist_object.name, " ".join(self.cdist_object.source), self.cdist_object.parameters, self.object_source, self.parameters) ) else: - self.cdist_object.create() + if self.cdist_object.exists: + self.log.debug('Object %s override forced with CDIST_ALLOW_OVERRIDE',self.cdist_object.name) + self.cdist_object.create(True) + else: + self.cdist_object.create() self.cdist_object.parameters = self.parameters # record the created object in typeorder file with open(self.typeorder_path, 'a') as typeorderfile: @@ -214,9 +219,11 @@ class Emulator(object): try: cdist_object = self.cdist_object.object_from_name(requirement) except core.cdist_type.NoSuchTypeError as e: - self.log.error("%s requires object %s, but type %s does not exist (definded at %s)" % (self.cdist_object.name, requirement, e.name, self.object_source)) + self.log.error("%s requires object %s, but type %s does not exist. Defined at %s" % (self.cdist_object.name, requirement, e.name, self.object_source)) + raise + except core.cdist_object.MissingObjectIdError as e: + self.log.error("%s requires object %s without object id. Defined at %s" % (self.cdist_object.name, requirement, self.object_source)) raise - self.log.debug("Recording requirement: %s", requirement) diff --git a/cdist/exec/local.py b/cdist/exec/local.py index 4233b874..2f75ffd4 100644 --- a/cdist/exec/local.py +++ b/cdist/exec/local.py @@ -188,7 +188,7 @@ class Local(object): Return the output as a string. """ - command = ["/bin/sh", "-e"] + command = [ os.environ.get('CDIST_LOCAL_SHELL',"/bin/sh") , "-e"] command.append(script) return self.run(command=command, env=env, return_output=return_output, message_prefix=message_prefix) diff --git a/cdist/exec/remote.py b/cdist/exec/remote.py index 7c807092..9b7d5d1c 100644 --- a/cdist/exec/remote.py +++ b/cdist/exec/remote.py @@ -113,7 +113,7 @@ class Remote(object): """ - command = ["/bin/sh", "-e"] + command = [ os.environ.get('CDIST_REMOTE_SHELL',"/bin/sh") , "-e"] command.append(script) return self.run(command, env, return_output) diff --git a/cdist/shell.py b/cdist/shell.py index ebf9f434..8ca68115 100644 --- a/cdist/shell.py +++ b/cdist/shell.py @@ -45,10 +45,7 @@ class Shell(object): """Select shell to execute, if not specified by user""" if not self.shell: - if 'SHELL' in os.environ: - self.shell = os.environ['SHELL'] - else: - self.shell = "/bin/sh" + self.shell = os.environ.get('SHELL',"/bin/sh") def _init_files_dirs(self): self.local.create_files_dirs() diff --git a/docs/changelog b/docs/changelog index a12de32a..9c222384 100644 --- a/docs/changelog +++ b/docs/changelog @@ -4,11 +4,48 @@ Changelog * Changes are always commented with their author in (braces) * Exception: No braces means author == Nico Schottelius -3.0.2: + +3.0.6: + * New Type: __apt_key (Steven Armstrong) + * New Type: __apt_key_uri (Steven Armstrong) + * New Type: __apt_norecommends (Steven Armstrong) + * New Type: __apt_source (Steven Armstrong) + + +3.0.5: 2014-02-05 + * Core: Introduce override concept (Daniel Heule) + * Type __process: Make --state absent work (Steven Armstrong) + * Documentation: Update documentation for environment variables + + +3.0.4: 2014-01-29 + * Core: Ignore install types in config mode + * Documentation: Update reference (files path in object space) + * Documentation: Update best practise: Replaces templates/ with files/ + * Type __apt_ppa: Install required software (Steven Armstrong) + * Type __debconf_set_selections: Support --file - to read from stdin + * Type __jail: Fix jaildir parameter handling (Jake Guffey) + + +3.0.3: 2014-01-22 + * Core: Enhance error message when requirement is missing object id + * Core: Add environment variable to select shell for executing scripts (Daniel Heule) + * Explorer hostname: Return host name by using uname -n + * New Type: __hostname (Steven Armstrong) + * Type __cdist: Use default paremeters (Daniel Heule) + * Type __key_value: Use default paremeters (Daniel Heule) + * Type __line: Use printf instead of echo for printing user input + * Type __qemu_img: Use default paremeters (Daniel Heule) + * Type __zypper_repo: Use default paremeters (Daniel Heule) + * Type __zypper_service: Use default paremeters (Daniel Heule) + + +3.0.2: 2014-01-19 * Documentation: Document all messages sent by types (Daniel Heule) * New Type: __block (Steven Armstrong) * New Type: __mount (Steven Armstrong) * Type __cron: Replace existing entry when changing it (Daniel Heule) + * Type __ssh_authorized_keys: Use new type __block (Steven Armstrong) 3.0.1: 2014-01-14 diff --git a/docs/dev/logs/2014-01-20.environments b/docs/dev/logs/2014-01-20.environments new file mode 100644 index 00000000..88fe42b9 --- /dev/null +++ b/docs/dev/logs/2014-01-20.environments @@ -0,0 +1,44 @@ +raw quote from irc + +16:00 < sar> telmich: btw, ich denke nicht dass man install schon zu gross bewerben + sollte +16:00 < telmich> sar: ack +16:00 < sar> telmich: imho sollten wir erst die cdist environments implementieren, + install waere dann eines davon +16:00 < sar> config ein anderes +16:01 < sar> foobar noch ein anderes +16:01 < sar> es macht einfach keinen sinn auf type ebene install vs nicht-install zu + unterscheiden +16:02 < telmich> sar: environments sind bei mir noch nicht ganz im gehirn (ganicht?) + angelangt - hast du (nochmal?) kurz eine idee, was du damit meinst? +16:02 < sar> telmich: wenn man cdist anschaut, dann macht es eigentlich folgendes: +16:03 < sar> - definiere objekte mit hilfe von types +16:03 < sar> - deps zwischen objekten +16:03 < sar> - queue von objekten abarbeiten und auf $etwas anwenden +16:03 < sar> das ist alles +16:04 < sar> telmich: das ist eigentlich ziemlich generisch +16:04 < sar> telmich: fuer mich wuerde es sich hier anbieten das auch so zu + abstrahieren +16:05 < sar> telmich: ein environment (nenn das mal so weil kein besserer name zzt) + koennte das wie $objekt auf $etwas bestimmen +16:05 < sar> telmich: und auch was fuer types es in diesem environment gibt +16:06 < telmich> sar: klingt gut +16:06 < sar> telmich: e.g. es gibt ein environment fuer config -> was wir jetzt haben +16:06 < sar> eins fuer install -> += was im install branch ist (nur die types), den + python code brauchts nacher nicht mehr +16:07 < sar> eins fuer cisco-switch -> hat types um mit cisco zu spielen +16:07 < sar> usw +16:07 < sar> ein environment hat auch eigene remote-{exec,copy} scripte +16:08 < sar> und vielleicht globale explorer, vielleicht auch nicht +16:08 < sar> ein enviroment ist ein cconfig style directory +16:09 < sar> wo man cdist drueber laufen laesst +16:09 < sar> so was in der art +16:13 < telmich> sar: hmmja...klingt gut +16:15 < telmich> vielleicht etwas für cdist 4 oder cdist 5 :-) +16:15 < telmich> aber ich denke auf jeden fall als grundgedanke behaltbar +16:16 < telmich> ok für dich, wenn ich den chat ins docs/dev/logs kopiere als + erinnerungs +16:16 < telmich> s/s$/?/? +16:16 < telmich> s/?$// +16:20 < sar> klar + diff --git a/docs/gfx/cdist-logo-1024-scaled.png b/docs/gfx/cdist-logo-1024-scaled.png new file mode 100644 index 00000000..4be8d4c9 Binary files /dev/null and b/docs/gfx/cdist-logo-1024-scaled.png differ diff --git a/docs/man/cdist-reference.text.sh b/docs/man/cdist-reference.text.sh index a72452eb..5de59eab 100755 --- a/docs/man/cdist-reference.text.sh +++ b/docs/man/cdist-reference.text.sh @@ -131,7 +131,8 @@ confdir/type//explorer:: confdir/type//files:: This directory is reserved for user data and will not be used - by cdist at any time + by cdist at any time. It can be used for storing supplementary + files (like scripts to act as a template or configuration files). out/:: This directory contains output of cdist and is usually located @@ -175,13 +176,22 @@ OBJECTS For object to object communication and tests, the following paths are usable within a object directory: +files:: + This directory is reserved for user data and will not be used + by cdist at any time. It can be used freely by the type + (for instance to store template results). changed:: This empty file exists in an object directory, if the object has code to be excuted (either remote or local) +stdin:: + This file exists and contains data, if data was provided on stdin + when the type was called. -ENVIRONMENT VARIABLES ---------------------- +ENVIRONMENT VARIABLES (FOR READING) +----------------------------------- +The following environment variables are exported by cdist: + __explorer:: Directory that contains all global explorers. Available for: initial manifest, explorer, type explorer, shell @@ -219,6 +229,15 @@ __type_explorer:: Directory that contains the type explorers. Available for: type explorer +ENVIRONMENT VARIABLES (FOR WRITING) +----------------------------------- +The following environment variables influence the behaviour of cdist: + +require:: + Setup dependencies between objects (see cdist-manifest(7)) + +CDIST_ALLOW_OVERRIDE:: + Allow overwriting type parameters (see cdist-manifest(7)) SEE ALSO -------- diff --git a/docs/man/man1/cdist.text b/docs/man/man1/cdist.text index de50a4ce..e8c12991 100644 --- a/docs/man/man1/cdist.text +++ b/docs/man/man1/cdist.text @@ -127,10 +127,16 @@ usage: __git --source SOURCE [--state STATE] [--branch BRANCH] ENVIRONMENT ----------- TMPDIR, TEMP, TMP:: - Setup the base directory for the temporary directory. - See http://docs.python.org/py3k/library/tempfile.html for - more information. This is rather useful, if the standard - directory used does not allow executables. + Setup the base directory for the temporary directory. + See http://docs.python.org/py3k/library/tempfile.html for + more information. This is rather useful, if the standard + directory used does not allow executables. + +CDIST_LOCAL_SHELL:: + Selects shell for local script execution, defaults to /bin/sh + +CDIST_REMOTE_SHELL:: + Selects shell for remote scirpt execution, defaults to /bin/sh EXIT STATUS diff --git a/docs/man/man7/cdist-best-practice.text b/docs/man/man7/cdist-best-practice.text index e6685cad..a818be60 100644 --- a/docs/man/man7/cdist-best-practice.text +++ b/docs/man/man7/cdist-best-practice.text @@ -164,8 +164,8 @@ For more details consult sudoers(5) TEMPLATING ---------- -* create directory templates/ in your type (convention) -* create the template as an executable file like templates/basic.conf.sh, it will output text using shell variables for the values +* create directory files/ in your type (convention) +* create the template as an executable file like files/basic.conf.sh, it will output text using shell variables for the values -------------------------------------------------------------------------------- #!/bin/sh @@ -191,7 +191,7 @@ EOF export ROOT='/var/www/test' # render the template mkdir -p "$__object/files" - "$__type/templates/basic.conf.sh" > "$__object/files/basic.conf" + "$__type/files/basic.conf.sh" > "$__object/files/basic.conf" # send the rendered template __file /etc/nginx/sites-available/test.conf \ --state present diff --git a/docs/man/man7/cdist-manifest.text b/docs/man/man7/cdist-manifest.text index d2f5ba05..8ae8f966 100644 --- a/docs/man/man7/cdist-manifest.text +++ b/docs/man/man7/cdist-manifest.text @@ -128,6 +128,19 @@ All objects that are created in a type manifest are automatically required from the type that is calling them. This is called "autorequirement" in cdist jargon. +OVERRIDES +--------- +In some special cases, you would like to create an already defined object +with different parameters. In normal situations this leads to an error in cdist. +If you whish, you can setup the environment variable CDIST_ALLOW_OVERRIDE +(any value or even empty is ok) to tell cdist, that this object override is +wanted and should be accepted. +ATTENTION: Only use this feature if you are 100% sure in which order +cdist encounter the affected objects, otherwhise this results +into an undefined situation. + +THIS IS A BETA FEATURE AND MAY BE REMOVED AT ANY TIME. + EXECUTE_TYPES_IN_CREATION_ORDER is a EXPERIMENTAL FEATURE ! You can tell cdist to execute all types in the order in which they are created @@ -189,6 +202,26 @@ __package lighttpd --state present require="__package/lighttpd" __package munin --state present -------------------------------------------------------------------------------- +How to override objects: + +-------------------------------------------------------------------------------- +# for example in the inital manifest + +# reate user account foobar with some hash for password +__user foobar --password 'some_fancy_hash' --home /home/foobarexample + +# ... many statements and includes in the manifest later ... +# somewhere in a conditionaly sourced manifest +# (e.g. for example only sourced if a special application is on the target host) + +# this leads to an error ... +__user foobar --password 'some_other_hash' + +# this tells cdist, that you know that this is an override and should be accepted +CDIST_ALLOW_OVERRIDE=yes __user foobar --password 'some_other_hash' +# its only an override, means the parameter --home is not touched +# and stay at the original value of /home/foobarexample +-------------------------------------------------------------------------------- SEE ALSO