diff --git a/.gitignore b/.gitignore index 2a193c2a..3bbc4e99 100644 --- a/.gitignore +++ b/.gitignore @@ -9,7 +9,7 @@ docs/man/man*/*.html docs/man/man*/*.xml docs/man/man*/docbook-xsl.css docs/man/man7/cdist-type__*.rst -docs/man/man7/cdist-reference.rst +docs/man/cdist-reference.rst # Ignore cdist cache for version control /cache/ @@ -20,8 +20,9 @@ MANIFEST dist/ cdist/version.py -#sphinx build dir +# sphinx build dirs, cache _build/ +docs/dist # Packaging: Archlinux /PKGBUILD diff --git a/Makefile b/Makefile index e584fc63..9d494f23 100644 --- a/Makefile +++ b/Makefile @@ -46,7 +46,8 @@ MAN7DSTDIR=$(MANDIR)/man7 # Manpages #1: Types # Use shell / ls to get complete list - $(TYPEDIR)/*/man.rst does not work -MANTYPESRC=$(shell ls $(TYPEDIR)/*/man.rst) +# Using ls does not work if no file with given pattern exist, so use wildcard +MANTYPESRC=$(wildcard $(TYPEDIR)/*/man.rst) MANTYPEPREFIX=$(subst $(TYPEDIR)/,$(MAN7DSTDIR)/cdist-type,$(MANTYPESRC)) MANTYPES=$(subst /man.rst,.rst,$(MANTYPEPREFIX)) @@ -62,17 +63,17 @@ $(MANREF): $(MANREFSH) $(MANREFSH) # Manpages #3: generic part -mansphinxman: $(MANTYPES) $(MANREF) +mansphinxman: $(MANTYPES) $(MANREF) $(PYTHON_VERSION) $(SPHINXM) -mansphinxhtml: $(MANTYPES) $(MANREF) +mansphinxhtml: $(MANTYPES) $(MANREF) $(PYTHON_VERSION) $(SPHINXH) man: mansphinxman mansphinxhtml # Manpages #5: release part MANWEBDIR=$(WEBBASE)/man/$(CHANGELOG_VERSION) -MANBUILDDIR=$(MANDIR)/_build/html +MANBUILDDIR=docs/dist/html man-dist: man rm -rf "${MANWEBDIR}" @@ -88,6 +89,25 @@ man-latest-link: web-pub ssh staticweb.ungleich.ch \ "cd /home/services/www/nico/nico.schottelius.org/www/software/cdist/man/ && rm -f latest && ln -sf "$(CHANGELOG_VERSION)" latest" +# Manpages: .cdist Types +DOT_CDIST_PATH=${HOME}/.cdist +DOTMAN7DSTDIR=$(MAN7DSTDIR) +DOTTYPEDIR=$(DOT_CDIST_PATH)/type +DOTMANTYPESRC=$(wildcard $(DOTTYPEDIR)/*/man.rst) +DOTMANTYPEPREFIX=$(subst $(DOTTYPEDIR)/,$(DOTMAN7DSTDIR)/cdist-type,$(DOTMANTYPESRC)) +DOTMANTYPES=$(subst /man.rst,.rst,$(DOTMANTYPEPREFIX)) + +# Link manpage: do not create man.html but correct named file +$(DOTMAN7DSTDIR)/cdist-type%.rst: $(DOTTYPEDIR)/%/man.rst + ln -sf "$^" $@ + +# Manpages #3: generic part +dotmansphinxman: $(DOTMANTYPES) + $(SPHINXM) + +dotman: dotmansphinxman + + ################################################################################ # Speeches # @@ -192,7 +212,7 @@ release: # clean: - rm -f $(MAN7DSTDIR)/cdist-reference.rst + rm -f $(MANDIR)/cdist-reference.rst find "$(MANDIR)" -mindepth 2 -type l \ | xargs rm -f diff --git a/bin/build-helper.freebsd b/bin/build-helper.freebsd new file mode 100755 index 00000000..da8170e1 --- /dev/null +++ b/bin/build-helper.freebsd @@ -0,0 +1,344 @@ +#!/bin/sh +# +# 2011-2013 Nico Schottelius (nico-cdist at schottelius.org) +# 2016 Darko Poljak (darko.poljak at gmail.com) +# +# 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 . +# +# +# This file contains the heavy lifting found usually in the Makefile +# + +# vars for make +helper=$0 + +basedir=${0%/*}/../ +# run_as is used to check how the script is called (by $0 value) +# currently supported sufixes for $0 are: +# .freebsd - run as freebsd +basename=${0##*/} +run_as=${basename#*.} +case "$run_as" in + freebsd) + to_a=cdist-configuration-management + to_d=googlegroups.com + from_a=darko.poljak + from_d=gmail.com + ml_name="Darko Poljak" + ml_sig_name="Darko" + + # vars for make + WEBDIR=../vcs/www.nico.schottelius.org + ;; + *) + to_a=cdist + to_d=l.schottelius.org + from_a=nico-cdist + from_d=schottelius.org + ml_name="Nico -telmich- Schottelius" + ml_sig_name="Nico" + + # vars for make + WEBDIR=$$HOME/vcs/www.nico.schottelius.org + ;; +esac + +# Change to checkout directory +cd "$basedir" + +version=$(git describe) + +option=$1; shift + +case "$option" in + print-make-vars) + printf "helper: ${helper}\n" + printf "WEBDIR: ${WEBDIR}\n" + ;; + print-runas) + printf "run_as: $run_as\n" + ;; + changelog-changes) + if [ "$#" -eq 1 ]; then + start=$1 + else + start="[[:digit:]]" + fi + + end="[[:digit:]]" + + awk -F: "BEGIN { start=0 } + { + if(start == 0) { + if (\$0 ~ /^$start/) { + start = 1 + } + } else { + if (\$0 ~ /^$end/) { + exit + } else { + print \$0 + } + } + }" "$basedir/docs/changelog" + ;; + + changelog-version) + # get version from changelog + grep '^[[:digit:]]' "$basedir/docs/changelog" | head -n1 | sed 's/:.*//' + ;; + + check-date) + # verify date in changelog is today + date_today="$(date +%Y-%m-%d)" + date_changelog=$(grep '^[[:digit:]]' "$basedir/docs/changelog" | head -n1 | sed 's/.*: //') + + if [ "$date_today" != "$date_changelog" ]; then + echo "Date in changelog is not today" + echo "Changelog: $date_changelog" + exit 1 + fi + ;; + + check-unittest) + "$0" test + ;; + + blog) + version=$1; shift + blogfile=$1; shift + dir=${blogfile%/*} + file=${blogfile##*/} + + + cat << eof > "$blogfile" +[[!meta title="Cdist $version released"]] + +Here's a short overview about the changes found in version ${version}: + +eof + + $0 changelog-changes "$version" >> "$blogfile" + + cat << eof >> "$blogfile" +For more information visit the [[cdist homepage|software/cdist]]. + +[[!tag cdist config unix]] +eof + cd "$dir" + git add "$file" + # Allow git commit to fail if there are no changes + git commit -m "cdist blog update: $version" "$blogfile" || true + ;; + + ml-release) + if [ $# -ne 1 ]; then + echo "$0 ml-release version" >&2 + exit 1 + fi + + version=$1; shift + + to=${to_a}@${to_d} + from=${from_a}@${from_d} + + ( + cat << eof +From: ${ml_name} <$from> +To: cdist mailing list <$to> +Subject: cdist $version released + +Hello .*, + +cdist $version has been released with the following changes: + +eof + + "$0" changelog-changes "$version" + cat << eof + +Cheers, + +${ml_sig_name} + +-- +Automatisation at its best level. With cdist. +eof + ) | /usr/sbin/sendmail -f "$from" "$to" + ;; + + release-git-tag) + target_version=$($0 changelog-version) + if git rev-parse --verify refs/tags/$target_version 2>/dev/null; then + echo "Tag for $target_version exists, aborting" + exit 1 + fi + printf "Enter tag description for ${target_version}: " + read tagmessage + git tag "$target_version" -m "$$tagmessage" + ;; + + release) + set -e + target_version=$($0 changelog-version) + target_branch=$($0 version-branch) + + echo "Beginning release process for $target_version" + + # First check everything is sane + "$0" check-date + "$0" check-unittest + + # Generate version file to be included in packaging + "$0" version + + # Ensure the git status is clean, else abort + if ! git diff-index --name-only --exit-code HEAD ; then + echo "Unclean tree, see files above, aborting" + exit 1 + 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" + + echo "Enter the magic word to release anyway" + read magicword + + if [ "$magicword" = "iknowwhatido" ]; then + masterbranch=no + else + exit 1 + fi + 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 + fi + + # Verify that after the merge everything works + "$0" check-date + "$0" check-unittest + + # Generate man pages (indirect check if they build) + make helper=${helper} WEBDIR=${WEBDIR} man + + # Generate speeches (indirect check if they build) + make helper=${helper} WEBDIR=${WEBDIR} speeches + + ############################################################# + # Everything green, let's do the release + + # Tag the current commit + "$0" release-git-tag + + # Also merge back the version branch + if [ "$masterbranch" = yes ]; then + git checkout master + git merge "$target_branch" + fi + + # Publish git changes + case "$run_as" in + freebsd) + # if we are not Nico :) then just push, no mirror + git push + ;; + *) + make helper=${helper} WEBDIR=${WEBDIR} pub + ;; + esac + + # publish man, speeches, website + if [ "$masterbranch" = yes ]; then + make helper=${helper} WEBDIR=${WEBDIR} web-release-all + else + make helper=${helper} WEBDIR=${WEBDIR} web-release-all-no-latest + fi + + # Ensure that pypi release has the right version + "$0" version + + # Create and publish package for pypi + make helper=${helper} WEBDIR=${WEBDIR} pypi-release + + case "$run_as" in + freebsd) + ;; + *) + # Archlinux release is based on pypi + make archlinux-release + ;; + esac + + # Announce change on ML + make helper=${helper} WEBDIR=${WEBDIR} ml-release + + cat << eof +Manual steps post release: + + - linkedin + - hackernews + - reddit + - twitter + +eof + + case "$run_as" in + freebsd) + cat < cdist/version.py + ;; + + *) + echo "Unknown helper target $@ - aborting" + exit 1 + ;; + +esac diff --git a/cdist/__init__.py b/cdist/__init__.py index 4454a3ac..b7436b5a 100644 --- a/cdist/__init__.py +++ b/cdist/__init__.py @@ -41,28 +41,33 @@ BANNER = """ "P' "" "" """ -REMOTE_COPY = "scp -o User=root -q" -REMOTE_EXEC = "ssh -o User=root -q" +REMOTE_COPY = "scp -o User=root" +REMOTE_EXEC = "ssh -o User=root" + class Error(Exception): """Base exception class for this project""" pass + class UnresolvableRequirementsError(cdist.Error): """Resolving requirements failed""" pass + class CdistObjectError(Error): """Something went wrong with an object""" - + def __init__(self, cdist_object, message): self.name = cdist_object.name self.source = " ".join(cdist_object.source) self.message = message - def __str__(self): - return '%s: %s (defined at %s)' % (self.name, self.message, self.source) + return '%s: %s (defined at %s)' % (self.name, + self.message, + self.source) + def file_to_list(filename): """Return list from \n seperated file""" diff --git a/cdist/conf/explorer/machine_type b/cdist/conf/explorer/machine_type index 74789f5a..eb3c9d36 100755 --- a/cdist/conf/explorer/machine_type +++ b/cdist/conf/explorer/machine_type @@ -22,6 +22,17 @@ # FIXME: other system types (not linux ...) +if [ -d "/proc/vz" -a ! -d "/proc/bc" ]; then + echo openvz + exit +fi + +if [ -e "/proc/1/environ" ] && + cat "/proc/1/environ" | tr '\000' '\n' | grep -Eiq '^container='; then + echo lxc + exit +fi + if [ -r /proc/cpuinfo ]; then # this should only exist on virtual guest machines, # tested on vmware, xen, kvm @@ -37,11 +48,12 @@ if [ -r /proc/cpuinfo ]; then if grep -q -i 'vmware' /sys/class/dmi/id/product_name; then echo "virtual_by_vmware" exit - else - if grep -q -i 'bochs' /sys/class/dmi/id/product_name; then - echo "virtual_by_kvm" - exit - fi + elif grep -q -i 'bochs' /sys/class/dmi/id/product_name; then + echo "virtual_by_kvm" + exit + elif grep -q -i 'virtualbox' /sys/class/dmi/id/product_name; then + echo "virtual_by_virtualbox" + exit fi fi fi diff --git a/cdist/conf/explorer/os b/cdist/conf/explorer/os index de1d29c3..550192d4 100755 --- a/cdist/conf/explorer/os +++ b/cdist/conf/explorer/os @@ -72,6 +72,11 @@ if [ -f /etc/owl-release ]; then fi ### Redhat and derivatives +if grep -q ^Scientific /etc/redhat-release 2>/dev/null; then + echo scientific + exit 0 +fi + if grep -q ^CentOS /etc/redhat-release 2>/dev/null; then echo centos exit 0 diff --git a/cdist/conf/explorer/os_version b/cdist/conf/explorer/os_version index 6c7becdc..58f750b0 100755 --- a/cdist/conf/explorer/os_version +++ b/cdist/conf/explorer/os_version @@ -54,7 +54,7 @@ case "$($__explorer/os)" in owl) cat /etc/owl-release ;; - redhat|centos|mitel) + redhat|centos|mitel|scientific) cat /etc/redhat-release ;; slackware) diff --git a/cdist/conf/type/__apt_key/man.rst b/cdist/conf/type/__apt_key/man.rst index 43dc89b1..488a1a06 100644 --- a/cdist/conf/type/__apt_key/man.rst +++ b/cdist/conf/type/__apt_key/man.rst @@ -1,8 +1,9 @@ cdist-type__apt_key(7) ====================== -Manage the list of keys used by apt -Steven Armstrong +NAME +---- +cdist-type__apt_key - Manage the list of keys used by apt DESCRIPTION @@ -47,9 +48,9 @@ EXAMPLES __apt_key UbuntuArchiveKey --keyid 437D05B5 --keyserver keyserver.ubuntu.com -SEE ALSO --------- -- `cdist-type(7) `_ +AUTHORS +------- +Steven Armstrong COPYING diff --git a/cdist/conf/type/__apt_key_uri/man.rst b/cdist/conf/type/__apt_key_uri/man.rst index a235e13a..e8741dff 100644 --- a/cdist/conf/type/__apt_key_uri/man.rst +++ b/cdist/conf/type/__apt_key_uri/man.rst @@ -1,8 +1,9 @@ cdist-type__apt_key_uri(7) ========================== -Add apt key from uri -Steven Armstrong +NAME +---- +cdist-type__apt_key_uri - Add apt key from uri DESCRIPTION @@ -37,9 +38,9 @@ EXAMPLES --state present -SEE ALSO --------- -- `cdist-type(7) `_ +AUTHORS +------- +Steven Armstrong COPYING diff --git a/cdist/conf/type/__apt_norecommends/man.rst b/cdist/conf/type/__apt_norecommends/man.rst index 232bb166..7ef496c3 100644 --- a/cdist/conf/type/__apt_norecommends/man.rst +++ b/cdist/conf/type/__apt_norecommends/man.rst @@ -1,8 +1,9 @@ cdist-type__apt_norecommends(7) =============================== -Configure apt to not install recommended packages -Steven Armstrong +NAME +---- +cdist-type__apt_norecommends - Configure apt to not install recommended packages DESCRIPTION @@ -28,9 +29,9 @@ EXAMPLES __apt_norecommends -SEE ALSO --------- -- `cdist-type(7) `_ +AUTHORS +------- +Steven Armstrong COPYING diff --git a/cdist/conf/type/__apt_ppa/man.rst b/cdist/conf/type/__apt_ppa/man.rst index e39bd6b2..978e1252 100644 --- a/cdist/conf/type/__apt_ppa/man.rst +++ b/cdist/conf/type/__apt_ppa/man.rst @@ -1,8 +1,9 @@ cdist-type__apt_ppa(7) ====================== -Manage ppa repositories -Steven Armstrong +NAME +---- +cdist-type__apt_ppa - Manage ppa repositories DESCRIPTION @@ -36,9 +37,9 @@ EXAMPLES __apt_ppa ppa:sans-intern/missing-bits --state absent -SEE ALSO --------- -- `cdist-type(7) `_ +AUTHORS +------- +Steven Armstrong COPYING diff --git a/cdist/conf/type/__apt_source/man.rst b/cdist/conf/type/__apt_source/man.rst index 70649c4b..31f2e9e6 100644 --- a/cdist/conf/type/__apt_source/man.rst +++ b/cdist/conf/type/__apt_source/man.rst @@ -1,8 +1,9 @@ cdist-type__apt_source(7) ========================= -Manage apt sources -Steven Armstrong +NAME +---- +cdist-type__apt_source - Manage apt sources DESCRIPTION @@ -55,9 +56,9 @@ EXAMPLES --component partner --state present -SEE ALSO --------- -- `cdist-type(7) `_ +AUTHORS +------- +Steven Armstrong COPYING diff --git a/cdist/conf/type/__apt_update_index/man.rst b/cdist/conf/type/__apt_update_index/man.rst index 2fc66c65..326d4c2f 100644 --- a/cdist/conf/type/__apt_update_index/man.rst +++ b/cdist/conf/type/__apt_update_index/man.rst @@ -1,8 +1,9 @@ cdist-type__apt_update_index(7) =============================== -Update apt's package index -Steven Armstrong +NAME +---- +cdist-type__apt_update_index - Update apt's package index DESCRIPTION @@ -27,9 +28,9 @@ EXAMPLES __apt_update_index -SEE ALSO --------- -- `cdist-type(7) `_ +AUTHORS +------- +Steven Armstrong COPYING diff --git a/cdist/conf/type/__block/man.rst b/cdist/conf/type/__block/man.rst index 4b7d61dc..6d7b8ba1 100644 --- a/cdist/conf/type/__block/man.rst +++ b/cdist/conf/type/__block/man.rst @@ -1,8 +1,9 @@ cdist-type__block(7) ==================== -Manage blocks of text in files -Steven Armstrong +NAME +---- +cdist-type__block - Manage blocks of text in files DESCRIPTION @@ -68,9 +69,9 @@ EXAMPLES DONE -SEE ALSO --------- -- `cdist-type(7) `_ +AUTHORS +------- +Steven Armstrong COPYING diff --git a/cdist/conf/type/__ccollect_source/man.rst b/cdist/conf/type/__ccollect_source/man.rst index 12fb8f42..cdacd31c 100644 --- a/cdist/conf/type/__ccollect_source/man.rst +++ b/cdist/conf/type/__ccollect_source/man.rst @@ -1,8 +1,9 @@ cdist-type__ccollect_source(7) ============================== -Manage ccollect sources -Nico Schottelius +NAME +---- +cdist-type__ccollect_source - Manage ccollect sources DESCRIPTION @@ -52,9 +53,12 @@ EXAMPLES SEE ALSO -------- -- `cdist-type(7) `_ -- ccollect(1) -- http://www.nico.schottelius.org/software/ccollect/ +:manpage:`ccollect`\ (1) + + +AUTHORS +------- +Nico Schottelius COPYING diff --git a/cdist/conf/type/__cdist/man.rst b/cdist/conf/type/__cdist/man.rst index f15d3b73..1bfb35c5 100644 --- a/cdist/conf/type/__cdist/man.rst +++ b/cdist/conf/type/__cdist/man.rst @@ -1,8 +1,9 @@ cdist-type__cdist(7) ==================== -Manage cdist installations -Nico Schottelius +NAME +---- +cdist-type__cdist - Manage cdist installations DESCRIPTION @@ -49,9 +50,9 @@ EXAMPLES __cdist --source "git://git.schottelius.org/cdist" /home/cdist/cdist -SEE ALSO --------- -- `cdist-type(7) `_ +AUTHORS +------- +Nico Schottelius COPYING diff --git a/cdist/conf/type/__cdistmarker/man.rst b/cdist/conf/type/__cdistmarker/man.rst index 22e711b6..cb4dace8 100644 --- a/cdist/conf/type/__cdistmarker/man.rst +++ b/cdist/conf/type/__cdistmarker/man.rst @@ -1,8 +1,9 @@ cdist-type__cdistmarker(7) ========================== -Add a timestamped cdist marker. -Daniel Maher +NAME +---- +cdist-type__cdistmarker - Add a timestamped cdist marker. DESCRIPTION @@ -41,9 +42,9 @@ EXAMPLES __cdistmarker --destination /tmp/cdist_marker --format '+%s' -SEE ALSO --------- -- `cdist-type(7) `_ +AUTHORS +------- +Daniel Maher COPYING diff --git a/cdist/conf/type/__config_file/man.rst b/cdist/conf/type/__config_file/man.rst index 49b63984..b9d58979 100644 --- a/cdist/conf/type/__config_file/man.rst +++ b/cdist/conf/type/__config_file/man.rst @@ -1,8 +1,9 @@ cdist-type__config_file(7) ========================== -Manages config files -Steven Armstrong +NAME +---- +cdist-type__config_file - _Manages config files DESCRIPTION @@ -47,8 +48,12 @@ EXAMPLES SEE ALSO -------- -- `cdist-type(7) `_ -- `cdist-type__file(7) `_ +:manpage:`cdist-type__file`\ (7) + + +AUTHORS +------- +Steven Armstrong COPYING diff --git a/cdist/conf/type/__consul/man.rst b/cdist/conf/type/__consul/man.rst index 77fae852..c15ded45 100644 --- a/cdist/conf/type/__consul/man.rst +++ b/cdist/conf/type/__consul/man.rst @@ -1,8 +1,9 @@ cdist-type__consul(7) ===================== -Install consul -Steven Armstrong +NAME +---- +cdist-type__consul - Install consul DESCRIPTION @@ -40,9 +41,9 @@ EXAMPLES --version 0.4.1 -SEE ALSO --------- -- `cdist-type(7) `_ +AUTHORS +------- +Steven Armstrong COPYING diff --git a/cdist/conf/type/__consul/manifest b/cdist/conf/type/__consul/manifest index 0187d959..b16c5749 100755 --- a/cdist/conf/type/__consul/manifest +++ b/cdist/conf/type/__consul/manifest @@ -23,7 +23,7 @@ os=$(cat "$__global/explorer/os") case "$os" in - centos|redhat|ubuntu|debian|archlinux|gentoo) + scientific|centos|redhat|ubuntu|debian|archlinux|gentoo) # any linux should work : ;; diff --git a/cdist/conf/type/__consul_agent/man.rst b/cdist/conf/type/__consul_agent/man.rst index 8285cb25..5a35a2cc 100644 --- a/cdist/conf/type/__consul_agent/man.rst +++ b/cdist/conf/type/__consul_agent/man.rst @@ -1,8 +1,9 @@ cdist-type__consul_agent(7) =========================== -Manage the consul agent -Steven Armstrong +NAME +---- +cdist-type__consul_agent - Manage the consul agent DESCRIPTION @@ -164,8 +165,12 @@ EXAMPLES SEE ALSO -------- -- `cdist-type(7) `_ -- http://www.consul.io/docs/agent/options.html +consul documentation at: . + + +AUTHORS +------- +Steven Armstrong COPYING diff --git a/cdist/conf/type/__consul_agent/manifest b/cdist/conf/type/__consul_agent/manifest index b4d1d75c..7f180494 100755 --- a/cdist/conf/type/__consul_agent/manifest +++ b/cdist/conf/type/__consul_agent/manifest @@ -23,7 +23,7 @@ os=$(cat "$__global/explorer/os") case "$os" in - centos|debian|redhat|ubuntu) + scientific|centos|debian|redhat|ubuntu) # whitelist safeguard : ;; diff --git a/cdist/conf/type/__consul_check/man.rst b/cdist/conf/type/__consul_check/man.rst index e12d9ca8..ad65d3c5 100644 --- a/cdist/conf/type/__consul_check/man.rst +++ b/cdist/conf/type/__consul_check/man.rst @@ -1,8 +1,9 @@ cdist-type__consul_check(7) ============================= -Manages consul checks -Steven Armstrong +NAME +---- +cdist-type__consul_check - Manages consul checks DESCRIPTION @@ -85,8 +86,12 @@ EXAMPLES SEE ALSO -------- -- `cdist-type(7) `_ -- `cdist-type__consul_agent(7) `_ +:manpage:`cdist-type__consul_agent`\ (7) + + +AUTHORS +------- +Steven Armstrong COPYING diff --git a/cdist/conf/type/__consul_reload/man.rst b/cdist/conf/type/__consul_reload/man.rst index f66bb545..410bd5e6 100644 --- a/cdist/conf/type/__consul_reload/man.rst +++ b/cdist/conf/type/__consul_reload/man.rst @@ -1,8 +1,9 @@ cdist-type__consul_reload(7) ============================ -Reload consul -Steven Armstrong +NAME +---- +cdist-type__consul_reload - Reload consul DESCRIPTION @@ -28,9 +29,9 @@ EXAMPLES __consul_reload -SEE ALSO --------- -- `cdist-type(7) `_ +AUTHORS +------- +Steven Armstrong COPYING diff --git a/cdist/conf/type/__consul_service/man.rst b/cdist/conf/type/__consul_service/man.rst index 9a8efaab..75b06aa0 100644 --- a/cdist/conf/type/__consul_service/man.rst +++ b/cdist/conf/type/__consul_service/man.rst @@ -1,8 +1,9 @@ cdist-type__consul_service(7) ============================= -Manages consul services -Steven Armstrong +NAME +---- +cdist-type__consul_service - Manages consul services DESCRIPTION @@ -65,8 +66,12 @@ EXAMPLES SEE ALSO -------- -- `cdist-type(7) `_ -- `cdist-type__consul_agent(7) `_ +:manpage:`cdist-type__consul_agent`\ (7) + + +AUTHORS +------- +Steven Armstrong COPYING diff --git a/cdist/conf/type/__consul_template/man.rst b/cdist/conf/type/__consul_template/man.rst index bcdb94e3..a6228cad 100644 --- a/cdist/conf/type/__consul_template/man.rst +++ b/cdist/conf/type/__consul_template/man.rst @@ -1,8 +1,9 @@ cdist-type__consul_template(7) ============================== -Manage the consul-template service -Steven Armstrong +NAME +---- +cdist-type__consul_template - Manage the consul-template service DESCRIPTION @@ -124,8 +125,12 @@ EXAMPLES SEE ALSO -------- -- `cdist-type(7) `_ -- https://github.com/hashicorp/consul-template +consul documentation at: . + + +AUTHORS +------- +Steven Armstrong COPYING diff --git a/cdist/conf/type/__consul_template/manifest b/cdist/conf/type/__consul_template/manifest index 83d2aae4..fd249185 100755 --- a/cdist/conf/type/__consul_template/manifest +++ b/cdist/conf/type/__consul_template/manifest @@ -22,7 +22,7 @@ os=$(cat "$__global/explorer/os") case "$os" in - centos|redhat) + scientific|centos|redhat) # whitelist safeguard service_onchange='service consul-template status >/dev/null && service consul-template reload || true' \ ;; diff --git a/cdist/conf/type/__consul_template_template/man.rst b/cdist/conf/type/__consul_template_template/man.rst index 6264f696..c450a1e7 100644 --- a/cdist/conf/type/__consul_template_template/man.rst +++ b/cdist/conf/type/__consul_template_template/man.rst @@ -1,8 +1,9 @@ cdist-type__consul_template_template(7) ======================================= -Manage consul-template templates -Steven Armstrong +NAME +---- +cdist-type__consul_template_template - Manage consul-template templates DESCRIPTION @@ -67,9 +68,12 @@ EXAMPLES SEE ALSO -------- -- `cdist-type(7) `_ -- `cdist-type__consul_template(7) `_ -- `cdist-type__consul_template_config(7) `_ +:manpage:`cdist-type__consul_template`\ (7), :manpage:`cdist-type__consul_template_config`\ (7) + + +AUTHORS +------- +Steven Armstrong COPYING diff --git a/cdist/conf/type/__consul_watch_checks/man.rst b/cdist/conf/type/__consul_watch_checks/man.rst index c1e8c0a7..ec04b0b3 100644 --- a/cdist/conf/type/__consul_watch_checks/man.rst +++ b/cdist/conf/type/__consul_watch_checks/man.rst @@ -1,8 +1,9 @@ cdist-type__consul_watch_checks(7) ================================== -Manages consul checks watches -Steven Armstrong +NAME +---- +cdist-type__consul_watch_checks - Manages consul checks watches DESCRIPTION @@ -54,9 +55,14 @@ EXAMPLES SEE ALSO -------- -- `cdist-type(7) `_ -- `cdist-type__consul_agent(7) `_ -- http://www.consul.io/docs/agent/watches.html +:manpage:`cdist-type__consul_agent`\ (7) + +consul documentation at: . + + +AUTHORS +------- +Steven Armstrong COPYING diff --git a/cdist/conf/type/__consul_watch_event/man.rst b/cdist/conf/type/__consul_watch_event/man.rst index ea9bc61a..664a19a2 100644 --- a/cdist/conf/type/__consul_watch_event/man.rst +++ b/cdist/conf/type/__consul_watch_event/man.rst @@ -1,8 +1,9 @@ cdist-type__consul_watch_event(7) ================================= -Manages consul event watches -Steven Armstrong +NAME +---- +cdist-type__consul_watch_event - Manages consul event watches DESCRIPTION @@ -47,9 +48,14 @@ EXAMPLES SEE ALSO -------- -- `cdist-type(7) `_ -- `cdist-type__consul_agent(7) `_ -- http://www.consul.io/docs/agent/watches.html +:manpage:`cdist-type__consul_agent`\ (7) + +consul documentation at: . + + +AUTHORS +------- +Steven Armstrong COPYING diff --git a/cdist/conf/type/__consul_watch_key/man.rst b/cdist/conf/type/__consul_watch_key/man.rst index 90e952b8..0f90245c 100644 --- a/cdist/conf/type/__consul_watch_key/man.rst +++ b/cdist/conf/type/__consul_watch_key/man.rst @@ -1,8 +1,9 @@ cdist-type__consul_watch_key(7) =============================== -Manages consul key watches -Steven Armstrong +NAME +---- +cdist-type__consul_watch_key - Manages consul key watches DESCRIPTION @@ -44,9 +45,14 @@ EXAMPLES SEE ALSO -------- -- `cdist-type(7) `_ -- `cdist-type__consul_agent(7) `_ -- http://www.consul.io/docs/agent/watches.html +:manpage:`cdist-type__consul_agent`\ (7) + +consul documentation at: . + + +AUTHORS +------- +Steven Armstrong COPYING diff --git a/cdist/conf/type/__consul_watch_keyprefix/man.rst b/cdist/conf/type/__consul_watch_keyprefix/man.rst index 8ee5822d..65fa16af 100644 --- a/cdist/conf/type/__consul_watch_keyprefix/man.rst +++ b/cdist/conf/type/__consul_watch_keyprefix/man.rst @@ -1,8 +1,9 @@ cdist-type__consul_watch_keyprefix(7) ===================================== -Manages consul keyprefix watches -Steven Armstrong +NAME +---- +cdist-type__consul_watch_keyprefix - Manages consul keyprefix watches DESCRIPTION @@ -44,9 +45,14 @@ EXAMPLES SEE ALSO -------- -- `cdist-type(7) `_ -- `cdist-type__consul_agent(7) `_ -- http://www.consul.io/docs/agent/watches.html +:manpage:`cdist-type__consul_agent`\ (7) + +consul documentation at: . + + +AUTHORS +------- +Steven Armstrong COPYING diff --git a/cdist/conf/type/__consul_watch_nodes/man.rst b/cdist/conf/type/__consul_watch_nodes/man.rst index b5f0a5ce..5a5bdbd2 100644 --- a/cdist/conf/type/__consul_watch_nodes/man.rst +++ b/cdist/conf/type/__consul_watch_nodes/man.rst @@ -1,8 +1,9 @@ cdist-type__consul_watch_nodes(7) ================================= -Manages consul nodes watches -Steven Armstrong +NAME +---- +cdist-type__consul_watch_nodes - Manages consul nodes watches DESCRIPTION @@ -40,9 +41,14 @@ EXAMPLES SEE ALSO -------- -- `cdist-type(7) `_ -- `cdist-type__consul_agent(7) `_ -- http://www.consul.io/docs/agent/watches.html +:manpage:`cdist-type__consul_agent`\ (7) + +consul documentation at: . + + +AUTHORS +------- +Steven Armstrong COPYING diff --git a/cdist/conf/type/__consul_watch_service/man.rst b/cdist/conf/type/__consul_watch_service/man.rst index 1cc2c00d..38ee501a 100644 --- a/cdist/conf/type/__consul_watch_service/man.rst +++ b/cdist/conf/type/__consul_watch_service/man.rst @@ -1,8 +1,9 @@ cdist-type__consul_watch_service(7) =================================== -Manages consul service watches -Steven Armstrong +NAME +---- +cdist-type__consul_watch_service - Manages consul service watches DESCRIPTION @@ -64,9 +65,14 @@ EXAMPLES SEE ALSO -------- -- `cdist-type(7) `_ -- `cdist-type__consul_agent(7) `_ -- http://www.consul.io/docs/agent/watches.html +:manpage:`cdist-type__consul_agent`\ (7) + +consul documentation at: . + + +AUTHORS +------- +Steven Armstrong COPYING diff --git a/cdist/conf/type/__consul_watch_services/man.rst b/cdist/conf/type/__consul_watch_services/man.rst index bf766222..41b115ae 100644 --- a/cdist/conf/type/__consul_watch_services/man.rst +++ b/cdist/conf/type/__consul_watch_services/man.rst @@ -1,8 +1,9 @@ cdist-type__consul_watch_services(7) ==================================== -Manages consul services watches -Steven Armstrong +NAME +---- +cdist-type__consul_watch_services - Manages consul services watches DESCRIPTION @@ -40,9 +41,14 @@ EXAMPLES SEE ALSO -------- -- `cdist-type(7) `_ -- `cdist-type__consul_agent(7) `_ -- http://www.consul.io/docs/agent/watches.html +:manpage:`cdist-type__consul_agent`\ (7) + +consul documentation at: . + + +AUTHORS +------- +Steven Armstrong COPYING diff --git a/cdist/conf/type/__cron/man.rst b/cdist/conf/type/__cron/man.rst index 353f6bae..4b9cb83d 100644 --- a/cdist/conf/type/__cron/man.rst +++ b/cdist/conf/type/__cron/man.rst @@ -1,8 +1,9 @@ cdist-type__cron(7) =================== -Installs and manages cron jobs -Steven Armstrong +NAME +---- +cdist-type__cron - Installs and manages cron jobs DESCRIPTION @@ -67,8 +68,12 @@ EXAMPLES SEE ALSO -------- -- `cdist-type(7) `_ -- crontab(5) +:manpage:`crontab`\ (5) + + +AUTHORS +------- +Steven Armstrong COPYING diff --git a/cdist/conf/type/__debconf_set_selections/man.rst b/cdist/conf/type/__debconf_set_selections/man.rst index 37aa65b9..b7e5f901 100644 --- a/cdist/conf/type/__debconf_set_selections/man.rst +++ b/cdist/conf/type/__debconf_set_selections/man.rst @@ -1,8 +1,9 @@ cdist-type__debconf_set_selections(7) ===================================== -Setup debconf selections -Nico Schottelius +NAME +---- +cdist-type__debconf_set_selections - Setup debconf selections DESCRIPTION @@ -36,9 +37,12 @@ EXAMPLES SEE ALSO -------- -- `cdist-type(7) `_ -- `cdist-type__update_alternatives(7) `_ -- debconf-set-selections(1) +:manpage:`debconf-set-selections`\ (1), :manpage:`cdist-type__update_alternatives`\ (7) + + +AUTHORS +------- +Nico Schottelius COPYING diff --git a/cdist/conf/type/__directory/man.rst b/cdist/conf/type/__directory/man.rst index 279763a1..e756b1d6 100644 --- a/cdist/conf/type/__directory/man.rst +++ b/cdist/conf/type/__directory/man.rst @@ -1,8 +1,9 @@ cdist-type__directory(7) ======================== -Manage a directory -Nico Schottelius +NAME +---- +cdist-type__directory - Manage a directory DESCRIPTION @@ -87,9 +88,9 @@ EXAMPLES --owner root --group root --mode 0755 --state present -SEE ALSO --------- -- `cdist-type(7) `_ +AUTHORS +------- +Nico Schottelius COPYING diff --git a/cdist/conf/type/__dog_vdi/man.rst b/cdist/conf/type/__dog_vdi/man.rst index 3e6155a6..65bea479 100644 --- a/cdist/conf/type/__dog_vdi/man.rst +++ b/cdist/conf/type/__dog_vdi/man.rst @@ -1,8 +1,9 @@ cdist-type__dog_vdi(7) ====================== -Manage Sheepdog VM images -Nico Schottelius +NAME +---- +cdist-type__dog_vdi - Manage Sheepdog VM images DESCRIPTION @@ -42,9 +43,12 @@ EXAMPLES SEE ALSO -------- -- `cdist-type(7) `_ -- dog(8) -- qemu(1) +:manpage:`qemu`\ (1), :manpage:`dog`\ (8) + + +AUTHORS +------- +Nico Schottelius COPYING diff --git a/cdist/conf/type/__file/man.rst b/cdist/conf/type/__file/man.rst index 73336581..e21390c7 100644 --- a/cdist/conf/type/__file/man.rst +++ b/cdist/conf/type/__file/man.rst @@ -1,8 +1,9 @@ cdist-type__file(7) =================== -Manage files. -Nico Schottelius +NAME +---- +cdist-type__file - Manage files. DESCRIPTION @@ -98,9 +99,9 @@ EXAMPLES DONE -SEE ALSO --------- -* `cdist-type(7) `_ +AUTHORS +------- +Nico Schottelius COPYING diff --git a/cdist/conf/type/__firewalld_rule/man.rst b/cdist/conf/type/__firewalld_rule/man.rst index d953b3d2..414eb7e9 100644 --- a/cdist/conf/type/__firewalld_rule/man.rst +++ b/cdist/conf/type/__firewalld_rule/man.rst @@ -1,8 +1,9 @@ cdist-type__firewalld_rule(7) ============================= -Configure firewalld rules -Nico Schottelius +NAME +---- +cdist-type__firewalld_rule - Configure firewalld rules DESCRIPTION @@ -64,9 +65,12 @@ EXAMPLES SEE ALSO -------- -- `cdist-type(7) `_ -- `cdist-type__iptables_rule(7) `_ -- firewalld(8) +:manpage:`cdist-type__iptables_rule`\ (7), :manpage:`firewalld`\ (8) + + +AUTHORS +------- +Nico Schottelius COPYING diff --git a/cdist/conf/type/__git/man.rst b/cdist/conf/type/__git/man.rst index 75f6e48b..c1341ec0 100644 --- a/cdist/conf/type/__git/man.rst +++ b/cdist/conf/type/__git/man.rst @@ -1,8 +1,9 @@ cdist-type__git(7) ================== -Get and or keep git repositories up-to-date -Nico Schottelius +NAME +---- +cdist-type__git - Get and or keep git repositories up-to-date DESCRIPTION @@ -46,9 +47,9 @@ EXAMPLES __git /home/nico/cdist --source git://github.com/telmich/cdist.git --branch 2.1 -SEE ALSO --------- -- `cdist-type(7) `_ +AUTHORS +------- +Nico Schottelius COPYING diff --git a/cdist/conf/type/__group/man.rst b/cdist/conf/type/__group/man.rst index 912dd226..daea0909 100644 --- a/cdist/conf/type/__group/man.rst +++ b/cdist/conf/type/__group/man.rst @@ -1,8 +1,9 @@ cdist-type__group(7) ==================== -Manage groups -Steven Armstrong +NAME +---- +cdist-type__group - Manage groups DESCRIPTION @@ -66,9 +67,9 @@ EXAMPLES __group foobar --gid 1234 --password 'crypted-password-string' -SEE ALSO --------- -- `cdist-type(7) `_ +AUTHORS +------- +Steven Armstrong COPYING diff --git a/cdist/conf/type/__hostname/gencode-remote b/cdist/conf/type/__hostname/gencode-remote index 9fac7bf4..c1808de0 100755 --- a/cdist/conf/type/__hostname/gencode-remote +++ b/cdist/conf/type/__hostname/gencode-remote @@ -40,7 +40,7 @@ case "$os" in exit 0 fi ;; - centos) + scientific|centos) if [ "$name_sysconfig" = "$name_should" -a "$name_running" = "$name_should" ]; then exit 0 fi diff --git a/cdist/conf/type/__hostname/man.rst b/cdist/conf/type/__hostname/man.rst index 32d452f7..ea1186bc 100644 --- a/cdist/conf/type/__hostname/man.rst +++ b/cdist/conf/type/__hostname/man.rst @@ -1,8 +1,9 @@ cdist-type__hostname(7) ======================= -Set the hostname -Steven Armstrong +NAME +---- +cdist-type__hostname - Set the hostname DESCRIPTION @@ -38,9 +39,9 @@ EXAMPLES __hostname --name some-static-hostname -SEE ALSO --------- -- `cdist-type(7) `_ +AUTHORS +------- +Steven Armstrong COPYING diff --git a/cdist/conf/type/__hostname/manifest b/cdist/conf/type/__hostname/manifest index 76f962e0..842075e0 100755 --- a/cdist/conf/type/__hostname/manifest +++ b/cdist/conf/type/__hostname/manifest @@ -38,7 +38,7 @@ case "$os" in # handled in gencode-remote : ;; - centos) + scientific|centos) __key_value sysconfig-hostname \ --file /etc/sysconfig/network \ --delimiter '=' \ diff --git a/cdist/conf/type/__iptables_apply/man.rst b/cdist/conf/type/__iptables_apply/man.rst index 40605351..48697f9c 100644 --- a/cdist/conf/type/__iptables_apply/man.rst +++ b/cdist/conf/type/__iptables_apply/man.rst @@ -1,8 +1,9 @@ cdist-type__iptables_apply(7) ============================= -Apply the rules -Nico Schottelius +NAME +---- +cdist-type__iptables_apply - Apply the rules DESCRIPTION @@ -28,9 +29,12 @@ None (__iptables_apply is used by __iptables_rule) SEE ALSO -------- -- `cdist-type(7) `_ -- `cdist-type__iptables_rule(7) `_ -- iptables(8) +:manpage:`cdist-type__iptables_rule`\ (7), :manpage:`iptables`\ (8) + + +AUTHORS +------- +Nico Schottelius COPYING diff --git a/cdist/conf/type/__iptables_rule/man.rst b/cdist/conf/type/__iptables_rule/man.rst index 5ee02f9c..fab6c47a 100644 --- a/cdist/conf/type/__iptables_rule/man.rst +++ b/cdist/conf/type/__iptables_rule/man.rst @@ -1,8 +1,9 @@ cdist-type__iptables_rule(7) ============================ -Deploy iptable rulesets -Nico Schottelius +NAME +---- +cdist-type__iptables_rule - Deploy iptable rulesets DESCRIPTION @@ -49,9 +50,12 @@ EXAMPLES SEE ALSO -------- -- `cdist-type(7) `_ -- `cdist-type__iptables_apply(7) `_ -- iptables(8) +:manpage:`cdist-type__iptables_apply`\ (7), :manpage:`iptables`\ (8) + + +AUTHORS +------- +Nico Schottelius COPYING diff --git a/cdist/conf/type/__issue/man.rst b/cdist/conf/type/__issue/man.rst index 4a6c1f8d..eacd8378 100644 --- a/cdist/conf/type/__issue/man.rst +++ b/cdist/conf/type/__issue/man.rst @@ -1,8 +1,9 @@ cdist-type__issue(7) ==================== -Manage issue -Nico Schottelius +NAME +---- +cdist-type__issue - Manage issue DESCRIPTION @@ -33,9 +34,9 @@ EXAMPLES __issue --source "$__type/files/myfancyissue" -SEE ALSO --------- -- `cdist-type(7) `_ +AUTHORS +------- +Nico Schottelius COPYING diff --git a/cdist/conf/type/__jail/man.rst b/cdist/conf/type/__jail/man.rst index 38ec4f96..756e7660 100644 --- a/cdist/conf/type/__jail/man.rst +++ b/cdist/conf/type/__jail/man.rst @@ -1,13 +1,14 @@ cdist-type__jail(7) =================== -Manage FreeBSD jails -Jake Guffey +NAME +---- +cdist-type__jail - Manage FreeBSD jails DESCRIPTION ----------- -This type is used on FreeBSD to manage jails. +This type is used on FreeBSD to manage jails by calling the appropriate per-version subtype. REQUIRED PARAMETERS @@ -107,10 +108,15 @@ EXAMPLES SEE ALSO -------- -- `cdist-type(7) `_ +:manpage:`jail`\ (8) + + +AUTHORS +------- +Jake Guffey COPYING ------- -Copyright \(C) 2012 Jake Guffey. Free use of this software is +Copyright \(C) 2012,2016 Jake Guffey. 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/__jail/manifest b/cdist/conf/type/__jail/manifest index 2d29e263..6df52c59 100755 --- a/cdist/conf/type/__jail/manifest +++ b/cdist/conf/type/__jail/manifest @@ -37,6 +37,19 @@ jaildir="$(cat "$__object/parameter/jaildir")" __directory ${jaildir} --parents +set -- "$@" "$__object_id" "--state" "$state" +cd "$__object/parameter" +for property in $(ls .); do + set -- "$@" "--$property" "$(cat "$property")" +done + +ver="$(cat "$__global/explorer/os_version")" +if [ -n "$(echo "$ver" | grep '^10\.' )" ]; then # Version is 10.x + __jail_freebsd10 "$@" +else + __jail_freebsd9 "$@" +fi + # Debug #set +x diff --git a/cdist/conf/type/__jail/explorer/basepresent b/cdist/conf/type/__jail_freebsd10/explorer/basepresent similarity index 100% rename from cdist/conf/type/__jail/explorer/basepresent rename to cdist/conf/type/__jail_freebsd10/explorer/basepresent diff --git a/cdist/conf/type/__jail/explorer/present b/cdist/conf/type/__jail_freebsd10/explorer/present similarity index 100% rename from cdist/conf/type/__jail/explorer/present rename to cdist/conf/type/__jail_freebsd10/explorer/present diff --git a/cdist/conf/type/__jail/explorer/status b/cdist/conf/type/__jail_freebsd10/explorer/status similarity index 100% rename from cdist/conf/type/__jail/explorer/status rename to cdist/conf/type/__jail_freebsd10/explorer/status diff --git a/cdist/conf/type/__jail_freebsd10/gencode-local b/cdist/conf/type/__jail_freebsd10/gencode-local new file mode 100755 index 00000000..d4b89730 --- /dev/null +++ b/cdist/conf/type/__jail_freebsd10/gencode-local @@ -0,0 +1,52 @@ +#!/bin/sh +# +# 2012 Jake Guffey (jake.guffey at eprotex.com) +# +# 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 . +# +# +# The __jail type creates, configures, and deletes FreeBSD jails for use as +# virtual machines. +# + +# Debug +#exec >&2 +#set -x + +jaildir="$(cat "$__object/parameter/jaildir")" + +jailbase="$(cat "$__object/parameter/jailbase")" + +state="$(cat "$__object/parameter/state")" + +if [ "$state" = "present" ] && [ -z "$jailbase" ]; then + exec >&2 + echo "jailbase is a REQUIRED parameter when state=present!" + exit 1 +fi + +remotebase="${jaildir}/jailbase.tgz" +basepresent="$(cat "$__object/explorer/basepresent")" + +if [ "$state" = "present" ]; then + if [ "$basepresent" = "NONE" ]; then + echo "$__remote_copy" "${jailbase}" "$__target_host:${remotebase}" + fi # basepresent=NONE +fi # state=present + +# Debug +#set +x + diff --git a/cdist/conf/type/__jail_freebsd10/gencode-remote b/cdist/conf/type/__jail_freebsd10/gencode-remote new file mode 100755 index 00000000..ae68616d --- /dev/null +++ b/cdist/conf/type/__jail_freebsd10/gencode-remote @@ -0,0 +1,362 @@ +#!/bin/sh +# +# 2012,2014,2016 Jake Guffey (jake.guffey at jointheirstm.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 . +# +# +# The __jail_freebsd10 type creates, configures, and deletes FreeBSD +# jails for use as virtual machines on FreeBSD 10.x. +# + +# Debug +#exec >&2 +#set -x + +if [ -f "$__object/parameter/name" ]; then + name="$(cat "$__object/parameter/name")" +else + name="$__object_id" +fi + +state="$(cat "$__object/parameter/state")" + +started="true" +# If the user wants the jail gone, it implies it shouldn't be started. +[ -f "$__object/parameter/stopped" -o "$state" = "absent" ] && started="false" + +if [ -f "$__object/parameter/ip" ]; then + ip="$(cat "$__object/parameter/ip")" +else +# IP is an optional param when $state=absent, but +# when $state=present, it's required. Enforce this. + if [ "$state" = "present" ]; then + exec >&2 + echo "If --state is 'present,' --ip must be given\!" + exit 1 + fi +fi + +if [ -f "$__object/parameter/hostname" ]; then + hostname="$(cat "$__object/parameter/hostname")" +else + hostname="$name" +fi + +if [ -f "$__object/parameter/devfs-disable" ]; then + devfsenable="false" +else + devfsenable="true" +fi + +devfsruleset="$(cat "$__object/parameter/devfs-ruleset")" + +# devfs_ruleset being defined without devfs_enable being true +# is pointless. Treat this as an error. +if [ -n "$devfsruleset" -a "$devfsenable" = "false" ]; then + exec >&2 + echo "Can't have --devfs-ruleset defined with --devfs-disable" + exit 1 +fi + +if [ -f "$__object/parameter/onboot" ]; then + onboot="true" +fi + +jaildir="$(cat "$__object/parameter/jaildir")" + +present="$(cat "$__object/explorer/present")" +#present="$(cat "$__type/explorer/present")" +status="$(cat "$__object/explorer/status")" + +# Handle ip="addr, addr" format +if [ $(expr "${ip}" : ".*, .*") -gt "0" ]; then + SAVE_IFS="$IFS" + IFS=", " + for cur_ip in ${ip}; do + # Just get the last IP address for SSH to listen on + mgmt_ip=$(echo "${ip}" | cut '-d ' -f1) # In case using "ip netmask" format rather than CIDR + done + IFS="$SAVE_IFS" +else + mgmt_ip=$(echo "${ip}" | cut '-d ' -f1) # In case using "ip netmask" format rather than CIDR +fi + +stopJail() { +# Check $status before issuing command + if [ "$status" = "STARTED" ]; then + echo "/etc/rc.d/jail stop ${name}" + echo "stop" >> "$__messages_out" + fi +} + +startJail() { +# Check $status before issuing command + if [ "$status" = "NOTSTART" ]; then + echo "/etc/rc.d/jail start ${name}" + echo "start" >> "$__messages_out" + fi +} + +deleteJail() { +# Unmount the jail's mountpoints if necessary + cat <=1 rw mount is mounted still + for DIR in "${output}"; do + umount -F "/etc/fstab.${name}" "\$(echo "${DIR}" | awk '{print $3}')" + done + fi + output="\$(mount | grep "\/${name} (")" || true + if [ -n "\${output}" ]; then # ro mount is mounted still + umount -F "/etc/fstab.${name}" "\$(echo "${output}" | awk '{print $3}')" + fi +EOF +# Remove the jail's rw mountpoints + echo "rm -rf \"${jaildir}/rw/${name}\"" +# Remove the jail directory + echo "rm -rf \"${jaildir}/${name}\"" +# Remove the jail's fstab + echo "rm -f \"/etc/fstab.${name}\"" +# Remove jail entry from jail.conf + cat <> "$__messages_out" +} + +createJail() { +# Create the jail directory +cat <> "$__messages_out" + +# Create the ro+rw mountpoint entries in fstab +cat </etc/fstab.${name} <>/etc/rc.conf + elif [ ! "\$(echo \$jail_enable | tr '[a-z]' '[A-Z]' | tr -d '"')" = "YES" ]; then # jail_enable="NO" + sed -i '.bak' 's/^jail_enable=.*$/jail_enable="YES"/g' /etc/rc.conf # fix this -^ + rm -f /etc/rc.conf.bak + fi + + jailfile=/etc/jail.conf + jailheader="${name} {" + + jaildata="path=\"${jaildir}/${name}\";" + + if [ "$devfsenable" = "true" ]; then + jaildata="\$jaildata + mount.devfs;" + else + jaildata="\$jaildata + mount.nodevfs;" + fi + + jaildata="\$jaildata + host.hostname=\"${hostname}\"; + ip4.addr=\"${ip}\"; + exec.start=\"/bin/sh /etc/rc\"; + exec.stop=\"/bin/sh /etc/rc.shutdown\"; + exec.consolelog=\"/var/log/jail_${name}_console.log\"; + mount.fstab=\"/etc/fstab.${name}\"; + allow.mount; + exec.clean; + allow.set_hostname=0; + allow.sysvipc=0; + allow.raw_sockets=0;" + + jailtrailer="}" + + if [ "$devfsenable" = "true" ] && [ "${devfsruleset}" = "jailrules" ]; then # The default ruleset is to be used + if [ ! -f /etc/devfs.rules ]; then + touch /etc/devfs.rules + fi + if [ -z "\$(grep '\[jailrules=' /etc/devfs.rules)" ]; then # The default ruleset doesn't exist + # Get the highest-numbered ruleset + highest="\$(sed -n 's/\[.*=\([0-9]*\)\]/\1/pg' /etc/devfs.rules | sort -u | tail -n 1)" || true + # increment by 1 + [ -z "\$highest" ] && highest=10 + let num="\${highest}+1" 2>&1 >/dev/null # Close the FD==fail... + # add default ruleset + cat >>/etc/devfs.rules <>\"\$jailfile\"" + +# Add $name to jail_list if $onboot=yes +if [ "$onboot" = "yes" ]; then + + # first check to see whether jail_enable="YES" exists in rc.conf or not and add it + # if necessary + + cat <> "$__messages_out" +fi + +# Add the normal entries into the jail's rc.conf +cat <"${jaildir}/rw/${name}/etc/rc.conf" +echo sshd_enable=\"YES\" >>"${jaildir}/rw/${name}/etc/rc.conf" +echo sendmail_enable=\"NONE\" >>"${jaildir}/rw/${name}/etc/rc.conf" +echo syslogd_enable=\"YES\" >>"${jaildir}/rw/${name}/etc/rc.conf" +echo syslogd_flags=\"-ss\" >>"${jaildir}/rw/${name}/etc/rc.conf" + +EOF +# Configure SSHd's listening address +cat <= 10.0 to manage jails. + + +REQUIRED PARAMETERS +------------------- +state + Either "present" or "absent", defaults to "present". + +jailbase + The location of the .tgz archive containing the base fs for your jails. + + +OPTIONAL PARAMETERS +------------------- +name + The name of the jail. Default is to use the object_id as the jail name. + +ip + The ifconfig style IP/netmask combination to use for the jail guest. If + the state parameter is "present," this parameter is required. + +hostname + The FQDN to use for the jail guest. Defaults to the name parameter. + +interface + The name of the physical interface on the jail server to bind the jail to. + Defaults to the first interface found in the output of ifconfig -l. + +devfs-ruleset + The name of the devfs ruleset to associate with the jail. Defaults to + "jailrules." This ruleset must be copied to the server via another type. + To use this option, devfs-enable must be "true." + +jaildir + The location on the remote server to use for hosting jail filesystems. + Defaults to /usr/jail. + +BOOLEAN PARAMETERS +------------------ +stopped + Do not start the jail + +devfs-disable + Whether to disallow devfs mounting within the jail + +onboot + Whether to add the jail to rc.conf's jail_list variable. + + +CAVEATS +------- +This type does not currently support modification of jail options. If, for +example a jail needs to have its IP address or netmask changed, the jail must +be removed then re-added with the correct IP address/netmask or the appropriate +modifications to jail.conf need to be made through alternate means. + +MESSAGES +-------- +start + The jail was started +stop + The jail was stopped +create: + The jail was created +delete + The jail was deleted +onboot + The jail was configured to start on boot + +EXAMPLES +-------- + +.. code-block:: sh + + # Create a jail called www + __jail_freebsd10 www --state present --ip "192.168.1.2" --jailbase /my/jail/base.tgz + + # Remove the jail called www + __jail_freebsd10 www --state absent --jailbase /my/jail/base.tgz + + # The jail www should not be started + __jail_freebsd10 www --state present --stopped \ + --ip "192.168.1.2 netmask 255.255.255.0" \ + --jailbase /my/jail/base.tgz + + # Use the name variable explicitly + __jail_freebsd10 thisjail --state present --name www \ + --ip "192.168.1.2" \ + --jailbase /my/jail/base.tgz + + # Go nuts + __jail_freebsd10 lotsofoptions --state present --name testjail \ + --ip "192.168.1.100 netmask 255.255.255.0" \ + --hostname "testjail.example.com" --interface "em0" \ + --onboot --jailbase /my/jail/base.tgz --jaildir /jails + + +SEE ALSO +-------- +:manpage:`jail`\ (8) + + +AUTHORS +------- +Jake Guffey + + +COPYING +------- +Copyright \(C) 2012-2016 Jake Guffey. 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/__jail_freebsd10/parameter/boolean b/cdist/conf/type/__jail_freebsd10/parameter/boolean new file mode 100644 index 00000000..39144f6f --- /dev/null +++ b/cdist/conf/type/__jail_freebsd10/parameter/boolean @@ -0,0 +1,3 @@ +onboot +stopped +devfs-disable diff --git a/cdist/conf/type/__jail_freebsd10/parameter/default/devfs-ruleset b/cdist/conf/type/__jail_freebsd10/parameter/default/devfs-ruleset new file mode 100644 index 00000000..f602aa0a --- /dev/null +++ b/cdist/conf/type/__jail_freebsd10/parameter/default/devfs-ruleset @@ -0,0 +1 @@ +jailrules diff --git a/cdist/conf/type/__jail_freebsd10/parameter/default/jailbase b/cdist/conf/type/__jail_freebsd10/parameter/default/jailbase new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/cdist/conf/type/__jail_freebsd10/parameter/default/jailbase @@ -0,0 +1 @@ + diff --git a/cdist/conf/type/__jail_freebsd10/parameter/default/jaildir b/cdist/conf/type/__jail_freebsd10/parameter/default/jaildir new file mode 100644 index 00000000..ec7d86c6 --- /dev/null +++ b/cdist/conf/type/__jail_freebsd10/parameter/default/jaildir @@ -0,0 +1 @@ +/usr/jail diff --git a/cdist/conf/type/__jail_freebsd10/parameter/default/state b/cdist/conf/type/__jail_freebsd10/parameter/default/state new file mode 100644 index 00000000..e7f6134f --- /dev/null +++ b/cdist/conf/type/__jail_freebsd10/parameter/default/state @@ -0,0 +1 @@ +present diff --git a/cdist/conf/type/__jail_freebsd10/parameter/optional b/cdist/conf/type/__jail_freebsd10/parameter/optional new file mode 100644 index 00000000..b36f0fa5 --- /dev/null +++ b/cdist/conf/type/__jail_freebsd10/parameter/optional @@ -0,0 +1,8 @@ +name +ip +hostname +interface +devfs-ruleset +jaildir +jailbase +state diff --git a/cdist/conf/type/__jail_freebsd9/explorer/basepresent b/cdist/conf/type/__jail_freebsd9/explorer/basepresent new file mode 100755 index 00000000..034128d5 --- /dev/null +++ b/cdist/conf/type/__jail_freebsd9/explorer/basepresent @@ -0,0 +1,54 @@ +#!/bin/sh +# +# 2012 Jake Guffey (jake.guffey at eprotex.com) +# +# 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 . +# +# +# See if the jailbase.tgz or $jaildir/base dir exists +# + +# Debug +#exec >&2 +#set -x + +if [ -f "$__object/parameter/jaildir" ]; then + jaildir="$(cat "$__object/parameter/jaildir")" +else + jaildir="/usr/jail" +fi + +name="base:jailbase.tgz" +out="" + +save_IFS="$IFS" +IFS=":" +for cur in $name; do + if [ -e "${jaildir}/$cur" ]; then + out="${out}:${cur}" + fi +done +IFS="$save_IFS" + +if [ -z "$out" ]; then + echo "NONE" +else + echo "${out}" +fi + +# Debug +#set +x + diff --git a/cdist/conf/type/__jail_freebsd9/explorer/present b/cdist/conf/type/__jail_freebsd9/explorer/present new file mode 100755 index 00000000..ddfb805c --- /dev/null +++ b/cdist/conf/type/__jail_freebsd9/explorer/present @@ -0,0 +1,43 @@ +#!/bin/sh +# +# 2012 Jake Guffey (jake.guffey at eprotex.com) +# +# 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 . +# +# +# See if the requested jail exists +# + +# Debug +#exec >&2 +#set -x + +if [ -f "$__object/parameter/name" ]; then + name="$(cat "$__object/parameter/name")" +else + name=$__object_id +fi + +if [ -f "$__object/parameter/jaildir" ]; then + jaildir="$(cat "$__object/parameter/jaildir")" +else + jaildir="/usr/jail" +fi + +[ -d "${jaildir}/$name" ] && echo "EXISTS" || echo "NOTEXIST" + +#set +x + diff --git a/cdist/conf/type/__jail_freebsd9/explorer/status b/cdist/conf/type/__jail_freebsd9/explorer/status new file mode 100755 index 00000000..1ceba212 --- /dev/null +++ b/cdist/conf/type/__jail_freebsd9/explorer/status @@ -0,0 +1,52 @@ +#!/bin/sh +# +# 2012 Jake Guffey (jake.guffey at eprotex.com) +# +# 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 . +# +# +# See if the requested jail is started +# + +# Debug +#exec >&2 +#set -x + +if [ -f "$__object/parameter/name" ]; then + name="$(cat "$__object/parameter/name")" +else + name="$__object_id" +fi + +if [ -f "$__object/parameter/jaildir" ]; then + jaildir="$(cat "$__object/parameter/jaildir")" +else + jaildir="/usr/jail" +fi +# backslash-escaped $jaildir +sjaildir="$(echo ${jaildir} | sed 's#/#\\/#g')" + +jls_output="$(jls | grep "[ ]${sjaildir}\/${name}\$")" || true + +if [ -n "${jls_output}" ]; then + echo "STARTED" +else + echo "NOTSTART" +fi + +# Debug +#set +x + diff --git a/cdist/conf/type/__jail/gencode-local b/cdist/conf/type/__jail_freebsd9/gencode-local similarity index 100% rename from cdist/conf/type/__jail/gencode-local rename to cdist/conf/type/__jail_freebsd9/gencode-local diff --git a/cdist/conf/type/__jail/gencode-remote b/cdist/conf/type/__jail_freebsd9/gencode-remote similarity index 98% rename from cdist/conf/type/__jail/gencode-remote rename to cdist/conf/type/__jail_freebsd9/gencode-remote index c88f3361..6a4c64de 100755 --- a/cdist/conf/type/__jail/gencode-remote +++ b/cdist/conf/type/__jail_freebsd9/gencode-remote @@ -1,6 +1,6 @@ #!/bin/sh # -# 2012,2014 Jake Guffey (jake.guffey at eprotex.com) +# 2012,2014,2016 Jake Guffey (jake.guffey at jointheirstm.org) # # This file is part of cdist. # @@ -18,8 +18,8 @@ # along with cdist. If not, see . # # -# The __jail type creates, configures, and deletes FreeBSD jails for use as -# virtual machines. +# The __jail_freebsd9 type creates, configures, and deletes FreeBSD jails +# for use as virtual machines on FreeBSD 9.x and before. # # Debug @@ -354,3 +354,4 @@ else # The jail does not currently exist exit 0 fi fi + diff --git a/cdist/conf/type/__jail_freebsd9/man.rst b/cdist/conf/type/__jail_freebsd9/man.rst new file mode 100644 index 00000000..ca526cd0 --- /dev/null +++ b/cdist/conf/type/__jail_freebsd9/man.rst @@ -0,0 +1,122 @@ +cdist-type__jail_freebsd9(7) +============================ + +NAME +---- +cdist-type__jail_freebsd9 - Manage FreeBSD jails + + +DESCRIPTION +----------- +This type is used on FreeBSD <= 9.x to manage jails. + + +REQUIRED PARAMETERS +------------------- +state + Either "present" or "absent", defaults to "present". + +jailbase + The location of the .tgz archive containing the base fs for your jails. + + +OPTIONAL PARAMETERS +------------------- +name + The name of the jail. Default is to use the object_id as the jail name. + +ip + The ifconfig style IP/netmask combination to use for the jail guest. If + the state parameter is "present," this parameter is required. + +hostname + The FQDN to use for the jail guest. Defaults to the name parameter. + +interface + The name of the physical interface on the jail server to bind the jail to. + Defaults to the first interface found in the output of ifconfig -l. + +devfs-ruleset + The name of the devfs ruleset to associate with the jail. Defaults to + "jailrules." This ruleset must be copied to the server via another type. + To use this option, devfs-enable must be "true." + +jaildir + The location on the remote server to use for hosting jail filesystems. + Defaults to /usr/jail. + +BOOLEAN PARAMETERS +------------------ +stopped + Do not start the jail + +devfs-disable + Whether to disallow devfs mounting within the jail + +onboot + Whether to add the jail to rc.conf's jail_list variable. + + +CAVEATS +------- +This type does not currently support modification of jail options. If, for +example a jail needs to have its IP address or netmask changed, the jail must +be removed then re-added with the correct IP address/netmask or the appropriate +line (jail__ip="...") modified within rc.conf through some alternate +means. + +MESSAGES +-------- +start + The jail was started +stop + The jail was stopped +create: + The jail was created +delete + The jail was deleted +onboot + The jail was configured to start on boot + +EXAMPLES +-------- + +.. code-block:: sh + + # Create a jail called www + __jail_freebsd9 www --state present --ip "192.168.1.2" --jailbase /my/jail/base.tgz + + # Remove the jail called www + __jail_freebsd9 www --state absent --jailbase /my/jail/base.tgz + + # The jail www should not be started + __jail_freebsd9 www --state present --stopped \ + --ip "192.168.1.2 netmask 255.255.255.0" \ + --jailbase /my/jail/base.tgz + + # Use the name variable explicitly + __jail_freebsd9 thisjail --state present --name www \ + --ip "192.168.1.2" \ + --jailbase /my/jail/base.tgz + + # Go nuts + __jail_freebsd9 lotsofoptions --state present --name testjail \ + --ip "192.168.1.100 netmask 255.255.255.0" \ + --hostname "testjail.example.com" --interface "em0" \ + --onboot --jailbase /my/jail/base.tgz --jaildir /jails + + +SEE ALSO +-------- +:manpage:`jail`\ (8) + + +AUTHORS +------- +Jake Guffey + + +COPYING +------- +Copyright \(C) 2012-2016 Jake Guffey. 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/__jail_freebsd9/parameter/boolean b/cdist/conf/type/__jail_freebsd9/parameter/boolean new file mode 100644 index 00000000..39144f6f --- /dev/null +++ b/cdist/conf/type/__jail_freebsd9/parameter/boolean @@ -0,0 +1,3 @@ +onboot +stopped +devfs-disable diff --git a/cdist/conf/type/__jail_freebsd9/parameter/default/devfs-ruleset b/cdist/conf/type/__jail_freebsd9/parameter/default/devfs-ruleset new file mode 100644 index 00000000..f602aa0a --- /dev/null +++ b/cdist/conf/type/__jail_freebsd9/parameter/default/devfs-ruleset @@ -0,0 +1 @@ +jailrules diff --git a/cdist/conf/type/__jail_freebsd9/parameter/default/jailbase b/cdist/conf/type/__jail_freebsd9/parameter/default/jailbase new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/cdist/conf/type/__jail_freebsd9/parameter/default/jailbase @@ -0,0 +1 @@ + diff --git a/cdist/conf/type/__jail_freebsd9/parameter/default/jaildir b/cdist/conf/type/__jail_freebsd9/parameter/default/jaildir new file mode 100644 index 00000000..ec7d86c6 --- /dev/null +++ b/cdist/conf/type/__jail_freebsd9/parameter/default/jaildir @@ -0,0 +1 @@ +/usr/jail diff --git a/cdist/conf/type/__jail_freebsd9/parameter/default/state b/cdist/conf/type/__jail_freebsd9/parameter/default/state new file mode 100644 index 00000000..e7f6134f --- /dev/null +++ b/cdist/conf/type/__jail_freebsd9/parameter/default/state @@ -0,0 +1 @@ +present diff --git a/cdist/conf/type/__jail_freebsd9/parameter/optional b/cdist/conf/type/__jail_freebsd9/parameter/optional new file mode 100644 index 00000000..b36f0fa5 --- /dev/null +++ b/cdist/conf/type/__jail_freebsd9/parameter/optional @@ -0,0 +1,8 @@ +name +ip +hostname +interface +devfs-ruleset +jaildir +jailbase +state diff --git a/cdist/conf/type/__key_value/man.rst b/cdist/conf/type/__key_value/man.rst index 4b259c75..80d6aa89 100644 --- a/cdist/conf/type/__key_value/man.rst +++ b/cdist/conf/type/__key_value/man.rst @@ -1,8 +1,9 @@ cdist-type__key_value(7) ======================== -Change property values in files -Steven Armstrong +NAME +---- +cdist-type__key_value - Change property values in files DESCRIPTION @@ -80,9 +81,9 @@ This type try to handle as many values as possible, so it doesn't use regexes. So you need to exactly specify the key and delimiter. Delimiter can be of any lenght. -SEE ALSO --------- -- `cdist-type(7) `_ +AUTHORS +------- +Steven Armstrong COPYING diff --git a/cdist/conf/type/__line/man.rst b/cdist/conf/type/__line/man.rst index f6d71a5a..1f38a974 100644 --- a/cdist/conf/type/__line/man.rst +++ b/cdist/conf/type/__line/man.rst @@ -1,8 +1,9 @@ cdist-type__line(7) =================== -Manage lines in files -Nico Schottelius +NAME +---- +cdist-type__line - Manage lines in files DESCRIPTION @@ -60,8 +61,12 @@ EXAMPLES SEE ALSO -------- -- `cdist-type(7) `_ -- grep(1) +:manpage:`grep`\ (1) + + +AUTHORS +------- +Nico Schottelius COPYING diff --git a/cdist/conf/type/__link/man.rst b/cdist/conf/type/__link/man.rst index 654b097b..4560b1af 100644 --- a/cdist/conf/type/__link/man.rst +++ b/cdist/conf/type/__link/man.rst @@ -1,8 +1,9 @@ cdist-type__link(7) =================== -Manage links (hard and symbolic) -Nico Schottelius +NAME +---- +cdist-type__link - Manage links (hard and symbolic) DESCRIPTION @@ -46,9 +47,9 @@ EXAMPLES __link /opt/plone --state absent -SEE ALSO --------- -- `cdist-type(7) `_ +AUTHORS +------- +Nico Schottelius COPYING diff --git a/cdist/conf/type/__locale/man.rst b/cdist/conf/type/__locale/man.rst index df337739..51ed38df 100644 --- a/cdist/conf/type/__locale/man.rst +++ b/cdist/conf/type/__locale/man.rst @@ -1,8 +1,9 @@ cdist-type__locale(7) ===================== -Configure locales -Nico Schottelius +NAME +---- +cdit-type__locale - Configure locales DESCRIPTION @@ -33,9 +34,12 @@ EXAMPLES SEE ALSO -------- -- locale(1) -- localedef(1) -- `cdist-type(7) `_ +:manpage:`locale`\ (1), :manpage:`localedef`\ (1) + + +AUTHORS +------- +Nico Schottelius COPYING diff --git a/cdist/conf/type/__locale/manifest b/cdist/conf/type/__locale/manifest index c1837ae3..d360e9f3 100644 --- a/cdist/conf/type/__locale/manifest +++ b/cdist/conf/type/__locale/manifest @@ -30,7 +30,7 @@ case "$os" in # Debian needs a seperate package __package locales --state present ;; - archlinux|suse|ubuntu|centos) + archlinux|suse|ubuntu|scientific|centos) : ;; *) diff --git a/cdist/conf/type/__motd/man.rst b/cdist/conf/type/__motd/man.rst index 988e2d02..b568985f 100644 --- a/cdist/conf/type/__motd/man.rst +++ b/cdist/conf/type/__motd/man.rst @@ -1,8 +1,9 @@ cdist-type__motd(7) =================== -Manage message of the day -Nico Schottelius +NAME +---- +cdist-type__motd - Manage message of the day DESCRIPTION @@ -34,9 +35,9 @@ EXAMPLES __motd --source "$__type/files/my-motd" -SEE ALSO --------- -- `cdist-type(7) `_ +AUTHORS +------- +Nico Schottelius COPYING diff --git a/cdist/conf/type/__mount/man.rst b/cdist/conf/type/__mount/man.rst index 696dfbd4..799288af 100644 --- a/cdist/conf/type/__mount/man.rst +++ b/cdist/conf/type/__mount/man.rst @@ -1,8 +1,9 @@ cdist-type__mount(7) ==================== -Manage filesystem mounts -Steven Armstrong +NAME +---- +cdit-type__mount - Manage filesystem mounts DESCRIPTION @@ -70,9 +71,9 @@ EXAMPLES --options "mfsmaster=mfsmaster.domain.tld,mfssubfolder=/one,nonempty,_netdev" -SEE ALSO --------- -- `cdist-type(7) `_ +AUTHORS +------- +Steven Armstrong COPYING diff --git a/cdist/conf/type/__mysql_database/man.rst b/cdist/conf/type/__mysql_database/man.rst index 88f1eecd..0e21a8a1 100644 --- a/cdist/conf/type/__mysql_database/man.rst +++ b/cdist/conf/type/__mysql_database/man.rst @@ -1,8 +1,9 @@ cdist-type__mysql_database(7) ============================= -Manage a MySQL database -Benedikt Koeppel +NAME +---- +cdist-type__mysql_database - Manage a MySQL database DESCRIPTION @@ -35,9 +36,9 @@ EXAMPLES __mysql_database "cdist" --name "cdist" --user "myuser" --password "mypwd" -SEE ALSO --------- -- `cdist-type(7) `_ +AUTHORS +------- +Benedikt Koeppel COPYING diff --git a/cdist/conf/type/__package/man.rst b/cdist/conf/type/__package/man.rst index 1ada06a7..91319e18 100644 --- a/cdist/conf/type/__package/man.rst +++ b/cdist/conf/type/__package/man.rst @@ -1,8 +1,9 @@ cdist-type__package(7) ====================== -Manage packages -Steven Armstrong +NAME +---- +cdist-type__package - Manage packages DESCRIPTION @@ -50,9 +51,9 @@ EXAMPLES __package vim --state present --type __package_apt -SEE ALSO --------- -- `cdist-type(7) `_ +AUTHORS +------- +Steven Armstrong COPYING diff --git a/cdist/conf/type/__package/manifest b/cdist/conf/type/__package/manifest index 6b0daa98..c745f85f 100755 --- a/cdist/conf/type/__package/manifest +++ b/cdist/conf/type/__package/manifest @@ -30,7 +30,7 @@ else # By default determine package manager based on operating system os="$(cat "$__global/explorer/os")" case "$os" in - amazon|centos|fedora|redhat) type="yum" ;; + amazon|scientific|centos|fedora|redhat) type="yum" ;; archlinux) type="pacman" ;; debian|ubuntu|devuan) type="apt" ;; freebsd) diff --git a/cdist/conf/type/__package/parameter/boolean b/cdist/conf/type/__package/parameter/boolean new file mode 100644 index 00000000..effcb218 --- /dev/null +++ b/cdist/conf/type/__package/parameter/boolean @@ -0,0 +1 @@ +upgrade diff --git a/cdist/conf/type/__package/parameter/optional b/cdist/conf/type/__package/parameter/optional index d674f32e..bb3f5154 100644 --- a/cdist/conf/type/__package/parameter/optional +++ b/cdist/conf/type/__package/parameter/optional @@ -4,3 +4,4 @@ type pkgsite state ptype +repo diff --git a/cdist/conf/type/__package_apt/man.rst b/cdist/conf/type/__package_apt/man.rst index ec28c0cc..a841fc5b 100644 --- a/cdist/conf/type/__package_apt/man.rst +++ b/cdist/conf/type/__package_apt/man.rst @@ -1,8 +1,9 @@ cdist-type__package_apt(7) ========================== -Manage packages with apt-get -Nico Schottelius +NAME +---- +cdist-type__package_apt - Manage packages with apt-get DESCRIPTION @@ -45,8 +46,12 @@ EXAMPLES SEE ALSO -------- -- `cdist-type(7) `_ -- `cdist-type__package(7) `_ +:manpage:`cdist-type__package`\ (7) + + +AUTHORS +------- +Nico Schottelius COPYING diff --git a/cdist/conf/type/__package_emerge/man.rst b/cdist/conf/type/__package_emerge/man.rst index fe06031e..ceb0f169 100644 --- a/cdist/conf/type/__package_emerge/man.rst +++ b/cdist/conf/type/__package_emerge/man.rst @@ -1,8 +1,9 @@ cdist-type__package_emerge(7) ============================= -Manage packages with portage -Thomas Oettli +NAME +---- +cdist-type__package_emerge - Manage packages with portage DESCRIPTION @@ -46,9 +47,12 @@ EXAMPLES SEE ALSO -------- -- `cdist-type(7) `_ -- `cdist-type__package(7) `_ -- `cdist-type__package_emerge_dependencies(7) `_ +:manpage:`cdist-type__package`\ (7), :manpage:`cdist-type__package_emerge_dependencies`\ (7) + + +AUTHORS +------- +Thomas Oettli COPYING diff --git a/cdist/conf/type/__package_emerge_dependencies/man.rst b/cdist/conf/type/__package_emerge_dependencies/man.rst index 21af86e3..1a227853 100644 --- a/cdist/conf/type/__package_emerge_dependencies/man.rst +++ b/cdist/conf/type/__package_emerge_dependencies/man.rst @@ -1,8 +1,9 @@ cdist-type__package_emerge_dependencies(7) ========================================== -Install dependencies for __package_emerge -Thomas Oettli +NAME +---- +cdist-type__package_emerge_dependencies - Install dependencies for __package_emerge DESCRIPTION @@ -35,9 +36,12 @@ EXAMPLES SEE ALSO -------- -- `cdist-type(7) `_ -- `cdist-type__package(7) `_ -- `cdist-type__package_emerge(7) `_ +:manpage:`cdist-type__package`\ (7), :manpage:`cdist-type__package_emerge`\ (7) + + +AUTHORS +------- +Thomas Oettli COPYING diff --git a/cdist/conf/type/__package_luarocks/man.rst b/cdist/conf/type/__package_luarocks/man.rst index ff7fea83..399b07af 100644 --- a/cdist/conf/type/__package_luarocks/man.rst +++ b/cdist/conf/type/__package_luarocks/man.rst @@ -1,8 +1,9 @@ cdist-type__package_luarocks(7) =============================== -Manage luarocks packages -Christian G. Warden +NAME +---- +cdist-type__package_luarocks - Manage luarocks packages DESCRIPTION @@ -38,8 +39,12 @@ EXAMPLES SEE ALSO -------- -- `cdist-type(7) `_ -- `cdist-type__package(7) `_ +:manpage:`cdist-type__package`\ (7) + + +AUTHORS +------- +Christian G. Warden COPYING diff --git a/cdist/conf/type/__package_opkg/man.rst b/cdist/conf/type/__package_opkg/man.rst index 9af17988..203b8a36 100644 --- a/cdist/conf/type/__package_opkg/man.rst +++ b/cdist/conf/type/__package_opkg/man.rst @@ -1,8 +1,9 @@ cdist-type__package_opkg(7) =========================== -Manage packages with opkg -Giel van Schijndel +NAME +---- +cdist-type__package_opkg - Manage packages with opkg DESCRIPTION @@ -38,8 +39,12 @@ EXAMPLES SEE ALSO -------- -- `cdist-type(7) `_ -- `cdist-type__package(7) `_ +:manpage:`cdist-type__package`\ (7) + + +AUTHORS +------- +Giel van Schijndel COPYING diff --git a/cdist/conf/type/__package_pacman/man.rst b/cdist/conf/type/__package_pacman/man.rst index 3d8845a5..44f36255 100644 --- a/cdist/conf/type/__package_pacman/man.rst +++ b/cdist/conf/type/__package_pacman/man.rst @@ -1,8 +1,9 @@ cdist-type__package_pacman(7) ============================= -Manage packages with pacman -Nico Schottelius +NAME +---- +cdist-type__package_pacman - Manage packages with pacman DESCRIPTION @@ -41,8 +42,12 @@ EXAMPLES SEE ALSO -------- -- `cdist-type(7) `_ -- `cdist-type__package(7) `_ +:manpage:`cdist-type__package`\ (7) + + +AUTHORS +------- +Nico Schottelius COPYING diff --git a/cdist/conf/type/__package_pip/man.rst b/cdist/conf/type/__package_pip/man.rst index b312fff5..f1ba98d9 100644 --- a/cdist/conf/type/__package_pip/man.rst +++ b/cdist/conf/type/__package_pip/man.rst @@ -1,8 +1,9 @@ cdist-type__package_pip(7) ========================== -Manage packages with pip -Nico Schottelius +NAME +---- +cdist-type__package_pip - Manage packages with pip DESCRIPTION @@ -48,8 +49,12 @@ EXAMPLES SEE ALSO -------- -- `cdist-type(7) `_ -- `cdist-type__package(7) `_ +:manpage:`cdist-type__package`\ (7) + + +AUTHORS +------- +Nico Schottelius COPYING diff --git a/cdist/conf/type/__package_pkg_freebsd/man.rst b/cdist/conf/type/__package_pkg_freebsd/man.rst index c728cc9a..a2633bcb 100644 --- a/cdist/conf/type/__package_pkg_freebsd/man.rst +++ b/cdist/conf/type/__package_pkg_freebsd/man.rst @@ -1,8 +1,9 @@ cdist-type__package_pkg_freebsd(7) ================================== -Manage FreeBSD packages -Jake Guffey +NAME +---- +cdist-type__package_pkg_freebsd - Manage FreeBSD packages DESCRIPTION @@ -53,8 +54,12 @@ EXAMPLES SEE ALSO -------- -- `cdist-type(7) `_ -- `cdist-type__package(7) `_ +:manpage:`cdist-type__package`\ (7) + + +AUTHORS +------- +Jake Guffey COPYING diff --git a/cdist/conf/type/__package_pkg_openbsd/man.rst b/cdist/conf/type/__package_pkg_openbsd/man.rst index f9a746b9..e776956c 100644 --- a/cdist/conf/type/__package_pkg_openbsd/man.rst +++ b/cdist/conf/type/__package_pkg_openbsd/man.rst @@ -1,8 +1,9 @@ cdist-type__package_pkg(7) ========================== -Manage OpenBSD packages -Andi Brönnimann +NAME +---- +cdist-type__package_pkg - Manage OpenBSD packages DESCRIPTION @@ -53,8 +54,12 @@ EXAMPLES SEE ALSO -------- -- `cdist-type(7) `_ -- `cdist-type__package(7) `_ +:manpage:`cdist-type__package`\ (7) + + +AUTHORS +------- +Andi Brönnimann COPYING diff --git a/cdist/conf/type/__package_pkgng_freebsd/man.rst b/cdist/conf/type/__package_pkgng_freebsd/man.rst index 36f1a7d8..9fdd7c76 100644 --- a/cdist/conf/type/__package_pkgng_freebsd/man.rst +++ b/cdist/conf/type/__package_pkgng_freebsd/man.rst @@ -1,8 +1,9 @@ cdist-type__package_pkgng_freebsd(7) ==================================== -Manage FreeBSD packages with pkg-ng -Jake Guffey +NAME +---- +cdist-type__package_pkgng_freebsd - Manage FreeBSD packages with pkg-ng DESCRIPTION @@ -84,8 +85,12 @@ EXAMPLES SEE ALSO -------- -- `cdist-type(7) `_ -- `cdist-type__package(7) `_ +:manpage:`cdist-type__package`\ (7) + + +AUTHORS +------- +Jake Guffey COPYING diff --git a/cdist/conf/type/__package_rubygem/man.rst b/cdist/conf/type/__package_rubygem/man.rst index 4cb9af04..eb76a036 100644 --- a/cdist/conf/type/__package_rubygem/man.rst +++ b/cdist/conf/type/__package_rubygem/man.rst @@ -1,8 +1,9 @@ cdist-type__package_rubygem(7) ============================== -Manage rubygem packages -Chase Allen James +NAME +---- +cdist-type__package_rubygem - Manage rubygem packages DESCRIPTION @@ -38,8 +39,12 @@ EXAMPLES SEE ALSO -------- -- `cdist-type(7) `_ -- `cdist-type__package(7) `_ +:manpage:`cdist-type__package`\ (7) + + +AUTHORS +------- +Chase Allen James COPYING diff --git a/cdist/conf/type/__package_update_index/gencode-remote b/cdist/conf/type/__package_update_index/gencode-remote index 589e7202..bf6a532d 100755 --- a/cdist/conf/type/__package_update_index/gencode-remote +++ b/cdist/conf/type/__package_update_index/gencode-remote @@ -29,7 +29,7 @@ else # By default determine package manager based on operating system os="$(cat "$__global/explorer/os")" case "$os" in - amazon|centos|fedora|redhat) type="yum" ;; + amazon|scientific|centos|fedora|redhat) type="yum" ;; debian|ubuntu|devuan) type="apt" ;; archlinux) type="pacman" ;; *) diff --git a/cdist/conf/type/__package_update_index/man.rst b/cdist/conf/type/__package_update_index/man.rst index a16d29ce..e64fddae 100644 --- a/cdist/conf/type/__package_update_index/man.rst +++ b/cdist/conf/type/__package_update_index/man.rst @@ -1,8 +1,9 @@ cdist-type__package_update_index(7) =================================== -Update the package index -Ricardo Catalinas Jiménez +NAME +---- +cdist-type__update_index - Update the package index DESCRIPTION @@ -39,9 +40,9 @@ EXAMPLES __package_update_index --type apt -SEE ALSO --------- -- `cdist-type(7) `_ +AUTHORS +------- +Ricardo Catalinas Jiménez COPYING diff --git a/cdist/conf/type/__package_upgrade_all/gencode-remote b/cdist/conf/type/__package_upgrade_all/gencode-remote index 4d034816..9dd3ddf6 100755 --- a/cdist/conf/type/__package_upgrade_all/gencode-remote +++ b/cdist/conf/type/__package_upgrade_all/gencode-remote @@ -30,7 +30,7 @@ else # By default determine package manager based on operating system os="$(cat "$__global/explorer/os")" case "$os" in - amazon|centos|fedora|redhat) type="yum" ;; + amazon|scientific|centos|fedora|redhat) type="yum" ;; debian|ubuntu|devuan) type="apt" ;; archlinux) type="pacman" ;; *) diff --git a/cdist/conf/type/__package_upgrade_all/man.rst b/cdist/conf/type/__package_upgrade_all/man.rst index 146a8259..fd4dba44 100644 --- a/cdist/conf/type/__package_upgrade_all/man.rst +++ b/cdist/conf/type/__package_upgrade_all/man.rst @@ -1,8 +1,9 @@ cdist-type__package_upgrade_all(7) ================================== -Upgrade all the installed packages -Ricardo Catalinas Jiménez +NAME +---- +cdist-type__package_upgrade_all - Upgrade all the installed packages DESCRIPTION @@ -39,9 +40,9 @@ EXAMPLES __package_upgrade_all --type apt -SEE ALSO --------- -- `cdist-type(7) `_ +AUTHORS +------- +Ricardo Catalinas Jiménez COPYING diff --git a/cdist/conf/type/__package_yum/gencode-remote b/cdist/conf/type/__package_yum/gencode-remote index 32a794a0..08c5c2b5 100755 --- a/cdist/conf/type/__package_yum/gencode-remote +++ b/cdist/conf/type/__package_yum/gencode-remote @@ -37,7 +37,7 @@ fi state_should="$(cat "$__object/parameter/state")" -if grep -q -E "(centos|redhat|amazon)" "$__global/explorer/os"; then +if grep -q -E "(scientific|centos|redhat|amazon)" "$__global/explorer/os"; then opts="-y --quiet" else opts="--assumeyes --quiet" diff --git a/cdist/conf/type/__package_yum/man.rst b/cdist/conf/type/__package_yum/man.rst index 65e56c7a..544afbf2 100644 --- a/cdist/conf/type/__package_yum/man.rst +++ b/cdist/conf/type/__package_yum/man.rst @@ -1,8 +1,9 @@ cdist-type__package_yum(7) ========================== -Manage packages with yum -Nico Schottelius +NAME +---- +cdist-type__package_yum - Manage packages with yum DESCRIPTION @@ -48,8 +49,12 @@ EXAMPLES SEE ALSO -------- -- `cdist-type(7) `_ -- `cdist-type__package(7) `_ +:manpage:`cdist-type__package`\ (7) + + +AUTHORS +------- +Nico Schottelius COPYING diff --git a/cdist/conf/type/__package_zypper/man.rst b/cdist/conf/type/__package_zypper/man.rst index 2df22e72..da8d1d81 100644 --- a/cdist/conf/type/__package_zypper/man.rst +++ b/cdist/conf/type/__package_zypper/man.rst @@ -1,8 +1,9 @@ cdist-type__package_zypper(7) ============================= -Manage packages with zypper -Daniel Heule +NAME +---- +cdist-type__package_zypper - Manage packages with zypper DESCRIPTION @@ -55,8 +56,12 @@ EXAMPLES SEE ALSO -------- -- `cdist-type(7) `_ -- `cdist-type__package(7) `_ +:manpage:`cdist-type__package`\ (7) + + +AUTHORS +------- +Daniel Heule COPYING diff --git a/cdist/conf/type/__pacman_conf/man.rst b/cdist/conf/type/__pacman_conf/man.rst index 930035fa..a61f2498 100644 --- a/cdist/conf/type/__pacman_conf/man.rst +++ b/cdist/conf/type/__pacman_conf/man.rst @@ -1,8 +1,9 @@ cdist-type__pacman_conf(7) ========================== -Manage pacman configuration -Dominique Roux +NAME +---- +cdist-type__pacman_conf - Manage pacman configuration DESCRIPTION @@ -58,8 +59,12 @@ EXAMPLES SEE ALSO -------- -- `cdist-type(7) `_ -- grep(1) +:manpage:`grep`\ (1) + + +AUTHORS +------- +Dominique Roux COPYING diff --git a/cdist/conf/type/__pacman_conf_integrate/man.rst b/cdist/conf/type/__pacman_conf_integrate/man.rst index 6a856efe..77d5c1c3 100644 --- a/cdist/conf/type/__pacman_conf_integrate/man.rst +++ b/cdist/conf/type/__pacman_conf_integrate/man.rst @@ -1,8 +1,9 @@ cdist-type__pacman_conf_integrate(7) ==================================== -Integrate default pacman.conf to cdist conform and vice versa -Dominique Roux +NAME +---- +cdist-type__pacman_conf_integrate - Integrate default pacman.conf to cdist conform and vice versa DESCRIPTION @@ -34,8 +35,12 @@ EXAMPLES SEE ALSO -------- -- `cdist-type(7) `_ -- grep(1) +:manpage:`grep`\ (1) + + +AUTHORS +------- +Dominique Roux COPYING diff --git a/cdist/conf/type/__pf_apply/man.rst b/cdist/conf/type/__pf_apply/man.rst index 0b440e2d..2c7fd4fb 100644 --- a/cdist/conf/type/__pf_apply/man.rst +++ b/cdist/conf/type/__pf_apply/man.rst @@ -1,12 +1,9 @@ cdist-type__pf_apply(7) ======================= -Apply pf(4) ruleset on \*BSD - -Jake Guffey - NAME ---- +cdist-type__pf_apply - Apply pf(4) ruleset on \*BSD DESCRIPTION @@ -42,9 +39,12 @@ EXAMPLES SEE ALSO -------- -- `cdist-type(7) `_ -- `cdist-type__pf_ruleset(7) `_ -- pf(4) +:manpage:`pf`\ (4), :manpage:`cdist-type__pf_ruleset`\ (7) + + +AUTHORS +------- +Jake Guffey COPYING diff --git a/cdist/conf/type/__pf_ruleset/man.rst b/cdist/conf/type/__pf_ruleset/man.rst index b3e9b073..eb97e086 100644 --- a/cdist/conf/type/__pf_ruleset/man.rst +++ b/cdist/conf/type/__pf_ruleset/man.rst @@ -1,8 +1,9 @@ cdist-type__pf_ruleset(7) ========================= -Copy a pf(4) ruleset to $__target_host -Jake Guffey +NAME +---- +cdist-type__pf_ruleset - Copy a pf(4) ruleset to $__target_host DESCRIPTION @@ -38,8 +39,12 @@ EXAMPLES SEE ALSO -------- -- `cdist-type(7) `_ -- pf(4) +:manpage:`pf`\ (4) + + +AUTHORS +------- +Jake Guffey COPYING diff --git a/cdist/conf/type/__postfix/man.rst b/cdist/conf/type/__postfix/man.rst index d10a9960..dff85fec 100644 --- a/cdist/conf/type/__postfix/man.rst +++ b/cdist/conf/type/__postfix/man.rst @@ -1,8 +1,9 @@ cdist-type__postfix(7) ====================== -Install postfix -Steven Armstrong +NAME +---- +cdist-type__postfix - Install postfix DESCRIPTION @@ -28,9 +29,9 @@ EXAMPLES __postfix -SEE ALSO --------- -- `cdist-type(7) `_ +AUTHORS +------- +Steven Armstrong COPYING diff --git a/cdist/conf/type/__postfix/manifest b/cdist/conf/type/__postfix/manifest index 43443e1e..b425e072 100755 --- a/cdist/conf/type/__postfix/manifest +++ b/cdist/conf/type/__postfix/manifest @@ -22,7 +22,7 @@ os=$(cat "$__global/explorer/os") case "$os" in - ubuntu|debian|archlinux|suse|centos|devuan) + ubuntu|debian|archlinux|suse|scientific|centos|devuan) __package postfix --state present ;; *) diff --git a/cdist/conf/type/__postfix_master/man.rst b/cdist/conf/type/__postfix_master/man.rst index 4853e687..27078070 100644 --- a/cdist/conf/type/__postfix_master/man.rst +++ b/cdist/conf/type/__postfix_master/man.rst @@ -1,8 +1,9 @@ cdist-type__postfix_master(7) ============================= -Configure postfix master.cf -Steven Armstrong +NAME +---- +cdist-type__postfix_master - Configure postfix master.cf DESCRIPTION @@ -67,8 +68,12 @@ EXAMPLES SEE ALSO -------- -- `cdist-type(7) `_ -- master(5) +:manpage:`master`\ (5) + + +AUTHORS +------- +Steven Armstrong COPYING diff --git a/cdist/conf/type/__postfix_master/manifest b/cdist/conf/type/__postfix_master/manifest index 3d82c526..af71b88e 100755 --- a/cdist/conf/type/__postfix_master/manifest +++ b/cdist/conf/type/__postfix_master/manifest @@ -22,7 +22,7 @@ os=$(cat "$__global/explorer/os") case "$os" in - ubuntu|debian|archlinux|centos|devuan) + ubuntu|debian|archlinux|scientific|centos|devuan) : ;; *) diff --git a/cdist/conf/type/__postfix_postconf/explorer/value b/cdist/conf/type/__postfix_postconf/explorer/value index d451bce6..17126c94 100755 --- a/cdist/conf/type/__postfix_postconf/explorer/value +++ b/cdist/conf/type/__postfix_postconf/explorer/value @@ -22,7 +22,7 @@ os=$("$__explorer/os") case "$os" in - ubuntu|debian|archlinux|suse|centos|devuan) + ubuntu|debian|archlinux|suse|scientific|centos|devuan) : ;; *) diff --git a/cdist/conf/type/__postfix_postconf/gencode-remote b/cdist/conf/type/__postfix_postconf/gencode-remote index b3557640..f886499b 100755 --- a/cdist/conf/type/__postfix_postconf/gencode-remote +++ b/cdist/conf/type/__postfix_postconf/gencode-remote @@ -21,7 +21,7 @@ os=$(cat "$__global/explorer/os") case "$os" in - ubuntu|debian|archlinux|suse|centos|devuan) + ubuntu|debian|archlinux|suse|scientific|centos|devuan) : ;; *) diff --git a/cdist/conf/type/__postfix_postconf/man.rst b/cdist/conf/type/__postfix_postconf/man.rst index e07e136f..5773fcaf 100644 --- a/cdist/conf/type/__postfix_postconf/man.rst +++ b/cdist/conf/type/__postfix_postconf/man.rst @@ -1,8 +1,9 @@ cdist-type__postfix_postconf(7) =============================== -Configure postfix main.cf -Steven Armstrong +NAME +---- +cdist-type__postfix_postconf - Configure postfix main.cf DESCRIPTION @@ -37,8 +38,12 @@ EXAMPLES SEE ALSO -------- -- `cdist-type(7) `_ -- postconf(5) +:manpage:`postconf`\ (5) + + +AUTHORS +------- +Steven Armstrong COPYING diff --git a/cdist/conf/type/__postfix_postmap/man.rst b/cdist/conf/type/__postfix_postmap/man.rst index ecee6722..2f455346 100644 --- a/cdist/conf/type/__postfix_postmap/man.rst +++ b/cdist/conf/type/__postfix_postmap/man.rst @@ -1,8 +1,9 @@ cdist-type__postfix_postmap(7) ============================== -Run postmap on the given file -Steven Armstrong +NAME +---- +cdist-type__postfix_postmap - Run postmap on the given file DESCRIPTION @@ -28,9 +29,9 @@ EXAMPLES __postfix_postmap /etc/postfix/generic -SEE ALSO --------- -- `cdist-type(7) `_ +AUTHORS +------- +Steven Armstrong COPYING diff --git a/cdist/conf/type/__postfix_reload/gencode-remote b/cdist/conf/type/__postfix_reload/gencode-remote index 7323606c..0efd6022 100755 --- a/cdist/conf/type/__postfix_reload/gencode-remote +++ b/cdist/conf/type/__postfix_reload/gencode-remote @@ -22,7 +22,7 @@ os=$(cat "$__global/explorer/os") case "$os" in - ubuntu|debian|archlinux|centos|devuan) + ubuntu|debian|archlinux|scientific|centos|devuan) echo "postfix reload" ;; *) diff --git a/cdist/conf/type/__postfix_reload/man.rst b/cdist/conf/type/__postfix_reload/man.rst index c5101953..36a66d45 100644 --- a/cdist/conf/type/__postfix_reload/man.rst +++ b/cdist/conf/type/__postfix_reload/man.rst @@ -1,8 +1,9 @@ cdist-type__postfix_reload(7) ============================= -Tell postfix to reload its configuration -Steven Armstrong +NAME +---- +cdist-type__postfix_reload - Tell postfix to reload its configuration DESCRIPTION @@ -28,9 +29,9 @@ EXAMPLES __postfix_reload -SEE ALSO --------- -- `cdist-type(7) `_ +AUTHORS +------- +Steven Armstrong COPYING diff --git a/cdist/conf/type/__postgres_database/man.rst b/cdist/conf/type/__postgres_database/man.rst index 152ee910..69e1a67f 100644 --- a/cdist/conf/type/__postgres_database/man.rst +++ b/cdist/conf/type/__postgres_database/man.rst @@ -1,8 +1,9 @@ cdist-type__postgres_database(7) ================================ -Create/drop postgres databases -Steven Armstrong +NAME +---- +cdist-type__postgres_database - Create/drop postgres databases DESCRIPTION @@ -29,8 +30,12 @@ EXAMPLES SEE ALSO -------- -- `cdist-type(7) `_ -- `cdist-type__postgres_role(7) `_ +:manpage:`cdist-type__postgres_role`\ (7) + + +AUTHORS +------- +Steven Armstrong COPYING diff --git a/cdist/conf/type/__postgres_role/man.rst b/cdist/conf/type/__postgres_role/man.rst index 6384568f..f9293be5 100644 --- a/cdist/conf/type/__postgres_role/man.rst +++ b/cdist/conf/type/__postgres_role/man.rst @@ -1,8 +1,9 @@ cdist-type__postgres_role(7) ============================ -Manage postgres roles -Steven Armstrong +NAME +---- +cdist-type__postgres_role - Manage postgres roles DESCRIPTION @@ -47,9 +48,15 @@ EXAMPLES SEE ALSO -------- -- `cdist-type(7) `_ -- `cdist-type__postgres_database(7) `_ -- http://www.postgresql.org/docs/current/static/sql-createrole.html +:manpage:`cdist-type__postgres_database`\ (7) + +postgresql documentation at: +. + + +AUTHORS +------- +Steven Armstrong COPYING diff --git a/cdist/conf/type/__process/man.rst b/cdist/conf/type/__process/man.rst index 09032a1a..19f68ddc 100644 --- a/cdist/conf/type/__process/man.rst +++ b/cdist/conf/type/__process/man.rst @@ -1,8 +1,9 @@ cdist-type__process(7) ====================== -Start or stop process -Nico Schottelius +NAME +---- +cdist-type__process - Start or stop process DESCRIPTION @@ -57,8 +58,12 @@ EXAMPLES SEE ALSO -------- -- `cdist-type(7) `_ -- `cdist-type__start_on_boot(7) `_ +:manpage:`cdist-type__start_on_boot`\ (7) + + +AUTHORS +------- +Nico Schottelius COPYING diff --git a/cdist/conf/type/__pyvenv/man.rst b/cdist/conf/type/__pyvenv/man.rst old mode 100755 new mode 100644 index bdc1166c..977501e6 --- a/cdist/conf/type/__pyvenv/man.rst +++ b/cdist/conf/type/__pyvenv/man.rst @@ -1,8 +1,9 @@ cdist-type__pyvenv(7) ===================== -Create or remove python virtual environment -Darko Poljak +NAME +---- +cdist-type__pyvenv - Create or remove python virtual environment DESCRIPTION @@ -66,9 +67,9 @@ EXAMPLES __pyvenv /home/services/djangoenv --venvparams "--copies --system-site-packages" -SEE ALSO --------- -- `cdist-type(7) `_ +AUTHORS +------- +Darko Poljak COPYING diff --git a/cdist/conf/type/__qemu_img/man.rst b/cdist/conf/type/__qemu_img/man.rst index 598e06ab..7cb4a758 100644 --- a/cdist/conf/type/__qemu_img/man.rst +++ b/cdist/conf/type/__qemu_img/man.rst @@ -1,8 +1,9 @@ cdist-type__qemu_img(7) ======================= -Manage VM disk images -Nico Schottelius +NAME +---- +cdist-type__qemu_img - Manage VM disk images DESCRIPTION @@ -36,8 +37,12 @@ EXAMPLES SEE ALSO -------- -- `cdist-type(7) `_ -- qemu-img(1) +:manpage:`qemu-img`\ (1) + + +AUTHORS +------- +Nico Schottelius COPYING diff --git a/cdist/conf/type/__rbenv/man.rst b/cdist/conf/type/__rbenv/man.rst index 314507fe..6341908a 100644 --- a/cdist/conf/type/__rbenv/man.rst +++ b/cdist/conf/type/__rbenv/man.rst @@ -1,8 +1,9 @@ cdist-type__rbenv(7) ==================== -Manage rbenv installation -Nico Schottelius +NAME +---- +cdist-type__rbenv - Manage rbenv installation DESCRIPTION @@ -35,9 +36,9 @@ EXAMPLES __rbenv /home/bastian --state absent -SEE ALSO --------- -- `cdist-type(7) `_ +AUTHORS +------- +Nico Schottelius COPYING diff --git a/cdist/conf/type/__rsync/man.rst b/cdist/conf/type/__rsync/man.rst index bc7b1bca..28e85ab2 100644 --- a/cdist/conf/type/__rsync/man.rst +++ b/cdist/conf/type/__rsync/man.rst @@ -1,8 +1,9 @@ cdist-type__rsync(7) ==================== -Mirror directories using rsync -Nico Schottelius +NAME +---- +cdist-type__rsync - Mirror directories using rsync DESCRIPTION @@ -97,8 +98,12 @@ EXAMPLES SEE ALSO -------- -- `cdist-type(7) `_ -- rsync(1) +:manpage:`rsync`\ (1) + + +AUTHORS +------- +Nico Schottelius COPYING diff --git a/cdist/conf/type/__rvm/man.rst b/cdist/conf/type/__rvm/man.rst index 8a3f72f5..412b651d 100644 --- a/cdist/conf/type/__rvm/man.rst +++ b/cdist/conf/type/__rvm/man.rst @@ -1,8 +1,9 @@ cdist-type__rvm(7) ================== -Install rvm for a given user -Evax Software +NAME +---- +cdist-type__rvm - Install rvm for a given user DESCRIPTION @@ -30,10 +31,13 @@ EXAMPLES SEE ALSO -------- -- `cdist-type(7) `_ -- `cdist-type__rvm_ruby(7) `_ -- `cdist-type__rvm_gemset(7) `_ -- `cdist-type__rvm_gem(7) `_ +:manpage:`cdist-type__rvm_gem`\ (7), :manpage:`cdist-type__rvm_gemset`\ (7), +:manpage:`cdist-type__rvm_ruby`\ (7) + + +AUTHORS +------- +Evax Software COPYING diff --git a/cdist/conf/type/__rvm_gem/man.rst b/cdist/conf/type/__rvm_gem/man.rst index 39d93065..a60fe843 100644 --- a/cdist/conf/type/__rvm_gem/man.rst +++ b/cdist/conf/type/__rvm_gem/man.rst @@ -1,8 +1,9 @@ cdist-type__rvm_gemset(7) ========================== -Manage Ruby gems through rvm -Evax Software +NAME +---- +cdist-type__rvm_gemset - Manage Ruby gems through rvm DESCRIPTION @@ -42,10 +43,13 @@ EXAMPLES SEE ALSO -------- -- `cdist-type(7) `_ -- `cdist-type__rvm(7) `_ -- `cdist-type__rvm_ruby(7) `_ -- `cdist-type__rvm_gemset(7) `_ +:manpage:`cdist-type__rvm`\ (7), :manpage:`cdist-type__rvm_gemset`\ (7), +:manpage:`cdist-type__rvm_ruby`\ (7) + + +AUTHORS +------- +Evax Software COPYING diff --git a/cdist/conf/type/__rvm_gemset/man.rst b/cdist/conf/type/__rvm_gemset/man.rst index 422130cb..4259ec92 100644 --- a/cdist/conf/type/__rvm_gemset/man.rst +++ b/cdist/conf/type/__rvm_gemset/man.rst @@ -1,8 +1,9 @@ cdist-type__rvm_gemset(7) ========================== -Manage gemsets through rvm -Evax Software +NAME +---- +cdist-type__rvm_gemset - Manage gemsets through rvm DESCRIPTION @@ -40,10 +41,13 @@ EXAMPLES SEE ALSO -------- -- `cdist-type(7) `_ -- `cdist-type__rvm(7) `_ -- `cdist-type__rvm_ruby(7) `_ -- `cdist-type__rvm_gem(7) `_ +:manpage:`cdist-type__rvm`\ (7), :manpage:`cdist-type__rvm_gem`\ (7), +:manpage:`cdist-type__rvm_ruby`\ (7) + + +AUTHORS +------- +Evax Software COPYING diff --git a/cdist/conf/type/__rvm_ruby/man.rst b/cdist/conf/type/__rvm_ruby/man.rst index dbb1c9a2..18b6044b 100644 --- a/cdist/conf/type/__rvm_ruby/man.rst +++ b/cdist/conf/type/__rvm_ruby/man.rst @@ -1,8 +1,9 @@ cdist-type__rvm_ruby(7) ======================= -Manage ruby installations through rvm -Evax Software +NAME +---- +cdist-type__rvm_ruby - Manage ruby installations through rvm DESCRIPTION @@ -41,10 +42,13 @@ EXAMPLES SEE ALSO -------- -- `cdist-type(7) `_ -- `cdist-type__rvm(7) `_ -- `cdist-type__rvm_gemset(7) `_ -- `cdist-type__rvm_gem(7) `_ +:manpage:`cdist-type__rvm`\ (7), :manpage:`cdist-type__rvm_gem`\ (7), +:manpage:`cdist-type__rvm_gemset`\ (7) + + +AUTHORS +------- +Evax Software COPYING diff --git a/cdist/conf/type/__ssh_authorized_key/man.rst b/cdist/conf/type/__ssh_authorized_key/man.rst index 984ea51b..3585717f 100644 --- a/cdist/conf/type/__ssh_authorized_key/man.rst +++ b/cdist/conf/type/__ssh_authorized_key/man.rst @@ -1,8 +1,9 @@ cdist-type__ssh_authorized_key(7) ================================= -Manage a single ssh authorized key entry -Steven Armstrong +NAME +---- +cdist-type__ssh_authorized_key - Manage a single ssh authorized key entry DESCRIPTION @@ -54,9 +55,13 @@ EXAMPLES SEE ALSO -------- -- `cdist-type(7) `_ -- `cdist__ssh_authorized_keys(7) `_ -- sshd(8) +:manpage:`cdist__ssh_authorized_keys`\ (7), :manpage:`sshd`\ (8) + + +AUTHORS +------- +Steven Armstrong + COPYING ------- diff --git a/cdist/conf/type/__ssh_authorized_keys/man.rst b/cdist/conf/type/__ssh_authorized_keys/man.rst index 0907c2b3..6729660e 100644 --- a/cdist/conf/type/__ssh_authorized_keys/man.rst +++ b/cdist/conf/type/__ssh_authorized_keys/man.rst @@ -1,8 +1,9 @@ cdist-type__ssh_authorized_keys(7) ================================== -Manage ssh authorized_keys files -Steven Armstrong +NAME +---- +cdist-type__ssh_authorized_keys - Manage ssh authorized_keys files DESCRIPTION @@ -104,8 +105,12 @@ EXAMPLES SEE ALSO -------- -- `cdist-type(7) `_ -- sshd(8) +:manpage:`sshd`\ (8) + + +AUTHORS +------- +Steven Armstrong COPYING diff --git a/cdist/conf/type/__ssh_dot_ssh/man.rst b/cdist/conf/type/__ssh_dot_ssh/man.rst index 1b84c924..75adbde0 100644 --- a/cdist/conf/type/__ssh_dot_ssh/man.rst +++ b/cdist/conf/type/__ssh_dot_ssh/man.rst @@ -1,12 +1,9 @@ cdist-type__ssh_dot_ssh(7) ========================== -Manage .ssh directory - -Nico Schottelius - NAME ---- +cdist-type__ssh_dot_ssh - Manage .ssh directory DESCRIPTION @@ -36,8 +33,12 @@ EXAMPLES SEE ALSO -------- -- `cdist-type(7) `_ -- `cdist-type__ssh_authorized_keys(7) `_ +:manpage:`cdist-type__ssh_authorized_keys`\ (7) + + +AUTHORS +------- +Nico Schottelius COPYING diff --git a/cdist/conf/type/__staged_file/man.rst b/cdist/conf/type/__staged_file/man.rst index ed977b28..d11338af 100644 --- a/cdist/conf/type/__staged_file/man.rst +++ b/cdist/conf/type/__staged_file/man.rst @@ -1,8 +1,9 @@ cdist-type__staged_file(7) ========================== -Manage staged files -Steven Armstrong +NAME +---- +cdist-type__staged_file - Manage staged files DESCRIPTION @@ -98,8 +99,12 @@ EXAMPLES SEE ALSO -------- -- `cdist-type(7) `_ -- `cdist-type__file(7) `_ +:manpage:`cdist-type__file`\ (7) + + +AUTHORS +------- +Steven Armstrong COPYING diff --git a/cdist/conf/type/__start_on_boot/explorer/state b/cdist/conf/type/__start_on_boot/explorer/state index ca0f3a51..d49f01c7 100644 --- a/cdist/conf/type/__start_on_boot/explorer/state +++ b/cdist/conf/type/__start_on_boot/explorer/state @@ -47,7 +47,7 @@ else [ -f "/etc/init/${name}.conf" ] && state="present" ;; - amazon|centos|fedora|owl|redhat) + amazon|scientific|centos|fedora|owl|redhat) state=$(chkconfig --level "$runlevel" "$name" || echo absent) [ "$state" ] || state="present" ;; diff --git a/cdist/conf/type/__start_on_boot/gencode-remote b/cdist/conf/type/__start_on_boot/gencode-remote index 057f9f48..e77132c9 100644 --- a/cdist/conf/type/__start_on_boot/gencode-remote +++ b/cdist/conf/type/__start_on_boot/gencode-remote @@ -59,7 +59,7 @@ case "$state_should" in echo rc-update add \"$name\" \"$target_runlevel\" ;; - amazon|centos|fedora|owl|redhat|suse) + amazon|scientific|centos|fedora|owl|redhat|suse) echo chkconfig \"$name\" on ;; diff --git a/cdist/conf/type/__start_on_boot/man.rst b/cdist/conf/type/__start_on_boot/man.rst index 2fb2c7d9..70c3e8d4 100644 --- a/cdist/conf/type/__start_on_boot/man.rst +++ b/cdist/conf/type/__start_on_boot/man.rst @@ -1,8 +1,9 @@ cdist-type__start_on_boot(7) ============================ -Manage stuff to be started at boot -Nico Schottelius +NAME +---- +cdist-type__start_on_boot - Manage stuff to be started at boot DESCRIPTION @@ -44,8 +45,12 @@ EXAMPLES SEE ALSO -------- -- `cdist-type(7) `_ -- `cdist-type__process(7) `_ +:manpage:`cdist-type__process`\ (7) + + +AUTHORS +------- +Nico Schottelius COPYING diff --git a/cdist/conf/type/__timezone/man.rst b/cdist/conf/type/__timezone/man.rst index 083f4fe6..8a945c16 100644 --- a/cdist/conf/type/__timezone/man.rst +++ b/cdist/conf/type/__timezone/man.rst @@ -1,8 +1,9 @@ cdist-type__timezone(7) ======================= -Allows one to configure the desired localtime timezone. -Ramon Salvadó +NAME +---- +cdist-type__timezone - Allows one to configure the desired localtime timezone. DESCRIPTION @@ -33,9 +34,9 @@ EXAMPLES __timezone US/Central -SEE ALSO --------- -- `cdist-type(7) `_ +AUTHORS +------- +Ramon Salvadó COPYING diff --git a/cdist/conf/type/__timezone/manifest b/cdist/conf/type/__timezone/manifest index 8ddfd122..bcbe41c3 100755 --- a/cdist/conf/type/__timezone/manifest +++ b/cdist/conf/type/__timezone/manifest @@ -38,7 +38,7 @@ case "$os" in # whitelist : ;; - centos) + scientific|centos) __package tzdata --state present export require="__package/tzdata" __file /etc/sysconfig/clock \ diff --git a/cdist/conf/type/__update_alternatives/man.rst b/cdist/conf/type/__update_alternatives/man.rst index 477ee88c..c2b8bf6d 100644 --- a/cdist/conf/type/__update_alternatives/man.rst +++ b/cdist/conf/type/__update_alternatives/man.rst @@ -1,8 +1,9 @@ cdist-type__update_alternatives(7) ================================== -Configure alternatives -Nico Schottelius +NAME +---- +cdist-type__update_alternatives - Configure alternatives DESCRIPTION @@ -29,9 +30,12 @@ EXAMPLES SEE ALSO -------- -- `cdist-type(7) `_ -- `cdist-type__debconf_set_selections(7) `_ -- update-alternatives(8) +:manpage:`cdist-type__debconf_set_selections`\ (7), :manpage:`update-alternatives`\ (8) + + +AUTHORS +------- +Nico Schottelius COPYING diff --git a/cdist/conf/type/__user/man.rst b/cdist/conf/type/__user/man.rst index c690a559..1ad17b5b 100644 --- a/cdist/conf/type/__user/man.rst +++ b/cdist/conf/type/__user/man.rst @@ -1,8 +1,9 @@ cdist-type__user(7) =================== -Manage users -Steven Armstrong +NAME +---- +cdist-type__user - Manage users DESCRIPTION @@ -83,8 +84,12 @@ EXAMPLES SEE ALSO -------- -- `cdist-type(7) `_ -- usermod(8) or pw(8) +:manpage:`pw`\ (8), :manpage:`usermod`\ (8) + + +AUTHORS +------- +Steven Armstrong COPYING diff --git a/cdist/conf/type/__user_groups/man.rst b/cdist/conf/type/__user_groups/man.rst index 4458a6cf..37fd25d7 100644 --- a/cdist/conf/type/__user_groups/man.rst +++ b/cdist/conf/type/__user_groups/man.rst @@ -1,8 +1,9 @@ cdist-type__user_groups(7) ========================== -Manage user groups -Steven Armstrong +NAME +---- +cdist-type__user_groups - Manage user groups DESCRIPTION @@ -38,9 +39,9 @@ EXAMPLES --group webuser2 --state absent -SEE ALSO --------- -- `cdist-type(7) `_ +AUTHORS +------- +Steven Armstrong COPYING diff --git a/cdist/conf/type/__yum_repo/man.rst b/cdist/conf/type/__yum_repo/man.rst index 396f271c..543a456d 100644 --- a/cdist/conf/type/__yum_repo/man.rst +++ b/cdist/conf/type/__yum_repo/man.rst @@ -1,8 +1,9 @@ cdist-type__yum_repo(7) ======================= -Manage yum repositories -Steven Armstrong +NAME +---- +cdist-type__yum_repo - Manage yum repositories DESCRIPTION @@ -110,9 +111,9 @@ EXAMPLES --gpgkey https://fedoraproject.org/static/0608B895.txt -SEE ALSO --------- -- `cdist-type(7) `_ +AUTHORS +------- +Steven Armstrong COPYING diff --git a/cdist/conf/type/__yum_repo/manifest b/cdist/conf/type/__yum_repo/manifest index 9bb63c3c..950c3b7a 100755 --- a/cdist/conf/type/__yum_repo/manifest +++ b/cdist/conf/type/__yum_repo/manifest @@ -22,7 +22,7 @@ os=$(cat "$__global/explorer/os") state="$(cat "$__object/parameter/state")" case "$os" in - centos) + scientific|centos) repo_name="$__object_id" export repo_name repo_file="/etc/yum.repos.d/${repo_name}.repo" diff --git a/cdist/conf/type/__zypper_repo/man.rst b/cdist/conf/type/__zypper_repo/man.rst index e3bc1d4f..9cc5e1c3 100644 --- a/cdist/conf/type/__zypper_repo/man.rst +++ b/cdist/conf/type/__zypper_repo/man.rst @@ -1,8 +1,9 @@ cdist-type__zypper_repo(7) ========================== -Repository management with zypper -Daniel Heule +NAME +---- +cdist-type__zypper_repo - Repository management with zypper DESCRIPTION @@ -59,9 +60,9 @@ EXAMPLES __zypper_repo testrepo4 --state disabled --repo_id 4 -SEE ALSO --------- -- `cdist-type(7) `_ +AUTHORS +------- +Daniel Heule COPYING diff --git a/cdist/conf/type/__zypper_service/man.rst b/cdist/conf/type/__zypper_service/man.rst index 377d30e1..c596dea0 100644 --- a/cdist/conf/type/__zypper_service/man.rst +++ b/cdist/conf/type/__zypper_service/man.rst @@ -1,8 +1,9 @@ cdist-type__zypper_service(7) ============================= -Service management with zypper -Daniel Heule +NAME +---- +cdist-type__zypper_service - Service management with zypper DESCRIPTION @@ -52,9 +53,9 @@ EXAMPLES __zypper_service INTERNAL_SLES11_SP3 --state absent --uri "http://path/to/your/ris/dir" -SEE ALSO --------- -- `cdist-type(7) `_ +AUTHORS +------- +Daniel Heule COPYING diff --git a/cdist/config.py b/cdist/config.py index f5e62ce1..5ebeab14 100644 --- a/cdist/config.py +++ b/cdist/config.py @@ -35,19 +35,21 @@ import cdist.exec.remote from cdist import core + class Config(object): """Cdist main class to hold arbitrary data""" def __init__(self, local, remote, dry_run=False): - self.local = local - self.remote = remote - self.log = logging.getLogger(self.local.target_host) - self.dry_run = dry_run + self.local = local + self.remote = remote + self.log = logging.getLogger(self.local.target_host) + self.dry_run = dry_run - self.explorer = core.Explorer(self.local.target_host, self.local, self.remote) + self.explorer = core.Explorer(self.local.target_host, self.local, + self.remote) self.manifest = core.Manifest(self.local.target_host, self.local) - self.code = core.Code(self.local.target_host, self.local, self.remote) + self.code = core.Code(self.local.target_host, self.local, self.remote) def _init_files_dirs(self): """Prepare files and directories for the run""" @@ -65,7 +67,7 @@ class Config(object): try: for host in fileinput.input(files=(source)): # remove leading and trailing whitespace - yield host.strip() + yield host.strip() except (IOError, OSError) as e: raise cdist.Error("Error reading hosts from \'{}\'".format( source)) @@ -74,7 +76,6 @@ class Config(object): for host in source: yield host - @classmethod def commandline(cls, args): """Configure remote system""" @@ -84,27 +85,29 @@ class Config(object): log = logging.getLogger("cdist") if args.manifest == '-' and args.hostfile == '-': - raise cdist.Error(("Cannot read both, manifest and host file, " - "from stdin")) + raise cdist.Error(("Cannot read both, manifest and host file, " + "from stdin")) # if no host source is specified then read hosts from stdin if not (args.hostfile or args.host): args.hostfile = '-' - + initial_manifest_tempfile = None if args.manifest == '-': # read initial manifest from stdin import tempfile try: - handle, initial_manifest_temp_path = tempfile.mkstemp(prefix='cdist.stdin.') + handle, initial_manifest_temp_path = tempfile.mkstemp( + prefix='cdist.stdin.') with os.fdopen(handle, 'w') as fd: fd.write(sys.stdin.read()) except (IOError, OSError) as e: - raise cdist.Error("Creating tempfile for stdin data failed: %s" % e) - + raise cdist.Error(("Creating tempfile for stdin data " + "failed: %s" % e)) + args.manifest = initial_manifest_temp_path import atexit atexit.register(lambda: os.remove(initial_manifest_temp_path)) - + process = {} failed_hosts = [] time_start = time.time() @@ -115,37 +118,38 @@ class Config(object): hostcnt += 1 if args.parallel: log.debug("Creating child process for %s", host) - process[host] = multiprocessing.Process(target=cls.onehost, args=(host, args, True)) + process[host] = multiprocessing.Process( + target=cls.onehost, args=(host, args, True)) process[host].start() else: try: cls.onehost(host, args, parallel=False) except cdist.Error as e: failed_hosts.append(host) - + # Catch errors in parallel mode when joining if args.parallel: for host in process.keys(): log.debug("Joining process %s", host) process[host].join() - + if not process[host].exitcode == 0: failed_hosts.append(host) - + time_end = time.time() log.info("Total processing time for %s host(s): %s", hostcnt, - (time_end - time_start)) - + (time_end - time_start)) + if len(failed_hosts) > 0: - raise cdist.Error("Failed to configure the following hosts: " + - " ".join(failed_hosts)) - + raise cdist.Error("Failed to configure the following hosts: " + + " ".join(failed_hosts)) + @classmethod def onehost(cls, host, args, parallel): """Configure ONE system""" log = logging.getLogger(host) - + try: local = cdist.exec.local.Local( target_host=host, @@ -157,10 +161,10 @@ class Config(object): target_host=host, remote_exec=args.remote_exec, remote_copy=args.remote_copy) - + c = cls(local, remote, dry_run=args.dry_run) c.run() - + except cdist.Error as e: log.error(e) if parallel: @@ -168,7 +172,7 @@ class Config(object): sys.exit(1) else: raise - + except KeyboardInterrupt: # Ignore in parallel mode, we are existing anyway if parallel: @@ -188,49 +192,50 @@ class Config(object): self.iterate_until_finished() self.local.save_cache() - self.log.info("Finished successful run in %s seconds", time.time() - start_time) - + self.log.info("Finished successful run in %s seconds", + time.time() - start_time) def object_list(self): """Short name for object list retrieval""" - for cdist_object in core.CdistObject.list_objects(self.local.object_path, - self.local.type_path, - self.local.object_marker_name): + for cdist_object in core.CdistObject.list_objects( + self.local.object_path, self.local.type_path, + self.local.object_marker_name): if cdist_object.cdist_type.is_install: - self.log.debug("Running in config mode, ignoring install object: {0}".format(cdist_object)) + self.log.debug(("Running in config mode, ignoring install " + "object: {0}").format(cdist_object)) else: yield cdist_object - def iterate_once(self): """ - Iterate over the objects once - helper method for + Iterate over the objects once - helper method for iterate_until_finished """ - objects_changed = False + objects_changed = False for cdist_object in self.object_list(): if cdist_object.requirements_unfinished(cdist_object.requirements): """We cannot do anything for this poor object""" continue - + if cdist_object.state == core.CdistObject.STATE_UNDEF: """Prepare the virgin object""" - + self.object_prepare(cdist_object) objects_changed = True - + if cdist_object.requirements_unfinished(cdist_object.autorequire): - """The previous step created objects we depend on - wait for them""" + """The previous step created objects we depend on - + wait for them + """ continue - + if cdist_object.state == core.CdistObject.STATE_PREPARED: self.object_run(cdist_object) objects_changed = True return objects_changed - def iterate_until_finished(self): """ Go through all objects and solve them @@ -256,22 +261,32 @@ class Config(object): requirement_names = [] autorequire_names = [] - for requirement in cdist_object.requirements_unfinished(cdist_object.requirements): + for requirement in cdist_object.requirements_unfinished( + cdist_object.requirements): requirement_names.append(requirement.name) - for requirement in cdist_object.requirements_unfinished(cdist_object.autorequire): + for requirement in cdist_object.requirements_unfinished( + cdist_object.autorequire): autorequire_names.append(requirement.name) requirements = "\n ".join(requirement_names) - autorequire = "\n ".join(autorequire_names) - info_string.append("%s requires:\n %s\n%s autorequires:\n %s" % (cdist_object.name, requirements, cdist_object.name, autorequire)) + autorequire = "\n ".join(autorequire_names) + info_string.append(("%s requires:\n" + " %s\n" + "%s ""autorequires:\n" + " %s" % ( + cdist_object.name, + requirements, cdist_object.name, + autorequire))) - raise cdist.UnresolvableRequirementsError("The requirements of the following objects could not be resolved:\n%s" % - ("\n".join(info_string))) + raise cdist.UnresolvableRequirementsError( + ("The requirements of the following objects could not be " + "resolved:\n%s") % ("\n".join(info_string))) def object_prepare(self, cdist_object): """Prepare object: Run type explorer + manifest""" - self.log.info("Running manifest and explorers for " + cdist_object.name) + self.log.info( + "Running manifest and explorers for " + cdist_object.name) self.explorer.run_type_explorers(cdist_object) self.manifest.run_type_manifest(cdist_object) cdist_object.state = core.CdistObject.STATE_PREPARED @@ -281,7 +296,8 @@ class Config(object): self.log.debug("Trying to run object %s" % (cdist_object.name)) if cdist_object.state == core.CdistObject.STATE_DONE: - raise cdist.Error("Attempting to run an already finished object: %s", cdist_object) + raise cdist.Error(("Attempting to run an already finished " + "object: %s"), cdist_object) cdist_type = cdist_object.cdist_type @@ -304,7 +320,6 @@ class Config(object): else: self.log.info("Skipping code execution due to DRY RUN") - # Mark this object as done self.log.debug("Finishing run of " + cdist_object.name) cdist_object.state = core.CdistObject.STATE_DONE diff --git a/cdist/core/__init__.py b/cdist/core/__init__.py index d773fc01..41e00a3a 100644 --- a/cdist/core/__init__.py +++ b/cdist/core/__init__.py @@ -20,10 +20,10 @@ # # -from cdist.core.cdist_type import CdistType -from cdist.core.cdist_type import NoSuchTypeError -from cdist.core.cdist_object import CdistObject -from cdist.core.cdist_object import IllegalObjectIdError -from cdist.core.explorer import Explorer -from cdist.core.manifest import Manifest -from cdist.core.code import Code +from cdist.core.cdist_type import CdistType +from cdist.core.cdist_type import NoSuchTypeError +from cdist.core.cdist_object import CdistObject +from cdist.core.cdist_object import IllegalObjectIdError +from cdist.core.explorer import Explorer +from cdist.core.manifest import Manifest +from cdist.core.code import Code diff --git a/cdist/core/cdist_object.py b/cdist/core/cdist_object.py index 8c6ee9c9..262db8bf 100644 --- a/cdist/core/cdist_object.py +++ b/cdist/core/cdist_object.py @@ -32,6 +32,7 @@ from cdist.util import fsproperty log = logging.getLogger(__name__) + class IllegalObjectIdError(cdist.Error): def __init__(self, object_id, message=None): self.object_id = object_id @@ -40,14 +41,17 @@ class IllegalObjectIdError(cdist.Error): def __str__(self): return '%s: %s' % (self.message, self.object_id) + class MissingObjectIdError(cdist.Error): def __init__(self, type_name): self.type_name = type_name - self.message = "Type %s requires object id (is not a singleton type)" % self.type_name + self.message = ("Type %s requires object id (is not a " + "singleton type)") % self.type_name def __str__(self): return '%s' % (self.message) + class CdistObject(object): """Represents a cdist object. @@ -64,7 +68,7 @@ class CdistObject(object): STATE_DONE = "done" def __init__(self, cdist_type, base_path, object_marker, object_id): - self.cdist_type = cdist_type # instance of Type + self.cdist_type = cdist_type # instance of Type self.base_path = base_path self.object_id = object_id @@ -74,7 +78,8 @@ class CdistObject(object): self.sanitise_object_id() self.name = self.join_name(self.cdist_type.name, self.object_id) - self.path = os.path.join(self.cdist_type.path, self.object_id, self.object_marker) + self.path = os.path.join(self.cdist_type.path, self.object_id, + self.object_marker) self.absolute_path = os.path.join(self.base_path, self.path) self.code_local_path = os.path.join(self.path, "code-local") @@ -84,12 +89,13 @@ class CdistObject(object): @classmethod def list_objects(cls, object_base_path, type_base_path, object_marker): """Return a list of object instances""" - for object_name in cls.list_object_names(object_base_path, object_marker): + for object_name in cls.list_object_names( + object_base_path, object_marker): type_name, object_id = cls.split_name(object_name) yield cls(cdist.core.CdistType(type_base_path, type_name), - base_path=object_base_path, - object_marker=object_marker, - object_id=object_id) + base_path=object_base_path, + object_marker=object_marker, + object_id=object_id) @classmethod def list_object_names(cls, object_base_path, object_marker): @@ -125,26 +131,34 @@ class CdistObject(object): def validate_object_id(self): if self.cdist_type.is_singleton and self.object_id: - raise IllegalObjectIdError('singleton objects can\'t have a object_id') + raise IllegalObjectIdError(('singleton objects can\'t have an ' + 'object_id')) - """Validate the given object_id and raise IllegalObjectIdError if it's not valid. + """Validate the given object_id and raise IllegalObjectIdError + if it's not valid. """ if self.object_id: if self.object_marker in self.object_id.split(os.sep): - raise IllegalObjectIdError(self.object_id, 'object_id may not contain \'%s\'' % self.object_marker) + raise IllegalObjectIdError( + self.object_id, ('object_id may not contain ' + '\'%s\'') % self.object_marker) if '//' in self.object_id: - raise IllegalObjectIdError(self.object_id, 'object_id may not contain //') + raise IllegalObjectIdError( + self.object_id, 'object_id may not contain //') if self.object_id == '.': - raise IllegalObjectIdError(self.object_id, 'object_id may not be a .') + raise IllegalObjectIdError( + self.object_id, 'object_id may not be a .') # If no object_id and type is not singleton => error out if not self.object_id and not self.cdist_type.is_singleton: raise MissingObjectIdError(self.cdist_type.name) - # Does not work: AttributeError: 'CdistObject' object has no attribute 'parameter_path' + # Does not work: + # AttributeError: + # 'CdistObject' object has no attribute 'parameter_path' - #"Type %s is not a singleton type - missing object id (parameters: %s)" % - # (self.cdist_type.name, self.parameters)) + # "Type %s is not a singleton type - missing object id + # (parameters: %s)" % (self.cdist_type.name, self.parameters)) def object_from_name(self, object_name): """Convenience method for creating an object instance from an object name. @@ -152,7 +166,8 @@ class CdistObject(object): Mainly intended to create objects when resolving requirements. e.g: - .object_from_name('__other/object') -> + .object_from_name('__other/object') -> + """ @@ -164,7 +179,8 @@ class CdistObject(object): cdist_type = self.cdist_type.__class__(type_path, type_name) - return self.__class__(cdist_type, base_path, object_marker, object_id=object_id) + return self.__class__(cdist_type, base_path, object_marker, + object_id=object_id) def __repr__(self): return '' % self.name @@ -172,7 +188,7 @@ class CdistObject(object): def __eq__(self, other): """define equality as 'name is the same'""" return self.name == other.name - + def __hash__(self): return hash(self.name) @@ -205,14 +221,22 @@ class CdistObject(object): # return relative path return os.path.join(self.path, "explorer") - requirements = fsproperty.FileListProperty(lambda obj: os.path.join(obj.absolute_path, 'require')) - autorequire = fsproperty.FileListProperty(lambda obj: os.path.join(obj.absolute_path, 'autorequire')) - parameters = fsproperty.DirectoryDictProperty(lambda obj: os.path.join(obj.base_path, obj.parameter_path)) - explorers = fsproperty.DirectoryDictProperty(lambda obj: os.path.join(obj.base_path, obj.explorer_path)) - state = fsproperty.FileStringProperty(lambda obj: os.path.join(obj.absolute_path, "state")) - source = fsproperty.FileListProperty(lambda obj: os.path.join(obj.absolute_path, "source")) - code_local = fsproperty.FileStringProperty(lambda obj: os.path.join(obj.base_path, obj.code_local_path)) - code_remote = fsproperty.FileStringProperty(lambda obj: os.path.join(obj.base_path, obj.code_remote_path)) + requirements = fsproperty.FileListProperty( + lambda obj: os.path.join(obj.absolute_path, 'require')) + autorequire = fsproperty.FileListProperty( + lambda obj: os.path.join(obj.absolute_path, 'autorequire')) + parameters = fsproperty.DirectoryDictProperty( + lambda obj: os.path.join(obj.base_path, obj.parameter_path)) + explorers = fsproperty.DirectoryDictProperty( + lambda obj: os.path.join(obj.base_path, obj.explorer_path)) + state = fsproperty.FileStringProperty( + lambda obj: os.path.join(obj.absolute_path, "state")) + source = fsproperty.FileListProperty( + lambda obj: os.path.join(obj.absolute_path, "source")) + code_local = fsproperty.FileStringProperty( + lambda obj: os.path.join(obj.base_path, obj.code_local_path)) + code_remote = fsproperty.FileStringProperty( + lambda obj: os.path.join(obj.base_path, obj.code_remote_path)) @property def exists(self): @@ -224,10 +248,12 @@ class CdistObject(object): """ try: os.makedirs(self.absolute_path, exist_ok=allow_overwrite) - absolute_parameter_path = os.path.join(self.base_path, self.parameter_path) + absolute_parameter_path = os.path.join(self.base_path, + self.parameter_path) 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)) + raise cdist.Error(('Error creating directories for cdist object: ' + '%s: %s') % (self, error)) def requirements_unfinished(self, requirements): """Return state whether requirements are satisfied""" diff --git a/cdist/core/cdist_type.py b/cdist/core/cdist_type.py index d5b4ea3e..a548f365 100644 --- a/cdist/core/cdist_type.py +++ b/cdist/core/cdist_type.py @@ -24,6 +24,7 @@ import os import cdist + class NoSuchTypeError(cdist.Error): def __init__(self, name, type_path, type_absolute_path): self.name = name @@ -31,7 +32,8 @@ class NoSuchTypeError(cdist.Error): self.type_absolute_path = type_absolute_path def __str__(self): - return "Type '%s' does not exist at %s" % (self.type_path, self.type_absolute_path) + return "Type '%s' does not exist at %s" % ( + self.type_path, self.type_absolute_path) class CdistType(object): @@ -75,13 +77,13 @@ class CdistType(object): """Return a list of type names""" return os.listdir(base_path) - _instances = {} + def __new__(cls, *args, **kwargs): """only one instance of each named type may exist""" # name is second argument name = args[1] - if not name in cls._instances: + if name not in cls._instances: instance = super(CdistType, cls).__new__(cls) cls._instances[name] = instance # return instance so __init__ is called @@ -103,7 +105,8 @@ class CdistType(object): @property def is_install(self): - """Check whether a type is used for installation (if not: for configuration)""" + """Check whether a type is used for installation + (if not: for configuration)""" return os.path.isfile(os.path.join(self.absolute_path, "install")) @property @@ -111,7 +114,8 @@ class CdistType(object): """Return a list of available explorers""" if not self.__explorers: try: - self.__explorers = os.listdir(os.path.join(self.absolute_path, "explorer")) + self.__explorers = os.listdir(os.path.join(self.absolute_path, + "explorer")) except EnvironmentError: # error ignored self.__explorers = [] @@ -123,7 +127,9 @@ class CdistType(object): if not self.__required_parameters: parameters = [] try: - with open(os.path.join(self.absolute_path, "parameter", "required")) as fd: + with open(os.path.join(self.absolute_path, + "parameter", + "required")) as fd: for line in fd: parameters.append(line.strip()) except EnvironmentError: @@ -139,7 +145,9 @@ class CdistType(object): if not self.__required_multiple_parameters: parameters = [] try: - with open(os.path.join(self.absolute_path, "parameter", "required_multiple")) as fd: + with open(os.path.join(self.absolute_path, + "parameter", + "required_multiple")) as fd: for line in fd: parameters.append(line.strip()) except EnvironmentError: @@ -155,7 +163,9 @@ class CdistType(object): if not self.__optional_parameters: parameters = [] try: - with open(os.path.join(self.absolute_path, "parameter", "optional")) as fd: + with open(os.path.join(self.absolute_path, + "parameter", + "optional")) as fd: for line in fd: parameters.append(line.strip()) except EnvironmentError: @@ -171,7 +181,9 @@ class CdistType(object): if not self.__optional_multiple_parameters: parameters = [] try: - with open(os.path.join(self.absolute_path, "parameter", "optional_multiple")) as fd: + with open(os.path.join(self.absolute_path, + "parameter", + "optional_multiple")) as fd: for line in fd: parameters.append(line.strip()) except EnvironmentError: @@ -187,7 +199,9 @@ class CdistType(object): if not self.__boolean_parameters: parameters = [] try: - with open(os.path.join(self.absolute_path, "parameter", "boolean")) as fd: + with open(os.path.join(self.absolute_path, + "parameter", + "boolean")) as fd: for line in fd: parameters.append(line.strip()) except EnvironmentError: @@ -202,7 +216,9 @@ class CdistType(object): if not self.__parameter_defaults: defaults = {} try: - defaults_dir = os.path.join(self.absolute_path, "parameter", "default") + defaults_dir = os.path.join(self.absolute_path, + "parameter", + "default") for name in os.listdir(defaults_dir): try: with open(os.path.join(defaults_dir, name)) as fd: diff --git a/cdist/core/code.py b/cdist/core/code.py index 5374bcdf..8e3cd63e 100644 --- a/cdist/core/code.py +++ b/cdist/core/code.py @@ -37,19 +37,22 @@ common: PATH: prepend directory with type emulator symlinks == local.bin_path __target_host: the target host we are working on __cdist_manifest: full qualified path of the manifest == script - __cdist_type_base_path: full qualified path to the directory where types are defined for use in type emulator - == local.type_path + __cdist_type_base_path: full qualified path to the directory where + types are defined for use in type emulator + == local.type_path gencode-local script: full qualified path to a types gencode-local env: __target_host: the target host we are working on - __global: full qualified path to the global output dir == local.out_path + __global: full qualified path to the global + output dir == local.out_path __object: full qualified path to the object's dir __object_id: the objects id __object_fq: full qualified object id, iow: $type.name + / + object_id __type: full qualified path to the type's dir + __files: full qualified path to the files dir returns: string containing the generated code or None @@ -58,11 +61,13 @@ gencode-remote env: __target_host: the target host we are working on - __global: full qualified path to the global output dir == local.out_path + __global: full qualified path to the global + output dir == local.out_path __object: full qualified path to the object's dir __object_id: the objects id __object_fq: full qualified object id, iow: $type.name + / + object_id __type: full qualified path to the type's dir + __files: full qualified path to the files dir returns: string containing the generated code or None @@ -91,11 +96,13 @@ class Code(object): self.env = { '__target_host': self.target_host, '__global': self.local.base_path, + '__files': self.local.files_path, } def _run_gencode(self, cdist_object, which): cdist_type = cdist_object.cdist_type - script = os.path.join(self.local.type_path, getattr(cdist_type, 'gencode_%s_path' % which)) + script = os.path.join(self.local.type_path, + getattr(cdist_type, 'gencode_%s_path' % which)) if os.path.isfile(script): env = os.environ.copy() env.update(self.env) @@ -105,8 +112,9 @@ class Code(object): '__object_id': cdist_object.object_id, '__object_name': cdist_object.name, }) - message_prefix=cdist_object.name - return self.local.run_script(script, env=env, return_output=True, message_prefix=message_prefix) + message_prefix = cdist_object.name + return self.local.run_script(script, env=env, return_output=True, + message_prefix=message_prefix) def run_gencode_local(self, cdist_object): """Run the gencode-local script for the given cdist object.""" @@ -117,21 +125,26 @@ class Code(object): return self._run_gencode(cdist_object, 'remote') def transfer_code_remote(self, cdist_object): - """Transfer the code_remote script for the given object to the remote side.""" - source = os.path.join(self.local.object_path, cdist_object.code_remote_path) - destination = os.path.join(self.remote.object_path, cdist_object.code_remote_path) + """Transfer the code_remote script for the given object to the + remote side.""" + source = os.path.join(self.local.object_path, + cdist_object.code_remote_path) + destination = os.path.join(self.remote.object_path, + cdist_object.code_remote_path) # FIXME: BUG: do not create destination, but top level of destination! self.remote.mkdir(destination) self.remote.transfer(source, destination) def _run_code(self, cdist_object, which, env=None): which_exec = getattr(self, which) - script = os.path.join(which_exec.object_path, getattr(cdist_object, 'code_%s_path' % which)) + script = os.path.join(which_exec.object_path, + getattr(cdist_object, 'code_%s_path' % which)) return which_exec.run_script(script, env=env) def run_code_local(self, cdist_object): """Run the code-local script for the given cdist object.""" - # Put some env vars, to allow read only access to the parameters over $__object + # Put some env vars, to allow read only access to the parameters + # over $__object env = os.environ.copy() env.update(self.env) env.update({ @@ -141,10 +154,13 @@ class Code(object): return self._run_code(cdist_object, 'local', env=env) def run_code_remote(self, cdist_object): - """Run the code-remote script for the given cdist object on the remote side.""" - # Put some env vars, to allow read only access to the parameters over $__object which is already on the remote side + """Run the code-remote script for the given cdist object on the + remote side.""" + # Put some env vars, to allow read only access to the parameters + # over $__object which is already on the remote side env = { - '__object': os.path.join(self.remote.object_path, cdist_object.path), + '__object': os.path.join(self.remote.object_path, + cdist_object.path), '__object_id': cdist_object.object_id, } return self._run_code(cdist_object, 'remote', env=env) diff --git a/cdist/core/explorer.py b/cdist/core/explorer.py index 41851bd6..345f45ff 100644 --- a/cdist/core/explorer.py +++ b/cdist/core/explorer.py @@ -31,7 +31,8 @@ common: runs only remotely, needs local and remote to construct paths env: - __explorer: full qualified path to other global explorers on remote side + __explorer: full qualified path to other global explorers on + remote side -> remote.global_explorer_path a global explorer is: @@ -52,7 +53,8 @@ type explorer is: __object: full qualified path to the object's remote dir __object_id: the objects id __object_fq: full qualified object id, iow: $type.name + / + object_id - __type_explorer: full qualified path to the other type explorers on remote side + __type_explorer: full qualified path to the other type explorers on + remote side creates: nothing, returns output @@ -76,7 +78,7 @@ class Explorer(object): } self._type_explorers_transferred = [] - ### global + # global def list_global_explorer_names(self): """Return a list of global explorer names.""" @@ -98,15 +100,17 @@ class Explorer(object): def transfer_global_explorers(self): """Transfer the global explorers to the remote side.""" self.remote.mkdir(self.remote.global_explorer_path) - self.remote.transfer(self.local.global_explorer_path, self.remote.global_explorer_path) - self.remote.run(["chmod", "0700", "%s/*" % (self.remote.global_explorer_path)]) + self.remote.transfer(self.local.global_explorer_path, + self.remote.global_explorer_path) + self.remote.run(["chmod", "0700", + "%s/*" % (self.remote.global_explorer_path)]) def run_global_explorer(self, explorer): """Run the given global explorer and return it's output.""" script = os.path.join(self.remote.global_explorer_path, explorer) return self.remote.run_script(script, env=self.env, return_output=True) - ### type + # type def list_type_explorer_names(self, cdist_type): """Return a list of explorer names for the given type.""" @@ -121,37 +125,48 @@ class Explorer(object): in the object. """ - self.log.debug("Transfering type explorers for type: %s", cdist_object.cdist_type) + self.log.debug("Transfering type explorers for type: %s", + cdist_object.cdist_type) self.transfer_type_explorers(cdist_object.cdist_type) - self.log.debug("Transfering object parameters for object: %s", cdist_object.name) + self.log.debug("Transfering object parameters for object: %s", + cdist_object.name) self.transfer_object_parameters(cdist_object) for explorer in self.list_type_explorer_names(cdist_object.cdist_type): output = self.run_type_explorer(explorer, cdist_object) - self.log.debug("Running type explorer '%s' for object '%s'", explorer, cdist_object.name) + self.log.debug("Running type explorer '%s' for object '%s'", + explorer, cdist_object.name) cdist_object.explorers[explorer] = output def run_type_explorer(self, explorer, cdist_object): - """Run the given type explorer for the given object and return it's output.""" + """Run the given type explorer for the given object and return + it's output.""" cdist_type = cdist_object.cdist_type env = self.env.copy() env.update({ - '__object': os.path.join(self.remote.object_path, cdist_object.path), + '__object': os.path.join(self.remote.object_path, + cdist_object.path), '__object_id': cdist_object.object_id, '__object_name': cdist_object.name, '__object_fq': cdist_object.path, - '__type_explorer': os.path.join(self.remote.type_path, cdist_type.explorer_path) + '__type_explorer': os.path.join(self.remote.type_path, + cdist_type.explorer_path) }) - script = os.path.join(self.remote.type_path, cdist_type.explorer_path, explorer) + script = os.path.join(self.remote.type_path, cdist_type.explorer_path, + explorer) return self.remote.run_script(script, env=env, return_output=True) def transfer_type_explorers(self, cdist_type): - """Transfer the type explorers for the given type to the remote side.""" + """Transfer the type explorers for the given type to the + remote side.""" if cdist_type.explorers: if cdist_type.name in self._type_explorers_transferred: - self.log.debug("Skipping retransfer of type explorers for: %s", cdist_type) + self.log.debug("Skipping retransfer of type explorers for: %s", + cdist_type) else: - source = os.path.join(self.local.type_path, cdist_type.explorer_path) - destination = os.path.join(self.remote.type_path, cdist_type.explorer_path) + source = os.path.join(self.local.type_path, + cdist_type.explorer_path) + destination = os.path.join(self.remote.type_path, + cdist_type.explorer_path) self.remote.mkdir(destination) self.remote.transfer(source, destination) self.remote.run(["chmod", "0700", "%s/*" % (destination)]) @@ -160,7 +175,9 @@ class Explorer(object): def transfer_object_parameters(self, cdist_object): """Transfer the parameters for the given object to the remote side.""" if cdist_object.parameters: - source = os.path.join(self.local.object_path, cdist_object.parameter_path) - destination = os.path.join(self.remote.object_path, cdist_object.parameter_path) + source = os.path.join(self.local.object_path, + cdist_object.parameter_path) + destination = os.path.join(self.remote.object_path, + cdist_object.parameter_path) self.remote.mkdir(destination) self.remote.transfer(source, destination) diff --git a/cdist/core/manifest.py b/cdist/core/manifest.py index 240e57a1..ac322101 100644 --- a/cdist/core/manifest.py +++ b/cdist/core/manifest.py @@ -32,10 +32,13 @@ common: env: PATH: prepend directory with type emulator symlinks == local.bin_path __target_host: the target host we are working on - __global: full qualified path to the global output dir == local.out_path + __global: full qualified path to the global + output dir == local.out_path __cdist_manifest: full qualified path of the manifest == script - __cdist_type_base_path: full qualified path to the directory where types are defined for use in type emulator + __cdist_type_base_path: full qualified path to the directory where + types are defined for use in type emulator == local.type_path + __files: full qualified path to the files dir initial manifest is: script: full qualified path to the initial manifest @@ -57,6 +60,7 @@ type manifeste is: creates: new objects through type emulator ''' + class NoInitialManifestError(cdist.Error): """ Display missing initial manifest: @@ -71,7 +75,9 @@ class NoInitialManifestError(cdist.Error): if user_supplied: if os.path.islink(manifest_path): - self.message = "%s: %s -> %s" % (msg_header, manifest_path, os.path.realpath(manifest_path)) + self.message = "%s: %s -> %s" % ( + msg_header, manifest_path, + os.path.realpath(manifest_path)) else: self.message = "%s: %s" % (msg_header, manifest_path) else: @@ -93,13 +99,15 @@ class Manifest(object): self.env = { 'PATH': "%s:%s" % (self.local.bin_path, os.environ['PATH']), - '__cdist_type_base_path': self.local.type_path, # for use in type emulator + # for use in type emulator + '__cdist_type_base_path': self.local.type_path, '__global': self.local.base_path, '__target_host': self.target_host, + '__files': self.local.files_path, } - if self.log.getEffectiveLevel() == logging.DEBUG: - self.env.update({'__cdist_debug': "yes" }) + if self.log.getEffectiveLevel() == logging.DEBUG: + self.env.update({'__cdist_debug': "yes"}) def env_initial_manifest(self, initial_manifest): env = os.environ.copy() @@ -122,11 +130,14 @@ class Manifest(object): if not os.path.isfile(initial_manifest): raise NoInitialManifestError(initial_manifest, user_supplied) - message_prefix="initialmanifest" - self.local.run_script(initial_manifest, env=self.env_initial_manifest(initial_manifest), message_prefix=message_prefix) + message_prefix = "initialmanifest" + self.local.run_script(initial_manifest, + env=self.env_initial_manifest(initial_manifest), + message_prefix=message_prefix) def env_type_manifest(self, cdist_object): - type_manifest = os.path.join(self.local.type_path, cdist_object.cdist_type.manifest_path) + type_manifest = os.path.join(self.local.type_path, + cdist_object.cdist_type.manifest_path) env = os.environ.copy() env.update(self.env) env.update({ @@ -141,7 +152,10 @@ class Manifest(object): return env def run_type_manifest(self, cdist_object): - type_manifest = os.path.join(self.local.type_path, cdist_object.cdist_type.manifest_path) + type_manifest = os.path.join(self.local.type_path, + cdist_object.cdist_type.manifest_path) message_prefix = cdist_object.name if os.path.isfile(type_manifest): - self.local.run_script(type_manifest, env=self.env_type_manifest(cdist_object), message_prefix=message_prefix) + self.local.run_script(type_manifest, + env=self.env_type_manifest(cdist_object), + message_prefix=message_prefix) diff --git a/cdist/emulator.py b/cdist/emulator.py index 3f553412..58ab7389 100644 --- a/cdist/emulator.py +++ b/cdist/emulator.py @@ -29,10 +29,12 @@ import sys import cdist from cdist import core + class MissingRequiredEnvironmentVariableError(cdist.Error): def __init__(self, name): self.name = name - self.message = "Emulator requires the environment variable %s to be setup" % self.name + self.message = ("Emulator requires the environment variable %s to be " + "setup" % self.name) def __str__(self): return self.message @@ -41,7 +43,7 @@ class MissingRequiredEnvironmentVariableError(cdist.Error): class DefaultList(list): """Helper class to allow default values for optional_multiple parameters. - @see https://groups.google.com/forum/#!msg/comp.lang.python/sAUvkJEDpRc/RnRymrzJVDYJ + @see https://groups.google.com/forum/#!msg/comp.lang.python/sAUvkJEDpRc/RnRymrzJVDYJ """ def __copy__(self): return [] @@ -54,20 +56,20 @@ class DefaultList(list): class Emulator(object): def __init__(self, argv, stdin=sys.stdin.buffer, env=os.environ): - self.argv = argv - self.stdin = stdin - self.env = env + self.argv = argv + self.stdin = stdin + self.env = env - self.object_id = '' + self.object_id = '' try: - self.global_path = self.env['__global'] - self.target_host = self.env['__target_host'] + self.global_path = self.env['__global'] + self.target_host = self.env['__target_host'] # Internal variables - self.object_source = self.env['__cdist_manifest'] + self.object_source = self.env['__cdist_manifest'] self.type_base_path = self.env['__cdist_type_base_path'] - self.object_marker = self.env['__cdist_object_marker'] + self.object_marker = self.env['__cdist_object_marker'] except KeyError as e: raise MissingRequiredEnvironmentVariableError(e.args[0]) @@ -75,8 +77,8 @@ class Emulator(object): self.object_base_path = os.path.join(self.global_path, "object") self.typeorder_path = os.path.join(self.global_path, "typeorder") - self.type_name = os.path.basename(argv[0]) - self.cdist_type = core.CdistType(self.type_base_path, self.type_name) + self.type_name = os.path.basename(argv[0]) + self.cdist_type = core.CdistType(self.type_base_path, self.type_name) self.__init_log() @@ -88,7 +90,8 @@ class Emulator(object): self.save_stdin() self.record_requirements() self.record_auto_requirements() - self.log.debug("Finished %s %s" % (self.cdist_object.path, self.parameters)) + self.log.debug("Finished %s %s" % ( + self.cdist_object.path, self.parameters)) def __init_log(self): """Setup logging facility""" @@ -98,30 +101,38 @@ class Emulator(object): else: logging.root.setLevel(logging.INFO) - self.log = logging.getLogger(self.target_host) + self.log = logging.getLogger(self.target_host) def commandline(self): """Parse command line""" - parser = argparse.ArgumentParser(add_help=False, argument_default=argparse.SUPPRESS) + parser = argparse.ArgumentParser(add_help=False, + argument_default=argparse.SUPPRESS) for parameter in self.cdist_type.required_parameters: argument = "--" + parameter - parser.add_argument(argument, dest=parameter, action='store', required=True) + parser.add_argument(argument, dest=parameter, action='store', + required=True) for parameter in self.cdist_type.required_multiple_parameters: argument = "--" + parameter - parser.add_argument(argument, dest=parameter, action='append', required=True) + parser.add_argument(argument, dest=parameter, action='append', + required=True) for parameter in self.cdist_type.optional_parameters: argument = "--" + parameter - parser.add_argument(argument, dest=parameter, action='store', required=False, - default=self.cdist_type.parameter_defaults.get(parameter, None)) + default = self.cdist_type.parameter_defaults.get(parameter, None) + parser.add_argument(argument, dest=parameter, action='store', + required=False, default=default) for parameter in self.cdist_type.optional_multiple_parameters: argument = "--" + parameter - parser.add_argument(argument, dest=parameter, action='append', required=False, - default=DefaultList.create(self.cdist_type.parameter_defaults.get(parameter, None))) + default = DefaultList.create( + self.cdist_type.parameter_defaults.get( + parameter, None)) + parser.add_argument(argument, dest=parameter, action='append', + required=False, default=default) for parameter in self.cdist_type.boolean_parameters: argument = "--" + parameter - parser.add_argument(argument, dest=parameter, action='store_const', const='') + parser.add_argument(argument, dest=parameter, + action='store_const', const='') # If not singleton support one positional parameter if not self.cdist_type.is_singleton: @@ -140,23 +151,33 @@ class Emulator(object): del self.args.object_id # Instantiate the cdist object we are defining - self.cdist_object = core.CdistObject(self.cdist_type, - self.object_base_path, self.object_marker, self.object_id) + self.cdist_object = core.CdistObject( + self.cdist_type, self.object_base_path, self.object_marker, + self.object_id) # Create object with given parameters self.parameters = {} - for key,value in vars(self.args).items(): + for key, value in vars(self.args).items(): if value is not None: self.parameters[key] = value - if self.cdist_object.exists and not 'CDIST_OVERRIDE' in self.env: + if self.cdist_object.exists and 'CDIST_OVERRIDE' not in self.env: + # make existing requirements a set, so we can compare it + # later with new requirements 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) - ) + errmsg = ("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)) + self.log.error(errmsg) + raise cdist.Error(errmsg) else: if self.cdist_object.exists: - self.log.debug('Object %s override forced with CDIST_OVERRIDE',self.cdist_object.name) + self.log.debug(('Object %s override forced with ' + 'CDIST_OVERRIDE'), self.cdist_object.name) self.cdist_object.create(True) else: self.cdist_object.create() @@ -169,6 +190,7 @@ class Emulator(object): self.cdist_object.source.append(self.object_source) chunk_size = 65536 + def _read_stdin(self): return self.stdin.read(self.chunk_size) @@ -190,11 +212,41 @@ class Emulator(object): except EnvironmentError as e: raise cdist.Error('Failed to read from stdin: %s' % e) + def record_requirement(self, requirement): + """record requirement and return recorded requirement""" + + # Raises an error, if object cannot be created + 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. 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) + + # Save the sanitised version, not the user supplied one + # (__file//bar => __file/bar) + # This ensures pattern matching is done against sanitised list + self.cdist_object.requirements.append(cdist_object.name) + + return cdist_object.name + def record_requirements(self): """record requirements""" - # Inject the predecessor, but not if its an override (this would leed to an circular dependency) - if "CDIST_ORDER_DEPENDENCY" in self.env and not 'CDIST_OVERRIDE' in self.env: + # Inject the predecessor, but not if its an override + # (this would leed to an circular dependency) + if ("CDIST_ORDER_DEPENDENCY" in self.env and + 'CDIST_OVERRIDE' not in self.env): # load object name created bevor this one from typeorder file ... with open(self.typeorder_path, 'r') as typecreationfile: typecreationorder = typecreationfile.readlines() @@ -205,48 +257,38 @@ class Emulator(object): self.env['require'] += " " + lastcreatedtype else: self.env['require'] = lastcreatedtype - self.log.debug("Injecting require for CDIST_ORDER_DEPENDENCY: %s for %s", lastcreatedtype, self.cdist_object.name) + self.log.debug(("Injecting require for " + "CDIST_ORDER_DEPENDENCY: %s for %s"), + lastcreatedtype, self.cdist_object.name) except IndexError: - # if no second last line, we are on the first type, so do not set a requirement + # if no second last line, we are on the first type, + # so do not set a requirement pass - if "require" in self.env: requirements = self.env['require'] self.log.debug("reqs = " + requirements) for requirement in requirements.split(" "): # Ignore empty fields - probably the only field anyway - if len(requirement) == 0: continue - - # Raises an error, if object cannot be created - 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. 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) - - # Save the sanitised version, not the user supplied one - # (__file//bar => __file/bar) - # This ensures pattern matching is done against sanitised list - self.cdist_object.requirements.append(cdist_object.name) + if len(requirement) == 0: + continue + self.record_requirement(requirement) def record_auto_requirements(self): - """An object shall automatically depend on all objects that it defined in it's type manifest. + """An object shall automatically depend on all objects that it + defined in it's type manifest. """ - # __object_name is the name of the object whose type manifest is currently executed + # __object_name is the name of the object whose type manifest is + # currently executed __object_name = self.env.get('__object_name', None) if __object_name: # The object whose type manifest is currently run parent = self.cdist_object.object_from_name(__object_name) # The object currently being defined current_object = self.cdist_object - # As parent defined current_object it shall automatically depend on it. + # As parent defined current_object it shall automatically + # depend on it. # But only if the user hasn't said otherwise. # Must prevent circular dependencies. - if not parent.name in current_object.requirements: + if parent.name not in current_object.requirements: parent.autorequire.append(current_object.name) diff --git a/cdist/exec/local.py b/cdist/exec/local.py index 64593235..cc905751 100644 --- a/cdist/exec/local.py +++ b/cdist/exec/local.py @@ -34,6 +34,10 @@ import hashlib import cdist import cdist.message from cdist import core +import cdist.exec.util as exec_util + +CONF_SUBDIRS_LINKED = ["explorer", "files", "manifest", "type", ] + class Local(object): """Execute commands locally. @@ -82,7 +86,8 @@ class Local(object): @property def dist_conf_dir(self): - return os.path.abspath(os.path.join(os.path.dirname(cdist.__file__), "conf")) + return os.path.abspath(os.path.join(os.path.dirname(cdist.__file__), + "conf")) @property def home_dir(self): @@ -107,15 +112,17 @@ class Local(object): # Depending on out_path self.bin_path = os.path.join(self.base_path, "bin") self.conf_path = os.path.join(self.base_path, "conf") - self.global_explorer_out_path = os.path.join(self.base_path, "explorer") + self.global_explorer_out_path = os.path.join(self.base_path, + "explorer") self.object_path = os.path.join(self.base_path, "object") self.messages_path = os.path.join(self.base_path, "messages") + self.files_path = os.path.join(self.conf_path, "files") # Depending on conf_path self.global_explorer_path = os.path.join(self.conf_path, "explorer") self.manifest_path = os.path.join(self.conf_path, "manifest") self.initial_manifest = (self.custom_initial_manifest or - os.path.join(self.manifest_path, "init")) + os.path.join(self.manifest_path, "init")) self.type_path = os.path.join(self.conf_path, "type") @@ -161,8 +168,8 @@ class Local(object): with open(self.object_marker_file, 'w') as fd: fd.write("%s\n" % self.object_marker_name) - self.log.debug("Object marker %s saved in %s" % (self.object_marker_name, self.object_marker_file)) - + self.log.debug("Object marker %s saved in %s" % ( + self.object_marker_name, self.object_marker_file)) def _init_cache_dir(self, cache_dir): if cache_dir: @@ -171,7 +178,8 @@ class Local(object): if self.home_dir: self.cache_path = os.path.join(self.home_dir, "cache") else: - raise cdist.Error("No homedir setup and no cache dir location given") + raise cdist.Error( + "No homedir setup and no cache dir location given") def rmdir(self, path): """Remove directory on the local side.""" @@ -189,7 +197,8 @@ class Local(object): """ self.log.debug("Local run: %s", command) - assert isinstance(command, (list, tuple)), "list or tuple argument expected, got: %s" % command + assert isinstance(command, (list, tuple)), ( + "list or tuple argument expected, got: %s" % command) if env is None: env = os.environ.copy() @@ -204,28 +213,30 @@ class Local(object): env.update(message.env) try: + output, errout = exec_util.call_get_output(command, env=env) + self.log.debug("Local stdout: {}".format(output)) + self.log.debug("Local stderr: {}".format(errout)) if return_output: - return subprocess.check_output(command, env=env).decode() - else: - subprocess.check_call(command, env=env) - except subprocess.CalledProcessError: - raise cdist.Error("Command failed: " + " ".join(command)) + return output.decode() + except subprocess.CalledProcessError as e: + exec_util.handle_called_process_error(e, command) except OSError as error: raise cdist.Error(" ".join(command) + ": " + error.args[1]) finally: if message_prefix: message.merge_messages() - def run_script(self, script, env=None, return_output=False, message_prefix=None): + def run_script(self, script, env=None, return_output=False, + message_prefix=None): """Run the given script with the given environment. Return the output as a string. """ - command = [ os.environ.get('CDIST_LOCAL_SHELL',"/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) - + return self.run(command=command, env=env, return_output=return_output, + message_prefix=message_prefix) def save_cache(self): destination = os.path.join(self.cache_path, self.target_host) @@ -235,7 +246,8 @@ class Local(object): if os.path.exists(destination): shutil.rmtree(destination) except PermissionError as e: - raise cdist.Error("Cannot delete old cache %s: %s" % (destination, e)) + raise cdist.Error( + "Cannot delete old cache %s: %s" % (destination, e)) shutil.move(self.base_path, destination) @@ -245,14 +257,14 @@ class Local(object): pass def _create_conf_path_and_link_conf_dirs(self): - # Link destination directories - for sub_dir in [ "explorer", "manifest", "type" ]: + # Create destination directories + for sub_dir in CONF_SUBDIRS_LINKED: self.mkdir(os.path.join(self.conf_path, sub_dir)) # Iterate over all directories and link the to the output dir for conf_dir in self.conf_dirs: self.log.debug("Checking conf_dir %s ..." % (conf_dir)) - for sub_dir in [ "explorer", "manifest", "type" ]: + for sub_dir in CONF_SUBDIRS_LINKED: current_dir = os.path.join(conf_dir, sub_dir) # Allow conf dirs to contain only partial content @@ -261,18 +273,21 @@ class Local(object): for entry in os.listdir(current_dir): rel_entry_path = os.path.join(sub_dir, entry) - src = os.path.abspath(os.path.join(conf_dir, sub_dir, entry)) + src = os.path.abspath(os.path.join(conf_dir, + sub_dir, + entry)) dst = os.path.join(self.conf_path, sub_dir, entry) # Already exists? remove and link if os.path.exists(dst): os.unlink(dst) - + self.log.debug("Linking %s to %s ..." % (src, dst)) try: os.symlink(src, dst) except OSError as e: - raise cdist.Error("Linking %s %s to %s failed: %s" % (sub_dir, src, dst, e.__str__())) + raise cdist.Error("Linking %s %s to %s failed: %s" % ( + sub_dir, src, dst, e.__str__())) def _link_types_for_emulator(self): """Link emulator to types""" @@ -284,4 +299,6 @@ class Local(object): try: os.symlink(src, dst) except OSError as e: - raise cdist.Error("Linking emulator from %s to %s failed: %s" % (src, dst, e.__str__())) + raise cdist.Error( + "Linking emulator from %s to %s failed: %s" % ( + src, dst, e.__str__())) diff --git a/cdist/exec/remote.py b/cdist/exec/remote.py index 77e2c8be..ff388e1d 100644 --- a/cdist/exec/remote.py +++ b/cdist/exec/remote.py @@ -26,9 +26,11 @@ import sys import glob import subprocess import logging +import cdist.exec.util as exec_util import cdist + class DecodeError(cdist.Error): def __init__(self, command): self.command = command @@ -74,7 +76,6 @@ class Remote(object): os.environ['__remote_copy'] = self._copy os.environ['__remote_exec'] = self._exec - def create_files_dirs(self): self.rmdir(self.base_path) self.mkdir(self.base_path) @@ -100,11 +101,13 @@ class Remote(object): for f in glob.glob1(source, '*'): command = self._copy.split() path = os.path.join(source, f) - command.extend([path, '{0}:{1}'.format(self.target_host, destination)]) + command.extend([path, '{0}:{1}'.format( + self.target_host, destination)]) self._run_command(command) else: command = self._copy.split() - command.extend([source, '{0}:{1}'.format(self.target_host, destination)]) + command.extend([source, '{0}:{1}'.format( + self.target_host, destination)]) self._run_command(command) def run_script(self, script, env=None, return_output=False): @@ -113,7 +116,7 @@ class Remote(object): """ - command = [ os.environ.get('CDIST_REMOTE_SHELL',"/bin/sh") , "-e"] + command = [os.environ.get('CDIST_REMOTE_SHELL', "/bin/sh"), "-e"] command.append(script) return self.run(command, env, return_output) @@ -147,8 +150,8 @@ class Remote(object): # /bin/csh will execute this script in the right way. if env: remote_env = [" export %s=%s;" % item for item in env.items()] - string_cmd = ("/bin/sh -c '" + " ".join(remote_env) - + " ".join(command) + "'") + string_cmd = ("/bin/sh -c '" + " ".join(remote_env) + + " ".join(command) + "'") cmd.append(string_cmd) else: cmd.extend(command) @@ -159,7 +162,8 @@ class Remote(object): Return the output as a string. """ - assert isinstance(command, (list, tuple)), "list or tuple argument expected, got: %s" % command + assert isinstance(command, (list, tuple)), ( + "list or tuple argument expected, got: %s" % command) # export target_host for use in __remote_{exec,copy} scripts os_environ = os.environ.copy() @@ -167,12 +171,13 @@ class Remote(object): self.log.debug("Remote run: %s", command) try: + output, errout = exec_util.call_get_output(command, env=os_environ) + self.log.debug("Remote stdout: {}".format(output)) + self.log.debug("Remote stderr: {}".format(errout)) if return_output: - return subprocess.check_output(command, env=os_environ).decode() - else: - subprocess.check_call(command, env=os_environ) - except subprocess.CalledProcessError: - raise cdist.Error("Command failed: " + " ".join(command)) + return output.decode() + except subprocess.CalledProcessError as e: + exec_util.handle_called_process_error(e, command) except OSError as error: raise cdist.Error(" ".join(command) + ": " + error.args[1]) except UnicodeDecodeError: diff --git a/cdist/exec/util.py b/cdist/exec/util.py new file mode 100644 index 00000000..6e04523b --- /dev/null +++ b/cdist/exec/util.py @@ -0,0 +1,84 @@ +# -*- coding: utf-8 -*- +# +# 2016 Darko Poljak (darko.poljak at gmail.com) +# +# 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 . +# +# + +import subprocess +import sys +from tempfile import TemporaryFile + +import cdist + +STDERR_UNSUPPORTED = '' + + +def call_get_output(command, env=None): + """Run the given command with the given environment. + Return the tuple of stdout and stderr output as a byte strings. + """ + + assert isinstance(command, (list, tuple)), ( + "list or tuple argument expected, got: {}".format(command)) + + if sys.version_info >= (3, 5): + return call_get_out_err(command, env) + else: + return (call_get_stdout(command, env), STDERR_UNSUPPORTED) + + +def handle_called_process_error(err, command): + if sys.version_info >= (3, 5): + errout = err.stderr + else: + errout = STDERR_UNSUPPORTED + raise cdist.Error("Command failed: " + " ".join(command) + + " with returncode: {} and stdout: {}, stderr: {}".format( + err.returncode, err.output, errout)) + + +def call_get_stdout(command, env=None): + """Run the given command with the given environment. + Return the stdout output as a byte string, stderr is ignored. + """ + assert isinstance(command, (list, tuple)), ( + "list or tuple argument expected, got: {}".format(command)) + + with TemporaryFile() as fout: + subprocess.check_call(command, env=env, stdout=fout) + fout.seek(0) + output = fout.read() + + return output + + +def call_get_out_err(command, env=None): + """Run the given command with the given environment. + Return the tuple of stdout and stderr output as a byte strings. + """ + assert isinstance(command, (list, tuple)), ( + "list or tuple argument expected, got: {}".format(command)) + + with TemporaryFile() as fout, TemporaryFile() as ferr: + subprocess.check_call(command, env=env, + stdout=fout, stderr=ferr) + fout.seek(0) + ferr.seek(0) + output = (fout.read(), ferr.read()) + + return output diff --git a/cdist/log.py b/cdist/log.py index 8c3aac79..2341c282 100644 --- a/cdist/log.py +++ b/cdist/log.py @@ -22,6 +22,7 @@ import logging + class Log(logging.Logger): def __init__(self, name): diff --git a/cdist/message.py b/cdist/message.py index f9b0c313..98a6e8cf 100644 --- a/cdist/message.py +++ b/cdist/message.py @@ -37,8 +37,9 @@ class Message(object): self.prefix = prefix self.global_messages = messages - in_fd, self.messages_in = tempfile.mkstemp(suffix='.cdist_message_in') - out_fd, self.messages_out = tempfile.mkstemp(suffix='.cdist_message_out') + in_fd, self.messages_in = tempfile.mkstemp(suffix='.cdist_message_in') + out_fd, self.messages_out = tempfile.mkstemp( + suffix='.cdist_message_out') os.close(in_fd) os.close(out_fd) @@ -48,7 +49,7 @@ class Message(object): @property def env(self): env = {} - env['__messages_in'] = self.messages_in + env['__messages_in'] = self.messages_in env['__messages_out'] = self.messages_out return env diff --git a/cdist/shell.py b/cdist/shell.py index d0921bc9..60faa2f8 100644 --- a/cdist/shell.py +++ b/cdist/shell.py @@ -31,8 +31,9 @@ import cdist.config log = logging.getLogger(__name__) + class Shell(object): - + def __init__(self, shell=None): self.shell = shell @@ -45,21 +46,23 @@ class Shell(object): """Select shell to execute, if not specified by user""" if not self.shell: - self.shell = os.environ.get('SHELL',"/bin/sh") + self.shell = os.environ.get('SHELL', "/bin/sh") def _init_files_dirs(self): self.local.create_files_dirs() def _init_environment(self): self.env = os.environ.copy() - additional_env = { + additional_env = { 'PATH': "%s:%s" % (self.local.bin_path, os.environ['PATH']), - '__cdist_type_base_path': self.local.type_path, # for use in type emulator + # for use in type emulator + '__cdist_type_base_path': self.local.type_path, '__cdist_manifest': "cdist shell", '__global': self.local.base_path, '__target_host': self.target_host, '__manifest': self.local.manifest_path, '__explorer': self.local.global_explorer_path, + '__files': self.local.files_path, } self.env.update(additional_env) diff --git a/cdist/sphinxext/__init__.py b/cdist/sphinxext/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/cdist/sphinxext/manpage.py b/cdist/sphinxext/manpage.py new file mode 100644 index 00000000..97b41f03 --- /dev/null +++ b/cdist/sphinxext/manpage.py @@ -0,0 +1,82 @@ +import sphinx.builders.manpage +import sphinx.writers.manpage +from docutils.frontend import OptionParser +from sphinx.util.console import bold, darkgreen +from six import string_types +from docutils.io import FileOutput +from os import path +from sphinx.util.nodes import inline_all_toctrees +from sphinx import addnodes + +""" + Extension based on sphinx builtin manpage. + It does not write its own .SH NAME based on config, + but leaves everything to actual reStructuredText file content. +""" + + +class ManualPageTranslator(sphinx.writers.manpage.ManualPageTranslator): + + def header(self): + tmpl = (".TH \"%(title_upper)s\" \"%(manual_section)s\"" + " \"%(date)s\" \"%(version)s\" \"%(manual_group)s\"\n") + return tmpl % self._docinfo + + +class ManualPageWriter(sphinx.writers.manpage.ManualPageWriter): + + def __init__(self, builder): + super().__init__(builder) + self.translator_class = ( + self.builder.translator_class or ManualPageTranslator) + + +class ManualPageBuilder(sphinx.builders.manpage.ManualPageBuilder): + + name = 'cman' + + def write(self, *ignored): + docwriter = ManualPageWriter(self) + docsettings = OptionParser( + defaults=self.env.settings, + components=(docwriter,), + read_config_files=True).get_default_values() + + self.info(bold('writing... '), nonl=True) + + for info in self.config.man_pages: + docname, name, description, authors, section = info + if isinstance(authors, string_types): + if authors: + authors = [authors] + else: + authors = [] + + targetname = '%s.%s' % (name, section) + self.info(darkgreen(targetname) + ' { ', nonl=True) + destination = FileOutput( + destination_path=path.join(self.outdir, targetname), + encoding='utf-8') + + tree = self.env.get_doctree(docname) + docnames = set() + largetree = inline_all_toctrees(self, docnames, docname, tree, + darkgreen, [docname]) + self.info('} ', nonl=True) + self.env.resolve_references(largetree, docname, self) + # remove pending_xref nodes + for pendingnode in largetree.traverse(addnodes.pending_xref): + pendingnode.replace_self(pendingnode.children) + + largetree.settings = docsettings + largetree.settings.title = name + largetree.settings.subtitle = description + largetree.settings.authors = authors + largetree.settings.section = section + + docwriter.write(largetree, destination) + self.info() + + +def setup(app): + app.add_builder(ManualPageBuilder) diff --git a/cdist/test/__init__.py b/cdist/test/__init__.py index ab767699..d9630f53 100644 --- a/cdist/test/__init__.py +++ b/cdist/test/__init__.py @@ -28,7 +28,9 @@ cdist_base_path = os.path.abspath( cdist_exec_path = os.path.join(cdist_base_path, "scripts/cdist") -global_fixtures_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), "fixtures")) +global_fixtures_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), + "fixtures")) + class CdistTestCase(unittest.TestCase): diff --git a/cdist/test/banner/__init__.py b/cdist/test/banner/__init__.py index 4b0ab6ac..957b7b12 100644 --- a/cdist/test/banner/__init__.py +++ b/cdist/test/banner/__init__.py @@ -27,6 +27,7 @@ import unittest import cdist import cdist.banner + class Banner(unittest.TestCase): def setUp(self): self.banner = cdist.BANNER + "\n" @@ -38,5 +39,5 @@ class Banner(unittest.TestCase): sys.stdout = output cdist.banner.banner(None) - + self.assertEqual(output.getvalue(), self.banner) diff --git a/cdist/test/cdist_object/__init__.py b/cdist/test/cdist_object/__init__.py index 9c075acb..d03c0642 100644 --- a/cdist/test/cdist_object/__init__.py +++ b/cdist/test/cdist_object/__init__.py @@ -57,29 +57,37 @@ class ObjectClassTestCase(test.CdistTestCase): self.expected_objects = [] for cdist_object_name in expected_object_names: cdist_type, cdist_object_id = cdist_object_name.split("/", 1) - cdist_object = core.CdistObject(core.CdistType(type_base_path, cdist_type), self.object_base_path, - OBJECT_MARKER_NAME, cdist_object_id) + cdist_object = core.CdistObject(core.CdistType(type_base_path, + cdist_type), + self.object_base_path, + OBJECT_MARKER_NAME, + cdist_object_id) cdist_object.create() self.expected_objects.append(cdist_object) - + def tearDown(self): shutil.rmtree(self.tempdir) def test_list_object_names(self): - found_object_names = sorted(list(core.CdistObject.list_object_names(self.object_base_path, OBJECT_MARKER_NAME))) - self.assertEqual(found_object_names, expected_object_names) + found_object_names = sorted(list(core.CdistObject.list_object_names( + self.object_base_path, OBJECT_MARKER_NAME))) + self.assertEqual(found_object_names, expected_object_names) def test_list_type_names(self): - type_names = list(cdist.core.CdistObject.list_type_names(self.object_base_path)) - self.assertEqual(sorted(type_names), ['__first', '__second', '__third']) + type_names = list(cdist.core.CdistObject.list_type_names( + self.object_base_path)) + self.assertEqual(sorted(type_names), + ['__first', '__second', '__third']) def test_list_objects(self): - found_objects = sorted(list(core.CdistObject.list_objects(self.object_base_path, type_base_path, OBJECT_MARKER_NAME))) + found_objects = sorted(list(core.CdistObject.list_objects( + self.object_base_path, type_base_path, OBJECT_MARKER_NAME))) self.assertEqual(found_objects, self.expected_objects) def test_create_singleton(self): """Check whether creating an object without id (singleton) works""" - singleton = self.expected_objects[0].object_from_name("__test_singleton") + singleton = self.expected_objects[0].object_from_name( + "__test_singleton") # came here - everything fine def test_create_singleton_not_singleton_type(self): @@ -88,6 +96,7 @@ class ObjectClassTestCase(test.CdistTestCase): with self.assertRaises(cdist.core.cdist_object.MissingObjectIdError): self.expected_objects[0].object_from_name("__first") + class ObjectIdTestCase(test.CdistTestCase): def setUp(self): @@ -97,11 +106,14 @@ class ObjectIdTestCase(test.CdistTestCase): self.expected_objects = [] for cdist_object_name in expected_object_names: cdist_type, cdist_object_id = cdist_object_name.split("/", 1) - cdist_object = core.CdistObject(core.CdistType(type_base_path, cdist_type), self.object_base_path, - OBJECT_MARKER_NAME, cdist_object_id) + cdist_object = core.CdistObject(core.CdistType(type_base_path, + cdist_type), + self.object_base_path, + OBJECT_MARKER_NAME, + cdist_object_id) cdist_object.create() self.expected_objects.append(cdist_object) - + def tearDown(self): shutil.rmtree(self.tempdir) @@ -109,31 +121,39 @@ class ObjectIdTestCase(test.CdistTestCase): cdist_type = core.CdistType(type_base_path, '__third') illegal_object_id = '/object_id//may/not/contain/double/slash' with self.assertRaises(core.IllegalObjectIdError): - core.CdistObject(cdist_type, self.object_base_path, OBJECT_MARKER_NAME, illegal_object_id) + core.CdistObject(cdist_type, self.object_base_path, + OBJECT_MARKER_NAME, illegal_object_id) def test_object_id_contains_object_marker(self): cdist_type = core.CdistType(type_base_path, '__third') - illegal_object_id = 'object_id/may/not/contain/%s/anywhere' % OBJECT_MARKER_NAME + illegal_object_id = ( + 'object_id/may/not/contain/%s/anywhere' % OBJECT_MARKER_NAME) with self.assertRaises(core.IllegalObjectIdError): - core.CdistObject(cdist_type, self.object_base_path, OBJECT_MARKER_NAME, illegal_object_id) + core.CdistObject(cdist_type, self.object_base_path, + OBJECT_MARKER_NAME, illegal_object_id) def test_object_id_contains_object_marker_string(self): cdist_type = core.CdistType(type_base_path, '__third') - illegal_object_id = 'object_id/may/contain_%s_in_filename' % OBJECT_MARKER_NAME - core.CdistObject(cdist_type, self.object_base_path, OBJECT_MARKER_NAME, illegal_object_id) + illegal_object_id = ( + 'object_id/may/contain_%s_in_filename' % OBJECT_MARKER_NAME) + core.CdistObject(cdist_type, self.object_base_path, + OBJECT_MARKER_NAME, illegal_object_id) # if we get here, the test passed def test_object_id_contains_only_dot(self): cdist_type = core.CdistType(type_base_path, '__third') illegal_object_id = '.' with self.assertRaises(core.IllegalObjectIdError): - core.CdistObject(cdist_type, self.object_base_path, OBJECT_MARKER_NAME, illegal_object_id) + core.CdistObject(cdist_type, self.object_base_path, + OBJECT_MARKER_NAME, illegal_object_id) def test_object_id_on_singleton_type(self): cdist_type = core.CdistType(type_base_path, '__test_singleton') illegal_object_id = 'object_id' with self.assertRaises(core.IllegalObjectIdError): - core.CdistObject(cdist_type, self.object_base_path, OBJECT_MARKER_NAME, illegal_object_id) + core.CdistObject(cdist_type, self.object_base_path, + OBJECT_MARKER_NAME, illegal_object_id) + class ObjectTestCase(test.CdistTestCase): @@ -142,13 +162,14 @@ class ObjectTestCase(test.CdistTestCase): self.object_base_path = self.tempdir self.cdist_type = core.CdistType(type_base_path, '__third') - self.cdist_object = core.CdistObject(self.cdist_type, self.object_base_path, OBJECT_MARKER_NAME, 'moon') + self.cdist_object = core.CdistObject(self.cdist_type, + self.object_base_path, + OBJECT_MARKER_NAME, 'moon') self.cdist_object.create() self.cdist_object.parameters['planet'] = 'Saturn' self.cdist_object.parameters['name'] = 'Prometheus' - def tearDown(self): self.cdist_object.prepared = False self.cdist_object.ran = False @@ -166,22 +187,29 @@ class ObjectTestCase(test.CdistTestCase): self.assertEqual(self.cdist_object.object_id, 'moon') def test_path(self): - self.assertEqual(self.cdist_object.path, "__third/moon/%s" % OBJECT_MARKER_NAME) + self.assertEqual(self.cdist_object.path, + "__third/moon/%s" % OBJECT_MARKER_NAME) def test_absolute_path(self): - self.assertEqual(self.cdist_object.absolute_path, os.path.join(self.object_base_path, "__third/moon/%s" % OBJECT_MARKER_NAME)) + self.assertEqual(self.cdist_object.absolute_path, + os.path.join(self.object_base_path, + "__third/moon/%s" % OBJECT_MARKER_NAME)) def test_code_local_path(self): - self.assertEqual(self.cdist_object.code_local_path, "__third/moon/%s/code-local" % OBJECT_MARKER_NAME) + self.assertEqual(self.cdist_object.code_local_path, + "__third/moon/%s/code-local" % OBJECT_MARKER_NAME) def test_code_remote_path(self): - self.assertEqual(self.cdist_object.code_remote_path, "__third/moon/%s/code-remote" % OBJECT_MARKER_NAME) + self.assertEqual(self.cdist_object.code_remote_path, + "__third/moon/%s/code-remote" % OBJECT_MARKER_NAME) def test_parameter_path(self): - self.assertEqual(self.cdist_object.parameter_path, "__third/moon/%s/parameter" % OBJECT_MARKER_NAME) + self.assertEqual(self.cdist_object.parameter_path, + "__third/moon/%s/parameter" % OBJECT_MARKER_NAME) def test_explorer_path(self): - self.assertEqual(self.cdist_object.explorer_path, "__third/moon/%s/explorer" % OBJECT_MARKER_NAME) + self.assertEqual(self.cdist_object.explorer_path, + "__third/moon/%s/explorer" % OBJECT_MARKER_NAME) def test_parameters(self): expected_parameters = {'planet': 'Saturn', 'name': 'Prometheus'} @@ -190,32 +218,39 @@ class ObjectTestCase(test.CdistTestCase): def test_explorers(self): self.assertEqual(self.cdist_object.explorers, {}) - # FIXME: actually testing fsproperty.DirectoryDictProperty here, move to their own test case + # FIXME: actually testing fsproperty.DirectoryDictProperty here, + # move to their own test case def test_explorers_assign_dict(self): expected = {'first': 'foo', 'second': 'bar'} # when set, written to file self.cdist_object.explorers = expected - object_explorer_path = os.path.join(self.cdist_object.base_path, self.cdist_object.explorer_path) + object_explorer_path = os.path.join(self.cdist_object.base_path, + self.cdist_object.explorer_path) self.assertTrue(os.path.isdir(object_explorer_path)) # when accessed, read from file self.assertEqual(self.cdist_object.explorers, expected) # remove dynamically created folder self.cdist_object.explorers = {} - os.rmdir(os.path.join(self.cdist_object.base_path, self.cdist_object.explorer_path)) + os.rmdir(os.path.join(self.cdist_object.base_path, + self.cdist_object.explorer_path)) - # FIXME: actually testing fsproperty.DirectoryDictProperty here, move to their own test case + # FIXME: actually testing fsproperty.DirectoryDictProperty here, + # move to their own test case def test_explorers_assign_key_value(self): expected = {'first': 'foo', 'second': 'bar'} - object_explorer_path = os.path.join(self.cdist_object.base_path, self.cdist_object.explorer_path) - for key,value in expected.items(): + object_explorer_path = os.path.join(self.cdist_object.base_path, + self.cdist_object.explorer_path) + for key, value in expected.items(): # when set, written to file self.cdist_object.explorers[key] = value - self.assertTrue(os.path.isfile(os.path.join(object_explorer_path, key))) + self.assertTrue(os.path.isfile(os.path.join(object_explorer_path, + key))) # when accessed, read from file self.assertEqual(self.cdist_object.explorers, expected) # remove dynamically created folder self.cdist_object.explorers = {} - os.rmdir(os.path.join(self.cdist_object.base_path, self.cdist_object.explorer_path)) + os.rmdir(os.path.join(self.cdist_object.base_path, + self.cdist_object.explorer_path)) def test_requirements(self): expected = [] @@ -226,15 +261,18 @@ class ObjectTestCase(test.CdistTestCase): def test_state_prepared(self): self.cdist_object.state = core.CdistObject.STATE_PREPARED - self.assertEqual(self.cdist_object.state, core.CdistObject.STATE_PREPARED) + self.assertEqual(self.cdist_object.state, + core.CdistObject.STATE_PREPARED) def test_state_running(self): self.cdist_object.state = core.CdistObject.STATE_RUNNING - self.assertEqual(self.cdist_object.state, core.CdistObject.STATE_RUNNING) + self.assertEqual(self.cdist_object.state, + core.CdistObject.STATE_RUNNING) def test_state_done(self): self.cdist_object.state = core.CdistObject.STATE_DONE - self.assertEqual(self.cdist_object.state, core.CdistObject.STATE_DONE) + self.assertEqual(self.cdist_object.state, + core.CdistObject.STATE_DONE) def test_source(self): self.assertEqual(list(self.cdist_object.source), []) diff --git a/cdist/test/cdist_type/__init__.py b/cdist/test/cdist_type/__init__.py index ccbf6742..feb5fa15 100644 --- a/cdist/test/cdist_type/__init__.py +++ b/cdist/test/cdist_type/__init__.py @@ -34,7 +34,8 @@ class TypeTestCase(test.CdistTestCase): def test_list_type_names(self): base_path = op.join(fixtures, 'list_types') type_names = core.CdistType.list_type_names(base_path) - self.assertEqual(sorted(type_names), ['__first', '__second', '__third']) + self.assertEqual(sorted(type_names), + ['__first', '__second', '__third']) def test_list_types(self): base_path = op.join(fixtures, 'list_types') @@ -54,7 +55,8 @@ class TypeTestCase(test.CdistTestCase): def test_nonexistent_type(self): base_path = fixtures - self.assertRaises(core.NoSuchTypeError, core.CdistType, base_path, '__i-dont-exist') + self.assertRaises(core.NoSuchTypeError, core.CdistType, base_path, + '__i-dont-exist') def test_name(self): base_path = fixtures @@ -74,27 +76,32 @@ class TypeTestCase(test.CdistTestCase): def test_absolute_path(self): base_path = fixtures cdist_type = core.CdistType(base_path, '__name_path') - self.assertEqual(cdist_type.absolute_path, os.path.join(base_path, '__name_path')) + self.assertEqual(cdist_type.absolute_path, + os.path.join(base_path, '__name_path')) def test_manifest_path(self): base_path = fixtures cdist_type = core.CdistType(base_path, '__name_path') - self.assertEqual(cdist_type.manifest_path, os.path.join('__name_path', 'manifest')) + self.assertEqual(cdist_type.manifest_path, + os.path.join('__name_path', 'manifest')) def test_explorer_path(self): base_path = fixtures cdist_type = core.CdistType(base_path, '__name_path') - self.assertEqual(cdist_type.explorer_path, os.path.join('__name_path', 'explorer')) + self.assertEqual(cdist_type.explorer_path, + os.path.join('__name_path', 'explorer')) def test_gencode_local_path(self): base_path = fixtures cdist_type = core.CdistType(base_path, '__name_path') - self.assertEqual(cdist_type.gencode_local_path, os.path.join('__name_path', 'gencode-local')) + self.assertEqual(cdist_type.gencode_local_path, + os.path.join('__name_path', 'gencode-local')) def test_gencode_remote_path(self): base_path = fixtures cdist_type = core.CdistType(base_path, '__name_path') - self.assertEqual(cdist_type.gencode_remote_path, os.path.join('__name_path', 'gencode-remote')) + self.assertEqual(cdist_type.gencode_remote_path, + os.path.join('__name_path', 'gencode-remote')) def test_singleton_is_singleton(self): base_path = fixtures @@ -119,17 +126,20 @@ class TypeTestCase(test.CdistTestCase): def test_with_required_parameters(self): base_path = fixtures cdist_type = core.CdistType(base_path, '__with_required_parameters') - self.assertEqual(cdist_type.required_parameters, ['required1', 'required2']) + self.assertEqual(cdist_type.required_parameters, + ['required1', 'required2']) def test_without_required_parameters(self): base_path = fixtures - cdist_type = core.CdistType(base_path, '__without_required_parameters') + cdist_type = core.CdistType(base_path, + '__without_required_parameters') self.assertEqual(cdist_type.required_parameters, []) def test_with_optional_parameters(self): base_path = fixtures cdist_type = core.CdistType(base_path, '__with_optional_parameters') - self.assertEqual(cdist_type.optional_parameters, ['optional1', 'optional2']) + self.assertEqual(cdist_type.optional_parameters, + ['optional1', 'optional2']) def test_without_optional_parameters(self): base_path = fixtures @@ -139,7 +149,8 @@ class TypeTestCase(test.CdistTestCase): def test_with_boolean_parameters(self): base_path = fixtures cdist_type = core.CdistType(base_path, '__with_boolean_parameters') - self.assertEqual(cdist_type.boolean_parameters, ['boolean1', 'boolean2']) + self.assertEqual(cdist_type.boolean_parameters, + ['boolean1', 'boolean2']) def test_without_boolean_parameters(self): base_path = fixtures @@ -158,5 +169,4 @@ class TypeTestCase(test.CdistTestCase): cdist_type = core.CdistType(base_path, '__directory_in_default') self.assertEqual( list(sorted(cdist_type.parameter_defaults.keys())), - ['bar', 'foo'] - ) + ['bar', 'foo']) diff --git a/cdist/test/code/__init__.py b/cdist/test/code/__init__.py index 689fcff6..7ec9e3c4 100644 --- a/cdist/test/code/__init__.py +++ b/cdist/test/code/__init__.py @@ -36,15 +36,16 @@ my_dir = op.abspath(op.dirname(__file__)) fixtures = op.join(my_dir, 'fixtures') conf_dir = op.join(fixtures, 'conf') + class CodeTestCase(test.CdistTestCase): def setUp(self): self.local_dir = self.mkdtemp() self.local = local.Local( - target_host=self.target_host, - base_path = self.local_dir, - exec_path = cdist.test.cdist_exec_path, + target_host=self.target_host, + base_path=self.local_dir, + exec_path=cdist.test.cdist_exec_path, add_conf_dirs=[conf_dir]) self.local.create_files_dirs() @@ -52,16 +53,19 @@ class CodeTestCase(test.CdistTestCase): remote_exec = self.remote_exec remote_copy = self.remote_copy self.remote = remote.Remote( - target_host=self.target_host, - remote_exec=remote_exec, + target_host=self.target_host, + remote_exec=remote_exec, remote_copy=remote_copy, base_path=self.remote_dir) self.remote.create_files_dirs() self.code = code.Code(self.target_host, self.local, self.remote) - self.cdist_type = core.CdistType(self.local.type_path, '__dump_environment') - self.cdist_object = core.CdistObject(self.cdist_type, self.local.object_path, 'whatever', self.local.object_marker_name) + self.cdist_type = core.CdistType(self.local.type_path, + '__dump_environment') + self.cdist_object = core.CdistObject( + self.cdist_type, self.local.object_path, 'whatever', + self.local.object_marker_name) self.cdist_object.create() def tearDown(self): @@ -73,42 +77,56 @@ class CodeTestCase(test.CdistTestCase): output_dict = {} for line in output_string.split('\n'): if line: - junk,value = line.split(': ') + junk, value = line.split(': ') key = junk.split(' ')[1] output_dict[key] = value self.assertEqual(output_dict['__target_host'], self.local.target_host) self.assertEqual(output_dict['__global'], self.local.base_path) self.assertEqual(output_dict['__type'], self.cdist_type.absolute_path) - self.assertEqual(output_dict['__object'], self.cdist_object.absolute_path) - self.assertEqual(output_dict['__object_id'], self.cdist_object.object_id) + self.assertEqual(output_dict['__object'], + self.cdist_object.absolute_path) + self.assertEqual(output_dict['__object_id'], + self.cdist_object.object_id) self.assertEqual(output_dict['__object_name'], self.cdist_object.name) + self.assertEqual(output_dict['__files'], self.local.files_path) def test_run_gencode_remote_environment(self): output_string = self.code.run_gencode_remote(self.cdist_object) output_dict = {} for line in output_string.split('\n'): if line: - junk,value = line.split(': ') + junk, value = line.split(': ') key = junk.split(' ')[1] output_dict[key] = value self.assertEqual(output_dict['__target_host'], self.local.target_host) self.assertEqual(output_dict['__global'], self.local.base_path) self.assertEqual(output_dict['__type'], self.cdist_type.absolute_path) - self.assertEqual(output_dict['__object'], self.cdist_object.absolute_path) - self.assertEqual(output_dict['__object_id'], self.cdist_object.object_id) + self.assertEqual(output_dict['__object'], + self.cdist_object.absolute_path) + self.assertEqual(output_dict['__object_id'], + self.cdist_object.object_id) self.assertEqual(output_dict['__object_name'], self.cdist_object.name) + self.assertEqual(output_dict['__files'], self.local.files_path) def test_transfer_code_remote(self): - self.cdist_object.code_remote = self.code.run_gencode_remote(self.cdist_object) + self.cdist_object.code_remote = self.code.run_gencode_remote( + self.cdist_object) self.code.transfer_code_remote(self.cdist_object) - destination = os.path.join(self.remote.object_path, self.cdist_object.code_remote_path) + destination = os.path.join(self.remote.object_path, + self.cdist_object.code_remote_path) self.assertTrue(os.path.isfile(destination)) def test_run_code_local(self): - self.cdist_object.code_local = self.code.run_gencode_local(self.cdist_object) + self.cdist_object.code_local = self.code.run_gencode_local( + self.cdist_object) self.code.run_code_local(self.cdist_object) def test_run_code_remote_environment(self): - self.cdist_object.code_remote = self.code.run_gencode_remote(self.cdist_object) + self.cdist_object.code_remote = self.code.run_gencode_remote( + self.cdist_object) self.code.transfer_code_remote(self.cdist_object) self.code.run_code_remote(self.cdist_object) + +if __name__ == '__main__': + import unittest + unittest.main() diff --git a/cdist/test/code/fixtures/conf/type/__dump_environment/gencode-local b/cdist/test/code/fixtures/conf/type/__dump_environment/gencode-local index 771894fb..5883c268 100755 --- a/cdist/test/code/fixtures/conf/type/__dump_environment/gencode-local +++ b/cdist/test/code/fixtures/conf/type/__dump_environment/gencode-local @@ -6,3 +6,4 @@ echo "echo __type: $__type" echo "echo __object: $__object" echo "echo __object_id: $__object_id" echo "echo __object_name: $__object_name" +echo "echo __files: $__files" diff --git a/cdist/test/config/__init__.py b/cdist/test/config/__init__.py index a36567de..3fd415fd 100644 --- a/cdist/test/config/__init__.py +++ b/cdist/test/config/__init__.py @@ -44,6 +44,7 @@ expected_object_names = sorted([ '__second/on-the', '__third/moon']) + class ConfigRunTestCase(test.CdistTestCase): def setUp(self): @@ -65,8 +66,11 @@ class ConfigRunTestCase(test.CdistTestCase): self.objects = [] for cdist_object_name in expected_object_names: cdist_type, cdist_object_id = cdist_object_name.split("/", 1) - cdist_object = core.CdistObject(core.CdistType(type_base_path, cdist_type), self.object_base_path, - self.local.object_marker_name, cdist_object_id) + cdist_object = core.CdistObject(core.CdistType(type_base_path, + cdist_type), + self.object_base_path, + self.local.object_marker_name, + cdist_object_id) cdist_object.create() self.objects.append(cdist_object) @@ -81,8 +85,8 @@ class ConfigRunTestCase(test.CdistTestCase): remote_exec=self.remote_exec, base_path=self.remote_dir) - self.local.object_path = self.object_base_path - self.local.type_path = type_base_path + self.local.object_path = self.object_base_path + self.local.type_path = type_base_path self.config = cdist.config.Config(self.local, self.remote) @@ -95,14 +99,14 @@ class ConfigRunTestCase(test.CdistTestCase): shutil.rmtree(self.temp_dir) def test_dependency_resolution(self): - first = self.object_index['__first/man'] - second = self.object_index['__second/on-the'] - third = self.object_index['__third/moon'] + first = self.object_index['__first/man'] + second = self.object_index['__second/on-the'] + third = self.object_index['__third/moon'] first.requirements = [second.name] second.requirements = [third.name] - # First run: + # First run: # solves first and maybe second (depending on the order in the set) self.config.iterate_once() self.assertTrue(third.state == third.STATE_DONE) @@ -110,11 +114,11 @@ class ConfigRunTestCase(test.CdistTestCase): self.config.iterate_once() self.assertTrue(second.state == second.STATE_DONE) - try: self.config.iterate_once() except cdist.Error: - # Allow failing, because the third run may or may not be unecessary already, + # Allow failing, because the third run may or may not be + # unecessary already, # depending on the order of the objects pass self.assertTrue(first.state == first.STATE_DONE) @@ -123,8 +127,8 @@ class ConfigRunTestCase(test.CdistTestCase): """Ensure an exception is thrown for unresolvable depedencies""" # Create to objects depending on each other - no solution possible - first = self.object_index['__first/man'] - second = self.object_index['__second/on-the'] + first = self.object_index['__first/man'] + second = self.object_index['__second/on-the'] first.requirements = [second.name] second.requirements = [first.name] @@ -153,21 +157,22 @@ class ConfigRunTestCase(test.CdistTestCase): with self.assertRaises(cdist.core.cdist_object.MissingObjectIdError): self.config.iterate_until_finished() - def test_dryrun(self): """Test if the dryrun option is working like expected""" drylocal = cdist.exec.local.Local( target_host=self.target_host, base_path=self.local_dir, - #exec_path can not derivated from sys.argv in case of unittest ... - exec_path=os.path.abspath(os.path.join(my_dir,'../../../scripts/cdist')), - initial_manifest=os.path.join(fixtures, 'manifest/dryrun_manifest'), - add_conf_dirs=[ fixtures ] ) + # exec_path can not derivated from sys.argv in case of unittest + exec_path=os.path.abspath(os.path.join( + my_dir, '../../../scripts/cdist')), + initial_manifest=os.path.join(fixtures, + 'manifest/dryrun_manifest'), + add_conf_dirs=[fixtures]) dryrun = cdist.config.Config(drylocal, self.remote, dry_run=True) dryrun.run() # if we are here, dryrun works like expected - + # Currently the resolving code will simply detect that this object does # not exist. It should probably check if the type is a singleton as well diff --git a/cdist/test/emulator/__init__.py b/cdist/test/emulator/__init__.py index f90e5320..69ca0fd9 100644 --- a/cdist/test/emulator/__init__.py +++ b/cdist/test/emulator/__init__.py @@ -40,6 +40,7 @@ my_dir = op.abspath(op.dirname(__file__)) fixtures = op.join(my_dir, 'fixtures') conf_dir = op.join(fixtures, 'conf') + class EmulatorTestCase(test.CdistTestCase): def setUp(self): @@ -68,7 +69,8 @@ class EmulatorTestCase(test.CdistTestCase): def test_nonexistent_type_exec(self): argv = ['__does-not-exist'] - self.assertRaises(core.cdist_type.NoSuchTypeError, emulator.Emulator, argv, env=self.env) + self.assertRaises(core.cdist_type.NoSuchTypeError, emulator.Emulator, + argv, env=self.env) def test_nonexistent_type_requirement(self): argv = ['__file', '/tmp/foobar'] @@ -78,7 +80,8 @@ class EmulatorTestCase(test.CdistTestCase): def test_illegal_object_id_requirement(self): argv = ['__file', '/tmp/foobar'] - self.env['require'] = "__file/bad/id/with/%s/inside" % self.local.object_marker_name + self.env['require'] = ( + "__file/bad/id/with/%s/inside") % self.local.object_marker_name emu = emulator.Emulator(argv, env=self.env) self.assertRaises(core.IllegalObjectIdError, emu.run) @@ -123,10 +126,14 @@ class EmulatorTestCase(test.CdistTestCase): emu.run() # now load the objects and verify the require parameter of the objects cdist_type = core.CdistType(self.local.type_path, '__planet') - erde_object = core.CdistObject(cdist_type, self.local.object_path, self.local.object_marker_name, 'erde') - mars_object = core.CdistObject(cdist_type, self.local.object_path, self.local.object_marker_name, 'mars') + erde_object = core.CdistObject(cdist_type, self.local.object_path, + self.local.object_marker_name, 'erde') + mars_object = core.CdistObject(cdist_type, self.local.object_path, + self.local.object_marker_name, 'mars') cdist_type = core.CdistType(self.local.type_path, '__file') - file_object = core.CdistObject(cdist_type, self.local.object_path, self.local.object_marker_name, '/tmp/cdisttest') + file_object = core.CdistObject(cdist_type, self.local.object_path, + self.local.object_marker_name, + '/tmp/cdisttest') # now test the recorded requirements self.assertTrue(len(erde_object.requirements) == 0) self.assertEqual(list(mars_object.requirements), ['__planet/erde']) @@ -134,6 +141,95 @@ class EmulatorTestCase(test.CdistTestCase): # if we get here all is fine +class EmulatorConflictingRequirementsTestCase(test.CdistTestCase): + + def setUp(self): + self.temp_dir = self.mkdtemp() + handle, self.script = self.mkstemp(dir=self.temp_dir) + os.close(handle) + base_path = self.temp_dir + + self.local = local.Local( + target_host=self.target_host, + base_path=base_path, + exec_path=test.cdist_exec_path, + add_conf_dirs=[conf_dir]) + self.local.create_files_dirs() + + self.manifest = core.Manifest(self.target_host, self.local) + self.env = self.manifest.env_initial_manifest(self.script) + self.env['__cdist_object_marker'] = self.local.object_marker_name + + def tearDown(self): + shutil.rmtree(self.temp_dir) + + def test_object_different_requirements_req_none(self): + argv = ['__directory', 'spam'] + emu = emulator.Emulator(argv, env=self.env) + emu.run() + argv = ['__file', 'eggs'] + self.env['require'] = '__directory/spam' + emu = emulator.Emulator(argv, env=self.env) + emu.run() + argv = ['__file', 'eggs'] + if 'require' in self.env: + del self.env['require'] + emu = emulator.Emulator(argv, env=self.env) + emu.run() + + cdist_type = core.CdistType(self.local.type_path, '__file') + cdist_object = core.CdistObject(cdist_type, self.local.object_path, + self.local.object_marker_name, 'eggs') + reqs = set(('__directory/spam',)) + self.assertEqual(reqs, set(cdist_object.requirements)) + + def test_object_different_requirements_none_req(self): + argv = ['__directory', 'spam'] + emu = emulator.Emulator(argv, env=self.env) + emu.run() + argv = ['__file', 'eggs'] + if 'require' in self.env: + del self.env['require'] + emu = emulator.Emulator(argv, env=self.env) + emu.run() + argv = ['__file', 'eggs'] + self.env['require'] = '__directory/spam' + emu = emulator.Emulator(argv, env=self.env) + emu.run() + + cdist_type = core.CdistType(self.local.type_path, '__file') + cdist_object = core.CdistObject(cdist_type, self.local.object_path, + self.local.object_marker_name, 'eggs') + reqs = set(('__directory/spam',)) + self.assertEqual(reqs, set(cdist_object.requirements)) + + def test_object_different_requirements(self): + argv = ['__directory', 'spam'] + emu = emulator.Emulator(argv, env=self.env) + emu.run() + argv = ['__directory', 'spameggs'] + emu = emulator.Emulator(argv, env=self.env) + emu.run() + + argv = ['__file', 'eggs'] + if 'require' in self.env: + del self.env['require'] + self.env['require'] = '__directory/spam' + emu = emulator.Emulator(argv, env=self.env) + emu.run() + + argv = ['__file', 'eggs'] + self.env['require'] = '__directory/spameggs' + emu = emulator.Emulator(argv, env=self.env) + emu.run() + + cdist_type = core.CdistType(self.local.type_path, '__file') + cdist_object = core.CdistObject(cdist_type, self.local.object_path, + self.local.object_marker_name, 'eggs') + reqs = set(('__directory/spam', '__directory/spameggs',)) + self.assertEqual(reqs, set(cdist_object.requirements)) + + class AutoRequireEmulatorTestCase(test.CdistTestCase): def setUp(self): @@ -155,11 +251,13 @@ class AutoRequireEmulatorTestCase(test.CdistTestCase): initial_manifest = os.path.join(self.local.manifest_path, "init") self.manifest.run_initial_manifest(initial_manifest) cdist_type = core.CdistType(self.local.type_path, '__saturn') - cdist_object = core.CdistObject(cdist_type, self.local.object_path, self.local.object_marker_name, '') + cdist_object = core.CdistObject(cdist_type, self.local.object_path, + self.local.object_marker_name, '') self.manifest.run_type_manifest(cdist_object) expected = ['__planet/Saturn', '__moon/Prometheus'] self.assertEqual(sorted(cdist_object.autorequire), sorted(expected)) + class OverrideTestCase(test.CdistTestCase): def setUp(self): @@ -186,7 +284,7 @@ class OverrideTestCase(test.CdistTestCase): argv = ['__file', '/tmp/foobar'] emu = emulator.Emulator(argv, env=self.env) emu.run() - argv = ['__file', '/tmp/foobar','--mode','404'] + argv = ['__file', '/tmp/foobar', '--mode', '404'] emu = emulator.Emulator(argv, env=self.env) self.assertRaises(cdist.Error, emu.run) @@ -194,7 +292,7 @@ class OverrideTestCase(test.CdistTestCase): argv = ['__file', '/tmp/foobar'] emu = emulator.Emulator(argv, env=self.env) emu.run() - argv = ['__file', '/tmp/foobar','--mode','404'] + argv = ['__file', '/tmp/foobar', '--mode', '404'] self.env['CDIST_OVERRIDE'] = 'on' emu = emulator.Emulator(argv, env=self.env) emu.run() @@ -223,13 +321,17 @@ class ArgumentsTestCase(test.CdistTestCase): shutil.rmtree(self.temp_dir) def test_arguments_with_dashes(self): - argv = ['__arguments_with_dashes', 'some-id', '--with-dash', 'some value'] + argv = ['__arguments_with_dashes', 'some-id', '--with-dash', + 'some value'] os.environ.update(self.env) emu = emulator.Emulator(argv) emu.run() - cdist_type = core.CdistType(self.local.type_path, '__arguments_with_dashes') - cdist_object = core.CdistObject(cdist_type, self.local.object_path, self.local.object_marker_name, 'some-id') + cdist_type = core.CdistType(self.local.type_path, + '__arguments_with_dashes') + cdist_object = core.CdistObject(cdist_type, self.local.object_path, + self.local.object_marker_name, + 'some-id') self.assertTrue('with-dash' in cdist_object.parameters) def test_boolean(self): @@ -241,7 +343,9 @@ class ArgumentsTestCase(test.CdistTestCase): emu.run() cdist_type = core.CdistType(self.local.type_path, type_name) - cdist_object = core.CdistObject(cdist_type, self.local.object_path, self.local.object_marker_name, object_id) + cdist_object = core.CdistObject(cdist_type, self.local.object_path, + self.local.object_marker_name, + object_id) self.assertTrue('boolean1' in cdist_object.parameters) self.assertFalse('boolean2' in cdist_object.parameters) # empty file -> True @@ -253,13 +357,16 @@ class ArgumentsTestCase(test.CdistTestCase): type_name = '__arguments_required' object_id = 'some-id' value = 'some value' - argv = [type_name, object_id, '--required1', value, '--required2', value] + argv = [type_name, object_id, '--required1', value, + '--required2', value] os.environ.update(self.env) emu = emulator.Emulator(argv) emu.run() cdist_type = core.CdistType(self.local.type_path, type_name) - cdist_object = core.CdistObject(cdist_type, self.local.object_path, self.local.object_marker_name, object_id) + cdist_object = core.CdistObject(cdist_type, self.local.object_path, + self.local.object_marker_name, + object_id) self.assertTrue('required1' in cdist_object.parameters) self.assertTrue('required2' in cdist_object.parameters) self.assertEqual(cdist_object.parameters['required1'], value) @@ -285,7 +392,9 @@ class ArgumentsTestCase(test.CdistTestCase): emu.run() cdist_type = core.CdistType(self.local.type_path, type_name) - cdist_object = core.CdistObject(cdist_type, self.local.object_path, self.local.object_marker_name, object_id) + cdist_object = core.CdistObject(cdist_type, self.local.object_path, + self.local.object_marker_name, + object_id) self.assertTrue('optional1' in cdist_object.parameters) self.assertFalse('optional2' in cdist_object.parameters) self.assertEqual(cdist_object.parameters['optional1'], value) @@ -300,7 +409,9 @@ class ArgumentsTestCase(test.CdistTestCase): emu.run() cdist_type = core.CdistType(self.local.type_path, type_name) - cdist_object = core.CdistObject(cdist_type, self.local.object_path, self.local.object_marker_name, object_id) + cdist_object = core.CdistObject(cdist_type, self.local.object_path, + self.local.object_marker_name, + object_id) self.assertTrue('optional1' in cdist_object.parameters) self.assertFalse('optional2' in cdist_object.parameters) self.assertEqual(cdist_object.parameters['optional1'], value) @@ -352,7 +463,9 @@ class StdinTestCase(test.CdistTestCase): ###################################################################### # Create path where stdin should reside at cdist_type = core.CdistType(self.local.type_path, type_name) - cdist_object = core.CdistObject(cdist_type, self.local.object_path, self.local.object_marker_name, object_id) + cdist_object = core.CdistObject(cdist_type, self.local.object_path, + self.local.object_marker_name, + object_id) stdin_out_path = os.path.join(cdist_object.absolute_path, 'stdin') ###################################################################### @@ -366,3 +479,8 @@ class StdinTestCase(test.CdistTestCase): stdin_saved_by_emulator = fd.read() self.assertEqual(random_string, stdin_saved_by_emulator) + + +if __name__ == '__main__': + import unittest + unittest.main() diff --git a/cdist/test/exec/local.py b/cdist/test/exec/local.py index 12a0d47b..2cd8b6db 100644 --- a/cdist/test/exec/local.py +++ b/cdist/test/exec/local.py @@ -39,6 +39,7 @@ conf_dir = op.join(fixtures, "conf") bin_true = "true" bin_false = "false" + class LocalTestCase(test.CdistTestCase): def setUp(self): @@ -59,43 +60,52 @@ class LocalTestCase(test.CdistTestCase): def tearDown(self): shutil.rmtree(self.temp_dir) - ### test api + # test api def test_cache_path(self): - self.assertEqual(self.local.cache_path, os.path.join(self.home_dir, "cache")) + self.assertEqual(self.local.cache_path, + os.path.join(self.home_dir, "cache")) def test_conf_path(self): - self.assertEqual(self.local.conf_path, os.path.join(self.out_path, "conf")) + self.assertEqual(self.local.conf_path, + os.path.join(self.out_path, "conf")) def test_out_path(self): self.assertEqual(self.local.base_path, self.out_path) def test_bin_path(self): - self.assertEqual(self.local.bin_path, os.path.join(self.out_path, "bin")) + self.assertEqual(self.local.bin_path, + os.path.join(self.out_path, "bin")) def test_global_explorer_out_path(self): - self.assertEqual(self.local.global_explorer_out_path, os.path.join(self.out_path, "explorer")) + self.assertEqual(self.local.global_explorer_out_path, + os.path.join(self.out_path, "explorer")) def test_object_path(self): - self.assertEqual(self.local.object_path, os.path.join(self.out_path, "object")) + self.assertEqual(self.local.object_path, + os.path.join(self.out_path, "object")) - ### /test api + # /test api - ### test internal implementation + # test internal implementation def test_global_explorer_path(self): - self.assertEqual(self.local.global_explorer_path, os.path.join(self.out_path, "conf", "explorer")) + self.assertEqual(self.local.global_explorer_path, + os.path.join(self.out_path, "conf", "explorer")) def test_manifest_path(self): - self.assertEqual(self.local.manifest_path, os.path.join(self.out_path, "conf", "manifest")) + self.assertEqual(self.local.manifest_path, + os.path.join(self.out_path, "conf", "manifest")) def test_type_path(self): - self.assertEqual(self.local.type_path, os.path.join(self.out_path, "conf", "type")) + self.assertEqual(self.local.type_path, + os.path.join(self.out_path, "conf", "type")) def test_dist_conf_dir_linking(self): - """Ensure that links are correctly created for types included in distribution""" + """Ensure that links are correctly created for types included + in distribution""" - test_type="__file" + test_type = "__file" link_test_local = local.Local( target_host='localhost', @@ -110,9 +120,10 @@ class LocalTestCase(test.CdistTestCase): self.assertTrue(os.path.isdir(our_type_dir)) def test_added_conf_dir_linking(self): - """Ensure that links are correctly created for types in added conf directories""" + """Ensure that links are correctly created for types in added conf + directories""" - test_type="__cdist_test_type" + test_type = "__cdist_test_type" link_test_local = local.Local( target_host='localhost', @@ -128,9 +139,10 @@ class LocalTestCase(test.CdistTestCase): self.assertTrue(os.path.isdir(our_type_dir)) def test_conf_dir_from_path_linking(self): - """Ensure that links are correctly created for types in conf directories which are defined in CDIST_PATH""" + """Ensure that links are correctly created for types in conf + directories which are defined in CDIST_PATH""" - test_type="__cdist_test_type" + test_type = "__cdist_test_type" os.environ['CDIST_PATH'] = conf_dir @@ -146,7 +158,7 @@ class LocalTestCase(test.CdistTestCase): self.assertTrue(os.path.isdir(our_type_dir)) - ### other tests + # other tests def test_run_success(self): self.local.run([bin_true]) @@ -170,7 +182,8 @@ class LocalTestCase(test.CdistTestCase): handle, script = self.mkstemp(dir=self.temp_dir) with os.fdopen(handle, "w") as fd: fd.writelines(["#!/bin/sh\n", "echo foobar"]) - self.assertEqual(self.local.run_script(script, return_output=True), "foobar\n") + self.assertEqual(self.local.run_script(script, return_output=True), + "foobar\n") def test_mkdir(self): temp_dir = self.mkdtemp(dir=self.temp_dir) diff --git a/cdist/test/exec/remote.py b/cdist/test/exec/remote.py index 89e9dbc8..318e4c7b 100644 --- a/cdist/test/exec/remote.py +++ b/cdist/test/exec/remote.py @@ -39,26 +39,32 @@ class RemoteTestCase(test.CdistTestCase): user = getpass.getuser() remote_exec = "ssh -o User=%s -q" % user remote_copy = "scp -o User=%s -q" % user - self.remote = remote.Remote(self.target_host, base_path=self.base_path, remote_exec=remote_exec, remote_copy=remote_copy) + self.remote = remote.Remote(self.target_host, base_path=self.base_path, + remote_exec=remote_exec, + remote_copy=remote_copy) def tearDown(self): shutil.rmtree(self.temp_dir) - ### test api + # test api def test_conf_path(self): - self.assertEqual(self.remote.conf_path, os.path.join(self.base_path, "conf")) + self.assertEqual(self.remote.conf_path, + os.path.join(self.base_path, "conf")) def test_object_path(self): - self.assertEqual(self.remote.object_path, os.path.join(self.base_path, "object")) + self.assertEqual(self.remote.object_path, + os.path.join(self.base_path, "object")) def test_type_path(self): - self.assertEqual(self.remote.type_path, os.path.join(self.base_path, "conf", "type")) + self.assertEqual(self.remote.type_path, + os.path.join(self.base_path, "conf", "type")) def test_global_explorer_path(self): - self.assertEqual(self.remote.global_explorer_path, os.path.join(self.base_path, "conf", "explorer")) + self.assertEqual(self.remote.global_explorer_path, + os.path.join(self.base_path, "conf", "explorer")) - ### /test api + # /test api def test_run_success(self): self.remote.run(['/bin/true']) @@ -76,13 +82,15 @@ class RemoteTestCase(test.CdistTestCase): handle, script = self.mkstemp(dir=self.temp_dir) with os.fdopen(handle, "w") as fd: fd.writelines(["#!/bin/sh\n", "/bin/false"]) - self.assertRaises(remote.RemoteScriptError, self.remote.run_script, script) + self.assertRaises(remote.RemoteScriptError, self.remote.run_script, + script) def test_run_script_get_output(self): handle, script = self.mkstemp(dir=self.temp_dir) with os.fdopen(handle, "w") as fd: fd.writelines(["#!/bin/sh\n", "echo foobar"]) - self.assertEqual(self.remote.run_script(script, return_output=True), "foobar\n") + self.assertEqual(self.remote.run_script(script, return_output=True), + "foobar\n") def test_mkdir(self): temp_dir = self.mkdtemp(dir=self.temp_dir) @@ -125,8 +133,10 @@ class RemoteTestCase(test.CdistTestCase): os.chmod(remote_exec_path, 0o755) remote_exec = remote_exec_path remote_copy = "echo" - r = remote.Remote(self.target_host, base_path=self.base_path, remote_exec=remote_exec, remote_copy=remote_copy) - self.assertEqual(r.run('/bin/true', return_output=True), "%s\n" % self.target_host) + r = remote.Remote(self.target_host, base_path=self.base_path, + remote_exec=remote_exec, remote_copy=remote_copy) + self.assertEqual(r.run('/bin/true', return_output=True), + "%s\n" % self.target_host) def test_run_script_target_host_in_env(self): handle, remote_exec_path = self.mkstemp(dir=self.temp_dir) @@ -135,16 +145,21 @@ class RemoteTestCase(test.CdistTestCase): os.chmod(remote_exec_path, 0o755) remote_exec = remote_exec_path remote_copy = "echo" - r = remote.Remote(self.target_host, base_path=self.base_path, remote_exec=remote_exec, remote_copy=remote_copy) + r = remote.Remote(self.target_host, base_path=self.base_path, + remote_exec=remote_exec, remote_copy=remote_copy) handle, script = self.mkstemp(dir=self.temp_dir) with os.fdopen(handle, "w") as fd: fd.writelines(["#!/bin/sh\n", "/bin/true"]) - self.assertEqual(r.run_script(script, return_output=True), "%s\n" % self.target_host) + self.assertEqual(r.run_script(script, return_output=True), + "%s\n" % self.target_host) def test_run_script_with_env_target_host_in_env(self): handle, script = self.mkstemp(dir=self.temp_dir) with os.fdopen(handle, "w") as fd: - fd.writelines(["#!/bin/sh\n", 'if [ "$__object" ]; then echo $__object; else echo no_env; fi\n']) + fd.writelines([ + "#!/bin/sh\n", + ('if [ "$__object" ]; then echo $__object; ' + 'else echo no_env; fi\n')]) os.chmod(script, 0o755) handle, remote_exec_path = self.mkstemp(dir=self.temp_dir) with os.fdopen(handle, 'w') as fd: @@ -152,7 +167,8 @@ class RemoteTestCase(test.CdistTestCase): os.chmod(remote_exec_path, 0o755) remote_exec = remote_exec_path remote_copy = "echo" - r = remote.Remote(self.target_host, base_path=self.base_path, remote_exec=remote_exec, remote_copy=remote_copy) + r = remote.Remote(self.target_host, base_path=self.base_path, + remote_exec=remote_exec, remote_copy=remote_copy) output = r.run_script(script, return_output=True) self.assertEqual(output, "no_env\n") @@ -164,7 +180,8 @@ class RemoteTestCase(test.CdistTestCase): env = { '__object': 'test_object', } - r = remote.Remote(self.target_host, base_path=self.base_path, remote_exec=remote_exec, remote_copy=remote_copy) + r = remote.Remote(self.target_host, base_path=self.base_path, + remote_exec=remote_exec, remote_copy=remote_copy) output = r.run_script(script, env=env, return_output=True) self.assertEqual(output, "test_object\n") diff --git a/cdist/test/explorer/__init__.py b/cdist/test/explorer/__init__.py index 335d0e32..2ca50b7c 100644 --- a/cdist/test/explorer/__init__.py +++ b/cdist/test/explorer/__init__.py @@ -36,12 +36,13 @@ my_dir = op.abspath(op.dirname(__file__)) fixtures = op.join(my_dir, 'fixtures') conf_dir = op.join(fixtures, "conf") + class ExplorerClassTestCase(test.CdistTestCase): def setUp(self): - self.temp_dir = self.mkdtemp() - self.local_path = os.path.join(self.temp_dir, "local") - self.remote_base_path = os.path.join(self.temp_dir, "remote") + self.temp_dir = self.mkdtemp() + self.local_path = os.path.join(self.temp_dir, "local") + self.remote_base_path = os.path.join(self.temp_dir, "remote") os.makedirs(self.remote_base_path) self.local = local.Local( @@ -54,15 +55,15 @@ class ExplorerClassTestCase(test.CdistTestCase): self.local.create_files_dirs() self.remote = remote.Remote( - target_host=self.target_host, + target_host=self.target_host, remote_exec=self.remote_exec, remote_copy=self.remote_copy, base_path=self.remote_base_path) self.remote.create_files_dirs() self.explorer = explorer.Explorer( - self.target_host, - self.local, + self.target_host, + self.local, self.remote) def tearDown(self): @@ -79,7 +80,8 @@ class ExplorerClassTestCase(test.CdistTestCase): self.explorer.transfer_global_explorers() source = self.local.global_explorer_path destination = self.remote.global_explorer_path - self.assertEqual(sorted(os.listdir(source)), sorted(os.listdir(destination))) + self.assertEqual(sorted(os.listdir(source)), + sorted(os.listdir(destination))) def test_run_global_explorer(self): """Checkt that running ONE global explorer works""" @@ -101,14 +103,16 @@ class ExplorerClassTestCase(test.CdistTestCase): def test_list_type_explorer_names(self): cdist_type = core.CdistType(self.local.type_path, '__test_type') expected = cdist_type.explorers - self.assertEqual(self.explorer.list_type_explorer_names(cdist_type), expected) + self.assertEqual(self.explorer.list_type_explorer_names(cdist_type), + expected) def test_transfer_type_explorers(self): """Test if transferring type explorers works""" cdist_type = core.CdistType(self.local.type_path, '__test_type') self.explorer.transfer_type_explorers(cdist_type) source = os.path.join(self.local.type_path, cdist_type.explorer_path) - destination = os.path.join(self.remote.type_path, cdist_type.explorer_path) + destination = os.path.join(self.remote.type_path, + cdist_type.explorer_path) self.assertEqual(os.listdir(source), os.listdir(destination)) def test_transfer_type_explorers_only_once(self): @@ -116,7 +120,8 @@ class ExplorerClassTestCase(test.CdistTestCase): # first transfer self.explorer.transfer_type_explorers(cdist_type) source = os.path.join(self.local.type_path, cdist_type.explorer_path) - destination = os.path.join(self.remote.type_path, cdist_type.explorer_path) + destination = os.path.join(self.remote.type_path, + cdist_type.explorer_path) self.assertEqual(os.listdir(source), os.listdir(destination)) # nuke destination folder content, but recreate directory shutil.rmtree(destination) @@ -127,24 +132,36 @@ class ExplorerClassTestCase(test.CdistTestCase): def test_transfer_object_parameters(self): cdist_type = core.CdistType(self.local.type_path, '__test_type') - cdist_object = core.CdistObject(cdist_type, self.local.object_path, self.local.object_marker_name, 'whatever') + cdist_object = core.CdistObject(cdist_type, self.local.object_path, + self.local.object_marker_name, + 'whatever') cdist_object.create() - cdist_object.parameters = {'first': 'first value', 'second': 'second value'} + cdist_object.parameters = { + 'first': 'first value', + 'second': 'second value' + } self.explorer.transfer_object_parameters(cdist_object) - source = os.path.join(self.local.object_path, cdist_object.parameter_path) - destination = os.path.join(self.remote.object_path, cdist_object.parameter_path) - self.assertEqual(sorted(os.listdir(source)), sorted(os.listdir(destination))) + source = os.path.join(self.local.object_path, + cdist_object.parameter_path) + destination = os.path.join(self.remote.object_path, + cdist_object.parameter_path) + self.assertEqual(sorted(os.listdir(source)), + sorted(os.listdir(destination))) def test_run_type_explorer(self): cdist_type = core.CdistType(self.local.type_path, '__test_type') - cdist_object = core.CdistObject(cdist_type, self.local.object_path, self.local.object_marker_name, 'whatever') + cdist_object = core.CdistObject(cdist_type, self.local.object_path, + self.local.object_marker_name, + 'whatever') self.explorer.transfer_type_explorers(cdist_type) output = self.explorer.run_type_explorer('world', cdist_object) self.assertEqual(output, 'hello\n') def test_run_type_explorers(self): cdist_type = core.CdistType(self.local.type_path, '__test_type') - cdist_object = core.CdistObject(cdist_type, self.local.object_path, self.local.object_marker_name, 'whatever') + cdist_object = core.CdistObject(cdist_type, self.local.object_path, + self.local.object_marker_name, + 'whatever') cdist_object.create() self.explorer.run_type_explorers(cdist_object) self.assertEqual(cdist_object.explorers, {'world': 'hello'}) diff --git a/cdist/test/manifest/__init__.py b/cdist/test/manifest/__init__.py index cc60c844..84c69ce1 100644 --- a/cdist/test/manifest/__init__.py +++ b/cdist/test/manifest/__init__.py @@ -40,6 +40,7 @@ my_dir = op.abspath(op.dirname(__file__)) fixtures = op.join(my_dir, 'fixtures') conf_dir = op.join(fixtures, 'conf') + class ManifestTestCase(test.CdistTestCase): def setUp(self): @@ -51,7 +52,7 @@ class ManifestTestCase(test.CdistTestCase): self.local = local.Local( target_host=self.target_host, base_path=out_path, - exec_path = cdist.test.cdist_exec_path, + exec_path=cdist.test.cdist_exec_path, add_conf_dirs=[conf_dir]) self.local.create_files_dirs() @@ -63,7 +64,8 @@ class ManifestTestCase(test.CdistTestCase): shutil.rmtree(self.temp_dir) def test_initial_manifest_environment(self): - initial_manifest = os.path.join(self.local.manifest_path, "dump_environment") + initial_manifest = os.path.join(self.local.manifest_path, + "dump_environment") handle, output_file = self.mkstemp(dir=self.temp_dir) os.close(handle) os.environ['__cdist_test_out'] = output_file @@ -74,17 +76,21 @@ class ManifestTestCase(test.CdistTestCase): output_dict = {} for line in output_string.split('\n'): if line: - key,value = line.split(': ') + key, value = line.split(': ') output_dict[key] = value self.assertTrue(output_dict['PATH'].startswith(self.local.bin_path)) self.assertEqual(output_dict['__target_host'], self.local.target_host) self.assertEqual(output_dict['__global'], self.local.base_path) - self.assertEqual(output_dict['__cdist_type_base_path'], self.local.type_path) + self.assertEqual(output_dict['__cdist_type_base_path'], + self.local.type_path) self.assertEqual(output_dict['__manifest'], self.local.manifest_path) + self.assertEqual(output_dict['__files'], self.local.files_path) def test_type_manifest_environment(self): cdist_type = core.CdistType(self.local.type_path, '__dump_environment') - cdist_object = core.CdistObject(cdist_type, self.local.object_path, self.local.object_marker_name, 'whatever') + cdist_object = core.CdistObject(cdist_type, self.local.object_path, + self.local.object_marker_name, + 'whatever') handle, output_file = self.mkstemp(dir=self.temp_dir) os.close(handle) os.environ['__cdist_test_out'] = output_file @@ -95,16 +101,18 @@ class ManifestTestCase(test.CdistTestCase): output_dict = {} for line in output_string.split('\n'): if line: - key,value = line.split(': ') + key, value = line.split(': ') output_dict[key] = value self.assertTrue(output_dict['PATH'].startswith(self.local.bin_path)) self.assertEqual(output_dict['__target_host'], self.local.target_host) self.assertEqual(output_dict['__global'], self.local.base_path) - self.assertEqual(output_dict['__cdist_type_base_path'], self.local.type_path) + self.assertEqual(output_dict['__cdist_type_base_path'], + self.local.type_path) self.assertEqual(output_dict['__type'], cdist_type.absolute_path) self.assertEqual(output_dict['__object'], cdist_object.absolute_path) self.assertEqual(output_dict['__object_id'], cdist_object.object_id) self.assertEqual(output_dict['__object_name'], cdist_object.name) + self.assertEqual(output_dict['__files'], self.local.files_path) def test_debug_env_setup(self): current_level = self.log.getEffectiveLevel() @@ -112,3 +120,8 @@ class ManifestTestCase(test.CdistTestCase): manifest = cdist.core.manifest.Manifest(self.target_host, self.local) self.assertTrue("__cdist_debug" in manifest.env) self.log.setLevel(current_level) + + +if __name__ == '__main__': + import unittest + unittest.main() diff --git a/cdist/test/manifest/fixtures/conf/manifest/dump_environment b/cdist/test/manifest/fixtures/conf/manifest/dump_environment index 7ce983ab..df901910 100755 --- a/cdist/test/manifest/fixtures/conf/manifest/dump_environment +++ b/cdist/test/manifest/fixtures/conf/manifest/dump_environment @@ -6,4 +6,5 @@ __target_host: $__target_host __global: $__global __cdist_type_base_path: $__cdist_type_base_path __manifest: $__manifest +__files: $__files DONE diff --git a/cdist/test/manifest/fixtures/conf/type/__dump_environment/manifest b/cdist/test/manifest/fixtures/conf/type/__dump_environment/manifest index e135de35..13efe038 100755 --- a/cdist/test/manifest/fixtures/conf/type/__dump_environment/manifest +++ b/cdist/test/manifest/fixtures/conf/type/__dump_environment/manifest @@ -10,4 +10,5 @@ __self: $__self __object: $__object __object_id: $__object_id __object_name: $__object_name +__files: $__files DONE diff --git a/cdist/test/message/__init__.py b/cdist/test/message/__init__.py index 653847f1..61cd5d97 100644 --- a/cdist/test/message/__init__.py +++ b/cdist/test/message/__init__.py @@ -25,14 +25,15 @@ import tempfile from cdist import test import cdist.message + class MessageTestCase(test.CdistTestCase): def setUp(self): - self.prefix="cdist-test" + self.prefix = "cdist-test" self.content = "A very short story" self.tempfile = tempfile.mkstemp()[1] self.message = cdist.message.Message(prefix=self.prefix, - messages=self.tempfile) + messages=self.tempfile) def tearDown(self): os.remove(self.tempfile) @@ -48,7 +49,6 @@ class MessageTestCase(test.CdistTestCase): self.assertIn('__messages_in', env) self.assertIn('__messages_out', env) - def test_copy_content(self): """ Ensure content copying is working diff --git a/cdist/util/fsproperty.py b/cdist/util/fsproperty.py index 98de09f8..e458fd9e 100644 --- a/cdist/util/fsproperty.py +++ b/cdist/util/fsproperty.py @@ -136,7 +136,7 @@ class DirectoryDict(collections.MutableMapping): with open(os.path.join(self.path, key), "w") as fd: if (not hasattr(value, 'strip') and (hasattr(value, '__getitem__') or - hasattr(value, '__iter__'))): + hasattr(value, '__iter__'))): # if it looks like a sequence and quacks like a sequence, # it is a sequence for v in value: @@ -175,14 +175,19 @@ class FileBasedProperty(object): """ :param path: string or callable - Abstract super class. Subclass and set the class member attribute_class accordingly. + Abstract super class. Subclass and set the class member + attribute_class accordingly. Usage with a sublcass: class Foo(object): - # note that the actual DirectoryDict is stored as __parameters on the instance - parameters = DirectoryDictProperty(lambda instance: os.path.join(instance.absolute_path, 'parameter')) - # note that the actual DirectoryDict is stored as __other_dict on the instance + # note that the actual DirectoryDict is stored as __parameters + # on the instance + parameters = DirectoryDictProperty( + lambda instance: os.path.join(instance.absolute_path, + 'parameter')) + # note that the actual DirectoryDict is stored as __other_dict + # on the instance other_dict = DirectoryDictProperty('/tmp/other_dict') def __init__(self): diff --git a/completions/bash/cdist-completion.bash b/completions/bash/cdist-completion.bash new file mode 100644 index 00000000..3d396bb4 --- /dev/null +++ b/completions/bash/cdist-completion.bash @@ -0,0 +1,59 @@ +_cdist() +{ + local cur prev prevprev opts cmds projects + COMPREPLY=() + cur="${COMP_WORDS[COMP_CWORD]}" + prev="${COMP_WORDS[COMP_CWORD-1]}" + prevprev="${COMP_WORDS[COMP_CWORD-2]}" + opts="-h --help -d --debug -v --verbose -V --version" + cmds="banner shell config" + + case "${prevprev}" in + shell) + case "${prev}" in + -s|--shell) + shells=$(grep -v '^#' /etc/shells) + COMPREPLY=( $(compgen -W "${shells}" -- ${cur}) ) + return 0 + ;; + esac + ;; + esac + + case "${prev}" in + -*) + COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) + return 0 + ;; + banner) + opts="-h --help -d --debug -v --verbose" + COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) + return 0 + ;; + shell) + opts="-h --help -d --debug -v --verbose -s --shell" + COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) + return 0 + ;; + config) + opts="-h --help -d --debug -v --verbose \ + -c --conf-dir -f --file -i --initial-manifest -n --dry-run \ + -o --out-dir -p --parallel -s --sequential --remote-copy \ + --remote-exec" + COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) + return 0 + ;; + *) + ;; + esac + + if [[ ${cur} == -* ]]; then + COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) + return 0 + fi + + COMPREPLY=( $(compgen -W "${cmds}" -- ${cur}) ) + return 0 +} + +complete -F _cdist cdist diff --git a/completions/zsh/_cdist b/completions/zsh/_cdist new file mode 100644 index 00000000..2bf324a6 --- /dev/null +++ b/completions/zsh/_cdist @@ -0,0 +1,48 @@ +#compdef cdist + +_cdist() +{ + local curcontext="$curcontext" state line + typeset -A opt_args + + _arguments \ + '1: :->opts_cmds'\ + '*: :->opts' + + case $state in + opts_cmds) + _arguments '1:Options and commands:(banner config shell -h --help -d --debug -v --verbose -V --version)' + ;; + *) + case $words[2] in + -*) + opts=(-h --help -d --debug -v --verbose -V --version) + compadd "$@" -- $opts + ;; + banner) + opts=(-h --help -d --debug -v --verbose) + compadd "$@" -- $opts + ;; + shell) + case $words[3] in + -s|--shell) + shells=($(grep -v '^#' /etc/shells)) + compadd "$@" -- $shells + ;; + *) + opts=(-h --help -d --debug -v --verbose -s --shell) + compadd "$@" -- $opts + ;; + esac + ;; + config) + opts=(-h --help -d --debug -v --verbose -c --conf-dir -f --file -i --initial-manifest -n --dry-run -o --out-dir -p --parallel -s --sequential --remote-copy --remote-exec) + compadd "$@" -- $opts + ;; + *) + ;; + esac + esac +} + +_cdist "$@" diff --git a/docs/2016-06-06.org b/docs/2016-06-06.org new file mode 100644 index 00000000..8e3624a8 --- /dev/null +++ b/docs/2016-06-06.org @@ -0,0 +1,7 @@ +* Enhance cdist speed +** Start separate server with own option +** Reconfigure normal sshd with appropriate options +** Start various own daemons +** Use custom multiplexing protocol +** Support native Python code +*** Use manifest.py instead of manifest if available diff --git a/docs/changelog b/docs/changelog index dada1d90..a5b1a6c3 100644 --- a/docs/changelog +++ b/docs/changelog @@ -1,6 +1,20 @@ Changelog --------- +next: + * Core: pep8 (Darko Poljak) + * Documentation: Restructure and fix and improve docs and manpages (Darko Poljak) + * Core: Add files directory for static files (Darko Poljak) + * Custom: Add bash and zsh completions (Darko Poljak) + * Core: Improve error reporting for local and remote run command (Darko Poljak) + * New type: __jail_freebsd9: Handle jail management on FreeBSD <= 9.X (Jake Guffey) + * New type: __jail_freebsd10: Handle jail management on FreeBSD >= 10.0 (Jake Guffey) + * Type __jail: Dynamically select the correct jail subtype based on target host OS (Jake Guffey) + * Explorer __machine_type: add openvz and lxc + * Explorer __os __os_version: add scientific + * Type various: add scientific + * Explorer __machine_type: add virtualbox (Stu Zhao) + 4.1.0: 2016-05-27 * Documentation: Migrate to reStructuredText format and sphinx (Darko Poljak) * Core: Add -f option to read additional hosts from file/stdin (Darko Poljak) diff --git a/docs/man/Makefile b/docs/man/Makefile index 721acaf6..800a80d8 100644 --- a/docs/man/Makefile +++ b/docs/man/Makefile @@ -5,7 +5,9 @@ SPHINXOPTS = SPHINXBUILD = sphinx-build PAPER = -BUILDDIR = _build +BUILDDIR = ../dist +# for cache, etc. +_BUILDDIR = _build # User-friendly check for sphinx-build ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1) @@ -15,7 +17,7 @@ endif # Internal variables. PAPEROPT_a4 = -D latex_paper_size=a4 PAPEROPT_letter = -D latex_paper_size=letter -ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . +ALLSPHINXOPTS = -d $(_BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . # the i18n builder cannot share the environment and doctrees with the others I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . @@ -52,6 +54,7 @@ help: .PHONY: clean clean: rm -rf $(BUILDDIR)/* + rm -rf $(_BUILDDIR)/* .PHONY: html html: @@ -161,7 +164,11 @@ text: .PHONY: man man: - $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man + $(SPHINXBUILD) -b cman $(ALLSPHINXOPTS) $(BUILDDIR)/man + mkdir -p $(BUILDDIR)/man/man1 + mkdir -p $(BUILDDIR)/man/man7 + mv -f $(BUILDDIR)/man/*.1 $(BUILDDIR)/man/man1/ + mv -f $(BUILDDIR)/man/*.7 $(BUILDDIR)/man/man7/ @echo @echo "Build finished. The manual pages are in $(BUILDDIR)/man." diff --git a/docs/man/man7/cdist-best-practice.rst b/docs/man/cdist-best-practice.rst similarity index 91% rename from docs/man/man7/cdist-best-practice.rst rename to docs/man/cdist-best-practice.rst index 13d65cce..57ce5cc1 100644 --- a/docs/man/man7/cdist-best-practice.rst +++ b/docs/man/cdist-best-practice.rst @@ -1,11 +1,8 @@ -cdist-best-practice(7) -====================== +Best practice +============= Practices used in real environments -Nico Schottelius - - -PASSWORDLESS CONNECTIONS +Passwordless connections ------------------------ It is recommended to run cdist with public key authentication. This requires a private/public key pair and the entry @@ -13,7 +10,7 @@ This requires a private/public key pair and the entry See sshd_config(5) and ssh-keygen(1). -SPEEDING UP SSH CONNECTIONS +Speeding up ssh connections --------------------------- When connecting to a new host, the initial delay with ssh connections is pretty big. You can work around this by @@ -27,7 +24,7 @@ inclusion into your ~/.ssh/config:: ControlPersist 10 -SPEEDING UP SHELL EXECUTION +Speeding up shell execution ---------------------------- On the source host, ensure that /bin/sh is *not* bash: bash is quite slow for script execution. Instead, you could use dash after installing it:: @@ -35,7 +32,7 @@ script execution. Instead, you could use dash after installing it:: ln -sf /bin/dash /bin/sh -MULTI MASTER OR ENVIRONMENT SETUPS +Multi master or environment setups ---------------------------------- If you plan to distribute cdist among servers or use different environments, you can do so easily with the included version @@ -61,7 +58,7 @@ you can clone it multiple times:: machine-b % git clone git://your-git-server/cdist -SEPERATING WORK BY GROUPS +Seperating work by groups ------------------------- If you are working with different groups on one cdist-configuration, you can delegate to other manifests and have the groups edit only @@ -74,7 +71,7 @@ their manifests. You can use the following snippet in sh -e "$__manifest/cbrg" -MAINTAINING MULTIPLE CONFIGURATIONS +Maintaining multiple configurations ----------------------------------- When you need to manage multiple sites with cdist, like company_a, company_b and private for instance, you can easily use git for this purpose. @@ -135,7 +132,7 @@ The following **.git/config** is taken from a a real world scenario:: Have a look at git-remote(1) to adjust the remote configuration, which allows -MULTIPLE DEVELOPERS WITH DIFFERENT TRUST +Multiple developers with different trust ---------------------------------------- If you are working in an environment that requires different people to work on the same configuration, but having different privileges, you can @@ -152,7 +149,7 @@ implement this scenario with a gateway host and sudo: For more details consult sudoers(5) -TEMPLATING +Templating ---------- * 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 @@ -190,7 +187,7 @@ TEMPLATING --source "$__object/files/basic.conf" -TESTING A NEW TYPE +Testing a new type ------------------ If you want to test a new type on a node, you can tell cdist to only use an object of this type: Use the '--initial-manifest' parameter @@ -211,7 +208,7 @@ of cdist: cdist --initial-manifest - cdist-dev-01.ungleich.ch -OTHER CONTENT IN CDIST REPOSITORY +Other content in cdist repository --------------------------------- Usually the cdist repository contains all configuration items. Sometimes you may have additional resources that @@ -224,15 +221,3 @@ in the repository for such content: It allows you to easily distinguish what is used by cdist and what not and also to store all important files in one repository. - - -SEE ALSO --------- -- `cdist(1) <../man1/cdist.html>`_ -- `cdist-tutorial(7) `_ - - -COPYING -------- -Copyright \(C) 2011-2013 Nico Schottelius. Free use of this software is -granted under the terms of the GNU General Public License version 3 (GPLv3). diff --git a/docs/man/man7/cdist-bootstrap.rst b/docs/man/cdist-bootstrap.rst similarity index 86% rename from docs/man/man7/cdist-bootstrap.rst rename to docs/man/cdist-bootstrap.rst index df55e2af..c9972a99 100644 --- a/docs/man/man7/cdist-bootstrap.rst +++ b/docs/man/cdist-bootstrap.rst @@ -1,18 +1,11 @@ -cdist-bootstrap(7) -================== -Setup cdist environment - -Nico Schottelius - - -INTRODUCTION ------------- +Bootstrap +========= This document describes the usual steps recommended for a new cdist setup. It is recommended that you have read and understood -cdist-quickstart(7) before digging into this. +`cdist quickstart `_ before digging into this. -LOCATION +Location --------- First of all, you should think about where to store your configuration database and who will be accessing or changing it. Secondly you have to @@ -26,13 +19,13 @@ relies on is recommended, for use as backup as well as to allow easy collaborati with others. For more sophisticated setups developing cdist configurations with multiple -people, have a look at cdist-best-practice(7). +people, have a look at `cdist best practice `_. -SETUP WORKING DIRECTORY AND BRANCH +Setup working directory and branch ---------------------------------- I assume you have a fresh copy of the cdist tree in ~/cdist, cloned from -one of the official urls (see cdist-quickstart(7) if you don't). +one of the official urls (see `cdist quickstart `_ if you don't). Entering the command "git branch" should show you "* master", which indicates you are on the **master** branch. @@ -82,7 +75,7 @@ In this tutorial I use the branch **mycompany**:: From now on, you can use git as usual to commit your changes in your own branch. -PUBLISHING THE CONFIGURATION +Publishing the configuration ---------------------------- Usually a development machine like a notebook should be considered temporary only. For this reason and to enable shareability, the configuration @@ -111,7 +104,7 @@ branch with the **master** branch on the host **loch**. Thus you can commit as usual in your branch and push out changes by entering **git push**. -UPDATING FROM ORIGIN +Updating from origin -------------------- Whenever you want to update your cdist installation, you can use git to do so:: @@ -123,15 +116,3 @@ Whenever you want to update your cdist installation, you can use git to do so:: # Alternative: Update current branch with 2.0 branch from origin cdist% git merge origin/2.0 - - -SEE ALSO --------- -- `cdist(1) <../man1/cdist.html>`_ -- `cdist-tutorial(7) `_ - - -COPYING -------- -Copyright \(C) 2012 Nico Schottelius. Free use of this software is -granted under the terms of the GNU General Public License version 3 (GPLv3). diff --git a/docs/man/man7/cdist-explorer.rst b/docs/man/cdist-explorer.rst similarity index 76% rename from docs/man/man7/cdist-explorer.rst rename to docs/man/cdist-explorer.rst index 1bbd7e75..4bb61d7a 100644 --- a/docs/man/man7/cdist-explorer.rst +++ b/docs/man/cdist-explorer.rst @@ -1,11 +1,7 @@ -cdist-explorer(7) -================= -Explore the target systems +Explorer +======== -Nico Schottelius - - -DESCRIPTION +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 @@ -36,7 +32,7 @@ error message on stderr, which will cause cdist to abort. You can also use stderr for debugging purposes while developing a new explorer. -EXAMPLES +Examples -------- A very simple explorer may look like this:: @@ -56,16 +52,3 @@ A type explorer, which could check for the status of a package may look like thi # Expect dpkg failing, if package is not known / installed dpkg -s "$name" 2>/dev/null || exit 0 - - -SEE ALSO --------- -- `cdist(1) <../man1/cdist.html>`_ -- `cdist-reference(7) `_ -- `cdist-stages(7) `_ - - -COPYING -------- -Copyright \(C) 2010-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/docs/man/cdist-features.rst b/docs/man/cdist-features.rst new file mode 100644 index 00000000..8a147741 --- /dev/null +++ b/docs/man/cdist-features.rst @@ -0,0 +1,48 @@ +Features +======== + +But cdist ticks differently, here is the feature set that makes it unique: + +Simplicity + There is only one type to extend cdist called **type** + +Design + + Type and core cleanly seperated + + Sticks completly to the KISS (keep it simple and stupid) paradigma + + Meaningful error messages - do not lose time debugging error messages + + Consistency in behaviour, naming and documentation + + No surprise factor: Only do what is obviously clear, no magic + + Define target state, do not focus on methods or scripts + + Push architecture: Instantly apply your changes + +Small core + cdist's core is very small - less code, less bugs + +Fast development + Focus on straightforwardness of type creation is a main development objective + Batteries included: A lot of requirements can be solved using standard types + +Modern Programming Language + cdist is written in Python + +Requirements, Scalability + No central server needed, cdist operates in push mode and can be run from any computer + +Requirements, Scalability, Upgrade + cdist only needs to be updated on the master, not on the target hosts + +Requirements, Security + Uses well-know `SSH `_ as transport protocol + +Requirements, Simplicity + Requires only shell and SSH server on the target + +UNIX + Reuse of existing tools like cat, find, mv, ... + +UNIX, familar environment, documentation + Is available as manpages and HTML + +UNIX, simplicity, familar environment + cdist is configured in POSIX shell + diff --git a/docs/man/man7/cdist-hacker.rst b/docs/man/cdist-hacker.rst similarity index 87% rename from docs/man/man7/cdist-hacker.rst rename to docs/man/cdist-hacker.rst index 1d0e7f2e..326d83ba 100644 --- a/docs/man/man7/cdist-hacker.rst +++ b/docs/man/cdist-hacker.rst @@ -1,11 +1,7 @@ -cdist-hacker(7) -=============== -How to get (stuff) into cdist +Hacking +======= -Nico Schottelius - - -WELCOME +Welcome ------- Welcome dear hacker! I invite you to a tour of pointers to get into the usable configuration mangament system, cdist. @@ -16,14 +12,14 @@ twice before merging or implementing a feature: Less features with good usability are far better than the opposite. -REPORTING BUGS +Reporting bugs -------------- If you believe you've found a bug and verified that it is in the latest version, drop a mail to the cdist mailing list, subject prefixed with "[BUG] " or create an issue on github. -CODING CONVENTIONS (EVERYWHERE) +Coding conventions (everywhere) ------------------------------- If something should be better done or needs to fixed, add the word FIXME nearby, so grepping for FIXME gives all positions that need to be fixed. @@ -31,7 +27,7 @@ nearby, so grepping for FIXME gives all positions that need to be fixed. Indention is 4 spaces (welcome to the python world). -HOW TO SUBMIT STUFF FOR INCLUSION INTO UPSTREAM CDIST +How to submit stuff for inclusion into upstream cdist ----------------------------------------------------- If you did some cool changes to cdist, which you value as a benefit for everybody using cdist, you're welcome to propose inclusion into upstream. @@ -58,9 +54,9 @@ for inclusion to the mailinglist **cdist at cdist -- at -- l.schottelius.org** or open a pull request at http://github.com/telmich/cdist. -HOW TO SUBMIT A NEW TYPE +How to submit a new type ------------------------ -For detailled information about types, see cdist-type(7). +For detailled information about types, see `cdist type `_. Submitting a type works as described above, with the additional requirement that a corresponding manpage named man.text in asciidoc format with @@ -74,9 +70,11 @@ code and thus such a type introduces redundant functionality that is given by core cdist already. -EXAMPLE GIT WORKFLOW +Example git workflow --------------------- -The following workflow works fine for most developers:: +The following workflow works fine for most developers + +.. code-block:: sh # get latest upstream master branch git clone https://github.com/telmich/cdist.git @@ -122,6 +120,8 @@ The following workflow works fine for most developers:: If at any point you want to go back to the original master branch, you can use **git stash** to stash your changes away:: +.. code-block:: sh + # assume you are on documentation_cleanup git stash @@ -133,6 +133,8 @@ use **git stash** to stash your changes away:: Similar when you want to develop another new feature, you go back to the master branch and create another branch based on it:: +.. code-block:: sh + # change to master and update to most recent upstream version git checkout master git fetch -v origin @@ -142,17 +144,3 @@ to the master branch and create another branch based on it:: (you can repeat the code above for as many features as you want to develop in parallel) - - -SEE ALSO --------- -- `cdist(1) <../man1/cdist.html>`_ -- git(1) -- git-checkout(1) -- git-stash(1) - - -COPYING -------- -Copyright \(C) 2011-2013 Nico Schottelius. Free use of this software is -granted under the terms of the GNU General Public License version 3 (GPLv3). diff --git a/docs/man/cdist-install.rst b/docs/man/cdist-install.rst new file mode 100644 index 00000000..f950a1ee --- /dev/null +++ b/docs/man/cdist-install.rst @@ -0,0 +1,116 @@ +How to install cdist +==================== + +Requirements +------------- + +Source Host +~~~~~~~~~~~ + +This is the machine you use to configure the target hosts. + + * /bin/sh: A posix like shell (for instance bash, dash, zsh) + * Python >= 3.2 + * SSH client + * sphinx (for building html docs and/or the manpages) + +Target Hosts +~~~~~~~~~~~~ + + * /bin/sh: A posix like shell (for instance bash, dash, zsh) + * SSH server + +Install cdist +------------- + +You can install cdist either from git or as a python package. + +From git +~~~~~~~~ + +Cloning cdist from git gives you the advantage of having +a version control in place for development of your own stuff +immediately. + +To install cdist, execute the following commands: + +.. code-block:: sh + + git clone https://github.com/ungleich/cdist.git + cd cdist + export PATH=$PATH:$(pwd -P)/bin + +Available versions in git +^^^^^^^^^^^^^^^^^^^^^^^^^ + + * The active development takes place in the **master** branch + * The released versions can be found in the tags + +Other branches may be available for features or bugfixes, but they +may vanish at any point. To select a specific branch use + +.. code-block:: sh + + # Generic code + git checkout -b origin/ + +So for instance if you want to use and stay with version 4.1, you can use + +.. code-block:: sh + + git checkout -b 4.1 origin/4.1 + +Git mirrors +^^^^^^^^^^^ + +If the main site is down, you can acquire cdist from one of the following sites: + + * git://github.com/telmich/cdist.git `github `_ + * git://git.code.sf.net/p/cdist/code `sourceforge `_ + +Building and using manpages +^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +If you want to build and use the manpages, run: + +.. code-block:: sh + + make man + export MANPATH=$MANPATH:$(pwd -P)/docs/dist/man + +Or you can move manpages from docs/dist/man directory to some +other directory and add it to MANPATH. + +You can also build manpages for types in your ~/.cdist directory: + +.. code-block:: sh + + make dotman + +Built manpages are now in docs/dist/man directory. If you have +some other custom .cdist directory, e.g. /opt/cdist then use: + +.. code-block:: sh + + DOT_CDIST_PATH=/opt/cdist make dotman + +Building and using HTML documentation +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +If you want to build and use HTML documentation, run: + +.. code-block:: sh + + make html + +Now you can access docs/dist/html/index.html. + +Python package +~~~~~~~~~~~~~~ + +Cdist is available as a python package at +`PyPi `_. You can install it using + +.. code-block:: sh + + pip install cdist diff --git a/docs/man/cdist-intro.rst b/docs/man/cdist-intro.rst new file mode 100644 index 00000000..fad40fe5 --- /dev/null +++ b/docs/man/cdist-intro.rst @@ -0,0 +1,15 @@ +cdist - usable configuration management +======================================= + +.. image:: cdist-logo.png + :alt: cdist-logo + +cdist is a usable configuration management system. +It adheres to the KISS principle and +is being used in small up to enterprise grade environments. +cdist is an alternative to other configuration management systems like + +* `bcfg2 `_ +* `chef `_ +* `cfengine `_ +* `puppet `_. diff --git a/docs/man/cdist-logo.png b/docs/man/cdist-logo.png new file mode 100644 index 00000000..13c27927 Binary files /dev/null and b/docs/man/cdist-logo.png differ diff --git a/docs/man/man7/cdist-manifest.rst b/docs/man/cdist-manifest.rst similarity index 92% rename from docs/man/man7/cdist-manifest.rst rename to docs/man/cdist-manifest.rst index c8984acf..5c35b6a5 100644 --- a/docs/man/man7/cdist-manifest.rst +++ b/docs/man/cdist-manifest.rst @@ -1,11 +1,7 @@ -cdist-manifest(7) -================= -(Re-)Use types +Manifest +======== -Nico Schottelius - - -DESCRIPTION +Description ----------- Manifests are used to define which objects to create. Objects are instances of **types**, like in object oriented programming languages. @@ -41,15 +37,15 @@ In general, manifests are used to define which types are used depending on given conditions. -INITIAL AND TYPE MANIFESTS +Initial and type manifests -------------------------- Cdist knows about two types of manifests: The initial manifest and type manifests. The initial manifest is used to define, which configurations to apply to which hosts. The type manifests are used to create objects -from types. More about manifests in types can be found in cdist-type(7). +from types. More about manifests in types can be found in `cdist type `_. -DEFINE STATE IN THE INITIAL MANIFEST +Define state in the initial manifest ------------------------------------ The **initial manifest** is the entry point for cdist to find out, which **objects** to configure on the selected host. @@ -79,12 +75,12 @@ utilises cdist types. Every available type can be executed like a normal command. -SPLITTING UP THE INITIAL MANIFEST +Splitting up the initial manifest --------------------------------- If you want to split up your initial manifest, you can create other shell scripts in **cdist/conf/manifest/** and include them in **cdist/conf/manifest/init**. Cdist provides the environment variable **__manifest** to reference -the directory containing the initial manifest (see cdist-reference(7)). +the directory containing the initial manifest (see `cdist reference `_). The following example would include every file with a **.sh** suffix:: @@ -95,7 +91,7 @@ The following example would include every file with a **.sh** suffix:: done -DEPENDENCIES +Dependencies ------------ If you want to describe that something requires something else, just setup the variable "require" to contain the requirements. Multiple @@ -154,10 +150,10 @@ from the type that is calling them. This is called "autorequirement" in cdist jargon. You can find an more in depth description of the flow execution of manifests -in cdist-stages(7) and of how types work in cdist-type(7). +in `cdist execution stages `_ and of how types work in `cdist type `_. -CREATE DEPENDENCIES FROM EXECUTION ORDER +Create dependencies from execution order ----------------------------------------- You can tell cdist to execute all types in the order in which they are created in the manifest by setting up the variable CDIST_ORDER_DEPENDENCY. @@ -168,7 +164,7 @@ It essentially helps you to build up blocks of code that build upon each other (like first creating the directory xyz than the file below the directory). -OVERRIDES +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. @@ -184,7 +180,7 @@ CDIST_ORDER_DEPENDENCY will be ignored, because adding a dependency in case of overrides would result in circular dependencies, which is an error. -EXAMPLES +Examples -------- The initial manifest may for instance contain the following code: @@ -257,15 +253,3 @@ Dependencies defined by execution order work as following: require="__some_type_somewhere/id __sample_type/1" __sample_type 2 require="__sample_type/2" __example_type 23 __not_in_order_type 42 - - -SEE ALSO --------- -- `cdist-tutorial(7) `_ -- `cdist-type(7) `_ - - -COPYING -------- -Copyright \(C) 2010-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/docs/man/man7/cdist-messaging.rst b/docs/man/cdist-messaging.rst similarity index 79% rename from docs/man/man7/cdist-messaging.rst rename to docs/man/cdist-messaging.rst index 6f29a363..ea35c404 100644 --- a/docs/man/man7/cdist-messaging.rst +++ b/docs/man/cdist-messaging.rst @@ -1,10 +1,7 @@ -cdist-messaging(7) -================== -How the initial manifest and types can communication +Messaging +========= -Nico Schottelius - -DESCRIPTION +Description ----------- cdist has a simple but powerful way of allowing communication between the initial manifest and types as well as types and types. @@ -24,11 +21,11 @@ This way overwriting any of the two files by accident does not interfere with other types. The order of execution is not defined unless you create dependencies -between the different objects (see cdist-manifest(7)) and thus you +between the different objects (see `cdist manifest `_) and thus you can only react reliably on messages by objects that you depend on. -AVAILABILITY +Availability ------------ Messaging is possible between all **local** scripts: @@ -38,7 +35,7 @@ Messaging is possible between all **local** scripts: - type/gencode-remote -EXAMPLES +Examples -------- When you want to emit a message use: @@ -95,17 +92,3 @@ Restart sshd on changes if grep -q "^__key_value/PermitRootLogin" "$__messages_in"; then echo $restart fi - - -SEE ALSO --------- -- `cdist(1) <../man1/cdist.html>`_ -- `cdist-manifest(7) `_ -- `cdist-reference(7) `_ -- `cdist-type(7) `_ - - -COPYING -------- -Copyright \(C) 2013 Nico Schottelius. Free use of this software is -granted under the terms of the GNU General Public License version 3 (GPLv3). diff --git a/docs/man/cdist-os.rst b/docs/man/cdist-os.rst new file mode 100644 index 00000000..4f6b4820 --- /dev/null +++ b/docs/man/cdist-os.rst @@ -0,0 +1,16 @@ +Supported Operating Systems +=========================== + +cdist was tested or is know to run on at least + +* `Archlinux `_ +* `Debian `_ +* `CentOS `_ +* `Fedora `_ +* `FreeBSD `_ +* `Gentoo `_ +* `Mac OS X `_ +* `OpenBSD `_ +* `Redhat `_ +* `Ubuntu `_ +* `XenServer `_ diff --git a/docs/man/man7/cdist-quickstart.rst b/docs/man/cdist-quickstart.rst similarity index 83% rename from docs/man/man7/cdist-quickstart.rst rename to docs/man/cdist-quickstart.rst index d1186ffe..20c33cb8 100644 --- a/docs/man/man7/cdist-quickstart.rst +++ b/docs/man/cdist-quickstart.rst @@ -1,28 +1,18 @@ -cdist-quickstart(7) -=================== -Jump in and enjoy cdist +Quickstart +========== -Nico Schottelius - - -INTRODUCTION ------------- This tutorial is aimed at people learning cdist and shows typical approaches as well as gives an easy start into the world of configuration management. -This tutorial assumes you are configuring **localhost**, because -it is always available. Just replace **localhost** with your target -host for real life usage. - - - -QUICK START - GET YOUR HANDS DIRTY NOW --------------------------------------- For those who just want to configure a system with the cdist configuration management and do not need (or want) to understand everything. +This tutorial assumes you are configuring **localhost**, because +it is always available. Just replace **localhost** with your target +host for real life usage. + Cdist uses **ssh** for communication and transportation and usually logs into the **target host** as the **root** user. So you need to configure the **ssh server** @@ -81,15 +71,3 @@ code into your shell to get started and configure localhost:: That's it, you've successfully used cdist to configure your first host! Continue reading the next sections, to understand what you did and how to create a more sophisticated configuration. - - -SEE ALSO --------- -- `cdist(1) <../man1/cdist.html>`_ -- `cdist-tutorial(7) `_ - - -COPYING -------- -Copyright \(C) 2011-2012 Nico Schottelius. Free use of this software is -granted under the terms of the GNU General Public License version 3 (GPLv3). diff --git a/docs/man/cdist-reference.rst.sh b/docs/man/cdist-reference.rst.sh index 132d37b4..42eced05 100755 --- a/docs/man/cdist-reference.rst.sh +++ b/docs/man/cdist-reference.rst.sh @@ -29,20 +29,17 @@ __cdist_myname=${0##*/}; __cdist_abs_myname="$__cdist_abs_mydir/$__cdist_myname" filename="${__cdist_myname%.sh}" -dest="$__cdist_abs_mydir/man7/$filename" +dest="$__cdist_abs_mydir/$filename" cd "$__cdist_abs_mydir" exec > "$dest" cat << eof -cdist-reference(7) -================== +Reference +========= Variable, path and type reference for cdist -Nico Schottelius - - -EXPLORERS +Explorers --------- The following global explorers are available: @@ -56,7 +53,7 @@ eof cat << eof -PATHS +Paths ----- \$HOME/.cdist The standard cdist configuration directory relative to your home directory @@ -87,11 +84,11 @@ confdir/manifest/* maintain different groups of hosts. confdir/explorer/ - Contains explorers to be run on the target hosts, see cdist-explorer(7). + Contains explorers to be run on the target hosts, see \`cdist explorer \`_. confdir/type/ Contains all available types, which are used to provide - some kind of functionality. See cdist-type(7). + some kind of functionality. See \`cdist type \`_. confdir/type// Home of the type . @@ -126,7 +123,7 @@ confdir/type//parameter/boolean confdir/type//explorer Location of the type specific explorers. This directory is referenced by the variable __type_explorer (see below). - See cdist-explorer(7). + See \`cdist explorer \`_. confdir/type//files This directory is reserved for user data and will not be used @@ -151,27 +148,28 @@ out/object/ out/object//explorers Output of type specific explorers, per object. -TYPES +Types ----- The following types are available: eof -for type in $(ls man7/cdist-type__*.rst | LC_ALL=C sort); do +# If there is no such file then ls prints error to stderr, +# so redirect stderr to /dev/null. +for type in $(ls man7/cdist-type__*.rst 2>/dev/null | LC_ALL=C sort); do no_dir="${type#man7/}"; no_type="${no_dir#cdist-type}"; name="${no_type%.rst}"; - name_no_underline="$(echo $name | sed 's/^__/\\__/g')" manref="${no_dir%.rst}" man="${manref}(7)" - echo "- $name_no_underline" "(\`${man} <${manref}.html>\`_)" + echo "- $name" "(\`${man} \`_)" done cat << eof -OBJECTS +Objects ------- For object to object communication and tests, the following paths are usable within a object directory: @@ -188,7 +186,7 @@ stdin when the type was called. -ENVIRONMENT VARIABLES (FOR READING) +Environment variables (for reading) ----------------------------------- The following environment variables are exported by cdist: @@ -229,12 +227,12 @@ __type_explorer Directory that contains the type explorers. Available for: type explorer -ENVIRONMENT VARIABLES (FOR WRITING) +Environment variables (for writing) ----------------------------------- The following environment variables influence the behaviour of cdist: require - Setup dependencies between objects (see cdist-manifest(7)) + Setup dependencies between objects (see \`cdist manifest \`_) CDIST_LOCAL_SHELL Use this shell locally instead of /bin/sh to execute scripts @@ -243,24 +241,14 @@ CDIST_REMOTE_SHELL Use this shell remotely instead of /bin/sh to execute scripts CDIST_OVERRIDE - Allow overwriting type parameters (see cdist-manifest(7)) + Allow overwriting type parameters (see \`cdist manifest \`_) CDIST_ORDER_DEPENDENCY - Create dependencies based on the execution order (see cdist-manifest(7)) + Create dependencies based on the execution order (see \`cdist manifest \`_) CDIST_REMOTE_EXEC Use this command for remote execution (should behave like ssh) CDIST_REMOTE_COPY Use this command for remote copy (should behave like scp) - -SEE ALSO --------- -- \`cdist(1) <../man1/cdist.html>\`_ - - -COPYING -------- -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). eof diff --git a/docs/man/man7/cdist-remote-exec-copy.rst b/docs/man/cdist-remote-exec-copy.rst similarity index 62% rename from docs/man/man7/cdist-remote-exec-copy.rst rename to docs/man/cdist-remote-exec-copy.rst index 27b78d42..10a370c7 100644 --- a/docs/man/man7/cdist-remote-exec-copy.rst +++ b/docs/man/cdist-remote-exec-copy.rst @@ -1,12 +1,6 @@ -cdist-remote-exec-copy(7) -========================= -How to use remote exec and copy +Remote exec and copy commands +============================= -Nico Schottelius - - -INTRO ------ Cdist interacts with the target host in two ways: - it executes code (__remote_exec) @@ -27,19 +21,3 @@ For __remote_copy, it must behave like scp. With this simple interface the user can take total control of how cdist interacts with the target when required, while the default implementation remains as simple as possible. - - -EXAMPLES --------- -See cdist/other/examples/remote/ for some example implementations. - - -SEE ALSO --------- -- `cdist(1) <../man1/cdist.html>`_ - - -COPYING -------- -Copyright \(C) 2011-2012 Nico Schottelius. Free use of this software is -granted under the terms of the GNU General Public License version 3 (GPLv3). diff --git a/docs/man/man7/cdist-stages.rst b/docs/man/cdist-stages.rst similarity index 78% rename from docs/man/man7/cdist-stages.rst rename to docs/man/cdist-stages.rst index 4b29585d..fd19ce0d 100644 --- a/docs/man/man7/cdist-stages.rst +++ b/docs/man/cdist-stages.rst @@ -1,16 +1,13 @@ -cdist-stages(7) -=============== -Stages used during configuration deployment +Execution stages +================ -Nico Schottelius - -DESCRIPTION +Description ----------- Starting the execution of deployment with cdist, cdist passes through different stages. -STAGE 1: TARGET INFORMATION RETRIEVAL +Stage 1: target information retrieval ------------------------------------- In this stage information is collected about the target host using so called explorers. Every existing explorer is run on the target and the output of all @@ -18,7 +15,7 @@ explorers are copied back into the local cache. The results can be used by manifests and types. -STAGE 2: RUN THE INITIAL MANIFEST +Stage 2: run the initial manifest --------------------------------- The initial manifest, which should be used for mappings of hosts to types, is executed. This stage creates objects in a cconfig database that contains @@ -27,7 +24,7 @@ no conflicts may occur, i.e. no object of the same type with the same id may be created, if it has different parameters. -STAGE 3: OBJECT INFORMATION RETRIEVAL +Stage 3: object information retrieval ------------------------------------- Every object is checked whether its type has explorers and if so, these are executed on the target host. The results are transferred back @@ -35,7 +32,7 @@ and can be used in the following stages to decide what changes need to be made on the target to implement the desired state. -STAGE 4: RUN THE OBJECT MANIFEST +Stage 4: run the object manifest -------------------------------- Every object is checked whether its type has a executable manifest. The manifest script may generate and change the created objects. In other words, @@ -49,7 +46,7 @@ may occur during the merge. A conflict would mean that two different objects try to create the same object, which indicates a broken configuration. -STAGE 5: CODE GENERATION +Stage 5: code generation ------------------------ In this stage for every created object its type is checked for executable gencode scripts. The gencode scripts generate the code to be executed on the @@ -57,30 +54,18 @@ target on stdout. If the gencode executables fail, they must print diagnostic messages on stderr and exit non-zero. -STAGE 6: CODE EXECUTION +Stage 6: code execution ----------------------- For every object the resulting code from the previous stage is transferred to the target host and executed there to apply the configuration changes. -STAGE 7: CACHE +Stage 7: cache -------------- The cache stores the information from the current run for later use. -SUMMARY +Summary ------- If, and only if, all the stages complete without an errors, the configuration will be applied to the target. - - -SEE ALSO --------- -- `cdist(1) <../man1/cdist.html>`_ -- `cdist-reference(7) `_ - - -COPYING -------- -Copyright \(C) 2010-2012 Nico Schottelius, Steven Armstrong. Free use of this software is -granted under the terms of the GNU General Public License version 3 (GPLv3). diff --git a/docs/man/cdist-support.rst b/docs/man/cdist-support.rst new file mode 100644 index 00000000..2343500e --- /dev/null +++ b/docs/man/cdist-support.rst @@ -0,0 +1,28 @@ +Support +------- + +IRC +~~~ + +You can join the development ***IRC channel*** +`#cstar on irc.freenode.net `_. + +Mailing list +~~~~~~~~~~~~ + +Bug reports, questions, patches, etc. should be send to the +`cdist mailing list `_. + +Linkedin +~~~~~~~~ + +If you have an account +at `Linked in `_, +you can join the +`cdist group `_. + +Commercial support +~~~~~~~~~~~~~~~~~~ + +You can request commercial support for cdist from +`my company `_. diff --git a/docs/man/man7/cdist-troubleshooting.rst b/docs/man/cdist-troubleshooting.rst similarity index 74% rename from docs/man/man7/cdist-troubleshooting.rst rename to docs/man/cdist-troubleshooting.rst index 075c3480..b016e845 100644 --- a/docs/man/man7/cdist-troubleshooting.rst +++ b/docs/man/cdist-troubleshooting.rst @@ -1,11 +1,7 @@ -cdist-troubleshooting(7) -======================== -Common problems and their solutions +Troubleshooting +=============== -Nico Schottelius - - -ERROR IN MANIFEST IS NOT CONSIDERED AN ERROR BY CDIST +Error in manifest is not considered an error by cdist ----------------------------------------------------- Situation: You are executing other scripts from a manifest. This script fails, but cdist does not recognise the error. @@ -47,15 +43,3 @@ you write to use the -e flag: % cat ~/.cdist/manifest/special #!/bin/sh -e ... - - -SEE ALSO --------- -- `cdist(1) <../man1/cdist.html>`_ -- `cdist-tutorial(7) `_ - - -COPYING -------- -Copyright \(C) 2013 Nico Schottelius. Free use of this software is -granted under the terms of the GNU General Public License version 3 (GPLv3). diff --git a/docs/man/man7/cdist-type.rst b/docs/man/cdist-type.rst similarity index 88% rename from docs/man/man7/cdist-type.rst rename to docs/man/cdist-type.rst index cfd331e1..c75d0a52 100644 --- a/docs/man/man7/cdist-type.rst +++ b/docs/man/cdist-type.rst @@ -1,28 +1,24 @@ -cdist-type(7) -============= -Functionality bundled +cdist type +========== -Nico Schottelius - - -SYNOPSIS --------- - -:: - - __TYPE ID --parameter value [--parameter value ...] - __TYPE --parameter value [--parameter value ...] (for singletons) - - -DESCRIPTION +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. +Synopsis +-------- -HOW TO USE A TYPE +.. code-block:: sh + + __TYPE ID --parameter value [--parameter value ...] + __TYPE --parameter value [--parameter value ...] (for singletons) + + +How to use a type ----------------- + You can use types from the initial manifest or the type manifest like a normal shell command: @@ -34,10 +30,10 @@ normal shell command: # Ensure tree is installed __package tree --state installed -A list of supported types can be found in the cdist-reference(7) manpage. +A list of supported types can be found in the `cdist reference `_ manpage. -SINGLETON TYPES +Singleton types --------------- If a type is flagged as a singleton, it may be used only once per host. This is useful for types which can be used only once on a @@ -55,7 +51,7 @@ Example: __myfancysingleton --colour green -HOW TO WRITE A NEW TYPE +How to write a new type ----------------------- A type consists of @@ -71,7 +67,7 @@ two underscores (__) to prevent collisions with other executables in $PATH. To implement a new type, create the directory **cdist/conf/type/__NAME**. -DEFINING PARAMETERS +Defining parameters ------------------- Every type consists of required, optional and boolean parameters, which must each be declared in a newline separated file in **parameter/required**, @@ -99,7 +95,7 @@ Example: echo use_ssl >> cdist/conf/type/__nginx_vhost/parameter/boolean -USING PARAMETERS +Using parameters ---------------- The parameters given to a type can be accessed and used in all type scripts (e.g manifest, gencode, explorer). Note that boolean parameters are @@ -135,7 +131,7 @@ Example: (e.g. in cdist/conf/type/__nginx_vhost/manifest) fi -INPUT FROM STDIN +Input from stdin ---------------- Every type can access what has been written on stdin when it has been called. The result is saved into the **stdin** file in the object directory. @@ -165,7 +161,7 @@ In the __file type, stdin is used as source for the file, if - is used for sourc .... -WRITING THE MANIFEST +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 @@ -187,13 +183,13 @@ a shortened version looks like this: __package_$type "$@" As you can see, the type can reference different environment variables, -which are documented in cdist-reference(7). +which are documented in `cdist reference `_. Always ensure the manifest is executable, otherwise cdist will not be able -to execute it. For more information about manifests see cdist-manifest(7). +to execute it. For more information about manifests see `cdist manifest `_. -SINGLETON - ONE INSTANCE ONLY +Singleton - one instance only ----------------------------- If you want to ensure that a type can only be used once per target, you can mark it as a singleton: Just create the (empty) file "singleton" in your type @@ -213,7 +209,7 @@ As you can see, the object ID is omitted, because it does not make any sense, if your type can be used only once. -THE TYPE EXPLORERS +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. @@ -235,7 +231,7 @@ client, like this (shortened version from the type __file): fi -WRITING THE GENCODE SCRIPT +Writing the gencode script -------------------------- There are two gencode scripts: **gencode-local** and **gencode-remote**. The output of gencode-local is executed locally, whereas @@ -256,7 +252,7 @@ script, you can write to stderr: echo "touch /etc/cdist-configured" -VARIABLE ACCESS FROM THE GENERATED SCRIPTS +Variable access from the generated scripts ------------------------------------------ In the generated scripts, you have access to the following cdist variables @@ -277,7 +273,7 @@ So when you generate a script with the following content, it will work: fi -HINTS FOR TYPEWRITERS +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 @@ -294,21 +290,8 @@ a folder named "files" within the type (again, because cdist guarantees to never ever touch this folder). -HOW TO INCLUDE A TYPE INTO UPSTREAM CDIST +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 have a look at cdist-hacker(7) on +current master branch of cdist and have a look at `cdist hacking `_ on how to submit it. - -SEE ALSO --------- -- `cdist-explorer(7) `_ -- `cdist-hacker(7) `_ -- `cdist-stages(7) `_ -- `cdist-tutorial(7) `_ - - -COPYING -------- -Copyright \(C) 2011-2012 Nico Schottelius. Free use of this software is -granted under the terms of the GNU General Public License version 3 (GPLv3). diff --git a/docs/man/cdist-types.rst b/docs/man/cdist-types.rst new file mode 100644 index 00000000..d5104667 --- /dev/null +++ b/docs/man/cdist-types.rst @@ -0,0 +1,8 @@ +cdist types +=========== + +.. toctree:: + :titlesonly: + :glob: + + man7/* diff --git a/docs/man/cdist-update.rst b/docs/man/cdist-update.rst new file mode 100644 index 00000000..0b445ba4 --- /dev/null +++ b/docs/man/cdist-update.rst @@ -0,0 +1,188 @@ +How to update cdist +=================== + +Update the git installation +--------------------------- + +To upgrade cdist in the current branch use + +.. code-block:: sh + + git pull + + # Also update the manpages + ./build man + export MANPATH=$MANPATH:$(pwd -P)/doc/man + +If you stay on a version branche (i.e. 1.0, 1.1., ...), nothing should break. +The master branch on the other hand is the development branch and may not be +working, break your setup or eat the tree in your garden. + +Safely upgrading to new versions +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +To upgrade to **any** further cdist version, you can take the +following procedure to do a safe upgrade: + +.. code-block:: sh + + # Create new branch to try out the update + git checkout -b upgrade_cdist + + # Get latest cdist version in git database + git fetch -v + + # see what will happen on merge - replace + # master with the branch you plan to merge + git diff upgrade_cdist..origin/master + + # Merge the new version + git merge origin/master + +Now you can ensure all custom types work with the new version. +Assume that you need to go back to an older version during +the migration/update, you can do so as follows: + +.. code-block:: sh + + # commit changes + git commit -m ... + + # go back to original branch + git checkout master + +After that, you can go back and continue the upgrade: + +.. code-block:: sh + + # git checkout upgrade_cdist + + +Update the python package +------------------------- + +To upgrade to the lastet version do + +.. code-block:: sh + + pip install --upgrade cdist + +General update instructions +--------------------------- + +Updating from 3.0 to 3.1 +~~~~~~~~~~~~~~~~~~~~~~~~ + +The type **\_\_ssh_authorized_keys** now also manages existing keys, +not only the ones added by cdist. + +Updating from 2.3 to 3.0 +~~~~~~~~~~~~~~~~~~~~~~~~ + +The **changed** attribute of objects has been removed. +Use `messaging `_ instead. + +Updating from 2.2 to 2.3 +~~~~~~~~~~~~~~~~~~~~~~~~ + +No incompatiblities. + +Updating from 2.1 to 2.2 +~~~~~~~~~~~~~~~~~~~~~~~~ + +Starting with 2.2, the syntax for requiring a singleton type changed: +Old format: + +.. code-block:: sh + + require="__singleton_type/singleton" ... + +New format: + +.. code-block:: sh + + require="__singleton_type" ... + +Internally the "singleton" object id was dropped to make life more easy. +You can probably fix your configuration by running the following code +snippet (currently untested, please report back if it works for you): + +.. code-block:: sh + + find ~/.cdist/* -type f -exec sed -i 's,/singleton,,' {} \; + +Updating from 2.0 to 2.1 +~~~~~~~~~~~~~~~~~~~~~~~~ + +Have a look at the update guide for [[2.0 to 2.1|2.0-to-2.1]]. + + * Type **\_\_package* and \_\_process** use --state **present** or **absent**. + The states **removed/installed** and **stopped/running** have been removed. + Support for the new states is already present in 2.0. + * Type **\_\_directory**: Parameter --parents and --recursive are now boolean + The old "yes/no" values need to be removed. + * Type **\_\_rvm_ruby**: Parameter --default is now boolean + The old "yes/no" values need to be removed. + * Type **\_\_rvm_gemset**: Parameter --default is now boolean + The old "yes/no" values need to be removed. + * Type **\_\_addifnosuchline** and **\_\_removeline** have been replaced by **\_\_line** + * The **conf** directory is now located at **cdist/conf**. + You need to migrate your types, explorers and manifests + manually to the new location. + * Replace the variable **\_\_self** by **\_\_object_name** + Support for the variable **\_\_object_name** is already present in 2.0. + * The types **\_\_autofs**, **\_\_autofs_map** and **\_\_autofs_reload** have been removed + (no maintainer, no users) + * Type **\_\_user**: Parameter --groups removed (use the new \_\_user_groups type) + * Type **\_\_ssh_authorized_key** has been replaced by more flexible type + **\_\_ssh_authorized_keys** + +Updating from 1.7 to 2.0 +~~~~~~~~~~~~~~~~~~~~~~~~ + +* Ensure python (>= 3.2) is installed on the source host +* Use "cdist config host" instead of "cdist-deploy-to host" +* Use "cdist config -p host1 host2" instead of "cdist-mass-deploy" +* Use "cdist banner" for fun +* Use **\_\_object_name** instead of **\_\_self** in manifests + +Updating from 1.6 to 1.7 +~~~~~~~~~~~~~~~~~~~~~~~~ + +* If you used the global explorer **hardware_type**, you need to change + your code to use **machine** instead. + +Updating from 1.5 to 1.6 +~~~~~~~~~~~~~~~~~~~~~~~~ + +* If you used **\_\_package_apt --preseed**, you need to use the new + type **\_\_debconf_set_selections** instead. +* The **\_\_package** types accepted either --state deinstalled or + --state uninstaaled. Starting with 1.6, it was made consistently + to --state removed. + +Updating from 1.3 to 1.5 +~~~~~~~~~~~~~~~~~~~~~~~~ + +No incompatiblities. + +Updating from 1.2 to 1.3 +~~~~~~~~~~~~~~~~~~~~~~~~ + +Rename **gencode** of every type to **gencode-remote**. + +Updating from 1.1 to 1.2 +~~~~~~~~~~~~~~~~~~~~~~~~ + +No incompatiblities. + +Updating from 1.0 to 1.1 +~~~~~~~~~~~~~~~~~~~~~~~~ + +In 1.1 the type **\_\_file** was split into **\_\_directory**, **\_\_file** and +**\_\_link**. The parameter **--type** was removed from **\_\_file**. Thus you +need to replace **\_\_file** calls in your manifests: + + * Remove --type from all \_\_file calls + * If type was symlink, use \_\_link and --type symbolic + * If type was directory, use \_\_directory diff --git a/docs/man/cdist-why.rst b/docs/man/cdist-why.rst new file mode 100644 index 00000000..e6aefefd --- /dev/null +++ b/docs/man/cdist-why.rst @@ -0,0 +1,72 @@ +Why should I use cdist? +======================= + +There are several motivations to use cdist, these +are probably the most popular ones. + +Known language +-------------- + +Cdist is being configured in +`shell script `_. +Shell script is used by UNIX system engineers for decades. +So when cdist is introduced, your staff does not need to learn a new +`DSL `_ +or programming language. + +Powerful language +----------------- + +Not only is shell scripting widely known by system engineers, +but it is also a very powerful language. Here are some features +which make daily work easy: + + * Configuration can react dynamicly on explored values + * High level string manipulation (using sed, awk, grep) + * Conditional support (**if, case**) + * Loop support (**for, while**) + * Support for dependencies between cdist types + +More than shell scripting +------------------------- + +If you compare regular shell scripting with cdist, there is one major +difference: When using cdist types, +the results are +`idempotent `_. +In practise that means it does not matter in which order you +call cdist types, the result is always the same. + +Zero dependency configuration management +---------------------------------------- + +Cdist requires very litte on a target system. Even better, +in almost all cases all dependencies are usually fulfilled. +Cdist does not require an agent or a high level programming +languages on the target host: it will run on any host that +has a **ssh server running** and a posix compatible shell +(**/bin/sh**). Compared to other configuration management systems, +it does not require to open up an additional port. + +Push based distribution +----------------------- + +Cdist uses the push based model for configuration. In this +scenario, one (or more) computers connect the target hosts +and apply the configuration. That way the source host has +very little requirements: Cdist can even run on a sysadmin +notebook that is loosely connected to the network and has +limited amount of resources. + +Furthermore, from a security point of view, only one machine +needs access to the target hosts. No target hosts will ever +need to connect back to the source host, which contains the +full configuration. + +Highly scalable +--------------- + +If at some point you manage more hosts than can be handled from +a single source host, you can simply add more resources: Either +add more cores to one host or add hosts. +Cdist will utilise the given resources in parallel. diff --git a/docs/man/conf.py b/docs/man/conf.py index 7df4ed25..334cfd51 100644 --- a/docs/man/conf.py +++ b/docs/man/conf.py @@ -20,6 +20,7 @@ import os # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. #sys.path.insert(0, os.path.abspath('.')) +sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(os.path.realpath(__file__)), "../../"))) # -- General configuration ------------------------------------------------ @@ -29,7 +30,10 @@ import os # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. -extensions = [] +extensions = [ + 'cdist.sphinxext.manpage', + 'sphinx.ext.extlinks', +] # Add any paths that contain templates here, relative to this directory. templates_path = ['_templates'] @@ -140,7 +144,7 @@ html_theme_path = [sphinx_rtd_theme.get_html_theme_path()] # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ['_static'] +# html_static_path = ['_static'] # Add any extra paths that contain custom files (such as robots.txt or # .htaccess) here, relative to this directory. These files are copied @@ -257,15 +261,18 @@ latex_documents = [ # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). -mandir = os.path.dirname(os.path.realpath(__file__)) -man_pages = [] +root_mandir = os.path.dirname(os.path.realpath(__file__)) +mandirs = [] for mansubdir in ('man1', 'man7'): - for root, dirs, files in os.walk(os.path.join(mandir, mansubdir)): + mandirs.append((os.path.join(root_mandir, mansubdir), mansubdir[-1])) +man_pages = [] +for mandir, section in mandirs: + for root, dirs, files in os.walk(mandir): for fname in files: froot, fext = os.path.splitext(fname) if fext == '.rst': - man_page = (os.path.join(mansubdir, froot), froot, '', - [], mansubdir[-1]) + man_page = (os.path.join('man' + str(section), froot), + froot, '', [], section) man_pages.append(man_page) #man_pages = [ diff --git a/docs/man/index.rst b/docs/man/index.rst index f0638779..a34231f8 100644 --- a/docs/man/index.rst +++ b/docs/man/index.rst @@ -4,9 +4,28 @@ Welcome to cdist documentation Contents: .. toctree:: - :titlesonly: + :maxdepth: 2 :glob: :numbered: - man1/* - man7/* + cdist-intro + cdist-why + cdist-os + cdist-install + cdist-update + cdist-support + cdist-features + cdist-quickstart + man1/cdist + cdist-bootstrap + cdist-manifest + cdist-type + cdist-types + cdist-explorer + cdist-messaging + cdist-reference + cdist-best-practice + cdist-stages + cdist-remote-exec-copy + cdist-hacker + cdist-troubleshooting diff --git a/docs/man/man1/cdist.rst b/docs/man/man1/cdist.rst index 21edee11..efc1a201 100644 --- a/docs/man/man1/cdist.rst +++ b/docs/man/man1/cdist.rst @@ -1,8 +1,9 @@ cdist(1) ======== -Usable Configuration Management -Nico Schottelius +NAME +---- +cdist - Usable Configuration Management SYNOPSIS @@ -174,11 +175,9 @@ The following exit values shall be returned: One or more host configurations failed -SEE ALSO --------- -- `cdist-type(7) <../man7/cdist-type.html>`_ -- `cdist-reference(7) <../man7/cdist-reference.html>`_ - +AUTHORS +------- +Nico Schottelius COPYING ------- diff --git a/docs/man/man7/.gitignore b/docs/man/man7/.gitignore new file mode 100644 index 00000000..e69de29b diff --git a/docs/man/man7/cdist-tutorial.rst b/docs/man/man7/cdist-tutorial.rst deleted file mode 100644 index 4899dcb0..00000000 --- a/docs/man/man7/cdist-tutorial.rst +++ /dev/null @@ -1,55 +0,0 @@ -cdist-tutorial(7) -================= -A guided introduction into cdist - -Nico Schottelius - - -INTRODUCTION ------------- -This document gives you a pointer on what to read in -which order and is thus a "guide to the right locations". -So in case you are just starting, just "begin at the beginning" -(Brave New World). You can see the target audience in [] brackets -after the description. - -cdist-quickstart - New to cdist? Want to get your hands dirty? Read this. [beginner] - -cdist-bootstrap - The comprehensive guide to your first cdist installation [beginner] - -cdist-manifest - Learn how to define which hosts get which configurations [beginner] - -cdist-type - Understand how types are working and created [intermediate] - -cdist-best-practice - Hints from real life experience to help you to organise cdist [intermediate] - -cdist-reference - The type, explorers and environment variables reference [intermediate] - -cdist-explorer - Interested in getting more information about the target system? [intermediate] - -cdist-stages - Understand the internal workflow of cdist. [advanced] - -cdist-hacker - README, if you want to extend or modify cdist. [hacker] - - -SEE ALSO --------- -- `cdist(1) <../man1/cdist.html>`_ -- `cdist-type(7) `_ -- `cdist-best-practice(7) `_ -- `cdist-stages(7) `_ -- Brave New World by Aldous Huxley - -COPYING -------- -Copyright \(C) 2011-2012 Nico Schottelius. Free use of this software is -granted under the terms of the GNU General Public License version 3 (GPLv3). diff --git a/docs/web/cdist/os.mdwn b/docs/web/cdist/os.mdwn index 24992439..3677f52c 100644 --- a/docs/web/cdist/os.mdwn +++ b/docs/web/cdist/os.mdwn @@ -5,6 +5,7 @@ cdist was tested or is know to run on at least * [Archlinux](http://www.archlinux.org/) * [Debian](http://www.debian.org/) * [CentOS](http://www.centos.org/) + * [Scientific](https://www.scientificlinux.org/) * [Fedora](http://fedoraproject.org/) * [FreeBSD](http://www.freebsd.org) * [Gentoo](http://www.gentoo.org/) diff --git a/scripts/cdist b/scripts/cdist index 6baa28f3..55113be0 100755 --- a/scripts/cdist +++ b/scripts/cdist @@ -26,8 +26,11 @@ def inspect_ssh_mux_opts(control_path_dir="~/.ssh/"): import subprocess import os - control_path = os.path.join(control_path_dir, - "cdist.socket.master-%l-%r@%h:%p") + # socket is always local to each cdist run, it is created in + # temp directory that is created at starting cdist, so + # control_path file name can be static, it will always be + # unique due to unique temp directory name + control_path = os.path.join(control_path_dir, "ssh-control-path") wanted_mux_opts = { "ControlPath": control_path, "ControlMaster": "auto", @@ -147,7 +150,7 @@ def commandline(): # didn't specify command line options nor env vars: # inspect multiplexing options for default cdist.REMOTE_COPY/EXEC if args_dict['remote_copy'] is None or args_dict['remote_exec'] is None: - control_path_dir = tempfile.mkdtemp() + control_path_dir = tempfile.mkdtemp(prefix="cdist") import atexit atexit.register(lambda: shutil.rmtree(control_path_dir)) mux_opts = inspect_ssh_mux_opts(control_path_dir)