diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 45c10d7b..00000000 --- a/.gitattributes +++ /dev/null @@ -1,8 +0,0 @@ -.gitignore export-ignore -.gitattributes export-ignore -.gitkeep export-ignore -docs/speeches export-ignore -docs/video export-ignore -docs/src/man7 export-ignore -bin/build-helper export-ignore -README-maintainers export-ignore diff --git a/.gitignore b/.gitignore index 4b80b425..baf9b6f2 100644 --- a/.gitignore +++ b/.gitignore @@ -1,52 +1,24 @@ # -vim -# Swap -[._]*.s[a-v][a-z] -[._]*.sw[a-p] -[._]s[a-rt-v][a-z] -[._]ss[a-gi-z] -[._]sw[a-p] - -# Session -Session.vim - -# Temporary -.netrwhist -*~ -*.tmp -# Auto-generated tag files -tags -# Persistent undo -[._]*.un~ +.*.swp # Ignore generated manpages -docs/src/.marker -docs/src/man1/*.1 -docs/src/man7/*.7 -docs/src/man7/cdist-type__*.rst -docs/src/cdist-reference.rst +docs/man/.marker +docs/man/man1/*.1 +docs/man/man7/*.7 +docs/man/man*/*.html +docs/man/man*/*.xml +docs/man/man*/docbook-xsl.css +docs/man/man7/cdist-type__*.text +docs/man/man7/cdist-reference.text # Ignore cdist cache for version control /cache/ -# Ignore inventory basedir -cdist/inventory/ - # Python: cache, distutils, distribution in general __pycache__/ -*.pyc MANIFEST dist/ cdist/version.py -cdist.egg-info/ - -# sphinx build dirs, cache -_build/ -docs/dist - -# Ignore temp files used for signing -cdist-*.tar -cdist-*.tar.gz -cdist-*.tar.gz.asc # Packaging: Archlinux /PKGBUILD diff --git a/.version b/.version new file mode 100644 index 00000000..71f08595 --- /dev/null +++ b/.version @@ -0,0 +1 @@ +2.1.0-pre1 diff --git a/Makefile b/Makefile index fa3327d1..112b1411 100644 --- a/Makefile +++ b/Makefile @@ -18,88 +18,106 @@ # # -.PHONY: help -help: - @echo "Please use \`make ' where is one of" - @echo "man build only man user documentation" - @echo "html build only html user documentation" - @echo "docs build both man and html user documentation" - @echo "dotman build man pages for types in your ~/.cdist directory" - @echo "speeches build speeches pdf files" - @echo "install install in the system site-packages directory" - @echo "install-user install in the user site-packages directory" - @echo "docs-clean clean documentation" - @echo "clean clean" +A2XM=a2x -f manpage --no-xmllint -a encoding=UTF-8 +A2XH=a2x -f xhtml --no-xmllint -a encoding=UTF-8 +# Create cross-links in html man pages +# We look for something like "cdist-type(7)" and make a href out of it +# The first matching group is the man page name and the second group +# is the man page section (1 or 7). The first three lines of the input +# (xml, DOCTYPE, head tags) are ignored, since the head tags contains +# the title of the page and should not contain a href. +CROSSLINK=sed --in-place '1,3!s/\([[:alnum:]_-]*\)(\([17]\))/&<\/a>/g' +helper=./bin/build-helper -DOCS_SRC_DIR=./docs/src -SPEECHDIR=./docs/speeches -TYPEDIR=./cdist/conf/type +MANDIR=docs/man +SPEECHDIR=docs/speeches +TYPEDIR=cdist/conf/type -SPHINXM=make -C $(DOCS_SRC_DIR) man -SPHINXH=make -C $(DOCS_SRC_DIR) html -SPHINXC=make -C $(DOCS_SRC_DIR) clean +WEBSRCDIR=docs/web + +WEBDIR=$$HOME/www.nico.schottelius.org +WEBBLOG=$(WEBDIR)/blog +WEBBASE=$(WEBDIR)/software/cdist +WEBPAGE=$(WEBBASE).mdwn + +CHANGELOG_VERSION=$(shell $(helper) changelog-version) +CHANGELOG_FILE=docs/changelog + +PYTHON_VERSION=cdist/version.py ################################################################################ # Manpages # -MAN7DSTDIR=$(DOCS_SRC_DIR)/man7 +MAN1DSTDIR=$(MANDIR)/man1 +MAN7DSTDIR=$(MANDIR)/man7 # Manpages #1: Types -# Use shell / ls to get complete list - $(TYPEDIR)/*/man.rst does not work -# 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)) +# Use shell / ls to get complete list - $(TYPEDIR)/*/man.text does not work +MANTYPESRC=$(shell ls $(TYPEDIR)/*/man.text) -# Link manpage: do not create man.html but correct named file -$(MAN7DSTDIR)/cdist-type%.rst: $(TYPEDIR)/%/man.rst - mkdir -p $(MAN7DSTDIR) +# replace first path component +MANTYPEPREFIX=$(subst $(TYPEDIR)/,$(MAN7DSTDIR)/cdist-type,$(MANTYPESRC)) + +# replace man.text with .7 or .html +MANTYPEMAN=$(subst /man.text,.7,$(MANTYPEPREFIX)) +MANTYPEHTML=$(subst /man.text,.html,$(MANTYPEPREFIX)) +MANTYPEALL=$(MANTYPEMAN) $(MANTYPEHTML) + +# Link manpage so A2XH does not create man.html but correct named file +$(MAN7DSTDIR)/cdist-type%.text: $(TYPEDIR)/%/man.text ln -sf "../../../$^" $@ # Manpages #2: reference -DOCSREF=$(MAN7DSTDIR)/cdist-reference.rst -DOCSREFSH=$(DOCS_SRC_DIR)/cdist-reference.rst.sh +MANREF=$(MAN7DSTDIR)/cdist-reference.text +MANREFSH=$(MANDIR)/cdist-reference.text.sh +MANREFMAN=$(MANREF:.text=.7) +MANREFHTML=$(MANREF:.text=.html) +MANREFALL=$(MANREFMAN) $(MANREFHTML) -$(DOCSREF): $(DOCSREFSH) - $(DOCSREFSH) +$(MANREF): $(MANREFSH) + $(MANREFSH) -version: - @[ -f "cdist/version.py" ] || { \ - printf "Missing 'cdist/version.py', please generate it first.\n" && exit 1; \ - } +# Manpages #3: static pages +MAN1STATIC=$(shell ls $(MAN1DSTDIR)/*.text) +MAN7STATIC=$(shell ls $(MAN7DSTDIR)/*.text) +MANSTATICMAN=$(MAN1STATIC:.text=.1) $(MAN7STATIC:.text=.7) +MANSTATICHTML=$(MAN1STATIC:.text=.html) $(MAN7STATIC:.text=.html) +MANSTATICALL=$(MANSTATICMAN) $(MANSTATICHTML) -# Manpages #3: generic part -man: version $(MANTYPES) $(DOCSREF) - $(SPHINXM) +# Manpages #4: generic part -html: version $(MANTYPES) $(DOCSREF) - $(SPHINXH) +# Creating the type manpage +%.1 %.7: %.text + $(A2XM) $^ -docs: man html +# Creating the type html page +%.html: %.text + $(A2XH) $^ + $(CROSSLINK) $@ -docs-clean: - $(SPHINXC) +man: $(MANTYPEALL) $(MANREFALL) $(MANSTATICALL) -# 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)) +# Manpages #5: release part +MANWEBDIR=$(WEBBASE)/man/$(CHANGELOG_VERSION) -# Link manpage: do not create man.html but correct named file -$(DOTMAN7DSTDIR)/cdist-type%.rst: $(DOTTYPEDIR)/%/man.rst - ln -sf "$^" $@ +man-dist: man check-date + rm -rf "${MANWEBDIR}" + mkdir -p "${MANWEBDIR}/man1" "${MANWEBDIR}/man7" + cp ${MAN1DSTDIR}/*.html ${MAN1DSTDIR}/*.css ${MANWEBDIR}/man1 + cp ${MAN7DSTDIR}/*.html ${MAN7DSTDIR}/*.css ${MANWEBDIR}/man7 + cd ${MANWEBDIR} && git add . && git commit -m "cdist manpages update: $(CHANGELOG_VERSION)" || true -dotman: version $(DOTMANTYPES) - $(SPHINXM) +man-latest-link: web-pub + # Fix ikiwiki, which does not like symlinks for pseudo security + ssh tee.schottelius.org \ + "cd /home/services/www/nico/www.nico.schottelius.org/www/software/cdist/man && rm -f latest && ln -sf "$(CHANGELOG_VERSION)" latest" ################################################################################ # Speeches # SPEECHESOURCES=$(SPEECHDIR)/*.tex SPEECHES=$(SPEECHESOURCES:.tex=.pdf) +SPEECHESWEBDIR=$(WEBBASE)/speeches # Create speeches and ensure Toc is up-to-date $(SPEECHDIR)/%.pdf: $(SPEECHDIR)/%.tex @@ -109,26 +127,137 @@ $(SPEECHDIR)/%.pdf: $(SPEECHDIR)/%.tex speeches: $(SPEECHES) -################################################################################ -# Misc -# -clean: docs-clean - rm -f $(DOCS_SRC_DIR)/cdist-reference.rst +speeches-dist: speeches + rm -rf "${SPEECHESWEBDIR}" + mkdir -p "${SPEECHESWEBDIR}" + cp ${SPEECHES} "${SPEECHESWEBDIR}" + cd ${SPEECHESWEBDIR} && git add . && git commit -m "cdist speeches updated" || true - find "$(DOCS_SRC_DIR)" -mindepth 2 -type l \ +################################################################################ +# Website +# + +BLOGFILE=$(WEBBLOG)/cdist-$(CHANGELOG_VERSION)-released.mdwn + +$(BLOGFILE): $(CHANGELOG_FILE) + $(helper) blog $(CHANGELOG_VERSION) $(BLOGFILE) + +web-blog: $(BLOGFILE) + +web-doc: + # Go to top level, because of cdist.mdwn + rsync -av "$(WEBSRCDIR)/" "${WEBBASE}/.." + cd "${WEBBASE}/.." && git add cdist* && git commit -m "cdist doc update" cdist* || true + +web-dist: web-blog web-doc + +web-pub: web-dist man-dist speeches-dist + cd "${WEBDIR}" && make pub + +web-release-all: man-latest-link +web-release-all-no-latest: web-pub + +################################################################################ +# Release: Mailinglist +# +ML_FILE=.lock-ml + +# Only send mail once - lock until new changelog things happened +$(ML_FILE): $(CHANGELOG_FILE) + $(helper) ml-release $(CHANGELOG_VERSION) + touch $@ + +ml-release: $(ML_FILE) + + +################################################################################ +# Release: Freecode +# +FREECODE_FILE=.lock-freecode + +$(FREECODE_FILE): $(CHANGELOG_FILE) + $(helper) freecode-release $(CHANGELOG_VERSION) + touch $@ + +freecode-release: $(FREECODE_FILE) + +################################################################################ +# pypi +# +PYPI_FILE=.pypi-release +$(PYPI_FILE): man $(PYTHON_VERSION) + python3 setup.py sdist upload + touch $@ + +pypi-release: $(PYPI_FILE) +################################################################################ +# archlinux +# +ARCHLINUX_FILE=.lock-archlinux +ARCHLINUXTAR=cdist-$(CHANGELOG_VERSION)-1.src.tar.gz + +$(ARCHLINUXTAR): PKGBUILD + makepkg -c --source + +PKGBUILD: PKGBUILD.in $(PYTHON_VERSION) + ./PKGBUILD.in $(CHANGELOG_VERSION) + +$(ARCHLINUX_FILE): $(ARCHLINUXTAR) $(PYTHON_VERSION) + burp -c system $(ARCHLINUXTAR) + touch $@ + +archlinux-release: $(ARCHLINUX_FILE) + +################################################################################ +# Release +# + +$(PYTHON_VERSION): .git/refs/heads/master + $(helper) version + +# Code that is better handled in a shell script +check-%: + $(helper) $@ + +release: + $(helper) $@ + +################################################################################ +# Cleanup +# + +clean: + rm -f $(MAN7DSTDIR)/cdist-reference.text + + find "$(MANDIR)" -mindepth 2 -type l \ + -o -name "*.1" \ + -o -name "*.7" \ + -o -name "*.html" \ + -o -name "*.xml" \ | xargs rm -f find * -name __pycache__ | xargs rm -rf - # distutils - rm -rf ./build + # Archlinux + rm -f cdist-*.pkg.tar.xz cdist-*.tar.gz + rm -rf pkg/ src/ + + rm -f MANIFEST PKGBUILD + rm -rf dist/ + +distclean: clean + rm -f cdist/version.py ################################################################################ -# install +# Misc # -install: - python3 setup.py install +# The pub is Nico's "push to all git remotes" way ("make pub") +pub: + for remote in "" github sf; do \ + echo "Pushing to $$remote"; \ + git push --mirror $$remote; \ + done -install-user: - python3 setup.py install --user +test: + $(helper) $@ diff --git a/PKGBUILD.in b/PKGBUILD.in index c0188e68..e3ae4619 100755 --- a/PKGBUILD.in +++ b/PKGBUILD.in @@ -9,7 +9,7 @@ pkgver=$version pkgrel=1 pkgdesc='A Usable Configuration Management System"' arch=('any') -url='https://www.cdi.st/' +url='http://www.nico.schottelius.org/software/cdist/' license=('GPL3') depends=('python>=3.2.0') source=("http://pypi.python.org/packages/source/c/cdist/cdist-\${pkgver}.tar.gz") @@ -17,13 +17,7 @@ source=("http://pypi.python.org/packages/source/c/cdist/cdist-\${pkgver}.tar.gz" package() { cd cdist-\${pkgver} python3 setup.py build install --root="\${pkgdir}" - find "\$pkgdir" -type d -exec chmod 0755 {} \; - find "\$pkgdir" -type f -exec chmod a+r {} \; } eof makepkg -g >> "${outfile}" - -# Fix this issue: -# error: failed to upload cdist-3.1.6-1.src.tar.gz: Error - all files must have permissions of 644 or 755. -chmod a+r "${outfile}" diff --git a/README b/README index caf2dac8..a67e25e3 100644 --- a/README +++ b/README @@ -3,5 +3,4 @@ cdist cdist is a usable configuration management system. -For the web documentation have a look at https://www.cdi.st/ -or at docs/src for reStructuredText manual. +For the web documentation have a look at docs/web/. diff --git a/README-maintainers b/README-maintainers deleted file mode 100644 index af57f475..00000000 --- a/README-maintainers +++ /dev/null @@ -1,4 +0,0 @@ -Maintainers should use ./bin/build-helper script. - -Makefile is intended for end users. It can be used for non-maintaining -targets that can be run from pure source (without git repository). diff --git a/bin/build-helper b/bin/build-helper index 9a776491..d28c0616 100755 --- a/bin/build-helper +++ b/bin/build-helper @@ -1,7 +1,6 @@ #!/bin/sh # # 2011-2013 Nico Schottelius (nico-cdist at schottelius.org) -# 2016-2019 Darko Poljak (darko.poljak at gmail.com) # # This file is part of cdist. # @@ -19,66 +18,17 @@ # along with cdist. If not, see . # # -# This file contains the heavy lifting found usually in the Makefile. +# This file contains the heavy lifting found usually in the Makefile # -usage() { - printf "usage: %s TARGET [TARGET-ARGS...] - Available targets: - changelog-changes - changelog-version - check-date - check-unittest - ml-release - archlinux-release - pypi-release - release-git-tag - sign-git-release - release - test - test-remote - pycodestyle - pep8 - check-pycodestyle - shellcheck-global-explorers - shellcheck-type-explorers - shellcheck-manifests - shellcheck-local-gencodes - shellcheck-remote-gencodes - shellcheck-scripts - shellcheck-gencodes - shellcheck-types - shellcheck - shellcheck-type-files - shellcheck-with-files - shellcheck-build-helper - check-shellcheck - version-branch - version - target-version - clean - distclean\n" "$1" -} +basedir=${0%/*}/../ +# Change to checkout directory +cd "$basedir" -basename="${0##*/}" - -if [ $# -lt 1 ] -then - usage "${basename}" - exit 1 -fi +version=$(git describe) option=$1; shift -SHELLCHECKCMD="shellcheck -s sh -f gcc -x" -# Skip SC2154 for variables starting with __ since such variables are cdist -# environment variables. -SHELLCHECK_SKIP=': __.*is referenced but not assigned.*\[SC2154\]' - -# Change to checkout directory -basedir="${0%/*}/../" -cd "$basedir" - case "$option" in changelog-changes) if [ "$#" -eq 1 ]; then @@ -116,8 +66,8 @@ case "$option" in date_changelog=$(grep '^[[:digit:]]' "$basedir/docs/changelog" | head -n1 | sed 's/.*: //') if [ "$date_today" != "$date_changelog" ]; then - printf "Date in changelog is not today\n" - printf "Changelog date: %s\n" "${date_changelog}" + echo "Date in changelog is not today" + echo "Changelog: $date_changelog" exit 1 fi ;; @@ -126,17 +76,54 @@ case "$option" in "$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 - printf "%s ml-release version\n" "$0" >&2 + echo "$0 ml-release version" >&2 exit 1 fi version=$1; shift + to_a=cdist + to_d=l.schottelius.org + to=${to_a}@${to_d} + + from_a=nico-cdist + from_d=schottelius.org + from=${from_a}@${from_d} + ( cat << eof -Subject: cdist $version has been released +From: Nico -telmich- Schottelius <$from> +To: cdist mailing list <$to> +Subject: cdist $version released Hello .*, @@ -147,135 +134,41 @@ eof "$0" changelog-changes "$version" cat << eof +Cheers, + +Nico + +-- +Automatisation at its best level. With cdist. eof - ) > mailinglist.tmp + ) | /usr/sbin/sendmail -f "$from" "$to" ;; - archlinux-release) - if [ $# -ne 1 ]; then - printf "%s archlinux-release version\n" "$0" >&2 - exit 1 - fi + + freecode-release) version=$1; shift + printf "Enter tag list for freecode release %s> " "$version" + read taglist - ARCHLINUXTAR="cdist-${version}-1.src.tar.gz" - ./PKGBUILD.in "${version}" - umask 022 - mkaurball - burp -c system "${ARCHLINUXTAR}" - ;; + printf "Enter changelog for freecode release %s> " "$version" + read changelog - pypi-release) - # Ensure that pypi release has the right version - "$0" version - - make docs-clean - make docs - python3 setup.py sdist upload + echo "Submitting to freecode ..." + python2 ~/p/foreign/freecode-submit-2.7/freecode-submit -P cdist \ + -v "$version" -c "$changelog" \ + -t "$taglist" \ + -n ;; release-git-tag) target_version=$($0 changelog-version) - if git rev-parse --verify "refs/tags/${target_version}" 2>/dev/null; then - printf "Tag for %s exists, aborting\n" "${target_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 %s: " "${target_version}" - read -r tagmessage - - # setup for signed tags: - # gpg --fulL-gen-key - # gpg --list-secret-keys --keyid-format LONG - # git config --local user.signingkey - # for exporting pub key: - # gpg --armor --export > pubkey.asc - # gpg --output pubkey.gpg --export - # show tag with signature - # git show - # verify tag signature - # git tag -v - # - # gpg verify signature - # gpg --verify - # gpg --no-default-keyring --keyring --verify - # Ensure gpg-agent is running. - GPG_TTY=$(tty) - export GPG_TTY - gpg-agent - - git tag -s "$target_version" -m "$tagmessage" - git push --tags - ;; - - sign-git-release) - if [ $# -lt 2 ] - then - printf "usage: %s sign-git-release TAG TOKEN [ARCHIVE]\n" "$0" - printf " if ARCHIVE is not specified then it is created\n" - exit 1 - fi - tag="$1" - if ! git rev-parse -q --verify "${tag}" >/dev/null 2>&1 - then - printf "Tag \"%s\" not found.\n" "${tag}" - exit 1 - fi - token="$2" - if [ $# -gt 2 ] - then - archivename="$3" - else - archivename="cdist-${tag}.tar" - git archive --prefix="cdist-${tag}/" -o "${archivename}" "${tag}" \ - || exit 1 - # make sure target version is generated - "$0" target-version - tar -x -f "${archivename}" || exit 1 - cp cdist/version.py "cdist-${tag}/cdist/version.py" || exit 1 - tar -c -f "${archivename}" "cdist-${tag}/" || exit 1 - rm -r -f "cdist-${tag}/" - gzip "${archivename}" || exit 1 - archivename="${archivename}.gz" - fi - gpg --armor --detach-sign "${archivename}" || exit 1 - - project="ungleich-public%2Fcdist" - sed_cmd='s/^.*"markdown":"\([^"]*\)".*$/\1/' - - # upload archive - response_archive=$(curl -f -X POST \ - --http1.1 \ - -H "PRIVATE-TOKEN: ${token}" \ - -F "file=@${archivename}" \ - "https://code.ungleich.ch/api/v4/projects/${project}/uploads" \ - | sed "${sed_cmd}") || exit 1 - - # upload archive signature - response_archive_sig=$(curl -f -X POST \ - --http1.1 \ - -H "PRIVATE-TOKEN: ${token}" \ - -F "file=@${archivename}.asc" \ - "https://code.ungleich.ch/api/v4/projects/${project}/uploads" \ - | sed "${sed_cmd}") || exit 1 - - # make release - changelog=$("$0" changelog-changes "$1" | sed 's/^[[:space:]]*//') - release_notes=$( - printf "%s\n\n%s\n\n**Changelog**\n\n%s\n" \ - "${response_archive}" "${response_archive_sig}" "${changelog}" - ) - curl -f -X POST \ - -H "PRIVATE-TOKEN: ${token}" \ - -F "description=${release_notes}" \ - "https://code.ungleich.ch/api/v4/projects/${project}/repository/tags/${tag}/release" \ - || exit 1 - - # remove generated files (archive and asc) - if [ $# -eq 2 ] - then - rm -f "${archivename}" - fi - rm -f "${archivename}.asc" + printf "Enter tag description for ${target_version}: " + read tagmessage + git tag "$target_version" -m "$$tagmessage" ;; release) @@ -283,30 +176,28 @@ eof target_version=$($0 changelog-version) target_branch=$($0 version-branch) - printf "Beginning release process for %s\n" "${target_version}" + echo "Beginning release process for $target_version" # First check everything is sane "$0" check-date "$0" check-unittest - "$0" check-pycodestyle - "$0" check-shellcheck # Generate version file to be included in packaging - "$0" target-version + "$0" version # Ensure the git status is clean, else abort if ! git diff-index --name-only --exit-code HEAD ; then - printf "Unclean tree, see files above, aborting.\n" + 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 - printf "Releases are happening from the master branch, aborting.\n" + echo "Releases are happening from the master branch, aborting" - printf "Enter the magic word to release anyway:" - read -r magicword + echo "Enter the magic word to release anyway" + read magicword if [ "$magicword" = "iknowwhatido" ]; then masterbranch=no @@ -317,7 +208,7 @@ eof if [ "$masterbranch" = yes ]; then # Ensure version branch exists - if ! git rev-parse --verify "refs/heads/${target_branch}" 2>/dev/null; then + if ! git rev-parse --verify refs/heads/$target_branch 2>/dev/null; then git branch "$target_branch" fi @@ -330,10 +221,11 @@ eof "$0" check-date "$0" check-unittest - # Generate documentation (man and html) - # First, clean old generated docs - make docs-clean - make docs + # Generate man pages (indirect check if they build) + make man + + # Generate speeches (indirect check if they build) + make speeches ############################################################# # Everything green, let's do the release @@ -348,41 +240,44 @@ eof fi # Publish git changes - # if you want to have mirror locally then uncomment this and comment below - # git push --mirror - git push - # push also new branch and set up tracking - git push -u origin "${target_branch}" - # fi + make pub + + # publish man, speeches, website + if [ "$masterbranch" = yes ]; then + make web-release-all + else + make web-release-all-no-latest + fi + + # Ensure that pypi release has the right version + "$0" version # Create and publish package for pypi - "$0" pypi-release + make pypi-release - # sign git tag - printf "Enter upstream repository authentication token: " - read -r token - "$0" sign-git-release "${target_version}" "${token}" + # Archlinux release is based on pypi + make archlinux-release + + # Announce change on Freecode + make freecode-release # Announce change on ML - "$0" ml-release "${target_version}" + make ml-release cat << eof Manual steps post release: - - cdist-web - - send mail body generated in mailinglist.tmp and inform Dmitry for deb + + - linkedin + - hackernews + - reddit - twitter + eof + ;; test) - if [ ! -f "cdist/version.py" ] - then - printf "cdist/version.py is missing, generate it first.\n" - exit 1 - fi - - PYTHONPATH="$(pwd -P)" - export PYTHONPATH + export PYTHONPATH="$(pwd -P)" if [ $# -lt 1 ]; then python3 -m cdist.test @@ -391,159 +286,16 @@ eof fi ;; - test-remote) - if [ ! -f "cdist/version.py" ] - then - printf "cdist/version.py is missing, generate it first.\n" - exit 1 - fi - - PYTHONPATH="$(pwd -P)" - export PYTHONPATH - - python3 -m cdist.test.exec.remote - ;; - - pycodestyle|pep8) - pycodestyle "${basedir}" "${basedir}/scripts/cdist" | less - ;; - - check-pycodestyle) - "$0" pycodestyle - printf "\\nPlease review pycodestyle report.\\n" - while true - do - printf "Continue (yes/no)?\n" - any= - read -r any - case "$any" in - yes) - break - ;; - no) - exit 1 - ;; - *) - printf "Please answer with 'yes' or 'no' explicitly.\n" - ;; - esac - done - ;; - - shellcheck-global-explorers) - find cdist/conf/explorer -type f -exec ${SHELLCHECKCMD} {} + | grep -v "${SHELLCHECK_SKIP}" || exit 0 - ;; - - shellcheck-type-explorers) - find cdist/conf/type -type f -path "*/explorer/*" -exec ${SHELLCHECKCMD} {} + | grep -v "${SHELLCHECK_SKIP}" || exit 0 - ;; - - shellcheck-manifests) - find cdist/conf/type -type f -name manifest -exec ${SHELLCHECKCMD} {} + | grep -v "${SHELLCHECK_SKIP}" || exit 0 - ;; - - shellcheck-local-gencodes) - find cdist/conf/type -type f -name gencode-local -exec ${SHELLCHECKCMD} {} + | grep -v "${SHELLCHECK_SKIP}" || exit 0 - ;; - - shellcheck-remote-gencodes) - find cdist/conf/type -type f -name gencode-remote -exec ${SHELLCHECKCMD} {} + | grep -v "${SHELLCHECK_SKIP}" || exit 0 - ;; - - shellcheck-scripts) - ${SHELLCHECKCMD} scripts/cdist-dump scripts/cdist-new-type || exit 0 - ;; - - shellcheck-gencodes) - "$0" shellcheck-local-gencodes - "$0" shellcheck-remote-gencodes - ;; - - shellcheck-types) - "$0" shellcheck-type-explorers - "$0" shellcheck-manifests - "$0" shellcheck-gencodes - ;; - - shellcheck) - "$0" shellcheck-global-explorers - "$0" shellcheck-types - "$0" shellcheck-scripts - ;; - - shellcheck-type-files) - find cdist/conf/type -type f -path "*/files/*" -exec ${SHELLCHECKCMD} {} + | grep -v "${SHELLCHECK_SKIP}" || exit 0 - ;; - - shellcheck-with-files) - "$0" shellcheck - "$0" shellcheck-type-files - ;; - - shellcheck-build-helper) - ${SHELLCHECKCMD} ./bin/build-helper - ;; - - check-shellcheck) - "$0" shellcheck - printf "\\nPlease review shellcheck report.\\n" - while true - do - printf "Continue (yes/no)?\n" - any= - read -r any - case "$any" in - yes) - break - ;; - no) - exit 1 - ;; - *) - printf "Please answer with 'yes' or 'no' explicitly.\n" - ;; - esac - done - ;; - version-branch) "$0" changelog-version | cut -d. -f '1,2' ;; version) - printf "VERSION = \"%s\"\n" "$(git describe)" > cdist/version.py + echo "VERSION = \"$(git describe)\"" > cdist/version.py ;; - target-version) - target_version=$($0 changelog-version) - printf "VERSION = \"%s\"\n" "${target_version}" > cdist/version.py - ;; - - clean) - make clean - - # Archlinux - rm -f cdist-*.pkg.tar.xz cdist-*.tar.gz - rm -rf pkg/ src/ - - rm -f MANIFEST PKGBUILD - rm -rf dist/ - - # Signed release - rm -f cdist-*.tar.gz - rm -f cdist-*.tar.gz.asc - - # Temp files - rm -f ./*.tmp - ;; - - distclean) - "$0" clean - rm -f cdist/version.py - ;; *) - printf "Unknown target: '%s'.\n" "${option}" >&2 - usage "${basename}" + echo "Unknown helper target $@ - aborting" exit 1 ;; diff --git a/cdist/__init__.py b/cdist/__init__.py index c673b3ba..20c76b31 100644 --- a/cdist/__init__.py +++ b/cdist/__init__.py @@ -1,7 +1,6 @@ # -*- coding: utf-8 -*- # -# 2010-2015 Nico Schottelius (nico-cdist at schottelius.org) -# 2012-2017 Steven Armstrong (steven-cdist at armstrong.cc) +# 2010-2012 Nico Schottelius (nico-cdist at schottelius.org) # # This file is part of cdist. # @@ -21,9 +20,8 @@ # import os -import hashlib +import subprocess -import cdist.log import cdist.version VERSION = cdist.version.VERSION @@ -43,198 +41,30 @@ BANNER = """ "P' "" "" """ -REMOTE_COPY = "scp -o User=root -q" -REMOTE_EXEC = "ssh -o User=root" -REMOTE_CMDS_CLEANUP_PATTERN = "ssh -o User=root -O exit -S {}" +DOT_CDIST = ".cdist" +REMOTE_COPY = "scp -o User=root -q" +REMOTE_EXEC = "ssh -o User=root -q" 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 -class CdistBetaRequired(cdist.Error): - """Beta functionality is used but beta is not enabled""" - - def __init__(self, command, arg=None): - self.command = command - self.arg = arg def __str__(self): - if self.arg is None: - err_msg = ("\'{}\' command is beta, but beta is " - "not enabled. If you want to use it please enable beta " - "functionalities by using the -b/--beta command " - "line flag or setting CDIST_BETA env var.") - fmt_args = [self.command, ] - else: - err_msg = ("\'{}\' argument of \'{}\' command is beta, but beta " - "is not enabled. If you want to use it please enable " - "beta functionalities by using the -b/--beta " - "command line flag or setting CDIST_BETA env var.") - fmt_args = [self.arg, self.command, ] - return err_msg.format(*fmt_args) - - -class CdistEntityError(Error): - """Something went wrong while executing cdist entity""" - def __init__(self, entity_name, entity_params, stdout_paths, - stderr_paths, subject=''): - self.entity_name = entity_name - self.entity_params = entity_params - self.stderr_paths = stderr_paths - self.stdout_paths = stdout_paths - if isinstance(subject, Error): - self.original_error = subject - else: - self.original_error = None - self.message = str(subject) - - def _stdpath(self, stdpaths, header_name): - result = {} - for name, path in stdpaths: - if name not in result: - result[name] = [] - try: - if os.path.exists(path) and os.path.getsize(path) > 0: - output = [] - label_begin = name + ":" + header_name - output.append(label_begin) - output.append('\n') - output.append('-' * len(label_begin)) - output.append('\n') - with open(path, 'r') as fd: - output.append(fd.read()) - output.append('\n') - result[name].append(''.join(output)) - except UnicodeError as ue: - result[name].append(('Cannot output {}:{} due to: {}.\n' - 'You can try to read the error file "{}"' - ' yourself.').format( - name, header_name, ue, path)) - return result - - def _stderr(self): - return self._stdpath(self.stderr_paths, 'stderr') - - def _stdout(self): - return self._stdpath(self.stdout_paths, 'stdout') - - def _update_dict_list(self, target, source): - for x in source: - if x not in target: - target[x] = [] - target[x].extend(source[x]) - - @property - def std_streams(self): - std_dict = {} - self._update_dict_list(std_dict, self._stdout()) - self._update_dict_list(std_dict, self._stderr()) - return std_dict - - def __str__(self): - output = [] - output.append(self.message) - output.append('\n\n') - header = "Error processing " + self.entity_name - under_header = '=' * len(header) - output.append(header) - output.append('\n') - output.append(under_header) - output.append('\n') - for param_name, param_value in self.entity_params: - output.append(param_name + ': ' + str(param_value)) - output.append('\n') - output.append('\n') - for x in self.std_streams: - output.append(''.join(self.std_streams[x])) - return ''.join(output) - - -class CdistObjectError(CdistEntityError): - """Something went wrong while working on a specific cdist object""" - def __init__(self, cdist_object, subject=''): - params = [ - ('name', cdist_object.name, ), - ('path', cdist_object.absolute_path, ), - ('source', " ".join(cdist_object.source), ), - ('type', os.path.realpath( - cdist_object.cdist_type.absolute_path), ), - ] - stderr_paths = [] - for stderr_name in os.listdir(cdist_object.stderr_path): - stderr_path = os.path.join(cdist_object.stderr_path, - stderr_name) - stderr_paths.append((stderr_name, stderr_path, )) - stdout_paths = [] - for stdout_name in os.listdir(cdist_object.stdout_path): - stdout_path = os.path.join(cdist_object.stdout_path, - stdout_name) - stdout_paths.append((stdout_name, stdout_path, )) - super().__init__("object '{}'".format(cdist_object.name), - params, stdout_paths, stderr_paths, subject) - - -class CdistObjectExplorerError(CdistEntityError): - """ - Something went wrong while working on a specific - cdist object explorer - """ - def __init__(self, cdist_object, explorer_name, explorer_path, - stderr_path, subject=''): - params = [ - ('object name', cdist_object.name, ), - ('object path', cdist_object.absolute_path, ), - ('object source', " ".join(cdist_object.source), ), - ('object type', os.path.realpath( - cdist_object.cdist_type.absolute_path), ), - ('explorer name', explorer_name, ), - ('explorer path', explorer_path, ), - ] - stdout_paths = [] - stderr_paths = [ - ('remote', stderr_path, ), - ] - super().__init__("explorer '{}' of object '{}'".format( - explorer_name, cdist_object.name), params, stdout_paths, - stderr_paths, subject) - - -class InitialManifestError(CdistEntityError): - """Something went wrong while executing initial manifest""" - def __init__(self, initial_manifest, stdout_path, stderr_path, subject=''): - params = [ - ('path', initial_manifest, ), - ] - stdout_paths = [ - ('init', stdout_path, ), - ] - stderr_paths = [ - ('init', stderr_path, ), - ] - super().__init__('initial manifest', params, stdout_paths, - stderr_paths, subject) - - -class GlobalExplorerError(CdistEntityError): - """Something went wrong while executing global explorer""" - def __init__(self, name, path, stderr_path, subject=''): - params = [ - ('name', name, ), - ('path', path, ), - ] - stderr_paths = [ - ('remote', stderr_path, ), - ] - super().__init__("global explorer '{}'".format(name), - params, [], stderr_paths, subject) - + return '%s: %s (defined at %s)' % (self.name, self.message, self.source) def file_to_list(filename): """Return list from \n seperated file""" @@ -249,23 +79,3 @@ def file_to_list(filename): lines = [] return lines - - -def str_hash(s): - """Return hash of string s""" - if isinstance(s, str): - return hashlib.md5(s.encode('utf-8')).hexdigest() - else: - raise Error("Param should be string") - - -def home_dir(): - if 'HOME' in os.environ: - home = os.environ['HOME'] - if home: - rv = os.path.join(home, ".cdist") - else: - rv = None - else: - rv = None - return rv diff --git a/cdist/argparse.py b/cdist/argparse.py deleted file mode 100644 index 421d1b54..00000000 --- a/cdist/argparse.py +++ /dev/null @@ -1,468 +0,0 @@ -import argparse -import cdist -import multiprocessing -import logging -import collections -import functools -import cdist.configuration - - -# set of beta sub-commands -BETA_COMMANDS = set(('install', 'inventory', )) -# set of beta arguments for sub-commands -BETA_ARGS = { - 'config': set(('tag', 'all_tagged_hosts', 'use_archiving', )), -} -EPILOG = "Get cdist at https://code.ungleich.ch/ungleich-public/cdist" -# Parser others can reuse -parser = None - - -_verbosity_level_off = -2 -_verbosity_level = { - _verbosity_level_off: logging.OFF, - -1: logging.ERROR, - 0: logging.WARNING, - 1: logging.INFO, - 2: logging.VERBOSE, - 3: logging.DEBUG, - 4: logging.TRACE, -} - - -# Generate verbosity level constants: -# VERBOSE_OFF, VERBOSE_ERROR, VERBOSE_WARNING, VERBOSE_INFO, VERBOSE_VERBOSE, -# VERBOSE_DEBUG, VERBOSE_TRACE. -this_globals = globals() -for level in _verbosity_level: - const = 'VERBOSE_' + logging.getLevelName(_verbosity_level[level]) - this_globals[const] = level - - -# All verbosity levels above 4 are TRACE. -_verbosity_level = collections.defaultdict( - lambda: logging.TRACE, _verbosity_level) - - -def add_beta_command(cmd): - BETA_COMMANDS.add(cmd) - - -def add_beta_arg(cmd, arg): - if cmd in BETA_ARGS: - if arg not in BETA_ARGS[cmd]: - BETA_ARGS[cmd].append(arg) - else: - BETA_ARGS[cmd] = set((arg, )) - - -def check_beta(args_dict): - if 'beta' not in args_dict: - args_dict['beta'] = False - # Check only if beta is not enabled: if beta option is specified then - # raise error. - if not args_dict['beta']: - cmd = args_dict['command'] - # first check if command is beta - if cmd in BETA_COMMANDS: - raise cdist.CdistBetaRequired(cmd) - # then check if some command's argument is beta - if cmd in BETA_ARGS: - for arg in BETA_ARGS[cmd]: - if arg in args_dict and args_dict[arg]: - raise cdist.CdistBetaRequired(cmd, arg) - - -def check_lower_bounded_int(value, lower_bound, name): - try: - val = int(value) - except ValueError: - raise argparse.ArgumentTypeError( - "{} is invalid int value".format(value)) - if val < lower_bound: - raise argparse.ArgumentTypeError( - "{} is invalid {} value".format(val, name)) - return val - - -def get_parsers(): - global parser - - # Construct parser others can reuse - if parser: - return parser - else: - parser = {} - # Options _all_ parsers have in common - parser['loglevel'] = argparse.ArgumentParser(add_help=False) - parser['loglevel'].add_argument( - '-l', '--log-level', metavar='LOGLEVEL', - type=functools.partial(check_lower_bounded_int, lower_bound=-1, - name="log level"), - help=('Set the specified verbosity level. ' - 'The levels, in order from the lowest to the highest, are: ' - 'ERROR (-1), WARNING (0), INFO (1), VERBOSE (2), DEBUG (3) ' - 'TRACE (4 or higher). If used along with -v then -v ' - 'increases last set value and -l overwrites last set ' - 'value.'), - action='store', dest='verbose', required=False) - parser['loglevel'].add_argument( - '-q', '--quiet', - help='Quiet mode: disables logging, including WARNING and ERROR.', - action='store_true', default=False) - parser['loglevel'].add_argument( - '-v', '--verbose', - help=('Increase the verbosity level. Every instance of -v ' - 'increments the verbosity level by one. Its default value ' - 'is 0 which includes ERROR and WARNING levels. ' - 'The levels, in order from the lowest to the highest, are: ' - 'ERROR (-1), WARNING (0), INFO (1), VERBOSE (2), DEBUG (3) ' - 'TRACE (4 or higher). If used along with -l then -l ' - 'overwrites last set value and -v increases last set ' - 'value.'), - action='count', default=None) - - parser['beta'] = argparse.ArgumentParser(add_help=False) - parser['beta'].add_argument( - '-b', '--beta', - help=('Enable beta functionality. '), - action='store_true', dest='beta', default=None) - - # Main subcommand parser - parser['main'] = argparse.ArgumentParser( - description='cdist ' + cdist.VERSION) - parser['main'].add_argument( - '-V', '--version', help='Show version.', action='version', - version='%(prog)s ' + cdist.VERSION) - parser['sub'] = parser['main'].add_subparsers( - title="Commands", dest="command") - - # Banner - parser['banner'] = parser['sub'].add_parser( - 'banner', parents=[parser['loglevel']]) - parser['banner'].set_defaults(func=cdist.banner.banner) - - parser['inventory_common'] = argparse.ArgumentParser(add_help=False) - parser['inventory_common'].add_argument( - '-I', '--inventory', - help=('Use specified custom inventory directory. ' - 'Inventory directory is set up by the following rules: ' - 'if cdist configuration resolves this value then specified ' - 'directory is used, ' - 'if HOME env var is set then ~/.cdist/inventory is ' - 'used, otherwise distribution inventory directory is used.'), - dest="inventory_dir", required=False) - - parser['common'] = argparse.ArgumentParser(add_help=False) - parser['common'].add_argument( - '-g', '--config-file', - help=('Use specified custom configuration file.'), - dest="config_file", required=False) - - # Config - parser['config_main'] = argparse.ArgumentParser(add_help=False) - parser['config_main'].add_argument( - '-4', '--force-ipv4', - help=('Force to use IPv4 addresses only. No influence for custom' - ' remote commands.'), - action='store_const', dest='force_ipv', const=4) - parser['config_main'].add_argument( - '-6', '--force-ipv6', - help=('Force to use IPv6 addresses only. No influence for custom' - ' remote commands.'), - action='store_const', dest='force_ipv', const=6) - parser['config_main'].add_argument( - '-C', '--cache-path-pattern', - help=('Specify custom cache path pattern. If ' - 'it is not set then default hostdir is used.'), - dest='cache_path_pattern', - default=None) - parser['config_main'].add_argument( - '-c', '--conf-dir', - help=('Add configuration directory (can be repeated, ' - 'last one wins).'), action='append') - parser['config_main'].add_argument( - '-i', '--initial-manifest', - help='Path to a cdist manifest or \'-\' to read from stdin.', - dest='manifest', required=False) - parser['config_main'].add_argument( - '-j', '--jobs', nargs='?', - type=functools.partial(check_lower_bounded_int, lower_bound=1, - name="positive int"), - help=('Operate in parallel in specified maximum number of jobs. ' - 'Global explorers, object prepare and object run are ' - 'supported. Without argument CPU count is used by default. '), - action='store', dest='jobs', - const=multiprocessing.cpu_count()) - parser['config_main'].add_argument( - '-n', '--dry-run', - help='Do not execute code.', action='store_true') - parser['config_main'].add_argument( - '-o', '--out-dir', - help='Directory to save cdist output in.', dest="out_path") - parser['config_main'].add_argument( - '-P', '--timestamp', - help=('Timestamp log messages with the current local date and time ' - 'in the format: YYYYMMDDHHMMSS.us.'), - action='store_true', dest='timestamp') - parser['config_main'].add_argument( - '-R', '--use-archiving', nargs='?', - choices=('tar', 'tgz', 'tbz2', 'txz',), - help=('Operate by using archiving with compression where ' - 'appropriate. Supported values are: tar - tar archive, ' - 'tgz - gzip tar archive (the default), ' - 'tbz2 - bzip2 tar archive and txz - lzma tar archive. ' - 'Currently in beta.'), - action='store', dest='use_archiving', - const='tgz') - - # remote-copy and remote-exec defaults are environment variables - # if set; if not then None - these will be futher handled after - # parsing to determine implementation default - parser['config_main'].add_argument( - '-r', '--remote-out-dir', - help='Directory to save cdist output in on the target host.', - dest="remote_out_path") - parser['config_main'].add_argument( - '--remote-copy', - help='Command to use for remote copy (should behave like scp).', - action='store', dest='remote_copy', - default=None) - parser['config_main'].add_argument( - '--remote-exec', - help=('Command to use for remote execution ' - '(should behave like ssh).'), - action='store', dest='remote_exec', - default=None) - parser['config_main'].add_argument( - '-S', '--disable-saving-output-streams', - help='Disable saving output streams.', - action='store_false', dest='save_output_streams', default=True) - - # Config - parser['config_args'] = argparse.ArgumentParser(add_help=False) - parser['config_args'].add_argument( - '-A', '--all-tagged', - help=('Use all hosts present in tags db. Currently in beta.'), - action="store_true", dest="all_tagged_hosts", default=False) - parser['config_args'].add_argument( - '-a', '--all', - help=('List hosts that have all specified tags, ' - 'if -t/--tag is specified.'), - action="store_true", dest="has_all_tags", default=False) - parser['config_args'].add_argument( - '-f', '--file', - help=('Read specified file for a list of additional hosts to ' - 'operate on or if \'-\' is given, read stdin (one host per ' - 'line). If no host or host file is specified then, by ' - 'default, read hosts from stdin.'), - dest='hostfile', required=False) - parser['config_args'].add_argument( - '-p', '--parallel', nargs='?', metavar='HOST_MAX', - type=functools.partial(check_lower_bounded_int, lower_bound=1, - name="positive int"), - help=('Operate on multiple hosts in parallel for specified maximum ' - 'hosts at a time. Without argument CPU count is used by ' - 'default.'), - action='store', dest='parallel', - const=multiprocessing.cpu_count()) - parser['config_args'].add_argument( - '-s', '--sequential', - help='Operate on multiple hosts sequentially (default).', - action='store_const', dest='parallel', const=0) - parser['config_args'].add_argument( - '-t', '--tag', - help=('Host is specified by tag, not hostname/address; ' - 'list all hosts that contain any of specified tags. ' - 'Currently in beta.'), - dest='tag', required=False, action="store_true", default=False) - parser['config_args'].add_argument( - 'host', nargs='*', help='Host(s) to operate on.') - parser['config'] = parser['sub'].add_parser( - 'config', parents=[parser['loglevel'], parser['beta'], - parser['common'], - parser['config_main'], - parser['inventory_common'], - parser['config_args']]) - parser['config'].set_defaults(func=cdist.config.Config.commandline) - - # Install - parser['install'] = parser['sub'].add_parser('install', add_help=False, - parents=[parser['config']]) - parser['install'].set_defaults(func=cdist.install.Install.commandline) - - # Inventory - parser['inventory'] = parser['sub'].add_parser('inventory') - parser['invsub'] = parser['inventory'].add_subparsers( - title="Inventory commands", dest="subcommand") - - parser['add-host'] = parser['invsub'].add_parser( - 'add-host', parents=[parser['loglevel'], parser['beta'], - parser['common'], - parser['inventory_common']]) - parser['add-host'].add_argument( - 'host', nargs='*', help='Host(s) to add.') - parser['add-host'].add_argument( - '-f', '--file', - help=('Read additional hosts to add from specified file ' - 'or from stdin if \'-\' (each host on separate line). ' - 'If no host or host file is specified then, by default, ' - 'read from stdin.'), - dest='hostfile', required=False) - - parser['add-tag'] = parser['invsub'].add_parser( - 'add-tag', parents=[parser['loglevel'], parser['beta'], - parser['common'], - parser['inventory_common']]) - parser['add-tag'].add_argument( - 'host', nargs='*', - help='List of host(s) for which tags are added.') - parser['add-tag'].add_argument( - '-f', '--file', - help=('Read additional hosts to add tags from specified file ' - 'or from stdin if \'-\' (each host on separate line). ' - 'If no host or host file is specified then, by default, ' - 'read from stdin. If no tags/tagfile nor hosts/hostfile' - ' are specified then tags are read from stdin and are' - ' added to all hosts.'), - dest='hostfile', required=False) - parser['add-tag'].add_argument( - '-T', '--tag-file', - help=('Read additional tags to add from specified file ' - 'or from stdin if \'-\' (each tag on separate line). ' - 'If no tag or tag file is specified then, by default, ' - 'read from stdin. If no tags/tagfile nor hosts/hostfile' - ' are specified then tags are read from stdin and are' - ' added to all hosts.'), - dest='tagfile', required=False) - parser['add-tag'].add_argument( - '-t', '--taglist', - help=("Tag list to be added for specified host(s), comma separated" - " values."), - dest="taglist", required=False) - - parser['del-host'] = parser['invsub'].add_parser( - 'del-host', parents=[parser['loglevel'], parser['beta'], - parser['common'], - parser['inventory_common']]) - parser['del-host'].add_argument( - 'host', nargs='*', help='Host(s) to delete.') - parser['del-host'].add_argument( - '-a', '--all', help=('Delete all hosts.'), - dest='all', required=False, action="store_true", default=False) - parser['del-host'].add_argument( - '-f', '--file', - help=('Read additional hosts to delete from specified file ' - 'or from stdin if \'-\' (each host on separate line). ' - 'If no host or host file is specified then, by default, ' - 'read from stdin.'), - dest='hostfile', required=False) - - parser['del-tag'] = parser['invsub'].add_parser( - 'del-tag', parents=[parser['loglevel'], parser['beta'], - parser['common'], - parser['inventory_common']]) - parser['del-tag'].add_argument( - 'host', nargs='*', - help='List of host(s) for which tags are deleted.') - parser['del-tag'].add_argument( - '-a', '--all', - help=('Delete all tags for specified host(s).'), - dest='all', required=False, action="store_true", default=False) - parser['del-tag'].add_argument( - '-f', '--file', - help=('Read additional hosts to delete tags for from specified ' - 'file or from stdin if \'-\' (each host on separate line). ' - 'If no host or host file is specified then, by default, ' - 'read from stdin. If no tags/tagfile nor hosts/hostfile' - ' are specified then tags are read from stdin and are' - ' deleted from all hosts.'), - dest='hostfile', required=False) - parser['del-tag'].add_argument( - '-T', '--tag-file', - help=('Read additional tags from specified file ' - 'or from stdin if \'-\' (each tag on separate line). ' - 'If no tag or tag file is specified then, by default, ' - 'read from stdin. If no tags/tagfile nor' - ' hosts/hostfile are specified then tags are read from' - ' stdin and are added to all hosts.'), - dest='tagfile', required=False) - parser['del-tag'].add_argument( - '-t', '--taglist', - help=("Tag list to be deleted for specified host(s), " - "comma separated values."), - dest="taglist", required=False) - - parser['list'] = parser['invsub'].add_parser( - 'list', parents=[parser['loglevel'], parser['beta'], - parser['common'], - parser['inventory_common']]) - parser['list'].add_argument( - 'host', nargs='*', help='Host(s) to list.') - parser['list'].add_argument( - '-a', '--all', - help=('List hosts that have all specified tags, ' - 'if -t/--tag is specified.'), - action="store_true", dest="has_all_tags", default=False) - parser['list'].add_argument( - '-f', '--file', - help=('Read additional hosts to list from specified file ' - 'or from stdin if \'-\' (each host on separate line). ' - 'If no host or host file is specified then, by default, ' - 'list all.'), dest='hostfile', required=False) - parser['list'].add_argument( - '-H', '--host-only', help=('Suppress tags listing.'), - action="store_true", dest="list_only_host", default=False) - parser['list'].add_argument( - '-t', '--tag', - help=('Host is specified by tag, not hostname/address; ' - 'list all hosts that contain any of specified tags.'), - action="store_true", default=False) - - parser['inventory'].set_defaults( - func=cdist.inventory.Inventory.commandline) - - # Shell - parser['shell'] = parser['sub'].add_parser( - 'shell', parents=[parser['loglevel']]) - parser['shell'].add_argument( - '-s', '--shell', - help=('Select shell to use, defaults to current shell. Used shell' - ' should be POSIX compatible shell.')) - parser['shell'].set_defaults(func=cdist.shell.Shell.commandline) - - for p in parser: - parser[p].epilog = EPILOG - - return parser - - -def handle_loglevel(args): - if hasattr(args, 'quiet') and args.quiet: - args.verbose = _verbosity_level_off - - logging.root.setLevel(_verbosity_level[args.verbose]) - - -def parse_and_configure(argv, singleton=True): - parser = get_parsers() - parser_args = parser['main'].parse_args(argv) - try: - cfg = cdist.configuration.Configuration(parser_args, - singleton=singleton) - args = cfg.get_args() - except ValueError as e: - raise cdist.Error(str(e)) - # Loglevels are handled globally in here - handle_loglevel(args) - - log = logging.getLogger("cdist") - - log.verbose("version %s" % cdist.VERSION) - log.trace('command line args: {}'.format(cfg.command_line_args)) - log.trace('configuration: {}'.format(cfg.get_config())) - log.trace('configured args: {}'.format(args)) - - check_beta(vars(args)) - - return parser, cfg diff --git a/cdist/autil.py b/cdist/autil.py deleted file mode 100644 index d16d147e..00000000 --- a/cdist/autil.py +++ /dev/null @@ -1,71 +0,0 @@ -# -*- coding: utf-8 -*- -# -# 2017 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 cdist -import tarfile -import os -import glob -import tempfile - - -_ARCHIVING_MODES = { - 'tar': '', - 'tgz': 'gz', - 'tbz2': 'bz2', - 'txz': 'xz', -} - - -_UNARCHIVE_OPT = { - 'tar': None, - 'tgz': '-z', - 'tbz2': '-j', - 'txz': '-J', -} - - -# Archiving will be enabled if directory contains more than FILES_LIMIT files. -FILES_LIMIT = 1 - - -def get_extract_option(mode): - return _UNARCHIVE_OPT[mode] - - -def tar(source, mode="tgz"): - if mode not in _ARCHIVING_MODES: - raise cdist.Error("Unsupported archiving mode {}.".format(mode)) - - files = glob.glob1(source, '*') - fcnt = len(files) - if fcnt <= FILES_LIMIT: - return None, fcnt - - tarmode = 'w:{}'.format(_ARCHIVING_MODES[mode]) - _, tarpath = tempfile.mkstemp(suffix='.' + mode) - with tarfile.open(tarpath, tarmode, dereference=True) as tar: - if os.path.isdir(source): - for f in files: - tar.add(os.path.join(source, f), arcname=f) - else: - tar.add(source) - return tarpath, fcnt diff --git a/cdist/banner.py b/cdist/banner.py index da4dea5d..edfa72e8 100644 --- a/cdist/banner.py +++ b/cdist/banner.py @@ -20,6 +20,8 @@ # import logging +import sys + import cdist log = logging.getLogger(__name__) diff --git a/cdist/conf/explorer/cpu_cores b/cdist/conf/explorer/cpu_cores index a52bddac..efabc848 100755 --- a/cdist/conf/explorer/cpu_cores +++ b/cdist/conf/explorer/cpu_cores @@ -22,23 +22,10 @@ # FIXME: other system types (not linux ...) -os=$("$__explorer/os") -case "$os" in - "macosx") - sysctl -n hw.physicalcpu - ;; - - "openbsd") - sysctl -n hw.ncpuonline - ;; - - *) - if [ -r /proc/cpuinfo ]; then - cores="$(grep "core id" /proc/cpuinfo | sort | uniq | wc -l)" - if [ "${cores}" -eq 0 ]; then - cores="1" - fi - echo "$cores" - fi - ;; -esac +if [ -r /proc/cpuinfo ]; then + cores="$(cat /proc/cpuinfo | grep "core id" | sort | uniq | wc -l)" + if [ ${cores} -eq 0 ]; then + cores="1" + fi + echo "${cores}" +fi diff --git a/cdist/conf/explorer/cpu_sockets b/cdist/conf/explorer/cpu_sockets index a32e2f00..98836cec 100755 --- a/cdist/conf/explorer/cpu_sockets +++ b/cdist/conf/explorer/cpu_sockets @@ -22,19 +22,10 @@ # FIXME: other system types (not linux ...) -os=$("$__explorer/os") -case "$os" in - "macosx") - system_profiler SPHardwareDataType | grep "Number of Processors" | awk -F': ' '{print $2}' - ;; - - *) - if [ -r /proc/cpuinfo ]; then - sockets="$(grep "physical id" /proc/cpuinfo | sort -u | wc -l)" - if [ "${sockets}" -eq 0 ]; then - sockets="$(grep -c "processor" /proc/cpuinfo)" - fi - echo "${sockets}" +if [ -r /proc/cpuinfo ]; then + sockets="$(cat /proc/cpuinfo | grep "physical id" | sort | uniq | wc -l)" + if [ ${sockets} -eq 0 ]; then + sockets="$(cat /proc/cpuinfo | grep "processor" | wc -l)" fi - ;; -esac + echo "${sockets}" +fi diff --git a/cdist/conf/explorer/disks b/cdist/conf/explorer/disks deleted file mode 100755 index 87a6b5c6..00000000 --- a/cdist/conf/explorer/disks +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/sh - -uname_s="$(uname -s)" - -case "${uname_s}" in - FreeBSD) - sysctl -n kern.disks - ;; - OpenBSD|NetBSD) - sysctl -n hw.disknames | grep -Eo '[lsw]d[0-9]+' | xargs - ;; - Linux) - if command -v lsblk > /dev/null - then - # exclude ram disks, floppies and cdroms - # https://www.kernel.org/doc/Documentation/admin-guide/devices.txt - lsblk -e 1,2,11 -dno name | xargs - else - printf "Don't know how to list disks for %s operating system without lsblk, if you can please submit a patch\n" "${uname_s}" >&2 - fi - ;; - *) - printf "Don't know how to list disks for %s operating system, if you can please submit a patch\n" "${uname_s}" >&2 - ;; -esac - -exit 0 diff --git a/cdist/conf/explorer/init b/cdist/conf/explorer/init deleted file mode 100755 index a8a7857e..00000000 --- a/cdist/conf/explorer/init +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/sh -# -# 2016 Daniel Heule (hda at sfs.biz) -# Copyright 2017, Philippe Gregoire -# -# 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 . -# -# -# Returns the process name of pid 1 ( normaly the init system ) -# for example at linux this value is "init" or "systemd" in most cases -# - -uname_s="$(uname -s)" - -case "$uname_s" in - Linux) - (pgrep -P0 -l | awk '/^1[ \t]/ {print $2;}') || true - ;; - FreeBSD|OpenBSD) - ps -o comm= -p 1 || true - ;; - *) - # return a empty string as unknown value - echo "" - ;; -esac diff --git a/cdist/conf/explorer/interfaces b/cdist/conf/explorer/interfaces index 55287971..c1f2a57a 100755 --- a/cdist/conf/explorer/interfaces +++ b/cdist/conf/explorer/interfaces @@ -1,6 +1,6 @@ -#!/bin/sh -e +#!/bin/sh # -# 2019 Ander Punnar (ander-at-kvlt-dot-ee) +# 2012 Sébastien Gross # # This file is part of cdist. # @@ -17,14 +17,35 @@ # You should have received a copy of the GNU General Public License # along with cdist. If not, see . # +# +# List all network interfaces in explorer/ifaces. One interface per line. +# +# If your OS is not supported please provide a ifconfig output +# -if command -v ip > /dev/null -then +# Use ip, if available +if command -v ip >/dev/null; then ip -o link show | sed -n 's/^[0-9]\+: \(.\+\): <.*/\1/p' - -elif command -v ifconfig > /dev/null -then - ifconfig -a \ - | sed -n -E 's/^(.*)(:[[:space:]]*flags=|Link encap).*/\1/p' \ - | sort -u + exit 0 fi + +if ! command -v ifconfig >/dev/null; then + # no ifconfig, nothing we could do + exit 0 +fi + +uname_s="$(uname -s)" +REGEXP='s/^(.*)(:[[:space:]]*flags=|Link encap).*/\1/p' + +case "$uname_s" in + Darwin) + ifconfig -a | sed -n -E "$REGEXP" + ;; + Linux|*BSD) + ifconfig -a | sed -n -r "$REGEXP" + ;; + *) + echo "Unsupported ifconfig output for $uname_s" >&2 + exit 1 + ;; +esac diff --git a/cdist/conf/explorer/is-freebsd-jail b/cdist/conf/explorer/is-freebsd-jail deleted file mode 100755 index 010917f5..00000000 --- a/cdist/conf/explorer/is-freebsd-jail +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -sysctl -n security.jail.jailed 2>/dev/null | grep "1" || true diff --git a/cdist/conf/explorer/kernel_name b/cdist/conf/explorer/kernel_name deleted file mode 100755 index 1f9cfca4..00000000 --- a/cdist/conf/explorer/kernel_name +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -uname -s diff --git a/cdist/conf/explorer/lsb_codename b/cdist/conf/explorer/lsb_codename index 26bb8e3d..eebd3e0f 100755 --- a/cdist/conf/explorer/lsb_codename +++ b/cdist/conf/explorer/lsb_codename @@ -20,9 +20,8 @@ # set +e -case "$("$__explorer/os")" in +case "$($__explorer/os)" in openwrt) - # shellcheck disable=SC1091 (. /etc/openwrt_release && echo "$DISTRIB_CODENAME") ;; *) diff --git a/cdist/conf/explorer/lsb_description b/cdist/conf/explorer/lsb_description index b1009627..23f45421 100755 --- a/cdist/conf/explorer/lsb_description +++ b/cdist/conf/explorer/lsb_description @@ -20,9 +20,8 @@ # set +e -case "$("$__explorer/os")" in +case "$($__explorer/os)" in openwrt) - # shellcheck disable=SC1091 (. /etc/openwrt_release && echo "$DISTRIB_DESCRIPTION") ;; *) diff --git a/cdist/conf/explorer/lsb_id b/cdist/conf/explorer/lsb_id index 82ff9977..9754eb63 100755 --- a/cdist/conf/explorer/lsb_id +++ b/cdist/conf/explorer/lsb_id @@ -20,9 +20,8 @@ # set +e -case "$("$__explorer/os")" in +case "$($__explorer/os)" in openwrt) - # shellcheck disable=SC1091 (. /etc/openwrt_release && echo "$DISTRIB_ID") ;; *) diff --git a/cdist/conf/explorer/lsb_release b/cdist/conf/explorer/lsb_release index 5ebfff1a..35b5547c 100755 --- a/cdist/conf/explorer/lsb_release +++ b/cdist/conf/explorer/lsb_release @@ -20,9 +20,8 @@ # set +e -case "$("$__explorer/os")" in +case "$($__explorer/os)" in openwrt) - # shellcheck disable=SC1091 (. /etc/openwrt_release && echo "$DISTRIB_RELEASE") ;; *) diff --git a/cdist/conf/explorer/machine b/cdist/conf/explorer/machine index 7ecb67e3..d4a0e106 100755 --- a/cdist/conf/explorer/machine +++ b/cdist/conf/explorer/machine @@ -22,6 +22,6 @@ # # -if command -v uname >/dev/null 2>&1 ; then +if command -v uname 2>&1 >/dev/null; then uname -m fi diff --git a/cdist/conf/explorer/machine_type b/cdist/conf/explorer/machine_type index bb21f69c..74789f5a 100755 --- a/cdist/conf/explorer/machine_type +++ b/cdist/conf/explorer/machine_type @@ -22,17 +22,6 @@ # FIXME: other system types (not linux ...) -if [ -d "/proc/vz" ] && [ ! -d "/proc/bc" ]; then - echo openvz - exit -fi - -if [ -e "/proc/1/environ" ] && - tr '\000' '\n' < "/proc/1/environ" | 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 @@ -48,28 +37,13 @@ if [ -r /proc/cpuinfo ]; then if grep -q -i 'vmware' /sys/class/dmi/id/product_name; then echo "virtual_by_vmware" exit - 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 + else + if grep -q -i 'bochs' /sys/class/dmi/id/product_name; then + echo "virtual_by_kvm" + exit + fi fi fi - - if [ -r /sys/class/dmi/id/sys_vendor ]; then - if grep -q -i 'qemu' /sys/class/dmi/id/sys_vendor; then - echo "virtual_by_kvm" - exit - fi - fi - - if [ -r /sys/class/dmi/id/chassis_vendor ]; then - if grep -q -i 'qemu' /sys/class/dmi/id/chassis_vendor; then - echo "virtual_by_kvm" - exit - fi - fi fi echo "virtual_by_unknown" else diff --git a/cdist/conf/explorer/memory b/cdist/conf/explorer/memory index 4e3efff8..982b5dfa 100755 --- a/cdist/conf/explorer/memory +++ b/cdist/conf/explorer/memory @@ -2,7 +2,6 @@ # # 2014 Daniel Heule (hda at sfs.biz) # 2014 Thomas Oettli (otho at sfs.biz) -# Copyright 2017, Philippe Gregoire # # This file is part of cdist. # @@ -23,19 +22,6 @@ # FIXME: other system types (not linux ...) -os=$("$__explorer/os") -case "$os" in - "macosx") - echo "$(sysctl -n hw.memsize)/1024" | bc - ;; - - "openbsd") - echo "$(sysctl -n hw.physmem) / 1048576" | bc - ;; - - *) - if [ -r /proc/meminfo ]; then - grep "MemTotal:" /proc/meminfo | awk '{print $2}' - fi - ;; -esac +if [ -r /proc/meminfo ]; then + echo "$(cat /proc/meminfo | grep "MemTotal:" | awk '{print $2}')" +fi diff --git a/cdist/conf/explorer/os b/cdist/conf/explorer/os index d522300c..053177eb 100755 --- a/cdist/conf/explorer/os +++ b/cdist/conf/explorer/os @@ -1,7 +1,6 @@ #!/bin/sh # # 2010-2011 Nico Schottelius (nico-cdist at schottelius.org) -# Copyright 2017, Philippe Gregoire # # This file is part of cdist. # @@ -40,28 +39,16 @@ if [ -f /etc/cdist-preos ]; then exit 0 fi -if [ -d /gnu/store ]; then - echo guixsd - exit 0 -fi - ### Debian and derivatives if grep -q ^DISTRIB_ID=Ubuntu /etc/lsb-release 2>/dev/null; then echo ubuntu exit 0 fi -# devuan ascii has both devuan_version and debian_version, so we need to check devuan_version first! -if [ -f /etc/devuan_version ]; then - echo devuan - exit 0 -fi - if [ -f /etc/debian_version ]; then echo debian exit 0 fi - ### if [ -f /etc/gentoo-release ]; then @@ -80,11 +67,6 @@ 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 @@ -95,11 +77,6 @@ if grep -q ^Fedora /etc/redhat-release 2>/dev/null; then exit 0 fi -if grep -q ^Mitel /etc/redhat-release 2>/dev/null; then - echo mitel - exit 0 -fi - if [ -f /etc/redhat-release ]; then echo redhat exit 0 @@ -142,12 +119,5 @@ case "$uname_s" in ;; esac -if [ -f /etc/os-release ]; then - # already lowercase, according to: - # https://www.freedesktop.org/software/systemd/man/os-release.html - awk -F= '/^ID=/ {print $2;}' /etc/os-release - exit 0 -fi - echo "Unknown OS" >&2 exit 1 diff --git a/cdist/conf/explorer/os_release b/cdist/conf/explorer/os_release deleted file mode 100644 index cfc01004..00000000 --- a/cdist/conf/explorer/os_release +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/sh -# -# 2018 Adam Dej (dejko.a 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 . -# -# - -# See os-release(5) and http://0pointer.de/blog/projects/os-release - -set +e - -cat /etc/os-release || cat /usr/lib/os-release || true diff --git a/cdist/conf/explorer/os_version b/cdist/conf/explorer/os_version index 4c41695b..50889429 100755 --- a/cdist/conf/explorer/os_version +++ b/cdist/conf/explorer/os_version @@ -22,7 +22,7 @@ # # -case "$("$__explorer/os")" in +case "$($__explorer/os)" in amazon) cat /etc/system-release ;; @@ -33,9 +33,6 @@ case "$("$__explorer/os")" in debian) cat /etc/debian_version ;; - devuan) - cat /etc/devuan_version - ;; fedora) cat /etc/fedora-release ;; @@ -54,18 +51,14 @@ case "$("$__explorer/os")" in owl) cat /etc/owl-release ;; - redhat|centos|mitel|scientific) + redhat|centos) cat /etc/redhat-release ;; slackware) cat /etc/slackware-version ;; suse) - if [ -f /etc/os-release ]; then - cat /etc/os-release - else - cat /etc/SuSE-release - fi + cat /etc/SuSE-release ;; ubuntu) lsb_release -sr diff --git a/cdist/conf/type/__acl/explorer/acl_is b/cdist/conf/type/__acl/explorer/acl_is deleted file mode 100755 index a693c023..00000000 --- a/cdist/conf/type/__acl/explorer/acl_is +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/sh -e -# -# 2018 Ander Punnar (ander-at-kvlt-dot-ee) -# -# 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 . -# - -[ ! -e "/$__object_id" ] && exit 0 - -if ! command -v getfacl > /dev/null -then - echo 'getfacl not available' >&2 - exit 1 -fi - -getfacl "/$__object_id" 2>/dev/null \ - | grep -Eo '^(default:)?(user|group|(mask|other):):[^:][[:graph:]]+' \ - || true diff --git a/cdist/conf/type/__acl/explorer/checks b/cdist/conf/type/__acl/explorer/checks deleted file mode 100755 index 70bb0412..00000000 --- a/cdist/conf/type/__acl/explorer/checks +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/sh -e -# -# 2019 Ander Punnar (ander-at-kvlt-dot-ee) -# -# 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 . -# - -# TODO check if filesystem has ACL turned on etc - -if [ -f "$__object/parameter/acl" ] -then - grep -E '^(default:)?(user|group):' "$__object/parameter/acl" \ - | while read -r acl - do - param="$( echo "$acl" | awk -F: '{print $(NF-2)}' )" - check="$( echo "$acl" | awk -F: '{print $(NF-1)}' )" - - [ "$param" = 'user' ] && db=passwd || db="$param" - - if ! getent "$db" "$check" > /dev/null - then - echo "missing $param '$check'" >&2 - exit 1 - fi - done -fi diff --git a/cdist/conf/type/__acl/explorer/file_is b/cdist/conf/type/__acl/explorer/file_is deleted file mode 100755 index 096cffd1..00000000 --- a/cdist/conf/type/__acl/explorer/file_is +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/sh -e -# -# 2018 Ander Punnar (ander-at-kvlt-dot-ee) -# -# This file is part of cdist. -# -# cdist is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# cdist is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with cdist. If not, see . -# - -if [ -e "/$__object_id" ] -then - if [ -d "/$__object_id" ] - then echo directory - elif [ -f "/$__object_id" ] - then echo regular - else echo other - fi -else - echo missing -fi diff --git a/cdist/conf/type/__acl/gencode-remote b/cdist/conf/type/__acl/gencode-remote deleted file mode 100755 index 6dab4d09..00000000 --- a/cdist/conf/type/__acl/gencode-remote +++ /dev/null @@ -1,126 +0,0 @@ -#!/bin/sh -e -# -# 2018 Ander Punnar (ander-at-kvlt-dot-ee) -# -# This file is part of cdist. -# -# cdist is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# cdist is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with cdist. If not, see . -# - -file_is="$( cat "$__object/explorer/file_is" )" - -[ "$file_is" = 'missing' ] && [ -z "$__cdist_dry_run" ] && exit 0 - -os="$( cat "$__global/explorer/os" )" - -acl_path="/$__object_id" - -acl_is="$( cat "$__object/explorer/acl_is" )" - -if [ -f "$__object/parameter/acl" ] -then - acl_should="$( cat "$__object/parameter/acl" )" -elif - [ -f "$__object/parameter/user" ] \ - || [ -f "$__object/parameter/group" ] \ - || [ -f "$__object/parameter/mask" ] \ - || [ -f "$__object/parameter/other" ] -then - acl_should="$( for param in user group mask other - do - [ ! -f "$__object/parameter/$param" ] && continue - - echo "$param" | grep -Eq 'mask|other' && sep=:: || sep=: - - echo "$param$sep$( cat "$__object/parameter/$param" )" - done )" -else - echo 'no parameters set' >&2 - exit 1 -fi - -if [ -f "$__object/parameter/default" ] -then - acl_should="$( echo "$acl_should" \ - | sed 's/^default://' \ - | sort -u \ - | sed 's/\(.*\)/default:\1\n\1/' )" -fi - -if [ "$file_is" = 'regular' ] \ - && echo "$acl_should" | grep -Eq '^default:' -then - # only directories can have default ACLs, - # but instead of error, - # let's just remove default entries - acl_should="$( echo "$acl_should" | grep -Ev '^default:' )" -fi - -if echo "$acl_should" | awk -F: '{ print $NF }' | grep -Fq 'X' -then - [ "$file_is" = 'directory' ] && rep=x || rep=- - - acl_should="$( echo "$acl_should" | sed "s/\\(.*\\)X/\\1$rep/" )" -fi - -setfacl_exec='setfacl' - -if [ -f "$__object/parameter/recursive" ] -then - if echo "$os" | grep -Fq 'freebsd' - then - echo "$os setfacl do not support recursive operations" >&2 - else - setfacl_exec="$setfacl_exec -R" - fi -fi - -if [ -f "$__object/parameter/remove" ] -then - echo "$acl_is" | while read -r acl - do - # skip wanted ACL entries which already exist - # and skip mask and other entries, because we - # can't actually remove them, but only change. - if echo "$acl_should" | grep -Eq "^$acl" \ - || echo "$acl" | grep -Eq '^(default:)?(mask|other)' - then continue - fi - - if echo "$os" | grep -Fq 'freebsd' - then - remove="$acl" - else - remove="$( echo "$acl" | sed 's/:...$//' )" - fi - - echo "$setfacl_exec -x \"$remove\" \"$acl_path\"" - echo "removed '$remove'" >> "$__messages_out" - done -fi - -for acl in $acl_should -do - if ! echo "$acl_is" | grep -Eq "^$acl" - then - if echo "$os" | grep -Fq 'freebsd' \ - && echo "$acl" | grep -Eq '^default:' - then - echo "setting default ACL in $os is currently not supported" >&2 - else - echo "$setfacl_exec -m \"$acl\" \"$acl_path\"" - echo "added '$acl'" >> "$__messages_out" - fi - fi -done diff --git a/cdist/conf/type/__acl/man.rst b/cdist/conf/type/__acl/man.rst deleted file mode 100644 index 85e946ce..00000000 --- a/cdist/conf/type/__acl/man.rst +++ /dev/null @@ -1,85 +0,0 @@ -cdist-type__acl(7) -================== - -NAME ----- -cdist-type__acl - Set ACL entries - - -DESCRIPTION ------------ -Fully supported and tested on Linux (ext4 filesystem), partial support for FreeBSD. - -See ``setfacl`` and ``acl`` manpages for more details. - - -REQUIRED MULTIPLE PARAMETERS ----------------------------- -acl - Set ACL entry following ``getfacl`` output syntax. - - -BOOLEAN PARAMETERS ------------------- -default - Set all ACL entries as default too. - Only directories can have default ACLs. - Setting default ACL in FreeBSD is currently not supported. - -recursive - Make ``setfacl`` recursive (Linux only), but not ``getfacl`` in explorer. - -remove - Remove undefined ACL entries. - ``mask`` and ``other`` entries can't be removed, but only changed. - - -DEPRECATED PARAMETERS ---------------------- -Parameters ``user``, ``group``, ``mask`` and ``other`` are deprecated and they -will be removed in future versions. Please use ``acl`` parameter instead. - - -EXAMPLES --------- - -.. code-block:: sh - - __acl /srv/project \ - --default \ - --recursive \ - --remove \ - --acl user:alice:rwx \ - --acl user:bob:r-x \ - --acl group:project-group:rwx \ - --acl group:some-other-group:r-x \ - --acl mask::r-x \ - --acl other::r-x - - # give Alice read-only access to subdir, - # but don't allow her to see parent content. - - __acl /srv/project2 \ - --remove \ - --acl default:group:secret-project:rwx \ - --acl group:secret-project:rwx \ - --acl user:alice:--x - - __acl /srv/project2/subdir \ - --default \ - --remove \ - --acl group:secret-project:rwx \ - --acl user:alice:r-x - - -AUTHORS -------- -Ander Punnar - - -COPYING -------- -Copyright \(C) 2018 Ander Punnar. 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. diff --git a/cdist/conf/type/__acl/parameter/boolean b/cdist/conf/type/__acl/parameter/boolean deleted file mode 100644 index 8b96693f..00000000 --- a/cdist/conf/type/__acl/parameter/boolean +++ /dev/null @@ -1,3 +0,0 @@ -recursive -default -remove diff --git a/cdist/conf/type/__acl/parameter/deprecated/group b/cdist/conf/type/__acl/parameter/deprecated/group deleted file mode 100644 index 94e14159..00000000 --- a/cdist/conf/type/__acl/parameter/deprecated/group +++ /dev/null @@ -1 +0,0 @@ -see manual for details diff --git a/cdist/conf/type/__acl/parameter/deprecated/mask b/cdist/conf/type/__acl/parameter/deprecated/mask deleted file mode 100644 index 94e14159..00000000 --- a/cdist/conf/type/__acl/parameter/deprecated/mask +++ /dev/null @@ -1 +0,0 @@ -see manual for details diff --git a/cdist/conf/type/__acl/parameter/deprecated/other b/cdist/conf/type/__acl/parameter/deprecated/other deleted file mode 100644 index 94e14159..00000000 --- a/cdist/conf/type/__acl/parameter/deprecated/other +++ /dev/null @@ -1 +0,0 @@ -see manual for details diff --git a/cdist/conf/type/__acl/parameter/deprecated/user b/cdist/conf/type/__acl/parameter/deprecated/user deleted file mode 100644 index 94e14159..00000000 --- a/cdist/conf/type/__acl/parameter/deprecated/user +++ /dev/null @@ -1 +0,0 @@ -see manual for details diff --git a/cdist/conf/type/__acl/parameter/optional b/cdist/conf/type/__acl/parameter/optional deleted file mode 100644 index 4b32086b..00000000 --- a/cdist/conf/type/__acl/parameter/optional +++ /dev/null @@ -1,2 +0,0 @@ -mask -other diff --git a/cdist/conf/type/__acl/parameter/optional_multiple b/cdist/conf/type/__acl/parameter/optional_multiple deleted file mode 100644 index 95c25d55..00000000 --- a/cdist/conf/type/__acl/parameter/optional_multiple +++ /dev/null @@ -1,3 +0,0 @@ -acl -user -group diff --git a/cdist/conf/type/__apt_default_release/man.rst b/cdist/conf/type/__apt_default_release/man.rst deleted file mode 100644 index 0277a06f..00000000 --- a/cdist/conf/type/__apt_default_release/man.rst +++ /dev/null @@ -1,46 +0,0 @@ -cdist-type__apt_default_release(7) -================================== - -NAME ----- -cdist-type__apt_default_release - Configure the default release for apt - - -DESCRIPTION ------------ -Configure the default release for apt, using the APT::Default-Release -configuration value. - -REQUIRED PARAMETERS -------------------- -release - The value to set APT::Default-Release to. - - This can contain release name, codename or release version. Examples: - 'stable', 'testing', 'unstable', 'stretch', 'buster', '4.0', '5.0*'. - - -OPTIONAL PARAMETERS -------------------- -None. - - -EXAMPLES --------- - -.. code-block:: sh - - __apt_default_release --release stretch - - -AUTHORS -------- -Matthijs Kooijman - - -COPYING -------- -Copyright \(C) 2017 Matthijs Kooijman. 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. diff --git a/cdist/conf/type/__apt_default_release/manifest b/cdist/conf/type/__apt_default_release/manifest deleted file mode 100755 index 1232efb5..00000000 --- a/cdist/conf/type/__apt_default_release/manifest +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/sh -e -# -# 2014 Steven Armstrong (steven-cdist at armstrong.cc) -# 2017 Matthijs Kooijman (matthijs at stdin.nl) -# -# This file is part of cdist. -# -# cdist is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# cdist is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with cdist. If not, see . -# - - -os=$(cat "$__global/explorer/os") -release="$(cat "$__object/parameter/release")" - -case "$os" in - ubuntu|debian|devuan) - __file /etc/apt/apt.conf.d/99-default-release \ - --owner root --group root --mode 644 \ - --source - << DONE -APT::Default-Release "$release"; -DONE - ;; - *) - cat >&2 << DONE -The developer of this type (${__type##*/}) did not think your operating system -($os) would have any use for it. If you think otherwise please submit a patch. -DONE - exit 1 - ;; -esac diff --git a/cdist/conf/type/__apt_default_release/parameter/required b/cdist/conf/type/__apt_default_release/parameter/required deleted file mode 100644 index d7025695..00000000 --- a/cdist/conf/type/__apt_default_release/parameter/required +++ /dev/null @@ -1 +0,0 @@ -release diff --git a/cdist/conf/type/__apt_default_release/singleton b/cdist/conf/type/__apt_default_release/singleton deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/conf/type/__apt_key/explorer/state b/cdist/conf/type/__apt_key/explorer/state index 38f1bd3c..f7940741 100755 --- a/cdist/conf/type/__apt_key/explorer/state +++ b/cdist/conf/type/__apt_key/explorer/state @@ -27,18 +27,6 @@ else keyid="$__object_id" fi -keydir="$(cat "$__object/parameter/keydir")" -keyfile="$keydir/$__object_id.gpg" - -if [ -d "$keydir" ] -then - if [ -f "$keyfile" ] - then echo present - else echo absent - fi -else - # fallback to deprecated apt-key - apt-key export "$keyid" | head -n 1 | grep -Fqe "BEGIN PGP PUBLIC KEY BLOCK" \ - && echo present \ - || echo absent -fi +apt-key export "$keyid" | head -n 1 | grep -Fqe "BEGIN PGP PUBLIC KEY BLOCK" \ + && echo present \ + || echo absent diff --git a/cdist/conf/type/__apt_key/gencode-remote b/cdist/conf/type/__apt_key/gencode-remote index 47c8bb49..c6ead91c 100755 --- a/cdist/conf/type/__apt_key/gencode-remote +++ b/cdist/conf/type/__apt_key/gencode-remote @@ -1,4 +1,4 @@ -#!/bin/sh -e +#!/bin/sh # # 2011-2014 Steven Armstrong (steven-cdist at armstrong.cc) # @@ -31,84 +31,12 @@ if [ "$state_should" = "$state_is" ]; then exit 0 fi -keydir="$(cat "$__object/parameter/keydir")" -keyfile="$keydir/$__object_id.gpg" - case "$state_should" in present) keyserver="$(cat "$__object/parameter/keyserver")" - - if [ -f "$__object/parameter/uri" ]; then - uri="$(cat "$__object/parameter/uri")" - - if [ -d "$keydir" ]; then - cat << EOF - -curl -s -L \\ - -o "$keyfile" \\ - "$uri" - -if grep -Fq 'BEGIN PGP PUBLIC KEY BLOCK' \\ - "$keyfile" -then - cat "$keyfile" \\ - | gpg --export > "$keyfile" -fi - -EOF - else - # fallback to deprecated apt-key - echo "curl -s -L '$uri' | apt-key add -" - fi - elif [ -d "$keydir" ]; then - tmp='/tmp/cdist_apt_key_tmp' - - # we need to kill gpg after 30 seconds, because gpg - # can get stuck if keyserver is not responding. - # exporting env var and not exit 1, - # because we need to clean up and kill dirmngr. - cat << EOF - -mkdir -m 700 -p "$tmp" - -if timeout 30s \\ - gpg --homedir "$tmp" \\ - --keyserver "$keyserver" \\ - --recv-keys "$keyid" -then - gpg --homedir "$tmp" \\ - --export "$keyid" \\ - > "$keyfile" -else - export GPG_GOT_STUCK=1 -fi - -GNUPGHOME="$tmp" gpgconf --kill dirmngr - -rm -rf "$tmp" - -if [ -n "\$GPG_GOT_STUCK" ] -then - echo "GPG GOT STUCK - no response from keyserver after 30 seconds" >&2 - exit 1 -fi - -EOF - else - # fallback to deprecated apt-key - echo "apt-key adv --keyserver \"$keyserver\" --recv-keys \"$keyid\"" - fi - - echo "added '$keyid'" >> "$__messages_out" + echo "apt-key adv --keyserver \"$keyserver\" --recv-keys \"$keyid\"" ;; absent) - if [ -f "$keyfile" ]; then - echo "rm '$keyfile'" - else - # fallback to deprecated apt-key - echo "apt-key del \"$keyid\"" - fi - - echo "removed '$keyid'" >> "$__messages_out" + echo "apt-key del \"$keyid\"" ;; esac diff --git a/cdist/conf/type/__apt_key/man.rst b/cdist/conf/type/__apt_key/man.rst deleted file mode 100644 index 234bc715..00000000 --- a/cdist/conf/type/__apt_key/man.rst +++ /dev/null @@ -1,72 +0,0 @@ -cdist-type__apt_key(7) -====================== - -NAME ----- -cdist-type__apt_key - Manage the list of keys used by apt - - -DESCRIPTION ------------ -Manages the list of keys used by apt to authenticate packages. - - -REQUIRED PARAMETERS -------------------- -None. - - -OPTIONAL PARAMETERS -------------------- -state - 'present' or 'absent'. Defaults to 'present' - -keyid - the id of the key to add. Defaults to __object_id - -keyserver - the keyserver from which to fetch the key. If omitted the default set - in ./parameter/default/keyserver is used. - -keydir - key save location, defaults to ``/etc/apt/trusted.pgp.d`` - -uri - the URI from which to download the key - - -EXAMPLES --------- - -.. code-block:: sh - - # Add Ubuntu Archive Automatic Signing Key - __apt_key 437D05B5 - # Same thing - __apt_key 437D05B5 --state present - # Get rid of it - __apt_key 437D05B5 --state absent - - # same thing with human readable name and explicit keyid - __apt_key UbuntuArchiveKey --keyid 437D05B5 - - # same thing with other keyserver - __apt_key UbuntuArchiveKey --keyid 437D05B5 --keyserver keyserver.ubuntu.com - - # download key from the internet - __apt_key rabbitmq \ - --uri http://www.rabbitmq.com/rabbitmq-signing-key-public.asc - - -AUTHORS -------- -Steven Armstrong -Ander Punnar - - -COPYING -------- -Copyright \(C) 2011-2019 Steven Armstrong and Ander Punnar. 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. diff --git a/cdist/conf/type/__apt_key/man.text b/cdist/conf/type/__apt_key/man.text new file mode 100644 index 00000000..1a33e732 --- /dev/null +++ b/cdist/conf/type/__apt_key/man.text @@ -0,0 +1,61 @@ +cdist-type__apt_key(7) +====================== +Steven Armstrong + + +NAME +---- +cdist-type__apt_key - manage the list of keys used by apt + + +DESCRIPTION +----------- +Manages the list of keys used by apt to authenticate packages. + + +REQUIRED PARAMETERS +------------------- +None. + + +OPTIONAL PARAMETERS +------------------- +state:: + 'present' or 'absent'. Defaults to 'present' + +keyid:: + the id of the key to add. Defaults to __object_id + +keyserver:: + the keyserver from which to fetch the key. If omitted the default set in + ./parameter/default/keyserver is used. + + +EXAMPLES +-------- + +-------------------------------------------------------------------------------- +# Add Ubuntu Archive Automatic Signing Key +__apt_key 437D05B5 +# Same thing +__apt_key 437D05B5 --state present +# Get rid of it +__apt_key 437D05B5 --state absent + +# same thing with human readable name and explicit keyid +__apt_key UbuntuArchiveKey --keyid 437D05B5 + +# same thing with other keyserver +__apt_key UbuntuArchiveKey --keyid 437D05B5 --keyserver keyserver.ubuntu.com +-------------------------------------------------------------------------------- + + +SEE ALSO +-------- +- cdist-type(7) + + +COPYING +------- +Copyright \(C) 2011-2014 Steven Armstrong. Free use of this software is +granted under the terms of the GNU General Public License version 3 (GPLv3). diff --git a/cdist/conf/type/__apt_key/manifest b/cdist/conf/type/__apt_key/manifest deleted file mode 100755 index 010357cd..00000000 --- a/cdist/conf/type/__apt_key/manifest +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh -e - -__package gnupg - -if [ -f "$__object/parameter/uri" ] -then __package curl -else __package dirmngr -fi diff --git a/cdist/conf/type/__apt_key/parameter/default/keydir b/cdist/conf/type/__apt_key/parameter/default/keydir deleted file mode 100644 index 190eb2de..00000000 --- a/cdist/conf/type/__apt_key/parameter/default/keydir +++ /dev/null @@ -1 +0,0 @@ -/etc/apt/trusted.gpg.d diff --git a/cdist/conf/type/__apt_key/parameter/default/keyserver b/cdist/conf/type/__apt_key/parameter/default/keyserver index 0d189916..f851282c 100644 --- a/cdist/conf/type/__apt_key/parameter/default/keyserver +++ b/cdist/conf/type/__apt_key/parameter/default/keyserver @@ -1 +1 @@ -pool.sks-keyservers.net +subkeys.pgp.net diff --git a/cdist/conf/type/__apt_key/parameter/optional b/cdist/conf/type/__apt_key/parameter/optional index de647375..18cf2586 100644 --- a/cdist/conf/type/__apt_key/parameter/optional +++ b/cdist/conf/type/__apt_key/parameter/optional @@ -1,5 +1,3 @@ state keyid keyserver -keydir -uri diff --git a/cdist/conf/type/__apt_key_uri/explorer/state b/cdist/conf/type/__apt_key_uri/explorer/state index 6f607607..15d6e653 100755 --- a/cdist/conf/type/__apt_key_uri/explorer/state +++ b/cdist/conf/type/__apt_key_uri/explorer/state @@ -27,6 +27,6 @@ else name="$__object_id" fi -apt-key list 2> /dev/null | grep -Fqe "$name" \ +apt-key list | grep -Fqe "$name" \ && echo present \ || echo absent diff --git a/cdist/conf/type/__apt_key_uri/gencode-remote b/cdist/conf/type/__apt_key_uri/gencode-remote index 229b6564..078b8695 100755 --- a/cdist/conf/type/__apt_key_uri/gencode-remote +++ b/cdist/conf/type/__apt_key_uri/gencode-remote @@ -1,4 +1,4 @@ -#!/bin/sh -e +#!/bin/sh # # 2011-2014 Steven Armstrong (steven-cdist at armstrong.cc) # diff --git a/cdist/conf/type/__apt_key_uri/man.rst b/cdist/conf/type/__apt_key_uri/man.rst deleted file mode 100644 index 82a191b9..00000000 --- a/cdist/conf/type/__apt_key_uri/man.rst +++ /dev/null @@ -1,51 +0,0 @@ -cdist-type__apt_key_uri(7) -========================== - -NAME ----- -cdist-type__apt_key_uri - Add apt key from uri - - -DESCRIPTION ------------ -Download a key from an uri and add it to the apt keyring. - - -REQUIRED PARAMETERS -------------------- -uri - the uri from which to download the key - - -OPTIONAL PARAMETERS -------------------- -state - 'present' or 'absent', defaults to 'present' - -name - a name for this key, used when testing if it is already installed. - Defaults to __object_id - - -EXAMPLES --------- - -.. code-block:: sh - - __apt_key_uri rabbitmq \ - --name 'RabbitMQ Release Signing Key ' \ - --uri http://www.rabbitmq.com/rabbitmq-signing-key-public.asc \ - --state present - - -AUTHORS -------- -Steven Armstrong - - -COPYING -------- -Copyright \(C) 2011-2014 Steven Armstrong. 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. diff --git a/cdist/conf/type/__apt_key_uri/man.text b/cdist/conf/type/__apt_key_uri/man.text new file mode 100644 index 00000000..fe9c3a25 --- /dev/null +++ b/cdist/conf/type/__apt_key_uri/man.text @@ -0,0 +1,51 @@ +cdist-type__apt_key_uri(7) +========================== +Steven Armstrong + + +NAME +---- +cdist-type__apt_key_uri - add apt key from uri + + +DESCRIPTION +----------- +Download a key from an uri and add it to the apt keyring. + + +REQUIRED PARAMETERS +------------------- +uri:: + the uri from which to download the key + + +OPTIONAL PARAMETERS +------------------- +state:: + 'present' or 'absent', defaults to 'present' + +name:: + a name for this key, used when testing if it is already installed. + Defaults to __object_id + + +EXAMPLES +-------- + +-------------------------------------------------------------------------------- +__apt_key_uri rabbitmq \ + --name 'RabbitMQ Release Signing Key ' \ + --uri http://www.rabbitmq.com/rabbitmq-signing-key-public.asc \ + --state present +-------------------------------------------------------------------------------- + + +SEE ALSO +-------- +- cdist-type(7) + + +COPYING +------- +Copyright \(C) 2011-2014 Steven Armstrong. Free use of this software is +granted under the terms of the GNU General Public License version 3 (GPLv3). diff --git a/cdist/conf/type/__apt_key_uri/manifest b/cdist/conf/type/__apt_key_uri/manifest index bf7b267d..8dddde56 100755 --- a/cdist/conf/type/__apt_key_uri/manifest +++ b/cdist/conf/type/__apt_key_uri/manifest @@ -1,4 +1,4 @@ -#!/bin/sh -e +#!/bin/sh # # 2013-2014 Steven Armstrong (steven-cdist at armstrong.cc) # diff --git a/cdist/conf/type/__apt_mark/explorer/apt_version b/cdist/conf/type/__apt_mark/explorer/apt_version deleted file mode 100755 index 7bb90cc2..00000000 --- a/cdist/conf/type/__apt_mark/explorer/apt_version +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/sh -e -# -# 2016 Ander Punnar (cdist at kvlt.ee) -# -# 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 . -# - -apt_version_is=$(dpkg-query --show --showformat '${Version}' apt) - -# from APT changelog: -# apt (0.8.14.2) UNRELEASED; urgency=low -# provide a 'dpkg --set-selections' wrapper to set/release holds - -apt_version_should=0.8.14.2 - -dpkg --compare-versions "$apt_version_should" le "$apt_version_is" \ - && echo 0 \ - || echo 1 diff --git a/cdist/conf/type/__apt_mark/explorer/package_installed b/cdist/conf/type/__apt_mark/explorer/package_installed deleted file mode 100755 index 0b072cbc..00000000 --- a/cdist/conf/type/__apt_mark/explorer/package_installed +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/sh -e -# -# 2016 Ander Punnar (cdist at kvlt.ee) -# -# This file is part of cdist. -# -# cdist is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# cdist is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with cdist. If not, see . -# - -if [ -f "$__object/parameter/name" ]; then - name="$(cat "$__object/parameter/name")" -else - name="$__object_id" -fi - -dpkg-query --show --showformat '${Status}' "$name" 2>/dev/null \ - | grep -Fq 'ok installed' \ - && echo 0 \ - || echo 1 diff --git a/cdist/conf/type/__apt_mark/explorer/state b/cdist/conf/type/__apt_mark/explorer/state deleted file mode 100755 index b7fe08fa..00000000 --- a/cdist/conf/type/__apt_mark/explorer/state +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/sh -e -# -# 2016 Ander Punnar (cdist at kvlt.ee) -# -# This file is part of cdist. -# -# cdist is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# cdist is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with cdist. If not, see . -# - -if [ -f "$__object/parameter/name" ]; then - name="$(cat "$__object/parameter/name")" -else - name="$__object_id" -fi - -apt-mark showhold | grep -Fq "$name" && echo hold || echo unhold diff --git a/cdist/conf/type/__apt_mark/gencode-remote b/cdist/conf/type/__apt_mark/gencode-remote deleted file mode 100755 index bc995444..00000000 --- a/cdist/conf/type/__apt_mark/gencode-remote +++ /dev/null @@ -1,56 +0,0 @@ -#!/bin/sh -e -# -# 2016 Ander Punnar (cdist at kvlt.ee) -# -# This file is part of cdist. -# -# cdist is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# cdist is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with cdist. If not, see . -# - -if [ -f "$__object/parameter/name" ]; then - name="$(cat "$__object/parameter/name")" -else - name="$__object_id" -fi - -apt_version="$(cat "$__object/explorer/apt_version")" - -if [ "$apt_version" != '0' ]; then - echo 'APT version not supported' >&2 - exit 1 -fi - -package_installed="$(cat "$__object/explorer/package_installed")" - -if [ "$package_installed" != '0' ]; then - exit 0 -fi - -state_should="$(cat "$__object/parameter/state")" - -state_is="$(cat "$__object/explorer/state")" - -if [ "$state_should" = "$state_is" ]; then - exit 0 -fi - -case "$state_should" in - hold|unhold) - echo "apt-mark $state_should $name > /dev/null" - ;; - *) - echo "Unknown state: $state_should" >&2 - exit 1 - ;; -esac diff --git a/cdist/conf/type/__apt_mark/man.rst b/cdist/conf/type/__apt_mark/man.rst deleted file mode 100644 index 7aa2a519..00000000 --- a/cdist/conf/type/__apt_mark/man.rst +++ /dev/null @@ -1,47 +0,0 @@ -cdist-type__apt_mark(7) -======================= - -NAME ----- -cdist-type__apt_mark - set package state as 'hold' or 'unhold' - - -DESCRIPTION ------------ -See apt-mark(8) for details. - - -REQUIRED PARAMETERS -------------------- -state - Either "hold" or "unhold". - - -OPTIONAL PARAMETERS -------------------- -name - If supplied, use the name and not the object id as the package name. - - -EXAMPLES --------- - -.. code-block:: sh - - # hold package - __apt_mark quagga --state hold - # unhold package - __apt_mark quagga --state unhold - - -AUTHORS -------- -Ander Punnar - - -COPYING -------- -Copyright \(C) 2016 Ander Punnar. 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. diff --git a/cdist/conf/type/__apt_mark/parameter/optional b/cdist/conf/type/__apt_mark/parameter/optional deleted file mode 100644 index f121bdbf..00000000 --- a/cdist/conf/type/__apt_mark/parameter/optional +++ /dev/null @@ -1 +0,0 @@ -name diff --git a/cdist/conf/type/__apt_mark/parameter/required b/cdist/conf/type/__apt_mark/parameter/required deleted file mode 100644 index ff72b5c7..00000000 --- a/cdist/conf/type/__apt_mark/parameter/required +++ /dev/null @@ -1 +0,0 @@ -state diff --git a/cdist/conf/type/__apt_norecommends/man.rst b/cdist/conf/type/__apt_norecommends/man.rst deleted file mode 100644 index 001fffe4..00000000 --- a/cdist/conf/type/__apt_norecommends/man.rst +++ /dev/null @@ -1,42 +0,0 @@ -cdist-type__apt_norecommends(7) -=============================== - -NAME ----- -cdist-type__apt_norecommends - Configure apt to not install recommended packages - - -DESCRIPTION ------------ -Configure apt to not install any recommended or suggested packages. - - -REQUIRED PARAMETERS -------------------- -None. - - -OPTIONAL PARAMETERS -------------------- -None. - - -EXAMPLES --------- - -.. code-block:: sh - - __apt_norecommends - - -AUTHORS -------- -Steven Armstrong - - -COPYING -------- -Copyright \(C) 2014 Steven Armstrong. 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. diff --git a/cdist/conf/type/__apt_norecommends/man.text b/cdist/conf/type/__apt_norecommends/man.text new file mode 100644 index 00000000..3b65e72f --- /dev/null +++ b/cdist/conf/type/__apt_norecommends/man.text @@ -0,0 +1,42 @@ +cdist-type__apt_norecommends(7) +=============================== +Steven Armstrong + + +NAME +---- +cdist-type__apt_norecommends - configure apt to not install recommended packages + + +DESCRIPTION +----------- +Configure apt to not install any recommended or suggested packages. + + +REQUIRED PARAMETERS +------------------- +None. + + +OPTIONAL PARAMETERS +------------------- +None. + + +EXAMPLES +-------- + +-------------------------------------------------------------------------------- +__apt_norecommends +-------------------------------------------------------------------------------- + + +SEE ALSO +-------- +- cdist-type(7) + + +COPYING +------- +Copyright \(C) 2014 Steven Armstrong. Free use of this software is +granted under the terms of the GNU General Public License version 3 (GPLv3). diff --git a/cdist/conf/type/__apt_norecommends/manifest b/cdist/conf/type/__apt_norecommends/manifest index e737df89..881c2427 100755 --- a/cdist/conf/type/__apt_norecommends/manifest +++ b/cdist/conf/type/__apt_norecommends/manifest @@ -1,4 +1,4 @@ -#!/bin/sh -e +#!/bin/sh # # 2014 Steven Armstrong (steven-cdist at armstrong.cc) # @@ -22,7 +22,7 @@ os=$(cat "$__global/explorer/os") case "$os" in - ubuntu|debian|devuan) + ubuntu|debian) # No stinking recommends thank you very much. # If I want something installed I will do so myself. __file /etc/apt/apt.conf.d/99-no-recommends \ @@ -30,8 +30,6 @@ case "$os" in --source - << DONE APT::Install-Recommends "0"; APT::Install-Suggests "0"; -APT::AutoRemove::RecommendsImportant "0"; -APT::AutoRemove::SuggestsImportant "0"; DONE ;; *) diff --git a/cdist/conf/type/__apt_ppa/explorer/state b/cdist/conf/type/__apt_ppa/explorer/state index d47e7d20..2bb4f65a 100755 --- a/cdist/conf/type/__apt_ppa/explorer/state +++ b/cdist/conf/type/__apt_ppa/explorer/state @@ -23,11 +23,10 @@ name="$__object_id" -# shellcheck disable=SC1091 . /etc/lsb-release repo_name="${name#ppa:}" -repo_file_name="$(echo "$repo_name" | sed -e 's|[/:]|-|' -e 's|\.|_|')-${DISTRIB_CODENAME}.list" +repo_file_name="$(echo "$repo_name" | sed -e "s|[/:]|-|" -e "s|\.|_|")-${DISTRIB_CODENAME}.list" [ -s "/etc/apt/sources.list.d/${repo_file_name}" ] \ && echo present || echo absent diff --git a/cdist/conf/type/__apt_ppa/gencode-remote b/cdist/conf/type/__apt_ppa/gencode-remote index 84ebebfe..300a0e1e 100755 --- a/cdist/conf/type/__apt_ppa/gencode-remote +++ b/cdist/conf/type/__apt_ppa/gencode-remote @@ -1,4 +1,4 @@ -#!/bin/sh -e +#!/bin/sh # # 2011 Steven Armstrong (steven-cdist at armstrong.cc) # @@ -29,9 +29,9 @@ fi case "$state_should" in present) - echo "add-apt-repository '$name'" + echo add-apt-repository \"$name\" ;; absent) - echo "remove-apt-repository '$name'" + echo remove-apt-repository \"$name\" ;; esac diff --git a/cdist/conf/type/__apt_ppa/man.rst b/cdist/conf/type/__apt_ppa/man.rst deleted file mode 100644 index 8347c908..00000000 --- a/cdist/conf/type/__apt_ppa/man.rst +++ /dev/null @@ -1,50 +0,0 @@ -cdist-type__apt_ppa(7) -====================== - -NAME ----- -cdist-type__apt_ppa - Manage ppa repositories - - -DESCRIPTION ------------ -This cdist type allows manage ubuntu ppa repositories. - - -REQUIRED PARAMETERS -------------------- -state - The state the ppa should be in, either 'present' or 'absent'. - Defaults to 'present' - - -OPTIONAL PARAMETERS -------------------- -None. - - -EXAMPLES --------- - -.. code-block:: sh - - # Enable a ppa repository - __apt_ppa ppa:sans-intern/missing-bits - # same as - __apt_ppa ppa:sans-intern/missing-bits --state present - - # Disable a ppa repository - __apt_ppa ppa:sans-intern/missing-bits --state absent - - -AUTHORS -------- -Steven Armstrong - - -COPYING -------- -Copyright \(C) 2011-2014 Steven Armstrong. 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. diff --git a/cdist/conf/type/__apt_ppa/man.text b/cdist/conf/type/__apt_ppa/man.text new file mode 100644 index 00000000..da18e9f0 --- /dev/null +++ b/cdist/conf/type/__apt_ppa/man.text @@ -0,0 +1,50 @@ +cdist-type__apt_ppa(7) +====================== +Steven Armstrong + + +NAME +---- +cdist-type__apt_ppa - Manage ppa repositories + + +DESCRIPTION +----------- +This cdist type allows manage ubuntu ppa repositories. + + +REQUIRED PARAMETERS +------------------- +state:: + The state the ppa should be in, either 'present' or 'absent'. + Defaults to 'present' + + +OPTIONAL PARAMETERS +------------------- +None. + + +EXAMPLES +-------- + +-------------------------------------------------------------------------------- +# Enable a ppa repository +__apt_ppa ppa:sans-intern/missing-bits +# same as +__apt_ppa ppa:sans-intern/missing-bits --state present + +# Disable a ppa repository +__apt_ppa ppa:sans-intern/missing-bits --state absent +-------------------------------------------------------------------------------- + + +SEE ALSO +-------- +- cdist-type(7) + + +COPYING +------- +Copyright \(C) 2011-2014 Steven Armstrong. Free use of this software is +granted under the terms of the GNU General Public License version 3 (GPLv3). diff --git a/cdist/conf/type/__apt_ppa/manifest b/cdist/conf/type/__apt_ppa/manifest index c6f4e876..1d90e9c4 100755 --- a/cdist/conf/type/__apt_ppa/manifest +++ b/cdist/conf/type/__apt_ppa/manifest @@ -1,6 +1,6 @@ -#!/bin/sh -e +#!/bin/sh # -# 2011-2016 Steven Armstrong (steven-cdist at armstrong.cc) +# 2011-2014 Steven Armstrong (steven-cdist at armstrong.cc) # # This file is part of cdist. # @@ -18,9 +18,12 @@ # along with cdist. If not, see . # -__package software-properties-common +name="$__object_id" -require="__package/software-properties-common" \ +__package software-properties-common +__package python-software-properties + +require="__package/software-properties-common __package/python-software-properties" \ __file /usr/local/bin/remove-apt-repository \ --source "$__type/files/remove-apt-repository" \ --mode 0755 diff --git a/cdist/conf/type/__apt_source/gencode-remote b/cdist/conf/type/__apt_source/gencode-remote deleted file mode 100755 index 1e8592c6..00000000 --- a/cdist/conf/type/__apt_source/gencode-remote +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/sh -e -# -# 2018 Steven Armstrong (steven-cdist at armstrong.cc) -# -# This file is part of cdist. -# -# cdist is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# cdist is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with cdist. If not, see . -# -# - -name="$__object_id" -destination="/etc/apt/sources.list.d/${name}.list" - -if grep -q "^__file${destination}" "$__messages_in"; then - printf 'apt-get update || apt-get update\n' -fi - diff --git a/cdist/conf/type/__apt_source/man.rst b/cdist/conf/type/__apt_source/man.rst deleted file mode 100644 index d1acb388..00000000 --- a/cdist/conf/type/__apt_source/man.rst +++ /dev/null @@ -1,70 +0,0 @@ -cdist-type__apt_source(7) -========================= - -NAME ----- -cdist-type__apt_source - Manage apt sources - - -DESCRIPTION ------------ -This cdist type allows you to manage apt sources. It invokes index update -internally when needed so call of index updating type is not needed. - - -REQUIRED PARAMETERS -------------------- -uri - the uri to the apt repository - - -OPTIONAL PARAMETERS -------------------- -arch - set this if you need to force and specific arch (ubuntu specific) - -state - 'present' or 'absent', defaults to 'present' - -distribution - the distribution codename to use. Defaults to DISTRIB_CODENAME from - the targets /etc/lsb-release - -component - space delimited list of components to enable. Defaults to an empty string. - - -BOOLEAN PARAMETERS ------------------- -include-src - include deb-src entries - - -EXAMPLES --------- - -.. code-block:: sh - - __apt_source rabbitmq \ - --uri http://www.rabbitmq.com/debian/ \ - --distribution testing \ - --component main \ - --include-src \ - --state present - - __apt_source canonical_partner \ - --uri http://archive.canonical.com/ \ - --component partner --state present - - -AUTHORS -------- -Steven Armstrong - - -COPYING -------- -Copyright \(C) 2011-2018 Steven Armstrong. 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. diff --git a/cdist/conf/type/__apt_source/man.text b/cdist/conf/type/__apt_source/man.text new file mode 100644 index 00000000..03b2b311 --- /dev/null +++ b/cdist/conf/type/__apt_source/man.text @@ -0,0 +1,69 @@ +cdist-type__apt_source(7) +========================= +Steven Armstrong + + +NAME +---- +cdist-type__apt_source - manage apt sources + + +DESCRIPTION +----------- +This cdist type allows you to manage apt sources. + + +REQUIRED PARAMETERS +------------------- +uri:: + the uri to the apt repository + + +OPTIONAL PARAMETERS +------------------- +arch:: + set this if you need to force and specific arch (ubuntu specific) + +state:: + 'present' or 'absent', defaults to 'present' + +distribution:: + the distribution codename to use. Defaults to DISTRIB_CODENAME from + the targets /etc/lsb-release + +component:: + space delimited list of components to enable. Defaults to an empty string. + + +BOOLEAN PARAMETERS +------------------ +include-src:: + include deb-src entries + + +EXAMPLES +-------- + +-------------------------------------------------------------------------------- +__apt_source rabbitmq \ + --uri http://www.rabbitmq.com/debian/ \ + --distribution testing \ + --component main \ + --include-src \ + --state present + +__apt_source canonical_partner \ + --uri http://archive.canonical.com/ \ + --component partner --state present +-------------------------------------------------------------------------------- + + +SEE ALSO +-------- +- cdist-type(7) + + +COPYING +------- +Copyright \(C) 2011-2014 Steven Armstrong. Free use of this software is +granted under the terms of the GNU General Public License version 3 (GPLv3). diff --git a/cdist/conf/type/__apt_source/manifest b/cdist/conf/type/__apt_source/manifest index 35f15909..0e782716 100755 --- a/cdist/conf/type/__apt_source/manifest +++ b/cdist/conf/type/__apt_source/manifest @@ -1,6 +1,6 @@ -#!/bin/sh -e +#!/bin/sh # -# 2011-2018 Steven Armstrong (steven-cdist at armstrong.cc) +# 2011-2013 Steven Armstrong (steven-cdist at armstrong.cc) # # This file is part of cdist. # @@ -27,9 +27,11 @@ if [ -f "$__object/parameter/distribution" ]; then else distribution="$(cat "$__global/explorer/lsb_codename")" fi - -component="$(cat "$__object/parameter/component")" - +if [ -f "$__object/parameter/component" ]; then + component="$(cat "$__object/parameter/component")" +else + component="" +fi if [ -f "$__object/parameter/arch" ]; then forcedarch="[arch=$(cat "$__object/parameter/arch")]" else @@ -50,3 +52,5 @@ __file "/etc/apt/sources.list.d/${name}.list" \ --source "$__object/files/source.list" \ --owner root --group root --mode 0644 \ --state "$state" + +require="$__object_name" __apt_update_index diff --git a/cdist/conf/type/__apt_source/nonparallel b/cdist/conf/type/__apt_source/nonparallel deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/conf/type/__apt_source/parameter/default/component b/cdist/conf/type/__apt_source/parameter/default/component deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/conf/type/__apt_update_index/gencode-remote b/cdist/conf/type/__apt_update_index/gencode-remote index 70b59710..61ce11a9 100755 --- a/cdist/conf/type/__apt_update_index/gencode-remote +++ b/cdist/conf/type/__apt_update_index/gencode-remote @@ -1,4 +1,4 @@ -#!/bin/sh -e +#!/bin/sh # # 2011 Steven Armstrong (steven-cdist at armstrong.cc) # diff --git a/cdist/conf/type/__apt_update_index/man.rst b/cdist/conf/type/__apt_update_index/man.rst deleted file mode 100644 index 3031902f..00000000 --- a/cdist/conf/type/__apt_update_index/man.rst +++ /dev/null @@ -1,41 +0,0 @@ -cdist-type__apt_update_index(7) -=============================== - -NAME ----- -cdist-type__apt_update_index - Update apt's package index - - -DESCRIPTION ------------ -This cdist type runs apt-get update whenever any apt sources have changed. - - -REQUIRED PARAMETERS -------------------- -None. - -OPTIONAL PARAMETERS -------------------- -None. - - -EXAMPLES --------- - -.. code-block:: sh - - __apt_update_index - - -AUTHORS -------- -Steven Armstrong - - -COPYING -------- -Copyright \(C) 2011 Steven Armstrong. 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. diff --git a/cdist/conf/type/__apt_update_index/man.text b/cdist/conf/type/__apt_update_index/man.text new file mode 100644 index 00000000..778af508 --- /dev/null +++ b/cdist/conf/type/__apt_update_index/man.text @@ -0,0 +1,41 @@ +cdist-type__apt_update_index(7) +=============================== +Steven Armstrong + + +NAME +---- +cdist-type__apt_update_index - update apt's package index + + +DESCRIPTION +----------- +This cdist type runs apt-get update whenever any apt sources have changed. + + +REQUIRED PARAMETERS +------------------- +None. + +OPTIONAL PARAMETERS +------------------- +None. + + +EXAMPLES +-------- + +-------------------------------------------------------------------------------- +__apt_update_index +-------------------------------------------------------------------------------- + + +SEE ALSO +-------- +- cdist-type(7) + + +COPYING +------- +Copyright \(C) 2011 Steven Armstrong. Free use of this software is +granted under the terms of the GNU General Public License version 3 (GPLv3). diff --git a/cdist/conf/type/__block/explorer/block b/cdist/conf/type/__block/explorer/block index e1ca3441..6c35bc46 100755 --- a/cdist/conf/type/__block/explorer/block +++ b/cdist/conf/type/__block/explorer/block @@ -1,24 +1,5 @@ #!/bin/sh -# -# 2013 Steven Armstrong (steven-cdist armstrong.cc) -# 2014 Nico Schottelius (nico-cdist at schottelius.org) -# -# This file is part of cdist. -# -# cdist is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# cdist is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with cdist. If not, see . -# - +# 2013 Steven Armstrong (steven-cdist at armstrong.cc) file="$(cat "$__object/parameter/file" 2>/dev/null || echo "/$__object_id")" @@ -27,12 +8,12 @@ file="$(cat "$__object/parameter/file" 2>/dev/null || echo "/$__object_id")" prefix=$(cat "$__object/parameter/prefix" 2>/dev/null || echo "#cdist:__block/$__object_id") suffix=$(cat "$__object/parameter/suffix" 2>/dev/null || echo "#/cdist:__block/$__object_id") -awk -v prefix="^$prefix\$" -v suffix="^$suffix\$" '{ - if (match($0,prefix)) { +awk -v prefix="$prefix" -v suffix="$suffix" '{ + if (index($0,prefix)) { triggered=1 } if (triggered) { - if (match($0,suffix)) { + if (index($0,suffix)) { triggered=0 } print diff --git a/cdist/conf/type/__block/gencode-remote b/cdist/conf/type/__block/gencode-remote index 1f5cc033..0a5eea18 100755 --- a/cdist/conf/type/__block/gencode-remote +++ b/cdist/conf/type/__block/gencode-remote @@ -1,4 +1,4 @@ -#!/bin/sh -e +#!/bin/sh # # 2013 Steven Armstrong (steven-cdist at armstrong.cc) # @@ -18,11 +18,6 @@ # along with cdist. If not, see . # -# quote function from http://www.etalabs.net/sh_tricks.html -quote() { - printf '%s\n' "$1" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/'/" -} - file="$(cat "$__object/parameter/file" 2>/dev/null || echo "/$__object_id")" state_should=$(cat "$__object/parameter/state") prefix=$(cat "$__object/parameter/prefix" 2>/dev/null || echo "#cdist:__block/$__object_id") @@ -51,13 +46,13 @@ tmpfile=\$(mktemp ${file}.cdist.XXXXXXXXXX) if [ -f "$file" ]; then cp -p "$file" "\$tmpfile" fi -awk -v prefix=^$(quote "$prefix")\$ -v suffix=^$(quote "$suffix")\$ ' +awk -v prefix="$prefix" -v suffix="$suffix" ' { - if (match(\$0,prefix)) { + if (index(\$0,prefix)) { triggered=1 } if (triggered) { - if (match(\$0,suffix)) { + if (index(\$0,suffix)) { triggered=0 } } else { diff --git a/cdist/conf/type/__block/man.rst b/cdist/conf/type/__block/man.text similarity index 57% rename from cdist/conf/type/__block/man.rst rename to cdist/conf/type/__block/man.text index 90e50381..2312d293 100644 --- a/cdist/conf/type/__block/man.rst +++ b/cdist/conf/type/__block/man.text @@ -1,5 +1,7 @@ cdist-type__block(7) ==================== +Steven Armstrong + NAME ---- @@ -16,67 +18,65 @@ of text. REQUIRED PARAMETERS ------------------- -text +text:: the text to manage. If text is '-' (dash), take what was written to stdin as the text. OPTIONAL PARAMETERS ------------------- -file +file:: the file in which to manage the text block. Defaults to object_id. -prefix +prefix:: the prefix to add before the text. Defaults to #cdist:__block/$__object_id -suffix - the suffix to add after the text. +suffix:: + the prefix to add after the text. Defaults to #/cdist:__block/$__object_id -state +state:: 'present' or 'absent', defaults to 'present' MESSAGES -------- -add +add:: block was added -update +update:: block was updated/changed -remove +remove:: block was removed EXAMPLES -------- -.. code-block:: sh +-------------------------------------------------------------------------------- +# text from argument +__block /path/to/file \ + --prefix '#start' \ + --suffix '#end' \ + --text 'some\nblock of\ntext' - # text from argument - __block /path/to/file \ - --prefix '#start' \ - --suffix '#end' \ - --text 'some\nblock of\ntext' - - # text from stdin - __block some-id \ - --file /path/to/file \ - --text - << DONE - here some block - of text - DONE +# text from stdin +__block some-id \ + --file /path/to/file \ + --text - << DONE +here some block +of text +DONE +-------------------------------------------------------------------------------- -AUTHORS -------- -Steven Armstrong +SEE ALSO +-------- +- cdist-type(7) COPYING ------- -Copyright \(C) 2013 Steven Armstrong. 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. +Copyright \(C) 2013 Steven Armstrong. Free use of this software is +granted under the terms of the GNU General Public License version 3 (GPLv3). diff --git a/cdist/conf/type/__block/manifest b/cdist/conf/type/__block/manifest index 726950d3..1fc9ec79 100755 --- a/cdist/conf/type/__block/manifest +++ b/cdist/conf/type/__block/manifest @@ -1,4 +1,4 @@ -#!/bin/sh -e +#!/bin/sh # # 2013-2014 Steven Armstrong (steven-cdist at armstrong.cc) # @@ -18,6 +18,8 @@ # along with cdist. If not, see . # + +file="$(cat "$__object/parameter/file" 2>/dev/null || echo "/$__object_id")" prefix=$(cat "$__object/parameter/prefix" 2>/dev/null || echo "#cdist:__block/$__object_id") suffix=$(cat "$__object/parameter/suffix" 2>/dev/null || echo "#/cdist:__block/$__object_id") text=$(cat "$__object/parameter/text") @@ -29,6 +31,6 @@ echo "$prefix" > "$block" if [ "$text" = "-" ]; then cat "$__object/stdin" >> "$block" else - echo "$text" >> "$block" + cat "$text" >> "$block" fi echo "$suffix" >> "$block" diff --git a/cdist/conf/type/__ccollect_source/explorer/stat b/cdist/conf/type/__ccollect_source/explorer/stat index 9b5ad75b..298221b7 100755 --- a/cdist/conf/type/__ccollect_source/explorer/stat +++ b/cdist/conf/type/__ccollect_source/explorer/stat @@ -25,7 +25,7 @@ destination="/$__object_id" os=$("$__explorer/os") case "$os" in - "freebsd"|"netbsd"|"openbsd") + "freebsd") # FIXME: should be something like this based on man page, but can not test stat -f "type: %ST owner: %Du %Su @@ -35,15 +35,6 @@ size: %Dz links: %Dl " "$destination" ;; - "macosx") - stat -f "type: %HT - owner: %Du %Su - group: %Dg %Sg - mode: %Lp %Sp - size: %Dz - links: %Dl - " "$destination" - ;; *) stat --printf="type: %F owner: %u %U diff --git a/cdist/conf/type/__ccollect_source/gencode-remote b/cdist/conf/type/__ccollect_source/gencode-remote index 57353c24..c41b5179 100755 --- a/cdist/conf/type/__ccollect_source/gencode-remote +++ b/cdist/conf/type/__ccollect_source/gencode-remote @@ -1,4 +1,4 @@ -#!/bin/sh -e +#!/bin/sh # # 2014 Nico Schottelius (nico-cdist at schottelius.org) # @@ -42,20 +42,21 @@ get_current_value() { } set_group() { - echo "chgrp '$1' '$destination'" - echo "chgrp '$1'" >> "$__messages_out" + echo chgrp \"$1\" \"$destination\" + echo chgrp $1 >> "$__messages_out" } set_owner() { - echo "chown '$1' '$destination'" - echo "chown '$1'" >> "$__messages_out" + echo chown \"$1\" \"$destination\" + echo chown $1 >> "$__messages_out" } set_mode() { - echo "chmod '$1' '$destination'" - echo "chmod '$1'" >> "$__messages_out" + echo chmod \"$1\" \"$destination\" + echo chmod $1 >> "$__messages_out" } +set_attributes= case "$state_should" in present|exists) # Note: Mode - needs to happen last as a chown/chgrp can alter mode by @@ -66,11 +67,11 @@ case "$state_should" in # change 0xxx format to xxx format => same as stat returns if [ "$attribute" = mode ]; then - value_should="$(echo "$value_should" | sed 's/^0\(...\)/\1/')" + value_should="$(echo $value_should | sed 's/^0\(...\)/\1/')" fi value_is="$(get_current_value "$attribute" "$value_should")" - if [ -f "$__object/files/set-attributes" ] || [ "$value_should" != "$value_is" ]; then + if [ -f "$__object/files/set-attributes" -o "$value_should" != "$value_is" ]; then "set_$attribute" "$value_should" fi fi @@ -80,7 +81,7 @@ case "$state_should" in absent) if [ "$type" = "file" ]; then - echo "rm -f '$destination'" + echo rm -f \"$destination\" echo remove >> "$__messages_out" fi ;; diff --git a/cdist/conf/type/__ccollect_source/man.rst b/cdist/conf/type/__ccollect_source/man.rst deleted file mode 100644 index b0c23482..00000000 --- a/cdist/conf/type/__ccollect_source/man.rst +++ /dev/null @@ -1,78 +0,0 @@ -cdist-type__ccollect_source(7) -============================== - -NAME ----- -cdist-type__ccollect_source - Manage ccollect sources - - -DESCRIPTION ------------ -This cdist type allows you to create or delete ccollect sources. - - -REQUIRED PARAMETERS -------------------- -source - The source from which to backup -destination - The destination directory - - -OPTIONAL PARAMETERS -------------------- -state - 'present' or 'absent', defaults to 'present' -ccollectconf - The CCOLLECT_CONF directory. Defaults to /etc/ccollect. - - -OPTIONAL MULTIPLE PARAMETERS ----------------------------- -exclude - Paths to exclude of backup - - -BOOLEAN PARAMETERS ------------------- -verbose - Whether to report backup verbosely - -create-destination - Create the directory specified in the destination parameter on the remote host - -EXAMPLES --------- - -.. code-block:: sh - - __ccollect_source doc.ungleich.ch \ - --source doc.ungleich.ch:/ \ - --destination /backup/doc.ungleich.ch \ - --exclude '/proc/*' --exclude '/sys/*' \ - --verbose - - __ccollect_source doc.ungleich.ch \ - --source doc.ungleich.ch:/ \ - --destination /backup/doc.ungleich.ch \ - --exclude '/proc/*' --exclude '/sys/*' \ - --verbose \ - --create-destination - - -SEE ALSO --------- -:strong:`ccollect`\ (1) - - -AUTHORS -------- -Nico Schottelius - - -COPYING -------- -Copyright \(C) 2014 Nico Schottelius. 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. diff --git a/cdist/conf/type/__ccollect_source/man.text b/cdist/conf/type/__ccollect_source/man.text new file mode 100644 index 00000000..32a7467e --- /dev/null +++ b/cdist/conf/type/__ccollect_source/man.text @@ -0,0 +1,64 @@ +cdist-type__ccollect_source(7) +============================== +Nico Schottelius + + +NAME +---- +cdist-type__ccollect_source - Manage ccollect sources + + +DESCRIPTION +----------- +This cdist type allows you to create or delete ccollect sources. + +REQUIRED PARAMETERS +------------------- +source:: + The source from which to backup +destination:: + The destination directory + + +OPTIONAL PARAMETERS +------------------- +state:: + 'present' or 'absent', defaults to 'present' +ccollectconf:: + The CCOLLECT_CONF directory. Defaults to /etc/ccollect. + + +OPTIONAL MULTIPLE PARAMETERS +---------------------------- +exclude:: + Paths to exclude of backup + +BOOLEAN PARAMETERS +------------------ +verbose:: + Whether to report backup verbosely + +EXAMPLES +-------- + +-------------------------------------------------------------------------------- +__ccollect_source doc.ungleich.ch \ + --source doc.ungleich.ch:/ \ + --destination /backup/doc.ungleich.ch \ + --exclude '/proc/*' --exclude '/sys/*' \ + --verbose + +-------------------------------------------------------------------------------- + + +SEE ALSO +-------- +- cdist-type(7) +- ccollect(1) +- http://www.nico.schottelius.org/software/ccollect/ + + +COPYING +------- +Copyright \(C) 2014 Nico Schottelius. Free use of this software is +granted under the terms of the GNU General Public License version 3 (GPLv3). diff --git a/cdist/conf/type/__ccollect_source/manifest b/cdist/conf/type/__ccollect_source/manifest index 727a4c97..89c2ef2b 100755 --- a/cdist/conf/type/__ccollect_source/manifest +++ b/cdist/conf/type/__ccollect_source/manifest @@ -1,4 +1,4 @@ -#!/bin/sh -e +#!/bin/sh # # 2014 Nico Schottelius (nico-cdist at schottelius.org) # @@ -22,7 +22,7 @@ name="$__object_id" state="$(cat "$__object/parameter/state")" source="$(cat "$__object/parameter/source")" destination="$(cat "$__object/parameter/destination")" -ccollectconf="$(sed 's,/$,,' "$__object/parameter/ccollectconf")" +ccollectconf="$(cat "$__object/parameter/ccollectconf" | sed 's,/$,,')" sourcedir="$ccollectconf/sources" basedir="$sourcedir/$name" @@ -40,9 +40,7 @@ echo "$source" | __file "$source_file" --source - --state "$state" ################################################################################ # Booleans -if [ "${state}" = "absent" ]; then - verbosestate="absent" -elif [ -f "$__object/parameter/verbose" ]; then +if [ -f "$__object/parameter/verbose" ]; then verbosestate="present" else verbosestate="absent" @@ -53,7 +51,3 @@ if [ -f "$__object/parameter/exclude" ]; then __file "$exclude_file" --source - --state "$state" \ < "$__object/parameter/exclude" fi - -if [ -f "$__object/parameter/create-destination" ]; then - __directory "${destination}" --parents --state "${state}" -fi diff --git a/cdist/conf/type/__ccollect_source/parameter/boolean b/cdist/conf/type/__ccollect_source/parameter/boolean index 434c644f..c00ee94a 100644 --- a/cdist/conf/type/__ccollect_source/parameter/boolean +++ b/cdist/conf/type/__ccollect_source/parameter/boolean @@ -1,2 +1 @@ verbose -create-destination diff --git a/cdist/conf/type/__cdist/man.rst b/cdist/conf/type/__cdist/man.text similarity index 55% rename from cdist/conf/type/__cdist/man.rst rename to cdist/conf/type/__cdist/man.text index be082781..0805598e 100644 --- a/cdist/conf/type/__cdist/man.rst +++ b/cdist/conf/type/__cdist/man.text @@ -1,5 +1,7 @@ cdist-type__cdist(7) ==================== +Nico Schottelius + NAME ---- @@ -24,16 +26,16 @@ REQUIRED PARAMETERS OPTIONAL PARAMETERS ------------------- -username +username:: Select the user to create for the cdist installation. Defaults to "cdist". -source +source:: Select the source from which to clone cdist from. - Defaults to "git@code.ungleich.ch:ungleich-public/cdist.git". + Defaults to "git://github.com/telmich/cdist.git". -branch +branch:: Select the branch to checkout from. Defaults to "master". @@ -41,23 +43,21 @@ branch EXAMPLES -------- -.. code-block:: sh +-------------------------------------------------------------------------------- +# Install cdist for user cdist in her home as subfolder cdist +__cdist /home/cdist/cdist - # Install cdist for user cdist in her home as subfolder cdist - __cdist /home/cdist/cdist - - # Use alternative source - __cdist --source "git@code.ungleich.ch:ungleich-public/cdist.git" /home/cdist/cdist +# Use alternative source +__cdist --source "git://git.schottelius.org/cdist" /home/cdist/cdist +-------------------------------------------------------------------------------- -AUTHORS -------- -Nico Schottelius +SEE ALSO +-------- +- cdist-type(7) COPYING ------- -Copyright \(C) 2013 Nico Schottelius. 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. +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/cdist/conf/type/__cdist/manifest b/cdist/conf/type/__cdist/manifest index a97cf288..7c0ae60e 100755 --- a/cdist/conf/type/__cdist/manifest +++ b/cdist/conf/type/__cdist/manifest @@ -1,4 +1,4 @@ -#!/bin/sh -e +#!/bin/sh # # 2013 Nico Schottelius (nico-cdist at schottelius.org) # diff --git a/cdist/conf/type/__cdist/parameter/default/source b/cdist/conf/type/__cdist/parameter/default/source index 1ad3a250..d669308f 100644 --- a/cdist/conf/type/__cdist/parameter/default/source +++ b/cdist/conf/type/__cdist/parameter/default/source @@ -1 +1 @@ -git@code.ungleich.ch:ungleich-public/cdist.git +git://github.com/telmich/cdist.git diff --git a/cdist/conf/type/__cdistmarker/gencode-remote b/cdist/conf/type/__cdistmarker/gencode-remote index e71955c4..e332df38 100755 --- a/cdist/conf/type/__cdistmarker/gencode-remote +++ b/cdist/conf/type/__cdistmarker/gencode-remote @@ -1,8 +1,8 @@ -#!/bin/sh -e +#!/bin/sh # # Copyright (C) 2011 Daniel Maher (phrawzty+cdist at gmail.com) # -# This file is part of cdist. +# This file is part of cdist (https://github.com/telmich/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 @@ -19,11 +19,19 @@ # # The marker file is established in the docs, but it isn't obligatory. -destination="$(cat "$__object/parameter/destination")" +if [ -f "$__object/parameter/destination" ]; then + destination="$(cat "$__object/parameter/destination")" +else + destination='/etc/cdist-configured' +fi # The basic output of date is usually good enough, but variety is the # spice of life... -format="$(cat "$__object/parameter/format")" +if [ -f "$__object/parameter/format" ]; then + format="$(cat "$__object/parameter/format")" +else + format='-u' +fi # Dump the timestamp in UTC to the marker echo "date $format > $destination" diff --git a/cdist/conf/type/__cdistmarker/man.rst b/cdist/conf/type/__cdistmarker/man.text similarity index 60% rename from cdist/conf/type/__cdistmarker/man.rst rename to cdist/conf/type/__cdistmarker/man.text index f3a8bafe..ca5611a7 100644 --- a/cdist/conf/type/__cdistmarker/man.rst +++ b/cdist/conf/type/__cdistmarker/man.text @@ -1,5 +1,7 @@ cdist-type__cdistmarker(7) ========================== +Daniel Maher + NAME ---- @@ -21,11 +23,11 @@ None. OPTIONAL PARAMETERS ------------------- -destination +destination:: The path and filename of the marker. Default: /etc/cdist-configured -format +format:: The format of the timestamp. This is passed directly to system 'date'. Default: -u @@ -33,23 +35,21 @@ format EXAMPLES -------- -.. code-block:: sh +-------------------------------------------------------------------------------- +# Creates the marker as normal. +__cdistmarker - # Creates the marker as normal. - __cdistmarker - - # Creates the marker differently. - __cdistmarker --destination /tmp/cdist_marker --format '+%s' +# Creates the marker differently. +__cdistmarker --file /tmp/cdist_marker --format '+%s' +-------------------------------------------------------------------------------- -AUTHORS -------- -Daniel Maher +SEE ALSO +-------- +- cdist-type(7) COPYING ------- -Copyright \(C) 2011 Daniel Maher. 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. +Copyright \(C) 2011 Daniel Maher. 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/__cdistmarker/parameter/default/destination b/cdist/conf/type/__cdistmarker/parameter/default/destination deleted file mode 100644 index bd3a112f..00000000 --- a/cdist/conf/type/__cdistmarker/parameter/default/destination +++ /dev/null @@ -1 +0,0 @@ -/etc/cdist-configured diff --git a/cdist/conf/type/__cdistmarker/parameter/default/format b/cdist/conf/type/__cdistmarker/parameter/default/format deleted file mode 100644 index 5dc9e6ec..00000000 --- a/cdist/conf/type/__cdistmarker/parameter/default/format +++ /dev/null @@ -1 +0,0 @@ --u diff --git a/cdist/conf/type/__check_messages/gencode-remote b/cdist/conf/type/__check_messages/gencode-remote deleted file mode 100755 index ec36cecc..00000000 --- a/cdist/conf/type/__check_messages/gencode-remote +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/sh -e -# -# 2019 Ander Punnar (ander-at-kvlt-dot-ee) -# -# This file is part of cdist. -# -# cdist is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# cdist is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with cdist. If not, see . -# - -if grep -Eq \ - "$( cat "$__object/parameter/pattern" )" \ - "$__messages_in" -then - tee "$__messages_out" < "$__object/parameter/execute" -fi diff --git a/cdist/conf/type/__check_messages/man.rst b/cdist/conf/type/__check_messages/man.rst deleted file mode 100644 index 5c80a0ae..00000000 --- a/cdist/conf/type/__check_messages/man.rst +++ /dev/null @@ -1,52 +0,0 @@ -cdist-type__check_messages(7) -============================= - -NAME ----- -cdist-type__check_messages - Check messages for pattern and execute command on match. - - -DESCRIPTION ------------ -Check messages for pattern and execute command on match. - -This type is useful if you chain together multiple related types using -dependencies and want to restart service if at least one type changes -something. - -For more information about messages see `cdist messaging `_. - -For more information about dependencies and execution order see -`cdist manifest `_ documentation. - - -REQUIRED PARAMETERS -------------------- -pattern - Extended regular expression pattern for search (passed to ``grep -E``). - -execute - Command to execute on pattern match. - - -EXAMPLES --------- - -.. code-block:: sh - - __check_messages munin \ - --pattern '^__(file|link|line)/etc/munin/' \ - --execute 'service munin-node restart' - - -AUTHORS -------- -Ander Punnar - - -COPYING -------- -Copyright \(C) 2019 Ander Punnar. 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. diff --git a/cdist/conf/type/__check_messages/parameter/required b/cdist/conf/type/__check_messages/parameter/required deleted file mode 100644 index 374363cb..00000000 --- a/cdist/conf/type/__check_messages/parameter/required +++ /dev/null @@ -1,2 +0,0 @@ -pattern -execute diff --git a/cdist/conf/type/__chroot_mount/gencode-local b/cdist/conf/type/__chroot_mount/gencode-local deleted file mode 100755 index b131346c..00000000 --- a/cdist/conf/type/__chroot_mount/gencode-local +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/sh -e -# -# 2016 Steven Armstrong (steven-cdist at armstrong.cc) -# -# This file is part of cdist. -# -# cdist is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# cdist is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with cdist. If not, see . -# - -chroot="/$__object_id" - -if [ -f "$__object/parameter/manage-resolv-conf" ]; then - suffix="$(cat "$__object/parameter/manage-resolv-conf")" - resolv_conf="${chroot}/etc/resolv.conf" - original_resolv_conf="${resolv_conf}.${suffix}" - cat << DONE -$__remote_exec $__target_host << EOSSH -if [ -f "${resolv_conf}" ]; then - mv "${resolv_conf}" "${original_resolv_conf}" -fi -# copy hosts resolv.conf into chroot -cp /etc/resolv.conf "${resolv_conf}" -EOSSH -DONE -fi diff --git a/cdist/conf/type/__chroot_mount/gencode-remote b/cdist/conf/type/__chroot_mount/gencode-remote deleted file mode 100755 index 4fbb3ffc..00000000 --- a/cdist/conf/type/__chroot_mount/gencode-remote +++ /dev/null @@ -1,44 +0,0 @@ -#!/bin/sh -e -# -# 2012 Steven Armstrong (steven-cdist at armstrong.cc) -# -# This file is part of cdist. -# -# cdist is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# cdist is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with cdist. If not, see . -# - -chroot="/$__object_id" - -cat << DONE -# Prepare chroot -[ -d "${chroot}/proc" ] || mkdir "${chroot}/proc" -mountpoint -q "${chroot}/proc" \ - || mount -t proc -o nosuid,noexec,nodev proc "${chroot}/proc" - -[ -d "${chroot}/sys" ] || mkdir "${chroot}/sys" -mountpoint -q "${chroot}/sys" \ - || mount -t sysfs -o nosuid,noexec,nodev sys "${chroot}/sys" - -[ -d "${chroot}/dev" ] || mkdir "${chroot}/dev" -mountpoint -q "${chroot}/dev" \ - || mount -t devtmpfs -o mode=0755,nosuid udev "${chroot}/dev" - -[ -d "${chroot}/dev/pts" ] || mkdir "${chroot}/dev/pts" -mountpoint -q "${chroot}/dev/pts" \ - || mount -t devpts -o mode=0620,gid=5,nosuid,noexec devpts "${chroot}/dev/pts" - -[ -d "${chroot}/tmp" ] || mkdir -m 1777 "${chroot}/tmp" -mountpoint -q "${chroot}/tmp" \ - || mount -t tmpfs -o mode=1777,strictatime,nodev,nosuid tmpfs "${chroot}/tmp" -DONE diff --git a/cdist/conf/type/__chroot_mount/man.rst b/cdist/conf/type/__chroot_mount/man.rst deleted file mode 100644 index 41fd496b..00000000 --- a/cdist/conf/type/__chroot_mount/man.rst +++ /dev/null @@ -1,55 +0,0 @@ -cdist-type__chroot_mount(7) -=========================== - -NAME ----- -cdist-type__chroot_mount - mount a chroot - - -DESCRIPTION ------------ -Mount and prepare a chroot for running commands within it. - - -REQUIRED PARAMETERS -------------------- -None - - -OPTIONAL PARAMETERS -------------------- -manage-resolv-conf - manage /etc/resolv.conf inside the chroot. - Use the value of this parameter as the suffix to save a copy - of the current /etc/resolv.conf to /etc/resolv.conf.$suffix. - This is used by the __chroot_umount type to restore the initial - file content when unmounting the chroot. - - -BOOLEAN PARAMETERS ------------------- -None. - - -EXAMPLES --------- - -.. code-block:: sh - - __chroot_mount /path/to/chroot - - __chroot_mount /path/to/chroot \ - --manage-resolv-conf "some-known-string" - - -AUTHORS -------- -Steven Armstrong - - -COPYING -------- -Copyright \(C) 2012-2017 Steven Armstrong. 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. diff --git a/cdist/conf/type/__chroot_mount/parameter/optional b/cdist/conf/type/__chroot_mount/parameter/optional deleted file mode 100644 index 27928f2c..00000000 --- a/cdist/conf/type/__chroot_mount/parameter/optional +++ /dev/null @@ -1 +0,0 @@ -manage-resolv-conf diff --git a/cdist/conf/type/__chroot_umount/gencode-local b/cdist/conf/type/__chroot_umount/gencode-local deleted file mode 100755 index b3cb69c6..00000000 --- a/cdist/conf/type/__chroot_umount/gencode-local +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/sh -e -# -# 2016 Steven Armstrong (steven-cdist at armstrong.cc) -# -# This file is part of cdist. -# -# cdist is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# cdist is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with cdist. If not, see . -# - -chroot="/$__object_id" - -if [ -f "$__object/parameter/manage-resolv-conf" ]; then - suffix="$(cat "$__object/parameter/manage-resolv-conf")" - resolv_conf="${chroot}/etc/resolv.conf" - original_resolv_conf="${resolv_conf}.${suffix}" -cat << DONE -$__remote_exec $__target_host << EOSSH -if [ -f "${original_resolv_conf}" ]; then - # restore original /etc/resolv.conf that we moved out of the way - # in __chroot_mount/gencode-local - mv -f "${original_resolv_conf}" "${resolv_conf}" -fi -EOSSH -DONE -fi diff --git a/cdist/conf/type/__chroot_umount/gencode-remote b/cdist/conf/type/__chroot_umount/gencode-remote deleted file mode 100755 index ff669e1b..00000000 --- a/cdist/conf/type/__chroot_umount/gencode-remote +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/sh -e -# -# 2012 Steven Armstrong (steven-cdist at armstrong.cc) -# -# This file is part of cdist. -# -# cdist is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# cdist is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with cdist. If not, see . -# - -chroot="/$__object_id" - -cat << DONE -umount -l "${chroot}/tmp" -umount -l "${chroot}/dev/pts" -umount -l "${chroot}/dev" -umount -l "${chroot}/sys" -umount -l "${chroot}/proc" -if [ -d "${chroot}/etc/resolvconf/resolv.conf.d" ]; then - # ensure /etc/resolvconf/resolv.conf.d/tail is not linked to \ - # e.g. /etc/resolvconf/resolv.conf.d/original - rm -f "${chroot}/etc/resolvconf/resolv.conf.d/tail" - touch "${chroot}/etc/resolvconf/resolv.conf.d/tail" -fi -DONE diff --git a/cdist/conf/type/__chroot_umount/man.rst b/cdist/conf/type/__chroot_umount/man.rst deleted file mode 100644 index 2a15f362..00000000 --- a/cdist/conf/type/__chroot_umount/man.rst +++ /dev/null @@ -1,60 +0,0 @@ -cdist-type__chroot_umount(7) -============================ - -NAME ----- -cdist-type__chroot_umount - unmount a chroot mounted by __chroot_mount - - -DESCRIPTION ------------ -Undo what __chroot_mount did. - - -REQUIRED PARAMETERS -------------------- -None - - -OPTIONAL PARAMETERS -------------------- -manage-resolv-conf - manage /etc/resolv.conf inside the chroot. - Use the value of this parameter as the suffix to find the backup file - that was saved by the __chroot_mount. - This is used by the to restore the initial file content when unmounting - the chroot. - - -BOOLEAN PARAMETERS ------------------- -None. - - -EXAMPLES --------- - -.. code-block:: sh - - __chroot_umount /path/to/chroot - - __chroot_umount /path/to/chroot \ - --manage-resolv-conf "some-known-string" - - -SEE ALSO --------- -:strong:`cdist-type__chroot_mount`\ (7) - - -AUTHORS -------- -Steven Armstrong - - -COPYING -------- -Copyright \(C) 2012-2017 Steven Armstrong. 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. diff --git a/cdist/conf/type/__chroot_umount/manifest b/cdist/conf/type/__chroot_umount/manifest deleted file mode 100755 index b3cb69c6..00000000 --- a/cdist/conf/type/__chroot_umount/manifest +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/sh -e -# -# 2016 Steven Armstrong (steven-cdist at armstrong.cc) -# -# This file is part of cdist. -# -# cdist is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# cdist is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with cdist. If not, see . -# - -chroot="/$__object_id" - -if [ -f "$__object/parameter/manage-resolv-conf" ]; then - suffix="$(cat "$__object/parameter/manage-resolv-conf")" - resolv_conf="${chroot}/etc/resolv.conf" - original_resolv_conf="${resolv_conf}.${suffix}" -cat << DONE -$__remote_exec $__target_host << EOSSH -if [ -f "${original_resolv_conf}" ]; then - # restore original /etc/resolv.conf that we moved out of the way - # in __chroot_mount/gencode-local - mv -f "${original_resolv_conf}" "${resolv_conf}" -fi -EOSSH -DONE -fi diff --git a/cdist/conf/type/__chroot_umount/parameter/optional b/cdist/conf/type/__chroot_umount/parameter/optional deleted file mode 100644 index 27928f2c..00000000 --- a/cdist/conf/type/__chroot_umount/parameter/optional +++ /dev/null @@ -1 +0,0 @@ -manage-resolv-conf diff --git a/cdist/conf/type/__clean_path/explorer/list b/cdist/conf/type/__clean_path/explorer/list deleted file mode 100755 index 07d38127..00000000 --- a/cdist/conf/type/__clean_path/explorer/list +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/sh -e -# -# 2019 Ander Punnar (ander-at-kvlt-dot-ee) -# -# 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 . -# - -path="/$__object_id" - -[ ! -d "$path" ] && exit 0 - -pattern="$( cat "$__object/parameter/pattern" )" - -if [ -f "$__object/parameter/exclude" ] -then - exclude="$( cat "$__object/parameter/exclude" )" - - find "$path" -mindepth 1 -maxdepth 1 -regex "$pattern" \ - -and -not -regex "$exclude" -else - find "$path" -mindepth 1 -maxdepth 1 -regex "$pattern" -fi diff --git a/cdist/conf/type/__clean_path/gencode-remote b/cdist/conf/type/__clean_path/gencode-remote deleted file mode 100755 index 998a70d8..00000000 --- a/cdist/conf/type/__clean_path/gencode-remote +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/sh -e -# -# 2019 Ander Punnar (ander-at-kvlt-dot-ee) -# -# 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 . -# - -[ ! -s "$__object/explorer/list" ] && exit 0 - -path="/$__object_id" - -pattern="$( cat "$__object/parameter/pattern" )" - -if [ -f "$__object/parameter/exclude" ] -then - exclude="$( cat "$__object/parameter/exclude" )" - - echo "find '$path' -mindepth 1 -maxdepth 1 -regex '$pattern'" \ - "-and -not -regex '$exclude'" \ - '-exec rm -rf {} \;' -else - echo "find '$path' -mindepth 1 -maxdepth 1 -regex '$pattern'" \ - '-exec rm -rf {} \;' -fi - -while read -r f -do - echo "removed '$f'" >> "$__messages_out" -done \ -< "$__object/explorer/list" - -if [ -f "$__object/parameter/onchange" ] -then - cat "$__object/parameter/onchange" -fi diff --git a/cdist/conf/type/__clean_path/man.rst b/cdist/conf/type/__clean_path/man.rst deleted file mode 100644 index 826f4589..00000000 --- a/cdist/conf/type/__clean_path/man.rst +++ /dev/null @@ -1,60 +0,0 @@ -cdist-type__clean_path(7) -========================= - -NAME ----- -cdist-type__clean_path - Remove files and directories which match the pattern. - - -DESCRIPTION ------------ -Remove files and directories which match the pattern. - -Provided path (as __object_id) must be a directory. - -Patterns are passed to ``find``'s ``-regex`` - see ``find(1)`` for more details. - -Look up of files and directories is non-recursive (``-maxdepth 1``). - -Parent directory is excluded (``-mindepth 1``). - -This type is not POSIX compatible (sorry, Solaris users). - - -REQUIRED PARAMETERS -------------------- -pattern - Pattern of files which are removed from path. - - -OPTIONAL PARAMETERS -------------------- -exclude - Pattern of files which are excluded from removal. - -onchange - The code to run if files or directories were removed. - - -EXAMPLES --------- - -.. code-block:: sh - - __clean_path /etc/apache2/conf-enabled \ - --pattern '.+' \ - --exclude '.+\(charset\.conf\|security\.conf\)' \ - --onchange 'service apache2 restart' - - -AUTHORS -------- -Ander Punnar - - -COPYING -------- -Copyright \(C) 2019 Ander Punnar. 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. diff --git a/cdist/conf/type/__clean_path/parameter/optional b/cdist/conf/type/__clean_path/parameter/optional deleted file mode 100644 index 6f313474..00000000 --- a/cdist/conf/type/__clean_path/parameter/optional +++ /dev/null @@ -1,2 +0,0 @@ -exclude -onchange diff --git a/cdist/conf/type/__clean_path/parameter/required b/cdist/conf/type/__clean_path/parameter/required deleted file mode 100644 index 54774947..00000000 --- a/cdist/conf/type/__clean_path/parameter/required +++ /dev/null @@ -1 +0,0 @@ -pattern diff --git a/cdist/conf/type/__config_file/gencode-remote b/cdist/conf/type/__config_file/gencode-remote deleted file mode 100755 index 5f1626be..00000000 --- a/cdist/conf/type/__config_file/gencode-remote +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/sh -e -# -# 2015 Steven Armstrong (steven-cdist at armstrong.cc) -# -# This file is part of cdist. -# -# cdist is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# cdist is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with cdist. If not, see . -# - -destination="$__object_id" - -if [ -f "$__object/parameter/onchange" ]; then - if grep -q "^__file/${destination}" "$__messages_in"; then - cat "$__object/parameter/onchange" - fi -fi diff --git a/cdist/conf/type/__config_file/man.rst b/cdist/conf/type/__config_file/man.rst deleted file mode 100644 index 5e0e58bd..00000000 --- a/cdist/conf/type/__config_file/man.rst +++ /dev/null @@ -1,64 +0,0 @@ -cdist-type__config_file(7) -========================== - -NAME ----- -cdist-type__config_file - _Manages config files - - -DESCRIPTION ------------ -Deploy config files using the file type. -Run the given code if the files changes. - - -REQUIRED PARAMETERS -------------------- -None. - - -OPTIONAL PARAMETERS -------------------- -group - see cdist-type__file -mode - see cdist-type__file -onchange - the code to run if the file changes -owner - see cdist-type__file -source - Path to the config file. - If source is '-' (dash), take what was written to stdin as the config file content. -state - see cdist-type__file - - -EXAMPLES --------- - -.. code-block:: sh - - __config_file /etc/consul/conf.d/watch_foo.json \ - --owner root --group consul --mode 640 \ - --source "$__type/files/watch_foo.json" \ - --state present \ - --onchange 'service consul status >/dev/null && service consul reload || true' - - -SEE ALSO --------- -:strong:`cdist-type__file`\ (7) - - -AUTHORS -------- -Steven Armstrong - - -COPYING -------- -Copyright \(C) 2015 Steven Armstrong. 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. diff --git a/cdist/conf/type/__config_file/manifest b/cdist/conf/type/__config_file/manifest deleted file mode 100755 index be8f9f67..00000000 --- a/cdist/conf/type/__config_file/manifest +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/sh -e -# -# 2015 Steven Armstrong (steven-cdist at armstrong.cc) -# -# This file is part of cdist. -# -# cdist is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# cdist is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with cdist. If not, see . -# - -set -- "/${__object_id}" -cd "$__object/parameter/" -for param in *; do - case "$param" in - source) - source="$(cat "$__object/parameter/source")" - if [ "$source" = "-" ]; then - source="$__object/stdin" - fi - set -- "$@" --source "$source" - ;; - owner|group|mode|state) - set -- "$@" "--${param}" "$(cat "$__object/parameter/$param")" - ;; - *) - # ignore unknown parameters - : - ;; - esac -done - -__file "$@" diff --git a/cdist/conf/type/__config_file/parameter/default/state b/cdist/conf/type/__config_file/parameter/default/state deleted file mode 100644 index e7f6134f..00000000 --- a/cdist/conf/type/__config_file/parameter/default/state +++ /dev/null @@ -1 +0,0 @@ -present diff --git a/cdist/conf/type/__config_file/parameter/optional b/cdist/conf/type/__config_file/parameter/optional deleted file mode 100644 index 085c7725..00000000 --- a/cdist/conf/type/__config_file/parameter/optional +++ /dev/null @@ -1,6 +0,0 @@ -group -mode -onchange -owner -source -state diff --git a/cdist/conf/type/__consul/files/versions/0.4.1/cksum b/cdist/conf/type/__consul/files/versions/0.4.1/cksum deleted file mode 100644 index edba1a68..00000000 --- a/cdist/conf/type/__consul/files/versions/0.4.1/cksum +++ /dev/null @@ -1 +0,0 @@ -428915666 15738724 consul diff --git a/cdist/conf/type/__consul/files/versions/0.4.1/source b/cdist/conf/type/__consul/files/versions/0.4.1/source deleted file mode 100644 index b1e9908d..00000000 --- a/cdist/conf/type/__consul/files/versions/0.4.1/source +++ /dev/null @@ -1 +0,0 @@ -https://dl.bintray.com/mitchellh/consul/0.4.1_linux_amd64.zip diff --git a/cdist/conf/type/__consul/files/versions/0.5.0/cksum b/cdist/conf/type/__consul/files/versions/0.5.0/cksum deleted file mode 100644 index fe9888ae..00000000 --- a/cdist/conf/type/__consul/files/versions/0.5.0/cksum +++ /dev/null @@ -1 +0,0 @@ -131560372 17734417 consul diff --git a/cdist/conf/type/__consul/files/versions/0.5.0/source b/cdist/conf/type/__consul/files/versions/0.5.0/source deleted file mode 100644 index 00a209a5..00000000 --- a/cdist/conf/type/__consul/files/versions/0.5.0/source +++ /dev/null @@ -1 +0,0 @@ -https://dl.bintray.com/mitchellh/consul/0.5.0_linux_amd64.zip diff --git a/cdist/conf/type/__consul/files/versions/0.5.1/cksum b/cdist/conf/type/__consul/files/versions/0.5.1/cksum deleted file mode 100644 index a176ed43..00000000 --- a/cdist/conf/type/__consul/files/versions/0.5.1/cksum +++ /dev/null @@ -1 +0,0 @@ -2564582176 18232733 consul diff --git a/cdist/conf/type/__consul/files/versions/0.5.1/source b/cdist/conf/type/__consul/files/versions/0.5.1/source deleted file mode 100644 index f02a1103..00000000 --- a/cdist/conf/type/__consul/files/versions/0.5.1/source +++ /dev/null @@ -1 +0,0 @@ -https://dl.bintray.com/mitchellh/consul/0.5.1_linux_amd64.zip diff --git a/cdist/conf/type/__consul/files/versions/0.5.2/cksum b/cdist/conf/type/__consul/files/versions/0.5.2/cksum deleted file mode 100644 index 1c077266..00000000 --- a/cdist/conf/type/__consul/files/versions/0.5.2/cksum +++ /dev/null @@ -1 +0,0 @@ -2207534901 18245010 consul diff --git a/cdist/conf/type/__consul/files/versions/0.5.2/source b/cdist/conf/type/__consul/files/versions/0.5.2/source deleted file mode 100644 index 43b43d55..00000000 --- a/cdist/conf/type/__consul/files/versions/0.5.2/source +++ /dev/null @@ -1 +0,0 @@ -https://releases.hashicorp.com/consul/0.5.2/consul_0.5.2_linux_amd64.zip diff --git a/cdist/conf/type/__consul/files/versions/0.6.0/cksum b/cdist/conf/type/__consul/files/versions/0.6.0/cksum deleted file mode 100644 index bf41a9b8..00000000 --- a/cdist/conf/type/__consul/files/versions/0.6.0/cksum +++ /dev/null @@ -1 +0,0 @@ -688442448 19798264 consul diff --git a/cdist/conf/type/__consul/files/versions/0.6.0/source b/cdist/conf/type/__consul/files/versions/0.6.0/source deleted file mode 100644 index 691f2a87..00000000 --- a/cdist/conf/type/__consul/files/versions/0.6.0/source +++ /dev/null @@ -1 +0,0 @@ -https://releases.hashicorp.com/consul/0.6.0/consul_0.6.0_linux_amd64.zip diff --git a/cdist/conf/type/__consul/files/versions/0.6.1/cksum b/cdist/conf/type/__consul/files/versions/0.6.1/cksum deleted file mode 100644 index aa354351..00000000 --- a/cdist/conf/type/__consul/files/versions/0.6.1/cksum +++ /dev/null @@ -1 +0,0 @@ -3100584780 20416856 consul diff --git a/cdist/conf/type/__consul/files/versions/0.6.1/source b/cdist/conf/type/__consul/files/versions/0.6.1/source deleted file mode 100644 index 3b20388f..00000000 --- a/cdist/conf/type/__consul/files/versions/0.6.1/source +++ /dev/null @@ -1 +0,0 @@ -https://releases.hashicorp.com/consul/0.6.1/consul_0.6.1_linux_amd64.zip diff --git a/cdist/conf/type/__consul/files/versions/0.6.2/cksum b/cdist/conf/type/__consul/files/versions/0.6.2/cksum deleted file mode 100644 index 9c0b35c5..00000000 --- a/cdist/conf/type/__consul/files/versions/0.6.2/cksum +++ /dev/null @@ -1 +0,0 @@ -2124180907 20416920 consul diff --git a/cdist/conf/type/__consul/files/versions/0.6.2/source b/cdist/conf/type/__consul/files/versions/0.6.2/source deleted file mode 100644 index b0c6eeed..00000000 --- a/cdist/conf/type/__consul/files/versions/0.6.2/source +++ /dev/null @@ -1 +0,0 @@ -https://releases.hashicorp.com/consul/0.6.2/consul_0.6.2_linux_amd64.zip diff --git a/cdist/conf/type/__consul/files/versions/0.6.3/cksum b/cdist/conf/type/__consul/files/versions/0.6.3/cksum deleted file mode 100644 index 886d01bb..00000000 --- a/cdist/conf/type/__consul/files/versions/0.6.3/cksum +++ /dev/null @@ -1 +0,0 @@ -1832669072 20417720 consul diff --git a/cdist/conf/type/__consul/files/versions/0.6.3/source b/cdist/conf/type/__consul/files/versions/0.6.3/source deleted file mode 100644 index fef668be..00000000 --- a/cdist/conf/type/__consul/files/versions/0.6.3/source +++ /dev/null @@ -1 +0,0 @@ -https://releases.hashicorp.com/consul/0.6.3/consul_0.6.3_linux_amd64.zip diff --git a/cdist/conf/type/__consul/files/versions/0.6.4/cksum b/cdist/conf/type/__consul/files/versions/0.6.4/cksum deleted file mode 100644 index 1124b7aa..00000000 --- a/cdist/conf/type/__consul/files/versions/0.6.4/cksum +++ /dev/null @@ -1 +0,0 @@ -3832641574 23002736 consul diff --git a/cdist/conf/type/__consul/files/versions/0.6.4/source b/cdist/conf/type/__consul/files/versions/0.6.4/source deleted file mode 100644 index 96879b8d..00000000 --- a/cdist/conf/type/__consul/files/versions/0.6.4/source +++ /dev/null @@ -1 +0,0 @@ -https://releases.hashicorp.com/consul/0.6.4/consul_0.6.4_linux_amd64.zip diff --git a/cdist/conf/type/__consul/files/versions/0.7.0/cksum b/cdist/conf/type/__consul/files/versions/0.7.0/cksum deleted file mode 100644 index 3bffeedb..00000000 --- a/cdist/conf/type/__consul/files/versions/0.7.0/cksum +++ /dev/null @@ -1 +0,0 @@ -695240564 24003648 consul diff --git a/cdist/conf/type/__consul/files/versions/0.7.0/source b/cdist/conf/type/__consul/files/versions/0.7.0/source deleted file mode 100644 index ad610fc7..00000000 --- a/cdist/conf/type/__consul/files/versions/0.7.0/source +++ /dev/null @@ -1 +0,0 @@ -https://releases.hashicorp.com/consul/0.7.0/consul_0.7.0_linux_amd64.zip diff --git a/cdist/conf/type/__consul/files/versions/0.7.1/cksum b/cdist/conf/type/__consul/files/versions/0.7.1/cksum deleted file mode 100644 index 476bd9f6..00000000 --- a/cdist/conf/type/__consul/files/versions/0.7.1/cksum +++ /dev/null @@ -1 +0,0 @@ -3128343188 28402769 consul diff --git a/cdist/conf/type/__consul/files/versions/0.7.1/source b/cdist/conf/type/__consul/files/versions/0.7.1/source deleted file mode 100644 index 6ba2e7bf..00000000 --- a/cdist/conf/type/__consul/files/versions/0.7.1/source +++ /dev/null @@ -1 +0,0 @@ -https://releases.hashicorp.com/consul/0.7.1/consul_0.7.1_linux_amd64.zip diff --git a/cdist/conf/type/__consul/files/versions/0.8.1/cksum b/cdist/conf/type/__consul/files/versions/0.8.1/cksum deleted file mode 100644 index 9125cc8f..00000000 --- a/cdist/conf/type/__consul/files/versions/0.8.1/cksum +++ /dev/null @@ -1 +0,0 @@ -283033689 36101209 consul diff --git a/cdist/conf/type/__consul/files/versions/0.8.1/source b/cdist/conf/type/__consul/files/versions/0.8.1/source deleted file mode 100644 index 92386c7c..00000000 --- a/cdist/conf/type/__consul/files/versions/0.8.1/source +++ /dev/null @@ -1 +0,0 @@ -https://releases.hashicorp.com/consul/0.8.1/consul_0.8.1_linux_amd64.zip diff --git a/cdist/conf/type/__consul/files/versions/1.0.6/cksum b/cdist/conf/type/__consul/files/versions/1.0.6/cksum deleted file mode 100644 index b70b55f4..00000000 --- a/cdist/conf/type/__consul/files/versions/1.0.6/cksum +++ /dev/null @@ -1 +0,0 @@ -4120550353 48801129 consul diff --git a/cdist/conf/type/__consul/files/versions/1.0.6/source b/cdist/conf/type/__consul/files/versions/1.0.6/source deleted file mode 100644 index 769d3134..00000000 --- a/cdist/conf/type/__consul/files/versions/1.0.6/source +++ /dev/null @@ -1 +0,0 @@ -https://releases.hashicorp.com/consul/1.0.6/consul_1.0.6_linux_amd64.zip diff --git a/cdist/conf/type/__consul/files/versions/1.2.3/cksum b/cdist/conf/type/__consul/files/versions/1.2.3/cksum deleted file mode 100644 index 6352409e..00000000 --- a/cdist/conf/type/__consul/files/versions/1.2.3/cksum +++ /dev/null @@ -1 +0,0 @@ -191982 110369685 diff --git a/cdist/conf/type/__consul/files/versions/1.2.3/source b/cdist/conf/type/__consul/files/versions/1.2.3/source deleted file mode 100644 index 5e67bc37..00000000 --- a/cdist/conf/type/__consul/files/versions/1.2.3/source +++ /dev/null @@ -1 +0,0 @@ -https://releases.hashicorp.com/consul/1.2.3/consul_1.2.3_linux_amd64.zip diff --git a/cdist/conf/type/__consul/files/versions/1.3.0/cksum b/cdist/conf/type/__consul/files/versions/1.3.0/cksum deleted file mode 100644 index 7a885378..00000000 --- a/cdist/conf/type/__consul/files/versions/1.3.0/cksum +++ /dev/null @@ -1 +0,0 @@ -1714523667 98363467 consul diff --git a/cdist/conf/type/__consul/files/versions/1.3.0/source b/cdist/conf/type/__consul/files/versions/1.3.0/source deleted file mode 100644 index 18a1ba8e..00000000 --- a/cdist/conf/type/__consul/files/versions/1.3.0/source +++ /dev/null @@ -1 +0,0 @@ -https://releases.hashicorp.com/consul/1.3.0/consul_1.3.0_linux_amd64.zip diff --git a/cdist/conf/type/__consul/files/versions/1.5.0/cksum b/cdist/conf/type/__consul/files/versions/1.5.0/cksum deleted file mode 100644 index efca9caa..00000000 --- a/cdist/conf/type/__consul/files/versions/1.5.0/cksum +++ /dev/null @@ -1 +0,0 @@ -886614099 103959898 consul diff --git a/cdist/conf/type/__consul/files/versions/1.5.0/source b/cdist/conf/type/__consul/files/versions/1.5.0/source deleted file mode 100644 index cafa9248..00000000 --- a/cdist/conf/type/__consul/files/versions/1.5.0/source +++ /dev/null @@ -1 +0,0 @@ -https://releases.hashicorp.com/consul/1.5.0/consul_1.5.0_linux_amd64.zip diff --git a/cdist/conf/type/__consul/gencode-remote b/cdist/conf/type/__consul/gencode-remote deleted file mode 100755 index 2a21054f..00000000 --- a/cdist/conf/type/__consul/gencode-remote +++ /dev/null @@ -1,63 +0,0 @@ -#!/bin/sh -e -# -# 2018 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 . -# - -#set -x - -if [ ! -f "$__object/parameter/direct" ]; then - # Nothing here, staged file is used. - exit 0 -fi - -state=$(cat "$__object/parameter/state") -destination="/usr/local/bin/consul" - -if [ "$state" = "absent" ]; then - printf 'rm -f "%s"' "$destination" - exit 0 -fi - -versions_dir="$__type/files/versions" -version="$(cat "$__object/parameter/version")" -version_dir="$versions_dir/$version" - -source=$(cat "$version_dir/source") -source_file_name="${source##*/}" -cksum_should=$(cut -d' ' -f1,2 "$version_dir/cksum") - -cat << eof - tmpdir=\$(mktemp -d -p /tmp "${__type##*/}.XXXXXXXXXX") - curl -s -L "$source" > "\$tmpdir/$source_file_name" - unzip -p "\$tmpdir/$source_file_name" > "${destination}.tmp" - rm -rf "\$tmpdir" - - cksum_is=\$(cksum "${destination}.tmp" | cut -d' ' -f1,2) - if [ "\$cksum_is" = "$cksum_should" ]; then - rm -f "${destination}" - mv "${destination}.tmp" "${destination}" - chown root:root "$destination" - chmod 755 "$destination" - else - rm -f "${destination}.tmp" - echo "Failed to verify checksum for $__object_name" >&2 - exit 1 - fi -eof - -echo "/usr/local/bin/consul created" >> "$__messages_out" diff --git a/cdist/conf/type/__consul/man.rst b/cdist/conf/type/__consul/man.rst deleted file mode 100644 index 5b2db50a..00000000 --- a/cdist/conf/type/__consul/man.rst +++ /dev/null @@ -1,75 +0,0 @@ -cdist-type__consul(7) -===================== - -NAME ----- -cdist-type__consul - Install consul - - -DESCRIPTION ------------ -Downloads and installs the consul binary from https://dl.bintray.com/mitchellh/consul. -Note that the consul binary is downloaded on the server (the machine running -cdist) and then deployed to the target host using the __file type unless --direct -parameter is used. - - -REQUIRED PARAMETERS -------------------- -None. - - -OPTIONAL PARAMETERS -------------------- -state - either 'present' or 'absent'. Defaults to 'present' - -version - which version of consul to install. See ./files/versions for a list of - supported versions. Defaults to the latest known version. - - -BOOLEAN PARAMETERS ------------------- -direct - Download and deploy consul binary directly on the target machine. - - -MESSAGES --------- -If consul binary is created using __staged_file then underlaying __file type messages are emitted. - -If consul binary is created by direct method then the following messages are emitted: - -/usr/local/bin/consul created - consul binary was created - - -EXAMPLES --------- - -.. code-block:: sh - - # just install using defaults - __consul - - # install by downloading consul binary directly on the target machine - __consul --direct - - # specific version - __consul \ - --version 0.4.1 - - -AUTHORS -------- -| Steven Armstrong -| Darko Poljak - - -COPYING -------- -Copyright \(C) 2015 Steven Armstrong. 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. diff --git a/cdist/conf/type/__consul/manifest b/cdist/conf/type/__consul/manifest deleted file mode 100755 index 156eb667..00000000 --- a/cdist/conf/type/__consul/manifest +++ /dev/null @@ -1,61 +0,0 @@ -#!/bin/sh -e -# -# 2015 Steven Armstrong (steven-cdist at armstrong.cc) -# 2016 Nico Schottelius (nico-cdist at schottelius.org) -# 2018 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 . -# - - -os=$(cat "$__global/explorer/os") - -case "$os" in - alpine|scientific|centos|redhat|ubuntu|debian|devuan|archlinux|gentoo) - # any linux should work - : - ;; - *) - echo "Your operating system ($os) is currently not supported by this type (${__type##*/})." >&2 - echo "Please contribute an implementation for it if you can." >&2 - exit 1 - ;; -esac - -versions_dir="$__type/files/versions" -version="$(cat "$__object/parameter/version")" -version_dir="$versions_dir/$version" - -if [ ! -d "$version_dir" ]; then - echo "Unknown consul version '$version'. Expected one of:" >&2 - ls "$versions_dir" >&2 - exit 1 -fi - -if [ -f "$__object/parameter/direct" ]; then - __package unzip - __package curl -else - __staged_file /usr/local/bin/consul \ - --source "$(cat "$version_dir/source")" \ - --cksum "$(cat "$version_dir/cksum")" \ - --fetch-command 'curl -s -L "%s"' \ - --prepare-command 'unzip -p "%s"' \ - --state "$(cat "$__object/parameter/state")" \ - --group root \ - --owner root \ - --mode 755 -fi diff --git a/cdist/conf/type/__consul/parameter/boolean b/cdist/conf/type/__consul/parameter/boolean deleted file mode 100644 index aa81b5e0..00000000 --- a/cdist/conf/type/__consul/parameter/boolean +++ /dev/null @@ -1 +0,0 @@ -direct diff --git a/cdist/conf/type/__consul/parameter/default/state b/cdist/conf/type/__consul/parameter/default/state deleted file mode 100644 index e7f6134f..00000000 --- a/cdist/conf/type/__consul/parameter/default/state +++ /dev/null @@ -1 +0,0 @@ -present diff --git a/cdist/conf/type/__consul/parameter/default/version b/cdist/conf/type/__consul/parameter/default/version deleted file mode 100644 index af0b7ddb..00000000 --- a/cdist/conf/type/__consul/parameter/default/version +++ /dev/null @@ -1 +0,0 @@ -1.0.6 diff --git a/cdist/conf/type/__consul/parameter/optional b/cdist/conf/type/__consul/parameter/optional deleted file mode 100644 index 4d595ed7..00000000 --- a/cdist/conf/type/__consul/parameter/optional +++ /dev/null @@ -1,2 +0,0 @@ -state -version diff --git a/cdist/conf/type/__consul/singleton b/cdist/conf/type/__consul/singleton deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/conf/type/__consul_agent/files/consul-prepare.upstart b/cdist/conf/type/__consul_agent/files/consul-prepare.upstart deleted file mode 100644 index 569220d1..00000000 --- a/cdist/conf/type/__consul_agent/files/consul-prepare.upstart +++ /dev/null @@ -1,9 +0,0 @@ -start on starting consul - -task - -script - mkdir -p /var/run/consul - chown consul:consul /var/run/consul - chmod 2770 /var/run/consul -end script diff --git a/cdist/conf/type/__consul_agent/files/consul.sys-openrc b/cdist/conf/type/__consul_agent/files/consul.sys-openrc deleted file mode 100644 index 1dbe9375..00000000 --- a/cdist/conf/type/__consul_agent/files/consul.sys-openrc +++ /dev/null @@ -1,38 +0,0 @@ -#!/sbin/openrc-run -# 2019 Nico Schottelius (nico-cdist at schottelius.org) - -description="consul agent" - -pidfile="${CONSUL_PIDFILE:-"/var/run/$RC_SVCNAME/pidfile"}" -command="${CONSUL_BINARY:-"/usr/local/bin/consul"}" - - -checkconfig() { - if [ ! -d /var/run/consul ] ; then - mkdir -p /var/run/consul || return 1 - chown consul:consul /var/run/$NAME || return 1 - chmod 2770 /var/run/$NAME || return 1 - fi -} - -start() { - need net - - start-stop-daemon --start --quiet --oknodo \ - --pidfile "$pidfile" --background \ - --exec $command -- agent -pid-file="$pidfile" -config-dir /etc/consul/conf.d -} -start_pre() { - checkconfig -} - -stop() { - if [ "${RC_CMD}" = "restart" ] ; then - checkconfig || return 1 - fi - - ebegin "Stopping $RC_SVCNAME" - start-stop-daemon --stop --exec "$command" \ - --pidfile "$pidfile" --quiet - eend $? -} diff --git a/cdist/conf/type/__consul_agent/files/consul.systemd b/cdist/conf/type/__consul_agent/files/consul.systemd deleted file mode 100644 index 8d5fd323..00000000 --- a/cdist/conf/type/__consul_agent/files/consul.systemd +++ /dev/null @@ -1,22 +0,0 @@ -[Unit] -Description=Consul Agent -Wants=basic.target -After=basic.target network.target - -[Service] -User=consul -Group=consul -Environment="GOMAXPROCS=2" -# Run ExecStartPre with root-permissions -PermissionsStartOnly=true -ExecStartPre=/usr/bin/mkdir -p /var/run/consul -ExecStartPre=/usr/bin/chown consul:consul /var/run/consul -ExecStartPre=/usr/bin/chmod 2770 /var/run/consul -ExecStart=/usr/local/bin/consul agent -config-dir /etc/consul/conf.d -ExecReload=/bin/kill -HUP $MAINPID -KillMode=process -Restart=on-failure -RestartSec=42s - -[Install] -WantedBy=multi-user.target diff --git a/cdist/conf/type/__consul_agent/files/consul.sysv-debian b/cdist/conf/type/__consul_agent/files/consul.sysv-debian deleted file mode 100644 index 4f43c000..00000000 --- a/cdist/conf/type/__consul_agent/files/consul.sysv-debian +++ /dev/null @@ -1,94 +0,0 @@ -#!/bin/sh -# -# 2015-2018 Nico Schottelius (nico-cdist at schottelius.org) -# 2015 Steven Armstrong (steven-cdist at armstrong.cc) -# -# This file is part of cdist. -# -# cdist is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# cdist is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with cdist. If not, see . -# -### BEGIN INIT INFO -# Provides: consul -# Required-Start: $network $local_fs $remote_fs -# Required-Stop: $local_fs -# Should-Start: -# Should-Stop: -# Short-Description: consul -# Description: consul agent -# Default-Start: 2 3 4 5 -# Default-Stop: 0 1 6 -### END INIT INFO - -if [ -f "/etc/default/consul" ]; then - # shellcheck disable=SC1091 - . /etc/default/consul -fi - -# shellcheck disable=SC1091 -. /lib/lsb/init-functions - -NAME=consul -CONSUL=/usr/local/bin/consul -CONFIG=/etc/$NAME/conf.d -PID_FILE=/var/run/$NAME/pidfile - -mkdir -p /var/run/$NAME -chown consul:consul /var/run/$NAME -chmod 2770 /var/run/$NAME - -export PATH="${PATH:+$PATH:}/usr/sbin:/sbin" - -case "$1" in - start) - log_daemon_msg "Starting consul agent" "consul" || true - if start-stop-daemon --start --quiet --oknodo \ - --pidfile "$PID_FILE" --background \ - --exec $CONSUL -- agent -pid-file="$PID_FILE" -config-dir "$CONFIG"; then - log_end_msg 0 || true - else - log_end_msg 1 || true - fi - ;; - - stop) - log_daemon_msg "Stopping consul agent" "consul" || true - if start-stop-daemon --stop --quiet --oknodo --pidfile $PID_FILE; then - log_end_msg 0 || true - else - log_end_msg 1 || true - fi - ;; - - reload) - log_daemon_msg "Reloading consul agent" "consul" || true - if start-stop-daemon --stop --signal HUP --quiet --oknodo --pidfile $PID_FILE --exec $CONSUL; then - log_end_msg 0 || true - else - log_end_msg 1 || true - fi - ;; - - restart) - $0 stop && $0 start - ;; - - status) - status_of_proc -p $PID_FILE $CONSUL consul && exit 0 || exit $? - ;; - - *) - log_action_msg "Usage: /etc/init.d/consul {start|stop|reload|restart|status}" - exit 1 - ;; -esac diff --git a/cdist/conf/type/__consul_agent/files/consul.sysv-redhat b/cdist/conf/type/__consul_agent/files/consul.sysv-redhat deleted file mode 100644 index 58fc9bd9..00000000 --- a/cdist/conf/type/__consul_agent/files/consul.sysv-redhat +++ /dev/null @@ -1,98 +0,0 @@ -#!/bin/bash -# -# /etc/rc.d/init.d/consul -# -# Daemonize the consul agent. -# -# chkconfig: 2345 95 95 -# description: Service discovery and configuration made easy. \ -# Distributed, highly available, and datacenter-aware. -# processname: consul -# pidfile: /var/run/consul/pidfile - -# Source function library. - -# shellcheck disable=SC1091 -. /etc/init.d/functions -NAME=consul -CONSUL=/usr/local/bin/consul -CONFIG="/etc/$NAME/conf.d" -PID_FILE="/var/run/$NAME/pidfile" -LOG_FILE="/var/log/$NAME" - -# shellcheck disable=SC1090 -[ -e "/etc/sysconfig/$NAME" ] && . "/etc/sysconfig/$NAME" -export GOMAXPROCS="${GOMAXPROCS:-2}" - -mkdir -p "/var/run/$NAME" -chown consul:consul "/var/run/$NAME" -chmod 2770 "/var/run/$NAME" - - -start() { - printf "Starting %s: " "$NAME" - daemon --user=consul \ - --pidfile="$PID_FILE" \ - "$CONSUL" agent -pid-file="$PID_FILE" -config-dir "$CONFIG" >> "$LOG_FILE" & - retcode=$? - touch "/var/lock/subsys/$NAME" - return "$retcode" -} - -stop() { - printf "Shutting down %s: " "$NAME" - killproc -p "$PID_FILE" "$NAME" - retcode=$? - rm -f "/var/lock/subsys/$NAME" - return "$retcode" -} - -case "$1" in - start) - if status -p "$PID_FILE" "$NAME" >/dev/null; then - echo "$NAME already running" - else - start - fi - ;; - stop) - if status -p "$PID_FILE" "$NAME" >/dev/null; then - stop - else - echo "$NAME not running" - fi - ;; - info) - "$CONSUL" info - ;; - status) - status -p "$PID_FILE" "$NAME" - exit $? - ;; - restart) - if status -p "$PID_FILE" "$NAME" >/dev/null; then - stop - fi - start - ;; - reload) - if status -p "$PID_FILE" "$NAME" >/dev/null; then - kill -HUP "$(cat "$PID_FILE")" - else - echo "$NAME not running" - fi - ;; - condrestart) - if [ -f "/var/lock/subsys/$NAME" ]; then - if status -p "$PID_FILE" "$NAME" >/dev/null; then - stop - fi - start - fi - ;; - *) - echo "Usage: $NAME {start|stop|status|reload|restart|condrestart|info}" - exit 1 - ;; -esac -exit $? diff --git a/cdist/conf/type/__consul_agent/files/consul.upstart b/cdist/conf/type/__consul_agent/files/consul.upstart deleted file mode 100644 index ed0c7b8e..00000000 --- a/cdist/conf/type/__consul_agent/files/consul.upstart +++ /dev/null @@ -1,13 +0,0 @@ -description "Consul Agent" -start on (local-filesystems and net-device-up IFACE!=lo) -stop on runlevel [06] - -setuid consul -setgid consul - -respawn -respawn limit 10 10 -kill timeout 10 - -exec /usr/local/bin/consul agent -config-dir /etc/consul/conf.d - diff --git a/cdist/conf/type/__consul_agent/gencode-remote b/cdist/conf/type/__consul_agent/gencode-remote deleted file mode 100755 index 997aa831..00000000 --- a/cdist/conf/type/__consul_agent/gencode-remote +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/sh -e -# -# 2015 Steven Armstrong (steven-cdist at armstrong.cc) -# -# This file is part of cdist. -# -# cdist is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# cdist is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with cdist. If not, see . -# - -service="consul" -state="$(cat "$__object/parameter/state")" - -case "$state" in - present) - : - ;; - absent) - echo "service $service stop || true" - ;; -esac diff --git a/cdist/conf/type/__consul_agent/man.rst b/cdist/conf/type/__consul_agent/man.rst deleted file mode 100644 index 966abc60..00000000 --- a/cdist/conf/type/__consul_agent/man.rst +++ /dev/null @@ -1,181 +0,0 @@ -cdist-type__consul_agent(7) -=========================== - -NAME ----- -cdist-type__consul_agent - Manage the consul agent - - -DESCRIPTION ------------ -Configure and manage the consul agent. - - -REQUIRED PARAMETERS -------------------- -None. - - -OPTIONAL PARAMETERS -------------------- -acl-datacenter - only used by servers. This designates the datacenter which is authoritative - for ACL information. - -acl-default-policy - either "allow" or "deny"; defaults to "allow". The default policy controls the - behavior of a token when there is no matching rule. - -acl-down-policy - either "allow", "deny" or "extend-cache"; "extend-cache" is the default. - -acl-master-token - only used for servers in the acl_datacenter. This token will be created with - management-level permissions if it does not exist. It allows operators to - bootstrap the ACL system with a token ID that is well-known. - -acl-token - when provided, the agent will use this token when making requests to the - Consul servers. - -acl-ttl - used to control Time-To-Live caching of ACLs. - -bind-addr - sets the bind address for cluster communication - -bootstrap-expect - sets server to expect bootstrap mode - -ca-file-source - path to a PEM encoded certificate authority file which will be uploaded and - configure using the ca_file config option. - -cert-file-source - path to a PEM encoded certificate file which will be uploaded and - configure using the cert_file config option. - -client-addr - sets the address to bind for client access - -datacenter - datacenter of the agent - -encrypt - provides the gossip encryption key - -group - the primary group for the agent - -json-config - path to a partial json config file without leading { and trailing }. - If json-config is '-' (dash), take what was written to stdin as the file content. - -key-file-source - path to a PEM encoded private key file which will be uploaded and - configure using the key_file config option. - -node-name - name of this node. Must be unique in the cluster - -retry-join - address to attempt joining every retry_interval until at least one join works. - Can be specified multiple times. - -user - the user to run the agent as - -state - if the agent is 'present' or 'absent'. Defaults to 'present'. - Currently state=absent is not working due to some dependency issues. - - -BOOLEAN PARAMETERS ------------------- -disable-remote-exec - disables support for remote execution. When set to true, the agent will ignore any incoming remote exec requests. - -disable-update-check - disables automatic checking for security bulletins and new version releases - -leave-on-terminate - gracefully leave cluster on SIGTERM - -rejoin-after-leave - rejoin the cluster using the previous state after leaving - -server - used to control if an agent is in server or client mode - -enable-syslog - enables logging to syslog - -verify-incoming - enforce the use of TLS and verify a client's authenticity on incoming connections - -verify-outgoing - enforce the use of TLS and verify the peers authenticity on outgoing connections - - -EXAMPLES --------- - -.. code-block:: sh - - # configure as server, bootstrap and rejoin - hostname="$(cat "$__global/explorer/hostname")" - __consul_agent \ - --datacenter dc1 \ - --node-name "${hostname%%.*}" \ - --disable-update-check \ - --server \ - --rejoin-after-leave \ - --bootstrap-expect 3 \ - --retry-join consul-01 \ - --retry-join consul-02 \ - --retry-join consul-03 - - # configure as server, bootstrap and rejoin with ssl support - hostname="$(cat "$__global/explorer/hostname")" - __consul_agent \ - --datacenter dc1 \ - --node-name "${hostname%%.*}" \ - --disable-update-check \ - --server \ - --rejoin-after-leave \ - --bootstrap-expect 3 \ - --retry-join consul-01 \ - --retry-join consul-02 \ - --retry-join consul-03 \ - --ca-file-source /path/to/ca.pem \ - --cert-file-source /path/to/cert.pem \ - --key-file-source /path/to/key.pem \ - --verify-incoming \ - --verify-outgoing - - # configure as client and try joining existing cluster - __consul_agent \ - --datacenter dc1 \ - --node-name "${hostname%%.*}" \ - --disable-update-check \ - --retry-join consul-01 \ - --retry-join consul-02 \ - --retry-join consul-03 - - -SEE ALSO --------- -consul documentation at: . - - -AUTHORS -------- -Steven Armstrong - - -COPYING -------- -Copyright \(C) 2015 Steven Armstrong. 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. diff --git a/cdist/conf/type/__consul_agent/manifest b/cdist/conf/type/__consul_agent/manifest deleted file mode 100755 index a88d26ed..00000000 --- a/cdist/conf/type/__consul_agent/manifest +++ /dev/null @@ -1,225 +0,0 @@ -#!/bin/sh -e -# -# 2015 Steven Armstrong (steven-cdist at armstrong.cc) -# 2015-2019 Nico Schottelius (nico-cdist at schottelius.org) -# -# This file is part of cdist. -# -# cdist is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# cdist is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with cdist. If not, see . -# - - -os=$(cat "$__global/explorer/os") - -case "$os" in - alpine|scientific|centos|debian|devuan|redhat|ubuntu) - # whitelist safeguard - : - ;; - *) - echo "Your operating system ($os) is currently not supported by this type (${__type##*/})." >&2 - echo "Please contribute an implementation for it if you can." >&2 - exit 1 - ;; -esac - -state="$(cat "$__object/parameter/state")" -user="$(cat "$__object/parameter/user")" -group="$(cat "$__object/parameter/group")" -data_dir="/var/lib/consul" -conf_dir="/etc/consul/conf.d" -conf_file="config.json" - -# FIXME: there has got to be a better way to handle the dependencies in this case -case "$state" in - present) - __group "$group" --system --state "$state" - require="__group/$group" \ - __user "$user" --system --gid "$group" \ - --home "$data_dir" --state "$state" - export require="__user/consul" - ;; - absent) - echo "Sorry, state=absent currently not supported :-(" >&2 - exit 1 - require="$__object_name" \ - __user "$user" --system --gid "$group" --state "$state" - require="__user/$user" \ - __group "$group" --system --state "$state" - ;; -esac - -__directory /etc/consul \ - --owner root --group "$group" --mode 750 --state "$state" -require="__directory/etc/consul" \ - __directory "$conf_dir" \ - --owner root --group "$group" --mode 750 --state "$state" - -if [ -f "$__object/parameter/ca-file-source" ] || [ -f "$__object/parameter/cert-file-source" ] || [ -f "$__object/parameter/key-file-source" ]; then - # create directory for ssl certs - require="__directory/etc/consul" \ - __directory /etc/consul/ssl \ - --owner root --group "$group" --mode 750 --state "$state" -fi - -__directory "$data_dir" \ - --owner "$user" --group "$group" --mode 770 --state "$state" - - -# Generate json config file -( -echo "{" - -# parameters we define ourself -printf ' "data_dir": "%s"\n' "$data_dir" - -cd "$__object/parameter/" -for param in *; do - case "$param" in - state|user|group|json-config) continue ;; - ca-file-source|cert-file-source|key-file-source) - source="$(cat "$__object/parameter/$param")" - destination="/etc/consul/ssl/${source##*/}" - require="__directory/etc/consul/ssl" \ - __file "$destination" \ - --owner root --group consul --mode 640 \ - --source "$source" \ - --state "$state" - key="$(echo "${param%-*}" | tr '-' '_')" - printf ' ,"%s": "%s"\n' "$key" "$destination" - ;; - disable-remote-exec|disable-update-check|leave-on-terminate|rejoin-after-leave|server|enable-syslog|verify-incoming|verify-outgoing) - # handle boolean parameters - key="$(echo "$param" | tr '-' '_')" - printf ' ,"%s": true\n' "$key" - ;; - retry-join) - # join multiple parameters into json array - retry_join="$(awk '{printf "\""$1"\","}' "$__object/parameter/retry-join")" - # remove trailing , - printf ' ,"retry_join": [%s]\n' "${retry_join%*,}" - ;; - retry-join-wan) - # join multiple parameters into json array over wan - retry_join_wan="$(awk '{printf "\""$1"\","}' "$__object/parameter/retry-join-wan")" - # remove trailing , - printf ' ,"retry_join_wan": [%s]\n' "${retry_join_wan%*,}" - ;; - bootstrap-expect) - # integer key=value parameters - key="$(echo "$param" | tr '-' '_')" - printf ' ,"%s": %s\n' "$key" "$(cat "$__object/parameter/$param")" - ;; - *) - # string key=value parameters - key="$(echo "$param" | tr '-' '_')" - printf ' ,"%s": "%s"\n' "$key" "$(cat "$__object/parameter/$param")" - ;; - esac -done -if [ -f "$__object/parameter/json-config" ]; then - json_config="$(cat "$__object/parameter/json-config")" - if [ "$json_config" = "-" ]; then - json_config="$__object/stdin" - fi - # remove leading and trailing whitespace and commas from first and last line - # indent each line with 3 spaces for consistency - json=$(sed -e 's/^[ \t]*/ /' -e '1s/^[ \t,]*//' -e '$s/[ \t,]*$//' "$json_config") - printf ' ,%s\n' "$json" -fi -echo "}" -) | \ -require="__directory${conf_dir}" \ - __config_file "${conf_dir}/${conf_file}" \ - --owner root --group "$group" --mode 640 \ - --state "$state" \ - --onchange 'service consul status >/dev/null && service consul reload || true' \ - --source - - -init_sysvinit() -{ - __file /etc/init.d/consul \ - --owner root --group root --mode 0755 \ - --state "$state" \ - --source "$__type/files/consul.sysv-$1" - require="__file/etc/init.d/consul" __start_on_boot consul -} - -init_systemd() -{ - __file /lib/systemd/system/consul.service \ - --owner root --group root --mode 0644 \ - --state "$state" \ - --source "$__type/files/consul.systemd" - require="__file/lib/systemd/system/consul.service" __start_on_boot consul -} - -init_upstart() -{ - __file /etc/init/consul-prepare.conf \ - --owner root --group root --mode 0644 \ - --state "$state" \ - --source "$__type/files/consul-prepare.upstart" - require="__file/etc/init/consul-prepare.conf" \ - __file /etc/init/consul.conf \ - --owner root --group root --mode 0644 \ - --state "$state" \ - --source "$__type/files/consul.upstart" - require="__file/etc/init/consul.conf" __start_on_boot consul -} - -# Install init script to start on boot -case "$os" in - alpine|devuan) - init_sysvinit debian - ;; - centos|redhat) - os_version="$(sed 's/[^0-9.]//g' "$__global/explorer/os_version")" - major_version="${os_version%%.*}" - case "$major_version" in - [456]) - init_sysvinit redhat - ;; - 7) - init_systemd - ;; - *) - echo "Unsupported CentOS/Redhat version: $os_version" >&2 - exit 1 - ;; - esac - ;; - - debian) - os_version=$(cat "$__global/explorer/os_version") - major_version="${os_version%%.*}" - - case "$major_version" in - [567]) - init_sysvinit debian - ;; - [89]) - init_systemd - ;; - *) - echo "Unsupported Debian version $os_version" >&2 - exit 1 - ;; - esac - ;; - - ubuntu) - init_upstart - ;; -esac diff --git a/cdist/conf/type/__consul_agent/parameter/boolean b/cdist/conf/type/__consul_agent/parameter/boolean deleted file mode 100644 index 91f7f17e..00000000 --- a/cdist/conf/type/__consul_agent/parameter/boolean +++ /dev/null @@ -1,8 +0,0 @@ -disable-remote-exec -disable-update-check -leave-on-terminate -rejoin-after-leave -server -enable-syslog -verify-incoming -verify-outgoing diff --git a/cdist/conf/type/__consul_agent/parameter/default/group b/cdist/conf/type/__consul_agent/parameter/default/group deleted file mode 100644 index 7d22c92b..00000000 --- a/cdist/conf/type/__consul_agent/parameter/default/group +++ /dev/null @@ -1 +0,0 @@ -consul diff --git a/cdist/conf/type/__consul_agent/parameter/default/state b/cdist/conf/type/__consul_agent/parameter/default/state deleted file mode 100644 index e7f6134f..00000000 --- a/cdist/conf/type/__consul_agent/parameter/default/state +++ /dev/null @@ -1 +0,0 @@ -present diff --git a/cdist/conf/type/__consul_agent/parameter/default/user b/cdist/conf/type/__consul_agent/parameter/default/user deleted file mode 100644 index 7d22c92b..00000000 --- a/cdist/conf/type/__consul_agent/parameter/default/user +++ /dev/null @@ -1 +0,0 @@ -consul diff --git a/cdist/conf/type/__consul_agent/parameter/optional b/cdist/conf/type/__consul_agent/parameter/optional deleted file mode 100644 index 37aad8c1..00000000 --- a/cdist/conf/type/__consul_agent/parameter/optional +++ /dev/null @@ -1,20 +0,0 @@ -acl-datacenter -acl-default-policy -acl-down-policy -acl-master-token -acl-token -acl-ttl -bind-addr -bootstrap-expect -ca-file-source -cert-file-source -client-addr -datacenter -encrypt -group -json-config -key-file-source -node-name -user -state -advertise-wan diff --git a/cdist/conf/type/__consul_agent/parameter/optional_multiple b/cdist/conf/type/__consul_agent/parameter/optional_multiple deleted file mode 100644 index 740e4d7f..00000000 --- a/cdist/conf/type/__consul_agent/parameter/optional_multiple +++ /dev/null @@ -1,2 +0,0 @@ -retry-join -retry-join-wan diff --git a/cdist/conf/type/__consul_agent/singleton b/cdist/conf/type/__consul_agent/singleton deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/conf/type/__consul_check/man.rst b/cdist/conf/type/__consul_check/man.rst deleted file mode 100644 index 9694c7af..00000000 --- a/cdist/conf/type/__consul_check/man.rst +++ /dev/null @@ -1,102 +0,0 @@ -cdist-type__consul_check(7) -============================= - -NAME ----- -cdist-type__consul_check - Manages consul checks - - -DESCRIPTION ------------ -Generate and deploy check definitions for a consul agent. -See http://www.consul.io/docs/agent/checks.html for parameter documentation. - -Use either script together with interval, or use ttl. - - -REQUIRED PARAMETERS -------------------- -None. - - -OPTIONAL PARAMETERS -------------------- -docker-container-id - the id of the docker container to run - -http - the url to check - -id - The id of this check. - -interval - the interval in which the check should run - -name - The name of this check. Defaults to __object_id - -notes - human readable description - -script - the shell command to run - -service-id - the id of the service this check is bound to - -shell - the shell to run inside the docker container - -state - if this check is 'present' or 'absent'. Defaults to 'present'. - -status - specify the initial state of this health check - -tcp - the host and port to check - -timeout - after how long to timeout checks which take to long - -token - ACL token to use for interacting with the catalog - -ttl - how long a TTL check is considered healthy without being updated through the - HTTP interface - - -EXAMPLES --------- - -.. code-block:: sh - - __consul_check redis \ - --script /usr/local/bin/check_redis.py \ - --interval 10s - - __consul_check some-object-id \ - --id web-app \ - --name "Web App Status" \ - --notes "Web app does a curl internally every 10 seconds" \ - --ttl 30s - - -SEE ALSO --------- -:strong:`cdist-type__consul_agent`\ (7) - - -AUTHORS -------- -Steven Armstrong - - -COPYING -------- -Copyright \(C) 2015-2016 Steven Armstrong. 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. diff --git a/cdist/conf/type/__consul_check/manifest b/cdist/conf/type/__consul_check/manifest deleted file mode 100755 index c9f7add9..00000000 --- a/cdist/conf/type/__consul_check/manifest +++ /dev/null @@ -1,73 +0,0 @@ -#!/bin/sh -e -# -# 2015-2016 Steven Armstrong (steven-cdist at armstrong.cc) -# -# This file is part of cdist. -# -# cdist is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# cdist is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with cdist. If not, see . -# - -name="$(cat "$__object/parameter/name" 2>/dev/null || echo "$__object_id")" -conf_dir="/etc/consul/conf.d" -conf_file="check_${name}.json" -state="$(cat "$__object/parameter/state")" - -# Sanity checks -if [ -f "$__object/parameter/ttl" ]; then - for conflicts_ttl in 'docker-container-id' 'http' 'script' 'tcp' 'timeout'; do - if [ -f "$__object/parameter/${conflicts_ttl}" ]; then - echo "Can not use --ttl together with --${conflicts_ttl}." >&2 - exit 1 - fi - done -fi -if [ ! -f "$__object/parameter/interval" ]; then - for requires_interval in 'docker-id' 'http' 'script' 'tcp'; do - if [ -f "$__object/parameter/${requires_interval}" ]; then - echo "When using --${requires_interval} you must also define --interval." >&2 - exit 1 - fi - done -fi -if [ -f "$__object/parameter/docker-container-id" ] && [ ! -f "$__object/parameter/script" ]; then - echo "When using --docker-container-id you must also define --script." >&2 - exit 1 -fi - -# Generate json config file -( -echo "{" -printf ' "check": {\n' -printf ' "name": "%s"\n' "$name" -cd "$__object/parameter/" -for param in *; do - case "$param" in - state|name) continue ;; - *) - key="$(echo "$param" | tr '-' '_')" - printf ' ,"%s": "%s"\n' "$key" "$(cat "$__object/parameter/$param")" - ;; - esac -done -# end check -echo " }" -# end json file -echo "}" -) | \ -require="__directory${conf_dir}" \ - __config_file "${conf_dir}/${conf_file}" \ - --owner root --group consul --mode 640 \ - --state "$state" \ - --onchange 'service consul status >/dev/null && service consul reload || true' \ - --source - diff --git a/cdist/conf/type/__consul_check/parameter/default/state b/cdist/conf/type/__consul_check/parameter/default/state deleted file mode 100644 index e7f6134f..00000000 --- a/cdist/conf/type/__consul_check/parameter/default/state +++ /dev/null @@ -1 +0,0 @@ -present diff --git a/cdist/conf/type/__consul_check/parameter/optional b/cdist/conf/type/__consul_check/parameter/optional deleted file mode 100644 index 0e392956..00000000 --- a/cdist/conf/type/__consul_check/parameter/optional +++ /dev/null @@ -1,15 +0,0 @@ -docker-container-id -http -id -interval -name -notes -script -service-id -shell -state -status -tcp -timeout -token -ttl diff --git a/cdist/conf/type/__consul_reload/gencode-remote b/cdist/conf/type/__consul_reload/gencode-remote deleted file mode 100755 index 839fd0c3..00000000 --- a/cdist/conf/type/__consul_reload/gencode-remote +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/sh -e -# -# 2015 Steven Armstrong (steven-cdist at armstrong.cc) -# -# This file is part of cdist. -# -# cdist is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# cdist is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with cdist. If not, see . -# - -service="consul" -if grep -q "^__file/etc/consul/conf.d/" "$__messages_in"; then - echo "service $service status && service $service reload || true" -fi diff --git a/cdist/conf/type/__consul_reload/man.rst b/cdist/conf/type/__consul_reload/man.rst deleted file mode 100644 index f48a041a..00000000 --- a/cdist/conf/type/__consul_reload/man.rst +++ /dev/null @@ -1,42 +0,0 @@ -cdist-type__consul_reload(7) -============================ - -NAME ----- -cdist-type__consul_reload - Reload consul - - -DESCRIPTION ------------ -Reload consul after configuration changes. - - -REQUIRED PARAMETERS -------------------- -None. - - -OPTIONAL PARAMETERS -------------------- -None. - - -EXAMPLES --------- - -.. code-block:: sh - - __consul_reload - - -AUTHORS -------- -Steven Armstrong - - -COPYING -------- -Copyright \(C) 2015 Steven Armstrong. 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. diff --git a/cdist/conf/type/__consul_reload/singleton b/cdist/conf/type/__consul_reload/singleton deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/conf/type/__consul_service/man.rst b/cdist/conf/type/__consul_service/man.rst deleted file mode 100644 index 510be3d5..00000000 --- a/cdist/conf/type/__consul_service/man.rst +++ /dev/null @@ -1,85 +0,0 @@ -cdist-type__consul_service(7) -============================= - -NAME ----- -cdist-type__consul_service - Manages consul services - - -DESCRIPTION ------------ -Generate and deploy service definitions for a consul agent. -See http://www.consul.io/docs/agent/services.html for parameter documentation. - -Use either script together with interval, or use ttl. - - -REQUIRED PARAMETERS -------------------- -None. - - -OPTIONAL PARAMETERS -------------------- -check-interval - the interval in which the script given with --check-script should be run - -check-http - the URL to check for HTTP 200-ish status every --check-interval - -check-script - the shell command to run every --check-interval - -check-ttl - how long a service is considered healthy without being updated through the - HTTP interfave - -id - Defaults to --name - -name - The name of this service. Defaults to __object_id - -port - the port at which this service can be reached - -state - if this service is 'present' or 'absent'. Defaults to 'present'. - -tag - a tag to add to this service. Can be specified multiple times. - - -EXAMPLES --------- - -.. code-block:: sh - - __consul_service redis \ - --tag master \ - --tag production \ - --port 8000 \ - --check-script /usr/local/bin/check_redis.py \ - --check-interval 10s - - __consul_service webapp \ - --port 80 \ - --check-ttl 10s - - -SEE ALSO --------- -:strong:`cdist-type__consul_agent`\ (7) - - -AUTHORS -------- -Steven Armstrong - - -COPYING -------- -Copyright \(C) 2015 Steven Armstrong. 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. diff --git a/cdist/conf/type/__consul_service/manifest b/cdist/conf/type/__consul_service/manifest deleted file mode 100755 index 60397db7..00000000 --- a/cdist/conf/type/__consul_service/manifest +++ /dev/null @@ -1,94 +0,0 @@ -#!/bin/sh -e -# -# 2015 Steven Armstrong (steven-cdist at armstrong.cc) -# -# This file is part of cdist. -# -# cdist is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# cdist is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with cdist. If not, see . -# - -name="$(cat "$__object/parameter/name" 2>/dev/null || echo "$__object_id")" -conf_dir="/etc/consul/conf.d" -conf_file="service_${name}.json" -state="$(cat "$__object/parameter/state")" - -# Sanity checks -if [ -f "$__object/parameter/check-script" ] && [ -f "$__object/parameter/check-ttl" ]; then - echo "Use either --check-script together with --check-interval OR --check-ttl, but not both" >&2 - exit 1 -fi -if [ -f "$__object/parameter/check-script" ] && [ ! -f "$__object/parameter/check-interval" ]; then - echo "When using --check-script you must also define --check-interval" >&2 - exit 1 -fi -if [ -f "$__object/parameter/check-http" ] && [ ! -f "$__object/parameter/check-interval" ]; then - echo "When using --check-http you must also define --check-interval" >&2 - exit 1 -fi - -# Generate json config file -( -echo "{" -printf ' "service": {\n' -printf ' "name": "%s"\n' "$name" -cd "$__object/parameter/" -for param in *; do - case "$param" in - state|name|check-interval) continue ;; - check-script) - printf ' ,"check": {\n' - printf ' "script": "%s"\n' "$(cat "$__object/parameter/check-script")" - printf ' ,"interval": "%s"\n' "$(cat "$__object/parameter/check-interval")" - printf ' }\n' - ;; - check-ttl) - printf ' ,"check": {\n' - printf ' "ttl": "%s"\n' "$(cat "$__object/parameter/check-ttl")" - printf ' }\n' - ;; - check-http) - printf ' ,"check": {\n' - printf ' "http": "%s"\n' "$(cat "$__object/parameter/check-http")" - printf ' ,"interval": "%s"\n' "$(cat "$__object/parameter/check-interval")" - printf ' }\n' - ;; - tag) - # create json array from newline delimited file - tags="$(awk '{printf "\""$1"\","}' "$__object/parameter/tag")" - # remove trailing , - printf ' ,"tags": [%s]\n' "${tags%*,}" - ;; - port) - # integer key=value parameters - key="$(echo "$param" | tr '-' '_')" - printf ' ,"%s": %s\n' "$key" "$(cat "$__object/parameter/$param")" - ;; - *) - # string key=value parameters - key="$(echo "$param" | tr '-' '_')" - printf ' ,"%s": "%s"\n' "$key" "$(cat "$__object/parameter/$param")" - ;; - esac -done -# end service -echo " }" -# end json file -echo "}" -) | \ -require="__directory${conf_dir}" \ - __config_file "${conf_dir}/${conf_file}" \ - --owner root --group consul --mode 640 \ - --state "$state" \ - --onchange 'service consul status >/dev/null && service consul reload || true' \ - --source - diff --git a/cdist/conf/type/__consul_service/parameter/default/state b/cdist/conf/type/__consul_service/parameter/default/state deleted file mode 100644 index e7f6134f..00000000 --- a/cdist/conf/type/__consul_service/parameter/default/state +++ /dev/null @@ -1 +0,0 @@ -present diff --git a/cdist/conf/type/__consul_service/parameter/optional b/cdist/conf/type/__consul_service/parameter/optional deleted file mode 100644 index 2e3e8b63..00000000 --- a/cdist/conf/type/__consul_service/parameter/optional +++ /dev/null @@ -1,8 +0,0 @@ -check-http -check-interval -check-script -check-ttl -id -name -port -state diff --git a/cdist/conf/type/__consul_service/parameter/optional_multiple b/cdist/conf/type/__consul_service/parameter/optional_multiple deleted file mode 100644 index 42c7c82c..00000000 --- a/cdist/conf/type/__consul_service/parameter/optional_multiple +++ /dev/null @@ -1 +0,0 @@ -tag diff --git a/cdist/conf/type/__consul_template/files/consul-template.systemd b/cdist/conf/type/__consul_template/files/consul-template.systemd deleted file mode 100644 index c67eaab5..00000000 --- a/cdist/conf/type/__consul_template/files/consul-template.systemd +++ /dev/null @@ -1,19 +0,0 @@ -[Unit] -Description=Consul-Template Daemon -Wants=basic.target -After=basic.target network.target - -[Service] -User=root -Group=root -Environment="CONSUL_TEMPLATE_LOG=info" -Environment="GOMAXPROCS=2" -ExecStart=/usr/local/bin/consul-template -config /etc/consul-template/conf.d -ExecReload=/bin/kill -HUP $MAINPID -KillMode=process -Restart=on-failure -RestartSec=10s -LimitNOFILE=4096 - -[Install] -WantedBy=multi-user.target diff --git a/cdist/conf/type/__consul_template/files/consul-template.sysv b/cdist/conf/type/__consul_template/files/consul-template.sysv deleted file mode 100644 index b263915a..00000000 --- a/cdist/conf/type/__consul_template/files/consul-template.sysv +++ /dev/null @@ -1,92 +0,0 @@ -#!/bin/bash -# -# /etc/rc.d/init.d/consul-template -# -# Daemonize the consul-template agent. -# -# chkconfig: 2345 95 95 -# description: Generic template rendering and notifications with Consul -# processname: consul-template -# pidfile: /var/run/consul-template/pidfile - -# Source function library. - -# shellcheck disable=SC1091 -. /etc/init.d/functions -NAME=consul-template -CONSUL_TEMPLATE=/usr/local/bin/consul-template -CONFIG="/etc/$NAME/conf.d" -PID_FILE="/var/run/$NAME/pidfile" -LOG_FILE="/var/log/$NAME" - -# shellcheck disable=SC1090 -[ -e "/etc/sysconfig/$NAME" ] && . "/etc/sysconfig/$NAME" -export CONSUL_TEMPLATE_LOG="${CONSUL_TEMPLATE_LOG:-info}" -export GOMAXPROCS="${GOMAXPROCS:-2}" - -mkdir -p "/var/run/$NAME" - -start() { - printf "Starting %s: " "$NAME" - daemon --pidfile="$PID_FILE" \ - "$CONSUL_TEMPLATE" -config "$CONFIG" >> "$LOG_FILE" 2>&1 & - echo "$!" > "$PID_FILE" - retcode=$? - touch "/var/lock/subsys/$NAME" - return "$retcode" -} - -stop() { - printf "Shutting down %s: " "$NAME" - killproc -p "$PID_FILE" "$CONSUL_TEMPLATE" - retcode=$? - rm -f "/var/lock/subsys/$NAME" - return "$retcode" -} - -case "$1" in - start) - if status -p "$PID_FILE" "$NAME" >/dev/null; then - echo "$NAME already running" - else - start - fi - ;; - stop) - if status -p "$PID_FILE" "$NAME" >/dev/null; then - stop - else - echo "$NAME not running" - fi - ;; - status) - status -p "$PID_FILE" "$NAME" - exit $? - ;; - restart) - if status -p "$PID_FILE" "$NAME" >/dev/null; then - stop - fi - start - ;; - reload) - if status -p "$PID_FILE" "$NAME" >/dev/null; then - kill -HUP "$(cat "$PID_FILE")" - else - echo "$NAME not running" - fi - ;; - condrestart) - if [ -f "/var/lock/subsys/$NAME" ]; then - if status -p "$PID_FILE" "$NAME" >/dev/null; then - stop - fi - start - fi - ;; - *) - echo "Usage: $NAME {start|stop|status|reload|restart}" - exit 1 - ;; -esac -exit $? diff --git a/cdist/conf/type/__consul_template/files/consul-template.upstart b/cdist/conf/type/__consul_template/files/consul-template.upstart deleted file mode 100644 index b81a2818..00000000 --- a/cdist/conf/type/__consul_template/files/consul-template.upstart +++ /dev/null @@ -1,12 +0,0 @@ -description "Consul-Template Daemon" -start on (local-filesystems and net-device-up IFACE!=lo) -stop on runlevel [06] - -env CONSUL_TEMPLATE_LOG=info -env GOMAXPROCS=${GOMAXPROCS} - -exec /usr/local/bin/consul-template -config /etc/consul-template/conf.d >> /var/log/consul-template 2>&1 - -respawn -respawn limit 10 10 -kill timeout 10 diff --git a/cdist/conf/type/__consul_template/files/versions/0.10.0/cksum b/cdist/conf/type/__consul_template/files/versions/0.10.0/cksum deleted file mode 100644 index bbf394db..00000000 --- a/cdist/conf/type/__consul_template/files/versions/0.10.0/cksum +++ /dev/null @@ -1 +0,0 @@ -3401777891 9273880 consul-template diff --git a/cdist/conf/type/__consul_template/files/versions/0.10.0/source b/cdist/conf/type/__consul_template/files/versions/0.10.0/source deleted file mode 100644 index 031b1155..00000000 --- a/cdist/conf/type/__consul_template/files/versions/0.10.0/source +++ /dev/null @@ -1 +0,0 @@ -https://releases.hashicorp.com/consul-template/0.10.0/consul-template_0.10.0_linux_amd64.zip diff --git a/cdist/conf/type/__consul_template/files/versions/0.15.0/cksum b/cdist/conf/type/__consul_template/files/versions/0.15.0/cksum deleted file mode 100644 index 426338bd..00000000 --- a/cdist/conf/type/__consul_template/files/versions/0.15.0/cksum +++ /dev/null @@ -1 +0,0 @@ -2643547924 12487232 consul-template diff --git a/cdist/conf/type/__consul_template/files/versions/0.15.0/source b/cdist/conf/type/__consul_template/files/versions/0.15.0/source deleted file mode 100644 index fdf1fccf..00000000 --- a/cdist/conf/type/__consul_template/files/versions/0.15.0/source +++ /dev/null @@ -1 +0,0 @@ -https://releases.hashicorp.com/consul-template/0.15.0/consul-template_0.15.0_linux_amd64.zip diff --git a/cdist/conf/type/__consul_template/man.rst b/cdist/conf/type/__consul_template/man.rst deleted file mode 100644 index f13c699d..00000000 --- a/cdist/conf/type/__consul_template/man.rst +++ /dev/null @@ -1,141 +0,0 @@ -cdist-type__consul_template(7) -============================== - -NAME ----- -cdist-type__consul_template - Manage the consul-template service - - -DESCRIPTION ------------ -Downloads and installs the consul-template binary from -https://github.com/hashicorp/consul-template/releases/download/. -Generates a global config file and creates directory for per template config files. -Note that the consul-template binary is downloaded on the server (the machine running -cdist) and then deployed to the target host using the __file type. - - -REQUIRED PARAMETERS -------------------- -None. - - -OPTIONAL PARAMETERS -------------------- -auth-username - specify a username for basic authentication. - -auth-password - specify a password for basic authentication. - -batch-size - the size of the batch when polling multiple dependencies. - -consul - the location of the Consul instance to query (may be an IP address or FQDN) with port. - Defaults to 'localhost:8500'. - -log-level - The log level for output. This applies to the stdout/stderr logging as well - as syslog logging (if enabled). Valid values are "debug", "info", "warn", - and "err". The default value is "warn". - -max-stale - the maximum staleness of a query. If specified, Consul will distribute work among all - servers instead of just the leader. - -retry - the amount of time to wait if Consul returns an error when communicating - with the API. - -state - either 'present' or 'absent'. Defaults to 'present' - -ssl-cert - Path to an SSL client certificate to use to authenticate to the consul server. - Useful if the consul server "verify_incoming" option is set. - -ssl-ca-cert - Path to a CA certificate file, containing one or more CA certificates to - use to validate the certificate sent by the consul server to us. This is a - handy alternative to setting --ssl-no-verify if you are using your own CA. - -syslog-facility - The facility to use when sending to syslog. This requires the use of --syslog. - The default value is LOCAL0. - -token - the Consul API token. - -vault-address - the location of the Vault instance to query (may be an IP address or FQDN) with port. - -vault-token - the Vault API token. - -vault-ssl-cert - Path to an SSL client certificate to use to authenticate to the vault server. - -vault-ssl-ca-cert - Path to a CA certificate file, containing one or more CA certificates to - use to validate the certificate sent by the vault server to us. - -version - which version of consul-template to install. See ./files/versions for a list of - supported versions. Defaults to the latest known version. - -wait - the minimum(:maximum) to wait before rendering a new template to disk and - triggering a command, separated by a colon (:). If the optional maximum - value is omitted, it is assumed to be 4x the required minimum value. - - -BOOLEAN PARAMETERS ------------------- -ssl - use HTTPS while talking to Consul. Requires the Consul server to be configured to serve secure connections. - -ssl-no-verify - ignore certificate warnings. Only used if ssl is enabled. - -syslog - Send log output to syslog (in addition to stdout and stderr). - -vault-ssl - use HTTPS while talking to Vault. Requires the Vault server to be configured to serve secure connections. - -vault-ssl-no-verify - ignore certificate warnings. Only used if vault is enabled. - - -EXAMPLES --------- - -.. code-block:: sh - - __consul_template \ - --consul consul.service.consul:8500 \ - --retry 30s - - # specific version - __consul_template \ - --version 0.6.5 \ - --retry 30s - - -SEE ALSO --------- -consul documentation at: . - - -AUTHORS -------- -Steven Armstrong - - -COPYING -------- -Copyright \(C) 2015 Steven Armstrong. 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. diff --git a/cdist/conf/type/__consul_template/manifest b/cdist/conf/type/__consul_template/manifest deleted file mode 100755 index b02fc332..00000000 --- a/cdist/conf/type/__consul_template/manifest +++ /dev/null @@ -1,191 +0,0 @@ -#!/bin/sh -e -# -# 2015 Steven Armstrong (steven-cdist at armstrong.cc) -# -# This file is part of cdist. -# -# cdist is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# cdist is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with cdist. If not, see . -# - - -os=$(cat "$__global/explorer/os") - -case "$os" in - scientific|centos|redhat) - # whitelist safeguard - service_onchange='service consul-template status >/dev/null && service consul-template reload || true' \ - ;; - archlinux) - service_onchange="systemctl status consul-template >/dev/null && systemctl reload consul-template || true" - ;; - *) - echo "Your operating system ($os) is currently not supported by this type (${__type##*/})." >&2 - echo "Please contribute an implementation for it if you can." >&2 - exit 1 - ;; -esac - -versions_dir="$__type/files/versions" -version="$(cat "$__object/parameter/version")" -version_dir="$versions_dir/$version" - -if [ ! -d "$version_dir" ]; then - echo "Unknown consul-template version '$version'. Expected one of:" >&2 - ls "$versions_dir" >&2 - exit 1 -fi - -state="$(cat "$__object/parameter/state")" - -__staged_file /usr/local/bin/consul-template \ - --source "$(cat "$version_dir/source")" \ - --cksum "$(cat "$version_dir/cksum")" \ - --fetch-command 'curl -s -L "%s"' \ - --prepare-command 'unzip -p "%s"' \ - --state "$state" \ - --group root \ - --owner root \ - --mode 755 - - -conf_dir="/etc/consul-template/conf.d" -conf_file="config.hcl" -template_dir="/etc/consul-template/template" - -__directory /etc/consul-template \ - --owner root --group root --mode 750 -require="__directory/etc/consul-template" \ - __directory "$conf_dir" \ - --owner root --group root --mode 750 -require="__directory/etc/consul-template" \ - __directory "$template_dir" \ - --owner root --group root --mode 750 - - -# Generate hcl config file -( -cd "$__object/parameter/" -for param in *; do - case "$param" in - auth-password|state|ssl-*|syslog-*|version|vault-token|vault-ssl*) continue ;; - auth-username) - printf 'auth {\n' - printf ' enabled = true\n' - printf ' username = "%s"\n' "$(cat "$__object/parameter/auth-username")" - if [ -f "$__object/parameter/auth-password" ]; then - printf ' password = %s\n' "$(cat "$__object/parameter/auth-password")" - fi - printf '}\n' - ;; - ssl) - printf 'ssl {\n' - printf ' enabled = true\n' - if [ -f "$__object/parameter/ssl-no-verify" ]; then - printf ' verify = false\n' - fi - if [ -f "$__object/parameter/ssl-cert" ]; then - printf ' cert = "%s"\n' "$(cat "$__object/parameter/ssl-cert")" - fi - if [ -f "$__object/parameter/ssl-ca-cert" ]; then - printf ' ca_cert = "%s"\n' "$(cat "$__object/parameter/ssl-ca-cert")" - fi - printf '}\n' - ;; - syslog) - printf 'syslog {\n' - printf ' enabled = true\n' - if [ -f "$__object/parameter/syslog-facility" ]; then - printf ' facility = "%s"\n' "$(cat "$__object/parameter/syslog-facility")" - fi - printf '}\n' - ;; - vault-address) - printf 'vault {\n' - printf ' address = "%s"\n' "$(cat "$__object/parameter/vault-address")" - if [ -f "$__object/parameter/vault-token" ]; then - printf ' token = "%s"\n' "$(cat "$__object/parameter/vault-token")" - fi - if [ -f "$__object/parameter/vault-ssl" ]; then - printf ' ssl {\n' - printf ' enabled = true\n' - if [ -f "$__object/parameter/vault-ssl-no-verify" ]; then - printf ' verify = false\n' - fi - if [ -f "$__object/parameter/vault-ssl-cert" ]; then - printf ' cert = "%s"\n' "$(cat "$__object/parameter/vault-ssl-cert")" - fi - if [ -f "$__object/parameter/vault-ssl-ca-cert" ]; then - printf ' ca_cert = "%s"\n' "$(cat "$__object/parameter/vault-ssl-ca-cert")" - fi - printf ' }\n' - fi - printf '}\n' - ;; - *) - # string key=value parameters - key="$(echo "$param" | tr '-' '_')" - printf '%s = "%s"\n' "$key" "$(cat "$__object/parameter/$param")" - ;; - esac -done -) | \ -require="__directory${conf_dir}" \ - __config_file "${conf_dir}/${conf_file}" \ - --owner root --group root --mode 640 \ - --state "$state" \ - --onchange "$service_onchange" \ - --source - - - -# Install init script to start on boot -service="consul-template" -case "$os" in - centos|redhat) - os_version="$(sed 's/[^0-9.]//g' "$__global/explorer/os_version")" - major_version="${os_version%%.*}" - case "$major_version" in - 7) - __file "/lib/systemd/system/${service}.service" \ - --owner root --group root --mode 0555 \ - --state "$state" \ - --source "$__type/files/${service}.systemd" - export require="__file/lib/systemd/system/${service}.service" - ;; - *) - __file "/etc/init.d/${service}" \ - --owner root --group root --mode 0555 \ - --state "$state" \ - --source "$__type/files/${service}.sysv" - export require="__file/etc/init.d/${service}" - ;; - esac - __start_on_boot "$service" --state "$state" - ;; - ubuntu) - __file "/etc/init/${service}.conf" \ - --owner root --group root --mode 0644 \ - --state "$state" \ - --source "$__type/files/${service}.upstart" - export require="__file/etc/init/${service}.conf" - __start_on_boot "$service" --state "$state" - ;; - archlinux) - __file "/lib/systemd/system/${service}.service" \ - --owner root --group root --mode 0555 \ - --state "$state" \ - --source "$__type/files/${service}.systemd" - export require="__file/lib/systemd/system/${service}.service" - __start_on_boot "$service" --state "$state" - ;; -esac diff --git a/cdist/conf/type/__consul_template/notes b/cdist/conf/type/__consul_template/notes deleted file mode 100644 index fc7cca11..00000000 --- a/cdist/conf/type/__consul_template/notes +++ /dev/null @@ -1,93 +0,0 @@ -# < 0.7.0 -ssl = true -ssl_no_verify = true - -# >= 0.7.0 -ssl { - enabled = true - verify = false -} - -# >= 0.9.0 -ssl-cert -ssl-ca-cert - - - --------------------------------------------------------------------------------- -### from docs - - -ssl { - enabled = true - verify = false - cert = "/path/to/client/cert.pem" - ca_cert = "/path/to/ca/cert.pem" -} - - -ssl - Use HTTPS while talking to Consul. Requires the Consul server to be configured to serve secure connections. The default value is false. - -ssl-verify - Verify certificates when connecting via SSL. This requires the use of -ssl. The default value is true. - -ssl-cert - Path to an SSL client certificate to use to authenticate to the consul server. Useful if the consul server "verify_incoming" option is set. - -ssl-ca-cert - Path to a CA certificate file, containing one or more CA certificates to use to validate the certificate sent by the consul server to us. This is a handy alternative to setting --ssl-verify=false if you are using your own CA. - --------------------------------------------------------------------------------- - -### example config file from docs - -consul = "127.0.0.1:8500" -token = "abcd1234" // May also be specified via the envvar CONSUL_TOKEN -retry = "10s" -max_stale = "10m" -log_level = "warn" -pid_file = "/path/to/pid" - -vault { - address = "https://vault.service.consul:8200" - token = "abcd1234" // May also be specified via the envvar VAULT_TOKEN - ssl { - enabled = true - verify = true - cert = "/path/to/client/cert.pem" - ca_cert = "/path/to/ca/cert.pem" - } -} - - ---auth-username ---auth-password -# if any are given enabled = true -auth { - enabled = true - username = "test" - password = "test" -} - -ssl { - enabled = true - verify = false - cert = "/path/to/client/cert.pem" - ca_cert = "/path/to/ca/cert.pem" -} - -syslog { - enabled = true - facility = "LOCAL5" -} - -template { - source = "/path/on/disk/to/template" - destination = "/path/on/disk/where/template/will/render" - command = "optional command to run when the template is updated" -} - -template { - // Multiple template definitions are supported -} diff --git a/cdist/conf/type/__consul_template/parameter/boolean b/cdist/conf/type/__consul_template/parameter/boolean deleted file mode 100644 index 10057e46..00000000 --- a/cdist/conf/type/__consul_template/parameter/boolean +++ /dev/null @@ -1,5 +0,0 @@ -ssl -ssl-no-verify -syslog -vault-ssl -vault-ssl-no-verify diff --git a/cdist/conf/type/__consul_template/parameter/default/consul b/cdist/conf/type/__consul_template/parameter/default/consul deleted file mode 100644 index 42dfa616..00000000 --- a/cdist/conf/type/__consul_template/parameter/default/consul +++ /dev/null @@ -1 +0,0 @@ -localhost:8500 diff --git a/cdist/conf/type/__consul_template/parameter/default/log-level b/cdist/conf/type/__consul_template/parameter/default/log-level deleted file mode 100644 index 1ef71804..00000000 --- a/cdist/conf/type/__consul_template/parameter/default/log-level +++ /dev/null @@ -1 +0,0 @@ -warn diff --git a/cdist/conf/type/__consul_template/parameter/default/state b/cdist/conf/type/__consul_template/parameter/default/state deleted file mode 100644 index e7f6134f..00000000 --- a/cdist/conf/type/__consul_template/parameter/default/state +++ /dev/null @@ -1 +0,0 @@ -present diff --git a/cdist/conf/type/__consul_template/parameter/default/syslog-facility b/cdist/conf/type/__consul_template/parameter/default/syslog-facility deleted file mode 100644 index f32df182..00000000 --- a/cdist/conf/type/__consul_template/parameter/default/syslog-facility +++ /dev/null @@ -1 +0,0 @@ -LOCAL0 diff --git a/cdist/conf/type/__consul_template/parameter/default/version b/cdist/conf/type/__consul_template/parameter/default/version deleted file mode 100644 index a5510516..00000000 --- a/cdist/conf/type/__consul_template/parameter/default/version +++ /dev/null @@ -1 +0,0 @@ -0.15.0 diff --git a/cdist/conf/type/__consul_template/parameter/optional b/cdist/conf/type/__consul_template/parameter/optional deleted file mode 100644 index 8bc528ac..00000000 --- a/cdist/conf/type/__consul_template/parameter/optional +++ /dev/null @@ -1,18 +0,0 @@ -auth-username -auth-password -batch-size -consul -log-level -max-stale -retry -state -ssl-cert -ssl-ca-cert -syslog-facility -token -vault-address -vault-token -vault-ssl-cert -vault-ssl-ca-cert -version -wait diff --git a/cdist/conf/type/__consul_template/singleton b/cdist/conf/type/__consul_template/singleton deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/conf/type/__consul_template_template/man.rst b/cdist/conf/type/__consul_template_template/man.rst deleted file mode 100644 index b2e3820b..00000000 --- a/cdist/conf/type/__consul_template_template/man.rst +++ /dev/null @@ -1,84 +0,0 @@ -cdist-type__consul_template_template(7) -======================================= - -NAME ----- -cdist-type__consul_template_template - Manage consul-template templates - - -DESCRIPTION ------------ -Generate and deploy template definitions for a consul-template. -See https://github.com/hashicorp/consul-template#examples for documentation. -Templates are written in the Go template format. -Either the --source or the --source-file parameter must be given. - - -REQUIRED PARAMETERS -------------------- -destination - the destination where the generated file should go. - - -OPTIONAL PARAMETERS -------------------- -command - an optional command to run after rendering the template to its destination. - -source - path to the template source. Conflicts --source-file. - -source-file - path to a local file which is uploaded using the __file type and configured - as the source. - If source is '-' (dash), take what was written to stdin as the file content. - Conflicts --source. - -state - if this template is 'present' or 'absent'. Defaults to 'present'. - -wait - The `minimum(:maximum)` time to wait before rendering a new template to - disk and triggering a command, separated by a colon (`:`). If the optional - maximum value is omitted, it is assumed to be 4x the required minimum value. - This is a numeric time with a unit suffix ("5s"). There is no default value. - The wait value for a template takes precedence over any globally-configured - wait. - - -EXAMPLES --------- - -.. code-block:: sh - - # configure template on the target - __consul_template_template nginx \ - --source /etc/my-consul-templates/nginx.ctmpl \ - --destination /etc/nginx/nginx.conf \ - --command 'service nginx restart' - - - # upload a local file to the target and configure it - __consul_template_template nginx \ - --wait '2s:6s' \ - --source-file "$__manifest/files/nginx.ctmpl" \ - --destination /etc/nginx/nginx.conf \ - --command 'service nginx restart' - - -SEE ALSO --------- -:strong:`cdist-type__consul_template`\ (7), :strong:`cdist-type__consul_template_config`\ (7) - - -AUTHORS -------- -Steven Armstrong - - -COPYING -------- -Copyright \(C) 2015-2016 Steven Armstrong. 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. diff --git a/cdist/conf/type/__consul_template_template/manifest b/cdist/conf/type/__consul_template_template/manifest deleted file mode 100755 index 1eae1fad..00000000 --- a/cdist/conf/type/__consul_template_template/manifest +++ /dev/null @@ -1,78 +0,0 @@ -#!/bin/sh -e -# -# 2015 Steven Armstrong (steven-cdist at armstrong.cc) -# -# This file is part of cdist. -# -# cdist is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# cdist is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with cdist. If not, see . -# - -name="$(cat "$__object/parameter/name" 2>/dev/null || echo "$__object_id")" -state="$(cat "$__object/parameter/state")" -conf_dir="/etc/consul-template/conf.d" -conf_file="template_${name}.hcl" -template_dir="/etc/consul-template/template" -require="" - -# Sanity checks -if [ -f "$__object/parameter/source" ] && [ -f "$__object/parameter/source-file" ]; then - echo "Use either --source OR --source-file, but not both." >&2 - exit 1 -fi -if [ ! -f "$__object/parameter/source" ] && [ ! -f "$__object/parameter/source-file" ]; then - echo "Either --source OR --source-file must be given." >&2 - exit 1 -fi - -if [ -f "$__object/parameter/source-file" ]; then - destination="${template_dir}/${name}" - require="__file${destination}" -fi - -# Generate hcl config file -{ -printf 'template {\n' -cd "$__object/parameter/" -for param in *; do - case "$param" in - source-file) - source="$(cat "$__object/parameter/$param")" - if [ "$source" = "-" ]; then - source="$__object/stdin" - fi - require="__directory${template_dir}" \ - __file "$destination" \ - --owner root --group root --mode 640 \ - --source "$source" \ - --state "$state" - printf ' source = "%s"\n' "$destination" - - ;; - source|destination|command|wait) - printf ' %s = "%s"\n' "$param" "$(cat "$__object/parameter/$param")" - ;; - *) - # ignore unknown parameters - : - ;; - esac -done -printf '}\n' -} | \ -require="$require __directory${conf_dir}" \ - __config_file "${conf_dir}/${conf_file}" \ - --owner root --group root --mode 640 \ - --state "$state" \ - --onchange 'service consul-template status >/dev/null && service consul-template reload || true' \ - --source - diff --git a/cdist/conf/type/__consul_template_template/parameter/default/state b/cdist/conf/type/__consul_template_template/parameter/default/state deleted file mode 100644 index e7f6134f..00000000 --- a/cdist/conf/type/__consul_template_template/parameter/default/state +++ /dev/null @@ -1 +0,0 @@ -present diff --git a/cdist/conf/type/__consul_template_template/parameter/optional b/cdist/conf/type/__consul_template_template/parameter/optional deleted file mode 100644 index 3e55fbb7..00000000 --- a/cdist/conf/type/__consul_template_template/parameter/optional +++ /dev/null @@ -1,5 +0,0 @@ -command -source -source-file -state -wait diff --git a/cdist/conf/type/__consul_template_template/parameter/required b/cdist/conf/type/__consul_template_template/parameter/required deleted file mode 100644 index ac459b09..00000000 --- a/cdist/conf/type/__consul_template_template/parameter/required +++ /dev/null @@ -1 +0,0 @@ -destination diff --git a/cdist/conf/type/__consul_watch_checks/man.rst b/cdist/conf/type/__consul_watch_checks/man.rst deleted file mode 100644 index a9a9f58d..00000000 --- a/cdist/conf/type/__consul_watch_checks/man.rst +++ /dev/null @@ -1,73 +0,0 @@ -cdist-type__consul_watch_checks(7) -================================== - -NAME ----- -cdist-type__consul_watch_checks - Manages consul checks watches - - -DESCRIPTION ------------ -Generate and deploy watch definitions of type 'checks' for a consul agent. -See http://www.consul.io/docs/agent/watches.html for parameter documentation. - - -REQUIRED PARAMETERS -------------------- -handler - the handler to invoke when the data view updates - - -OPTIONAL PARAMETERS -------------------- -datacenter - can be provided to override the agent's default datacenter - -filter-service - filter to a specific service. Conflicts with --filter-state. - -filter-state - filter to a specific state. Conflicts with --filter-service. - -state - if this watch is 'present' or 'absent'. Defaults to 'present'. - -token - can be provided to override the agent's default ACL token - - -EXAMPLES --------- - -.. code-block:: sh - - __consul_watch_checks some-id \ - --handler /usr/bin/my-handler.sh - - __consul_watch_checks some-id \ - --filter-service consul \ - --handler /usr/bin/my-handler.sh - - __consul_watch_checks some-id \ - --filter-state passing \ - --handler /usr/bin/my-handler.sh - - -SEE ALSO --------- -:strong:`cdist-type__consul_agent`\ (7) - -consul documentation at: . - - -AUTHORS -------- -Steven Armstrong - - -COPYING -------- -Copyright \(C) 2015 Steven Armstrong. 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. diff --git a/cdist/conf/type/__consul_watch_checks/manifest b/cdist/conf/type/__consul_watch_checks/manifest deleted file mode 100755 index 5fdd7a74..00000000 --- a/cdist/conf/type/__consul_watch_checks/manifest +++ /dev/null @@ -1,62 +0,0 @@ -#!/bin/sh -e -# -# 2015 Steven Armstrong (steven-cdist at armstrong.cc) -# -# This file is part of cdist. -# -# cdist is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# cdist is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with cdist. If not, see . -# - -cdist_type="${__type##*/}" -watch_type="${cdist_type##*_}" -conf_dir="/etc/consul/conf.d" -conf_file="watch_${watch_type}_${__object_id}.json" -state="$(cat "$__object/parameter/state")" - -# Sanity checks -if [ -f "$__object/parameter/filter-service" ] && [ -f "$__object/parameter/filter-state" ]; then - echo "Use either --filter-service or --filter-state but not both." >&2 - exit 1 -fi - -# Generate json config file -( -echo "{" -printf ' "watches": [{\n' -printf ' "type": "%s"\n' "$watch_type" -cd "$__object/parameter/" -for param in *; do - case "$param" in - state) continue ;; - filter-*) - key="${param##*-}" - printf ' ,"%s": "%s"\n' "$key" "$(cat "$__object/parameter/$param")" - ;; - *) - key="$(echo "$param" | tr '-' '_')" - printf ' ,"%s": "%s"\n' "$key" "$(cat "$__object/parameter/$param")" - ;; - esac -done -# end watches -echo " }]" -# end json file -echo "}" -) | \ -require="__directory${conf_dir}" \ - __config_file "${conf_dir}/${conf_file}" \ - --owner root --group consul --mode 640 \ - --state "$state" \ - --onchange 'service consul status >/dev/null && service consul reload || true' \ - --source - diff --git a/cdist/conf/type/__consul_watch_checks/parameter/default/state b/cdist/conf/type/__consul_watch_checks/parameter/default/state deleted file mode 100644 index e7f6134f..00000000 --- a/cdist/conf/type/__consul_watch_checks/parameter/default/state +++ /dev/null @@ -1 +0,0 @@ -present diff --git a/cdist/conf/type/__consul_watch_checks/parameter/optional b/cdist/conf/type/__consul_watch_checks/parameter/optional deleted file mode 100644 index d37fd557..00000000 --- a/cdist/conf/type/__consul_watch_checks/parameter/optional +++ /dev/null @@ -1,5 +0,0 @@ -datacenter -filter-service -filter-state -state -token diff --git a/cdist/conf/type/__consul_watch_checks/parameter/required b/cdist/conf/type/__consul_watch_checks/parameter/required deleted file mode 100644 index 64b916c1..00000000 --- a/cdist/conf/type/__consul_watch_checks/parameter/required +++ /dev/null @@ -1 +0,0 @@ -handler diff --git a/cdist/conf/type/__consul_watch_event/man.rst b/cdist/conf/type/__consul_watch_event/man.rst deleted file mode 100644 index 6fe60d40..00000000 --- a/cdist/conf/type/__consul_watch_event/man.rst +++ /dev/null @@ -1,66 +0,0 @@ -cdist-type__consul_watch_event(7) -================================= - -NAME ----- -cdist-type__consul_watch_event - Manages consul event watches - - -DESCRIPTION ------------ -Generate and deploy watch definitions of type 'event' for a consul agent. -See http://www.consul.io/docs/agent/watches.html for parameter documentation. - - -REQUIRED PARAMETERS -------------------- -handler - the handler to invoke when the data view updates - - -OPTIONAL PARAMETERS -------------------- -datacenter - can be provided to override the agent's default datacenter - -name - restrict the watch to only events with the given name - -state - if this watch is 'present' or 'absent'. Defaults to 'present'. - -token - can be provided to override the agent's default ACL token - - -EXAMPLES --------- - -.. code-block:: sh - - __consul_watch_event some-id \ - --handler /usr/bin/my-handler.sh - - __consul_watch_event some-id \ - --name web-deploy \ - --handler /usr/bin/my-handler.sh - - -SEE ALSO --------- -:strong:`cdist-type__consul_agent`\ (7) - -consul documentation at: . - - -AUTHORS -------- -Steven Armstrong - - -COPYING -------- -Copyright \(C) 2015 Steven Armstrong. 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. diff --git a/cdist/conf/type/__consul_watch_event/manifest b/cdist/conf/type/__consul_watch_event/manifest deleted file mode 100755 index 61934656..00000000 --- a/cdist/conf/type/__consul_watch_event/manifest +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/sh -e -# -# 2015 Steven Armstrong (steven-cdist at armstrong.cc) -# -# This file is part of cdist. -# -# cdist is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# cdist is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with cdist. If not, see . -# - -cdist_type="${__type##*/}" -watch_type="${cdist_type##*_}" -conf_dir="/etc/consul/conf.d" -conf_file="watch_${watch_type}_${__object_id}.json" -state="$(cat "$__object/parameter/state")" - -# Generate json config file -( -echo "{" -printf ' "watches": [{\n' -printf ' "type": "%s"\n' "$watch_type" -cd "$__object/parameter/" -for param in *; do - case "$param" in - state) continue ;; - *) - key="$(echo "$param" | tr '-' '_')" - printf ' ,"%s": "%s"\n' "$key" "$(cat "$__object/parameter/$param")" - ;; - esac -done -# end watches -echo " }]" -# end json file -echo "}" -) | \ -require="__directory${conf_dir}" \ - __config_file "${conf_dir}/${conf_file}" \ - --owner root --group consul --mode 640 \ - --state "$state" \ - --onchange 'service consul status >/dev/null && service consul reload || true' \ - --source - diff --git a/cdist/conf/type/__consul_watch_event/parameter/default/state b/cdist/conf/type/__consul_watch_event/parameter/default/state deleted file mode 100644 index e7f6134f..00000000 --- a/cdist/conf/type/__consul_watch_event/parameter/default/state +++ /dev/null @@ -1 +0,0 @@ -present diff --git a/cdist/conf/type/__consul_watch_event/parameter/optional b/cdist/conf/type/__consul_watch_event/parameter/optional deleted file mode 100644 index ac808c47..00000000 --- a/cdist/conf/type/__consul_watch_event/parameter/optional +++ /dev/null @@ -1,4 +0,0 @@ -datacenter -name -state -token diff --git a/cdist/conf/type/__consul_watch_event/parameter/required b/cdist/conf/type/__consul_watch_event/parameter/required deleted file mode 100644 index 64b916c1..00000000 --- a/cdist/conf/type/__consul_watch_event/parameter/required +++ /dev/null @@ -1 +0,0 @@ -handler diff --git a/cdist/conf/type/__consul_watch_key/man.rst b/cdist/conf/type/__consul_watch_key/man.rst deleted file mode 100644 index a12f8425..00000000 --- a/cdist/conf/type/__consul_watch_key/man.rst +++ /dev/null @@ -1,63 +0,0 @@ -cdist-type__consul_watch_key(7) -=============================== - -NAME ----- -cdist-type__consul_watch_key - Manages consul key watches - - -DESCRIPTION ------------ -Generate and deploy watch definitions of type 'key' for a consul agent. -See http://www.consul.io/docs/agent/watches.html for parameter documentation. - - -REQUIRED PARAMETERS -------------------- -handler - the handler to invoke when the data view updates - -key - the key to watch for changes - - -OPTIONAL PARAMETERS -------------------- -datacenter - can be provided to override the agent's default datacenter - -state - if this watch is 'present' or 'absent'. Defaults to 'present'. - -token - can be provided to override the agent's default ACL token - - -EXAMPLES --------- - -.. code-block:: sh - - __consul_watch_key some-id \ - --key foo/bar/baz \ - --handler /usr/bin/my-key-handler.sh - - -SEE ALSO --------- -:strong:`cdist-type__consul_agent`\ (7) - -consul documentation at: . - - -AUTHORS -------- -Steven Armstrong - - -COPYING -------- -Copyright \(C) 2015 Steven Armstrong. 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. diff --git a/cdist/conf/type/__consul_watch_key/manifest b/cdist/conf/type/__consul_watch_key/manifest deleted file mode 100755 index 61934656..00000000 --- a/cdist/conf/type/__consul_watch_key/manifest +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/sh -e -# -# 2015 Steven Armstrong (steven-cdist at armstrong.cc) -# -# This file is part of cdist. -# -# cdist is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# cdist is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with cdist. If not, see . -# - -cdist_type="${__type##*/}" -watch_type="${cdist_type##*_}" -conf_dir="/etc/consul/conf.d" -conf_file="watch_${watch_type}_${__object_id}.json" -state="$(cat "$__object/parameter/state")" - -# Generate json config file -( -echo "{" -printf ' "watches": [{\n' -printf ' "type": "%s"\n' "$watch_type" -cd "$__object/parameter/" -for param in *; do - case "$param" in - state) continue ;; - *) - key="$(echo "$param" | tr '-' '_')" - printf ' ,"%s": "%s"\n' "$key" "$(cat "$__object/parameter/$param")" - ;; - esac -done -# end watches -echo " }]" -# end json file -echo "}" -) | \ -require="__directory${conf_dir}" \ - __config_file "${conf_dir}/${conf_file}" \ - --owner root --group consul --mode 640 \ - --state "$state" \ - --onchange 'service consul status >/dev/null && service consul reload || true' \ - --source - diff --git a/cdist/conf/type/__consul_watch_key/parameter/default/state b/cdist/conf/type/__consul_watch_key/parameter/default/state deleted file mode 100644 index e7f6134f..00000000 --- a/cdist/conf/type/__consul_watch_key/parameter/default/state +++ /dev/null @@ -1 +0,0 @@ -present diff --git a/cdist/conf/type/__consul_watch_key/parameter/optional b/cdist/conf/type/__consul_watch_key/parameter/optional deleted file mode 100644 index bfce8305..00000000 --- a/cdist/conf/type/__consul_watch_key/parameter/optional +++ /dev/null @@ -1,3 +0,0 @@ -datacenter -state -token diff --git a/cdist/conf/type/__consul_watch_key/parameter/required b/cdist/conf/type/__consul_watch_key/parameter/required deleted file mode 100644 index a7ae5b65..00000000 --- a/cdist/conf/type/__consul_watch_key/parameter/required +++ /dev/null @@ -1,2 +0,0 @@ -handler -key diff --git a/cdist/conf/type/__consul_watch_keyprefix/man.rst b/cdist/conf/type/__consul_watch_keyprefix/man.rst deleted file mode 100644 index c600323c..00000000 --- a/cdist/conf/type/__consul_watch_keyprefix/man.rst +++ /dev/null @@ -1,63 +0,0 @@ -cdist-type__consul_watch_keyprefix(7) -===================================== - -NAME ----- -cdist-type__consul_watch_keyprefix - Manages consul keyprefix watches - - -DESCRIPTION ------------ -Generate and deploy watch definitions of type 'keyprefix' for a consul agent. -See http://www.consul.io/docs/agent/watches.html for parameter documentation. - - -REQUIRED PARAMETERS -------------------- -handler - the handler to invoke when the data view updates - -prefix - the prefix of keys to watch for changes - - -OPTIONAL PARAMETERS -------------------- -datacenter - can be provided to override the agent's default datacenter - -state - if this watch is 'present' or 'absent'. Defaults to 'present'. - -token - can be provided to override the agent's default ACL token - - -EXAMPLES --------- - -.. code-block:: sh - - __consul_watch_keyprefix some-id \ - --prefix foo/ \ - --handler /usr/bin/my-prefix-handler.sh - - -SEE ALSO --------- -:strong:`cdist-type__consul_agent`\ (7) - -consul documentation at: . - - -AUTHORS -------- -Steven Armstrong - - -COPYING -------- -Copyright \(C) 2015 Steven Armstrong. 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. diff --git a/cdist/conf/type/__consul_watch_keyprefix/manifest b/cdist/conf/type/__consul_watch_keyprefix/manifest deleted file mode 100755 index 61934656..00000000 --- a/cdist/conf/type/__consul_watch_keyprefix/manifest +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/sh -e -# -# 2015 Steven Armstrong (steven-cdist at armstrong.cc) -# -# This file is part of cdist. -# -# cdist is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# cdist is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with cdist. If not, see . -# - -cdist_type="${__type##*/}" -watch_type="${cdist_type##*_}" -conf_dir="/etc/consul/conf.d" -conf_file="watch_${watch_type}_${__object_id}.json" -state="$(cat "$__object/parameter/state")" - -# Generate json config file -( -echo "{" -printf ' "watches": [{\n' -printf ' "type": "%s"\n' "$watch_type" -cd "$__object/parameter/" -for param in *; do - case "$param" in - state) continue ;; - *) - key="$(echo "$param" | tr '-' '_')" - printf ' ,"%s": "%s"\n' "$key" "$(cat "$__object/parameter/$param")" - ;; - esac -done -# end watches -echo " }]" -# end json file -echo "}" -) | \ -require="__directory${conf_dir}" \ - __config_file "${conf_dir}/${conf_file}" \ - --owner root --group consul --mode 640 \ - --state "$state" \ - --onchange 'service consul status >/dev/null && service consul reload || true' \ - --source - diff --git a/cdist/conf/type/__consul_watch_keyprefix/parameter/default/state b/cdist/conf/type/__consul_watch_keyprefix/parameter/default/state deleted file mode 100644 index e7f6134f..00000000 --- a/cdist/conf/type/__consul_watch_keyprefix/parameter/default/state +++ /dev/null @@ -1 +0,0 @@ -present diff --git a/cdist/conf/type/__consul_watch_keyprefix/parameter/optional b/cdist/conf/type/__consul_watch_keyprefix/parameter/optional deleted file mode 100644 index bfce8305..00000000 --- a/cdist/conf/type/__consul_watch_keyprefix/parameter/optional +++ /dev/null @@ -1,3 +0,0 @@ -datacenter -state -token diff --git a/cdist/conf/type/__consul_watch_keyprefix/parameter/required b/cdist/conf/type/__consul_watch_keyprefix/parameter/required deleted file mode 100644 index 6223b4de..00000000 --- a/cdist/conf/type/__consul_watch_keyprefix/parameter/required +++ /dev/null @@ -1,2 +0,0 @@ -handler -keyprefix diff --git a/cdist/conf/type/__consul_watch_nodes/man.rst b/cdist/conf/type/__consul_watch_nodes/man.rst deleted file mode 100644 index d886a586..00000000 --- a/cdist/conf/type/__consul_watch_nodes/man.rst +++ /dev/null @@ -1,59 +0,0 @@ -cdist-type__consul_watch_nodes(7) -================================= - -NAME ----- -cdist-type__consul_watch_nodes - Manages consul nodes watches - - -DESCRIPTION ------------ -Generate and deploy watch definitions of type 'nodes' for a consul agent. -See http://www.consul.io/docs/agent/watches.html for parameter documentation. - - -REQUIRED PARAMETERS -------------------- -handler - the handler to invoke when the data view updates - - -OPTIONAL PARAMETERS -------------------- -datacenter - can be provided to override the agent's default datacenter - -state - if this watch is 'present' or 'absent'. Defaults to 'present'. - -token - can be provided to override the agent's default ACL token - - -EXAMPLES --------- - -.. code-block:: sh - - __consul_watch_nodes some-id \ - --handler /usr/bin/my-key-handler.sh - - -SEE ALSO --------- -:strong:`cdist-type__consul_agent`\ (7) - -consul documentation at: . - - -AUTHORS -------- -Steven Armstrong - - -COPYING -------- -Copyright \(C) 2015 Steven Armstrong. 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. diff --git a/cdist/conf/type/__consul_watch_nodes/manifest b/cdist/conf/type/__consul_watch_nodes/manifest deleted file mode 100755 index 61934656..00000000 --- a/cdist/conf/type/__consul_watch_nodes/manifest +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/sh -e -# -# 2015 Steven Armstrong (steven-cdist at armstrong.cc) -# -# This file is part of cdist. -# -# cdist is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# cdist is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with cdist. If not, see . -# - -cdist_type="${__type##*/}" -watch_type="${cdist_type##*_}" -conf_dir="/etc/consul/conf.d" -conf_file="watch_${watch_type}_${__object_id}.json" -state="$(cat "$__object/parameter/state")" - -# Generate json config file -( -echo "{" -printf ' "watches": [{\n' -printf ' "type": "%s"\n' "$watch_type" -cd "$__object/parameter/" -for param in *; do - case "$param" in - state) continue ;; - *) - key="$(echo "$param" | tr '-' '_')" - printf ' ,"%s": "%s"\n' "$key" "$(cat "$__object/parameter/$param")" - ;; - esac -done -# end watches -echo " }]" -# end json file -echo "}" -) | \ -require="__directory${conf_dir}" \ - __config_file "${conf_dir}/${conf_file}" \ - --owner root --group consul --mode 640 \ - --state "$state" \ - --onchange 'service consul status >/dev/null && service consul reload || true' \ - --source - diff --git a/cdist/conf/type/__consul_watch_nodes/parameter/default/state b/cdist/conf/type/__consul_watch_nodes/parameter/default/state deleted file mode 100644 index e7f6134f..00000000 --- a/cdist/conf/type/__consul_watch_nodes/parameter/default/state +++ /dev/null @@ -1 +0,0 @@ -present diff --git a/cdist/conf/type/__consul_watch_nodes/parameter/optional b/cdist/conf/type/__consul_watch_nodes/parameter/optional deleted file mode 100644 index bfce8305..00000000 --- a/cdist/conf/type/__consul_watch_nodes/parameter/optional +++ /dev/null @@ -1,3 +0,0 @@ -datacenter -state -token diff --git a/cdist/conf/type/__consul_watch_nodes/parameter/required b/cdist/conf/type/__consul_watch_nodes/parameter/required deleted file mode 100644 index 64b916c1..00000000 --- a/cdist/conf/type/__consul_watch_nodes/parameter/required +++ /dev/null @@ -1 +0,0 @@ -handler diff --git a/cdist/conf/type/__consul_watch_service/man.rst b/cdist/conf/type/__consul_watch_service/man.rst deleted file mode 100644 index 37cabcc9..00000000 --- a/cdist/conf/type/__consul_watch_service/man.rst +++ /dev/null @@ -1,83 +0,0 @@ -cdist-type__consul_watch_service(7) -=================================== - -NAME ----- -cdist-type__consul_watch_service - Manages consul service watches - - -DESCRIPTION ------------ -Generate and deploy watch definitions of type 'service' for a consul agent. -See http://www.consul.io/docs/agent/watches.html for parameter documentation. - - -REQUIRED PARAMETERS -------------------- -handler - the handler to invoke when the data view updates - -service - the service to watch for changes - - -OPTIONAL PARAMETERS -------------------- -datacenter - can be provided to override the agent's default datacenter - -state - if this watch is 'present' or 'absent'. Defaults to 'present'. - -token - can be provided to override the agent's default ACL token - -tag - filter by tag - - -BOOLEAN PARAMETERS ------------------- -passingonly - specifies if only hosts passing all checks are displayed - - -EXAMPLES --------- - -.. code-block:: sh - - __consul_watch_service some-id \ - --service consul \ - --handler /usr/bin/my-handler.sh - - __consul_watch_service some-id \ - --service redis \ - --tag production \ - --handler /usr/bin/my-handler.sh - - __consul_watch_service some-id \ - --service redis \ - --tag production \ - --passingonly \ - --handler /usr/bin/my-handler.sh - - -SEE ALSO --------- -:strong:`cdist-type__consul_agent`\ (7) - -consul documentation at: . - - -AUTHORS -------- -Steven Armstrong - - -COPYING -------- -Copyright \(C) 2015 Steven Armstrong. 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. diff --git a/cdist/conf/type/__consul_watch_service/manifest b/cdist/conf/type/__consul_watch_service/manifest deleted file mode 100755 index db38eb18..00000000 --- a/cdist/conf/type/__consul_watch_service/manifest +++ /dev/null @@ -1,55 +0,0 @@ -#!/bin/sh -e -# -# 2015 Steven Armstrong (steven-cdist at armstrong.cc) -# -# This file is part of cdist. -# -# cdist is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# cdist is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with cdist. If not, see . -# - -cdist_type="${__type##*/}" -watch_type="${cdist_type##*_}" -conf_dir="/etc/consul/conf.d" -conf_file="watch_${watch_type}_${__object_id}.json" -state="$(cat "$__object/parameter/state")" - -# Generate json config file -( -echo "{" -printf ' "watches": [{\n' -printf ' "type": "%s"\n' "$watch_type" -cd "$__object/parameter/" -for param in *; do - case "$param" in - state) continue ;; - passingonly) - printf ' ,"passingonly": true\n' - ;; - *) - key="$(echo "$param" | tr '-' '_')" - printf ' ,"%s": "%s"\n' "$key" "$(cat "$__object/parameter/$param")" - ;; - esac -done -# end watches -echo " }]" -# end json file -echo "}" -) | \ -require="__directory${conf_dir}" \ - __config_file "${conf_dir}/${conf_file}" \ - --owner root --group consul --mode 640 \ - --state "$state" \ - --onchange 'service consul status >/dev/null && service consul reload || true' \ - --source - diff --git a/cdist/conf/type/__consul_watch_service/parameter/boolean b/cdist/conf/type/__consul_watch_service/parameter/boolean deleted file mode 100644 index 4c1e4b3f..00000000 --- a/cdist/conf/type/__consul_watch_service/parameter/boolean +++ /dev/null @@ -1 +0,0 @@ -passingonly diff --git a/cdist/conf/type/__consul_watch_service/parameter/default/state b/cdist/conf/type/__consul_watch_service/parameter/default/state deleted file mode 100644 index e7f6134f..00000000 --- a/cdist/conf/type/__consul_watch_service/parameter/default/state +++ /dev/null @@ -1 +0,0 @@ -present diff --git a/cdist/conf/type/__consul_watch_service/parameter/optional b/cdist/conf/type/__consul_watch_service/parameter/optional deleted file mode 100644 index a81860ac..00000000 --- a/cdist/conf/type/__consul_watch_service/parameter/optional +++ /dev/null @@ -1,4 +0,0 @@ -datacenter -state -tag -token diff --git a/cdist/conf/type/__consul_watch_service/parameter/required b/cdist/conf/type/__consul_watch_service/parameter/required deleted file mode 100644 index e1ffa4d6..00000000 --- a/cdist/conf/type/__consul_watch_service/parameter/required +++ /dev/null @@ -1,2 +0,0 @@ -handler -service diff --git a/cdist/conf/type/__consul_watch_services/man.rst b/cdist/conf/type/__consul_watch_services/man.rst deleted file mode 100644 index cea5f901..00000000 --- a/cdist/conf/type/__consul_watch_services/man.rst +++ /dev/null @@ -1,59 +0,0 @@ -cdist-type__consul_watch_services(7) -==================================== - -NAME ----- -cdist-type__consul_watch_services - Manages consul services watches - - -DESCRIPTION ------------ -Generate and deploy watch definitions of type 'services' for a consul agent. -See http://www.consul.io/docs/agent/watches.html for parameter documentation. - - -REQUIRED PARAMETERS -------------------- -handler - the handler to invoke when the data view updates - - -OPTIONAL PARAMETERS -------------------- -datacenter - can be provided to override the agent's default datacenter - -state - if this watch is 'present' or 'absent'. Defaults to 'present'. - -token - can be provided to override the agent's default ACL token - - -EXAMPLES --------- - -.. code-block:: sh - - __consul_watch_services some-id \ - --handler /usr/bin/my-key-handler.sh - - -SEE ALSO --------- -:strong:`cdist-type__consul_agent`\ (7) - -consul documentation at: . - - -AUTHORS -------- -Steven Armstrong - - -COPYING -------- -Copyright \(C) 2015 Steven Armstrong. 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. diff --git a/cdist/conf/type/__consul_watch_services/manifest b/cdist/conf/type/__consul_watch_services/manifest deleted file mode 100755 index 61934656..00000000 --- a/cdist/conf/type/__consul_watch_services/manifest +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/sh -e -# -# 2015 Steven Armstrong (steven-cdist at armstrong.cc) -# -# This file is part of cdist. -# -# cdist is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# cdist is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with cdist. If not, see . -# - -cdist_type="${__type##*/}" -watch_type="${cdist_type##*_}" -conf_dir="/etc/consul/conf.d" -conf_file="watch_${watch_type}_${__object_id}.json" -state="$(cat "$__object/parameter/state")" - -# Generate json config file -( -echo "{" -printf ' "watches": [{\n' -printf ' "type": "%s"\n' "$watch_type" -cd "$__object/parameter/" -for param in *; do - case "$param" in - state) continue ;; - *) - key="$(echo "$param" | tr '-' '_')" - printf ' ,"%s": "%s"\n' "$key" "$(cat "$__object/parameter/$param")" - ;; - esac -done -# end watches -echo " }]" -# end json file -echo "}" -) | \ -require="__directory${conf_dir}" \ - __config_file "${conf_dir}/${conf_file}" \ - --owner root --group consul --mode 640 \ - --state "$state" \ - --onchange 'service consul status >/dev/null && service consul reload || true' \ - --source - diff --git a/cdist/conf/type/__consul_watch_services/parameter/default/state b/cdist/conf/type/__consul_watch_services/parameter/default/state deleted file mode 100644 index e7f6134f..00000000 --- a/cdist/conf/type/__consul_watch_services/parameter/default/state +++ /dev/null @@ -1 +0,0 @@ -present diff --git a/cdist/conf/type/__consul_watch_services/parameter/optional b/cdist/conf/type/__consul_watch_services/parameter/optional deleted file mode 100644 index bfce8305..00000000 --- a/cdist/conf/type/__consul_watch_services/parameter/optional +++ /dev/null @@ -1,3 +0,0 @@ -datacenter -state -token diff --git a/cdist/conf/type/__consul_watch_services/parameter/required b/cdist/conf/type/__consul_watch_services/parameter/required deleted file mode 100644 index 64b916c1..00000000 --- a/cdist/conf/type/__consul_watch_services/parameter/required +++ /dev/null @@ -1 +0,0 @@ -handler diff --git a/cdist/conf/type/__cron/explorer/entry b/cdist/conf/type/__cron/explorer/entry index 801861a3..c3bf02d2 100644 --- a/cdist/conf/type/__cron/explorer/entry +++ b/cdist/conf/type/__cron/explorer/entry @@ -22,9 +22,4 @@ name="$__object_name" user="$(cat "$__object/parameter/user")" -if [ -f "$__object/parameter/raw_command" ]; then - command="$(cat "$__object/parameter/command")" - crontab -u "$user" -l 2>/dev/null | grep "^$command\$" || true -else - crontab -u "$user" -l 2>/dev/null | grep "# $name\$" || true -fi +crontab -u $user -l 2>/dev/null | grep "# $name\$" || true diff --git a/cdist/conf/type/__cron/gencode-remote b/cdist/conf/type/__cron/gencode-remote index 59398058..77a63b9b 100755 --- a/cdist/conf/type/__cron/gencode-remote +++ b/cdist/conf/type/__cron/gencode-remote @@ -1,9 +1,8 @@ -#!/bin/sh -e +#!/bin/sh # # 2011 Steven Armstrong (steven-cdist at armstrong.cc) # 2013 Nico Schottelius (nico-cdist at schottelius.org) # 2013 Thomas Oettli (otho at sfs.biz) -# 2017 Daniel Heule (hda at sfs.biz) # # This file is part of cdist. # @@ -27,7 +26,7 @@ command="$(cat "$__object/parameter/command")" if [ -f "$__object/parameter/raw" ]; then raw="$(cat "$__object/parameter/raw")" - entry="$raw $command # $name" + entry="$raw $command" elif [ -f "$__object/parameter/raw_command" ]; then entry="$command" else @@ -36,9 +35,10 @@ else day_of_month="$(cat "$__object/parameter/day_of_month" 2>/dev/null || echo "*")" month="$(cat "$__object/parameter/month" 2>/dev/null || echo "*")" day_of_week="$(cat "$__object/parameter/day_of_week" 2>/dev/null || echo "*")" - entry="$minute $hour $day_of_month $month $day_of_week $command # $name" + entry="$minute $hour $day_of_month $month $day_of_week $command" fi +entry="$entry # $name" mkdir "$__object/files" echo "$entry" > "$__object/files/entry" @@ -58,7 +58,7 @@ state_should="$(cat "$__object/parameter/state" 2>/dev/null || echo "present")" # These are the old markers prefix="#cdist:__cron/$__object_id" suffix="#/cdist:__cron/$__object_id" -filter='^# DO NOT EDIT THIS FILE|^# \(.* installed on |^# \(Cron version V|^# \(Cronie version .\..\)$' +filter="^# DO NOT EDIT THIS FILE|^# \(.* installed on |^# \(Cron version V" cat << DONE crontab -u $user -l 2>/dev/null | grep -v -E "$filter" | awk -v prefix="$prefix" -v suffix="$suffix" ' { @@ -85,12 +85,7 @@ case "$state_should" in echo ") | crontab -u $user -" ;; absent) - if [ -f "$__object/parameter/raw_command" ]; then - echo "( crontab -u $user -l 2>/dev/null | grep -v -E \"$filter\" 2>/dev/null || true ) | \\" - echo "grep -v \"^$entry\\$\" | crontab -u $user -" - else - echo "( crontab -u $user -l 2>/dev/null | grep -v -E \"$filter\" 2>/dev/null || true ) | \\" - echo "grep -v \"# $name\\$\" | crontab -u $user -" - fi + echo "( crontab -u $user -l 2>/dev/null | grep -v -E \"$filter\" 2>/dev/null || true ) | \\" + echo "grep -v \"# $name\\$\" | crontab -u $user -" ;; esac diff --git a/cdist/conf/type/__cron/man.rst b/cdist/conf/type/__cron/man.text similarity index 50% rename from cdist/conf/type/__cron/man.rst rename to cdist/conf/type/__cron/man.text index d0694738..f4e80a08 100644 --- a/cdist/conf/type/__cron/man.rst +++ b/cdist/conf/type/__cron/man.text @@ -1,9 +1,11 @@ cdist-type__cron(7) =================== +Steven Armstrong + NAME ---- -cdist-type__cron - Installs and manages cron jobs +cdist-type__cron - installs and manages cron jobs DESCRIPTION @@ -13,34 +15,34 @@ This cdist type allows you to manage entries in a users crontab. REQUIRED PARAMETERS ------------------- -user +user:: The user who's crontab is edited -command +command:: The command to run. OPTIONAL PARAMETERS ------------------- -state +state:: Either present or absent. Defaults to present. -minute +minute:: See crontab(5). Defaults to * -hour +hour:: See crontab(5). Defaults to * -day_of_month +day_of_month:: See crontab(5). Defaults to * -month +month:: See crontab(5). Defaults to * -day_of_week +day_of_week:: See crontab(5). Defaults to * -raw +raw:: Take whatever the user has given instead of time and date fields. If given, all other time and date fields are ignored. Can for example be used to specify cron EXTENSIONS like reboot, yearly etc. See crontab(5) for the extensions if any that your cron implementation implements. -raw_command - Take whatever the user has given in the command and ignore everything else. +raw_command:: + Take whatever the user has given in the commmand and ignore everything else. If given, the command will be added to crontab. Can for example be used to define variables like SHELL or MAILTO. @@ -48,37 +50,31 @@ raw_command EXAMPLES -------- -.. code-block:: sh +-------------------------------------------------------------------------------- +# run Monday to Saturday at 23:15 +__cron some-id --user root --command "/path/to/script" \ + --hour 23 --minute 15 --day_of_week 1-6 - # run Monday to Saturday at 23:15 - __cron some-id --user root --command "/path/to/script" \ - --hour 23 --minute 15 --day_of_week 1-6 +# run on reboot +__cron some-id --user root --command "/path/to/script" \ + --raw @reboot - # run on reboot - __cron some-id --user root --command "/path/to/script" \ - --raw @reboot +# remove cronjob +__cron some-id --user root --command "/path/to/script" --state absent - # remove cronjob - __cron some-id --user root --command "/path/to/script" --state absent - - # define default shell - __cron some-id --user root --raw_command --command "SHELL=/bin/bash" \ - --state present +# define default shell +__cron some-id --user root --raw_command --command "SHELL=/bin/bash" \ + --state present +-------------------------------------------------------------------------------- SEE ALSO -------- -:strong:`crontab`\ (5) - - -AUTHORS -------- -Steven Armstrong +- cdist-type(7) +- crontab(5) COPYING ------- -Copyright \(C) 2011-2013 Steven Armstrong. 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. +Copyright \(C) 2011-2013 Steven Armstrong. Free use of this software is +granted under the terms of the GNU General Public License version 3 (GPLv3). diff --git a/cdist/conf/type/__cron/manifest b/cdist/conf/type/__cron/manifest old mode 100755 new mode 100644 index 53973e07..9992df25 --- a/cdist/conf/type/__cron/manifest +++ b/cdist/conf/type/__cron/manifest @@ -1,4 +1,4 @@ -#!/bin/sh -e +#!/bin/sh # # 2013 Thomas Oettli (otho at sfs.biz) # diff --git a/cdist/conf/type/__daemontools/files/init.d-svscan b/cdist/conf/type/__daemontools/files/init.d-svscan deleted file mode 100644 index 996eb4e8..00000000 --- a/cdist/conf/type/__daemontools/files/init.d-svscan +++ /dev/null @@ -1,68 +0,0 @@ -#!/bin/bash -### BEGIN INIT INFO -# Provides: svscan -# Required-Start: -# Required-Stop: -# Default-Start: 2 3 4 5 -# Default-Stop: 0 1 6 -# Short-Description: svscan -# Description: djb svscan -### END INIT INFO -# from https://gist.githubusercontent.com/pacojp/5766990/raw/2ed009ab19515afc9e58291b636d673c5ca864b3/init.d.svscan -# written by Adam McKenna -# edited by Kamila Součková - -export PATH=$PATH:/usr/local/bin - -l=/var/log/svscan - -if [ ! -d $l ]; then - mkdir $l - chown daemon $l -fi - -case "$1" in - start) - printf "Starting daemontools: " - if ! pidof svscan > /dev/null 2>&1; then - printf "svscan " - env - PATH="$PATH" svscan /service 2>&1 | setuidgid daemon multilog t /var/log/svscan & - echo "." - else - echo "already running." - fi - ;; - stop) - printf "Stopping daemontools: " - pids="$(pidof svscan)" - if [ -n "${pids}" ] - then - printf "svscan" - while [ -n "${pids}" ] - do - # shellcheck disable=SC2086 - kill ${pids} - printf "." - pids="$(pidof svscan)" - done - fi - printf " services" - for i in /service/*; do - svc -dx "$i" - printf "." - done - printf " logging " - for i in /service/*/log; do - svc -dx "$i" - printf "." - done - echo "" - ;; - restart|force-reload) - $0 stop - $0 start - ;; - *) - echo 'Usage: /etc/init.d/svscan {start|stop|restart|force-reload}' - exit 1 -esac diff --git a/cdist/conf/type/__daemontools/man.rst b/cdist/conf/type/__daemontools/man.rst deleted file mode 100644 index bc1b4d33..00000000 --- a/cdist/conf/type/__daemontools/man.rst +++ /dev/null @@ -1,54 +0,0 @@ -cdist-type__daemontools(7) -========================== - -NAME ----- -cdist-type__daemontools - Install daemontools - - -DESCRIPTION ------------ -Install djb daemontools and (optionally) an init script. - - -REQUIRED PARAMETERS -------------------- -None. - - -OPTIONAL PARAMETERS -------------------- -from-package - Package to install. Must be compatible with the original daemontools. Example: daemontools-encore. Default: daemontools. - -servicedir - Directory to scan for services. Default: `/service` - - -BOOLEAN PARAMETERS ------------------- -install-init-script - Add an init script and set it to start on boot. - - -EXAMPLES --------- - -.. code-block:: sh - - __daemontools --from-package daemontools-encore # if you prefer - -SEE ALSO --------- -:strong:`cdist-type__daemontools_service`\ (7) - -AUTHORS -------- -Kamila Součková - -COPYING -------- -Copyright \(C) 2017 Kamila Součková. 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. diff --git a/cdist/conf/type/__daemontools/manifest b/cdist/conf/type/__daemontools/manifest deleted file mode 100755 index b04c7e07..00000000 --- a/cdist/conf/type/__daemontools/manifest +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/sh -e - -pkg=$(cat "$__object/parameter/from-package") -servicedir=$(cat "$__object/parameter/servicedir") - -__package "$pkg" -__directory "$servicedir" --mode 700 - -os=$(cat "$__global/explorer/os") -init=$(cat "$__global/explorer/init") - -require="" -case $os in - freebsd) - # TODO change to __start_on_boot once it supports freebsd - __config_file /etc/rc.conf.d/svscan --source - <<-EOT - svscan_enable="YES" - svscan_servicedir="$servicedir" - EOT - require="$require __package/$pkg __directory/$servicedir __config_file/etc/rc.conf.d/svscan" \ - __process svscan --name ".*/svscan $servicedir" --start 'service svscan start' - ;; - *) - case $init in - init) - if [ -f "$__object/parameter/install-init-script" ]; then - __config_file /etc/init.d/svscan --mode 755 --source "$__type/files/init.d-svscan" - REQUIREEXTRA="__config_file/etc/init.d/svscan" - fi - require="$require $REQUIREEXTRA" __start_on_boot svscan - require="$require __package/$pkg __directory/$servicedir __start_on_boot/svscan" \ - __process svscan --name ".*/svscan $servicedir" --start 'service svscan start' - ;; - *) - echo "Your init system ($init) is not supported by this type. Submit a patch at github.com/ungleich/cdist!" - exit 1 - ;; - esac - ;; -esac diff --git a/cdist/conf/type/__daemontools/parameter/boolean b/cdist/conf/type/__daemontools/parameter/boolean deleted file mode 100644 index 99a1cefd..00000000 --- a/cdist/conf/type/__daemontools/parameter/boolean +++ /dev/null @@ -1 +0,0 @@ -install-init-script diff --git a/cdist/conf/type/__daemontools/parameter/default/from-package b/cdist/conf/type/__daemontools/parameter/default/from-package deleted file mode 100644 index 598dd40a..00000000 --- a/cdist/conf/type/__daemontools/parameter/default/from-package +++ /dev/null @@ -1 +0,0 @@ -daemontools diff --git a/cdist/conf/type/__daemontools/parameter/default/servicedir b/cdist/conf/type/__daemontools/parameter/default/servicedir deleted file mode 100644 index b74e27f6..00000000 --- a/cdist/conf/type/__daemontools/parameter/default/servicedir +++ /dev/null @@ -1 +0,0 @@ -/service diff --git a/cdist/conf/type/__daemontools/parameter/optional b/cdist/conf/type/__daemontools/parameter/optional deleted file mode 100644 index 22c0805d..00000000 --- a/cdist/conf/type/__daemontools/parameter/optional +++ /dev/null @@ -1,2 +0,0 @@ -from-package -servicedir diff --git a/cdist/conf/type/__daemontools/singleton b/cdist/conf/type/__daemontools/singleton deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/conf/type/__daemontools_service/explorer/svc b/cdist/conf/type/__daemontools_service/explorer/svc deleted file mode 100755 index 9ba462f2..00000000 --- a/cdist/conf/type/__daemontools_service/explorer/svc +++ /dev/null @@ -1,2 +0,0 @@ -#!/bin/sh -command -v svc || true diff --git a/cdist/conf/type/__daemontools_service/man.rst b/cdist/conf/type/__daemontools_service/man.rst deleted file mode 100644 index ec1d20ff..00000000 --- a/cdist/conf/type/__daemontools_service/man.rst +++ /dev/null @@ -1,72 +0,0 @@ -cdist-type__daemontools_service(7) -================================== - -NAME ----- -cdist-type__daemontools_service - Create a daemontools-compatible service dir. - - -DESCRIPTION ------------ -Create a directory structure compatible with daemontools-like service management. - -Note that svc must be present on the target system. - -The object ID will be used as the service name. - -REQUIRED PARAMETERS -------------------- -None. - -OPTIONAL PARAMETERS -------------------- -run - Command to run. exec-ing and stderr redirection will be added. One of run, run-file must be specified. - - Example: `my-program` - -run-file - File to save as /run. One of run, run-file must be specified. - - Example: - -.. code-block:: sh - - #!/bin/sh - exec 2>&1 - exec my_program - - -log-run - Command to run for log consumption. Default: `multilog t ./main` - -servicedir - Directory to install into. Default: `/service` - -BOOLEAN PARAMETERS ------------------- -None. - -EXAMPLES --------- - -.. code-block:: sh - - require="__daemontools" __daemontools_service prometheus --run "setuidgid prometheus $GOBIN/prometheus $FLAGS" - - -SEE ALSO --------- -:strong:`cdist-type__daemontools`\ (7) - - -AUTHORS -------- -Kamila Součková - -COPYING -------- -Copyright \(C) 2017 Kamila Součková. 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. diff --git a/cdist/conf/type/__daemontools_service/manifest b/cdist/conf/type/__daemontools_service/manifest deleted file mode 100755 index 78bae285..00000000 --- a/cdist/conf/type/__daemontools_service/manifest +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/sh -e - -RUN_PREFIX="#!/bin/sh -exec 2>&1 -exec " # mind the space :D - -name=$__object_id -servicedir=$(cat "$__object/parameter/servicedir") -run=$(cat "$__object/parameter/run") -runfile=$(cat "$__object/parameter/run-file") -logrun=$(cat "$__object/parameter/log-run") - -svc=$(cat "$__type/explorer/svc") - -if [ -z "$svc" ]; then - echo "svc not found! Install daemontools first: see __daemontools" - exit 1 -fi - -badusage() { - echo "__daemontools_service/$__object_id: exactly one of --run, --run-file must be set" >&2 - exit 1 -} - -[ -z "$run$runfile" ] && badusage -[ -n "$run" ] && [ -n "$runfile" ] && badusage - -__directory "$servicedir/$name/log/main" --parents - -echo "$RUN_PREFIX$run" | require="__directory/$servicedir/$name/log/main" __config_file "$servicedir/$name/run" \ - --onchange "svc -t '$servicedir/$name' 2>/dev/null" \ - --mode 755 \ - --source "${runfile:--}" - -echo "$RUN_PREFIX$logrun" | require="__directory/$servicedir/$name/log/main" __config_file "$servicedir/$name/log/run" \ - --onchange "svc -t '$servicedir/$name/log' 2>/dev/null" \ - --mode 755 \ - --source "-" diff --git a/cdist/conf/type/__daemontools_service/parameter/default/log-run b/cdist/conf/type/__daemontools_service/parameter/default/log-run deleted file mode 100644 index 80d57a74..00000000 --- a/cdist/conf/type/__daemontools_service/parameter/default/log-run +++ /dev/null @@ -1 +0,0 @@ -multilog t ./main diff --git a/cdist/conf/type/__daemontools_service/parameter/default/run b/cdist/conf/type/__daemontools_service/parameter/default/run deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/conf/type/__daemontools_service/parameter/default/run-file b/cdist/conf/type/__daemontools_service/parameter/default/run-file deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/conf/type/__daemontools_service/parameter/default/servicedir b/cdist/conf/type/__daemontools_service/parameter/default/servicedir deleted file mode 100644 index b74e27f6..00000000 --- a/cdist/conf/type/__daemontools_service/parameter/default/servicedir +++ /dev/null @@ -1 +0,0 @@ -/service diff --git a/cdist/conf/type/__daemontools_service/parameter/optional b/cdist/conf/type/__daemontools_service/parameter/optional deleted file mode 100644 index 7e54985f..00000000 --- a/cdist/conf/type/__daemontools_service/parameter/optional +++ /dev/null @@ -1,4 +0,0 @@ -log-run -run -run-file -servicedir diff --git a/cdist/conf/type/__debconf_set_selections/gencode-remote b/cdist/conf/type/__debconf_set_selections/gencode-remote index e99aef40..bb719c46 100755 --- a/cdist/conf/type/__debconf_set_selections/gencode-remote +++ b/cdist/conf/type/__debconf_set_selections/gencode-remote @@ -1,4 +1,4 @@ -#!/bin/sh -e +#!/bin/sh # # 2011-2014 Nico Schottelius (nico-cdist at schottelius.org) # diff --git a/cdist/conf/type/__debconf_set_selections/man.rst b/cdist/conf/type/__debconf_set_selections/man.rst deleted file mode 100644 index 58c25b81..00000000 --- a/cdist/conf/type/__debconf_set_selections/man.rst +++ /dev/null @@ -1,53 +0,0 @@ -cdist-type__debconf_set_selections(7) -===================================== - -NAME ----- -cdist-type__debconf_set_selections - Setup debconf selections - - -DESCRIPTION ------------ -On Debian and alike systems debconf-set-selections(1) can be used -to setup configuration parameters. - - -REQUIRED PARAMETERS -------------------- -file - Use the given filename as input for debconf-set-selections(1) - If filename is "-", read from stdin. - - -EXAMPLES --------- - -.. code-block:: sh - - # Setup configuration for nslcd - __debconf_set_selections nslcd --file /path/to/file - - # Setup configuration for nslcd from another type - __debconf_set_selections nslcd --file "$__type/files/preseed/nslcd" - - __debconf_set_selections nslcd --file - << eof - gitolite gitolite/gituser string git - eof - - -SEE ALSO --------- -:strong:`debconf-set-selections`\ (1), :strong:`cdist-type__update_alternatives`\ (7) - - -AUTHORS -------- -Nico Schottelius - - -COPYING -------- -Copyright \(C) 2011-2014 Nico Schottelius. 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. diff --git a/cdist/conf/type/__debconf_set_selections/man.text b/cdist/conf/type/__debconf_set_selections/man.text new file mode 100644 index 00000000..e36ebaa3 --- /dev/null +++ b/cdist/conf/type/__debconf_set_selections/man.text @@ -0,0 +1,50 @@ +cdist-type__debconf_set_selections(7) +===================================== +Nico Schottelius + + +NAME +---- +cdist-type__debconf_set_selections - Setup debconf selections + + +DESCRIPTION +----------- +On Debian and alike systems debconf-set-selections(1) can be used +to setup configuration parameters. + + +REQUIRED PARAMETERS +------------------- +file:: + Use the given filename as input for debconf-set-selections(1) + If filename is "-", read from stdin. + + +EXAMPLES +-------- + +-------------------------------------------------------------------------------- +# Setup configuration for nslcd +__debconf_set_selections nslcd --file /path/to/file + +# Setup configuration for nslcd from another type +__debconf_set_selections nslcd --file "$__type/files/preseed/nslcd" + +__debconf_set_selections nslcd --file - << eof +gitolite gitolite/gituser string git +eof +-------------------------------------------------------------------------------- + + +SEE ALSO +-------- +- cdist-type(7) +- cdist-type__update_alternatives(7) +- debconf-set-selections(1) + + +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). diff --git a/cdist/conf/type/__directory/explorer/stat b/cdist/conf/type/__directory/explorer/stat index 03d466ba..d8cdbb9e 100755 --- a/cdist/conf/type/__directory/explorer/stat +++ b/cdist/conf/type/__directory/explorer/stat @@ -25,51 +25,16 @@ destination="/$__object_id" os=$("$__explorer/os") case "$os" in - "freebsd"|"netbsd"|"openbsd"|"macosx") - stat -f "type: %HT + "freebsd") + # FIXME: should be something like this based on man page, but can not test + stat -f "type: %ST owner: %Du %Su group: %Dg %Sg -mode: %Lp %Sp -" "$destination" | awk '/^type/ { print tolower($0); next; } { print; }' - ;; - alpine) - stat -c "type: %F -owner: %u %U -group: %g %G -mode: %a %A +mode: %Op %Sp " "$destination" - ;; - solaris) - ls1="$( ls -ld "$destination" )" - ls2="$( ls -ldn "$destination" )" - - if [ -f "$__object/parameter/mode" ] - then mode_should="$( cat "$__object/parameter/mode" )" - fi - - # yes, it is ugly hack, but if you know better way... - if [ -z "$( find "$destination" -perm "$mode_should" )" ] - then octets=888 - else octets="$( echo "$mode_should" | sed 's/^0//' )" - fi - - case "$( echo "$ls1" | cut -c1-1 )" in - -) echo 'type: regular file' ;; - d) echo 'type: directory' ;; - esac - - echo "owner: $( echo "$ls2" \ - | awk '{print $3}' ) $( echo "$ls1" \ - | awk '{print $3}' )" - - echo "group: $( echo "$ls2" \ - | awk '{print $4}' ) $( echo "$ls1" \ - | awk '{print $4}' )" - - echo "mode: $octets $( echo "$ls1" | awk '{print $1}' )" - ;; + ;; *) - stat --printf="type: %F + stat --printf="type: %F owner: %u %U group: %g %G mode: %a %A diff --git a/cdist/conf/type/__directory/gencode-remote b/cdist/conf/type/__directory/gencode-remote index 374db47a..aba618ac 100755 --- a/cdist/conf/type/__directory/gencode-remote +++ b/cdist/conf/type/__directory/gencode-remote @@ -1,4 +1,4 @@ -#!/bin/sh -e +#!/bin/sh # # 2011-2013 Nico Schottelius (nico-cdist at schottelius.org) # 2013 Steven Armstrong (steven-cdist armstrong.cc) @@ -57,18 +57,18 @@ get_current_value() { } set_group() { - echo "chgrp $recursive '$1' '$destination'" - echo "chgrp $recursive '$1'" >> "$__messages_out" + echo chgrp $recursive \"$1\" \"$destination\" + echo chgrp $recursive $1 >> "$__messages_out" } set_owner() { - echo "chown $recursive '$1' '$destination'" - echo "chown $recursive '$1'" >> "$__messages_out" + echo chown $recursive \"$1\" \"$destination\" + echo chown $recursive $1 >> "$__messages_out" } set_mode() { - echo "chmod $recursive '$1' '$destination'" - echo "chmod $recursive '$1'" >> "$__messages_out" + echo chmod $recursive \"$1\" \"$destination\" + echo chmod $recursive $1 >> "$__messages_out" } case "$state_should" in @@ -78,10 +78,10 @@ case "$state_should" in if [ "$type" != "none" ]; then # our destination is not a directory, remove whatever is there # and then create our directory and set all attributes - echo "rm -f '$destination'" + echo rm -f "\"$destination\"" echo "remove non directory" >> "$__messages_out" fi - echo "mkdir $mkdiropt '$destination'" + echo "mkdir $mkdiropt \"$destination\"" echo "create" >> "$__messages_out" fi @@ -94,7 +94,7 @@ case "$state_should" in # change 0xxx format to xxx format => same as stat returns if [ "$attribute" = mode ]; then - value_should="$(echo "$value_should" | sed 's/^0\(...\)/\1/')" + value_should="$(echo $value_should | sed 's/^0\(...\)/\1/')" fi if [ "$set_attributes" = 1 ] || [ "$value_should" != "$value_is" ]; then @@ -105,7 +105,7 @@ case "$state_should" in ;; absent) if [ "$type" = "directory" ]; then - echo "rm -rf '$destination'" + echo rm -rf \"$destination\" echo remove >> "$__messages_out" fi ;; diff --git a/cdist/conf/type/__directory/man.rst b/cdist/conf/type/__directory/man.rst deleted file mode 100644 index 74b00afe..00000000 --- a/cdist/conf/type/__directory/man.rst +++ /dev/null @@ -1,101 +0,0 @@ -cdist-type__directory(7) -======================== - -NAME ----- -cdist-type__directory - Manage a directory - - -DESCRIPTION ------------ -This cdist type allows you to create or remove directories on the target. - - -REQUIRED PARAMETERS -------------------- -None. - - -OPTIONAL PARAMETERS -------------------- -state - 'present' or 'absent', defaults to 'present' - -group - Group to chgrp to. - -mode - Unix permissions, suitable for chmod. - -owner - User to chown to. - - -BOOLEAN PARAMETERS ------------------- -parents - Whether to create parents as well (mkdir -p behaviour). - Warning: all intermediate directory permissions default - to whatever mkdir -p does. - - Usually this means root:root, 0700. - -recursive - If supplied the chgrp and chown call will run recursively. - This does *not* influence the behaviour of chmod. - -MESSAGES --------- -chgrp - Changed group membership -chown - Changed owner -chmod - Changed mode -create - Empty directory was created -remove - Directory exists, but state is absent, directory will be removed by generated code. -remove non directory - Something other than a directory with the same name exists and was removed prior to create. - - -EXAMPLES --------- - -.. code-block:: sh - - # A silly example - __directory /tmp/foobar - - # Remove a directory - __directory /tmp/foobar --state absent - - # Ensure /etc exists correctly - __directory /etc --owner root --group root --mode 0755 - - # Create nfs service directory, including parents - __directory /home/services/nfs --parents - - # Change permissions recursively - __directory /home/services --recursive --owner root --group root - - # Setup a temp directory - __directory /local --mode 1777 - - # Take it all - __directory /home/services/kvm --recursive --parents \ - --owner root --group root --mode 0755 --state present - - -AUTHORS -------- -Nico Schottelius - - -COPYING -------- -Copyright \(C) 2011 Nico Schottelius. 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. diff --git a/cdist/conf/type/__directory/man.text b/cdist/conf/type/__directory/man.text new file mode 100644 index 00000000..a0bf8062 --- /dev/null +++ b/cdist/conf/type/__directory/man.text @@ -0,0 +1,102 @@ +cdist-type__directory(7) +======================== +Nico Schottelius + + +NAME +---- +cdist-type__directory - Manage a directory + + +DESCRIPTION +----------- +This cdist type allows you to create or remove directories on the target. + + +REQUIRED PARAMETERS +------------------- +None. + + +OPTIONAL PARAMETERS +------------------- +state:: + 'present' or 'absent', defaults to 'present' + +group:: + Group to chgrp to. + +mode:: + Unix permissions, suitable for chmod. + +owner:: + User to chown to. + + +BOOLEAN PARAMETERS +------------------ +parents:: + Whether to create parents as well (mkdir -p behaviour). + Warning: all intermediate directory permissions default + to whatever mkdir -p does. + + Usually this means root:root, 0700. + +recursive:: + If supplied the chgrp and chown call will run recursively. + This does *not* influence the behaviour of chmod. + +MESSAGES +-------- +chgrp :: + Changed group membership +chown :: + Changed owner +chmod :: + Changed mode +create:: + Empty directory was created +remove:: + Directory exists, but state is absent, directory will be removed by generated code. +remove non directory:: + Someting other than a directory with the same name exists and was removed prior to create. + + +EXAMPLES +-------- + +-------------------------------------------------------------------------------- +# A silly example +__directory /tmp/foobar + +# Remove a directory +__directory /tmp/foobar --state absent + +# Ensure /etc exists correctly +__directory /etc --owner root --group root --mode 0755 + +# Create nfs service directory, including parents +__directory /home/services/nfs --parents + +# Change permissions recursively +__directory /home/services --recursive --owner root --group root + +# Setup a temp directory +__directory /local --mode 1777 + +# Take it all +__directory /home/services/kvm --recursive --parents \ + --owner root --group root --mode 0755 --state present + +-------------------------------------------------------------------------------- + + +SEE ALSO +-------- +- cdist-type(7) + + +COPYING +------- +Copyright \(C) 2011 Nico Schottelius. Free use of this software is +granted under the terms of the GNU General Public License version 3 (GPLv3). diff --git a/cdist/conf/type/__docker/man.rst b/cdist/conf/type/__docker/man.rst deleted file mode 100644 index 718543a8..00000000 --- a/cdist/conf/type/__docker/man.rst +++ /dev/null @@ -1,55 +0,0 @@ -cdist-type__docker(7) -===================== - -NAME ----- -cdist-type__docker - install Docker CE - - -DESCRIPTION ------------ -Installs latest Docker Community Edition package. - - -REQUIRED PARAMETERS -------------------- -None. - - -OPTIONAL PARAMETERS -------------------- -state - 'present' or 'absent', defaults to 'present' -version - The specific version to install. Defaults to the special value 'latest', - meaning the version the package manager will install by default. - - -BOOLEAN PARAMETERS ------------------- -None. - - -EXAMPLES --------- - -.. code-block:: sh - - # Install docker - __docker - - # Remove docker - __docker --state absent - - # Install specific version - __docker --state present --version 18.03.0.ce - -AUTHORS -------- -Steven Armstrong - - -COPYING -------- -Copyright \(C) 2016 Steven Armstrong. Free use of this software is -granted under the terms of the GNU General Public License version 3 (GPLv3). diff --git a/cdist/conf/type/__docker/manifest b/cdist/conf/type/__docker/manifest deleted file mode 100755 index 6a57d85a..00000000 --- a/cdist/conf/type/__docker/manifest +++ /dev/null @@ -1,109 +0,0 @@ -#!/bin/sh -e -# -# 2016 Steven Armstrong (steven-cdist at armstrong.cc) -# -# This file is part of cdist. -# -# cdist is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# cdist is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with cdist. If not, see . -# - - -os=$(cat "$__global/explorer/os") -state=$(cat "$__object/parameter/state") -version=$(cat "$__object/parameter/version") - -case "$os" in - centos) - # shellcheck source=/dev/null - if (. "$__global/explorer/os_release" && [ "${VERSION_ID}" = "7" ]); then - __yum_repo docker-ce-stable \ - --name 'Docker CE Stable' \ - --baseurl "https://download.docker.com/linux/centos/7/\$basearch/stable" \ - --enabled \ - --gpgcheck 1 \ - --gpgkey 'https://download.docker.com/linux/centos/gpg' \ - --state "${state}" - if [ "$version" != "latest" ]; then - require="__yum_repo/docker-ce-stable" __package docker-ce --version "${version}" --state "${state}" - else - require="__yum_repo/docker-ce-stable" __package docker-ce --state "${state}" - fi - else - echo "CentOS version 7 is required!" >&2 - exit 1 - fi - ;; - ubuntu|debian) - if [ "${state}" = "present" ]; then - __package apt-transport-https - __package ca-certificates - __package gnupg2 - fi - __apt_key_uri docker --name "Docker Release (CE deb) " \ - --uri "https://download.docker.com/linux/${os}/gpg" --state "${state}" - - require="__apt_key_uri/docker" __apt_source docker \ - --uri "https://download.docker.com/linux/${os}" \ - --distribution "$(cat "$__global/explorer/lsb_codename")" \ - --state "${state}" \ - --component "stable" - if [ "$version" != "latest" ]; then - require="__apt_source/docker" __package docker-ce --version "${version}" --state "${state}" - else - require="__apt_source/docker" __package docker-ce --state "${state}" - fi - ;; - devuan) - os_version="$(cat "$__global/explorer/os_version")" - - case "$os_version" in - ascii) - distribution="stretch" - ;; - jessie) - distribution="jessie" - ;; - *) - echo "Your devuan release ($os_version) is currently not supported by this type (${__type##*/}).">&2 - echo "Please contribute an implementation for it if you can." >&2 - exit 1 - ;; - esac - - if [ "${state}" = "present" ]; then - __package apt-transport-https - __package ca-certificates - __package gnupg2 - fi - __apt_key_uri docker --name "Docker Release (CE deb) " \ - --uri "https://download.docker.com/linux/${os}/gpg" --state "${state}" - - require="__apt_key_uri/docker" __apt_source docker \ - --uri "https://download.docker.com/linux/${os}" \ - --distribution "${distribution}" \ - --state "${state}" \ - --component "stable" - if [ "$version" != "latest" ]; then - require="__apt_source/docker" __package docker-ce --version "${version}" --state "${state}" - else - require="__apt_source/docker" __package docker-ce --state "${state}" - fi - - ;; - *) - echo "Your operating system ($os) is currently not supported by this type (${__type##*/})." >&2 - echo "Please contribute an implementation for it if you can." >&2 - exit 1 - ;; -esac diff --git a/cdist/conf/type/__docker/parameter/default/state b/cdist/conf/type/__docker/parameter/default/state deleted file mode 100644 index e7f6134f..00000000 --- a/cdist/conf/type/__docker/parameter/default/state +++ /dev/null @@ -1 +0,0 @@ -present diff --git a/cdist/conf/type/__docker/parameter/default/version b/cdist/conf/type/__docker/parameter/default/version deleted file mode 100644 index a0f9a4b4..00000000 --- a/cdist/conf/type/__docker/parameter/default/version +++ /dev/null @@ -1 +0,0 @@ -latest diff --git a/cdist/conf/type/__docker/parameter/optional b/cdist/conf/type/__docker/parameter/optional deleted file mode 100644 index 4d595ed7..00000000 --- a/cdist/conf/type/__docker/parameter/optional +++ /dev/null @@ -1,2 +0,0 @@ -state -version diff --git a/cdist/conf/type/__docker/singleton b/cdist/conf/type/__docker/singleton deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/conf/type/__docker_compose/gencode-remote b/cdist/conf/type/__docker_compose/gencode-remote deleted file mode 100755 index 77fc2fdf..00000000 --- a/cdist/conf/type/__docker_compose/gencode-remote +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/sh -e -# -# 2016 Dominique Roux (dominique.roux at ungleich.ch) -# -# 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 . -# - -# Variables -version="$(cat "$__object/parameter/version")" -state="$(cat "$__object/parameter/state")" - -if [ "${state}" = "present" ]; then - # Download docker-compose file - #shellcheck disable=SC2016 - echo 'curl -L "https://github.com/docker/compose/releases/download/'"${version}"'/docker-compose-$(uname -s)-$(uname -m)" -o /tmp/docker-compose' - echo 'mv /tmp/docker-compose /usr/local/bin/docker-compose' - # Change permissions - echo 'chmod +x /usr/local/bin/docker-compose' -fi diff --git a/cdist/conf/type/__docker_compose/man.rst b/cdist/conf/type/__docker_compose/man.rst deleted file mode 100644 index 7386e737..00000000 --- a/cdist/conf/type/__docker_compose/man.rst +++ /dev/null @@ -1,58 +0,0 @@ -cdist-type__docker_compose(7) -============================= - -NAME ----- -cdist-type__docker_compose - install docker-compose - - -DESCRIPTION ------------ -Installs docker-compose package. -State 'absent' will not remove docker binary itself, -only docker-compose binary will be removed - - -REQUIRED PARAMETERS -------------------- -None. - - -OPTIONAL PARAMETERS -------------------- -version - Define docker_compose version, defaults to "1.9.0" - -state - 'present' or 'absent', defaults to 'present' - - -BOOLEAN PARAMETERS ------------------- -None. - - -EXAMPLES --------- - -.. code-block:: sh - - # Install docker-compose - __docker_compose - - # Install version 1.9.0-rc4 - __docker_compose --version 1.9.0-rc4 - - # Remove docker-compose - __docker_compose --state absent - - -AUTHORS -------- -Dominique Roux - - -COPYING -------- -Copyright \(C) 2016 Dominique Roux. Free use of this software is -granted under the terms of the GNU General Public License version 3 or later (GPLv3+). diff --git a/cdist/conf/type/__docker_compose/manifest b/cdist/conf/type/__docker_compose/manifest deleted file mode 100755 index f7de3a76..00000000 --- a/cdist/conf/type/__docker_compose/manifest +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/sh -e -# -# 2016 Dominique Roux (dominique.roux at ungleich.ch) -# -# 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 . -# -# - -state="$(cat "$__object/parameter/state")" - -# Needed packages -if [ "${state}" = "present" ]; then - __docker - __package curl -elif [ "${state}" = "absent" ]; then - __file /usr/local/bin/docker-compose --state absent -else - echo "Unknown state: ${state}" >&2 - exit 1 -fi diff --git a/cdist/conf/type/__docker_compose/parameter/default/state b/cdist/conf/type/__docker_compose/parameter/default/state deleted file mode 100644 index e7f6134f..00000000 --- a/cdist/conf/type/__docker_compose/parameter/default/state +++ /dev/null @@ -1 +0,0 @@ -present diff --git a/cdist/conf/type/__docker_compose/parameter/default/version b/cdist/conf/type/__docker_compose/parameter/default/version deleted file mode 100644 index 850e7424..00000000 --- a/cdist/conf/type/__docker_compose/parameter/default/version +++ /dev/null @@ -1 +0,0 @@ -1.14.0 diff --git a/cdist/conf/type/__docker_compose/parameter/optional b/cdist/conf/type/__docker_compose/parameter/optional deleted file mode 100644 index 4d595ed7..00000000 --- a/cdist/conf/type/__docker_compose/parameter/optional +++ /dev/null @@ -1,2 +0,0 @@ -state -version diff --git a/cdist/conf/type/__docker_compose/singleton b/cdist/conf/type/__docker_compose/singleton deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/conf/type/__docker_config/explorer/config-data b/cdist/conf/type/__docker_config/explorer/config-data deleted file mode 100755 index b4bb0e11..00000000 --- a/cdist/conf/type/__docker_config/explorer/config-data +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/sh -e -# -# 2018 Ľubomír Kučera -# -# 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 . -# - -docker config inspect "${__object_id:?}" --format '{{json .Spec.Data}}' \ - 2>/dev/null | tr -d '"' | base64 -d diff --git a/cdist/conf/type/__docker_config/explorer/config-exists b/cdist/conf/type/__docker_config/explorer/config-exists deleted file mode 100755 index 58c207d4..00000000 --- a/cdist/conf/type/__docker_config/explorer/config-exists +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/sh -e -# -# 2018 Ľubomír Kučera -# -# This file is part of cdist. -# -# cdist is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# cdist is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with cdist. If not, see . -# - -if docker config ls | grep -q " ${__object_id:?} "; then - echo yes -else - echo no -fi diff --git a/cdist/conf/type/__docker_config/gencode-remote b/cdist/conf/type/__docker_config/gencode-remote deleted file mode 100755 index 65497b7e..00000000 --- a/cdist/conf/type/__docker_config/gencode-remote +++ /dev/null @@ -1,69 +0,0 @@ -#!/bin/sh -e -# -# 2018 Ľubomír Kučera -# -# 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 . -# - -config="${__object_id:?}" -config_exists=$(cat "${__object:?}/explorer/config-exists") -state=$(cat "${__object:?}/parameter/state") - -case "${state}" in - absent) - if [ "${config_exists}" != "yes" ]; then - exit 0 - fi - - echo "docker config rm \"${config}\"" - ;; - present) - source=$(cat "${__object}/parameter/source") - - if [ -z "${source}" ]; then - exit 0 - fi - - if [ "${source}" = "-" ]; then - source="${__object}/stdin" - fi - - if [ "${config_exists}" = "yes" ]; then - if cmp -s "${source}" "${__object}/explorer/config-data"; then - exit 0 - else - echo "docker config rm \"${config}\"" - fi - fi - - cat <<-EOF - source_file="\$(mktemp cdist.XXXXXXXXXX)" - - base64 -d > "\${source_file}" << eof - $(base64 "${source}") - eof - - docker config create "${config}" "\${source_file}" - - rm "\${source_file}" - EOF - ;; - *) - echo "Unsupported state: ${state}" >&2 - - exit 1 - ;; -esac diff --git a/cdist/conf/type/__docker_config/man.rst b/cdist/conf/type/__docker_config/man.rst deleted file mode 100644 index 7c74c8af..00000000 --- a/cdist/conf/type/__docker_config/man.rst +++ /dev/null @@ -1,55 +0,0 @@ -cdist-type__docker_config(7) -============================ - -NAME ----- - -cdist-type__docker_config - Manage Docker configs - -DESCRIPTION ------------ - -This type manages Docker configs. - -OPTIONAL PARAMETERS -------------------- - -source - Path to the source file. If it is '-' (dash), read standard input. - -state - 'present' or 'absent', defaults to 'present' where: - - present - if the config does not exist, it is created - absent - the config is removed - -CAVEATS -------- - -Since Docker configs cannot be updated once created, this type tries removing -and recreating the config if it changes. If the config is used by a service at -the time of removing, then this type will fail. - -EXAMPLES --------- - -.. code-block:: sh - - # Creates "foo" config from "bar" source file - __docker_config foo --source bar - - -AUTHORS -------- - -Ľubomír Kučera - -COPYING -------- - -Copyright \(C) 2018 Ľubomír Kučera. 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. diff --git a/cdist/conf/type/__docker_config/parameter/default/source b/cdist/conf/type/__docker_config/parameter/default/source deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/conf/type/__docker_config/parameter/default/state b/cdist/conf/type/__docker_config/parameter/default/state deleted file mode 100644 index e7f6134f..00000000 --- a/cdist/conf/type/__docker_config/parameter/default/state +++ /dev/null @@ -1 +0,0 @@ -present diff --git a/cdist/conf/type/__docker_config/parameter/optional b/cdist/conf/type/__docker_config/parameter/optional deleted file mode 100644 index d77f3048..00000000 --- a/cdist/conf/type/__docker_config/parameter/optional +++ /dev/null @@ -1,2 +0,0 @@ -source -state diff --git a/cdist/conf/type/__docker_secret/explorer/secret-exists b/cdist/conf/type/__docker_secret/explorer/secret-exists deleted file mode 100755 index 1405f8bc..00000000 --- a/cdist/conf/type/__docker_secret/explorer/secret-exists +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/sh -e -# -# 2018 Ľubomír Kučera -# -# This file is part of cdist. -# -# cdist is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# cdist is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with cdist. If not, see . -# - -if docker secret ls | grep -q " ${__object_id:?} "; then - echo yes -else - echo no -fi diff --git a/cdist/conf/type/__docker_secret/gencode-remote b/cdist/conf/type/__docker_secret/gencode-remote deleted file mode 100755 index c75e91d9..00000000 --- a/cdist/conf/type/__docker_secret/gencode-remote +++ /dev/null @@ -1,65 +0,0 @@ -#!/bin/sh -e -# -# 2018 Ľubomír Kučera -# -# 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 . -# - -secret="${__object_id:?}" -secret_exists=$(cat "${__object:?}/explorer/secret-exists") -state=$(cat "${__object:?}/parameter/state") - -case "${state}" in - absent) - if [ "${secret_exists}" != "yes" ]; then - exit 0 - fi - - echo "docker secret rm ${secret}" - ;; - present) - if [ "${secret_exists}" = "yes" ]; then - exit 0 - fi - - source=$(cat "${__object}/parameter/source") - - if [ -z "${source}" ]; then - exit 0 - fi - - if [ "${source}" = "-" ]; then - source="${__object}/stdin" - fi - - cat <<-EOF - source_file="\$(mktemp cdist.XXXXXXXXXX)" - - base64 -d > "\${source_file}" << eof - $(base64 "${source}") - eof - - docker secret create "${secret}" "\${source_file}" - - rm "\${source_file}" - EOF - ;; - *) - echo "Unsupported state: ${state}" >&2 - - exit 1 - ;; -esac diff --git a/cdist/conf/type/__docker_secret/man.rst b/cdist/conf/type/__docker_secret/man.rst deleted file mode 100644 index 7fe69623..00000000 --- a/cdist/conf/type/__docker_secret/man.rst +++ /dev/null @@ -1,54 +0,0 @@ -cdist-type__docker_secret(7) -============================ - -NAME ----- - -cdist-type__docker_secret - Manage Docker secrets - -DESCRIPTION ------------ - -This type manages Docker secrets. - -OPTIONAL PARAMETERS -------------------- - -source - Path to the source file. If it is '-' (dash), read standard input. - -state - 'present' or 'absent', defaults to 'present' where: - - present - if the secret does not exist, it is created - absent - the secret is removed - -CAVEATS -------- - -Since Docker secrets cannot be updated once created, this type takes no action -if the specified secret already exists. - -EXAMPLES --------- - -.. code-block:: sh - - # Creates "foo" secret from "bar" source file - __docker_secret foo --source bar - - -AUTHORS -------- - -Ľubomír Kučera - -COPYING -------- - -Copyright \(C) 2018 Ľubomír Kučera. 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. diff --git a/cdist/conf/type/__docker_secret/parameter/default/source b/cdist/conf/type/__docker_secret/parameter/default/source deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/conf/type/__docker_secret/parameter/default/state b/cdist/conf/type/__docker_secret/parameter/default/state deleted file mode 100644 index e7f6134f..00000000 --- a/cdist/conf/type/__docker_secret/parameter/default/state +++ /dev/null @@ -1 +0,0 @@ -present diff --git a/cdist/conf/type/__docker_secret/parameter/optional b/cdist/conf/type/__docker_secret/parameter/optional deleted file mode 100644 index d77f3048..00000000 --- a/cdist/conf/type/__docker_secret/parameter/optional +++ /dev/null @@ -1,2 +0,0 @@ -source -state diff --git a/cdist/conf/type/__docker_stack/explorer/stack-exists b/cdist/conf/type/__docker_stack/explorer/stack-exists deleted file mode 100755 index 4f511821..00000000 --- a/cdist/conf/type/__docker_stack/explorer/stack-exists +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/sh -e -# -# 2018 Ľubomír Kučera -# -# This file is part of cdist. -# -# cdist is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# cdist is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with cdist. If not, see . -# - -if docker stack ls | grep -q "^${__object_id:?} "; then - echo 1 -else - echo 0 -fi diff --git a/cdist/conf/type/__docker_stack/gencode-remote b/cdist/conf/type/__docker_stack/gencode-remote deleted file mode 100755 index 586271d0..00000000 --- a/cdist/conf/type/__docker_stack/gencode-remote +++ /dev/null @@ -1,63 +0,0 @@ -#!/bin/sh -e -# -# 2018 Ľubomír Kučera -# -# 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 . -# - -stack="${__object_id:?}" -state=$(cat "${__object:?}/parameter/state") - -case "${state}" in - absent) - stack_exists=$(cat "${__object:?}/explorer/stack-exists") - - if [ "${stack_exists}" -ne 1 ]; then - exit 0 - fi - - echo "docker stack rm ${stack}" - ;; - present) - compose_file=$(cat "${__object}/parameter/compose-file") - - if [ -z "${compose_file}" ]; then - exit 0 - fi - - if [ "${compose_file}" = "-" ]; then - compose_file="${__object}/stdin" - fi - - cat <<-EOF - compose_file="\$(mktemp cdist.XXXXXXXXXX)" - - base64 -d > "\${compose_file}" << eof - $(base64 "${compose_file}") - eof - - docker stack deploy --compose-file "\${compose_file}" \ - --prune --with-registry-auth ${stack} - - rm "\${compose_file}" - EOF - ;; - *) - echo "Unsupported state: ${state}" >&2 - - exit 1 - ;; -esac diff --git a/cdist/conf/type/__docker_stack/man.rst b/cdist/conf/type/__docker_stack/man.rst deleted file mode 100644 index d0597c25..00000000 --- a/cdist/conf/type/__docker_stack/man.rst +++ /dev/null @@ -1,54 +0,0 @@ -cdist-type__docker_stack(7) -=========================== - -NAME ----- - -cdist-type__docker_stack - Manage Docker stacks - -DESCRIPTION ------------ - -This type manages service stacks. - -.. note:: - Since there is no easy way to tell whether a stack needs to be updated, - `docker stack deploy` is being run every time this type is invoked. - However, it does not mean this type is not idempotent. If Docker does not - detect changes, the existing stack will not be updated. - -OPTIONAL PARAMETERS -------------------- - -compose-file - Path to the compose file. If it is '-' (dash), read standard input. - -state - 'present' or 'absent', defaults to 'present' where: - - present - the stack is deployed - absent - the stack is removed - -EXAMPLES --------- - -.. code-block:: sh - - # Deploys 'foo' stack defined in 'docker-compose.yml' compose file - __docker_stack foo --compose-file docker-compose.yml - - -AUTHORS -------- - -Ľubomír Kučera - -COPYING -------- - -Copyright \(C) 2018 Ľubomír Kučera. 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. diff --git a/cdist/conf/type/__docker_stack/parameter/default/compose-file b/cdist/conf/type/__docker_stack/parameter/default/compose-file deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/conf/type/__docker_stack/parameter/default/state b/cdist/conf/type/__docker_stack/parameter/default/state deleted file mode 100644 index e7f6134f..00000000 --- a/cdist/conf/type/__docker_stack/parameter/default/state +++ /dev/null @@ -1 +0,0 @@ -present diff --git a/cdist/conf/type/__docker_stack/parameter/optional b/cdist/conf/type/__docker_stack/parameter/optional deleted file mode 100644 index b3457bd3..00000000 --- a/cdist/conf/type/__docker_stack/parameter/optional +++ /dev/null @@ -1,2 +0,0 @@ -compose-file -state diff --git a/cdist/conf/type/__docker_swarm/explorer/swarm-state b/cdist/conf/type/__docker_swarm/explorer/swarm-state deleted file mode 100755 index 2c9fd598..00000000 --- a/cdist/conf/type/__docker_swarm/explorer/swarm-state +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/sh -e -# -# 2018 Ľubomír Kučera -# -# 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 . -# - -docker info 2>/dev/null | grep '^ *Swarm: ' | awk '{print $2}' diff --git a/cdist/conf/type/__docker_swarm/gencode-remote b/cdist/conf/type/__docker_swarm/gencode-remote deleted file mode 100755 index 4b199a02..00000000 --- a/cdist/conf/type/__docker_swarm/gencode-remote +++ /dev/null @@ -1,46 +0,0 @@ -#!/bin/sh -e -# -# 2018 Ľubomír Kučera -# -# 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 . -# - -state=$(cat "${__object:?}/parameter/state") -swarm_state="$(cat "${__object}/explorer/swarm-state")" - -if [ -z "${swarm_state}" ]; then - echo "Unable to determine Swarm state. Is compatible version of Docker installed?" >&2 - - exit 1 -fi - -case "${state}" in - absent) - if [ "${swarm_state}" = "active" ]; then - echo "docker swarm leave --force" - fi - ;; - present) - if [ "${swarm_state}" = "inactive" ]; then - echo "docker swarm init" - fi - ;; - *) - echo "Unsupported state: ${state}" >&2 - - exit 1 - ;; -esac diff --git a/cdist/conf/type/__docker_swarm/man.rst b/cdist/conf/type/__docker_swarm/man.rst deleted file mode 100644 index 4dc408f0..00000000 --- a/cdist/conf/type/__docker_swarm/man.rst +++ /dev/null @@ -1,49 +0,0 @@ -cdist-type__docker_swarm(7) -=========================== - -NAME ----- - -cdist-type__docker_swarm - Manage Swarm - -DESCRIPTION ------------ - -This type can initialize Docker swarm mode. For more information about swarm -mode, see `Swarm mode overview `_. - -OPTIONAL PARAMETERS -------------------- - -state - 'present' or 'absent', defaults to 'present' where: - - present - Swarm is initialized - absent - Swarm is left - -EXAMPLES --------- - -.. code-block:: sh - - # Initializes a swarm - __docker_swarm - - # Leaves a swarm - __docker_swarm --state absent - - -AUTHORS -------- - -Ľubomír Kučera - -COPYING -------- - -Copyright \(C) 2018 Ľubomír Kučera. 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. diff --git a/cdist/conf/type/__docker_swarm/parameter/default/state b/cdist/conf/type/__docker_swarm/parameter/default/state deleted file mode 100644 index e7f6134f..00000000 --- a/cdist/conf/type/__docker_swarm/parameter/default/state +++ /dev/null @@ -1 +0,0 @@ -present diff --git a/cdist/conf/type/__docker_swarm/parameter/optional b/cdist/conf/type/__docker_swarm/parameter/optional deleted file mode 100644 index ff72b5c7..00000000 --- a/cdist/conf/type/__docker_swarm/parameter/optional +++ /dev/null @@ -1 +0,0 @@ -state diff --git a/cdist/conf/type/__docker_swarm/singleton b/cdist/conf/type/__docker_swarm/singleton deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/conf/type/__dog_vdi/gencode-remote b/cdist/conf/type/__dog_vdi/gencode-remote old mode 100755 new mode 100644 index 9d49506c..56e4108a --- a/cdist/conf/type/__dog_vdi/gencode-remote +++ b/cdist/conf/type/__dog_vdi/gencode-remote @@ -1,4 +1,4 @@ -#!/bin/sh -e +#!/bin/sh # # 2014 Nico Schottelius (nico-cdist at schottelius.org) # diff --git a/cdist/conf/type/__dog_vdi/man.rst b/cdist/conf/type/__dog_vdi/man.rst deleted file mode 100644 index 4be1920d..00000000 --- a/cdist/conf/type/__dog_vdi/man.rst +++ /dev/null @@ -1,59 +0,0 @@ -cdist-type__dog_vdi(7) -====================== - -NAME ----- -cdist-type__dog_vdi - Manage Sheepdog VM images - - -DESCRIPTION ------------ -The dog program is used to create images for sheepdog -to be used in qemu. - - -OPTIONAL PARAMETERS -------------------- -state - Either "present" or "absent", defaults to "present" -size - Size of the image in "dog vdi" compatible units. - - Required if state is "present". - - - -EXAMPLES --------- - -.. code-block:: sh - - # Create a 50G size image - __dog_vdi nico-privat.sky.ungleich.ch --size 50G - - # Create a 50G size image (more explicit) - __dog_vdi nico-privat.sky.ungleich.ch --size 50G --state present - - # Remove image - __dog_vdi nico-privat.sky.ungleich.ch --state absent - - # Remove image - keeping --size is ok - __dog_vdi nico-privat.sky.ungleich.ch --size 50G --state absent - - -SEE ALSO --------- -:strong:`qemu`\ (1), :strong:`dog`\ (8) - - -AUTHORS -------- -Nico Schottelius - - -COPYING -------- -Copyright \(C) 2014 Nico Schottelius. 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. diff --git a/cdist/conf/type/__dog_vdi/man.text b/cdist/conf/type/__dog_vdi/man.text new file mode 100644 index 00000000..e3453ba7 --- /dev/null +++ b/cdist/conf/type/__dog_vdi/man.text @@ -0,0 +1,56 @@ +cdist-type__dog_vdi(7) +====================== +Nico Schottelius + + +NAME +---- +cdist-type__dog_vdi - Manage Sheepdog VM images + + +DESCRIPTION +----------- +The dog program is used to create images for sheepdog +to be used in qemu. + + +OPTIONAL PARAMETERS +------------------- +state:: + Either "present" or "absent", defaults to "present" +size:: + Size of the image in "dog vdi" compatible units. + + Required if state is "present". + + + +EXAMPLES +-------- + +-------------------------------------------------------------------------------- +# Create a 50G size image +__dog_vdi nico-privat.sky.ungleich.ch --size 50G + +# Create a 50G size image (more explicit) +__dog_vdi nico-privat.sky.ungleich.ch --size 50G --state present + +# Remove image +__dog_vdi nico-privat.sky.ungleich.ch --state absent + +# Remove image - keeping --size is ok +__dog_vdi nico-privat.sky.ungleich.ch --size 50G --state absent +-------------------------------------------------------------------------------- + + +SEE ALSO +-------- +- cdist-type(7) +- dog(8) +- qemu(1) + + +COPYING +------- +Copyright \(C) 2014 Nico Schottelius. Free use of this software is +granted under the terms of the GNU General Public License version 3 (GPLv3). diff --git a/cdist/conf/type/__dog_vdi/manifest b/cdist/conf/type/__dog_vdi/manifest old mode 100755 new mode 100644 index 869bdede..be327a3a --- a/cdist/conf/type/__dog_vdi/manifest +++ b/cdist/conf/type/__dog_vdi/manifest @@ -1,4 +1,4 @@ -#!/bin/sh -e +#!/bin/sh # # 2014 Nico Schottelius (nico-cdist at schottelius.org) # diff --git a/cdist/conf/type/__dot_file/explorer/home b/cdist/conf/type/__dot_file/explorer/home deleted file mode 100755 index 08d941bf..00000000 --- a/cdist/conf/type/__dot_file/explorer/home +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/sh -# Copyright (C) 2016 Dmitry Bogatov - -# Author: Dmitry Bogatov - -# This program 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. - -# This program 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 this program. If not, see . -set -eu - -user="$(cat "${__object}/parameter/user")" - -if command -v getent >/dev/null 2>&1; then - line=$(getent passwd "${user}") -else - line=$(grep "^${user}:" /etc/passwd) -fi -printf '%s' "$line" | cut -d: -f6 diff --git a/cdist/conf/type/__dot_file/explorer/primary_group b/cdist/conf/type/__dot_file/explorer/primary_group deleted file mode 100755 index 30b303ac..00000000 --- a/cdist/conf/type/__dot_file/explorer/primary_group +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/sh -# Copyright (C) 2016 Dmitry Bogatov - -# Author: Dmitry Bogatov - -# This program 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. - -# This program 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 this program. If not, see . -set -eu - -user="$(cat "${__object}/parameter/user")" -id -gn "${user}" diff --git a/cdist/conf/type/__dot_file/man.rst b/cdist/conf/type/__dot_file/man.rst deleted file mode 100644 index ae65eb95..00000000 --- a/cdist/conf/type/__dot_file/man.rst +++ /dev/null @@ -1,71 +0,0 @@ -cdist-type__dot_file(7) -======================== - -NAME ----- - -cdist-type__dot_file - install file under user's home directory - -DESCRIPTION ------------ - -This type installs a file (=\ *__object_id*) under user's home directory, -providing a way to install per-user configuration files. File owner -and group is deduced from user, for who file is installed. - -Unlike regular __file type, you do not need make any assumptions, -where user's home directory is. - -REQUIRED PARAMETERS -------------------- - -user - User, for who file is installed - -OPTIONAL PARAMETERS -------------------- - -mode - forwarded to :strong:`__file` type - -state - forwarded to :strong:`__file` type - -source - forwarded to :strong:`__file` type - -MESSAGES --------- - -This type inherits all messages from :strong:`file` type, and do not add -any new. - -EXAMPLES --------- - -.. code-block:: sh - - # Install .forward file for user 'alice'. Since state is 'present', - # user is not meant to edit this file, all changes will be overridden. - # It is good idea to put warning about it in file itself. - __dot_file .forward --user alice --source "$__files/forward" - - # Install .muttrc for user 'bob', if not already present. User can safely - # edit it, his changes will not be overwritten. - __dot_file .muttrc --user bob --source "$__files/recommended_mutt_config" --state exists - - - # Install default xmonad config for user 'eve'. Parent directory is created automatically. - __dot_file .xmonad/xmonad.hs --user eve --state exists --source "$__files/xmonad.hs" - -SEE ALSO --------- - -**cdist-type__file**\ (7) - -COPYING -------- - -Copyright (C) 2015 Dmitry Bogatov. Free use of this software is granted -under the terms of the GNU General Public License version 3 or later -(GPLv3+). diff --git a/cdist/conf/type/__dot_file/manifest b/cdist/conf/type/__dot_file/manifest deleted file mode 100755 index 5e4957e5..00000000 --- a/cdist/conf/type/__dot_file/manifest +++ /dev/null @@ -1,65 +0,0 @@ -#!/bin/sh -e -# -# Copyright (C) 2016 Bogatov Dmitry -# -# This program 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. -# -# This program 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 this program. If not, see . -set -eu - -user="$(cat "${__object}/parameter/user")" -home="$(cat "${__object}/explorer/home")" -primary_group="$(cat "${__object}/explorer/primary_group")" - -# Create parent directory. Type __directory has flag 'parents', but it -# will leave us with root-owned directory in user home, which is not -# acceptable. So we create parent directories one-by-one. XXX: maybe -# it should be fixed in '__directory'? -set -- -subpath=${__object_id} -while subpath="$(dirname "${subpath}")" ; do - [ "${subpath}" = . ] && break - set -- "${subpath}" "$@" -done -unset subpath - -export CDIST_ORDER_DEPENDENCY -for dir ; do - __directory "${home}/${dir}" \ - --group "${primary_group}" \ - --owner "${user}" -done - -# These parameters are forwarded to __file type. 'mode' is always -# present, since it have been given default. - -set -- -for p in state mode source ; do - if [ -f "${__object}/parameter/${p}" ] ; then - value="$(cat "${__object}/parameter/${p}")" - set -- "$@" "--${p}" "${value}" - unset value - fi -done - -# If source is `-' we can't just forward it, since stdin is already -# captured by __dot_file. So, we replace '-' with "$__object/stdin". -# -# It means that it is possible for __file to receive --source -# parameter twice, but, since latest wins, it is okay. -source="$(cat "${__object}/parameter/source")" -if [ "${source}" = "-" ] ; then - set -- "$@" --source "${__object}/stdin" -fi -unset source - -__file "${home}/${__object_id}" --owner "$user" --group "$primary_group" "$@" diff --git a/cdist/conf/type/__dot_file/parameter/default/mode b/cdist/conf/type/__dot_file/parameter/default/mode deleted file mode 100644 index e9f960cf..00000000 --- a/cdist/conf/type/__dot_file/parameter/default/mode +++ /dev/null @@ -1 +0,0 @@ -600 diff --git a/cdist/conf/type/__dot_file/parameter/optional b/cdist/conf/type/__dot_file/parameter/optional deleted file mode 100644 index ccab9fa6..00000000 --- a/cdist/conf/type/__dot_file/parameter/optional +++ /dev/null @@ -1,3 +0,0 @@ -state -mode -source diff --git a/cdist/conf/type/__dot_file/parameter/required b/cdist/conf/type/__dot_file/parameter/required deleted file mode 100644 index 4eb8387f..00000000 --- a/cdist/conf/type/__dot_file/parameter/required +++ /dev/null @@ -1 +0,0 @@ -user diff --git a/cdist/conf/type/__file/explorer/stat b/cdist/conf/type/__file/explorer/stat index 13c1c208..52570379 100755 --- a/cdist/conf/type/__file/explorer/stat +++ b/cdist/conf/type/__file/explorer/stat @@ -1,7 +1,6 @@ #!/bin/sh # # 2013 Steven Armstrong (steven-cdist armstrong.cc) -# 2019 Nico Schottelius (nico-cdist at schottelius.org) # # This file is part of cdist. # @@ -26,56 +25,16 @@ destination="/$__object_id" os=$("$__explorer/os") case "$os" in - "freebsd"|"netbsd"|"openbsd"|"macosx") - stat -f "type: %HT + "freebsd"|"openbsd") + # FIXME: should be something like this based on man page, but can not test + stat -f "type: %ST owner: %Du %Su group: %Dg %Sg -mode: %Lp %Sp +mode: %Op %Sp size: %Dz links: %Dl -" "$destination" | awk '/^type/ { print tolower($0); next; } { print; }' - ;; - alpine) - # busybox stat - stat -c "type: %F -owner: %u %U -group: %g %G -mode: %a %A -size: %s -links: %h " "$destination" - ;; - solaris) - ls1="$( ls -ld "$destination" )" - ls2="$( ls -ldn "$destination" )" - - if [ -f "$__object/parameter/mode" ] - then mode_should="$( cat "$__object/parameter/mode" )" - fi - - # yes, it is ugly hack, but if you know better way... - if [ -z "$( find "$destination" -perm "$mode_should" )" ] - then octets=888 - else octets="$( echo "$mode_should" | sed 's/^0//' )" - fi - - case "$( echo "$ls1" | cut -c1-1 )" in - -) echo 'type: regular file' ;; - d) echo 'type: directory' ;; - esac - - echo "owner: $( echo "$ls2" \ - | awk '{print $3}' ) $( echo "$ls1" \ - | awk '{print $3}' )" - - echo "group: $( echo "$ls2" \ - | awk '{print $4}' ) $( echo "$ls1" \ - | awk '{print $4}' )" - - echo "mode: $octets $( echo "$ls1" | awk '{print $1}' )" - echo "size: $( echo "$ls1" | awk '{print $5}' )" - echo "links: $( echo "$ls1" | awk '{print $2}' )" - ;; + ;; *) stat --printf="type: %F owner: %u %U @@ -84,5 +43,5 @@ mode: %a %A size: %s links: %h " "$destination" - ;; + ;; esac diff --git a/cdist/conf/type/__file/gencode-local b/cdist/conf/type/__file/gencode-local index fb9f9a92..601705c8 100755 --- a/cdist/conf/type/__file/gencode-local +++ b/cdist/conf/type/__file/gencode-local @@ -1,4 +1,4 @@ -#!/bin/sh -e +#!/bin/sh # # 2011-2012 Nico Schottelius (nico-cdist at schottelius.org) # 2013 Steven Armstrong (steven-cdist armstrong.cc) @@ -23,31 +23,14 @@ destination="/$__object_id" state_should="$(cat "$__object/parameter/state")" type="$(cat "$__object/explorer/type")" -[ "$state_should" = "exists" ] && [ "$type" = "file" ] && exit 0 # nothing to do - -if [ "$state_should" = "pre-exists" ]; then - if [ -f "$__object/parameter/source" ]; then - echo "--source cannot be used with --state pre-exists" - exit 1 - fi - - if [ "$type" = "file" ]; then - exit 0 # nothing to do - else - echo "File \"$destination\" does not exist" - exit 1 - fi -fi +[ "$state_should" = "exists" -a "$type" = "file" ] && exit 0 # nothing to do upload_file= create_file= -if [ "$state_should" = "present" ] || [ "$state_should" = "exists" ]; then +if [ "$state_should" = "present" -o "$state_should" = "exists" ]; then if [ ! -f "$__object/parameter/source" ]; then - remote_stat="$(cat "$__object/explorer/stat")" - if [ -z "$remote_stat" ]; then - create_file=1 - echo create >> "$__messages_out" - fi + create_file=1 + echo create >> "$__messages_out" else source="$(cat "$__object/parameter/source")" if [ "$source" = "-" ]; then @@ -70,7 +53,7 @@ if [ "$state_should" = "present" ] || [ "$state_should" = "exists" ]; then fi fi fi - if [ "$create_file" ] || [ "$upload_file" ]; then + if [ "$create_file" -o "$upload_file" ]; then # tell gencode-remote that we created or uploaded a file and that it must # set all attributes no matter what the explorer retreived mkdir "$__object/files" @@ -83,15 +66,8 @@ destination_upload="\$($__remote_exec $__target_host "mktemp $tempfile_template" DONE if [ "$upload_file" ]; then echo upload >> "$__messages_out" - # IPv6 fix - if echo "${__target_host}" | grep -q -E '^[0-9a-fA-F:]+$' - then - my_target_host="[${__target_host}]" - else - my_target_host="${__target_host}" - fi cat << DONE -$__remote_copy "$source" "${my_target_host}:\$destination_upload" +$__remote_copy $source ${__target_host}:\$destination_upload DONE fi # move uploaded file into place diff --git a/cdist/conf/type/__file/gencode-remote b/cdist/conf/type/__file/gencode-remote index b04c471e..dcf3857b 100755 --- a/cdist/conf/type/__file/gencode-remote +++ b/cdist/conf/type/__file/gencode-remote @@ -1,4 +1,4 @@ -#!/bin/sh -e +#!/bin/sh # # 2011-2013 Nico Schottelius (nico-cdist at schottelius.org) # 2013 Steven Armstrong (steven-cdist armstrong.cc) @@ -23,7 +23,7 @@ destination="/$__object_id" state_should="$(cat "$__object/parameter/state")" type="$(cat "$__object/explorer/type")" stat_file="$__object/explorer/stat" -fire_onchange='' + get_current_value() { if [ -s "$stat_file" ]; then @@ -43,25 +43,23 @@ get_current_value() { } set_group() { - echo "chgrp '$1' '$destination'" - echo "chgrp '$1'" >> "$__messages_out" - fire_onchange=1 + echo chgrp \"$1\" \"$destination\" + echo chgrp $1 >> "$__messages_out" } set_owner() { - echo "chown '$1' '$destination'" - echo "chown '$1'" >> "$__messages_out" - fire_onchange=1 + echo chown \"$1\" \"$destination\" + echo chown $1 >> "$__messages_out" } set_mode() { - echo "chmod '$1' '$destination'" - echo "chmod '$1'" >> "$__messages_out" - fire_onchange=1 + echo chmod \"$1\" \"$destination\" + echo chmod $1 >> "$__messages_out" } +set_attributes= case "$state_should" in - present|exists|pre-exists) + present|exists) # Note: Mode - needs to happen last as a chown/chgrp can alter mode by # clearing S_ISUID and S_ISGID bits (see chown(2)) for attribute in group owner mode; do @@ -70,27 +68,22 @@ case "$state_should" in # change 0xxx format to xxx format => same as stat returns if [ "$attribute" = mode ]; then - value_should="$(echo "$value_should" | sed 's/^0\(...\)/\1/')" + value_should="$(echo $value_should | sed 's/^0\(...\)/\1/')" fi value_is="$(get_current_value "$attribute" "$value_should")" - if [ -f "$__object/files/set-attributes" ] || [ "$value_should" != "$value_is" ]; then + if [ -f "$__object/files/set-attributes" -o "$value_should" != "$value_is" ]; then "set_$attribute" "$value_should" fi fi done - if [ -f "$__object/files/set-attributes" ]; then - # set-attributes is created if file is created or uploaded in gencode-local - fire_onchange=1 - fi ;; absent) if [ "$type" = "file" ]; then - echo "rm -f '$destination'" + echo rm -f \"$destination\" echo remove >> "$__messages_out" - fire_onchange=1 fi ;; @@ -99,9 +92,3 @@ case "$state_should" in exit 1 ;; esac - -if [ -f "$__object/parameter/onchange" ]; then - if [ -n "$fire_onchange" ]; then - cat "$__object/parameter/onchange" - fi -fi diff --git a/cdist/conf/type/__file/man.rst b/cdist/conf/type/__file/man.rst deleted file mode 100644 index 7a0603bb..00000000 --- a/cdist/conf/type/__file/man.rst +++ /dev/null @@ -1,124 +0,0 @@ -cdist-type__file(7) -=================== - -NAME ----- -cdist-type__file - Manage files. - - -DESCRIPTION ------------ -This cdist type allows you to create files, remove files and set file -attributes on the target. - -If the file already exists on the target, then if it is a: - -regular file, and state is: - present - replace it with the source file if they are not equal - exists - do nothing -symlink - replace it with the source file -directory - replace it with the source file - -One exception is that when state is pre-exists, an error is raised if -the file would have been created otherwise (e.g. it is not present or -not a regular file). - -In any case, make sure that the file attributes are as specified. - - -REQUIRED PARAMETERS -------------------- -None. - -OPTIONAL PARAMETERS -------------------- -state - 'present', 'absent', 'exists' or 'pre-exists', defaults to 'present' where: - - present - the file is exactly the one from source - absent - the file does not exist - exists - the file from source but only if it doesn't already exist - pre-exists - check that the file exists and is a regular file, but do not - create or modify it - -group - Group to chgrp to. - -mode - Unix permissions, suitable for chmod. - -owner - User to chown to. - -source - If supplied, copy this file from the host running cdist to the target. - If not supplied, an empty file or directory will be created. - If source is '-' (dash), take what was written to stdin as the file content. - -onchange - The code to run if file is modified. - -MESSAGES --------- -chgrp - Changed group membership -chown - Changed owner -chmod - Changed mode -create - Empty file was created (no --source specified) -remove - File exists, but state is absent, file will be removed by generated code. -upload - File was uploaded - - -EXAMPLES --------- - -.. code-block:: sh - - # Create /etc/cdist-configured as an empty file - __file /etc/cdist-configured - # The same thing - __file /etc/cdist-configured --state present - # Use __file from another type - __file /etc/issue --source "$__type/files/archlinux" --state present - # Delete existing file - __file /etc/cdist-configured --state absent - # Supply some more settings - __file /etc/shadow --source "$__type/files/shadow" \ - --owner root --group shadow --mode 0640 \ - --state present - # Provide a default file, but let the user change it - __file /home/frodo/.bashrc --source "/etc/skel/.bashrc" \ - --state exists \ - --owner frodo --mode 0600 - # Check that the file is present, show an error when it is not - __file /etc/somefile --state pre-exists - # Take file content from stdin - __file /tmp/whatever --owner root --group root --mode 644 --source - << DONE - Here goes the content for /tmp/whatever - DONE - - -AUTHORS -------- -Nico Schottelius - - -COPYING -------- -Copyright \(C) 2011-2013 Nico Schottelius. 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. diff --git a/cdist/conf/type/__file/man.text b/cdist/conf/type/__file/man.text new file mode 100644 index 00000000..a582b27b --- /dev/null +++ b/cdist/conf/type/__file/man.text @@ -0,0 +1,109 @@ +cdist-type__file(7) +=================== +Nico Schottelius + + +NAME +---- +cdist-type__file - Manage files + + +DESCRIPTION +----------- +This cdist type allows you to create files, remove files and set file +attributes on the target. + +If the file already exists on the target, then if it is a: +- regular file, and state is: + present: replace it with the source file if they are not equal + exists: do nothing +- symlink: replace it with the source file +- directory: replace it with the source file + +In any case, make sure that the file attributes are as specified. + + +REQUIRED PARAMETERS +------------------- +None. + +OPTIONAL PARAMETERS +------------------- +state:: + 'present', 'absent' or 'exists', defaults to 'present' + where: + present: the file is exactly the one from source + absent: the file does not exist + exists: the file from source but only if it doesn't already exist + +group:: + Group to chgrp to. + +mode:: + Unix permissions, suitable for chmod. + +owner:: + User to chown to. + +source:: + If supplied, copy this file from the host running cdist to the target. + If not supplied, an empty file or directory will be created. + If source is '-' (dash), take what was written to stdin as the file content. + +MESSAGES +-------- +chgrp :: + Changed group membership +chown :: + Changed owner +chmod :: + Changed mode +create:: + Empty file was created (no --source specified) +remove:: + File exists, but state is absent, file will be removed by generated code. +upload:: + File was uploaded + + +EXAMPLES +-------- + +-------------------------------------------------------------------------------- +# Create /etc/cdist-configured as an empty file +__file /etc/cdist-configured +# The same thing +__file /etc/cdist-configured --state present +# Delete existing file +__file /etc/cdist-configured --state absent + +# Use __file from another type +__file /etc/issue --source "$__type/files/archlinux" --state present + +# Supply some more settings +__file /etc/shadow --source "$__type/files/shadow" \ + --owner root --group shadow --mode 0640 \ + --state present + +# Provide a default file, but let the user change it +__file /home/frodo/.bashrc --source "/etc/skel/.bashrc" \ + --state exists \ + --owner frodo --mode 0600 + +# Take file content from stdin +__file /tmp/whatever --owner root --group root --mode 644 --source - << DONE +Here goes the content for /tmp/whatever +DONE + +-------------------------------------------------------------------------------- + + +SEE ALSO +-------- +- cdist-type(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/cdist/conf/type/__file/parameter/optional b/cdist/conf/type/__file/parameter/optional index 9b98352c..c696d592 100644 --- a/cdist/conf/type/__file/parameter/optional +++ b/cdist/conf/type/__file/parameter/optional @@ -3,4 +3,3 @@ group mode owner source -onchange diff --git a/cdist/conf/type/__filesystem/explorer/lsblk b/cdist/conf/type/__filesystem/explorer/lsblk deleted file mode 100644 index 9ae544ac..00000000 --- a/cdist/conf/type/__filesystem/explorer/lsblk +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/sh -# -# 2016 - 2016 Daniel Heule (hda at sfs.biz) -# -# This file is part of cdist. -# -# cdist is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# cdist is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with cdist. If not, see . -# - -os=$("$__explorer/os") - -if [ -f "$__object/parameter/device" ]; then - blkdev="$(cat "$__object/parameter/device")" -else - blkdev="$__object_id" -fi - -case "$os" in - centos|fedora|redhat|suse|gentoo) - if [ ! -x "$(command -v lsblk)" ]; then - echo "lsblk is required for __filesystem type" >&2 - exit 1 - else - #echo -n $(lsblk -nd -P -o NAME,FSTYPE,LABEL,MOUNTPOINT "$blkdev" 2>/dev/null) - lsblk -nd -P -o NAME,FSTYPE,LABEL,MOUNTPOINT "$blkdev" 2>/dev/null - fi - ;; - *) - echo "__filesystem type lacks implementation for os: $os" >&2 - exit 1 - ;; -esac diff --git a/cdist/conf/type/__filesystem/gencode-remote b/cdist/conf/type/__filesystem/gencode-remote deleted file mode 100755 index 0bcdc13c..00000000 --- a/cdist/conf/type/__filesystem/gencode-remote +++ /dev/null @@ -1,102 +0,0 @@ -#!/bin/sh -e -# -# 2016 - 2016 Daniel Heule (hda at sfs.biz) -# -# 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 . -# - - -fstype="$(cat "$__object/parameter/fstype")" - -if [ -f "$__object/parameter/device" ]; then - mydev="$(cat "$__object/parameter/device")" -else - mydev="$__object_id" -fi - -label="$(cat "$__object/parameter/label")" -mkfsoptions="$(cat "$__object/parameter/mkfsoptions")" - - -if [ -f "$__object/parameter/force" ]; then - # create filesystem even an other filesystem is on disk or the label is not correct, use with caution ! - forcefs="true" -else - forcefs="false" -fi - - - -blkdev_devname="$(grep -P -o 'NAME="\K[^"]*' "$__object/explorer/lsblk")" -blkdev_fstype="$(grep -P -o 'FSTYPE="\K[^"]*' "$__object/explorer/lsblk")" -blkdev_label="$(grep -P -o 'LABEL="\K[^"]*' "$__object/explorer/lsblk")" -blkdev_mountpoint="$(grep -P -o 'MOUNTPOINT="\K[^"]*' "$__object/explorer/lsblk")" - -if [ -z "$blkdev_devname" ]; then - echo "Specified device $mydev not found on target system" >&2 - exit 1 -fi - -[ "$blkdev_label" = "$label" ] && [ "$blkdev_fstype" = "$fstype" ] && exit 0 - -if [ -n "$blkdev_mountpoint" ]; then - echo "Specified device $mydev is mounted on $blkdev_mountpoint, __filesystem does NOTHING with mountd devices" >&2 - exit 0 -fi - -if [ -n "$blkdev_fstype" ] && [ "$forcefs" != "true" ]; then - if [ "$blkdev_label" != "$label" ]; then - echo "Specified device $mydev has not the spezified label: $blkdev_label, but __filesystem does NOTHING in this case without the --force option" >&2 - exit 0 - fi - if [ "$blkdev_fstype" != "$fstype" ]; then - echo "Specified device $mydev has not the spezified filesystem: $blkdev_fstype, but __filesystem does NOTHING in this case without the --force option" >&2 - exit 0 - fi -fi - - -# ok, all conditions checked, we need to format the device, lets go -opts="$mkfsoptions" -if [ -n "$label" ]; then - opts="$opts -L '$label'" -fi - -case "$fstype" in - ext2|ext3|ext4) - if [ "$forcefs" = "true" ]; then - opts="$opts -F" - fi - echo "mkfs.$fstype $opts /dev/$blkdev_devname" - ;; - btrfs) - if [ "$forcefs" = "true" ]; then - opts="$opts --force" - fi - echo "mkfs.btrfs $opts /dev/$blkdev_devname" - ;; - xfs) - if [ "$forcefs" = "true" ]; then - opts="$opts -f" - fi - echo "mkfs.xfs $opts /dev/$blkdev_devname" - ;; - *) - echo "__filesystem type lacks implementation for filesystem: $fstype" >&2 - exit 1 - ;; -esac -echo "filesystem $fstype on $mydev : /dev/$blkdev_devname created" >> "$__messages_out" diff --git a/cdist/conf/type/__filesystem/man.rst b/cdist/conf/type/__filesystem/man.rst deleted file mode 100644 index 1c103ac9..00000000 --- a/cdist/conf/type/__filesystem/man.rst +++ /dev/null @@ -1,81 +0,0 @@ -cdist-type__filesystem(7) -========================= - -NAME ----- -cdist-type__filesystem - Create Filesystems. - - -DESCRIPTION ------------ -This cdist type allows you to create filesystems on devices. - -If the device is mounted on target, it refuses to do anything. - -If the device has a filesystem other then the specified and/or -the label is not correct, it only makes a new filesystem -if you have specified --force option. - - -REQUIRED PARAMETERS -------------------- -fstype - Filesystem type, for example 'ext3', 'btrfs' or 'xfs'. - - - -OPTIONAL PARAMETERS -------------------- -device - Blockdevice for filesystem, Defaults to object_id. - On linux, it can be any lsblk accepted device notation. - - | - | For example: - | /dev/sdx - | or /dev/disk/by-xxxx/xxx - | or /dev/mapper/xxxx - -label - Label which should be applied on the filesystem. - -mkfsoptions - Additional options which are inserted to the mkfs.xxx call. - - -BOOLEAN PARAMETERS ------------------- -force - Normally, this type does nothing if a filesystem is found - on the target device. If you specify force, it's formatted - if the filesystem type or label differs from parameters. - Warning: This option can easily lead into data loss! - -MESSAGES --------- -filesystem on \: created - Filesystem was created on - - -EXAMPLES --------- - -.. code-block:: sh - - # Ensures that device /dev/sdb is formatted with xfs - __filesystem /dev/sdb --fstype xfs --label Testdisk1 - # The same thing with btrfs and disk spezified by pci path to disk 1:0 on vmware - __filesystem dev_sdb --fstype btrfs --device /dev/disk/by-path/pci-0000:0b:00.0-scsi-0:0:0:0 --label Testdisk2 - # Make sure that a multipath san device has a filesystem ... - __filesystem dev_sdb --fstype xfs --device /dev/mapper/360060e80432f560050202f22000023ff --label Testdisk3 - - -AUTHORS -------- -Daniel Heule - - -COPYING -------- -Copyright \(C) 2016 Daniel Heule. Free use of this software is -granted under the terms of the GNU General Public License version 3 or any later version (GPLv3+). diff --git a/cdist/conf/type/__filesystem/parameter/boolean b/cdist/conf/type/__filesystem/parameter/boolean deleted file mode 100644 index 14b33226..00000000 --- a/cdist/conf/type/__filesystem/parameter/boolean +++ /dev/null @@ -1 +0,0 @@ -force diff --git a/cdist/conf/type/__filesystem/parameter/default/label b/cdist/conf/type/__filesystem/parameter/default/label deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/conf/type/__filesystem/parameter/default/mkfsoptions b/cdist/conf/type/__filesystem/parameter/default/mkfsoptions deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/conf/type/__filesystem/parameter/optional b/cdist/conf/type/__filesystem/parameter/optional deleted file mode 100644 index 79dddc21..00000000 --- a/cdist/conf/type/__filesystem/parameter/optional +++ /dev/null @@ -1,3 +0,0 @@ -device -label -mkfsoptions diff --git a/cdist/conf/type/__filesystem/parameter/required b/cdist/conf/type/__filesystem/parameter/required deleted file mode 100644 index 98f8b69f..00000000 --- a/cdist/conf/type/__filesystem/parameter/required +++ /dev/null @@ -1 +0,0 @@ -fstype diff --git a/cdist/conf/type/__firewalld_rule/explorer/rule b/cdist/conf/type/__firewalld_rule/explorer/rule deleted file mode 100644 index 0234e5b6..00000000 --- a/cdist/conf/type/__firewalld_rule/explorer/rule +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/sh -# -# 2015 Nico Schottelius (nico-cdist at schottelius.org) -# -# This file is part of cdist. -# -# cdist is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# cdist is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with cdist. If not, see . -# -# - -protocol="$(cat "$__object/parameter/protocol")" -table="$(cat "$__object/parameter/table")" -chain="$(cat "$__object/parameter/chain")" -priority="$(cat "$__object/parameter/priority")" -rule="$(cat "$__object/parameter/rule")" - -if firewall-cmd --permanent --direct --query-rule "$protocol" "$table" "$chain" "$priority" "$rule" >/dev/null; then - echo present -else - echo absent -fi diff --git a/cdist/conf/type/__firewalld_rule/gencode-remote b/cdist/conf/type/__firewalld_rule/gencode-remote deleted file mode 100755 index bd6d13e5..00000000 --- a/cdist/conf/type/__firewalld_rule/gencode-remote +++ /dev/null @@ -1,47 +0,0 @@ -#!/bin/sh -e -# -# 2015 Nico Schottelius (nico-cdist at schottelius.org) -# -# This file is part of cdist. -# -# cdist is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# cdist is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with cdist. If not, see . -# -# - -state_should="$(cat "$__object/parameter/state")" -state_is="$(cat "$__object/explorer/rule")" - -[ "$state_is" = "$state_should" ] && exit 0 - -protocol="$(cat "$__object/parameter/protocol")" -table="$(cat "$__object/parameter/table")" -chain="$(cat "$__object/parameter/chain")" -priority="$(cat "$__object/parameter/priority")" -rule="$(cat "$__object/parameter/rule")" - -case "$state_should" in - present) - echo "firewall-cmd --quiet --permanent --direct --add-rule '$protocol' '$table' '$chain' '$priority' $rule" - echo "firewall-cmd --quiet --direct --add-rule '$protocol' '$table' '$chain' '$priority' $rule" - ;; - - absent) - echo "firewall-cmd --quiet --permanent --direct --remove-rule '$protocol' '$table' '$chain' '$priority' $rule" - echo "firewall-cmd --quiet --direct --remove-rule '$protocol' '$table' '$chain' '$priority' $rule" - ;; - *) - echo "Unknown state $state_should" >&2 - exit 1 - ;; -esac diff --git a/cdist/conf/type/__firewalld_rule/man.rst b/cdist/conf/type/__firewalld_rule/man.rst deleted file mode 100644 index 5de5d15c..00000000 --- a/cdist/conf/type/__firewalld_rule/man.rst +++ /dev/null @@ -1,81 +0,0 @@ -cdist-type__firewalld_rule(7) -============================= - -NAME ----- -cdist-type__firewalld_rule - Configure firewalld rules - - -DESCRIPTION ------------ -This cdist type allows you to manage rules in firewalld -using the *direct* way (i.e. no zone support). - - -REQUIRED PARAMETERS -------------------- -rule - The rule to apply. Essentially an firewalld command - line without firewalld in front of it. -protocol - Either ipv4, ipv4 or eb. See firewall-cmd(1) -table - The table to use (like filter or nat). See firewall-cmd(1). -chain - The chain to use (like INPUT_direct or FORWARD_direct). See firewall-cmd(1). -priority - The priority to use (0 is topmost). See firewall-cmd(1). - - -OPTIONAL PARAMETERS -------------------- -state - 'present' or 'absent', defaults to 'present' - - -EXAMPLES --------- - -.. code-block:: sh - - # Allow access from entrance.place4.ungleich.ch - __firewalld_rule entrance \ - --protocol ipv4 \ - --table filter \ - --chain INPUT_direct \ - --priority 0 \ - --rule '-s entrance.place4.ungleich.ch -j ACCEPT' - - # Allow forwarding of traffic from br0 - __firewalld_rule vm-forward --protocol ipv4 \ - --table filter \ - --chain FORWARD_direct \ - --priority 0 \ - --rule '-i br0 -j ACCEPT' - - # Ensure old rule is absent - warning, the rule part must stay the same! - __firewalld_rule vm-forward - --protocol ipv4 \ - --table filter \ - --chain FORWARD_direct \ - --priority 0 \ - --rule '-i br0 -j ACCEPT' \ - --state absent - - -SEE ALSO --------- -:strong:`cdist-type__iptables_rule`\ (7), :strong:`firewalld`\ (8) - - -AUTHORS -------- -Nico Schottelius - - -COPYING -------- -Copyright \(C) 2015 Nico Schottelius. 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. diff --git a/cdist/conf/type/__firewalld_rule/manifest b/cdist/conf/type/__firewalld_rule/manifest deleted file mode 100755 index 71156329..00000000 --- a/cdist/conf/type/__firewalld_rule/manifest +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/sh -e -# -# 2015 David Hürlimann (david at ungleich.ch) -# -# 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 type allows to configure the desired localtime timezone. - -__package firewalld diff --git a/cdist/conf/type/__firewalld_rule/parameter/default/state b/cdist/conf/type/__firewalld_rule/parameter/default/state deleted file mode 100644 index e7f6134f..00000000 --- a/cdist/conf/type/__firewalld_rule/parameter/default/state +++ /dev/null @@ -1 +0,0 @@ -present diff --git a/cdist/conf/type/__firewalld_rule/parameter/optional b/cdist/conf/type/__firewalld_rule/parameter/optional deleted file mode 100644 index ff72b5c7..00000000 --- a/cdist/conf/type/__firewalld_rule/parameter/optional +++ /dev/null @@ -1 +0,0 @@ -state diff --git a/cdist/conf/type/__firewalld_rule/parameter/required b/cdist/conf/type/__firewalld_rule/parameter/required deleted file mode 100644 index 58def7e4..00000000 --- a/cdist/conf/type/__firewalld_rule/parameter/required +++ /dev/null @@ -1,5 +0,0 @@ -chain -priority -protocol -rule -table diff --git a/cdist/conf/type/__firewalld_start/gencode-remote b/cdist/conf/type/__firewalld_start/gencode-remote deleted file mode 100755 index 3e767f68..00000000 --- a/cdist/conf/type/__firewalld_start/gencode-remote +++ /dev/null @@ -1,84 +0,0 @@ -#!/bin/sh -e -# -# 2016 Darko Poljak(darko.poljak at ungleich.ch) -# -# 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 . -# -# - -startstate="$(cat "$__object/parameter/startstate")" -init=$(cat "$__global/explorer/init") - -os=$(cat "$__global/explorer/os") -os_version=$(cat "$__global/explorer/os_version") -name="firewalld" - -case "${startstate}" in - present) - cmd="start" - ;; - absent) - cmd="stop" - ;; - *) - echo "Unknown startstate: ${startstate}" >&2 - exit 1 - ;; -esac - -if [ "$init" = 'systemd' ]; then - # this handles ALL linux distros with systemd - # e.g. archlinux, gentoo in some cases, new RHEL and SLES versions - echo "systemctl \"$cmd\" \"$name\"" -else - case "$os" in - debian) - case "$os_version" in - [1-7]*) - echo "service \"$name\" \"$cmd\"" - ;; - 8*) - echo "systemctl \"$cmd\" \"$name\"" - ;; - *) - echo "Unsupported version $os_version of $os" >&2 - exit 1 - ;; - esac - ;; - - gentoo) - echo service \"$name\" \"$cmd\" - ;; - - amazon|scientific|centos|fedora|owl|redhat|suse) - echo service \"$name\" \"$cmd\" - ;; - - openwrt) - echo "/etc/init.d/\"$name\" \"$cmd\"" - ;; - - ubuntu) - echo "service \"$name\" \"$cmd\"" - ;; - - *) - echo "Unsupported os: $os" >&2 - exit 1 - ;; - esac -fi diff --git a/cdist/conf/type/__firewalld_start/man.rst b/cdist/conf/type/__firewalld_start/man.rst deleted file mode 100644 index 74199cd6..00000000 --- a/cdist/conf/type/__firewalld_start/man.rst +++ /dev/null @@ -1,53 +0,0 @@ -cdist-type__firewalld_start(7) -============================== - -NAME ----- -cdist-type__firewalld_start - start and enable firewalld - - -DESCRIPTION ------------ -This cdist type allows you to start and enable firewalld. - - -REQUIRED PARAMETERS -------------------- -None - -OPTIONAL PARAMETERS -------------------- -startstate - 'present' or 'absent', start/stop firewalld. Default is 'present'. -bootstate - 'present' or 'absent', enable/disable firewalld on boot. Default is 'present'. - - -EXAMPLES --------- - -.. code-block:: sh - - # start and enable firewalld - __firewalld_start - - # only enable firewalld to start on boot - __firewalld_start --startstate present --bootstate absent - - -SEE ALSO --------- -:strong:`firewalld`\ (8) - - -AUTHORS -------- -Darko Poljak - - -COPYING -------- -Copyright \(C) 2016 Darko Poljak. 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. diff --git a/cdist/conf/type/__firewalld_start/manifest b/cdist/conf/type/__firewalld_start/manifest deleted file mode 100755 index 98caaad9..00000000 --- a/cdist/conf/type/__firewalld_start/manifest +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/sh -e -# -# 2016 Darko Poljak (darko.poljak at ungleich.ch) -# -# 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 . - -bootstate="$(cat "$__object/parameter/bootstate")" - -__package firewalld -require="__package/firewalld" __start_on_boot firewalld --state "${bootstate}" diff --git a/cdist/conf/type/__firewalld_start/parameter/default/bootstate b/cdist/conf/type/__firewalld_start/parameter/default/bootstate deleted file mode 100644 index e7f6134f..00000000 --- a/cdist/conf/type/__firewalld_start/parameter/default/bootstate +++ /dev/null @@ -1 +0,0 @@ -present diff --git a/cdist/conf/type/__firewalld_start/parameter/default/startstate b/cdist/conf/type/__firewalld_start/parameter/default/startstate deleted file mode 100644 index e7f6134f..00000000 --- a/cdist/conf/type/__firewalld_start/parameter/default/startstate +++ /dev/null @@ -1 +0,0 @@ -present diff --git a/cdist/conf/type/__firewalld_start/parameter/optional b/cdist/conf/type/__firewalld_start/parameter/optional deleted file mode 100644 index 934c7d0d..00000000 --- a/cdist/conf/type/__firewalld_start/parameter/optional +++ /dev/null @@ -1,2 +0,0 @@ -bootstate -startstate diff --git a/cdist/conf/type/__firewalld_start/singleton b/cdist/conf/type/__firewalld_start/singleton deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/conf/type/__git/explorer/group b/cdist/conf/type/__git/explorer/group index 3ddf9656..1308c710 100644 --- a/cdist/conf/type/__git/explorer/group +++ b/cdist/conf/type/__git/explorer/group @@ -2,4 +2,4 @@ destination="/$__object_id/.git" -stat --print "%G" "${destination}" 2>/dev/null || exit 0 +stat --print "%G" ${destination} 2>/dev/null || exit 0 diff --git a/cdist/conf/type/__git/explorer/owner b/cdist/conf/type/__git/explorer/owner index 4c3cd431..8c36b035 100644 --- a/cdist/conf/type/__git/explorer/owner +++ b/cdist/conf/type/__git/explorer/owner @@ -2,4 +2,4 @@ destination="/$__object_id/.git" -stat --print "%U" "${destination}" 2>/dev/null || exit 0 +stat --print "%U" ${destination} 2>/dev/null || exit 0 diff --git a/cdist/conf/type/__git/gencode-remote b/cdist/conf/type/__git/gencode-remote old mode 100755 new mode 100644 index 5a9e23fc..c4fc1ef2 --- a/cdist/conf/type/__git/gencode-remote +++ b/cdist/conf/type/__git/gencode-remote @@ -1,4 +1,4 @@ -#!/bin/sh -e +#!/bin/sh # # 2012 Nico Schottelius (nico-cdist at schottelius.org) # @@ -35,10 +35,10 @@ owner="$(cat "$__object/parameter/owner")" group="$(cat "$__object/parameter/group")" mode="$(cat "$__object/parameter/mode")" -[ "$state_should" = "$state_is" ] && \ -[ "$owner" = "$owner_is" ] && \ -[ "$group" = "$group_is" ] && \ -[ -n "$mode" ] && exit 0 +[ "$state_should" = "$state_is" -a \ + "$owner" = "$owner_is" -a \ + "$group" = "$group_is" -a \ + -n "$mode" ] && exit 0 case $state_should in present) @@ -46,8 +46,8 @@ case $state_should in if [ "$state_should" != "$state_is" ]; then echo git clone --quiet --branch "$branch" "$source" "$destination" fi - if { [ -n "$owner" ] && [ "$owner_is" != "$owner" ]; } || \ - { [ -n "$group" ] && [ "$group_is" != "$group" ]; }; then + if [ \( -n "$owner" -a "$owner_is" != "$owner" \) -o \ + \( -n "$group" -a "$group_is" != "$group" \) ]; then echo chown -R "${owner}:${group}" "$destination" fi if [ -n "$mode" ]; then diff --git a/cdist/conf/type/__git/man.rst b/cdist/conf/type/__git/man.rst deleted file mode 100644 index 130925c8..00000000 --- a/cdist/conf/type/__git/man.rst +++ /dev/null @@ -1,60 +0,0 @@ -cdist-type__git(7) -================== - -NAME ----- -cdist-type__git - Get and or keep git repositories up-to-date - - -DESCRIPTION ------------ -This cdist type allows you to clone git repositories - - -REQUIRED PARAMETERS -------------------- -source - Specifies the git remote to clone from - - -OPTIONAL PARAMETERS -------------------- -state - Either "present" or "absent", defaults to "present" - -branch - Create this branch by checking out the remote branch of this name - Default branch is "master" - -group - Group to chgrp to. - -mode - Unix permissions, suitable for chmod. - -owner - User to chown to. - - -EXAMPLES --------- - -.. code-block:: sh - - __git /home/services/dokuwiki --source git://github.com/splitbrain/dokuwiki.git - - # Checkout cdist, stay on branch 2.1 - __git /home/nico/cdist --source git@code.ungleich.ch:ungleich-public/cdist.git --branch 2.1 - - -AUTHORS -------- -Nico Schottelius - - -COPYING -------- -Copyright \(C) 2012 Nico Schottelius. 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. diff --git a/cdist/conf/type/__git/man.text b/cdist/conf/type/__git/man.text new file mode 100644 index 00000000..5f74108b --- /dev/null +++ b/cdist/conf/type/__git/man.text @@ -0,0 +1,60 @@ +cdist-type__git(7) +================== +Nico Schottelius + + +NAME +---- +cdist-type__git - Get and or keep git repositories up-to-date + + +DESCRIPTION +----------- +This cdist type allows you to clone git repositories + + +REQUIRED PARAMETERS +------------------- +source:: + Specifies the git remote to clone from + + +OPTIONAL PARAMETERS +------------------- +state:: + Either "present" or "absent", defaults to "present" + +branch:: + Create this branch by checking out the remote branch of this name + Default branch is "master" + +group:: + Group to chgrp to. + +mode:: + Unix permissions, suitable for chmod. + +owner:: + User to chown to. + + +EXAMPLES +-------- + +-------------------------------------------------------------------------------- +__git /home/services/dokuwiki --source git://github.com/splitbrain/dokuwiki.git + +# Checkout cdist, stay on branch 2.1 +__git /home/nico/cdist --source git://github.com/telmich/cdist.git --branch 2.1 +-------------------------------------------------------------------------------- + + +SEE ALSO +-------- +- cdist-type(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/cdist/conf/type/__git/manifest b/cdist/conf/type/__git/manifest old mode 100755 new mode 100644 index 6fb870f4..b2b0feb0 --- a/cdist/conf/type/__git/manifest +++ b/cdist/conf/type/__git/manifest @@ -1,4 +1,4 @@ -#!/bin/sh -e +#!/bin/sh # # 2012 Nico Schottelius (nico-cdist at schottelius.org) # diff --git a/cdist/conf/type/__go_get/explorer/go-executable b/cdist/conf/type/__go_get/explorer/go-executable deleted file mode 100755 index 87182282..00000000 --- a/cdist/conf/type/__go_get/explorer/go-executable +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh -# shellcheck disable=SC1091 -[ -f /etc/environment ] && . /etc/environment -# shellcheck disable=SC1091 -[ -f /etc/profile ] && . /etc/profile -go version 2>/dev/null || true diff --git a/cdist/conf/type/__go_get/gencode-remote b/cdist/conf/type/__go_get/gencode-remote deleted file mode 100755 index 4c47a70e..00000000 --- a/cdist/conf/type/__go_get/gencode-remote +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh -e - -package=$__object_id - -cat< - - -COPYING -------- -Copyright \(C) 2017 Kamila Součková. 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. diff --git a/cdist/conf/type/__go_get/manifest b/cdist/conf/type/__go_get/manifest deleted file mode 100755 index a5cc4c80..00000000 --- a/cdist/conf/type/__go_get/manifest +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/sh -e - -go_executable=$(cat "$__object/explorer/go-executable") -[ -z "$go_executable" ] && echo "__go_get: Cannot find go executable; make sure it is installed and in PATH" >&2 && exit 1 - -os=$(cat "$__global/explorer/os") -case $os in - debian|devuan|ubuntu) - __package build-essential - ;; - *) - echo "__go_get: Don't know how to install g++ on $os" >&2 - echo "__go_get: Send a pull request or contact to add support for $os." >&2 - exit 1 - ;; -esac - -__package git diff --git a/cdist/conf/type/__golang_from_vendor/gencode-remote b/cdist/conf/type/__golang_from_vendor/gencode-remote deleted file mode 100755 index 5200e9e3..00000000 --- a/cdist/conf/type/__golang_from_vendor/gencode-remote +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/sh -e - -version=$(cat "$__object/parameter/version") - -kernel_name=$(tr '[:upper:]' '[:lower:]' < "$__global/explorer/kernel_name") -machine=$(cat "$__global/explorer/machine") -case $machine in - x86_64|amd64) - arch=amd64 - ;; - x86) - arch=386 - ;; - *) - arch=$machine # at least try... - ;; -esac - -PACKAGE="go${version}.${kernel_name}-${arch}" -URL="https://storage.googleapis.com/golang/${PACKAGE}.tar.gz" -cat </dev/null)" = "xgo$version" ] && exit 0 # already there -wget --no-verbose "$URL" -O "/tmp/${PACKAGE}.tar.gz" -rm -rf /usr/local/go -tar -C /usr/local -xzf /tmp/${PACKAGE}.tar.gz -EOF diff --git a/cdist/conf/type/__golang_from_vendor/man.rst b/cdist/conf/type/__golang_from_vendor/man.rst deleted file mode 100644 index 2b4f065e..00000000 --- a/cdist/conf/type/__golang_from_vendor/man.rst +++ /dev/null @@ -1,48 +0,0 @@ -cdist-type__golang_from_vendor(7) -================================= - -NAME ----- -cdist-type__golang_from_vendor - Install any version of golang from golang.org - - -DESCRIPTION ------------ -This cdist type allows you to install golang from archives provided by https://golang.org/dl/. - -See https://golang.org/dl/ for the list of supported versions, operating systems and architectures. - -This is a singleton type. - - -REQUIRED PARAMETERS -------------------- -None. - - -OPTIONAL PARAMETERS -------------------- -version - The golang version to install, defaults to 1.8.1 - - -EXAMPLES --------- - -.. code-block:: sh - - __golang_from_vendor --version 1.8.1 - - - -AUTHORS -------- -Kamila Součková - - -COPYING -------- -Copyright \(C) 2017 Kamila Součková. 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. diff --git a/cdist/conf/type/__golang_from_vendor/manifest b/cdist/conf/type/__golang_from_vendor/manifest deleted file mode 100755 index ad39ddfb..00000000 --- a/cdist/conf/type/__golang_from_vendor/manifest +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh -e - -# shellcheck disable=SC2016 -__line go_in_path --line 'export PATH=/usr/local/go/bin:$PATH' --file /etc/profile diff --git a/cdist/conf/type/__golang_from_vendor/parameter/default/version b/cdist/conf/type/__golang_from_vendor/parameter/default/version deleted file mode 100644 index a8fdfda1..00000000 --- a/cdist/conf/type/__golang_from_vendor/parameter/default/version +++ /dev/null @@ -1 +0,0 @@ -1.8.1 diff --git a/cdist/conf/type/__golang_from_vendor/parameter/optional b/cdist/conf/type/__golang_from_vendor/parameter/optional deleted file mode 100644 index 088eda41..00000000 --- a/cdist/conf/type/__golang_from_vendor/parameter/optional +++ /dev/null @@ -1 +0,0 @@ -version diff --git a/cdist/conf/type/__golang_from_vendor/singleton b/cdist/conf/type/__golang_from_vendor/singleton deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/conf/type/__grafana_dashboard/man.rst b/cdist/conf/type/__grafana_dashboard/man.rst deleted file mode 100644 index b3974028..00000000 --- a/cdist/conf/type/__grafana_dashboard/man.rst +++ /dev/null @@ -1,43 +0,0 @@ -cdist-type__grafana_dashboard(7) -================================ - -NAME ----- -cdist-type__grafana_dashboard - Install Grafana (https://grafana.com) - - -DESCRIPTION ------------ -This cdist type adds the Grafana repository, installs the grafana package, and sets the server to start on boot. - -This is a singleton type. - -REQUIRED PARAMETERS -------------------- -None. - - -OPTIONAL PARAMETERS -------------------- -None. - - -EXAMPLES --------- - -.. code-block:: sh - - __grafana_dashboard - - -AUTHORS -------- -Kamila Součková - - -COPYING -------- -Copyright \(C) 2017 Kamila Součková. 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. diff --git a/cdist/conf/type/__grafana_dashboard/manifest b/cdist/conf/type/__grafana_dashboard/manifest deleted file mode 100755 index e652202b..00000000 --- a/cdist/conf/type/__grafana_dashboard/manifest +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/sh -e - -os=$(cat "$__global/explorer/os") -os_version=$(cat "$__global/explorer/os_version") - -require="" -case $os in - debian|devuan) - case $os_version in - 8*|jessie) - # Differntation not needed anymore - apt_source_distribution=stable - ;; - 9*|ascii/ceres|ascii) - # Differntation not needed anymore - apt_source_distribution=stable - ;; - *) - echo "Don't know how to install Grafana on $os $os_version. Send us a pull request!" >&2 - exit 1 - ;; - esac - - __apt_key_uri grafana \ - --name 'Grafana Release Signing Key' \ - --uri https://packages.grafana.com/gpg.key - - require="$require __apt_key_uri/grafana" __apt_source grafana \ - --uri https://packages.grafana.com/oss/deb \ - --distribution $apt_source_distribution \ - --component main - - __package apt-transport-https - - require="$require __apt_source/grafana __package/apt-transport-https" __package grafana - require="$require __package/grafana" __start_on_boot grafana-server - require="$require __start_on_boot/grafana-server" __process grafana-server --start "service grafana-server start" - ;; - *) - echo "Don't know how to install Grafana on $os. Send us a pull request!" >&2 - exit 1 - ;; -esac diff --git a/cdist/conf/type/__grafana_dashboard/singleton b/cdist/conf/type/__grafana_dashboard/singleton deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/conf/type/__group/TODO b/cdist/conf/type/__group/TODO new file mode 100644 index 00000000..c20a5d21 --- /dev/null +++ b/cdist/conf/type/__group/TODO @@ -0,0 +1,2 @@ +- delete groups + diff --git a/cdist/conf/type/__group/explorer/group b/cdist/conf/type/__group/explorer/group index 07f73a91..4c1e6ac0 100755 --- a/cdist/conf/type/__group/explorer/group +++ b/cdist/conf/type/__group/explorer/group @@ -1,6 +1,6 @@ #!/bin/sh # -# 2011-2015 Steven Armstrong (steven-cdist at armstrong.cc) +# 2011 Steven Armstrong (steven-cdist at armstrong.cc) # # This file is part of cdist. # diff --git a/cdist/conf/type/__group/explorer/gshadow b/cdist/conf/type/__group/explorer/gshadow index ef40b7bc..5ab4ed80 100755 --- a/cdist/conf/type/__group/explorer/gshadow +++ b/cdist/conf/type/__group/explorer/gshadow @@ -1,6 +1,6 @@ #!/bin/sh # -# 2011-2015 Steven Armstrong (steven-cdist at armstrong.cc) +# 2011 Steven Armstrong (steven-cdist at armstrong.cc) # # This file is part of cdist. # @@ -22,13 +22,21 @@ # name=$__object_id -os="$("$__explorer/os")" +os_version="$($__explorer/os_version)" +os="$($__explorer/os)" -case "$os" in - "freebsd"|"netbsd") - echo "$os does not have getent gshadow" - exit 0 - ;; +if [ "$os" = "freebsd" ]; then + echo "FreeBSD does not have getent gshadow" + exit 0 +fi + +case "$os_version" in + "Red Hat Enterprise Linux Server release "[45]*|"CentOS release "[45]*) + # TODO: find a way to get this information + echo "$os_version does not have getent gshadow" + ;; + *) + getent gshadow "$name" || true + ;; esac -getent gshadow "$name" || true diff --git a/cdist/conf/type/__group/gencode-remote b/cdist/conf/type/__group/gencode-remote index 6091c548..1cffa8d4 100755 --- a/cdist/conf/type/__group/gencode-remote +++ b/cdist/conf/type/__group/gencode-remote @@ -1,6 +1,6 @@ -#!/bin/sh -e +#!/bin/sh # -# 2011-2015 Steven Armstrong (steven-cdist at armstrong.cc) +# 2011 Steven Armstrong (steven-cdist at armstrong.cc) # 2011 Nico Schottelius (nico-cdist at schottelius.org) # # This file is part of cdist. @@ -23,84 +23,91 @@ # name="$__object_id" +os_version="$(cat "$__global/explorer/os_version")" os="$(cat "$__global/explorer/os")" -state="$(cat "$__object/parameter/state")" +cd "$__object/parameter" +if grep -q "^${name}:" "$__object/explorer/group"; then + for property in $(ls .); do + new_value="$(cat "$property")" + # argument to pass the groupmod command for this property (exceptions + # are made in the case statement below) + proparg="--$property" -# Use short option names for portability -shorten_property() { - case "$1" in - gid) echo " -g";; - password) echo " -p";; - system) echo " -r";; - esac -} - - -if [ "$state" = "present" ]; then - case "$os" in - freebsd) - supported_change_properties="gid" - ;; - *) - supported_change_properties="gid password" - ;; - esac - if grep -q "^${name}:" "$__object/explorer/group"; then - # change existing - for property in $supported_change_properties; do - if [ -f "$__object/parameter/$property" ]; then - new_value="$(cat "$__object/parameter/$property")" - unset current_value - case "$property" in - password) - current_value="$(awk -F: '{ print $2 }' "$__object/explorer/gshadow")" - ;; - gid) - current_value="$(awk -F: '{ print $3 }' "$__object/explorer/group")" + case "$property" in + password) + if [ "$os" = "freebsd" ]; then + echo "group/$name: FreeBSD doesn't support password modification" >&2 + exit 1 + fi + case "$os_version" in + "Red Hat Enterprise Linux Server release "[45]*|"CentOS release "[45]*) + # TODO: Use gpasswd? Need to fix gshadow explorer first. + echo "group/$name: '$os_version' groupmod does not support password modification" >&2 + exit 1 ;; esac - if [ "$new_value" != "$current_value" ]; then - set -- "$@" "$(shorten_property "$property")" \'"$new_value"\' - echo "change $property $new_value $current_value" >> "$__messages_out" - fi - fi - done - if [ $# -gt 0 ]; then - if [ "$os" = "freebsd" ]; then - echo pw groupmod "$@" "$name" - else + current_value="$(awk -F: '{ print $2 }' < "$__object/explorer/gshadow")" + ;; + gid) + # set to -g to support older redhat/centos + proparg="-g" + current_value="$(awk -F: '{ print $3 }' < "$__object/explorer/group")" + ;; + esac + + if [ "$new_value" != "$current_value" ]; then + set -- "$@" "$proparg" \"$new_value\" + echo change $property $new_value $current_value >> "$__messages_out" + fi + done + + if [ $# -gt 0 ]; then + echo mod >> "$__messages_out" + case $os in + freebsd) + echo pw group mod "$@" "$name" + ;; + *) echo groupmod "$@" "$name" - fi - echo mod >> "$__messages_out" - fi - else - # create new - for property in $supported_change_properties; do - if [ -f "$__object/parameter/$property" ]; then - new_value="$(cat "$__object/parameter/$property")" - if [ -z "$new_value" ]; then - # Boolean parameters have no value - set -- "$@" "$(shorten_property "$property")" - else - set -- "$@" "$(shorten_property "$property")" \'"$new_value"\' - fi - fi - done - if [ "$os" = "freebsd" ]; then - echo pw groupadd "$@" "$name" - else - echo groupadd "$@" "$name" - fi + ;; + esac fi else - # delete existing - if grep -q "^${name}:" "$__object/explorer/group"; then + echo add >> "$__messages_out" + for property in $(ls .); do + new_value="$(cat "$property")" if [ "$os" = "freebsd" ]; then - echo pw groupdel "$name" + case $property in + gid) + proparg="-g" + ;; + password) + echo "group/$name: FreeBSD doesn't support password setting" >&2 + exit 1 + ;; + *) + # The type has been updated to support more properties than it knows how to handle for FreeBSD + # tell the user about this. + echo "Currently unknown property: $property" >&2 + exit 1 + ;; + esac else - echo groupdel "$name" + proparg="--$property" fi - echo remove >> "$__messages_out" - fi + + set -- "$@" "$proparg" \"$new_value\" + echo set $property $new_value >> "$__messages_out" + done + + case $os in + freebsd) + echo pw group add "$@" "$name" + ;; + *) + echo groupadd "$@" "$name" + ;; + esac fi + diff --git a/cdist/conf/type/__group/man.rst b/cdist/conf/type/__group/man.rst deleted file mode 100644 index 614f3d57..00000000 --- a/cdist/conf/type/__group/man.rst +++ /dev/null @@ -1,80 +0,0 @@ -cdist-type__group(7) -==================== - -NAME ----- -cdist-type__group - Manage groups - - -DESCRIPTION ------------ -This cdist type allows you to create or modify groups on the target. - - -REQUIRED PARAMETERS -------------------- -None. - - -OPTIONAL PARAMETERS -------------------- -state - absent or present, defaults to present -gid - see groupmod(8) -password - see above - - -BOOLEAN PARAMETERS ------------------- -system - see groupadd(8), apply only on group creation - - -MESSAGES --------- -mod - group is modified -add - New group added -remove - group is removed -change - Changed group property from current_value to new_value -set - set property to new value, property was not set before - - -EXAMPLES --------- - -.. code-block:: sh - - # Create a group 'foobar' with operating system default settings - __group foobar - - # Remove the 'foobar' group - __group foobar --state absent - - # Create a system group 'myservice' with operating system default settings - __group myservice --system - - # Same but with a specific gid - __group foobar --gid 1234 - - # Same but with a gid and password - __group foobar --gid 1234 --password 'crypted-password-string' - - -AUTHORS -------- -Steven Armstrong - - -COPYING -------- -Copyright \(C) 2011-2015 Steven Armstrong. 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. diff --git a/cdist/conf/type/__group/man.text b/cdist/conf/type/__group/man.text new file mode 100644 index 00000000..def0232f --- /dev/null +++ b/cdist/conf/type/__group/man.text @@ -0,0 +1,64 @@ +cdist-type__group(7) +==================== +Steven Armstrong + + +NAME +---- +cdist-type__group - Manage groups + + +DESCRIPTION +----------- +This cdist type allows you to create or modify groups on the target. + + +REQUIRED PARAMETERS +------------------- +None. + + +OPTIONAL PARAMETERS +------------------- +gid:: + see groupmod(8) +password:: + see above + + +MESSAGES +-------- +mod:: + group is modified +add:: + New group added +change :: + Changed group property from current_value to new_value +set :: + set property to new value, property was not set bevore + + +EXAMPLES +-------- + +-------------------------------------------------------------------------------- +# Create a group 'foobar' with operating system default settings +__group foobar + +# Same but with a specific gid +__group foobar --gid 1234 + +# Same but with a gid and password +__group foobar --gid 1234 --password 'crypted-password-string' +-------------------------------------------------------------------------------- + + +SEE ALSO +-------- +- cdist-type(7) + + +COPYING +------- +Copyright \(C) 2011 Steven Armstrong. Free use of this software is +granted under the terms of the GNU General Public License version 3 (GPLv3). diff --git a/cdist/conf/type/__group/parameter/boolean b/cdist/conf/type/__group/parameter/boolean deleted file mode 100644 index bec3a35e..00000000 --- a/cdist/conf/type/__group/parameter/boolean +++ /dev/null @@ -1 +0,0 @@ -system diff --git a/cdist/conf/type/__group/parameter/default/state b/cdist/conf/type/__group/parameter/default/state deleted file mode 100644 index e7f6134f..00000000 --- a/cdist/conf/type/__group/parameter/default/state +++ /dev/null @@ -1 +0,0 @@ -present diff --git a/cdist/conf/type/__group/parameter/optional b/cdist/conf/type/__group/parameter/optional index dd51c173..4c661c8f 100644 --- a/cdist/conf/type/__group/parameter/optional +++ b/cdist/conf/type/__group/parameter/optional @@ -1,3 +1,2 @@ gid password -state diff --git a/cdist/conf/type/__hostname/explorer/hostname_file b/cdist/conf/type/__hostname/explorer/hostname_file index 6a00aa9f..ed28c8a8 100755 --- a/cdist/conf/type/__hostname/explorer/hostname_file +++ b/cdist/conf/type/__hostname/explorer/hostname_file @@ -21,10 +21,6 @@ # Retrieve the contents of /etc/hostname # -# Almost any distribution if [ -f /etc/hostname ]; then cat /etc/hostname -# SuSE -elif [ -f /etc/HOSTNAME ]; then - cat /etc/HOSTNAME fi diff --git a/cdist/conf/type/__hostname/gencode-remote b/cdist/conf/type/__hostname/gencode-remote index 8b5797dd..eec3bc9f 100755 --- a/cdist/conf/type/__hostname/gencode-remote +++ b/cdist/conf/type/__hostname/gencode-remote @@ -1,6 +1,6 @@ -#!/bin/sh -e +#!/bin/sh # -# 2014-2017 Steven Armstrong (steven-cdist at armstrong.cc) +# 2014 Steven Armstrong (steven-cdist at armstrong.cc) # 2014 Nico Schottelius (nico-cdist at schottelius.org) # # This file is part of cdist. @@ -22,33 +22,29 @@ if [ -f "$__object/parameter/name" ]; then name_should="$(cat "$__object/parameter/name")" else - name_should="${__target_host%%.*}" + name_should="$(echo "${__target_host%%.*}")" fi os=$(cat "$__global/explorer/os") name_running=$(cat "$__global/explorer/hostname") name_config=$(cat "$__object/explorer/hostname_file") -name_sysconfig=$(cat "$__object/explorer/hostname_sysconfig") +name_sysconfig=$(cat "$__object/explorer/hostname_file") has_hostnamectl=$(cat "$__object/explorer/has_hostnamectl") ################################################################################ # If everything is ok -> exit # case "$os" in - archlinux|debian|suse|ubuntu|devuan|coreos|alpine) - if [ "$name_config" = "$name_should" ] && [ "$name_running" = "$name_should" ]; then + archlinux|debian|ubuntu) + if [ "$name_config" = "$name_should" -a "$name_running" = "$name_should" ]; then exit 0 fi ;; - scientific|centos|freebsd|openbsd) - if [ "$name_sysconfig" = "$name_should" ] && [ "$name_running" = "$name_should" ]; then + centos) + if [ "$name_sysconfig" = "$name_should" -a "$name_running" = "$name_should" ]; then exit 0 fi ;; - *) - echo "Unsupported os: $os" >&2 - exit 1 - ;; esac ################################################################################ @@ -56,23 +52,16 @@ esac # echo changed >> "$__messages_out" -# Use the good old way to set the hostname even on machines running systemd. -case "$os" in - archlinux|debian|ubuntu|devuan|centos|coreos|alpine) - printf "printf '%%s\\\\n' '$name_should' > /etc/hostname\\n" - echo "hostname -F /etc/hostname" - ;; - freebsd|openbsd) - echo "hostname '$name_should'" - ;; - suse) - echo "hostname '$name_should'" - printf "printf '%%s\\\\n' '$name_should' > /etc/HOSTNAME\\n" - ;; -esac - if [ "$has_hostnamectl" ]; then - # Allow hostnamectl set-hostname to fail silently. - # Who the fuck invented a tool that needs dbus to set the hostname anyway ... - echo "hostnamectl set-hostname '$name_should' || true" + echo "hostnamectl set-hostname '$name_should'" +else + case "$os" in + archlinux|debian|ubuntu) + echo "hostname '$name_should'" + echo "printf '%s\n' '$name_should' > /etc/hostname" + ;; + centos) + echo "hostname '$name_should'" + ;; + esac fi diff --git a/cdist/conf/type/__hostname/man.rst b/cdist/conf/type/__hostname/man.rst deleted file mode 100644 index d23a3b8a..00000000 --- a/cdist/conf/type/__hostname/man.rst +++ /dev/null @@ -1,52 +0,0 @@ -cdist-type__hostname(7) -======================= - -NAME ----- -cdist-type__hostname - Set the hostname - - -DESCRIPTION ------------ -Set's the hostname on various operating systems. - - -REQUIRED PARAMETERS -------------------- -None. - -OPTIONAL PARAMETERS -------------------- -name - The hostname to set. Defaults to the first segment of __target_host - (${__target_host%%.*}) - - -MESSAGES --------- -changed - Changed the hostname - -EXAMPLES --------- - -.. code-block:: sh - - # take hostname from __target_host - __hostname - - # set hostname explicitly - __hostname --name some-static-hostname - - -AUTHORS -------- -Steven Armstrong - - -COPYING -------- -Copyright \(C) 2012 Steven Armstrong. 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. diff --git a/cdist/conf/type/__hostname/man.text b/cdist/conf/type/__hostname/man.text new file mode 100644 index 00000000..ac44d426 --- /dev/null +++ b/cdist/conf/type/__hostname/man.text @@ -0,0 +1,52 @@ +cdist-type__hostname(7) +======================= +Steven Armstrong + + +NAME +---- +cdist-type__hostname - set the hostname + + +DESCRIPTION +----------- +Set's the hostname on various operating systems. + + +REQUIRED PARAMETERS +------------------- +None. + +OPTIONAL PARAMETERS +------------------- +name:: + The hostname to set. Defaults to the first segment of __target_host + (${__target_host%%.*}) + + +MESSAGES +-------- +changed:: + Changed the hostname + +EXAMPLES +-------- + +-------------------------------------------------------------------------------- +# take hostname from __target_host +__hostname + +# set hostname explicitly +__hostname --name some-static-hostname +-------------------------------------------------------------------------------- + + +SEE ALSO +-------- +- cdist-type(7) + + +COPYING +------- +Copyright \(C) 2012 Steven Armstrong. Free use of this software is +granted under the terms of the GNU General Public License version 3 (GPLv3). diff --git a/cdist/conf/type/__hostname/manifest b/cdist/conf/type/__hostname/manifest index 8f1adf12..b6985c1c 100755 --- a/cdist/conf/type/__hostname/manifest +++ b/cdist/conf/type/__hostname/manifest @@ -1,4 +1,4 @@ -#!/bin/sh -e +#!/bin/sh # # 2012 Steven Armstrong (steven-cdist at armstrong.cc) # 2014 Nico Schottelius (nico-cdist at schottelius.org) @@ -23,14 +23,7 @@ os=$(cat "$__global/explorer/os") if [ -f "$__object/parameter/name" ]; then name_should="$(cat "$__object/parameter/name")" else - case "$os" in - openbsd) - name_should="${__target_host}" - ;; - *) - name_should="${__target_host%%.*}" - ;; - esac + name_should="$(echo "${__target_host%%.*}")" fi @@ -41,27 +34,17 @@ not_supported() { } case "$os" in - archlinux|debian|suse|ubuntu|devuan|coreos|alpine) + archlinux|debian|ubuntu) # handled in gencode-remote : ;; - scientific|centos) + centos) __key_value sysconfig-hostname \ --file /etc/sysconfig/network \ --delimiter '=' \ --key HOSTNAME \ --value "$name_should" --exact_delimiter ;; - freebsd) - __key_value rcconf-hostname \ - --file /etc/rc.conf \ - --delimiter '=' \ - --key 'hostname' \ - --value "$name_should" - ;; - openbsd) - echo "$name_should" | __file /etc/myname --source - - ;; *) not_supported ;; diff --git a/cdist/conf/type/__hosts/man.rst b/cdist/conf/type/__hosts/man.rst deleted file mode 100644 index bece7967..00000000 --- a/cdist/conf/type/__hosts/man.rst +++ /dev/null @@ -1,55 +0,0 @@ -cdist-type__hosts(7) -==================== - -NAME ----- - -cdist-type__hosts - manage entries in /etc/hosts - -DESCRIPTION ------------ - -Add or remove entries from */etc/hosts* file. - -OPTIONAL PARAMETERS -------------------- - -state - If state is ``present``, make *object_id* resolve to *ip*. If - state is ``absent``, *object_id* will no longer resolve via - */etc/hosts*, if it was previously configured with this type. - Manually inserted entries are unaffected. - -ip - IP address, to which hostname (=\ *object_id*) must resolve. If - state is ``present``, this parameter is mandatory, if state is - ``absent``, this parameter is silently ignored. - -EXAMPLES --------- - -.. code-block:: sh - - # Now `funny' resolves to 192.168.1.76, - __hosts funny --ip 192.168.1.76 - # and `happy' no longer resolve via /etc/hosts if it was - # previously configured via __hosts. - __hosts happy --state absent - -SEE ALSO --------- - -:strong:`hosts`\ (5) - -AUTHORS -------- - -Dmitry Bogatov - - -COPYING -------- - -Copyright (C) 2015,2016 Dmitry Bogatov. Free use of this software is granted -under the terms of the GNU General Public License version 3 or later -(GPLv3+). diff --git a/cdist/conf/type/__hosts/manifest b/cdist/conf/type/__hosts/manifest deleted file mode 100755 index c536b83b..00000000 --- a/cdist/conf/type/__hosts/manifest +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/sh -e -# Copyright (C) 2015 Bogatov Dmitry -# -# This program 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. -# -# This program 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 this program. If not, see . -set -ue - -hostname="$__object_id" -state="$(cat "$__object/parameter/state")" -marker="# __hosts/$hostname" - -set -- "__hosts/$hostname" --file /etc/hosts --state "$state" - -if [ "$state" = absent ] ; then - __line "$@" --regex "$marker" -else - ip="$(cat "$__object/parameter/ip")" - __line "$@" --line "$ip $hostname $marker" -fi diff --git a/cdist/conf/type/__hosts/parameter/default/state b/cdist/conf/type/__hosts/parameter/default/state deleted file mode 100644 index e7f6134f..00000000 --- a/cdist/conf/type/__hosts/parameter/default/state +++ /dev/null @@ -1 +0,0 @@ -present diff --git a/cdist/conf/type/__hosts/parameter/optional b/cdist/conf/type/__hosts/parameter/optional deleted file mode 100644 index 411fc5d2..00000000 --- a/cdist/conf/type/__hosts/parameter/optional +++ /dev/null @@ -1,2 +0,0 @@ -state -ip diff --git a/cdist/conf/type/__install_bootloader_grub/explorer/target_os b/cdist/conf/type/__install_bootloader_grub/explorer/target_os deleted file mode 100755 index f235710a..00000000 --- a/cdist/conf/type/__install_bootloader_grub/explorer/target_os +++ /dev/null @@ -1,100 +0,0 @@ -#!/bin/sh -# -# 2010-2011 Nico Schottelius (nico-cdist at schottelius.org) -# 2014 Steven Armstrong (steven-cdist at armstrong.cc) -# -# This file is part of cdist. -# -# cdist is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# cdist is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with cdist. If not, see . -# -# -# All os variables are lower case. Keep this file in alphabetical -# order by os variable except in cases where order otherwise matters, -# in which case keep the primary os and its derivatives together in -# a block (see Debian and Redhat examples below). -# - -chroot="$(cat "$__object/parameter/chroot")" - -if grep -q ^Amazon "$chroot/etc/system-release" 2>/dev/null; then - echo amazon - exit 0 -fi - -if [ -f "$chroot/etc/arch-release" ]; then - echo archlinux - exit 0 -fi - -if [ -f "$chroot/etc/cdist-preos" ]; then - echo cdist-preos - exit 0 -fi - -### Debian and derivatives -if grep -q ^DISTRIB_ID=Ubuntu "$chroot/etc/lsb-release" 2>/dev/null; then - echo ubuntu - exit 0 -fi - -if [ -f "$chroot/etc/debian_version" ]; then - echo debian - exit 0 -fi -### - -if [ -f "$chroot/etc/gentoo-release" ]; then - echo gentoo - exit 0 -fi - -if [ -f "$chroot/etc/openwrt_version" ]; then - echo openwrt - exit 0 -fi - -if [ -f "$chroot/etc/owl-release" ]; then - echo owl - exit 0 -fi - -### Redhat and derivatives -if grep -q ^CentOS "$chroot/etc/redhat-release" 2>/dev/null; then - echo centos - exit 0 -fi - -if grep -q ^Fedora "$chroot/etc/redhat-release" 2>/dev/null; then - echo fedora - exit 0 -fi - -if [ -f "$chroot/etc/redhat-release" ]; then - echo redhat - exit 0 -fi -### - -if [ -f "$chroot/etc/SuSE-release" ]; then - echo suse - exit 0 -fi - -if [ -f "$chroot/etc/slackware-version" ]; then - echo slackware - exit 0 -fi - -echo "Unknown OS" >&2 -exit 1 diff --git a/cdist/conf/type/__install_bootloader_grub/gencode-remote b/cdist/conf/type/__install_bootloader_grub/gencode-remote deleted file mode 100755 index 1caebbbf..00000000 --- a/cdist/conf/type/__install_bootloader_grub/gencode-remote +++ /dev/null @@ -1,97 +0,0 @@ -#!/bin/sh -e -# -# 2011-2015 Steven Armstrong (steven-cdist at armstrong.cc) -# -# This file is part of cdist. -# -# cdist is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# cdist is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with cdist. If not, see . -# - -device="$(cat "$__object/parameter/device" 2>/dev/null || echo "/$__object_id")" -chroot="$(cat "$__object/parameter/chroot")" - -target_os=$(cat "$__object/explorer/target_os") - -mkdir "$__object/files" -install_script="$__object/files/install_script" -# Link file descriptor #6 with stdout -exec 6>&1 -# Link stdout with $install_script -exec > "$install_script" - -# Generate script to install bootloader on distro -printf '#!/bin/sh -l\n' - -case "$target_os" in - ubuntu|debian) - if [ -s "$__global/explorer/efi" ]; then - # FIXME: untested. maybe also just run update-grub for EFI system? - printf 'grub-mkconfig --output=/boot/efi/EFI/%s/grub.cfg\n' "$target_os" - printf 'mkdir -p /boot/efi/EFI/BOOT\n' - printf 'cp /boot/efi/EFI/%s/grubx64.efi /boot/efi/EFI/BOOT/bootx64.efi' "$target_os" - else - printf 'grub-install "%s"\n' "$device" - printf 'update-grub\n' - fi - ;; - archlinux) - if [ -s "$__global/explorer/efi" ]; then - echo "EFI boot loader installation is on your operating system ($target_os) is currently not supported by this type (${__type##*/})." >&2 - echo "Please contribute an implementation for it if you can." >&2 - exit 1 - else - printf 'grub-install "%s"\n' "$device" - # bugfix/workarround: rebuild initramfs - # FIXME: doesn't belong here - printf 'mkinitcpio -p linux\n' - printf 'grub-mkconfig -o /boot/grub/grub.cfg\n' - fi - ;; - centos) - if [ -s "$__global/explorer/efi" ]; then - printf 'grub2-mkconfig --output=/boot/efi/EFI/%s/grub.cfg\n' "$target_os" - printf 'mkdir -p /boot/efi/EFI/BOOT\n' - printf 'cp /boot/efi/EFI/%s/grubx64.efi /boot/efi/EFI/BOOT/bootx64.efi' "$target_os" - else - printf 'grub2-install "%s"\n' "$device" - printf 'grub2-mkconfig --output=/boot/grub2/grub.cfg\n' - fi - ;; - *) - echo "Your operating system ($target_os) is currently not supported by this type (${__type##*/})." >&2 - echo "If you can, please contribute an implementation for it." >&2 - exit 1 - ;; -esac -# Restore stdout and close file descriptor #6. -exec 1>&6 6>&- - - -cat << DONE -# Ensure /tmp exists -[ -d "${chroot}/tmp" ] || mkdir -m 1777 "${chroot}/tmp" -# Generate script to run in chroot -script=\$(mktemp "${chroot}/tmp/${__type##*/}.XXXXXXXXXX") -cat > \$script << script_DONE -$(cat "$install_script") -script_DONE - -# Make script executable -chmod +x "\$script" - -# Run script in chroot -relative_script="\${script#$chroot}" -chroot "$chroot" "\$relative_script" -rm -rf \$script -DONE diff --git a/cdist/conf/type/__install_bootloader_grub/install b/cdist/conf/type/__install_bootloader_grub/install deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/conf/type/__install_bootloader_grub/man.rst b/cdist/conf/type/__install_bootloader_grub/man.rst deleted file mode 100644 index 625db1d2..00000000 --- a/cdist/conf/type/__install_bootloader_grub/man.rst +++ /dev/null @@ -1,48 +0,0 @@ -cdist-type__install_bootloader_grub(7) -====================================== - -NAME ----- -cdist-type__install_bootloader_grub - install grub2 bootloader on given disk - - -DESCRIPTION ------------ -This cdist type allows you to install grub2 bootloader on given disk. - - -REQUIRED PARAMETERS -------------------- -None - - -OPTIONAL PARAMETERS -------------------- -device - The device to install grub to. Defaults to object_id - -chroot - where to chroot before running grub-install. Defaults to /target. - - -EXAMPLES --------- - -.. code-block:: sh - - __install_bootloader_grub /dev/sda - - __install_bootloader_grub /dev/sda --chroot /mnt/foobar - - -AUTHORS -------- -Steven Armstrong - - -COPYING -------- -Copyright \(C) 2011 Steven Armstrong. 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. diff --git a/cdist/conf/type/__install_bootloader_grub/parameter/default/chroot b/cdist/conf/type/__install_bootloader_grub/parameter/default/chroot deleted file mode 100644 index ea8c4bf7..00000000 --- a/cdist/conf/type/__install_bootloader_grub/parameter/default/chroot +++ /dev/null @@ -1 +0,0 @@ -/target diff --git a/cdist/conf/type/__install_bootloader_grub/parameter/optional b/cdist/conf/type/__install_bootloader_grub/parameter/optional deleted file mode 100644 index 0bd1ce46..00000000 --- a/cdist/conf/type/__install_bootloader_grub/parameter/optional +++ /dev/null @@ -1,2 +0,0 @@ -device -chroot diff --git a/cdist/conf/type/__install_chroot_mount/gencode-local b/cdist/conf/type/__install_chroot_mount/gencode-local deleted file mode 120000 index 68dcbd6a..00000000 --- a/cdist/conf/type/__install_chroot_mount/gencode-local +++ /dev/null @@ -1 +0,0 @@ -../__chroot_mount/gencode-local \ No newline at end of file diff --git a/cdist/conf/type/__install_chroot_mount/gencode-remote b/cdist/conf/type/__install_chroot_mount/gencode-remote deleted file mode 120000 index b1a5485e..00000000 --- a/cdist/conf/type/__install_chroot_mount/gencode-remote +++ /dev/null @@ -1 +0,0 @@ -../__chroot_mount/gencode-remote \ No newline at end of file diff --git a/cdist/conf/type/__install_chroot_mount/install b/cdist/conf/type/__install_chroot_mount/install deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/conf/type/__install_chroot_mount/man.rst b/cdist/conf/type/__install_chroot_mount/man.rst deleted file mode 100644 index 4054c4c4..00000000 --- a/cdist/conf/type/__install_chroot_mount/man.rst +++ /dev/null @@ -1,42 +0,0 @@ -cdist-type__install_chroot_mount(7) -=================================== - -NAME ----- -cdist-type__install_chroot_mount - mount a chroot with install command - - -DESCRIPTION ------------ -Mount and prepare a chroot for running commands within it. - - -REQUIRED PARAMETERS -------------------- -None - - -OPTIONAL PARAMETERS -------------------- -None - - -EXAMPLES --------- - -.. code-block:: sh - - __install_chroot_mount /path/to/chroot - - -AUTHORS -------- -Steven Armstrong - - -COPYING -------- -Copyright \(C) 2012 Steven Armstrong. 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. diff --git a/cdist/conf/type/__install_chroot_mount/parameter b/cdist/conf/type/__install_chroot_mount/parameter deleted file mode 120000 index 5b5c9e20..00000000 --- a/cdist/conf/type/__install_chroot_mount/parameter +++ /dev/null @@ -1 +0,0 @@ -../__chroot_mount/parameter \ No newline at end of file diff --git a/cdist/conf/type/__install_chroot_umount/gencode-remote b/cdist/conf/type/__install_chroot_umount/gencode-remote deleted file mode 120000 index f2bd2681..00000000 --- a/cdist/conf/type/__install_chroot_umount/gencode-remote +++ /dev/null @@ -1 +0,0 @@ -../__chroot_umount/gencode-remote \ No newline at end of file diff --git a/cdist/conf/type/__install_chroot_umount/install b/cdist/conf/type/__install_chroot_umount/install deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/conf/type/__install_chroot_umount/man.rst b/cdist/conf/type/__install_chroot_umount/man.rst deleted file mode 100644 index 2e020c01..00000000 --- a/cdist/conf/type/__install_chroot_umount/man.rst +++ /dev/null @@ -1,47 +0,0 @@ -cdist-type__install_chroot_umount(7) -==================================== - -NAME ----- -cdist-type__install_chroot_umount - unmount a chroot mounted by __install_chroot_mount - - -DESCRIPTION ------------ -Undo what __install_chroot_mount did. - - -REQUIRED PARAMETERS -------------------- -None - - -OPTIONAL PARAMETERS -------------------- -None - - -EXAMPLES --------- - -.. code-block:: sh - - __install_chroot_umount /path/to/chroot - - -SEE ALSO --------- -:strong:`cdist-type__install_chroot_mount`\ (7) - - -AUTHORS -------- -Steven Armstrong - - -COPYING -------- -Copyright \(C) 2012 Steven Armstrong. 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. diff --git a/cdist/conf/type/__install_chroot_umount/parameter b/cdist/conf/type/__install_chroot_umount/parameter deleted file mode 120000 index 4148bcd0..00000000 --- a/cdist/conf/type/__install_chroot_umount/parameter +++ /dev/null @@ -1 +0,0 @@ -../__chroot_umount/parameter \ No newline at end of file diff --git a/cdist/conf/type/__install_config/files/remote/copy b/cdist/conf/type/__install_config/files/remote/copy deleted file mode 100755 index fa7fa9b7..00000000 --- a/cdist/conf/type/__install_config/files/remote/copy +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/sh -e -# -# 2011-2017 Steven Armstrong (steven-cdist at armstrong.cc) -# -# This file is part of cdist. -# -# cdist is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# cdist is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with cdist. If not, see . -# -# -# __remote_copy script to run cdist against a chroot on a remote host via ssh. -# -# Usage: -# __remote_copy="/path/to/this/script /path/to/your/chroot" cdist config target-id -# - -log() { - #echo "$@" | logger -t "__install_config copy" - : -} - -chroot="$1"; shift -target_host="$__target_host" - -# postfix target_host with chroot location -code="$(echo "$@" | sed "s|$target_host:|$target_host:$chroot|g")" - -log "target_host: $target_host" -log "chroot: $chroot" -log "@: $*" -log "code: $code" - -# copy files into chroot -# __default_remote_copy and code should be split -# shellcheck disable=SC2086 -$__default_remote_copy $code - -log "-----" diff --git a/cdist/conf/type/__install_config/files/remote/exec b/cdist/conf/type/__install_config/files/remote/exec deleted file mode 100755 index c2057ebf..00000000 --- a/cdist/conf/type/__install_config/files/remote/exec +++ /dev/null @@ -1,52 +0,0 @@ -#!/bin/sh -e -# -# 2011-2017 Steven Armstrong (steven-cdist at armstrong.cc) -# -# This file is part of cdist. -# -# cdist is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# cdist is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with cdist. If not, see . -# -# -# __remote_exec script to run cdist against a chroot on a remote host via ssh. -# -# Usage: -# __remote_exec="/path/to/this/script /path/to/your/chroot" cdist config target-id -# - -log() { - #echo "$@" | logger -t "__install_config exec" - : -} - -chroot="$1"; shift -target_host="$__target_host" -# In exec mode the first argument is the __target_host which we already got from env. Get rid of it. -shift - -# escape ' with '"'"' -code="$(echo "$@" | sed -e "s/'/'\"'\"'/g")" -# shellcheck disable=SC2089 -code="chroot $chroot sh -e -c '$code'" - -log "target_host: $target_host" -log "chroot: $chroot" -log "@: $*" -log "code: $code" - -# Run the code -# __default_remote_exec and code should be split -# shellcheck disable=SC2086,SC2090 -$__default_remote_exec "$target_host" $code - -log "-----" diff --git a/cdist/conf/type/__install_config/gencode-local b/cdist/conf/type/__install_config/gencode-local deleted file mode 100755 index dd4f2a78..00000000 --- a/cdist/conf/type/__install_config/gencode-local +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/sh -e -# -# 2011-2018 Steven Armstrong (steven-cdist at armstrong.cc) -# -# This file is part of cdist. -# -# cdist is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# cdist is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with cdist. If not, see . -# - -chroot="$(cat "$__object/parameter/chroot")" -remote_exec="$__type/files/remote/exec" -remote_copy="$__type/files/remote/copy" - -cat << DONE -export __cdist_install_config=yes -export __cdist_log_level=$__cdist_log_level -export __default_remote_exec="$__remote_exec" -export __default_remote_copy="$__remote_copy" -cdist config \ - --remote-exec="$remote_exec $chroot" \ - --remote-copy="$remote_copy $chroot" \ - $__target_host -DONE - diff --git a/cdist/conf/type/__install_config/install b/cdist/conf/type/__install_config/install deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/conf/type/__install_config/man.rst b/cdist/conf/type/__install_config/man.rst deleted file mode 100644 index 0034e85d..00000000 --- a/cdist/conf/type/__install_config/man.rst +++ /dev/null @@ -1,47 +0,0 @@ -cdist-type__install_config(7) -============================= - -NAME ----- -cdist-type__install_config - run cdist config as part of the installation - - -DESCRIPTION ------------ -This cdist type allows you to run cdist config as part of the installation. -It does this by using a custom __remote_{copy,exec} prefix which runs -cdist config against the /target chroot on the remote host. - - -REQUIRED PARAMETERS -------------------- -None - - -OPTIONAL PARAMETERS -------------------- -chroot - where to chroot before running grub-install. Defaults to /target. - - -EXAMPLES --------- - -.. code-block:: sh - - __install_config - - __install_config --chroot /mnt/somewhere - - -AUTHORS -------- -Steven Armstrong - - -COPYING -------- -Copyright \(C) 2011 Steven Armstrong. 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. diff --git a/cdist/conf/type/__install_config/parameter/default/chroot b/cdist/conf/type/__install_config/parameter/default/chroot deleted file mode 100644 index ea8c4bf7..00000000 --- a/cdist/conf/type/__install_config/parameter/default/chroot +++ /dev/null @@ -1 +0,0 @@ -/target diff --git a/cdist/conf/type/__install_config/parameter/optional b/cdist/conf/type/__install_config/parameter/optional deleted file mode 100644 index fa32393d..00000000 --- a/cdist/conf/type/__install_config/parameter/optional +++ /dev/null @@ -1 +0,0 @@ -chroot diff --git a/cdist/conf/type/__install_config/singleton b/cdist/conf/type/__install_config/singleton deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/conf/type/__install_coreos/gencode-remote b/cdist/conf/type/__install_coreos/gencode-remote deleted file mode 100755 index f550b5a5..00000000 --- a/cdist/conf/type/__install_coreos/gencode-remote +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/sh -e - -device=$(cat "${__object:?}/parameter/device") -ignition=$(cat "${__object}/parameter/ignition") - -cat < "\${ignition_file}" << eof -$(base64 "${ignition}") -eof - -coreos-install -d "${device}" \ - \$(if [ -s "\${ignition_file}" ]; then - printf -- "-i \${ignition_file}\\n" - fi) - -rm "\${ignition_file}" -EOF diff --git a/cdist/conf/type/__install_coreos/install b/cdist/conf/type/__install_coreos/install deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/conf/type/__install_coreos/man.rst b/cdist/conf/type/__install_coreos/man.rst deleted file mode 100644 index 314f9f2a..00000000 --- a/cdist/conf/type/__install_coreos/man.rst +++ /dev/null @@ -1,50 +0,0 @@ -cdist-type__install_coreos(7) -============================= - -NAME ----- - -cdist-type__install_coreos - Install CoreOS - -DESCRIPTION ------------ - -This type installs CoreOS to a given device using coreos-install_, which is -present in CoreOS ISO by default. - -.. _coreos-install: https://raw.githubusercontent.com/coreos/init/master/bin/coreos-install - -REQUIRED PARAMETERS -------------------- - -device - A device CoreOS will be installed to. - -OPTIONAL PARAMETERS -------------------- - -ignition - Path to ignition config. - -EXAMPLES --------- - -.. code-block:: sh - - __install_coreos \ - --device /dev/sda \ - --ignition ignition.json - - -AUTHORS -------- - -Ľubomír Kučera - -COPYING -------- - -Copyright \(C) 2018 Ľubomír Kučera. 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. diff --git a/cdist/conf/type/__install_coreos/parameter/default/ignition b/cdist/conf/type/__install_coreos/parameter/default/ignition deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/conf/type/__install_coreos/parameter/optional b/cdist/conf/type/__install_coreos/parameter/optional deleted file mode 100644 index df284caa..00000000 --- a/cdist/conf/type/__install_coreos/parameter/optional +++ /dev/null @@ -1 +0,0 @@ -ignition diff --git a/cdist/conf/type/__install_coreos/parameter/required b/cdist/conf/type/__install_coreos/parameter/required deleted file mode 100644 index f89ee6a8..00000000 --- a/cdist/conf/type/__install_coreos/parameter/required +++ /dev/null @@ -1 +0,0 @@ -device diff --git a/cdist/conf/type/__install_coreos/singleton b/cdist/conf/type/__install_coreos/singleton deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/conf/type/__install_directory/explorer b/cdist/conf/type/__install_directory/explorer deleted file mode 120000 index ba2591e1..00000000 --- a/cdist/conf/type/__install_directory/explorer +++ /dev/null @@ -1 +0,0 @@ -../__directory/explorer \ No newline at end of file diff --git a/cdist/conf/type/__install_directory/gencode-remote b/cdist/conf/type/__install_directory/gencode-remote deleted file mode 120000 index c86d61c9..00000000 --- a/cdist/conf/type/__install_directory/gencode-remote +++ /dev/null @@ -1 +0,0 @@ -../__directory/gencode-remote \ No newline at end of file diff --git a/cdist/conf/type/__install_directory/install b/cdist/conf/type/__install_directory/install deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/conf/type/__install_directory/man.rst b/cdist/conf/type/__install_directory/man.rst deleted file mode 120000 index 1ad7fa84..00000000 --- a/cdist/conf/type/__install_directory/man.rst +++ /dev/null @@ -1 +0,0 @@ -../__directory/man.rst \ No newline at end of file diff --git a/cdist/conf/type/__install_directory/parameter b/cdist/conf/type/__install_directory/parameter deleted file mode 120000 index e23d9672..00000000 --- a/cdist/conf/type/__install_directory/parameter +++ /dev/null @@ -1 +0,0 @@ -../__directory/parameter \ No newline at end of file diff --git a/cdist/conf/type/__install_file/explorer b/cdist/conf/type/__install_file/explorer deleted file mode 120000 index 8479ee44..00000000 --- a/cdist/conf/type/__install_file/explorer +++ /dev/null @@ -1 +0,0 @@ -../__file/explorer \ No newline at end of file diff --git a/cdist/conf/type/__install_file/gencode-local b/cdist/conf/type/__install_file/gencode-local deleted file mode 120000 index 9ce4e805..00000000 --- a/cdist/conf/type/__install_file/gencode-local +++ /dev/null @@ -1 +0,0 @@ -../__file/gencode-local \ No newline at end of file diff --git a/cdist/conf/type/__install_file/gencode-remote b/cdist/conf/type/__install_file/gencode-remote deleted file mode 120000 index f390bba4..00000000 --- a/cdist/conf/type/__install_file/gencode-remote +++ /dev/null @@ -1 +0,0 @@ -../__file/gencode-remote \ No newline at end of file diff --git a/cdist/conf/type/__install_file/install b/cdist/conf/type/__install_file/install deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/conf/type/__install_file/man.rst b/cdist/conf/type/__install_file/man.rst deleted file mode 100644 index c5409167..00000000 --- a/cdist/conf/type/__install_file/man.rst +++ /dev/null @@ -1,112 +0,0 @@ -cdist-type__install_file(7) -=========================== - -NAME ----- -cdist-type__install_file - Manage files with install command. - - -DESCRIPTION ------------ -This cdist type allows you to create files, remove files and set file -attributes on the target. - -If the file already exists on the target, then if it is a: - -regular file, and state is: - present - replace it with the source file if they are not equal - exists - do nothing -symlink - replace it with the source file -directory - replace it with the source file - -In any case, make sure that the file attributes are as specified. - - -REQUIRED PARAMETERS -------------------- -None. - -OPTIONAL PARAMETERS -------------------- -state - 'present', 'absent' or 'exists', defaults to 'present' where: - - present - the file is exactly the one from source - absent - the file does not exist - exists - the file from source but only if it doesn't already exist - -group - Group to chgrp to. - -mode - Unix permissions, suitable for chmod. - -owner - User to chown to. - -source - If supplied, copy this file from the host running cdist to the target. - If not supplied, an empty file or directory will be created. - If source is '-' (dash), take what was written to stdin as the file content. - -MESSAGES --------- -chgrp - Changed group membership -chown - Changed owner -chmod - Changed mode -create - Empty file was created (no --source specified) -remove - File exists, but state is absent, file will be removed by generated code. -upload - File was uploaded - - -EXAMPLES --------- - -.. code-block:: sh - - # Create /etc/cdist-configured as an empty file - __install_file /etc/cdist-configured - # The same thing - __install_file /etc/cdist-configured --state present - # Use __file from another type - __install_file /etc/issue --source "$__type/files/archlinux" --state present - # Delete existing file - __install_file /etc/cdist-configured --state absent - # Supply some more settings - __install_file /etc/shadow --source "$__type/files/shadow" \ - --owner root --group shadow --mode 0640 \ - --state present - # Provide a default file, but let the user change it - __install_file /home/frodo/.bashrc --source "/etc/skel/.bashrc" \ - --state exists \ - --owner frodo --mode 0600 - # Take file content from stdin - __install_file /tmp/whatever --owner root --group root --mode 644 --source - << DONE - Here goes the content for /tmp/whatever - DONE - - -AUTHORS -------- -Nico Schottelius - - -COPYING -------- -Copyright \(C) 2011-2013 Nico Schottelius. 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. diff --git a/cdist/conf/type/__install_file/parameter b/cdist/conf/type/__install_file/parameter deleted file mode 120000 index e5099e86..00000000 --- a/cdist/conf/type/__install_file/parameter +++ /dev/null @@ -1 +0,0 @@ -../__file/parameter \ No newline at end of file diff --git a/cdist/conf/type/__install_fstab/install b/cdist/conf/type/__install_fstab/install deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/conf/type/__install_fstab/man.rst b/cdist/conf/type/__install_fstab/man.rst deleted file mode 100644 index 5562c139..00000000 --- a/cdist/conf/type/__install_fstab/man.rst +++ /dev/null @@ -1,53 +0,0 @@ -cdist-type__install_fstab(7) -============================ - -NAME ----- -cdist-type__install_fstab - generate /etc/fstab during installation - - -DESCRIPTION ------------ -Uses __install_generate_fstab to generate a /etc/fstab file and uploads it -to the target machine at ${prefix}/etc/fstab. - - -REQUIRED PARAMETERS -------------------- -None - - -OPTIONAL PARAMETERS -------------------- -prefix - The prefix under which to generate the /etc/fstab file. - Defaults to /target. - - -EXAMPLES --------- - -.. code-block:: sh - - __install_fstab - - __install_fstab --prefix /mnt/target - - -SEE ALSO --------- -:strong:`cdist-type__install_generate_fstab`\ (7), -:strong:`cdist-type__install_mount`\ (7) - - -AUTHORS -------- -Steven Armstrong - - -COPYING -------- -Copyright \(C) 2011 Steven Armstrong. 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. diff --git a/cdist/conf/type/__install_fstab/manifest b/cdist/conf/type/__install_fstab/manifest deleted file mode 100755 index c5d24f3c..00000000 --- a/cdist/conf/type/__install_fstab/manifest +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/sh -e -# -# 2011 Steven Armstrong (steven-cdist at armstrong.cc) -# -# This file is part of cdist. -# -# cdist is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# cdist is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with cdist. If not, see . -# - -prefix="$(cat "$__object/parameter/prefix" 2>/dev/null || echo "/target")" - -[ -d "$__object/files" ] || mkdir "$__object/files" -__install_generate_fstab --uuid --destination "$__object/files/fstab" -require="__install_generate_fstab" \ - __install_file "${prefix}/etc/fstab" --source "$__object/files/fstab" \ - --mode 644 \ - --owner root \ - --group root diff --git a/cdist/conf/type/__install_fstab/parameter/optional b/cdist/conf/type/__install_fstab/parameter/optional deleted file mode 100644 index f73f3093..00000000 --- a/cdist/conf/type/__install_fstab/parameter/optional +++ /dev/null @@ -1 +0,0 @@ -file diff --git a/cdist/conf/type/__install_fstab/singleton b/cdist/conf/type/__install_fstab/singleton deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/conf/type/__install_generate_fstab/files/fstab.header b/cdist/conf/type/__install_generate_fstab/files/fstab.header deleted file mode 100644 index 7653cc78..00000000 --- a/cdist/conf/type/__install_generate_fstab/files/fstab.header +++ /dev/null @@ -1 +0,0 @@ -# Generated by cdist __install_generate_fstab diff --git a/cdist/conf/type/__install_generate_fstab/gencode-local b/cdist/conf/type/__install_generate_fstab/gencode-local deleted file mode 100755 index 80455aaa..00000000 --- a/cdist/conf/type/__install_generate_fstab/gencode-local +++ /dev/null @@ -1,65 +0,0 @@ -#!/bin/sh -e -# -# 2011 Steven Armstrong (steven-cdist at armstrong.cc) -# -# This file is part of cdist. -# -# cdist is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# cdist is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with cdist. If not, see . -# - -destination="$(cat "$__object/parameter/destination")" -cat "$__type/files/fstab.header" > "$destination" - -mkdir "$__object/files" -# get current UUID's from target_host -$__remote_exec "$__target_host" blkid > "$__object/files/blkid" - -find "$__global/object/__install_mount" -type d -name "$__cdist_object_marker" | -while IFS= read -r object -do - device="$(cat "$object/parameter/device")" - dir="$(cat "$object/parameter/dir")" - type="$(cat "$object/parameter/type")" - if [ -f "$object/parameter/options" ]; then - options="$(cat "$object/parameter/options")" - else - options="defaults" - fi - dump=0 - case "$type" in - swap) - pass=0 - dir="$type" - ;; - tmpfs) - pass=0 - ;; - bind) - pass=0 - type=none - options="bind,$options" - ;; - *) - pass=1 - ;; - esac - if [ -f "$__object/parameter/uuid" ]; then - uuid="$(grep -w "$device" "$__object/files/blkid" | awk '{print $2}')" - if [ -n "$uuid" ]; then - echo "# $dir was on $device during installation" >> "$destination" - device="$uuid" - fi - fi - echo "$device $dir $type $options $dump $pass" >> "$destination" -done diff --git a/cdist/conf/type/__install_generate_fstab/install b/cdist/conf/type/__install_generate_fstab/install deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/conf/type/__install_generate_fstab/man.rst b/cdist/conf/type/__install_generate_fstab/man.rst deleted file mode 100644 index b38f8876..00000000 --- a/cdist/conf/type/__install_generate_fstab/man.rst +++ /dev/null @@ -1,53 +0,0 @@ -cdist-type__install_generate_fstab(7) -===================================== - -NAME ----- -cdist-type__install_generate_fstab - generate /etc/fstab during installation - - -DESCRIPTION ------------ -Generates a /etc/fstab file from information retrieved from -__install_mount definitions. - - -REQUIRED PARAMETERS -------------------- -destination - The path where to store the generated fstab file. - Note that this is a path on the server, where cdist is running, not the target host. - - -OPTIONAL PARAMETERS -------------------- -None - - -BOOLEAN PARAMETERS -------------------- -uuid - use UUID instead of device in fstab - - -EXAMPLES --------- - -.. code-block:: sh - - __install_generate_fstab --destination /path/where/you/want/fstab - - __install_generate_fstab --uuid --destination /path/where/you/want/fstab - - -AUTHORS -------- -Steven Armstrong - - -COPYING -------- -Copyright \(C) 2012 Steven Armstrong. 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. diff --git a/cdist/conf/type/__install_generate_fstab/parameter/boolean b/cdist/conf/type/__install_generate_fstab/parameter/boolean deleted file mode 100644 index 43ab6159..00000000 --- a/cdist/conf/type/__install_generate_fstab/parameter/boolean +++ /dev/null @@ -1 +0,0 @@ -uuid diff --git a/cdist/conf/type/__install_generate_fstab/parameter/required b/cdist/conf/type/__install_generate_fstab/parameter/required deleted file mode 100644 index ac459b09..00000000 --- a/cdist/conf/type/__install_generate_fstab/parameter/required +++ /dev/null @@ -1 +0,0 @@ -destination diff --git a/cdist/conf/type/__install_generate_fstab/singleton b/cdist/conf/type/__install_generate_fstab/singleton deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/conf/type/__install_mkfs/gencode-remote b/cdist/conf/type/__install_mkfs/gencode-remote deleted file mode 100755 index 8fc2c98e..00000000 --- a/cdist/conf/type/__install_mkfs/gencode-remote +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/sh -e -# -# 2011-2013 Steven Armstrong (steven-cdist at armstrong.cc) -# 2017 Nico Schottelius (nico-cdist at schottelius.org) -# -# This file is part of cdist. -# -# cdist is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# cdist is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with cdist. If not, see . -# - -device="$(cat "$__object/parameter/device")" -type="$(cat "$__object/parameter/type")" - -case "$type" in - swap) - echo "mkswap -f $device" - exit 0 - ;; - xfs) - command="mkfs.xfs -f -q" - ;; - - vfat) - command="mkfs.vfat" - ;; - - *) - command="mkfs -t $type -q" - ;; -esac - -if [ -f "$__object/parameter/options" ]; then - options="$(cat "$__object/parameter/options")" - command="$command $options" -fi - -command="$command $device" -if [ -f "$__object/parameter/blocks" ]; then - blocks="$(cat "$__object/parameter/blocks")" - command="$command $blocks" -fi -echo "$command" diff --git a/cdist/conf/type/__install_mkfs/install b/cdist/conf/type/__install_mkfs/install deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/conf/type/__install_mkfs/man.rst b/cdist/conf/type/__install_mkfs/man.rst deleted file mode 100644 index 6e5c9aa9..00000000 --- a/cdist/conf/type/__install_mkfs/man.rst +++ /dev/null @@ -1,62 +0,0 @@ -cdist-type__install_mkfs(7) -=========================== - -NAME ----- -cdist-type__install_mkfs - build a linux file system - - -DESCRIPTION ------------ -This cdist type is a wrapper for the mkfs command. - - -REQUIRED PARAMETERS -------------------- -type - The filesystem type to use. Same as used with mkfs -t. - - -OPTIONAL PARAMETERS -------------------- -device - defaults to object_id - -options - file system-specific options to be passed to the mkfs command - -blocks - the number of blocks to be used for the file system - - -EXAMPLES --------- - -.. code-block:: sh - - # reiserfs /dev/sda5 - __install_mkfs /dev/sda5 --type reiserfs - - # same thing with explicit device - __install_mkfs whatever --device /dev/sda5 --type reiserfs - - # jfs with journal on /dev/sda2 - __install_mkfs /dev/sda1 --type jfs --options "-j /dev/sda2" - - -SEE ALSO --------- -:strong:`mkfs`\ (8) - - -AUTHORS -------- -Steven Armstrong - - -COPYING -------- -Copyright \(C) 2011 Steven Armstrong. 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. diff --git a/cdist/conf/type/__install_mkfs/manifest b/cdist/conf/type/__install_mkfs/manifest deleted file mode 100755 index b0a21dae..00000000 --- a/cdist/conf/type/__install_mkfs/manifest +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/sh -e -# -# 2011 Steven Armstrong (steven-cdist at armstrong.cc) -# -# This file is part of cdist. -# -# cdist is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# cdist is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with cdist. If not, see . -# - -# set defaults -if [ ! -f "$__object/parameter/device" ]; then - device="/$__object_id" - echo "$device" > "$__object/parameter/device" -fi diff --git a/cdist/conf/type/__install_mkfs/parameter/optional b/cdist/conf/type/__install_mkfs/parameter/optional deleted file mode 100644 index 86aeae30..00000000 --- a/cdist/conf/type/__install_mkfs/parameter/optional +++ /dev/null @@ -1,3 +0,0 @@ -device -options -blocks diff --git a/cdist/conf/type/__install_mkfs/parameter/required b/cdist/conf/type/__install_mkfs/parameter/required deleted file mode 100644 index aa80e646..00000000 --- a/cdist/conf/type/__install_mkfs/parameter/required +++ /dev/null @@ -1 +0,0 @@ -type diff --git a/cdist/conf/type/__install_mount/gencode-remote b/cdist/conf/type/__install_mount/gencode-remote deleted file mode 100755 index 4415f0ff..00000000 --- a/cdist/conf/type/__install_mount/gencode-remote +++ /dev/null @@ -1,68 +0,0 @@ -#!/bin/sh -e -# -# 2011-2013 Steven Armstrong (steven-cdist at armstrong.cc) -# -# This file is part of cdist. -# -# cdist is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# cdist is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with cdist. If not, see . -# - -get_type_from_mkfs() { - _device="$1" - find "$__global/object/__install_mkfs" -type d -name "$__cdist_object_marker" | - while IFS= read -r mkfs_object - do - mkfs_device="$(cat "$mkfs_object/parameter/device")" - if [ "$_device" = "$mkfs_device" ]; then - cat "$mkfs_object/parameter/type" - break - fi - done - unset _device - unset mkfs_device - unset mkfs_object -} - -device="$(cat "$__object/parameter/device")" -dir="$(cat "$__object/parameter/dir")" -prefix="$(cat "$__object/parameter/prefix")" -if [ -f "$__object/parameter/type" ]; then - type="$(cat "$__object/parameter/type")" -else - type="$(get_type_from_mkfs "$device")" - # store for later use by others - echo "$type" > "$__object/parameter/type" -fi -[ -n "$type" ] || { - echo "Can't determine type for $__object" >&2 - exit 1 -} -if [ "$type" = "swap" ]; then - printf 'swapon "%s"\n' "$device" -else - mount_point="${prefix}${dir}" - printf '[ -d "%s" ] || mkdir -p "%s"\n' "$mount_point" "$mount_point" - printf 'mount' - if [ "$type" = "bind" ]; then - printf ' --bind' - device="${prefix}${device}" - else - printf ' -t "%s"' "$type" - fi - if [ -f "$__object/parameter/options" ]; then - printf ' -o %s' "$(cat "$__object/parameter/options")" - fi - printf ' "%s"' "$device" - printf ' "%s"\n' "$mount_point" -fi diff --git a/cdist/conf/type/__install_mount/install b/cdist/conf/type/__install_mount/install deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/conf/type/__install_mount/man.rst b/cdist/conf/type/__install_mount/man.rst deleted file mode 100644 index 256cef53..00000000 --- a/cdist/conf/type/__install_mount/man.rst +++ /dev/null @@ -1,65 +0,0 @@ -cdist-type__install_mount(7) -============================ - -NAME ----- -cdist-type__install_mount - mount filesystems in the installer - - -DESCRIPTION ------------ -Mounts filesystems in the installer. Collects data to generate /etc/fstab. - - -REQUIRED PARAMETERS -------------------- -device - the device to mount - - -OPTIONAL PARAMETERS -------------------- -dir - where to mount device. Defaults to object_id. - -options - mount options passed to mount(8) and used in /etc/fstab - -type - filesystem type passed to mount(8) and used in /etc/fstab. - If type is swap, 'dir' is ignored. - Defaults to the filesystem used in __install_mkfs for the same 'device'. - -prefix - the prefix to prepend to 'dir' when mounting in the installer. - Defaults to /target. - - -EXAMPLES --------- - -.. code-block:: sh - - __install_mount slash --dir / --device /dev/sda5 --options noatime - require="__install_mount/slash" __install_mount /boot --device /dev/sda1 - __install_mount swap --device /dev/sda2 --type swap - require="__install_mount/slash" __install_mount /tmp --device tmpfs --type tmpfs - - -SEE ALSO --------- -:strong:`cdist-type__install_mkfs`\ (7), -:strong:`cdist-type__install_mount_apply` (7) - - -AUTHORS -------- -Steven Armstrong - - -COPYING -------- -Copyright \(C) 2011 Steven Armstrong. 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. diff --git a/cdist/conf/type/__install_mount/manifest b/cdist/conf/type/__install_mount/manifest deleted file mode 100755 index 72fc26e2..00000000 --- a/cdist/conf/type/__install_mount/manifest +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/sh -e -# -# 2011 Steven Armstrong (steven-cdist at armstrong.cc) -# -# This file is part of cdist. -# -# cdist is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# cdist is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with cdist. If not, see . -# - -# set defaults -if [ ! -f "$__object/parameter/dir" ]; then - dir="/$__object_id" - echo "$dir" > "$__object/parameter/dir" -fi -if [ ! -f "$__object/parameter/prefix" ]; then - prefix="/target" - echo "$prefix" > "$__object/parameter/prefix" -fi diff --git a/cdist/conf/type/__install_mount/parameter/optional b/cdist/conf/type/__install_mount/parameter/optional deleted file mode 100644 index 08b6ad04..00000000 --- a/cdist/conf/type/__install_mount/parameter/optional +++ /dev/null @@ -1,3 +0,0 @@ -dir -type -options diff --git a/cdist/conf/type/__install_mount/parameter/required b/cdist/conf/type/__install_mount/parameter/required deleted file mode 100644 index f89ee6a8..00000000 --- a/cdist/conf/type/__install_mount/parameter/required +++ /dev/null @@ -1 +0,0 @@ -device diff --git a/cdist/conf/type/__install_partition_msdos/install b/cdist/conf/type/__install_partition_msdos/install deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/conf/type/__install_partition_msdos/man.rst b/cdist/conf/type/__install_partition_msdos/man.rst deleted file mode 100644 index c408a614..00000000 --- a/cdist/conf/type/__install_partition_msdos/man.rst +++ /dev/null @@ -1,72 +0,0 @@ -cdist-type__install_partition_msdos(7) -====================================== - -NAME ----- -cdist-type__install_partition_msdos - creates msdos partitions - - -DESCRIPTION ------------ -This cdist type allows you to create msdos paritions. - - -REQUIRED PARAMETERS -------------------- -type - the partition type used in fdisk (such as 82 or 83) or "extended" - - -OPTIONAL PARAMETERS -------------------- -device - the device we're working on. Defaults to the string prefix of --partition - -minor - the partition number we're working on. Defaults to the numeric suffix of --partition - -partition - defaults to object_id - -bootable - mark partition as bootable, true or false, defaults to false - -size - the size of the partition (such as 32M or 15G, whole numbers - only), '+' for remaining space, or 'n%' for percentage of remaining - (these should only be used after all specific partition sizes are - specified). Defaults to +. - - -EXAMPLES --------- - -.. code-block:: sh - - # 128MB, linux, bootable - __install_partition_msdos /dev/sda1 --type 83 --size 128M --bootable true - # 512MB, swap - __install_partition_msdos /dev/sda2 --type 82 --size 512M - # 100GB, extended - __install_partition_msdos /dev/sda3 --type extended --size 100G - # 10GB, linux - __install_partition_msdos /dev/sda5 --type 83 --size 10G - # 50% of the free space of the extended partition, linux - __install_partition_msdos /dev/sda6 --type 83 --size 50% - # rest of the extended partition, linux - __install_partition_msdos /dev/sda7 --type 83 --size + - # nvm device partition 2 - __install_partition_msdos /dev/nvme0n1p2 --device /dev/nvme0n1 --minor 2 --type 83 --size 128M --bootable true - - -AUTHORS -------- -Steven Armstrong - - -COPYING -------- -Copyright \(C) 2011-2017 Steven Armstrong. 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. diff --git a/cdist/conf/type/__install_partition_msdos/manifest b/cdist/conf/type/__install_partition_msdos/manifest deleted file mode 100755 index b32605fa..00000000 --- a/cdist/conf/type/__install_partition_msdos/manifest +++ /dev/null @@ -1,46 +0,0 @@ -#!/bin/sh -e -# -# 2011 Steven Armstrong (steven-cdist at armstrong.cc) -# -# This file is part of cdist. -# -# cdist is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# cdist is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with cdist. If not, see . -# - -# set defaults -if [ -f "$__object/parameter/partition" ]; then - partition="(cat "$__object/parameter/partition")" -else - partition="/$__object_id" - echo "$partition" > "$__object/parameter/partition" -fi - -if [ ! -f "$__object/parameter/device" ]; then - device="$(echo "$partition" | sed 's/[0-9]//g')" - echo "$device" > "$__object/parameter/device" -fi -if [ ! -f "$__object/parameter/minor" ]; then - minor="$(echo "$partition" | sed 's/[^0-9]//g')" - echo "$minor" > "$__object/parameter/minor" -fi - -if [ ! -f "$__object/parameter/bootable" ]; then - echo "false" > "$__object/parameter/bootable" -fi -if [ ! -f "$__object/parameter/size" ]; then - echo "+" > "$__object/parameter/size" -fi - -# pull in the type that actually does something with the above parameters -require="$__object_name" __install_partition_msdos_apply diff --git a/cdist/conf/type/__install_partition_msdos/parameter/optional b/cdist/conf/type/__install_partition_msdos/parameter/optional deleted file mode 100644 index 3b3f2083..00000000 --- a/cdist/conf/type/__install_partition_msdos/parameter/optional +++ /dev/null @@ -1,5 +0,0 @@ -device -minor -partition -bootable -size diff --git a/cdist/conf/type/__install_partition_msdos/parameter/required b/cdist/conf/type/__install_partition_msdos/parameter/required deleted file mode 100644 index aa80e646..00000000 --- a/cdist/conf/type/__install_partition_msdos/parameter/required +++ /dev/null @@ -1 +0,0 @@ -type diff --git a/cdist/conf/type/__install_partition_msdos_apply/explorer/partitions b/cdist/conf/type/__install_partition_msdos_apply/explorer/partitions deleted file mode 100755 index 6be61af4..00000000 --- a/cdist/conf/type/__install_partition_msdos_apply/explorer/partitions +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -cat /proc/partitions diff --git a/cdist/conf/type/__install_partition_msdos_apply/files/lib.sh b/cdist/conf/type/__install_partition_msdos_apply/files/lib.sh deleted file mode 100644 index 2db9a441..00000000 --- a/cdist/conf/type/__install_partition_msdos_apply/files/lib.sh +++ /dev/null @@ -1,70 +0,0 @@ -#!/bin/sh - -die() { - echo "[__install_partition_msdos_apply] $*" >&2 - exit 1 -} -debug() { - #echo "[__install_partition_msdos_apply] $*" >&2 - : -} - -fdisk_command() { - device="$1" - cmd="$2" - - debug fdisk_command "running fdisk command '${cmd}' on device ${device}" - printf '%s\nw\n' "${cmd}" | fdisk -c -u "$device" - ret=$? - # give disk some time - sleep 1 - return $ret -} - -create_disklabel() { - device=$1 - - debug create_disklabel "creating new msdos disklabel" - fdisk_command "${device}" "o" - return $? -} - -toggle_bootable() { - device="$1" - minor="$2" - fdisk_command "${device}" "a\\n${minor}\\n" - return $? -} - -create_partition() { - device="$1" - minor="$2" - size="$3" - type="$4" - primary_count="$5" - - if [ "$type" = "extended" ] || [ "$type" = "5" ]; then - # Extended partition - primary_extended='e\n' - first_minor="${minor}\\n" - [ "${minor}" = "4" ] && first_minor="" - type_minor="${minor}\\n" - [ "${minor}" = "1" ] && type_minor="" - type="5" - elif [ "${minor}" -lt "5" ]; then - primary_extended='p\n' - first_minor="${minor}\\n" - [ "${minor}" = "4" ] && first_minor="" - type_minor="${minor}\\n" - [ "${minor}" = "1" ] && type_minor="" - else - # Logical partitions - first_minor="${minor}\\n" - type_minor="${minor}\\n" - primary_extended='l\n' - [ "$primary_count" -gt "3" ] && primary_extended="" - fi - [ -n "${size}" ] && size="+${size}M" - fdisk_command "${device}" "n\\n${primary_extended}${first_minor}\\n${size}\\nt\\n${type_minor}${type}\\n" - return $? -} diff --git a/cdist/conf/type/__install_partition_msdos_apply/gencode-remote b/cdist/conf/type/__install_partition_msdos_apply/gencode-remote deleted file mode 100755 index a0b46b2d..00000000 --- a/cdist/conf/type/__install_partition_msdos_apply/gencode-remote +++ /dev/null @@ -1,163 +0,0 @@ -#!/bin/sh -e -# -# 2011-2013 Steven Armstrong (steven-cdist at armstrong.cc) -# -# This file is part of cdist. -# -# cdist is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# cdist is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with cdist. If not, see . -# - -#set -x - -die() { - echo "[__install_partition_msdos_apply] $*" >&2 - exit 1 -} -debug() { - #echo "[__install_partition_msdos_apply] $*" >&2 - : -} - -# Convert a size specifier 1G 100M or 50% into the corresponding numeric MB. -size_to_mb() { - size=$1 - available_size="$2" - - number_suffix="$(echo "${size}" | sed -e 's:\.[0-9]\+::' -e 's:\([0-9]\+\)\([KkMmGg%]\)[Bb]\?:\1|\2:')" - number="$(echo "${number_suffix}" | cut -d '|' -f1)" - suffix="$(echo "${number_suffix}" | cut -d '|' -f2)" - - case "$suffix" in - K|k) - size="$(( number / 1024 ))" - ;; - M|m) - size="$number" - ;; - G|g) - size="$(( number * 1024 ))" - ;; - %) - size="$(( available_size * number / 100 ))" - ;; - *) - size="-1" - esac - echo "$size" -} - -get_objects() { - objects_file=$(mktemp) - find "$__global/object/__install_partition_msdos" -type d -name "$__cdist_object_marker" | - while IFS= read -r object - do - object_device="$(cat "$object/parameter/device")" - object_minor="$(cat "$object/parameter/minor")" - echo "$object_device $object_minor $object" >> "$objects_file" - done - sort -k 1,2 "$objects_file" | cut -d' ' -f 3 - rm "$objects_file" - unset objects_file - unset object - unset object_device - unset object_minor -} - -# include function library for use on target -cat "$__type/files/lib.sh" - -partitions="$__object/explorer/partitions" -objects=$(get_objects) -current_device="" -available_device_size= -available_extended_size= -available_size= -primary_count=0 -for object in $objects; do - device="$(cat "$object/parameter/device")" - if [ "$current_device" != "$device" ]; then - echo "create_disklabel '$device' || die 'Failed to create disklabel for $device'" - current_device="$device" - device_name=$(echo "${device}" | sed -e 's:^/dev/::;s:/:\\/:g') - available_device_size=$(( $(awk "/${device_name}\$/ { print \$3; }" "$partitions") / 1024)) - # make sure we don't go past the end of the drive - available_device_size=$((available_device_size - 2)) - available_extended_size=0 - primary_count=0 - debug "----- $device" - debug "current_device=$current_device" - debug "available_device_size=$available_device_size" - fi - - type="$(cat "$object/parameter/type")" - partition="$(cat "$object/parameter/partition")" - minor="$(cat "$object/parameter/minor")" - - bootable="$(cat "$object/parameter/bootable")" - size="$(cat "$object/parameter/size")" - - - if [ "${minor}" -lt "5" ]; then - # Primary partitions - primary_count=$(( primary_count + 1 )) - available_size=$available_device_size - else - # Logical partitions - available_size=$available_extended_size - fi - - if [ "$size" = "+" ]; then - # use rest of device - partition_size="" - available_size=0 - else - partition_size=$(size_to_mb "$size" "$available_size") - available_size="$(( available_size - partition_size ))" - fi - - if [ "${minor}" -lt "5" ]; then - # Primary partitions - available_device_size=$available_size - if [ "$type" = "extended" ] || [ "$type" = "5" ]; then - # Extended partition - available_extended_size=$partition_size - fi - else - # Logical paritions - available_extended_size=$available_size - fi - - [ "$partition_size" = "-1" ] && die "could not translate size '$size' to a usable value" - debug "----- $partition" - debug "primary_count=$primary_count" - debug "current_device=$current_device" - debug "device=$device" - debug "type=$type" - debug "partition=$partition" - debug "minor=$minor" - debug "bootable=$bootable" - debug "size=$size" - debug "partition_size=$partition_size" - debug "available_size=$available_size" - debug "available_device_size=$available_device_size" - debug "available_extended_size=$available_extended_size" - debug "----------" - - echo "create_partition '$device' '$minor' '$partition_size' '$type' '$primary_count' \ - || die 'Failed to create partition: $partition'" - - if [ "$bootable" = "true" ]; then - echo "toggle_bootable '$device' '$minor' || die 'Failed to toogle bootable flag for partition: $partition'" - fi -done diff --git a/cdist/conf/type/__install_partition_msdos_apply/install b/cdist/conf/type/__install_partition_msdos_apply/install deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/conf/type/__install_partition_msdos_apply/man.rst b/cdist/conf/type/__install_partition_msdos_apply/man.rst deleted file mode 100644 index 80740fde..00000000 --- a/cdist/conf/type/__install_partition_msdos_apply/man.rst +++ /dev/null @@ -1,47 +0,0 @@ -cdist-type__install_partition_msdos_apply(7) -============================================ - -NAME ----- -cdist-type__install_partition_msdos_apply - Apply dos partition settings - - -DESCRIPTION ------------ -Create the partitions defined with __install_partition_msdos - - -REQUIRED PARAMETERS -------------------- -None - - -OPTIONAL PARAMETERS -------------------- -None - - -EXAMPLES --------- - -.. code-block:: sh - - __install_partition_msdos_apply - - -SEE ALSO --------- -:strong:`cdist-type__install_partition_msdos_apply`\ (7) - - -AUTHORS -------- -Steven Armstrong - - -COPYING -------- -Copyright \(C) 2011 Steven Armstrong. 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. diff --git a/cdist/conf/type/__install_partition_msdos_apply/singleton b/cdist/conf/type/__install_partition_msdos_apply/singleton deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/conf/type/__install_reboot/gencode-remote b/cdist/conf/type/__install_reboot/gencode-remote deleted file mode 100755 index 9a6322c1..00000000 --- a/cdist/conf/type/__install_reboot/gencode-remote +++ /dev/null @@ -1,30 +0,0 @@ -#!/bin/sh -e -# -# 2011 Steven Armstrong (steven-cdist at armstrong.cc) -# -# This file is part of cdist. -# -# cdist is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# cdist is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with cdist. If not, see . -# - -#echo "reboot $options" -cat << DONE -echo 1 > /proc/sys/kernel/sysrq -echo s > /proc/sysrq-trigger - -# close file descriptors to detach from ssh -sh -c 'sleep 3; echo b > /proc/sysrq-trigger' > /dev/null 2>&1 - - -COPYING -------- -Copyright \(C) 2011 Steven Armstrong. 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. diff --git a/cdist/conf/type/__install_reboot/singleton b/cdist/conf/type/__install_reboot/singleton deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/conf/type/__install_reset_disk/gencode-remote b/cdist/conf/type/__install_reset_disk/gencode-remote deleted file mode 100755 index ac9ae6cf..00000000 --- a/cdist/conf/type/__install_reset_disk/gencode-remote +++ /dev/null @@ -1,71 +0,0 @@ -#!/bin/sh -e -# -# 2012 Steven Armstrong (steven-cdist at armstrong.cc) -# -# This file is part of cdist. -# -# cdist is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# cdist is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with cdist. If not, see . -# - -disk="/$__object_id" -disk_name="${disk##*/}" - -cat << DONE - -debug() { - echo "[DEBUG] \$@" >&2 -} - -find_md_device_names() { - local disk_name="\$1" - for slave in \$(find /sys/devices/virtual/block/*/slaves/ -name "\${disk_name}*"); do - debug "slave: \$slave" - for holder in \$slave/holders/*; do - debug "holder: \$holder" - if [ -d "\$holder/md" ]; then - debug "mdadm found at \$holder" - holder_name="\${holder##*/}" - echo "\$holder_name" - fi - done - done -} - -# disable any enabled volume group -if command -v vgchange >/dev/null; then - vgchange -a n -else - echo "WARNING: vgchange command not found" >&2 -fi - -# disable any running mdadm arrays related to $disk -for md_name in \$(find_md_device_names "$disk_name" | sort | uniq); do - echo "md_name: \$md_name" - if command -v mdadm >/dev/null; then - mdadm --stop "/dev/\$md_name" - else - echo "WARNING: mdadm command not found" >&2 - echo "WARNING: could not stop active mdadm raid for disk $disk" >&2 - fi -done - -# clean disks from any legacy signatures -if command -v wipefs >/dev/null; then - wipefs -a "$disk" || true -fi - -# erase partition table -dd if=/dev/zero of=$disk bs=512 count=1 -printf 'w\\n' | fdisk -u -c $disk || true -DONE diff --git a/cdist/conf/type/__install_reset_disk/install b/cdist/conf/type/__install_reset_disk/install deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/conf/type/__install_reset_disk/man.rst b/cdist/conf/type/__install_reset_disk/man.rst deleted file mode 100644 index fadeec71..00000000 --- a/cdist/conf/type/__install_reset_disk/man.rst +++ /dev/null @@ -1,43 +0,0 @@ -cdist-type__install_reset_disk(7) -================================= - -NAME ----- -cdist-type__install_reset_disk - reset a disk - - -DESCRIPTION ------------ -Remove partition table. -Remove all lvm labels. -Remove mdadm superblock. - - -REQUIRED PARAMETERS -------------------- -None - -OPTIONAL PARAMETERS -------------------- -None - - -EXAMPLES --------- - -.. code-block:: sh - - __install_reset_disk /dev/sdb - - -AUTHORS -------- -Steven Armstrong - - -COPYING -------- -Copyright \(C) 2012 Steven Armstrong. 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. diff --git a/cdist/conf/type/__install_stage/gencode-remote b/cdist/conf/type/__install_stage/gencode-remote deleted file mode 100755 index 776e9fd5..00000000 --- a/cdist/conf/type/__install_stage/gencode-remote +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/sh -e -# -# 2011-2013 Steven Armstrong (steven-cdist at armstrong.cc) -# -# This file is part of cdist. -# -# cdist is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# cdist is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with cdist. If not, see . -# - -uri="$(cat "$__object/parameter/uri" 2>/dev/null \ - || echo "$__object_id")" -target="$(cat "$__object/parameter/target")" - -if [ "$__cdist_log_level" -le "10" ] -then - curl="curl" - tar="tar -xvzp" -else - curl="curl -s" - tar="tar -xzp" -fi - -if [ -f "$__object/parameter/insecure" ] ; then - curl="$curl -k" -fi - -echo "$curl '$uri' | $tar -C '$target'" diff --git a/cdist/conf/type/__install_stage/install b/cdist/conf/type/__install_stage/install deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/conf/type/__install_stage/man.rst b/cdist/conf/type/__install_stage/man.rst deleted file mode 100644 index fd764693..00000000 --- a/cdist/conf/type/__install_stage/man.rst +++ /dev/null @@ -1,58 +0,0 @@ -cdist-type__install_stage(7) -============================ - -NAME ----- -cdist-type__install_stage - download and unpack a stage file - - -DESCRIPTION ------------ -Downloads a operating system stage using curl and unpacks it to /target -using tar. The stage tarball is expected to be gzip compressed. - - -REQUIRED PARAMETERS -------------------- -uri - The uri from which to fetch the tarball. - Can be anything understood by curl, e.g: - | http://path/to/stage.tgz - | tftp:///path/to/stage.tgz - | file:///local/path/stage.tgz - - -OPTIONAL PARAMETERS -------------------- -target - where to unpack the tarball to. Defaults to /target. - - -BOOLEAN PARAMETERS ------------------- -insecure - run curl in insecure mode so it does not check the servers ssl certificate - - -EXAMPLES --------- - -.. code-block:: sh - - __install_stage --uri tftp:///path/to/stage.tgz - __install_stage --uri http://path/to/stage.tgz --target /mnt/foobar - __install_stage --uri file:///path/to/stage.tgz --target /target - __install_stage --uri https://path/to/stage.tgz --target /mnt/foobar --insecure - - -AUTHORS -------- -Steven Armstrong - - -COPYING -------- -Copyright \(C) 2011 - 2013 Steven Armstrong. 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. diff --git a/cdist/conf/type/__install_stage/parameter/boolean b/cdist/conf/type/__install_stage/parameter/boolean deleted file mode 100644 index e86bf3fc..00000000 --- a/cdist/conf/type/__install_stage/parameter/boolean +++ /dev/null @@ -1 +0,0 @@ -insecure diff --git a/cdist/conf/type/__install_stage/parameter/default/target b/cdist/conf/type/__install_stage/parameter/default/target deleted file mode 100644 index ea8c4bf7..00000000 --- a/cdist/conf/type/__install_stage/parameter/default/target +++ /dev/null @@ -1 +0,0 @@ -/target diff --git a/cdist/conf/type/__install_stage/parameter/optional b/cdist/conf/type/__install_stage/parameter/optional deleted file mode 100644 index eb5a316c..00000000 --- a/cdist/conf/type/__install_stage/parameter/optional +++ /dev/null @@ -1 +0,0 @@ -target diff --git a/cdist/conf/type/__install_stage/parameter/required b/cdist/conf/type/__install_stage/parameter/required deleted file mode 100644 index c7954952..00000000 --- a/cdist/conf/type/__install_stage/parameter/required +++ /dev/null @@ -1 +0,0 @@ -uri diff --git a/cdist/conf/type/__install_stage/singleton b/cdist/conf/type/__install_stage/singleton deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/conf/type/__install_umount/gencode-remote b/cdist/conf/type/__install_umount/gencode-remote deleted file mode 100755 index 8dcfb253..00000000 --- a/cdist/conf/type/__install_umount/gencode-remote +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/sh -e -# -# 2011 Steven Armstrong (steven-cdist at armstrong.cc) -# -# This file is part of cdist. -# -# cdist is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# cdist is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with cdist. If not, see . -# - -target="$(cat "$__object/parameter/target")" - -echo "swapoff -a" -echo "umount -l ${target}/* || true" -echo "umount -l ${target}" diff --git a/cdist/conf/type/__install_umount/install b/cdist/conf/type/__install_umount/install deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/conf/type/__install_umount/man.rst b/cdist/conf/type/__install_umount/man.rst deleted file mode 100644 index 59f63449..00000000 --- a/cdist/conf/type/__install_umount/man.rst +++ /dev/null @@ -1,43 +0,0 @@ -cdist-type__install_umount(7) -============================= - -NAME ----- -cdist-type__install_umount - umount target directory - - -DESCRIPTION ------------ -This cdist type allows you to recursively umount the given target directory. - - -REQUIRED PARAMETERS -------------------- -None - - -OPTIONAL PARAMETERS -------------------- -target - the mount point to umount. Defaults to object_id - - -EXAMPLES --------- - -.. code-block:: sh - - __install_umount /target - - -AUTHORS -------- -Steven Armstrong - - -COPYING -------- -Copyright \(C) 2011 Steven Armstrong. 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. diff --git a/cdist/conf/type/__install_umount/parameter/default/target b/cdist/conf/type/__install_umount/parameter/default/target deleted file mode 100644 index ea8c4bf7..00000000 --- a/cdist/conf/type/__install_umount/parameter/default/target +++ /dev/null @@ -1 +0,0 @@ -/target diff --git a/cdist/conf/type/__install_umount/parameter/optional b/cdist/conf/type/__install_umount/parameter/optional deleted file mode 100644 index eb5a316c..00000000 --- a/cdist/conf/type/__install_umount/parameter/optional +++ /dev/null @@ -1 +0,0 @@ -target diff --git a/cdist/conf/type/__iptables_apply/files/init-script b/cdist/conf/type/__iptables_apply/files/init-script index d9c79ef7..2dc952e9 100644 --- a/cdist/conf/type/__iptables_apply/files/init-script +++ b/cdist/conf/type/__iptables_apply/files/init-script @@ -24,15 +24,13 @@ case $1 in iptables-save > "$status" # Apply our ruleset - cd "$basedir" || exit - count="$(find . ! -name . -prune | wc -l)" + cd "$basedir" + count="$(ls -1 | wc -l)" # Only do something if there are rules if [ "$count" -ge 1 ]; then for rule in *; do echo "Applying iptables rule $rule ..." - # Rule should be split. - # shellcheck disable=SC2046 iptables $(cat "$rule") done fi @@ -47,14 +45,4 @@ case $1 in restart) "$0" stop && "$0" start ;; - reset) - for table in INPUT FORWARD OUTPUT; do - iptables -P "$table" ACCEPT - iptables -F "$table" - done - for table in PREROUTING POSTROUTING OUTPUT; do - iptables -t nat -P "$table" ACCEPT - iptables -t nat -F "$table" - done - ;; esac diff --git a/cdist/conf/type/__iptables_apply/gencode-remote b/cdist/conf/type/__iptables_apply/gencode-remote old mode 100755 new mode 100644 index a80cb936..9cdf28cf --- a/cdist/conf/type/__iptables_apply/gencode-remote +++ b/cdist/conf/type/__iptables_apply/gencode-remote @@ -1,5 +1,3 @@ -#!/bin/sh -e - if grep -q "^__file/etc/iptables.d/" "$__messages_in"; then echo /etc/init.d/iptables restart fi diff --git a/cdist/conf/type/__iptables_apply/man.rst b/cdist/conf/type/__iptables_apply/man.text similarity index 60% rename from cdist/conf/type/__iptables_apply/man.rst rename to cdist/conf/type/__iptables_apply/man.text index 76e1f6bf..87f4b4ee 100644 --- a/cdist/conf/type/__iptables_apply/man.rst +++ b/cdist/conf/type/__iptables_apply/man.text @@ -1,5 +1,7 @@ cdist-type__iptables_apply(7) ============================= +Nico Schottelius + NAME ---- @@ -29,17 +31,12 @@ None (__iptables_apply is used by __iptables_rule) SEE ALSO -------- -:strong:`cdist-type__iptables_rule`\ (7), :strong:`iptables`\ (8) - - -AUTHORS -------- -Nico Schottelius +- cdist-type(7) +- cdist-type__iptables_rule(7) +- iptables(8) COPYING ------- -Copyright \(C) 2013 Nico Schottelius. 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. +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/cdist/conf/type/__iptables_apply/manifest b/cdist/conf/type/__iptables_apply/manifest old mode 100755 new mode 100644 index 0061d3de..a22901ba --- a/cdist/conf/type/__iptables_apply/manifest +++ b/cdist/conf/type/__iptables_apply/manifest @@ -1,4 +1,3 @@ -#!/bin/sh -e # # 2013 Nico Schottelius (nico-cdist at schottelius.org) # diff --git a/cdist/conf/type/__iptables_rule/man.rst b/cdist/conf/type/__iptables_rule/man.rst deleted file mode 100644 index 92d8859f..00000000 --- a/cdist/conf/type/__iptables_rule/man.rst +++ /dev/null @@ -1,66 +0,0 @@ -cdist-type__iptables_rule(7) -============================ - -NAME ----- -cdist-type__iptables_rule - Deploy iptable rulesets - - -DESCRIPTION ------------ -This cdist type allows you to manage iptable rules -in a distribution independent manner. - - -REQUIRED PARAMETERS -------------------- -rule - The rule to apply. Essentially an iptables command - line without iptables in front of it. - - -OPTIONAL PARAMETERS -------------------- -state - 'present' or 'absent', defaults to 'present' - - -EXAMPLES --------- - -.. code-block:: sh - - # Deploy some policies - __iptables_rule policy-in --rule "-P INPUT DROP" - __iptables_rule policy-out --rule "-P OUTPUT ACCEPT" - __iptables_rule policy-fwd --rule "-P FORWARD DROP" - - # The usual established rule - __iptables_rule established --rule "-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT" - - # Some service rules - __iptables_rule http --rule "-A INPUT -p tcp --dport 80 -j ACCEPT" - __iptables_rule ssh --rule "-A INPUT -p tcp --dport 22 -j ACCEPT" - __iptables_rule https --rule "-A INPUT -p tcp --dport 443 -j ACCEPT" - - # Ensure some rules are not present anymore - __iptables_rule munin --rule "-A INPUT -p tcp --dport 4949 -j ACCEPT" \ - --state absent - - -SEE ALSO --------- -:strong:`cdist-type__iptables_apply`\ (7), :strong:`iptables`\ (8) - - -AUTHORS -------- -Nico Schottelius - - -COPYING -------- -Copyright \(C) 2013 Nico Schottelius. 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. diff --git a/cdist/conf/type/__iptables_rule/man.text b/cdist/conf/type/__iptables_rule/man.text new file mode 100644 index 00000000..2f5b9785 --- /dev/null +++ b/cdist/conf/type/__iptables_rule/man.text @@ -0,0 +1,64 @@ +cdist-type__iptables_rule(7) +============================ +Nico Schottelius + + +NAME +---- +cdist-type__iptables_rule - Deploy iptable rulesets + + +DESCRIPTION +----------- +This cdist type allows you to manage iptable rules +in a distribution independent manner. + + +REQUIRED PARAMETERS +------------------- +rule:: + The rule to apply. Essentially an iptables command + line without iptables in front of it. + + +OPTIONAL PARAMETERS +------------------- +state:: + 'present' or 'absent', defaults to 'present' + + +EXAMPLES +-------- + +-------------------------------------------------------------------------------- +# Deploy some policies +__iptables_rule policy-in --rule "-P INPUT DROP" +__iptables_rule policy-out --rule "-P OUTPUT ACCEPT" +__iptables_rule policy-fwd --rule "-P FORWARD DROP" + +# The usual established rule +__iptables_rule established --rule "-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT" + +# Some service rules +__iptables_rule http --rule "-A INPUT -p tcp --dport 80 -j ACCEPT" +__iptables_rule ssh --rule "-A INPUT -p tcp --dport 22 -j ACCEPT" +__iptables_rule https --rule "-A INPUT -p tcp --dport 443 -j ACCEPT" + +# Ensure some rules are not present anymore +__iptables_rule munin --rule "-A INPUT -p tcp --dport 4949 -j ACCEPT" \ + --state absent + +-------------------------------------------------------------------------------- + + +SEE ALSO +-------- +- cdist-type(7) +- cdist-type__iptables_apply(7) +- iptables(8) + + +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/cdist/conf/type/__iptables_rule/manifest b/cdist/conf/type/__iptables_rule/manifest old mode 100755 new mode 100644 index ed78787f..f02ab18b --- a/cdist/conf/type/__iptables_rule/manifest +++ b/cdist/conf/type/__iptables_rule/manifest @@ -1,4 +1,3 @@ -#!/bin/sh -e # # 2013 Nico Schottelius (nico-cdist at schottelius.org) # diff --git a/cdist/conf/type/__issue/man.rst b/cdist/conf/type/__issue/man.rst deleted file mode 100644 index 097f2c01..00000000 --- a/cdist/conf/type/__issue/man.rst +++ /dev/null @@ -1,47 +0,0 @@ -cdist-type__issue(7) -==================== - -NAME ----- -cdist-type__issue - Manage issue - - -DESCRIPTION ------------ -This cdist type allows you to easily setup /etc/issue. - - -REQUIRED PARAMETERS -------------------- -None. - - -OPTIONAL PARAMETERS -------------------- -source - If supplied, use this file as /etc/issue instead of default. - - - -EXAMPLES --------- - -.. code-block:: sh - - __issue - - # When called from another type - __issue --source "$__type/files/myfancyissue" - - -AUTHORS -------- -Nico Schottelius - - -COPYING -------- -Copyright \(C) 2011 Nico Schottelius. 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. diff --git a/cdist/conf/type/__issue/man.text b/cdist/conf/type/__issue/man.text new file mode 100644 index 00000000..40ed920e --- /dev/null +++ b/cdist/conf/type/__issue/man.text @@ -0,0 +1,47 @@ +cdist-type__issue(7) +==================== +Nico Schottelius + + +NAME +---- +cdist-type__issue - Manage issue + + +DESCRIPTION +----------- +This cdist type allows you to easily setup /etc/issue. + + +REQUIRED PARAMETERS +------------------- +None. + + +OPTIONAL PARAMETERS +------------------- +source:: + If supplied, use this file as /etc/issue instead of default. + + + +EXAMPLES +-------- + +-------------------------------------------------------------------------------- +__issue + +# When called from another type +__issue --source "$__type/files/myfancyissue" +-------------------------------------------------------------------------------- + + +SEE ALSO +-------- +- cdist-type(7) + + +COPYING +------- +Copyright \(C) 2011 Nico Schottelius. Free use of this software is +granted under the terms of the GNU General Public License version 3 (GPLv3). diff --git a/cdist/conf/type/__issue/manifest b/cdist/conf/type/__issue/manifest index 0f0b3d83..d2720f2d 100755 --- a/cdist/conf/type/__issue/manifest +++ b/cdist/conf/type/__issue/manifest @@ -1,4 +1,4 @@ -#!/bin/sh -e +#!/bin/sh # # 2011-2012 Nico Schottelius (nico-cdist at schottelius.org) # @@ -25,9 +25,6 @@ os="$(cat "$__global/explorer/os")" if [ -f "$__object/parameter/source" ]; then source="$(cat "$__object/parameter/source")" - if [ "$source" = "-" ]; then - source="${__object}/stdin" - fi else case "$os" in archlinux|redhat) diff --git a/cdist/conf/type/__jail_freebsd10/explorer/basepresent b/cdist/conf/type/__jail/explorer/basepresent similarity index 100% rename from cdist/conf/type/__jail_freebsd10/explorer/basepresent rename to cdist/conf/type/__jail/explorer/basepresent diff --git a/cdist/conf/type/__jail_freebsd10/explorer/present b/cdist/conf/type/__jail/explorer/present similarity index 100% rename from cdist/conf/type/__jail_freebsd10/explorer/present rename to cdist/conf/type/__jail/explorer/present diff --git a/cdist/conf/type/__jail_freebsd10/explorer/status b/cdist/conf/type/__jail/explorer/status similarity index 94% rename from cdist/conf/type/__jail_freebsd10/explorer/status rename to cdist/conf/type/__jail/explorer/status index c8039f21..1ceba212 100755 --- a/cdist/conf/type/__jail_freebsd10/explorer/status +++ b/cdist/conf/type/__jail/explorer/status @@ -39,7 +39,7 @@ fi # backslash-escaped $jaildir sjaildir="$(echo ${jaildir} | sed 's#/#\\/#g')" -jls_output="$(jls | grep "[ ]${sjaildir}\\/${name}\$")" || true +jls_output="$(jls | grep "[ ]${sjaildir}\/${name}\$")" || true if [ -n "${jls_output}" ]; then echo "STARTED" diff --git a/cdist/conf/type/__jail_freebsd9/gencode-local b/cdist/conf/type/__jail/gencode-local similarity index 82% rename from cdist/conf/type/__jail_freebsd9/gencode-local rename to cdist/conf/type/__jail/gencode-local index bbdc9fcc..08c7b7bf 100755 --- a/cdist/conf/type/__jail_freebsd9/gencode-local +++ b/cdist/conf/type/__jail/gencode-local @@ -1,4 +1,4 @@ -#!/bin/sh -e +#!/bin/sh # # 2012 Jake Guffey (jake.guffey at eprotex.com) # @@ -39,14 +39,7 @@ basepresent="$(cat "$__object/explorer/basepresent")" if [ "$state" = "present" ]; then if [ "$basepresent" = "NONE" ]; then - # IPv6 fix - if echo "${__target_host}" | grep -q -E '^[0-9a-fA-F:]+$' - then - my_target_host="[${__target_host}]" - else - my_target_host="${__target_host}" - fi - echo "$__remote_copy" "${jailbase}" "${my_target_host}:${remotebase}" + echo "$__remote_copy" "${jailbase}" "$__target_host:${remotebase}" fi # basepresent=NONE fi # state=present diff --git a/cdist/conf/type/__jail_freebsd9/gencode-remote b/cdist/conf/type/__jail/gencode-remote similarity index 90% rename from cdist/conf/type/__jail_freebsd9/gencode-remote rename to cdist/conf/type/__jail/gencode-remote index 68229d3e..c88f3361 100755 --- a/cdist/conf/type/__jail_freebsd9/gencode-remote +++ b/cdist/conf/type/__jail/gencode-remote @@ -1,6 +1,6 @@ -#!/bin/sh -e +#!/bin/sh # -# 2012,2014,2016 Jake Guffey (jake.guffey at jointheirstm.org) +# 2012,2014 Jake Guffey (jake.guffey at eprotex.com) # # This file is part of cdist. # @@ -18,8 +18,8 @@ # along with cdist. If not, see . # # -# The __jail_freebsd9 type creates, configures, and deletes FreeBSD jails -# for use as virtual machines on FreeBSD 9.x and before. +# The __jail type creates, configures, and deletes FreeBSD jails for use as +# virtual machines. # # Debug @@ -36,7 +36,7 @@ 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" ] || [ "$state" = "absent" ]; } && started="false" +[ -f "$__object/parameter/stopped" -o "$state" = "absent" ] && started="false" if [ -f "$__object/parameter/ip" ]; then ip="$(cat "$__object/parameter/ip")" @@ -45,7 +45,7 @@ else # when $state=present, it's required. Enforce this. if [ "$state" = "present" ]; then exec >&2 - printf 'If --state is "present", --ip must be given\!\n' + echo "If --state is 'present,' --ip must be given\!" exit 1 fi fi @@ -70,7 +70,7 @@ 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" ] && [ "$devfsenable" = "false" ]; then +if [ -n "$devfsruleset" -a "$devfsenable" = "false" ]; then exec >&2 echo "Can't have --devfs-ruleset defined with --devfs-disable" exit 1 @@ -86,14 +86,14 @@ present="$(cat "$__object/explorer/present")" status="$(cat "$__object/explorer/status")" # Handle ip="iface|addr, iface|addr" format -if [ "$(expr "${ip}" : ".*|.*")" -gt "0" ]; then +if [ $(expr "${ip}" : ".*|.*") -gt "0" ]; then # If we have multiple IPs defined, $interface doesn't make sense because ip="iface|addr, iface|addr" implies it interface="" SAVE_IFS="$IFS" IFS=", " for cur_ip in ${ip}; do # Just get the last IP address for SSH to listen on - mgmt_ip=$(echo "${cur_ip}" | sed -E -e 's/^.*\|(.*)\/[0-9]+$/\1/') + mgmt_ip=$(echo "${ip}" | sed -E -e 's/^.*\|(.*)\/[0-9]+$/\1/') done IFS="$SAVE_IFS" else @@ -119,19 +119,19 @@ startJail() { 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}')" + for DIR in "${output}"; do + umount -F "/etc/fstab.${name}" "\$(echo "${DIR}" | awk '{print $3}')" done fi - output="\$(mount | grep "\\/${name} (")" || true + output="\$(mount | grep "\/${name} (")" || true if [ -n "\${output}" ]; then # ro mount is mounted still - umount -F "/etc/fstab.${name}" "\$(echo "\${output}" | awk '{print \$3}')" + umount -F "/etc/fstab.${name}" "\$(echo "${output}" | awk '{print $3}')" fi EOF # Remove the jail's rw mountpoints @@ -279,9 +279,9 @@ END 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 + 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 + highest="\$(sed -n 's/\[.*=\([0-9]*\)\]/\1/pg' /etc/devfs.rules | sort -u | tail -n 1)" || true # increment by 1 let num="\${highest}+1" 2>&- >&- # add default ruleset @@ -354,4 +354,3 @@ else # The jail does not currently exist exit 0 fi fi - diff --git a/cdist/conf/type/__jail/man.rst b/cdist/conf/type/__jail/man.text similarity index 57% rename from cdist/conf/type/__jail/man.rst rename to cdist/conf/type/__jail/man.text index 7fc8f455..be27e909 100644 --- a/cdist/conf/type/__jail/man.rst +++ b/cdist/conf/type/__jail/man.text @@ -1,5 +1,7 @@ cdist-type__jail(7) =================== +Jake Guffey + NAME ---- @@ -8,52 +10,52 @@ cdist-type__jail - Manage FreeBSD jails DESCRIPTION ----------- -This type is used on FreeBSD to manage jails by calling the appropriate per-version subtype. +This type is used on FreeBSD to manage jails. REQUIRED PARAMETERS ------------------- -state +state:: Either "present" or "absent", defaults to "present". -jailbase +jailbase:: The location of the .tgz archive containing the base fs for your jails. OPTIONAL PARAMETERS ------------------- -name +name:: The name of the jail. Default is to use the object_id as the jail name. -ip +ip:: The ifconfig style IP/netmask combination to use for the jail guest. If the state parameter is "present," this parameter is required. -hostname +hostname:: The FQDN to use for the jail guest. Defaults to the name parameter. -interface +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 +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 +jaildir:: The location on the remote server to use for hosting jail filesystems. Defaults to /usr/jail. BOOLEAN PARAMETERS ------------------ -stopped +stopped:: Do not start the jail -devfs-disable +devfs-disable:: Whether to disallow devfs mounting within the jail -onboot +onboot:: Whether to add the jail to rc.conf's jail_list variable. @@ -67,58 +69,51 @@ means. MESSAGES -------- -start +start:: The jail was started -stop +stop:: The jail was stopped create: The jail was created -delete +delete:: The jail was deleted -onboot +onboot:: The jail was configured to start on boot EXAMPLES -------- -.. code-block:: sh +-------------------------------------------------------------------------------- +# Create a jail called www +__jail www --state present --ip "192.168.1.2" --jailbase /my/jail/base.tgz - # Create a jail called www - __jail www --state present --ip "192.168.1.2" --jailbase /my/jail/base.tgz +# Remove the jail called www +__jail www --state absent --jailbase /my/jail/base.tgz - # Remove the jail called www - __jail www --state absent --jailbase /my/jail/base.tgz +# The jail www should not be started +__jail www --state present --stopped \ + --ip "192.168.1.2 netmask 255.255.255.0" \ + --jailbase /my/jail/base.tgz - # The jail www should not be started - __jail 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 thisjail --state present --name www \ + --ip "192.168.1.2" \ + --jailbase /my/jail/base.tgz - # Use the name variable explicitly - __jail thisjail --state present --name www \ - --ip "192.168.1.2" \ - --jailbase /my/jail/base.tgz - - # Go nuts - __jail 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 +# Go nuts +__jail 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 -------- -:strong:`jail`\ (8) - - -AUTHORS -------- -Jake Guffey +- cdist-type(7) COPYING ------- -Copyright \(C) 2012,2016 Jake Guffey. 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. +Copyright \(C) 2012 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 fad6a3a1..2d29e263 100755 --- a/cdist/conf/type/__jail/manifest +++ b/cdist/conf/type/__jail/manifest @@ -1,4 +1,4 @@ -#!/bin/sh -e +#!/bin/sh # # 2012 Jake Guffey (jake.guffey at eprotex.com) # @@ -35,19 +35,7 @@ fi jaildir="$(cat "$__object/parameter/jaildir")" -__directory "${jaildir}" --parents - -set -- "$@" "$__object_id" -cd "$__object/parameter" -for property in *; do - set -- "$@" "--$property" "$(cat "$property")" -done - -if grep -q '^10\.' "$(cat "$__global/explorer/os_version")" ; then # Version is 10.x - __jail_freebsd10 "$@" -else - __jail_freebsd9 "$@" -fi +__directory ${jaildir} --parents # Debug #set +x diff --git a/cdist/conf/type/__jail_freebsd10/gencode-local b/cdist/conf/type/__jail_freebsd10/gencode-local deleted file mode 100755 index f163cad3..00000000 --- a/cdist/conf/type/__jail_freebsd10/gencode-local +++ /dev/null @@ -1,59 +0,0 @@ -#!/bin/sh -e -# -# 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 - # IPv6 fix - if echo "${__target_host}" | grep -q -E '^[0-9a-fA-F:]+$' - then - my_target_host="[${__target_host}]" - else - my_target_host="${__target_host}" - fi - echo "$__remote_copy" "${jailbase}" "${my_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 deleted file mode 100755 index 4f376c25..00000000 --- a/cdist/conf/type/__jail_freebsd10/gencode-remote +++ /dev/null @@ -1,362 +0,0 @@ -#!/bin/sh -e -# -# 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" ] || [ "$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 - printf 'If --state is "present", --ip must be given\!\n' - 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" ] && [ "$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 "${cur_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 --------- -:strong:`jail`\ (8) - - -AUTHORS -------- -Jake Guffey - - -COPYING -------- -Copyright \(C) 2012-2016 Jake Guffey. 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. diff --git a/cdist/conf/type/__jail_freebsd10/parameter/boolean b/cdist/conf/type/__jail_freebsd10/parameter/boolean deleted file mode 100644 index 39144f6f..00000000 --- a/cdist/conf/type/__jail_freebsd10/parameter/boolean +++ /dev/null @@ -1,3 +0,0 @@ -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 deleted file mode 100644 index f602aa0a..00000000 --- a/cdist/conf/type/__jail_freebsd10/parameter/default/devfs-ruleset +++ /dev/null @@ -1 +0,0 @@ -jailrules diff --git a/cdist/conf/type/__jail_freebsd10/parameter/default/jailbase b/cdist/conf/type/__jail_freebsd10/parameter/default/jailbase deleted file mode 100644 index 8b137891..00000000 --- a/cdist/conf/type/__jail_freebsd10/parameter/default/jailbase +++ /dev/null @@ -1 +0,0 @@ - diff --git a/cdist/conf/type/__jail_freebsd10/parameter/default/jaildir b/cdist/conf/type/__jail_freebsd10/parameter/default/jaildir deleted file mode 100644 index ec7d86c6..00000000 --- a/cdist/conf/type/__jail_freebsd10/parameter/default/jaildir +++ /dev/null @@ -1 +0,0 @@ -/usr/jail diff --git a/cdist/conf/type/__jail_freebsd10/parameter/default/state b/cdist/conf/type/__jail_freebsd10/parameter/default/state deleted file mode 100644 index e7f6134f..00000000 --- a/cdist/conf/type/__jail_freebsd10/parameter/default/state +++ /dev/null @@ -1 +0,0 @@ -present diff --git a/cdist/conf/type/__jail_freebsd10/parameter/optional b/cdist/conf/type/__jail_freebsd10/parameter/optional deleted file mode 100644 index b36f0fa5..00000000 --- a/cdist/conf/type/__jail_freebsd10/parameter/optional +++ /dev/null @@ -1,8 +0,0 @@ -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 deleted file mode 100755 index 034128d5..00000000 --- a/cdist/conf/type/__jail_freebsd9/explorer/basepresent +++ /dev/null @@ -1,54 +0,0 @@ -#!/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 deleted file mode 100755 index ddfb805c..00000000 --- a/cdist/conf/type/__jail_freebsd9/explorer/present +++ /dev/null @@ -1,43 +0,0 @@ -#!/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 deleted file mode 100755 index c8039f21..00000000 --- a/cdist/conf/type/__jail_freebsd9/explorer/status +++ /dev/null @@ -1,52 +0,0 @@ -#!/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_freebsd9/man.rst b/cdist/conf/type/__jail_freebsd9/man.rst deleted file mode 100644 index cc79c785..00000000 --- a/cdist/conf/type/__jail_freebsd9/man.rst +++ /dev/null @@ -1,124 +0,0 @@ -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 --------- -:strong:`jail`\ (8) - - -AUTHORS -------- -Jake Guffey - - -COPYING -------- -Copyright \(C) 2012-2016 Jake Guffey. 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. diff --git a/cdist/conf/type/__jail_freebsd9/parameter/boolean b/cdist/conf/type/__jail_freebsd9/parameter/boolean deleted file mode 100644 index 39144f6f..00000000 --- a/cdist/conf/type/__jail_freebsd9/parameter/boolean +++ /dev/null @@ -1,3 +0,0 @@ -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 deleted file mode 100644 index f602aa0a..00000000 --- a/cdist/conf/type/__jail_freebsd9/parameter/default/devfs-ruleset +++ /dev/null @@ -1 +0,0 @@ -jailrules diff --git a/cdist/conf/type/__jail_freebsd9/parameter/default/jailbase b/cdist/conf/type/__jail_freebsd9/parameter/default/jailbase deleted file mode 100644 index 8b137891..00000000 --- a/cdist/conf/type/__jail_freebsd9/parameter/default/jailbase +++ /dev/null @@ -1 +0,0 @@ - diff --git a/cdist/conf/type/__jail_freebsd9/parameter/default/jaildir b/cdist/conf/type/__jail_freebsd9/parameter/default/jaildir deleted file mode 100644 index ec7d86c6..00000000 --- a/cdist/conf/type/__jail_freebsd9/parameter/default/jaildir +++ /dev/null @@ -1 +0,0 @@ -/usr/jail diff --git a/cdist/conf/type/__jail_freebsd9/parameter/default/state b/cdist/conf/type/__jail_freebsd9/parameter/default/state deleted file mode 100644 index e7f6134f..00000000 --- a/cdist/conf/type/__jail_freebsd9/parameter/default/state +++ /dev/null @@ -1 +0,0 @@ -present diff --git a/cdist/conf/type/__jail_freebsd9/parameter/optional b/cdist/conf/type/__jail_freebsd9/parameter/optional deleted file mode 100644 index b36f0fa5..00000000 --- a/cdist/conf/type/__jail_freebsd9/parameter/optional +++ /dev/null @@ -1,8 +0,0 @@ -name -ip -hostname -interface -devfs-ruleset -jaildir -jailbase -state diff --git a/cdist/conf/type/__key_value/explorer/state b/cdist/conf/type/__key_value/explorer/state index 7b2de1df..b990733d 100755 --- a/cdist/conf/type/__key_value/explorer/state +++ b/cdist/conf/type/__key_value/explorer/state @@ -19,9 +19,9 @@ # along with cdist. If not, see . # -key="$(cat "$__object/parameter/key" 2>/dev/null \ +export key="$(cat "$__object/parameter/key" 2>/dev/null \ || echo "$__object_id")" -state="$(cat "$__object/parameter/state")" +export state="$(cat "$__object/parameter/state")" file="$(cat "$__object/parameter/file")" @@ -30,15 +30,14 @@ if [ ! -f "$file" ]; then exit fi -delimiter="$(cat "$__object/parameter/delimiter")" -value="$(cat "$__object/parameter/value" 2>/dev/null \ +export delimiter="$(cat "$__object/parameter/delimiter")" +export value="$(cat "$__object/parameter/value" 2>/dev/null \ || echo "__CDIST_NOTSET__")" if [ -f "$__object/parameter/exact_delimiter" ]; then - exact_delimiter=1 + export exact_delimiter=1 else - exact_delimiter=0 + export exact_delimiter=0 fi -export key state delimiter value exact_delimiter awk -f - "$file" <<"AWK_EOF" BEGIN { diff --git a/cdist/conf/type/__key_value/files/remote_script.sh b/cdist/conf/type/__key_value/files/remote_script.sh index f7a1add5..282ba531 100644 --- a/cdist/conf/type/__key_value/files/remote_script.sh +++ b/cdist/conf/type/__key_value/files/remote_script.sh @@ -1,21 +1,17 @@ -#!/bin/sh - -key="$(cat "$__object/parameter/key" 2>/dev/null \ +export key="$(cat "$__object/parameter/key" 2>/dev/null \ || echo "$__object_id")" -state="$(cat "$__object/parameter/state")" +export state="$(cat "$__object/parameter/state")" file="$(cat "$__object/parameter/file")" -delimiter="$(cat "$__object/parameter/delimiter")" -value="$(cat "$__object/parameter/value" 2>/dev/null \ +export delimiter="$(cat "$__object/parameter/delimiter")" +export value="$(cat "$__object/parameter/value" 2>/dev/null \ || echo "__CDIST_NOTSET__")" -export key state delimiter value if [ -f "$__object/parameter/exact_delimiter" ]; then - exact_delimiter=1 + export exact_delimiter=1 else - exact_delimiter=0 + export exact_delimiter=0 fi -export exact_delimiter tmpfile=$(mktemp "${file}.cdist.XXXXXXXXXX") # preserve ownership and permissions by copying existing file over tmpfile diff --git a/cdist/conf/type/__key_value/gencode-remote b/cdist/conf/type/__key_value/gencode-remote index 13cc27c7..e6815cb6 100755 --- a/cdist/conf/type/__key_value/gencode-remote +++ b/cdist/conf/type/__key_value/gencode-remote @@ -1,4 +1,4 @@ -#!/bin/sh -e +#!/bin/sh # # 2011 Steven Armstrong (steven-cdist at armstrong.cc) # 2012-2014 Nico Schottelius (nico-cdist at schottelius.org) @@ -23,14 +23,13 @@ state_should="$(cat "$__object/parameter/state")" state_is="$(cat "$__object/explorer/state")" -fire_onchange='' if [ "$state_is" = "$state_should" ]; then exit 0 fi # here we check only if the states are valid, -# emit messages and +# emmit messages and # let awk do the work ... case "$state_should" in absent) @@ -40,7 +39,6 @@ case "$state_should" in ;; wrongformat|wrongvalue|present) echo "remove" >> "$__messages_out" - fire_onchange=1 ;; *) echo "Unknown explorer state: $state_is" >&2 @@ -52,15 +50,12 @@ case "$state_should" in case "$state_is" in nosuchfile) echo "create" >> "$__messages_out" - fire_onchange=1 ;; absent) echo "insert" >> "$__messages_out" - fire_onchange=1 ;; wrongformated|wrongvalue) echo "change" >> "$__messages_out" - fire_onchange=1 ;; present) # nothing to do @@ -72,13 +67,9 @@ case "$state_should" in esac ;; *) - echo "Unknown state: $state_should" >&2 - exit 1 + echo "Unknown state: $state_should" >&2 + exit 1 ;; esac cat "$__type/files/remote_script.sh" - -if [ -n "$fire_onchange" ]; then - cat "$__object/parameter/onchange" -fi diff --git a/cdist/conf/type/__key_value/man.rst b/cdist/conf/type/__key_value/man.text similarity index 56% rename from cdist/conf/type/__key_value/man.rst rename to cdist/conf/type/__key_value/man.text index 34e4aab2..d4c8e2cc 100644 --- a/cdist/conf/type/__key_value/man.rst +++ b/cdist/conf/type/__key_value/man.text @@ -1,5 +1,7 @@ cdist-type__key_value(7) ======================== +Steven Armstrong + NAME ---- @@ -14,83 +16,79 @@ file. REQUIRED PARAMETERS ------------------- -file +file:: The file to operate on. -delimiter - The delimiter which separates the key from the value. +delimiter:: + The delimiter which seperates the key from the value. OPTIONAL PARAMETERS ------------------- -state +state:: present or absent, defaults to present. If present, sets the key to value, if absent, removes the key from the file. -key +key:: The key to change. Defaults to object_id. -value +value:: The value for the key. Optional if state=absent, required otherwise. -comment +comment:: If supplied, the value will be inserted before the line with the key, but only if the key or value must be changed. You need to ensure yourself that the line is prefixed with the correct comment sign. (for example # or ; or wathever ..) -onchange - The code to run if the key or value changes (i.e. is inserted, removed or replaced). BOOLEAN PARAMETERS ------------------ -exact_delimiter +exact_delimiter:: If supplied, treat additional whitespaces between key, delimiter and value as wrong value. MESSAGES -------- -remove +remove:: Removed existing key and value -insert +insert:: Added key and value -change +change:: Changed value of existing key -create +create:: A new line was inserted in a new file EXAMPLES -------- -.. code-block:: sh +-------------------------------------------------------------------------------- +# Set the maximum system user id +__key_value SYS_UID_MAX --file /etc/login.defs --value 666 --delimiter ' ' - # Set the maximum system user id - __key_value SYS_UID_MAX --file /etc/login.defs --value 666 --delimiter ' ' +# Same with fancy id +__key_value my-fancy-id --file /etc/login.defs --key SYS_UID_MAX --value 666 \ + --delimiter ' ' - # Same with fancy id - __key_value my-fancy-id --file /etc/login.defs --key SYS_UID_MAX --value 666 \ - --delimiter ' ' +# Enable packet forwarding +__key_value net.ipv4.ip_forward --file /etc/sysctl.conf --value 1 \ + --delimiter ' = ' --comment '# my linux kernel should act as a router' - # Enable packet forwarding - __key_value net.ipv4.ip_forward --file /etc/sysctl.conf --value 1 \ - --delimiter ' = ' --comment '# my linux kernel should act as a router' - - # Remove existing key/value - __key_value LEGACY_KEY --file /etc/somefile --state absent --delimiter '=' +# Remove existing key/value +__key_value LEGACY_KEY --file /etc/somefile --state absent --delimiter '=' +-------------------------------------------------------------------------------- MORE INFORMATION ---------------- 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 length. +So you need to exactly specify the key and delimiter. Delimiter can be of any lenght. -AUTHORS -------- -Steven Armstrong +SEE ALSO +-------- +- cdist-type(7) COPYING ------- -Copyright \(C) 2011 Steven Armstrong. 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. +Copyright \(C) 2011 Steven Armstrong. Free use of this software is +granted under the terms of the GNU General Public License version 3 (GPLv3). diff --git a/cdist/conf/type/__key_value/manifest b/cdist/conf/type/__key_value/manifest index 5a91f60c..56f4c874 100755 --- a/cdist/conf/type/__key_value/manifest +++ b/cdist/conf/type/__key_value/manifest @@ -1,4 +1,4 @@ -#!/bin/sh -e +#!/bin/sh # # 2011 Steven Armstrong (steven-cdist at armstrong.cc) # 2012 Nico Schottelius (nico-cdist at schottelius.org) @@ -21,7 +21,7 @@ state_should="$(cat "$__object/parameter/state")" -if [ "$state_should" = "present" ] && [ ! -f "$__object/parameter/value" ]; then +if [ "$state_should" = "present" -a ! -f "$__object/parameter/value" ]; then echo "Missing required parameter 'value'" >&2 exit 1 fi diff --git a/cdist/conf/type/__key_value/parameter/default/onchange b/cdist/conf/type/__key_value/parameter/default/onchange deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/conf/type/__key_value/parameter/optional b/cdist/conf/type/__key_value/parameter/optional index d4b8cac0..666be2ae 100644 --- a/cdist/conf/type/__key_value/parameter/optional +++ b/cdist/conf/type/__key_value/parameter/optional @@ -2,4 +2,3 @@ key value state comment -onchange diff --git a/cdist/conf/type/__keyboard/man.rst b/cdist/conf/type/__keyboard/man.rst deleted file mode 100644 index 0eb4cde9..00000000 --- a/cdist/conf/type/__keyboard/man.rst +++ /dev/null @@ -1,37 +0,0 @@ -cdist-type__keyboard(7) -======================= - -NAME ----- -cdit-type__keyboard - Set keyboard layout - - -DESCRIPTION ------------ -This cdist type allows you to modify keyboard layout. - - -REQUIRED PARAMETERS -------------------- -type - Any valid type, for example "us" - - -EXAMPLES --------- - -.. code-block:: sh - - # Set keyboard type to "us" - __keyboard --type "us" - - -AUTHORS -------- -Carlos Ortigoza - - -COPYING -------- -Copyright \(C) 2016 Carlos Ortigoza. Free use of this software is -granted under the terms of the GNU General Public License v3 or later (GPLv3+). diff --git a/cdist/conf/type/__keyboard/manifest b/cdist/conf/type/__keyboard/manifest deleted file mode 100755 index 80cd4819..00000000 --- a/cdist/conf/type/__keyboard/manifest +++ /dev/null @@ -1,50 +0,0 @@ -#!/bin/sh -e -# -# Carlos Ortigoza (carlos.ortigoza at ungleich.ch) -# -# 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 . -# -# -# Configure keyboard type by modifying /etc/sysconfig/keyboard file. -# - -os=$(cat "$__global/explorer/os") -keyboard_type="$(cat "$__object/parameter/type")" - -case "$os" in - centos) - __file /etc/sysconfig/keyboard \ - --owner root --group root --mode 644 \ - --state exists - - require="__file/etc/sysconfig/keyboard" \ - __key_value KEYTABLE \ - --file /etc/sysconfig/keyboard \ - --delimiter '=' \ - --value "\"$keyboard_type\"" - - require="__file/etc/sysconfig/keyboard" \ - __key_value LAYOUT \ - --file /etc/sysconfig/keyboard \ - --delimiter '=' \ - --value "\"$keyboard_type\"" - ;; - *) - echo "Your operating system ($os) is currently not supported by this type (${__type##*/})." >&2 - echo "Please contribute an implementation for it if you can." >&2 - exit 1 - ;; -esac diff --git a/cdist/conf/type/__keyboard/parameter/required b/cdist/conf/type/__keyboard/parameter/required deleted file mode 100644 index aa80e646..00000000 --- a/cdist/conf/type/__keyboard/parameter/required +++ /dev/null @@ -1 +0,0 @@ -type diff --git a/cdist/conf/type/__keyboard/singleton b/cdist/conf/type/__keyboard/singleton deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/conf/type/__letsencrypt_cert/explorer/certbot-path b/cdist/conf/type/__letsencrypt_cert/explorer/certbot-path deleted file mode 100755 index 3c6076df..00000000 --- a/cdist/conf/type/__letsencrypt_cert/explorer/certbot-path +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -e - -command -v certbot 2>/dev/null || true diff --git a/cdist/conf/type/__letsencrypt_cert/explorer/certificate-domains b/cdist/conf/type/__letsencrypt_cert/explorer/certificate-domains deleted file mode 100755 index db605b63..00000000 --- a/cdist/conf/type/__letsencrypt_cert/explorer/certificate-domains +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh -e - -certbot_path=$("${__type_explorer}/certbot-path") -if [ -n "${certbot_path}" ] -then - certbot certificates --cert-name "${__object_id:?}" | grep ' Domains: ' | \ - cut -d ' ' -f 6- | tr ' ' '\n' -fi diff --git a/cdist/conf/type/__letsencrypt_cert/explorer/certificate-exists b/cdist/conf/type/__letsencrypt_cert/explorer/certificate-exists deleted file mode 100755 index 4e6f44db..00000000 --- a/cdist/conf/type/__letsencrypt_cert/explorer/certificate-exists +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh -e - -certbot_path=$("${__type_explorer}/certbot-path") -if [ -n "${certbot_path}" ] -then - if certbot certificates | grep -q " Certificate Name: ${__object_id:?}$"; then - echo yes - else - echo no - fi -else - echo no -fi diff --git a/cdist/conf/type/__letsencrypt_cert/explorer/certificate-is-test b/cdist/conf/type/__letsencrypt_cert/explorer/certificate-is-test deleted file mode 100755 index 9b445059..00000000 --- a/cdist/conf/type/__letsencrypt_cert/explorer/certificate-is-test +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh -e - -certbot_path=$("${__type_explorer}/certbot-path") -if [ -n "${certbot_path}" ] -then - if certbot certificates --cert-name "${__object_id:?}" | \ - grep -q 'INVALID: TEST_CERT'; then - echo yes - else - echo no - fi -else - echo no -fi diff --git a/cdist/conf/type/__letsencrypt_cert/gencode-remote b/cdist/conf/type/__letsencrypt_cert/gencode-remote deleted file mode 100755 index 375570a4..00000000 --- a/cdist/conf/type/__letsencrypt_cert/gencode-remote +++ /dev/null @@ -1,82 +0,0 @@ -#!/bin/sh -e - -certificate_exists=$(cat "${__object:?}/explorer/certificate-exists") -name="${__object_id:?}" -state=$(cat "${__object}/parameter/state") - -case "${state}" in - absent) - if [ "${certificate_exists}" = "no" ]; then - exit 0 - fi - - echo "certbot delete --cert-name '${name}' --quiet" - - echo remove >> "${__messages_out:?}" - ;; - present) - domain_param_file="${__object}/parameter/domain" - requested_domains=$(mktemp "${TMPDIR:-/tmp}/domain.cdist.XXXXXXXXXX") - if [ -f "${domain_param_file}" ]; then - cp "${domain_param_file}" "${requested_domains}" - else - echo "$__object_id" >> "${requested_domains}" - fi - - staging=no - if [ -f "${__object}/parameter/staging" ]; then - staging=yes - fi - - if [ "${certificate_exists}" = "yes" ]; then - existing_domains="${__object}/explorer/certificate-domains" - certificate_is_test=$(cat "${__object}/explorer/certificate-is-test") - - sort -uo "${requested_domains}" "${requested_domains}" - sort -uo "${existing_domains}" "${existing_domains}" - - if [ -z "$(comm -23 "${requested_domains}" "${existing_domains}")" ] && \ - [ "${certificate_is_test}" = "${staging}" ]; then - exit 0 - fi - fi - - admin_email="$(cat "$__object/parameter/admin-email")" - webroot="$(cat "$__object/parameter/webroot")" - - cat <<-EOF - certbot certonly \ - --agree-tos \ - --cert-name '${name}' \ - --email '${admin_email}' \ - --expand \ - --non-interactive \ - --quiet \ - $(if [ "${staging}" = "yes" ]; then - echo "--staging" - elif [ "${certificate_is_test}" != "${staging}" ]; then - echo "--force-renewal" - fi) \ - $(if [ -z "${webroot}" ]; then - echo "--standalone" - else - echo "--webroot --webroot-path '${webroot}'" - fi) \ - $(while read -r domain; do - echo "--domain '${domain}' \\" - done < "${requested_domains}") - EOF - rm -f "${requested_domains}" - - if [ "${certificate_exists}" = "no" ]; then - echo create >> "${__messages_out}" - else - echo change >> "${__messages_out}" - fi - ;; - *) - echo "Unsupported state: ${state}" >&2 - - exit 1 - ;; -esac diff --git a/cdist/conf/type/__letsencrypt_cert/man.rst b/cdist/conf/type/__letsencrypt_cert/man.rst deleted file mode 100644 index c4ffc6bc..00000000 --- a/cdist/conf/type/__letsencrypt_cert/man.rst +++ /dev/null @@ -1,109 +0,0 @@ -cdist-type__letsencrypt_cert(7) -=============================== - -NAME ----- - -cdist-type__letsencrypt_cert - Get an SSL certificate from Let's Encrypt - -DESCRIPTION ------------ - -Automatically obtain a Let's Encrypt SSL certificate using Certbot. - -REQUIRED PARAMETERS -------------------- - -object id - A cert name. If domain parameter is not specified then it is used - as a domain to be included in the certificate. - -admin-email - Where to send Let's Encrypt emails like "certificate needs renewal". - -OPTIONAL PARAMETERS -------------------- - -state - 'present' or 'absent', defaults to 'present' where: - - present - if the certificate does not exist, it will be obtained - absent - the certificate will be removed - -webroot - The path to your webroot, as set up in your webserver config. If this - parameter is not present, Certbot will be run in standalone mode. - -OPTIONAL MULTIPLE PARAMETERS ----------------------------- - -renew-hook - Renew hook command directly passed to Certbot in cron job. - -domain - Domains to be included in the certificate. When specified then object id - is not used as a domain. - -BOOLEAN PARAMETERS ------------------- - -automatic-renewal - Install a cron job, which attempts to renew certificates daily. - -staging - Obtain a test certificate from a staging server. - -MESSAGES --------- - -change - Certificte was changed. - -create - Certificte was created. - -remove - Certificte was removed. - -EXAMPLES --------- - -.. code-block:: sh - - # use object id as domain - __letsencrypt_cert example.com \ - --admin-email root@example.com \ - --automatic-renewal \ - --renew-hook "service nginx reload" \ - --webroot /data/letsencrypt/root - -.. code-block:: sh - - # domain parameter is specified so object id is not used as domain - # and example.com needs to be included again with domain parameter - __letsencrypt_cert example.com \ - --admin-email root@example.com \ - --automatic-renewal \ - --domain example.com \ - --domain foo.example.com \ - --domain bar.example.com \ - --renew-hook "service nginx reload" \ - --webroot /data/letsencrypt/root - -AUTHORS -------- - -| Nico Schottelius -| Kamila Součková -| Darko Poljak -| Ľubomír Kučera - -COPYING -------- - -Copyright \(C) 2017-2018 Nico Schottelius, Kamila Součková, Darko Poljak and -Ľubomír Kučera. 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. diff --git a/cdist/conf/type/__letsencrypt_cert/manifest b/cdist/conf/type/__letsencrypt_cert/manifest deleted file mode 100755 index d598949e..00000000 --- a/cdist/conf/type/__letsencrypt_cert/manifest +++ /dev/null @@ -1,105 +0,0 @@ -#!/bin/sh - -certbot_fullpath="$(cat "${__object:?}/explorer/certbot-path")" - -if [ -z "${certbot_fullpath}" ]; then - os="$(cat "${__global:?}/explorer/os")" - os_version="$(cat "${__global}/explorer/os_version")" - - case "$os" in - debian) - case "$os_version" in - 8*) - __apt_source jessie-backports \ - --uri http://http.debian.net/debian \ - --distribution jessie-backports \ - --component main - - require="__apt_source/jessie-backports" __package_apt python-certbot \ - --target-release jessie-backports - require="__apt_source/jessie-backports" __package_apt certbot \ - --target-release jessie-backports - # Seems to be a missing dependency on debian 8 - __package python-ndg-httpsclient - ;; - 9*) - __apt_source stretch-backports \ - --uri http://http.debian.net/debian \ - --distribution stretch-backports \ - --component main - - require="__apt_source/stretch-backports" __package_apt python-certbot \ - --target-release stretch-backports - require="__apt_source/stretch-backports" __package_apt certbot \ - --target-release stretch-backports - ;; - *) - echo "Unsupported OS version: $os_version" >&2 - exit 1 - ;; - esac - - certbot_fullpath=/usr/bin/certbot - ;; - devuan) - case "$os_version" in - jessie) - __apt_source jessie-backports \ - --uri http://auto.mirror.devuan.org/merged \ - --distribution jessie-backports \ - --component main - - require="__apt_source/jessie-backports" __package_apt python-certbot \ - --target-release jessie-backports - require="__apt_source/jessie-backports" __package_apt certbot \ - --target-release jessie-backports - # Seems to be a missing dependency on debian 8 - __package python-ndg-httpsclient - ;; - ascii*) - __apt_source ascii-backports \ - --uri http://auto.mirror.devuan.org/merged \ - --distribution ascii-backports \ - --component main - - require="__apt_source/ascii-backports" __package_apt certbot \ - --target-release ascii-backports - ;; - bewoulf*) - __package_apt certbot - ;; - *) - echo "Unsupported OS version: $os_version" >&2 - exit 1 - ;; - esac - - certbot_fullpath=/usr/bin/certbot - ;; - freebsd) - __package py27-certbot - - certbot_fullpath=/usr/local/bin/certbot - ;; - *) - echo "Unsupported os: $os" >&2 - exit 1 - ;; - esac -fi - -if [ -f "${__object}/parameter/automatic-renewal" ]; then - renew_hook_param="${__object}/parameter/renew-hook" - renew_hook="" - if [ -f "${renew_hook_param}" ]; then - while read -r hook; do - renew_hook="${renew_hook} --renew-hook \"${hook}\"" - done < "${renew_hook_param}" - fi - - __cron letsencrypt-certbot \ - --user root \ - --command "${certbot_fullpath} renew -q ${renew_hook}" \ - --hour 0 \ - --minute 47 -fi diff --git a/cdist/conf/type/__letsencrypt_cert/nonparallel b/cdist/conf/type/__letsencrypt_cert/nonparallel deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/conf/type/__letsencrypt_cert/parameter/boolean b/cdist/conf/type/__letsencrypt_cert/parameter/boolean deleted file mode 100644 index d5b8be99..00000000 --- a/cdist/conf/type/__letsencrypt_cert/parameter/boolean +++ /dev/null @@ -1,2 +0,0 @@ -automatic-renewal -staging diff --git a/cdist/conf/type/__letsencrypt_cert/parameter/default/state b/cdist/conf/type/__letsencrypt_cert/parameter/default/state deleted file mode 100644 index e7f6134f..00000000 --- a/cdist/conf/type/__letsencrypt_cert/parameter/default/state +++ /dev/null @@ -1 +0,0 @@ -present diff --git a/cdist/conf/type/__letsencrypt_cert/parameter/default/webroot b/cdist/conf/type/__letsencrypt_cert/parameter/default/webroot deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/conf/type/__letsencrypt_cert/parameter/optional b/cdist/conf/type/__letsencrypt_cert/parameter/optional deleted file mode 100644 index 0a63b11e..00000000 --- a/cdist/conf/type/__letsencrypt_cert/parameter/optional +++ /dev/null @@ -1,2 +0,0 @@ -state -webroot diff --git a/cdist/conf/type/__letsencrypt_cert/parameter/optional_multiple b/cdist/conf/type/__letsencrypt_cert/parameter/optional_multiple deleted file mode 100644 index 0e866d45..00000000 --- a/cdist/conf/type/__letsencrypt_cert/parameter/optional_multiple +++ /dev/null @@ -1,2 +0,0 @@ -domain -renew-hook diff --git a/cdist/conf/type/__letsencrypt_cert/parameter/required b/cdist/conf/type/__letsencrypt_cert/parameter/required deleted file mode 100644 index bfe77226..00000000 --- a/cdist/conf/type/__letsencrypt_cert/parameter/required +++ /dev/null @@ -1 +0,0 @@ -admin-email diff --git a/cdist/conf/type/__line/explorer/state b/cdist/conf/type/__line/explorer/state index 2ef252c8..d04d5d09 100755 --- a/cdist/conf/type/__line/explorer/state +++ b/cdist/conf/type/__line/explorer/state @@ -1,6 +1,6 @@ -#!/bin/sh -e +#!/bin/sh # -# 2018 Steven Armstrong (steven-cdist at armstrong.cc) +# 2012-2013 Nico Schottelius (nico-cdist at schottelius.org) # # This file is part of cdist. # @@ -17,79 +17,26 @@ # You should have received a copy of the GNU General Public License # along with cdist. If not, see . # +# -if [ -f "$__object/parameter/before" ]; then - position="before" -elif [ -f "$__object/parameter/after" ]; then - position="after" -else - # By default we append to the end of the file. - position="end" -fi +file="/$__object_id" +[ -f "$__object/parameter/file" ] && file=$(cat "$__object/parameter/file") if [ -f "$__object/parameter/regex" ]; then - needle="regex" + regex=$(cat "$__object/parameter/regex") + greparg="" else - needle="line" + if [ ! -f "$__object/parameter/line" ]; then + echo "Parameter line and regex missing - cannot explore" >&2 + exit 1 + fi + regex="$(cat "$__object/parameter/line")" + greparg="-F -x" fi -if [ -f "$__object/parameter/file" ]; then - file="$(cat "$__object/parameter/file")" +# Allow missing file - thus 2>/dev/null +if grep -q $greparg "$regex" "$file" 2>/dev/null; then + echo present else - file="/$__object_id" + echo absent fi - -if [ ! -f "$file" ]; then - echo "file_missing" - exit 0 -fi - -awk -v position="$position" -v needle="$needle" ' -function _find(_text, _pattern) { - if (needle == "regex") { - return match(_text, _pattern) - } else { - return index(_text, _pattern) - } -} -BEGIN { - getline anchor < (ENVIRON["__object"] "/parameter/" position) - getline pattern < (ENVIRON["__object"] "/parameter/" needle) - state = "absent" -} -{ - if (position == "after") { - if (match($0, anchor)) { - getline - if (_find($0, pattern)) { - state = "present" - } - else { - state = "wrongposition" - } - exit 0 - } - } - else if (position == "before") { - if (_find($0, pattern)) { - getline - if (match($0, anchor)) { - state = "present" - } - else { - state = "wrongposition" - } - exit 0 - } - } - else { - if (_find($0, pattern)) { - state = "present" - exit 0 - } - } -} -END { - print state -} -' "$file" diff --git a/cdist/conf/type/__line/gencode-remote b/cdist/conf/type/__line/gencode-remote index 03e90c1b..f73444e3 100755 --- a/cdist/conf/type/__line/gencode-remote +++ b/cdist/conf/type/__line/gencode-remote @@ -1,6 +1,7 @@ -#!/bin/sh -e +#!/bin/sh # -# 2018 Steven Armstrong (steven-cdist at armstrong.cc) +# 2012 Nico Schottelius (nico-cdist at schottelius.org) +# 2014 Steven Armstrong (steven-cdist at armstrong.cc) # # This file is part of cdist. # @@ -17,112 +18,74 @@ # You should have received a copy of the GNU General Public License # along with cdist. If not, see . # +# -if [ -f "$__object/parameter/before" ] && [ -f "$__object/parameter/after" ]; then - echo "Use either --before OR --after but not both." >&2 - exit 1 -fi +file="/$__object_id" +regex="" +state_should="present" +[ -f "$__object/parameter/file" ] && file=$(cat "$__object/parameter/file") +[ -f "$__object/parameter/regex" ] && regex=$(cat "$__object/parameter/regex") +[ -f "$__object/parameter/state" ] && state_should=$(cat "$__object/parameter/state") +[ -f "$__object/parameter/line" ] && line=$(cat "$__object/parameter/line") -state_should="$(cat "$__object/parameter/state")" state_is="$(cat "$__object/explorer/state")" -if [ "$state_should" = "$state_is" ]; then - # nothing to do - exit 0 -fi +[ "$state_should" = "$state_is" ] && exit 0 -if [ -f "$__object/parameter/before" ]; then - position="before" -elif [ -f "$__object/parameter/after" ]; then - position="after" -else - # By default we append to the end of the file. - position="end" -fi - -if [ -f "$__object/parameter/regex" ]; then - needle="regex" -else - needle="line" -fi - -if [ -f "$__object/parameter/file" ]; then - file="$(cat "$__object/parameter/file")" -else - file="/$__object_id" -fi - -add=0 -remove=0 case "$state_should" in - present) - if [ "$state_is" = "wrongposition" ]; then - echo updated >> "$__messages_out" - remove=1 - else - echo added >> "$__messages_out" - fi - add=1 - ;; - absent) - echo removed >> "$__messages_out" - remove=1 - ;; -esac + present) + if [ ! "$line" ]; then + echo "Required parameter \"line\" is missing" >&2 + exit 1 + fi -cat << DONE + #echo "echo \"$line\" >> $file" + #line_sanitised=$(cat "$__object/parameter/line" | sed 's/"/\"/g') + # Idea: replace ' in the string: + # '"'"' + # |------> ': end the string + # |-|---> "'": create ' in the output string + # |--> ': continue the string + # + # Replace all \ so \t and other combinations are not interpreted + # + + + # line_sanitised=$(cat "$__object/parameter/line" | sed -e "s/'/'\"'\"'/g" -e 's/\\/\\\\/g') + # The one above does not work: + # --line "PS1='[\t] \[\033[1m\]\h\[\033[0m\]:\w\\$ '" + # becomes + # PS1='[\\t] \\[\\033[1m\\]\\h\\[\\033[0m\\]:\\w\\$ ' + + # Only replace ' with '"'"' and keep \ as they are + line_sanitised=$(cat "$__object/parameter/line" | sed -e "s/'/'\"'\"'/g") + printf '%s' "printf '%s\n' '$line_sanitised' >> $file" + + ;; + absent) + if [ "$regex" -a "$line" ]; then + echo "Mutally exclusive parameters regex and line given for state absent" >&2 + exit 1 + fi + + greparg="" + if [ "$line" ]; then + regex="$line" + greparg="-F -x" + fi + + cat << eof tmpfile=\$(mktemp ${file}.cdist.XXXXXXXXXX) # preserve ownership and permissions of existing file if [ -f "$file" ]; then cp -p "$file" "\$tmpfile" fi - -awk -v position="$position" -v needle="$needle" -v remove=$remove -v add=$add ' -function _find(_text, _pattern) { - if (needle == "regex") { - return match(_text, _pattern) - } else { - return index(_text, _pattern) - } -} -BEGIN { - line_file = ENVIRON["__object"] "/parameter/line" - getline line < line_file - # Need to close line file as it may be re-read as pattern below. - close(line_file) - getline pattern < (ENVIRON["__object"] "/parameter/" needle) - getline anchor < (ENVIRON["__object"] "/parameter/" position) -} -{ - if (remove) { - if (_find(\$0, pattern)) { - # skip over this line -> remove it - next - } - } - if (add) { - if (anchor && match(\$0, anchor)) { - if (position == "before") { - print line - print - } else if (position == "after") { - print - print line - } - next - } - } - print -} -END { - if (add && position == "end") { - print line - } -} -' "$file" > "\$tmpfile" +grep -v $greparg '$regex' '$file' > \$tmpfile || true mv -f "\$tmpfile" "$file" -DONE - -if [ -f "$__object/parameter/onchange" ]; then - cat "$__object/parameter/onchange" -fi +eof + ;; + *) + echo "Unknown state: $state_should" >&2 + exit 1 + ;; +esac diff --git a/cdist/conf/type/__line/man.rst b/cdist/conf/type/__line/man.rst deleted file mode 100644 index f76cab64..00000000 --- a/cdist/conf/type/__line/man.rst +++ /dev/null @@ -1,116 +0,0 @@ -cdist-type__line(7) -=================== - -NAME ----- -cdist-type__line - Manage lines in files - - -DESCRIPTION ------------ -This cdist type allows you to add lines and remove lines from files. - - -REQUIRED PARAMETERS -------------------- -None. - - -OPTIONAL PARAMETERS -------------------- -after - Insert the given line after this pattern. - -before - Insert the given line before this pattern. - -file - If supplied, use this as the destination file. - Otherwise the object_id is used. - -line - Specifies the line which should be absent or present. - - Must be present, if state is 'present'. - Ignored if regex is given and state is 'absent'. - -regex - If state is 'present', search for this pattern and if it matches add - the given line. - - If state is 'absent', ensure all lines matching the regular expression - are absent. - - The regular expression is interpreted by awk's match function. - -state - 'present' or 'absent', defaults to 'present' - -onchange - The code to run if line is added, removed or updated. - - -BOOLEAN PARAMETERS ------------------- -None. - - -MESSAGES --------- -added - The line was added. - -updated - The line or its position was changed. - -removed - The line was removed. - - -EXAMPLES --------- - -.. code-block:: sh - - # Manage a hosts entry for www.example.com. - __line /etc/hosts \ - --line '127.0.0.2 www.example.com' - - # Manage another hosts entry for test.example.com. - __line hosts:test.example.com \ - --file /etc/hosts \ - --line '127.0.0.3 test.example.com' - - # Remove the line starting with TIMEZONE from the /etc/rc.conf file. - __line legacy_timezone \ - --file /etc/rc.conf \ - --regex 'TIMEZONE=.*' \ - --state absent - - # Insert a line before another one. - __line password-auth-local:classify \ - --file /etc/pam.d/password-auth-local \ - --line '-session required pam_exec.so debug log=/tmp/classify.log /usr/local/libexec/classify' \ - --before '^session[[:space:]]+include[[:space:]]+password-auth-ac$' - - # Insert a line after another one. - __line password-auth-local:classify \ - --file /etc/pam.d/password-auth-local \ - --line '-session required pam_exec.so debug log=/tmp/classify.log /usr/local/libexec/classify' \ - --after '^session[[:space:]]+include[[:space:]]+password-auth-ac$' - - -SEE ALSO --------- -:strong:`cdist-type`\ (7) - - -AUTHORS -------- -Steven Armstrong - - -COPYING -------- -Copyright \(C) 2018 Steven Armstrong. Free use of this software is -granted under the terms of the GNU General Public License version 3 (GPLv3). diff --git a/cdist/conf/type/__line/man.text b/cdist/conf/type/__line/man.text new file mode 100644 index 00000000..f39ee929 --- /dev/null +++ b/cdist/conf/type/__line/man.text @@ -0,0 +1,73 @@ +cdist-type__line(7) +=================== +Nico Schottelius + + +NAME +---- +cdist-type__line - Manage lines in files + + +DESCRIPTION +----------- +This cdist type allows you to add lines and remove lines from files. + + +REQUIRED PARAMETERS +------------------- + +OPTIONAL PARAMETERS +------------------- +state:: + 'present' or 'absent', defaults to 'present' + +line:: + Specifies the line which should be absent or present + + Must be present, if state is present. + Must not be combined with regex, if state is absent. + +regex:: + If state is present, search for this pattern and add + given line, if the given regular expression does not match. + + In case of absent, ensure all lines matching the + regular expression are absent. + + The regular expression is interpreted by grep. + + Must not be combined with line, if state is absent. + +file:: + If supplied, use this as the destination file. + Otherwise the object_id is used. + + +EXAMPLES +-------- + +-------------------------------------------------------------------------------- +# Manage the DAEMONS line in rc.conf +__line daemons --file /etc/rc.conf --line 'DAEMONS=(hwclock !network sshd crond postfix)' + +# Ensure the home mount is present in /etc/fstab - explicitly make it present +__line home-fstab \ + --file /etc/fstab \ + --line 'filer.fs:/vol/home /home nfs defaults 0 0' \ + --state present + +# Removes the line specifiend in "include_www" from the file "lighttpd.conf" +__line legacy_timezone --file /etc/rc.conf --regex 'TIMEZONE=.*' --state absent +-------------------------------------------------------------------------------- + + +SEE ALSO +-------- +- cdist-type(7) +- grep(1) + + +COPYING +------- +Copyright \(C) 2012-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/cdist/conf/type/__line/parameter/default/state b/cdist/conf/type/__line/parameter/default/state deleted file mode 100644 index e7f6134f..00000000 --- a/cdist/conf/type/__line/parameter/default/state +++ /dev/null @@ -1 +0,0 @@ -present diff --git a/cdist/conf/type/__line/parameter/optional b/cdist/conf/type/__line/parameter/optional index 1c34c699..604a203e 100644 --- a/cdist/conf/type/__line/parameter/optional +++ b/cdist/conf/type/__line/parameter/optional @@ -1,7 +1,4 @@ -after -before +state +regex file line -regex -state -onchange diff --git a/cdist/conf/type/__link/explorer/state b/cdist/conf/type/__link/explorer/state index 7150df25..b8d8fc2b 100755 --- a/cdist/conf/type/__link/explorer/state +++ b/cdist/conf/type/__link/explorer/state @@ -32,9 +32,9 @@ destination_dir="${destination%/*}" case "$type" in symbolic) - cd "$destination_dir" || exit 1 + cd "$destination_dir" + source_is=$(ls -l "$destination" | sed 's/.*-> //g') if [ -h "$destination" ]; then - source_is=$(readlink "$destination") # ignore trailing slashes for comparison if [ "${source_is%/}" = "${source%/}" ]; then echo present @@ -46,19 +46,13 @@ case "$type" in fi ;; hard) - cd "$destination_dir" || exit 1 + cd "$destination_dir" # check source relative to destination_dir if [ ! -e "$source" ]; then echo sourcemissing exit 0 fi - # Currently not worth the effor to change it, stat is not defined by POSIX - # and different OSes has different implementations for it. - # shellcheck disable=SC2012 destination_inode=$(ls -i "$destination" | awk '{print $1}') - # Currently not worth the effor to change it, stat is not defined by POSIX - # and different OSes has different implementations for it. - # shellcheck disable=SC2012 source_inode=$(ls -i "$source" | awk '{print $1}') if [ "$destination_inode" -eq "$source_inode" ]; then echo present diff --git a/cdist/conf/type/__link/explorer/type b/cdist/conf/type/__link/explorer/type index b322bf42..579fd081 100755 --- a/cdist/conf/type/__link/explorer/type +++ b/cdist/conf/type/__link/explorer/type @@ -24,26 +24,23 @@ destination="/$__object_id" if [ ! -e "$destination" ]; then - echo none + echo none elif [ -h "$destination" ]; then - echo symlink + echo symlink elif [ -f "$destination" ]; then - type="$(cat "$__object/parameter/type")" - case "$type" in - hard) - # Currently not worth the effor to change it, stat is not defined by POSIX - # and different OSes has different implementations for it. - # shellcheck disable=SC2012 - link_count=$(ls -l "$destination" | awk '{ print $2 }') - if [ "$link_count" -gt 1 ]; then - echo hardlink - exit 0 - fi - ;; - esac - echo file + type="$(cat "$__object/parameter/type")" + case "$type" in + hard) + link_count=$(ls -l "$destination" | awk '{ print $2 }') + if [ $link_count -gt 1 ]; then + echo hardlink + exit 0 + fi + ;; + esac + echo file elif [ -d "$destination" ]; then - echo directory + echo directory else - echo unknown + echo unknown fi diff --git a/cdist/conf/type/__link/gencode-remote b/cdist/conf/type/__link/gencode-remote index 45c22fcc..9e7831c7 100755 --- a/cdist/conf/type/__link/gencode-remote +++ b/cdist/conf/type/__link/gencode-remote @@ -1,4 +1,4 @@ -#!/bin/sh -e +#!/bin/sh # # 2011-2012 Nico Schottelius (nico-cdist at schottelius.org) # 2013-2014 Steven Armstrong (steven-cdist at armstrong.cc) @@ -48,25 +48,21 @@ case "$state_should" in if [ "$file_type" = "directory" ]; then # our destination is currently a directory, delete it printf 'rm -rf "%s" &&\n' "$destination" - echo "removed '$destination' (directory)" >> "$__messages_out" else if [ "$state_is" = "wrongsource" ]; then # our destination is a symlink but points to the wrong source, # delete it printf 'rm -f "%s" &&\n' "$destination" - echo "removed '$destination' (wrongsource)" >> "$__messages_out" fi fi # create our link printf 'ln %s -f "%s" "%s"\n' "$lnopt" "$source" "$destination" - echo "created '$destination'" >> "$__messages_out" ;; absent) # only delete if it is a sym/hard link - if [ "$file_type" = "symlink" ] || [ "$file_type" = "hardlink" ]; then + if [ "$file_type" = "symlink" -o "$file_type" = "hardlink" ]; then printf 'rm -f "%s"\n' "$destination" - echo "removed '$destination'" >> "$__messages_out" fi ;; *) diff --git a/cdist/conf/type/__link/man.rst b/cdist/conf/type/__link/man.rst deleted file mode 100644 index fe0ce425..00000000 --- a/cdist/conf/type/__link/man.rst +++ /dev/null @@ -1,76 +0,0 @@ -cdist-type__link(7) -=================== - -NAME ----- -cdist-type__link - Manage links (hard and symbolic) - - -DESCRIPTION ------------ -This cdist type allows you to manage hard and symbolic links. -The given object id is the destination for the link. - - -REQUIRED PARAMETERS -------------------- -source - Specifies the link source. - -type - Specifies the link type: Either hard or symoblic. - - -OPTIONAL PARAMETERS -------------------- -state - 'present' or 'absent', defaults to 'present' - - -MESSAGES --------- - -created - Link to destination was created. - -removed - Link to destination was removed. - -removed (directory) - Destination was removed because state is ``present`` and destination was directory. - -removed (wrongsource) - Destination was removed because state is ``present`` and destination link source was wrong. - - -EXAMPLES --------- - -.. code-block:: sh - - # Create hard link of /etc/shadow - __link /root/shadow --source /etc/shadow --type hard - - # Relative symbolic link - __link /etc/apache2/sites-enabled/www.test.ch \ - --source ../sites-available/www.test.ch \ - --type symbolic - - # Absolute symbolic link - __link /opt/plone --source /home/services/plone --type symbolic - - # Remove link - __link /opt/plone --state absent - - -AUTHORS -------- -Nico Schottelius - - -COPYING -------- -Copyright \(C) 2011-2012 Nico Schottelius. 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. diff --git a/cdist/conf/type/__link/man.text b/cdist/conf/type/__link/man.text new file mode 100644 index 00000000..663087db --- /dev/null +++ b/cdist/conf/type/__link/man.text @@ -0,0 +1,60 @@ +cdist-type__link(7) +=================== +Nico Schottelius + + +NAME +---- +cdist-type__link - Manage links (hard and symbolic) + + +DESCRIPTION +----------- +This cdist type allows you to manage hard and symbolic links. +The given object id is the destination for the link. + + +REQUIRED PARAMETERS +------------------- +source:: + Specifies the link source. + +type:: + Specifies the link type: Either hard or symoblic. + + +OPTIONAL PARAMETERS +------------------- +state:: + 'present' or 'absent', defaults to 'present' + + +EXAMPLES +-------- + +-------------------------------------------------------------------------------- +# Create hard link of /etc/shadow +__link /root/shadow --source /etc/shadow --type hard + +# Relative symbolic link +__link /etc/apache2/sites-enabled/www.test.ch \ + --source ../sites-available/www.test.ch \ + --type symbolic + +# Absolute symbolic link +__link /opt/plone --source /home/services/plone --type symbolic + +# Remove link +__link /opt/plone --state absent +-------------------------------------------------------------------------------- + + +SEE ALSO +-------- +- cdist-type(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/cdist/conf/type/__locale/gencode-remote b/cdist/conf/type/__locale/gencode-remote old mode 100755 new mode 100644 index 1feb9884..538ce2cd --- a/cdist/conf/type/__locale/gencode-remote +++ b/cdist/conf/type/__locale/gencode-remote @@ -1,6 +1,6 @@ -#!/bin/sh -e +#!/bin/sh # -# 2013-2019 Nico Schottelius (nico-cdist at schottelius.org) +# 2013 Nico Schottelius (nico-cdist at schottelius.org) # # This file is part of cdist. # @@ -37,15 +37,6 @@ locale_remove=$(echo "$locale" | sed 's/UTF-8/utf8/') state=$(cat "$__object/parameter/state") -os=$(cat "$__global/explorer/os") - -# Nothing to be done on alpine -case "$os" in - alpine) - exit 0 - ;; -esac - case "$state" in present) echo localedef -A "$alias" -f "$charmap" -i "$input" "$locale" diff --git a/cdist/conf/type/__locale/man.rst b/cdist/conf/type/__locale/man.rst deleted file mode 100644 index e36ab061..00000000 --- a/cdist/conf/type/__locale/man.rst +++ /dev/null @@ -1,50 +0,0 @@ -cdist-type__locale(7) -===================== - -NAME ----- -cdist-type__locale - Configure locales - - -DESCRIPTION ------------ -This cdist type allows you to setup locales. On systems that don't -support locale setting like alpine/musl libc, it is a no-op. - - -OPTIONAL PARAMETERS -------------------- -state - 'present' or 'absent', defaults to present - - -EXAMPLES --------- - -.. code-block:: sh - - # Add locale de_CH.UTF-8 - __locale de_CH.UTF-8 - - # Same as above, but more explicit - __locale de_CH.UTF-8 --state present - - # Remove colourful British English - __locale en_GB.UTF-8 --state absent - - -SEE ALSO --------- -:strong:`locale`\ (1), :strong:`localedef`\ (1), :strong:`cdist-type__locale_system`\ (7) - - -AUTHORS -------- -Nico Schottelius - - -COPYING -------- -Copyright \(C) 2013-2019 Nico Schottelius. Free use of this software is -granted under the terms of the GNU General Public License version 3 or -later (GPLv3+). diff --git a/cdist/conf/type/__locale/man.text b/cdist/conf/type/__locale/man.text new file mode 100644 index 00000000..5ccd3eab --- /dev/null +++ b/cdist/conf/type/__locale/man.text @@ -0,0 +1,47 @@ +cdist-type__locale(7) +===================== +Nico Schottelius + + +NAME +---- +cdist-type__locale - Configure locales + + +DESCRIPTION +----------- +This cdist type allows you to setup locales. + + +OPTIONAL PARAMETERS +------------------- +state:: + 'present' or 'absent', defaults to present + + +EXAMPLES +-------- + +-------------------------------------------------------------------------------- +# Add locale de_CH.UTF-8 +__locale de_CH.UTF-8 + +# Same as above, but more explicit +__locale de_CH.UTF-8 --state present + +# Remove colourful British English +__locale en_GB.UTF-8 --state absent +-------------------------------------------------------------------------------- + + +SEE ALSO +-------- +- locale(1) +- localedef(1) +- cdist-type(7) + + +COPYING +------- +Copyright \(C) 2013-2014 Nico Schottelius. Free use of this software is +granted under the terms of the GNU General Public License version 3 (GPLv3). diff --git a/cdist/conf/type/__locale/manifest b/cdist/conf/type/__locale/manifest old mode 100755 new mode 100644 index 9f1e17ac..f3d75d59 --- a/cdist/conf/type/__locale/manifest +++ b/cdist/conf/type/__locale/manifest @@ -1,7 +1,6 @@ -#!/bin/sh -e +#!/bin/sh # -# 2013-2019 Nico Schottelius (nico-cdist at schottelius.org) -# 2015 David Hürlimann (david at ungleich.ch) +# 2013-2014 Nico Schottelius (nico-cdist at schottelius.org) # # This file is part of cdist. # @@ -19,20 +18,17 @@ # along with cdist. If not, see . # # -# Install required packages +# Install required packages # os=$(cat "$__global/explorer/os") case "$os" in - debian|devuan) + debian) # Debian needs a seperate package __package locales --state present ;; - archlinux|suse|ubuntu|scientific|centos|alpine) - : - ;; *) echo "Sorry, do not know how to handle os: $os" >&2 echo "Please edit the type ${__type##*/} to fix this." >&2 diff --git a/cdist/conf/type/__locale_system/man.rst b/cdist/conf/type/__locale_system/man.rst deleted file mode 100644 index 03d36960..00000000 --- a/cdist/conf/type/__locale_system/man.rst +++ /dev/null @@ -1,64 +0,0 @@ -cdist-type__locale_system(7) -============================ - -NAME ----- -cdist-type__locale_system - Set system-wide locale - - -DESCRIPTION ------------ -This cdist type allows you to modify system-wide locale. -The name of the locale category is given as the object id -(usually you are probably interested in using LANG). - - -OPTIONAL PARAMETERS -------------------- - -state - present or absent, defaults to present. - If present, sets the locale category to the given value. - If absent, removes the locale category from the system file. - -value - The value for the locale category. - Defaults to en_US.UTF-8. - - -EXAMPLES --------- - -.. code-block:: sh - - # Set LANG to en_US.UTF-8 - __locale_system LANG - - # Same as above, but more explicit - __locale_system LANG --value en_US.UTF-8 - - # Set category LC_MESSAGES to de_CH.UTF-8 - __locale_system LC_MESSAGES --value de_CH.UTF-8 - - # Remove setting for LC_ALL - __locale_system LC_ALL --state absent - - - -SEE ALSO --------- -:strong:`locale`\ (1), :strong:`localedef`\ (1), :strong:`cdist-type__locale`\ (7) - - -AUTHORS -------- -| Steven Armstrong -| Carlos Ortigoza -| Nico Schottelius - - -COPYING -------- -Copyright \(C) 2016 Nico Schottelius. Free use of this software is -granted under the terms of the GNU General Public License version 3 or -later (GPLv3+). diff --git a/cdist/conf/type/__locale_system/manifest b/cdist/conf/type/__locale_system/manifest deleted file mode 100755 index 80f7401b..00000000 --- a/cdist/conf/type/__locale_system/manifest +++ /dev/null @@ -1,55 +0,0 @@ -#!/bin/sh -e -# -# 2012-2016 Steven Armstrong (steven-cdist at armstrong.cc) -# 2016 Carlos Ortigoza (carlos.ortigoza at ungleich.ch) -# 2016 Nico Schottelius (nico.schottelius at ungleich.ch) -# -# 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 . -# -# -# Configure system-wide locale by modifying i18n file. -# - -os=$(cat "$__global/explorer/os") - -case "$os" in - debian|ubuntu) - locale_conf="/etc/default/locale" - ;; - archlinux) - locale_conf="/etc/locale.conf" - ;; - redhat|centos) - locale_conf="/etc/sysconfig/i18n" - ;; - *) - echo "Your operating system ($os) is currently not supported by this type (${__type##*/})." >&2 - echo "Please contribute an implementation for it if you can." >&2 - exit 1 - ;; -esac - -__file "$locale_conf" \ - --owner root --group root --mode 644 \ - --state exists - -require="__file/$locale_conf" \ - __key_value "$locale_conf:$__object_id" \ - --file "$locale_conf" \ - --key "$__object_id" \ - --delimiter = \ - --state "$(cat "$__object/parameter/state")" \ - --value "$(cat "$__object/parameter/value")" diff --git a/cdist/conf/type/__locale_system/parameter/default/state b/cdist/conf/type/__locale_system/parameter/default/state deleted file mode 100644 index e7f6134f..00000000 --- a/cdist/conf/type/__locale_system/parameter/default/state +++ /dev/null @@ -1 +0,0 @@ -present diff --git a/cdist/conf/type/__locale_system/parameter/default/value b/cdist/conf/type/__locale_system/parameter/default/value deleted file mode 100644 index 927508f3..00000000 --- a/cdist/conf/type/__locale_system/parameter/default/value +++ /dev/null @@ -1 +0,0 @@ -en_US.UTF-8 diff --git a/cdist/conf/type/__locale_system/parameter/optional b/cdist/conf/type/__locale_system/parameter/optional deleted file mode 100644 index d0460d86..00000000 --- a/cdist/conf/type/__locale_system/parameter/optional +++ /dev/null @@ -1,2 +0,0 @@ -state -value diff --git a/cdist/conf/type/__motd/gencode-remote b/cdist/conf/type/__motd/gencode-remote index bc842cc8..2aa84902 100755 --- a/cdist/conf/type/__motd/gencode-remote +++ b/cdist/conf/type/__motd/gencode-remote @@ -1,5 +1,3 @@ -#!/bin/sh -e -# # 2013 Nico Schottelius (nico-cdist at schottelius.org) # # This file is part of cdist. @@ -22,8 +20,8 @@ os=$(cat "$__global/explorer/os") case "$os" in - debian|ubuntu|devuan) - + debian|ubuntu) + # Debian and Ubuntu need to be updated, # as seen in /etc/init.d/bootlogs echo "uname -snrvm > /var/run/motd" diff --git a/cdist/conf/type/__motd/man.rst b/cdist/conf/type/__motd/man.text similarity index 52% rename from cdist/conf/type/__motd/man.rst rename to cdist/conf/type/__motd/man.text index 17369684..a4ca80b5 100644 --- a/cdist/conf/type/__motd/man.rst +++ b/cdist/conf/type/__motd/man.text @@ -1,5 +1,7 @@ cdist-type__motd(7) =================== +Nico Schottelius + NAME ---- @@ -18,7 +20,7 @@ None. OPTIONAL PARAMETERS ------------------- -source +source:: If supplied, copy this file from the host running cdist to the target. If not supplied, a default message will be placed onto the target. @@ -26,23 +28,21 @@ source EXAMPLES -------- -.. code-block:: sh +-------------------------------------------------------------------------------- +# Use cdist defaults +__motd - # Use cdist defaults - __motd - - # Supply source file from a different type - __motd --source "$__type/files/my-motd" +# Supply source file from a different type +__motd --source "$__type/files/my-motd" +-------------------------------------------------------------------------------- -AUTHORS -------- -Nico Schottelius +SEE ALSO +-------- +- cdist-type(7) COPYING ------- -Copyright \(C) 2011 Nico Schottelius. 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. +Copyright \(C) 2011 Nico Schottelius. Free use of this software is +granted under the terms of the GNU General Public License version 3 (GPLv3). diff --git a/cdist/conf/type/__motd/manifest b/cdist/conf/type/__motd/manifest index cd741cf4..286d1ff3 100755 --- a/cdist/conf/type/__motd/manifest +++ b/cdist/conf/type/__motd/manifest @@ -1,4 +1,4 @@ -#!/bin/sh -e +#!/bin/sh # # 2011 Nico Schottelius (nico-cdist at schottelius.org) # @@ -22,9 +22,6 @@ # Select motd source if [ -f "$__object/parameter/source" ]; then source="$(cat "$__object/parameter/source")" - if [ "$source" = "-" ]; then - source="${__object}/stdin" - fi else source="$__type/files/motd" fi @@ -33,7 +30,7 @@ os=$(cat "$__global/explorer/os") case "$os" in - debian|ubuntu|devuan) + debian|ubuntu) destination=/etc/motd.tail ;; *) diff --git a/cdist/conf/type/__mount/gencode-remote b/cdist/conf/type/__mount/gencode-remote index b2096764..2626f3de 100755 --- a/cdist/conf/type/__mount/gencode-remote +++ b/cdist/conf/type/__mount/gencode-remote @@ -1,4 +1,4 @@ -#!/bin/sh -e +#!/bin/sh # # 2014 Steven Armstrong (steven-cdist at armstrong.cc) # @@ -39,7 +39,7 @@ case "$state_should" in printf ' -o %s' "$(cat "$__object/parameter/options")" fi printf ' %s' "$(cat "$__object/parameter/device")" - printf ' %s\n' "$path" + printf " %s\n" "$path" else # mount using existing fstab entry printf 'mount "%s"\n' "$path" diff --git a/cdist/conf/type/__mount/man.rst b/cdist/conf/type/__mount/man.text similarity index 57% rename from cdist/conf/type/__mount/man.rst rename to cdist/conf/type/__mount/man.text index d719a1cd..7299bdf3 100644 --- a/cdist/conf/type/__mount/man.rst +++ b/cdist/conf/type/__mount/man.text @@ -1,9 +1,11 @@ cdist-type__mount(7) ==================== +Steven Armstrong + NAME ---- -cdit-type__mount - Manage filesystem mounts +cdist-type__mount - manage filesystem mounts DESCRIPTION @@ -18,67 +20,65 @@ None. OPTIONAL PARAMETERS ------------------- -device +device:: device to mount at path, defaults to 'none'. see mount(8) -dump +dump:: value for the dump field in fstab. see fstab(5) defaults to 0. This parameter is ignored, if the nofstab parameter is given. -options +options:: comma separated string of options, see mount(8) -pass +pass:: value for the pass field in fstab. see fstab(5) defaults to 0. This parameter is ignored, if the nofstab parameter is given. -path +path:: mount point where to mount the device, see mount(8). Defaults to __object_id -state +state:: either present or absent. Defaults to present. -type +type:: vfstype, see mount(8) BOOLEAN PARAMETERS ------------------ -nofstab +nofstab:: do not manage an entry in /etc/fstab EXAMPLES -------- -.. code-block:: sh +-------------------------------------------------------------------------------- +__mount /some/dir \ + --device /dev/sdc3 \ + --type xfs \ + --options "defaults,ro" + --dump 0 \ + --pass 1 - __mount /some/dir \ - --device /dev/sdc3 \ - --type xfs \ - --options "defaults,ro" - --dump 0 \ - --pass 1 - - __mount /var/lib/one \ - --device mfsmount \ - --type fuse \ - --options "mfsmaster=mfsmaster.domain.tld,mfssubfolder=/one,nonempty,_netdev" +__mount /var/lib/one \ + --device mfsmount \ + --type fuse \ + --options "mfsmaster=mfsmaster.domain.tld,mfssubfolder=/one,nonempty,_netdev" +-------------------------------------------------------------------------------- -AUTHORS -------- -Steven Armstrong +SEE ALSO +-------- +- cdist-type(7) COPYING ------- -Copyright \(C) 2014 Steven Armstrong. 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. +Copyright \(C) 2014 Steven Armstrong. Free use of this software is +granted under the terms of the GNU General Public License version 3 (GPLv3). diff --git a/cdist/conf/type/__mount/manifest b/cdist/conf/type/__mount/manifest index 999d806c..8a1fa234 100755 --- a/cdist/conf/type/__mount/manifest +++ b/cdist/conf/type/__mount/manifest @@ -1,4 +1,4 @@ -#!/bin/sh -e +#!/bin/sh # # 2014 Steven Armstrong (steven-cdist at armstrong.cc) # @@ -26,12 +26,12 @@ if [ ! -f "$__object/parameter/nofstab" ]; then ( printf "%s" "$(cat "$__object/parameter/device")" printf " %s" "$path" -type="$(cat "$__object/parameter/type")" +type="$(cat "$__object/parameter/type" 2>/dev/null || echo "auto")" printf " %s" "$type" -options="$(cat "$__object/parameter/options")" +options="$(cat "$__object/parameter/options" 2>/dev/null || echo "defaults")" printf " %s" "$options" printf " %s" "$(cat "$__object/parameter/dump")" -printf ' %s\n' "$(cat "$__object/parameter/pass")" +printf " %s\n" "$(cat "$__object/parameter/pass")" ) | \ __block "$__object_name" \ --file "/etc/fstab" \ diff --git a/cdist/conf/type/__mount/parameter/default/options b/cdist/conf/type/__mount/parameter/default/options deleted file mode 100644 index e94f8140..00000000 --- a/cdist/conf/type/__mount/parameter/default/options +++ /dev/null @@ -1 +0,0 @@ -defaults diff --git a/cdist/conf/type/__mount/parameter/default/type b/cdist/conf/type/__mount/parameter/default/type deleted file mode 100644 index 865faf10..00000000 --- a/cdist/conf/type/__mount/parameter/default/type +++ /dev/null @@ -1 +0,0 @@ -auto diff --git a/cdist/conf/type/__mysql_database/gencode-remote b/cdist/conf/type/__mysql_database/gencode-remote index 23e51b05..7cd32242 100755 --- a/cdist/conf/type/__mysql_database/gencode-remote +++ b/cdist/conf/type/__mysql_database/gencode-remote @@ -1,4 +1,4 @@ -#!/bin/sh -e +#!/bin/sh # # 2012 Benedikt Koeppel (code@benediktkoeppel.ch) # @@ -45,6 +45,7 @@ if [ -f "$__object/parameter/user" ]; then EOF EOFF else + password="" cat <<-EOFF mysql -u root <<-EOF GRANT ALL PRIVILEGES ON $database.* to '$user'@'localhost'; diff --git a/cdist/conf/type/__mysql_database/man.rst b/cdist/conf/type/__mysql_database/man.text similarity index 55% rename from cdist/conf/type/__mysql_database/man.rst rename to cdist/conf/type/__mysql_database/man.text index 1e245a08..f184a30e 100644 --- a/cdist/conf/type/__mysql_database/man.rst +++ b/cdist/conf/type/__mysql_database/man.text @@ -1,5 +1,7 @@ cdist-type__mysql_database(7) ============================= +Benedikt Koeppel + NAME ---- @@ -17,33 +19,31 @@ None. OPTIONAL PARAMETERS ------------------- -name +name:: The name of the database to install defaults to the object id -user +user:: A user that should have access to the database -password +password:: The password for the user who manages the database EXAMPLES -------- -.. code-block:: sh - - __mysql_database "cdist" --name "cdist" --user "myuser" --password "mypwd" +-------------------------------------------------------------------------------- +__mysql_database "cdist" --name "cdist" --user "myuser" --password "mypwd" +-------------------------------------------------------------------------------- -AUTHORS -------- -Benedikt Koeppel +SEE ALSO +-------- +- cdist-type(7) COPYING ------- -Copyright \(C) 2012 Benedikt Koeppel. 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. +Copyright \(C) 2012 Benedikt Koeppel. 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/__package/man.rst b/cdist/conf/type/__package/man.rst deleted file mode 100644 index fc36402b..00000000 --- a/cdist/conf/type/__package/man.rst +++ /dev/null @@ -1,64 +0,0 @@ -cdist-type__package(7) -====================== - -NAME ----- -cdist-type__package - Manage packages - - -DESCRIPTION ------------ -This cdist type allows you to install or uninstall packages on the target. -It dispatches the actual work to the package system dependent types. - - -REQUIRED PARAMETERS -------------------- -None - - -OPTIONAL PARAMETERS -------------------- -name - The name of the package to install. Default is to use the object_id as the - package name. -version - The version of the package to install. Default is to install the version - chosen by the local package manager. -type - The package type to use. Default is determined based on the $os explorer - variable. - e.g. - * __package_apt for Debian - * __package_emerge for Gentoo - -state - Either "present" or "absent", defaults to "present" - - -EXAMPLES --------- - -.. code-block:: sh - - # Install the package vim on the target - __package vim --state present - - # Same but install specific version - __package vim --state present --version 7.3.50 - - # Force use of a specific package type - __package vim --state present --type __package_apt - - -AUTHORS -------- -Steven Armstrong - - -COPYING -------- -Copyright \(C) 2011 Steven Armstrong. 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. diff --git a/cdist/conf/type/__package/man.text b/cdist/conf/type/__package/man.text new file mode 100644 index 00000000..b656c890 --- /dev/null +++ b/cdist/conf/type/__package/man.text @@ -0,0 +1,63 @@ +cdist-type__package(7) +====================== +Steven Armstrong + + +NAME +---- +cdist-type__package - Manage packages + + +DESCRIPTION +----------- +This cdist type allows you to install or uninstall packages on the target. +It dispatches the actual work to the package system dependant types. + + +REQUIRED PARAMETERS +------------------- +None + + +OPTIONAL PARAMETERS +------------------- +name:: + The name of the package to install. Default is to use the object_id as the + package name. +version:: + The version of the package to install. Default is to install the version + choosen by the local package manager. +type:: + The package type to use. Default is determined based on the $os explorer + variable. + e.g. __package_apt for Debian + __package_emerge for Gentoo + +state:: + Either "present" or "absent", defaults to "present" + + +EXAMPLES +-------- + +-------------------------------------------------------------------------------- +# Install the package vim on the target +__package vim --state present + +# Same but install specific version +__package vim --state present --version 7.3.50 + +# Force use of a specific package type +__package vim --state present --type __package_apt +-------------------------------------------------------------------------------- + + +SEE ALSO +-------- +- cdist-type(7) + + +COPYING +------- +Copyright \(C) 2011 Steven Armstrong. Free use of this software is +granted under the terms of the GNU General Public License version 3 (GPLv3). diff --git a/cdist/conf/type/__package/manifest b/cdist/conf/type/__package/manifest index a453c32b..0ebf0099 100755 --- a/cdist/conf/type/__package/manifest +++ b/cdist/conf/type/__package/manifest @@ -1,7 +1,6 @@ -#!/bin/sh -e +#!/bin/sh # # 2011-2013 Steven Armstrong (steven-cdist at armstrong.cc) -# 2019 Nico Schottelius (nico-cdist at schottelius.org) # # This file is part of cdist. # @@ -20,7 +19,7 @@ # # # __package is an abstract type which dispatches to the lower level -# __package_$type types which do the actual interaction with the packaging +# __package_$name types which do the actual interaction with the packaging # system. # @@ -31,21 +30,13 @@ else # By default determine package manager based on operating system os="$(cat "$__global/explorer/os")" case "$os" in - amazon|scientific|centos|fedora|redhat) type="yum" ;; + amazon|centos|fedora|redhat) type="yum" ;; archlinux) type="pacman" ;; - debian|ubuntu|devuan) type="apt" ;; - freebsd) - if [ -n "$(cat "$__object/explorer/pkgng_exists")" ]; then - type="pkgng_freebsd" - else - type="pkg_freebsd" - fi - ;; + debian|ubuntu) type="apt" ;; + freebsd) type="pkg_freebsd" ;; gentoo) type="emerge" ;; suse) type="zypper" ;; openwrt) type="opkg" ;; - openbsd) type="pkg_openbsd" ;; - alpine) type="apk" ;; *) echo "Don't know how to manage packages on: $os" >&2 exit 1 @@ -57,8 +48,8 @@ state="$(cat "$__object/parameter/state")" set -- "$@" "$__object_id" "--state" "$state" cd "$__object/parameter" -for property in *; do - if [ "$property" != "type" ] && [ "$property" != "state" ]; then +for property in $(ls .); do + if [ "$property" != "type" -a "$property" != "state" ]; then set -- "$@" "--$property" "$(cat "$property")" fi done diff --git a/cdist/conf/type/__package/nonparallel b/cdist/conf/type/__package/nonparallel deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/conf/type/__package/parameter/boolean b/cdist/conf/type/__package/parameter/boolean deleted file mode 100644 index effcb218..00000000 --- a/cdist/conf/type/__package/parameter/boolean +++ /dev/null @@ -1 +0,0 @@ -upgrade diff --git a/cdist/conf/type/__package/parameter/optional b/cdist/conf/type/__package/parameter/optional index bb3f5154..d674f32e 100644 --- a/cdist/conf/type/__package/parameter/optional +++ b/cdist/conf/type/__package/parameter/optional @@ -4,4 +4,3 @@ type pkgsite state ptype -repo diff --git a/cdist/conf/type/__package_apk/explorer/state b/cdist/conf/type/__package_apk/explorer/state deleted file mode 100755 index b477ca7c..00000000 --- a/cdist/conf/type/__package_apk/explorer/state +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/sh -# -# 2019 Nico Schottelius (nico-cdist at schottelius.org) -# -# This file is part of cdist. -# -# cdist is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# cdist is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with cdist. If not, see . -# -# -# Retrieve the status of a package - parsed apk output -# - -if [ -f "$__object/parameter/name" ]; then - name="$(cat "$__object/parameter/name")" -else - name="$__object_id" -fi - -# Remove the @.. repo tag for finding out whether it is installed -# f.i. pass@testing => pass -name="$(echo "$name" | sed 's/@.*//')" - -if [ "$(apk list -I "$name")" ]; then - echo present -else - echo absent -fi diff --git a/cdist/conf/type/__package_apk/gencode-remote b/cdist/conf/type/__package_apk/gencode-remote deleted file mode 100755 index 79e3d2b6..00000000 --- a/cdist/conf/type/__package_apk/gencode-remote +++ /dev/null @@ -1,49 +0,0 @@ -#!/bin/sh -e -# -# 2019 Nico Schottelius (nico-cdist at schottelius.org) -# -# This file is part of cdist. -# -# cdist is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# cdist is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with cdist. If not, see . -# -# -# Manage packages on Debian and co. -# - -if [ -f "$__object/parameter/name" ]; then - name="$(cat "$__object/parameter/name")" -else - name="$__object_id" -fi - -state_should="$(cat "$__object/parameter/state")" -state_is="$(cat "$__object/explorer/state")" - -# Nothing to be done -[ "$state_is" = "$state_should" ] && exit 0 - -case "$state_should" in - present) - echo "apk add -q '$name'" - echo "installed" >> "$__messages_out" - ;; - absent) - echo "apk del -q '$name'" - echo "removed" >> "$__messages_out" - ;; - *) - echo "Unknown state: $state_should" >&2 - exit 1 - ;; -esac diff --git a/cdist/conf/type/__package_apk/man.rst b/cdist/conf/type/__package_apk/man.rst deleted file mode 100644 index bc2408b4..00000000 --- a/cdist/conf/type/__package_apk/man.rst +++ /dev/null @@ -1,55 +0,0 @@ -cdist-type__package_akp(7) -========================== - -NAME ----- -cdist-type__package_akp - Manage packages with akp - - -DESCRIPTION ------------ -apk is usually used on Alpine to manage packages. - - -REQUIRED PARAMETERS -------------------- -None - - -OPTIONAL PARAMETERS -------------------- -name - If supplied, use the name and not the object id as the package name. - -state - Either "present" or "absent", defaults to "present" - - -EXAMPLES --------- - -.. code-block:: sh - - # Ensure zsh in installed - __package_apk zsh --state present - - # Remove package - __package_apk apache2 --state absent - - -SEE ALSO --------- -:strong:`cdist-type__package`\ (7) - - -AUTHORS -------- -Nico Schottelius - - -COPYING -------- -Copyright \(C) 2019 Nico Schottelius. 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. diff --git a/cdist/conf/type/__package_apk/nonparallel b/cdist/conf/type/__package_apk/nonparallel deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/conf/type/__package_apk/parameter/default/state b/cdist/conf/type/__package_apk/parameter/default/state deleted file mode 100644 index e7f6134f..00000000 --- a/cdist/conf/type/__package_apk/parameter/default/state +++ /dev/null @@ -1 +0,0 @@ -present diff --git a/cdist/conf/type/__package_apk/parameter/optional b/cdist/conf/type/__package_apk/parameter/optional deleted file mode 100644 index 1b423dc4..00000000 --- a/cdist/conf/type/__package_apk/parameter/optional +++ /dev/null @@ -1,2 +0,0 @@ -name -state diff --git a/cdist/conf/type/__package_apt/explorer/state b/cdist/conf/type/__package_apt/explorer/state index 7ccd6fce..04926b60 100755 --- a/cdist/conf/type/__package_apt/explorer/state +++ b/cdist/conf/type/__package_apt/explorer/state @@ -30,9 +30,8 @@ fi # Except dpkg failing, if package is not known / installed packages="$(apt-cache showpkg "$name" | sed -e "1,/Reverse Provides:/d" | cut -d ' ' -f 1) $name" for p in $packages; do - if dpkg -s "$p" 2>/dev/null | grep --quiet "^Status: install ok installed$" ; then - version=$(dpkg -s "$p" 2>/dev/null | grep "^Version:" | cut -d ' ' -f 2) - echo "present $p $version" + if [ -n "$(dpkg -s "$p" 2>/dev/null | grep "^Status: install ok installed$")" ]; then + echo "present $p" exit 0 fi done diff --git a/cdist/conf/type/__package_apt/gencode-remote b/cdist/conf/type/__package_apt/gencode-remote index 699eb0c9..57339db3 100755 --- a/cdist/conf/type/__package_apt/gencode-remote +++ b/cdist/conf/type/__package_apt/gencode-remote @@ -1,4 +1,4 @@ -#!/bin/sh -e +#!/bin/sh # # 2011-2013 Nico Schottelius (nico-cdist at schottelius.org) # @@ -27,62 +27,33 @@ else name="$__object_id" fi -state_should="$(cat "$__object/parameter/state")" - -version_param="$__object/parameter/version" - -version="" -if [ -f "$version_param" ]; then - version="$(cat "$version_param")" -fi - -if [ -f "$__object/parameter/target-release" ]; then - target_release="--target-release $(cat "$__object/parameter/target-release")" +if [ -f "$__object/parameter/state" ]; then + state_should="$(cat "$__object/parameter/state")" else - target_release="" + state_should="present" fi -if [ -f "$__object/parameter/purge-if-absent" ]; then - purgeparam="--purge" -else - purgeparam="" -fi - - # FIXME: use grep directly, state is a list, not a line! state_is="$(cat "$__object/explorer/state")" case "$state_is" in present*) name="$(echo "$state_is" | cut -d ' ' -f 2)" - version_is="$(echo "$state_is" | cut -d ' ' -f 3)" state_is="present" ;; - *) - version_is="" - ;; esac # Hint if we need to avoid questions at some point: # DEBIAN_PRIORITY=critical can reduce the number of questions -aptget="DEBIAN_FRONTEND=noninteractive apt-get --quiet --yes --no-install-recommends -o Dpkg::Options::=\"--force-confdef\" -o Dpkg::Options::=\"--force-confold\"" +aptget="DEBIAN_FRONTEND=noninteractive apt-get --quiet --yes --no-install-recommends -o DPkg::Options::=\"--force-confold\"" -if [ "$state_is" = "$state_should" ]; then - if [ -z "$version" ] || [ "$version" = "$version_is" ]; then - exit 0; - fi -fi +[ "$state_is" = "$state_should" ] && exit 0 case "$state_should" in present) - if [ -n "$version" ]; then - name="${name}=${version}" - fi - echo "$aptget install $target_release '$name'" - echo "installed" >> "$__messages_out" + echo $aptget install \"$name\" ;; absent) - echo "$aptget remove $purgeparam '$name'" - echo "removed" >> "$__messages_out" + echo $aptget remove \"$name\" ;; *) echo "Unknown state: $state_should" >&2 diff --git a/cdist/conf/type/__package_apt/man.rst b/cdist/conf/type/__package_apt/man.rst deleted file mode 100644 index a3a70d91..00000000 --- a/cdist/conf/type/__package_apt/man.rst +++ /dev/null @@ -1,74 +0,0 @@ -cdist-type__package_apt(7) -========================== - -NAME ----- -cdist-type__package_apt - Manage packages with apt-get - - -DESCRIPTION ------------ -apt-get is usually used on Debian and variants (like Ubuntu) to -manage packages. - - -REQUIRED PARAMETERS -------------------- -None - - -OPTIONAL PARAMETERS -------------------- -name - If supplied, use the name and not the object id as the package name. - -state - Either "present" or "absent", defaults to "present" - -target-release - Passed on to apt-get install, see apt-get(8). - Essentially allows you to retrieve packages from a different release - -version - The version of the package to install. Default is to install the version - chosen by the local package manager. - - -BOOLEAN PARAMETERS ------------------- -purge-if-absent - If this parameter is given when state is `absent`, the package is - purged from the system (using `--purge`). - - -EXAMPLES --------- - -.. code-block:: sh - - # Ensure zsh in installed - __package_apt zsh --state present - - # In case you only want *a* webserver, but don't care which one - __package_apt webserver --state present --name nginx - - # Remove obsolete package - __package_apt puppet --state absent - - -SEE ALSO --------- -:strong:`cdist-type__package`\ (7) - - -AUTHORS -------- -Nico Schottelius - - -COPYING -------- -Copyright \(C) 2011-2012 Nico Schottelius. 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. diff --git a/cdist/conf/type/__package_apt/man.text b/cdist/conf/type/__package_apt/man.text new file mode 100644 index 00000000..5d4656c1 --- /dev/null +++ b/cdist/conf/type/__package_apt/man.text @@ -0,0 +1,55 @@ +cdist-type__package_apt(7) +========================== +Nico Schottelius + + +NAME +---- +cdist-type__package_apt - Manage packages with apt-get + + +DESCRIPTION +----------- +apt-get is usually used on Debian and variants (like Ubuntu) to +manage packages. + + +REQUIRED PARAMETERS +------------------- +None + + +OPTIONAL PARAMETERS +------------------- +name:: + If supplied, use the name and not the object id as the package name. + +state:: + Either "present" or "absent", defaults to "present" + + +EXAMPLES +-------- + +-------------------------------------------------------------------------------- +# Ensure zsh in installed +__package_apt zsh --state present + +# In case you only want *a* webserver, but don't care which one +__package_apt webserver --state present --name nginx + +# Remove obsolete package +__package_apt puppet --state absent +-------------------------------------------------------------------------------- + + +SEE ALSO +-------- +- cdist-type(7) +- cdist-type__package(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/cdist/conf/type/__package_apt/nonparallel b/cdist/conf/type/__package_apt/nonparallel deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/conf/type/__package_apt/parameter/boolean b/cdist/conf/type/__package_apt/parameter/boolean deleted file mode 100644 index f9a0f6b0..00000000 --- a/cdist/conf/type/__package_apt/parameter/boolean +++ /dev/null @@ -1 +0,0 @@ -purge-if-absent diff --git a/cdist/conf/type/__package_apt/parameter/default/state b/cdist/conf/type/__package_apt/parameter/default/state deleted file mode 100644 index e7f6134f..00000000 --- a/cdist/conf/type/__package_apt/parameter/default/state +++ /dev/null @@ -1 +0,0 @@ -present diff --git a/cdist/conf/type/__package_apt/parameter/optional b/cdist/conf/type/__package_apt/parameter/optional index d6674f95..41b8e6cf 100644 --- a/cdist/conf/type/__package_apt/parameter/optional +++ b/cdist/conf/type/__package_apt/parameter/optional @@ -1,4 +1,3 @@ name version state -target-release diff --git a/cdist/conf/type/__package_dpkg/explorer/pkg_state b/cdist/conf/type/__package_dpkg/explorer/pkg_state deleted file mode 100644 index d7487ed8..00000000 --- a/cdist/conf/type/__package_dpkg/explorer/pkg_state +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh -e - -package=$( basename "$__object_id" ) - -dpkg_status="$(dpkg-query --show --showformat='${db:Status-Abbrev} ${binary:Package}_${Version}_${Architecture}.deb\n' "${package%%_*}" 2>/dev/null || true)" - -if echo "$dpkg_status" | grep -q '^ii'; then - echo "${dpkg_status##* }" -fi - - diff --git a/cdist/conf/type/__package_dpkg/gencode-remote b/cdist/conf/type/__package_dpkg/gencode-remote deleted file mode 100755 index 1c271748..00000000 --- a/cdist/conf/type/__package_dpkg/gencode-remote +++ /dev/null @@ -1,51 +0,0 @@ -#!/bin/sh -e -# -# 2013 Tomas Pospisek (tpo_deb sourcepole.ch) -# 2018 Thomas Eckert (tom at it-eckert.de) -# -# This file is based on cdist's __file/gencode-local and 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 __package_dpkg type does not check whether a *.deb package is -# allready installed. It just copies the *.deb package over to the -# destination and installs it. We could use __package_apt to check -# whether a *.deb package is allready installed and only install it -# if we're given a --force argument or similar (would be clever not -# to conflict with dpkg's --force options). But currently we don't -# do any checks or --force'ing. -# -state=$( cat "$__object/parameter/state" ) -package=$( basename "$__object_id" ) -state_is="$(cat "$__object/explorer/pkg_state")" -state_should="" - -[ "$state" = "absent" ] || state_should="$package" -[ "$state_is" = "$state_should" ] && exit 0 - -case "$state" in - present) - echo "dpkg --install /var/cache/apt/archives/$__object_id" - echo "installed" >> "$__messages_out" - ;; - absent) - [ -f "$__object/parameter/purge-if-absent" ] \ - && action="--purge" \ - || action="--remove" - echo "dpkg $action ${__object_id%%_*}" - echo "removed ($action)" >> "$__messages_out" - ;; - *) echo "ERROR: unknown state '$state'" >&2 ;; -esac diff --git a/cdist/conf/type/__package_dpkg/man.rst b/cdist/conf/type/__package_dpkg/man.rst deleted file mode 100644 index 828d8cdd..00000000 --- a/cdist/conf/type/__package_dpkg/man.rst +++ /dev/null @@ -1,93 +0,0 @@ -cdist-type__package_dpkg(7) -=========================== - -NAME ----- -cdist-type__package_dpkg - Manage packages with dpkg - - -DESCRIPTION ------------ -This type is used on Debian and variants (like Ubuntu) to -install packages that are provided locally as \*.deb files. - -The object given to this type must be the name of the deb package. -The filename of the deb package has to follow Debian naming conventions, i.e. -`${binary:Package}_${Version}_${Architecture}.deb` (see `dpkg-query(1)` for -details). - - -OPTIONAL PARAMETERS -------------------- -state - `present` or `absent`, defaults to `present`. - -REQUIRED PARAMETERS -------------------- -source - path to the \*.deb package - - -BOOLEAN PARAMETERS ------------------- -purge-if-absent - If this parameter is given when state is `absent`, the package is - purged from the system (using `--purge`). - - -EXPLORER --------- -pkg_state - Returns the full package name if package is installed, empty otherwise. - - -MESSAGES --------- -installed - The deb-file was installed. - -removed (--remove) - The package was removed, keeping config. - -removed (--purge) - The package was removed including config (purged). - - -EXAMPLES --------- - -.. code-block:: sh - - # Install foo and bar packages - __package_dpkg foo_0.1_all.deb --source /tmp/foo_0.1_all.deb - __package_dpkg bar_1.4.deb --source $__type/files/bar_1.4.deb - - # uninstall baz: - __package_dpkg baz_1.4_amd64.deb \ - --source $__type/files/baz_1.4_amd64.deb \ - --state "absent" - # uninstall baz and also purge config-files: - __package_dpkg baz_1.4_amd64.deb \ - --source $__type/files/baz_1.4_amd64.deb \ - --purge-if-absent \ - --state "absent" - - -SEE ALSO --------- -:strong:`cdist-type__package`\ (7), :strong:`dpkg-query`\ (1) - - -AUTHORS -------- -| Tomas Pospisek -| Thomas Eckert - - -COPYING -------- -Copyright \(C) 2013 Tomas Pospisek. 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. -This type is based on __package_apt. diff --git a/cdist/conf/type/__package_dpkg/manifest b/cdist/conf/type/__package_dpkg/manifest deleted file mode 100755 index 6d228d8e..00000000 --- a/cdist/conf/type/__package_dpkg/manifest +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/sh -e -# -# 2013 Tomas Pospisek (tpo_deb sourcepole.ch) -# -# 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 __package_dpkg type does not check whether a *.deb package is -# allready installed. It just copies the *.deb package over to the -# destination and installs it. We could use __package_apt to check -# whether a *.deb package is allready installed and only install it -# if we're given a --force argument or similar (would be clever not -# to conflict with dpkg's --force options). But currently we don't -# do any checks or --force'ing. - - -state=$( cat "$__object/parameter/state" ) -package_path=$( cat "$__object/parameter/source" ) -package=$( basename "$__object_id" ) -state_is="$(cat "$__object/explorer/pkg_state")" -state_should="" - -[ "$state" = "absent" ] || state_should="$package" -[ "$state_is" = "$state_should" ] && exit 0 - -__file "/var/cache/apt/archives/$package" \ - --source "$package_path" \ - --state "$state" - diff --git a/cdist/conf/type/__package_dpkg/nonparallel b/cdist/conf/type/__package_dpkg/nonparallel deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/conf/type/__package_dpkg/parameter/boolean b/cdist/conf/type/__package_dpkg/parameter/boolean deleted file mode 100644 index f9a0f6b0..00000000 --- a/cdist/conf/type/__package_dpkg/parameter/boolean +++ /dev/null @@ -1 +0,0 @@ -purge-if-absent diff --git a/cdist/conf/type/__package_dpkg/parameter/default/state b/cdist/conf/type/__package_dpkg/parameter/default/state deleted file mode 100644 index e7f6134f..00000000 --- a/cdist/conf/type/__package_dpkg/parameter/default/state +++ /dev/null @@ -1 +0,0 @@ -present diff --git a/cdist/conf/type/__package_dpkg/parameter/optional b/cdist/conf/type/__package_dpkg/parameter/optional deleted file mode 100644 index ff72b5c7..00000000 --- a/cdist/conf/type/__package_dpkg/parameter/optional +++ /dev/null @@ -1 +0,0 @@ -state diff --git a/cdist/conf/type/__package_dpkg/parameter/required b/cdist/conf/type/__package_dpkg/parameter/required deleted file mode 100644 index 5a18cd2f..00000000 --- a/cdist/conf/type/__package_dpkg/parameter/required +++ /dev/null @@ -1 +0,0 @@ -source diff --git a/cdist/conf/type/__package_emerge/explorer/pkg_version b/cdist/conf/type/__package_emerge/explorer/pkg_version index d02b9d6b..7053eaff 100644 --- a/cdist/conf/type/__package_emerge/explorer/pkg_version +++ b/cdist/conf/type/__package_emerge/explorer/pkg_version @@ -32,5 +32,4 @@ else name="$__object_id" fi -# shellcheck disable=SC2016 equery -q l -F '$cp $fullversion' "$name" || true diff --git a/cdist/conf/type/__package_emerge/gencode-remote b/cdist/conf/type/__package_emerge/gencode-remote old mode 100755 new mode 100644 index e1b85ebb..d4cee37e --- a/cdist/conf/type/__package_emerge/gencode-remote +++ b/cdist/conf/type/__package_emerge/gencode-remote @@ -1,4 +1,4 @@ -#!/bin/sh -e +#!/bin/sh # # 2013 Thomas Oettli (otho at sfs.biz) # @@ -27,48 +27,43 @@ else name="$__object_id" fi -state_should="$(cat "$__object/parameter/state")" - -version="$(cat "$__object/parameter/version")" - -if [ -n "$version" ]; then - name="=$name-$version" +if [ -f "$__object/parameter/state" ]; then + state_should="$(cat "$__object/parameter/state")" +else + state_should="present" fi pkg_version="$(cat "$__object/explorer/pkg_version")" if [ -z "$pkg_version" ]; then state_is="absent" -elif [ -z "$version" ] && [ "$(echo "$pkg_version" | wc -l)" -gt 1 ]; then - echo "Package name is not unique! The following packages are installed:" >&2 - echo "$pkg_version" >&2 - exit 1 -elif [ -n "$version" ] && [ "$(echo "$pkg_version" | cut -d " " -f 1 | sort | uniq | wc -l)" -gt 1 ]; then - echo "Package name is not unique! The following packages are installed:" >&2 - echo "$pkg_version" >&2 +elif [ $(echo "$pkg_version" | wc -l) -gt 1 ]; then + echo "Package name is not unique! The following packages are installed:" + echo "$pkg_version" exit 1 else state_is="present" - if [ -n "$version" ] && echo "$pkg_version" | cut -d " " -f 2 | grep -q -x "$version"; then - installed_version="$(echo "$pkg_version" | cut -d " " -f 2 | grep -x "$version")" - else - installed_version="$(echo "$pkg_version" | cut -d " " -f 2 | tail -n 1)" - fi + installed_version="$(echo "$pkg_version" | cut -d " " -f 2)" fi +if [ -f "$__object/parameter/version" ]; then + version="$(cat "$__object/parameter/version")" + if [ ! -z "$version" ]; then + name="=$name-$version" + fi +else + version="" +fi # Exit if nothing is needed to be done -[ "$state_is" = "$state_should" ] && { [ -z "$version" ] || [ "$installed_version" = "$version" ]; } && exit 0 -[ "$state_should" = "absent" ] && [ -n "$version" ] && [ "$installed_version" != "$version" ] && exit 0 - +[ "$state_is" = "$state_should" ] && ( [ -z "$version" ] || [ "$installed_version" = "$version" ] ) && exit 0 +[ "$state_should" = "absent" ] && [ ! -z "$version" ] && [ "$installed_version" != "$version" ] && exit 0 case "$state_should" in present) - echo "emerge '$name' &>/dev/null || exit 1" - echo "installed" >> "$__messages_out" + echo "emerge \"$name\" &>/dev/null || exit 1" ;; absent) - echo "emerge -C '$name' &>/dev/null || exit 1" - echo "removed" >> "$__messages_out" + echo "emerge -C \"$name\" &>/dev/null || exit 1" ;; *) echo "Unknown state: $state_should" >&2 diff --git a/cdist/conf/type/__package_emerge/man.rst b/cdist/conf/type/__package_emerge/man.text similarity index 53% rename from cdist/conf/type/__package_emerge/man.rst rename to cdist/conf/type/__package_emerge/man.text index 88adaff0..983b49a8 100644 --- a/cdist/conf/type/__package_emerge/man.rst +++ b/cdist/conf/type/__package_emerge/man.text @@ -1,5 +1,7 @@ cdist-type__package_emerge(7) ============================= +Thomas Oettli + NAME ---- @@ -21,43 +23,38 @@ None OPTIONAL PARAMETERS ------------------- -name +name:: If supplied, use the name and not the object id as the package name. -state +state:: Either "present" or "absent", defaults to "present". -version +version:: If supplied, use to install or uninstall a specific version of the package named. EXAMPLES -------- -.. code-block:: sh +-------------------------------------------------------------------------------- +# Ensure sys-devel/gcc is installed +__package_emerge sys-devel/gcc --state present - # Ensure sys-devel/gcc is installed - __package_emerge sys-devel/gcc --state present +# If you want a specific version of a package +__package_emerge app-portage/gentoolkit --state present --version 0.3.0.8-r2 - # If you want a specific version of a package - __package_emerge app-portage/gentoolkit --state present --version 0.3.0.8-r2 - - # Remove package - __package_emerge sys-devel/gcc --state absent +# Remove package +__package_emerge sys-devel/gcc --state absent +-------------------------------------------------------------------------------- SEE ALSO -------- -:strong:`cdist-type__package`\ (7), :strong:`cdist-type__package_emerge_dependencies`\ (7) - - -AUTHORS -------- -Thomas Oettli +- cdist-type(7) +- cdist-type__package(7) +- cdist-type__package_emerge_dependencies(7) COPYING ------- -Copyright \(C) 2013 Thomas Oettli. 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. +Copyright \(C) 2013 Thomas Oettli. 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/__package_emerge/nonparallel b/cdist/conf/type/__package_emerge/nonparallel deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/conf/type/__package_emerge/parameter/default/state b/cdist/conf/type/__package_emerge/parameter/default/state deleted file mode 100644 index e7f6134f..00000000 --- a/cdist/conf/type/__package_emerge/parameter/default/state +++ /dev/null @@ -1 +0,0 @@ -present diff --git a/cdist/conf/type/__package_emerge/parameter/default/version b/cdist/conf/type/__package_emerge/parameter/default/version deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/conf/type/__package_emerge_dependencies/gencode-remote b/cdist/conf/type/__package_emerge_dependencies/gencode-remote old mode 100755 new mode 100644 index f3e6f76e..0c84e53d --- a/cdist/conf/type/__package_emerge_dependencies/gencode-remote +++ b/cdist/conf/type/__package_emerge_dependencies/gencode-remote @@ -1,4 +1,4 @@ -#!/bin/sh -e +#!/bin/sh gentoolkit_installed="$(cat "$__object/explorer/gentoolkit_installed")" flaggie_installed="$(cat "$__object/explorer/flaggie_installed")" @@ -6,11 +6,10 @@ flaggie_installed="$(cat "$__object/explorer/flaggie_installed")" if [ "${gentoolkit_installed}" != "true" ]; then # emerge app-portage/gentoolkit echo "emerge app-portage/gentoolkit &> /dev/null || exit 1" - echo "installed app-portage/gentoolkit" >> "$__messages_out" fi if [ "${flaggie_installed}" != "true" ]; then # emerge app-portage/flaggie echo "emerge app-portage/flaggie &> /dev/null || exit 1" - echo "installed app-portage/flaggie" >> "$__messages_out" fi + diff --git a/cdist/conf/type/__package_emerge_dependencies/man.rst b/cdist/conf/type/__package_emerge_dependencies/man.text similarity index 51% rename from cdist/conf/type/__package_emerge_dependencies/man.rst rename to cdist/conf/type/__package_emerge_dependencies/man.text index 598d31f1..0862256b 100644 --- a/cdist/conf/type/__package_emerge_dependencies/man.rst +++ b/cdist/conf/type/__package_emerge_dependencies/man.text @@ -1,5 +1,7 @@ cdist-type__package_emerge_dependencies(7) ========================================== +Thomas Oettli + NAME ---- @@ -10,9 +12,8 @@ DESCRIPTION ----------- Portage is usually used on the gentoo distribution to manage packages. This type installs the following tools which are required by __package_emerge to work: - -* app-portage/flaggie -* app-portage/gentoolkit +app-portage/flaggie +app-portage/gentoolkit REQUIRED PARAMETERS @@ -28,25 +29,20 @@ None EXAMPLES -------- -.. code-block:: sh - - # Ensure app-portage/flaggie and app-portage/gentoolkit are installed - __package_emerge_dependencies +-------------------------------------------------------------------------------- +# Ensure app-portage/flaggie and app-portage/gentoolkit are installed +__package_emerge_dependencies +-------------------------------------------------------------------------------- SEE ALSO -------- -:strong:`cdist-type__package`\ (7), :strong:`cdist-type__package_emerge`\ (7) - - -AUTHORS -------- -Thomas Oettli +- cdist-type(7) +- cdist-type__package(7) +- cdist-type__package_emerge(7) COPYING ------- -Copyright \(C) 2013 Thomas Oettli. 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. +Copyright \(C) 2013 Thomas Oettli. 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/__package_emerge_dependencies/nonparallel b/cdist/conf/type/__package_emerge_dependencies/nonparallel deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/conf/type/__package_luarocks/explorer/pkg_status b/cdist/conf/type/__package_luarocks/explorer/pkg_status index e83e8ce6..3eb73298 100755 --- a/cdist/conf/type/__package_luarocks/explorer/pkg_status +++ b/cdist/conf/type/__package_luarocks/explorer/pkg_status @@ -28,4 +28,4 @@ else fi # Accept luarocks failing if package is not known/installed -luarocks list "$name" | grep -E -A1 "^$name$" || exit 0 +luarocks list "$name" | egrep -A1 "^$name$" || exit 0 diff --git a/cdist/conf/type/__package_luarocks/gencode-remote b/cdist/conf/type/__package_luarocks/gencode-remote index d83b3c3a..7a5a5b04 100755 --- a/cdist/conf/type/__package_luarocks/gencode-remote +++ b/cdist/conf/type/__package_luarocks/gencode-remote @@ -1,4 +1,4 @@ -#!/bin/sh -e +#!/bin/sh # # 2012 SwellPath, Inc. # Christian G. Warden @@ -29,7 +29,11 @@ else name="$__object_id" fi -state_should="$(cat "$__object/parameter/state")" +if [ -f "$__object/parameter/state" ]; then + state_should="$(cat "$__object/parameter/state")" +else + state_should="present" +fi if grep -q "(installed)" "$__object/explorer/pkg_status"; then state_is="present" @@ -42,12 +46,10 @@ fi case "$state_should" in present) - echo "luarocks install '$name'" - echo "installed" >> "$__messages_out" + echo luarocks install \"$name\" ;; absent) - echo "luarocks remove '$name'" - echo "removed" >> "$__messages_out" + echo luarocks remove \"$name\" ;; *) echo "Unknown state: $state_should" >&2 diff --git a/cdist/conf/type/__package_luarocks/man.rst b/cdist/conf/type/__package_luarocks/man.text similarity index 52% rename from cdist/conf/type/__package_luarocks/man.rst rename to cdist/conf/type/__package_luarocks/man.text index 5dc10195..657f68e5 100644 --- a/cdist/conf/type/__package_luarocks/man.rst +++ b/cdist/conf/type/__package_luarocks/man.text @@ -1,5 +1,7 @@ cdist-type__package_luarocks(7) =============================== +Christian G. Warden + NAME ---- @@ -18,38 +20,32 @@ None OPTIONAL PARAMETERS ------------------- -name +name:: If supplied, use the name and not the object id as the package name. -state +state:: Either "present" or "absent", defaults to "present" EXAMPLES -------- -.. code-block:: sh +-------------------------------------------------------------------------------- +# Ensure luasocket is installed +__package_luarocks luasocket --state present - # Ensure luasocket is installed - __package_luarocks luasocket --state present - - # Remove package - __package_luarocks luasocket --state absent +# Remove package +__package_luarocks luasocket --state absent +-------------------------------------------------------------------------------- SEE ALSO -------- -:strong:`cdist-type__package`\ (7) - - -AUTHORS -------- -Christian G. Warden +- cdist-type(7) +- cdist-type__package(7) COPYING ------- -Copyright \(C) 2012 SwellPath, Inc. 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. +Copyright \(C) 2012 SwellPath, Inc. 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/__package_luarocks/manifest b/cdist/conf/type/__package_luarocks/manifest old mode 100755 new mode 100644 index 7d8262ca..8e626714 --- a/cdist/conf/type/__package_luarocks/manifest +++ b/cdist/conf/type/__package_luarocks/manifest @@ -1,4 +1,4 @@ -#!/bin/sh -e +#!/bin/sh # # 2012 SwellPath, Inc. # Christian G. Warden diff --git a/cdist/conf/type/__package_luarocks/nonparallel b/cdist/conf/type/__package_luarocks/nonparallel deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/conf/type/__package_luarocks/parameter/default/state b/cdist/conf/type/__package_luarocks/parameter/default/state deleted file mode 100644 index e7f6134f..00000000 --- a/cdist/conf/type/__package_luarocks/parameter/default/state +++ /dev/null @@ -1 +0,0 @@ -present diff --git a/cdist/conf/type/__package_opkg/gencode-remote b/cdist/conf/type/__package_opkg/gencode-remote index 269d5f49..1fb78fbe 100755 --- a/cdist/conf/type/__package_opkg/gencode-remote +++ b/cdist/conf/type/__package_opkg/gencode-remote @@ -1,4 +1,4 @@ -#!/bin/sh -e +#!/bin/sh # # 2011,2013 Nico Schottelius (nico-cdist at schottelius.org) # 2012 Giel van Schijndel (giel plus cdist at mortis dot eu) @@ -28,7 +28,11 @@ else name="$__object_id" fi -state_should="$(cat "$__object/parameter/state")" +if [ -f "$__object/parameter/state" ]; then + state_should="$(cat "$__object/parameter/state")" +else + state_should="present" +fi state_is="$(cat "$__object/explorer/pkg_status")" case "$state_is" in @@ -43,17 +47,15 @@ esac case "$state_should" in present) if [ "$present" = "notpresent" ]; then - echo "opkg --verbosity=0 update" + echo opkg --verbosity=0 update fi - echo "opkg --verbosity=0 install '$name'" - echo "installed" >> "$__messages_out" + echo opkg --verbosity=0 install \"$name\" ;; absent) - echo "opkg --verbosity=0 remove '$name'" - echo "removed" >> "$__messages_out" + echo opkg --verbosity=0 remove \"$name\" ;; *) - echo "Unknown state: ${state_should}" >&2 + echo "Unknown state: $state" >&2 exit 1 ;; esac diff --git a/cdist/conf/type/__package_opkg/man.rst b/cdist/conf/type/__package_opkg/man.rst deleted file mode 100644 index 0fd40b33..00000000 --- a/cdist/conf/type/__package_opkg/man.rst +++ /dev/null @@ -1,55 +0,0 @@ -cdist-type__package_opkg(7) -=========================== - -NAME ----- -cdist-type__package_opkg - Manage packages with opkg - - -DESCRIPTION ------------ -opkg is usually used on OpenWRT to manage packages. - - -REQUIRED PARAMETERS -------------------- -None - - -OPTIONAL PARAMETERS -------------------- -name - If supplied, use the name and not the object id as the package name. - -state - Either "present" or "absent", defaults to "present" - - -EXAMPLES --------- - -.. code-block:: sh - - # Ensure lsof is installed - __package_opkg lsof --state present - - # Remove obsolete package - __package_opkg dnsmasq --state absent - - -SEE ALSO --------- -:strong:`cdist-type__package`\ (7) - - -AUTHORS -------- -Giel van Schijndel - - -COPYING -------- -Copyright \(C) 2012 Giel van Schijndel. 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. diff --git a/cdist/conf/type/__package_opkg/man.text b/cdist/conf/type/__package_opkg/man.text new file mode 100644 index 00000000..aeb0a1c5 --- /dev/null +++ b/cdist/conf/type/__package_opkg/man.text @@ -0,0 +1,51 @@ +cdist-type__package_opkg(7) +========================== +Giel van Schijndel + + +NAME +---- +cdist-type__package_opkg - Manage packages with opkg + + +DESCRIPTION +----------- +opkg is usually used on OpenWRT to manage packages. + + +REQUIRED PARAMETERS +------------------- +None + + +OPTIONAL PARAMETERS +------------------- +name:: + If supplied, use the name and not the object id as the package name. + +state:: + Either "present" or "absent", defaults to "present" + + +EXAMPLES +-------- + +-------------------------------------------------------------------------------- +# Ensure lsof is installed +__package_opkg lsof --state present + +# Remove obsolete package +__package_opkg dnsmasq --state absent +-------------------------------------------------------------------------------- + + +SEE ALSO +-------- +- cdist-type(7) +- cdist-type__package(7) + + +COPYING +------- +Copyright \(C) 2012 Giel van Schijndel. 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/__package_opkg/nonparallel b/cdist/conf/type/__package_opkg/nonparallel deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/conf/type/__package_opkg/parameter/default/state b/cdist/conf/type/__package_opkg/parameter/default/state deleted file mode 100644 index e7f6134f..00000000 --- a/cdist/conf/type/__package_opkg/parameter/default/state +++ /dev/null @@ -1 +0,0 @@ -present diff --git a/cdist/conf/type/__package_pacman/gencode-remote b/cdist/conf/type/__package_pacman/gencode-remote index 2e076ec3..02744fa8 100755 --- a/cdist/conf/type/__package_pacman/gencode-remote +++ b/cdist/conf/type/__package_pacman/gencode-remote @@ -1,4 +1,4 @@ -#!/bin/sh -e +#!/bin/sh # # 2011-2012 Nico Schottelius (nico-cdist at schottelius.org) # @@ -31,7 +31,11 @@ else name="$__object_id" fi -state_should="$(cat "$__object/parameter/state")" +if [ -f "$__object/parameter/state" ]; then + state_should="$(cat "$__object/parameter/state")" +else + state_should="present" +fi pkg_version="$(cat "$__object/explorer/pkg_version")" if [ -z "$pkg_version" ]; then @@ -45,12 +49,10 @@ fi case "$state_should" in present) - echo "pacman --needed --noconfirm --noprogressbar -S '$name'" - echo "installed" >> "$__messages_out" + echo pacman --needed --noconfirm --noprogressbar -S \"$name\" ;; absent) - echo "pacman --noconfirm --noprogressbar -R '$name'" - echo "removed" >> "$__messages_out" + echo pacman --noconfirm --noprogressbar -R \"$name\" ;; *) echo "Unknown state: $state_should" >&2 diff --git a/cdist/conf/type/__package_pacman/man.rst b/cdist/conf/type/__package_pacman/man.rst deleted file mode 100644 index 2686202d..00000000 --- a/cdist/conf/type/__package_pacman/man.rst +++ /dev/null @@ -1,58 +0,0 @@ -cdist-type__package_pacman(7) -============================= - -NAME ----- -cdist-type__package_pacman - Manage packages with pacman - - -DESCRIPTION ------------ -Pacman is usually used on the Archlinux distribution to manage packages. - - -REQUIRED PARAMETERS -------------------- -None - - -OPTIONAL PARAMETERS -------------------- -name - If supplied, use the name and not the object id as the package name. - -state - Either "present" or "absent", defaults to "present" - - -EXAMPLES --------- - -.. code-block:: sh - - # Ensure zsh in installed - __package_pacman zsh --state present - - # If you don't want to follow pythonX packages, but always use python - __package_pacman python --state present --name python2 - - # Remove obsolete package - __package_pacman puppet --state absent - - -SEE ALSO --------- -:strong:`cdist-type__package`\ (7) - - -AUTHORS -------- -Nico Schottelius - - -COPYING -------- -Copyright \(C) 2011-2012 Nico Schottelius. 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. diff --git a/cdist/conf/type/__package_pacman/man.text b/cdist/conf/type/__package_pacman/man.text new file mode 100644 index 00000000..2e24ecd9 --- /dev/null +++ b/cdist/conf/type/__package_pacman/man.text @@ -0,0 +1,54 @@ +cdist-type__package_pacman(7) +============================= +Nico Schottelius + + +NAME +---- +cdist-type__package_pacman - Manage packages with pacman + + +DESCRIPTION +----------- +Pacman is usually used on the Archlinux distribution to manage packages. + + +REQUIRED PARAMETERS +------------------- +None + + +OPTIONAL PARAMETERS +------------------- +name:: + If supplied, use the name and not the object id as the package name. + +state:: + Either "present" or "absent", defaults to "present" + + +EXAMPLES +-------- + +-------------------------------------------------------------------------------- +# Ensure zsh in installed +__package_pacman zsh --state present + +# If you don't want to follow pythonX packages, but always use python +__package_pacman python --state present --name python2 + +# Remove obsolete package +__package_pacman puppet --state absent +-------------------------------------------------------------------------------- + + +SEE ALSO +-------- +- cdist-type(7) +- cdist-type__package(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/cdist/conf/type/__package_pacman/nonparallel b/cdist/conf/type/__package_pacman/nonparallel deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/conf/type/__package_pacman/parameter/default/state b/cdist/conf/type/__package_pacman/parameter/default/state deleted file mode 100644 index e7f6134f..00000000 --- a/cdist/conf/type/__package_pacman/parameter/default/state +++ /dev/null @@ -1 +0,0 @@ -present diff --git a/cdist/conf/type/__package_pip/gencode-remote b/cdist/conf/type/__package_pip/gencode-remote old mode 100755 new mode 100644 index dcc4fdf9..ec1c89f8 --- a/cdist/conf/type/__package_pip/gencode-remote +++ b/cdist/conf/type/__package_pip/gencode-remote @@ -1,7 +1,6 @@ -#!/bin/sh -e +#!/bin/sh # # 2012 Nico Schottelius (nico-cdist at schottelius.org) -# 2016 Darko Poljak (darko.poljak at gmail.com) # # This file is part of cdist. # @@ -23,7 +22,11 @@ # state_is=$(cat "$__object/explorer/state") -state_should="$(cat "$__object/parameter/state")" +if [ -f "$__object/parameter/state" ]; then + state_should="$(cat "$__object/parameter/state")" +else + state_should="present" +fi [ "$state_is" = "$state_should" ] && exit 0 @@ -41,32 +44,12 @@ else pip="pip" fi -runasparam="$__object/parameter/runas" -if [ -f "$runasparam" ] -then - runas=$(cat "$runasparam") -else - runas="" -fi - case "$state_should" in present) - if [ "$runas" ] - then - echo "su -c '$pip install -q $name' $runas" - else - echo $pip install -q "$name" - fi - echo "installed" >> "$__messages_out" + echo $pip install -q "$name" ;; absent) - if [ "$runas" ] - then - echo "su -c '$pip uninstall -q -y $name' $runas" - else - echo $pip uninstall -q -y "$name" - fi - echo "removed" >> "$__messages_out" + echo $pip uninstall -q -y "$name" ;; *) echo "Unknown state: $state_should" >&2 diff --git a/cdist/conf/type/__package_pip/man.rst b/cdist/conf/type/__package_pip/man.rst deleted file mode 100644 index 234ceee2..00000000 --- a/cdist/conf/type/__package_pip/man.rst +++ /dev/null @@ -1,65 +0,0 @@ -cdist-type__package_pip(7) -========================== - -NAME ----- -cdist-type__package_pip - Manage packages with pip - - -DESCRIPTION ------------ -Pip is used in Python environments to install packages. -It is also included in the python virtualenv environment. - - -REQUIRED PARAMETERS -------------------- -None - - -OPTIONAL PARAMETERS -------------------- -name - If supplied, use the name and not the object id as the package name. - -pip - Instead of using pip from PATH, use the specific pip path. - -state - Either "present" or "absent", defaults to "present" - -runas - Run pip as specified user. By default it runs as root. - - -EXAMPLES --------- - -.. code-block:: sh - - # Install a package - __package_pip pyro --state present - - # Use pip in a virtualenv located at /root/shinken_virtualenv - __package_pip pyro --state present --pip /root/shinken_virtualenv/bin/pip - - # Use pip in a virtualenv located at /foo/shinken_virtualenv as user foo - __package_pip pyro --state present --pip /foo/shinken_virtualenv/bin/pip --runas foo - - -SEE ALSO --------- -:strong:`cdist-type__package`\ (7) - - -AUTHORS -------- -Nico Schottelius - - -COPYING -------- -Copyright \(C) 2012 Nico Schottelius. 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. diff --git a/cdist/conf/type/__package_pip/man.text b/cdist/conf/type/__package_pip/man.text new file mode 100644 index 00000000..5f619871 --- /dev/null +++ b/cdist/conf/type/__package_pip/man.text @@ -0,0 +1,55 @@ +cdist-type__package_pip(7) +========================== +Nico Schottelius + + +NAME +---- +cdist-type__package_pip - Manage packages with pip + + +DESCRIPTION +----------- +Pip is used in Python environments to install packages. +It is also included in the python virtualenv environment. + + +REQUIRED PARAMETERS +------------------- +None + + +OPTIONAL PARAMETERS +------------------- +name:: + If supplied, use the name and not the object id as the package name. + +pip:: + Instead of using pip from PATH, use the specific pip path. + +state:: + Either "present" or "absent", defaults to "present" + + +EXAMPLES +-------- + +-------------------------------------------------------------------------------- +# Install a package +__package_pip pyro --state present + +# Use pip in a virtualenv located at /root/shinken_virtualenv +__package_pip pyro --state present --pip /root/shinken_virtualenv/bin/pip +-------------------------------------------------------------------------------- + + +SEE ALSO +-------- +- cdist-type(7) +- cdist-type__package(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/cdist/conf/type/__package_pip/nonparallel b/cdist/conf/type/__package_pip/nonparallel deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/conf/type/__package_pip/parameter/default/state b/cdist/conf/type/__package_pip/parameter/default/state deleted file mode 100644 index e7f6134f..00000000 --- a/cdist/conf/type/__package_pip/parameter/default/state +++ /dev/null @@ -1 +0,0 @@ -present diff --git a/cdist/conf/type/__package_pip/parameter/optional b/cdist/conf/type/__package_pip/parameter/optional index d909e790..f32876f7 100644 --- a/cdist/conf/type/__package_pip/parameter/optional +++ b/cdist/conf/type/__package_pip/parameter/optional @@ -1,4 +1,2 @@ -name pip state -runas diff --git a/cdist/conf/type/__package_pkg_freebsd/explorer/pkg_version b/cdist/conf/type/__package_pkg_freebsd/explorer/pkg_version index 0a1ab75c..1335ba79 100755 --- a/cdist/conf/type/__package_pkg_freebsd/explorer/pkg_version +++ b/cdist/conf/type/__package_pkg_freebsd/explorer/pkg_version @@ -30,7 +30,7 @@ fi # Don't produce "no pkgs installed" output -- breaks things PKG_OUTPUT=$(pkg_info 2>&1) if [ ! "$PKG_OUTPUT" = "pkg_info: no packages installed" ]; then - printf "%s" "$(echo "$PKG_OUTPUT" \ + echo -n "$(echo "$PKG_OUTPUT" \ | awk '{print $1}' \ | sed 's/^\(.*\)-\([^-]*\)$/name:\1 ver:\2/g' \ | grep "name:$name ver:" \ diff --git a/cdist/conf/type/__package_pkg_freebsd/gencode-remote b/cdist/conf/type/__package_pkg_freebsd/gencode-remote index 3f88f6bc..3f5ebde7 100755 --- a/cdist/conf/type/__package_pkg_freebsd/gencode-remote +++ b/cdist/conf/type/__package_pkg_freebsd/gencode-remote @@ -1,4 +1,4 @@ -#!/bin/sh -e +#!/bin/sh # # 2012 Jake Guffey (jake.guffey at eprotex.com) # @@ -33,13 +33,12 @@ assert () # If condition false, lineno=$2 - if [ ! "$1" ] + if [ ! $1 ] then echo "Assertion failed: \"$1\"" - # shellcheck disable=SC2039 echo "File \"$0\", line $lineno, called by $(caller 0)" exit $E_ASSERT_FAILED - fi + fi } # Debug @@ -52,10 +51,23 @@ else name="$__object_id" fi -flavor="$(cat "$__object/parameter/flavor")" -version="$(cat "$__object/parameter/version")" -pkgsite="$(cat "$__object/parameter/pkgsite")" -state="$(cat "$__object/parameter/state")" +if [ -f "$__object/parameter/flavor" ]; then + flavor="$(cat "$__object/parameter/flavor")" +fi + +if [ -f "$__object/parameter/version" ]; then + version="$(cat "$__object/parameter/version")" +fi + +if [ -f "$__object/parameter/pkgsite" ]; then + pkgsite="$(cat "$__object/parameter/pkgsite")" +fi + +if [ -f "$__object/parameter/state" ]; then + state="$(cat "$__object/parameter/state")" +else + state="present" +fi curr_version="$(cat "$__object/explorer/pkg_version")" add_cmd="pkg_add" rm_cmd="pkg_delete" @@ -67,7 +79,7 @@ cmd="" # FIXME: This is ugly. execcmd(){ # Set the PACKAGESITE if we're ADDing a new package - if [ "$1" = "add" ] && [ -n "$pkgsite" ]; then + if [ "$1" = "add" -a -n "$pkgsite" ]; then # Use http.../All/ if we know the exact version we want, use .../Latest/ otherwise pkgsite="export PACKAGESITE=${pkgsite}" [ -n "$version" ] && pkgsite="${pkgsite}/All/" || pkgsite="${pkgsite}/Latest/" @@ -89,7 +101,6 @@ if [ -n "$curr_version" ]; then # PKG *is* installed cmd="${rm_cmd} ${name}-${curr_version}" fi execcmd "remove" "${cmd}" - echo "removed" >> "$__messages_out" exit 0 else # Should be installed if [ -n "$version" ]; then # Want a specific version @@ -97,13 +108,11 @@ if [ -n "$curr_version" ]; then # PKG *is* installed exit 0 else # Current version is wrong, fix #updatepkg "$name" "$version" - # shellcheck disable=SC2039 assert "! ${version} = ${curr_version}" $LINENO cmd="${rm_cmd} ${name}-${curr_version}" execcmd "remove" "${cmd}" cmd="${add_cmd} -r ${name}-${version}" execcmd "add" "${cmd}" - echo "installed" >> "$__messages_out" fi else # Don't care what version to use exit 0 @@ -122,7 +131,6 @@ else # PKG *isn't* installed cmd="${cmd}-${version}" fi execcmd "add" "${cmd}" - echo "installed" >> "$__messages_out" exit 0 fi fi diff --git a/cdist/conf/type/__package_pkg_freebsd/man.rst b/cdist/conf/type/__package_pkg_freebsd/man.rst deleted file mode 100644 index b06c7faf..00000000 --- a/cdist/conf/type/__package_pkg_freebsd/man.rst +++ /dev/null @@ -1,70 +0,0 @@ -cdist-type__package_pkg_freebsd(7) -================================== - -NAME ----- -cdist-type__package_pkg_freebsd - Manage FreeBSD packages - - -DESCRIPTION ------------ -This type is usually used on FreeBSD to manage packages. - - -REQUIRED PARAMETERS -------------------- -None - - -OPTIONAL PARAMETERS -------------------- -name - If supplied, use the name and not the object id as the package name. - -flavor - If supplied, use to avoid ambiguity. - -version - If supplied, use to install a specific version of the package named. - -pkgsite - If supplied, use to install from a specific package repository. - -state - Either "present" or "absent", defaults to "present" - - -EXAMPLES --------- - -.. code-block:: sh - - # Ensure zsh is installed - __package_pkg_freebsd zsh --state present - - # Ensure vim is installed, use flavor no_x11 - __package_pkg_freebsd vim --state present --flavor no_x11 - - # If you don't want to follow pythonX packages, but always use python - __package_pkg_freebsd python --state present --name python2 - - # Remove obsolete package - __package_pkg_freebsd puppet --state absent - - -SEE ALSO --------- -:strong:`cdist-type__package`\ (7) - - -AUTHORS -------- -Jake Guffey - - -COPYING -------- -Copyright \(C) 2012 Jake Guffey. 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. diff --git a/cdist/conf/type/__package_pkg_freebsd/man.text b/cdist/conf/type/__package_pkg_freebsd/man.text new file mode 100644 index 00000000..71387148 --- /dev/null +++ b/cdist/conf/type/__package_pkg_freebsd/man.text @@ -0,0 +1,66 @@ +cdist-type__package_pkg_freebsd(7) +================================== +Jake Guffey + + +NAME +---- +cdist-type__package_pkg_freebsd - Manage FreeBSD packages + + +DESCRIPTION +----------- +This type is usually used on FreeBSD to manage packages. + + +REQUIRED PARAMETERS +------------------- +None + + +OPTIONAL PARAMETERS +------------------- +name:: + If supplied, use the name and not the object id as the package name. + +flavor:: + If supplied, use to avoid ambiguity. + +version:: + If supplied, use to install a specific version of the package named. + +pkgsite:: + If supplied, use to install from a specific package repository. + +state:: + Either "present" or "absent", defaults to "present" + + +EXAMPLES +-------- + +-------------------------------------------------------------------------------- +# Ensure zsh is installed +__package_pkg_freebsd zsh --state present + +# Ensure vim is installed, use flavor no_x11 +__package_pkg_freebsd vim --state present --flavor no_x11 + +# If you don't want to follow pythonX packages, but always use python +__package_pkg_freebsd python --state present --name python2 + +# Remove obsolete package +__package_pkg_freebsd puppet --state absent +-------------------------------------------------------------------------------- + + +SEE ALSO +-------- +- cdist-type(7) +- cdist-type__package(7) + + +COPYING +------- +Copyright \(C) 2012 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/__package_pkg_freebsd/nonparallel b/cdist/conf/type/__package_pkg_freebsd/nonparallel deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/conf/type/__package_pkg_freebsd/parameter/default/flavor b/cdist/conf/type/__package_pkg_freebsd/parameter/default/flavor deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/conf/type/__package_pkg_freebsd/parameter/default/pkgsite b/cdist/conf/type/__package_pkg_freebsd/parameter/default/pkgsite deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/conf/type/__package_pkg_freebsd/parameter/default/state b/cdist/conf/type/__package_pkg_freebsd/parameter/default/state deleted file mode 100644 index e7f6134f..00000000 --- a/cdist/conf/type/__package_pkg_freebsd/parameter/default/state +++ /dev/null @@ -1 +0,0 @@ -present diff --git a/cdist/conf/type/__package_pkg_freebsd/parameter/default/version b/cdist/conf/type/__package_pkg_freebsd/parameter/default/version deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/conf/type/__package_pkg_openbsd/explorer/has_installurl b/cdist/conf/type/__package_pkg_openbsd/explorer/has_installurl deleted file mode 100755 index 68337cbb..00000000 --- a/cdist/conf/type/__package_pkg_openbsd/explorer/has_installurl +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/sh -# -# Copyright 2017, Philippe Gregoire -# -# This file is part of cdist. -# -# cdist is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# cdist is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with cdist. If not, see . -# - -# -# Retrieve the installurl(5), as introduced in OpenBSD 6.1 -# -# As of 6.1, the file is supposed to contained a single line -# with the URL used to install from during install or upgrade. -# -# Allow for expansion and take the first non-commented (#) line. -# - -if [ -f /etc/installurl ]; then - printf 'yes' -else - printf 'no' -fi - -exit 0 diff --git a/cdist/conf/type/__package_pkg_openbsd/explorer/pkg_state b/cdist/conf/type/__package_pkg_openbsd/explorer/pkg_state deleted file mode 100755 index 9cd17787..00000000 --- a/cdist/conf/type/__package_pkg_openbsd/explorer/pkg_state +++ /dev/null @@ -1,49 +0,0 @@ -#!/bin/sh -# -# Copyright 2018, Takashi Yoshi -# -# This file is part of cdist. -# -# cdist is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# cdist is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with cdist. If not, see . -# -# -# Retrieve the status of a package - parsed pkg_info output -# - -if [ -f "${__object}/parameter/name" ] -then - pkgid="$(cat "${__object}/parameter/name")" -else - pkgid="${__object_id}" -fi - -if [ -f "${__object}/parameter/version" ] -then - pkgid="${pkgid}-$(cat "${__object}/parameter/version")" -fi - -if [ -f "${__object}/parameter/flavor" ] -then - # If a flavor but no version is given we need to add another -, - # otherwise pkg_info confuses the flavor with the version. - [ -f "${__object}/parameter/version" ] || pkgid="${pkgid}-" - - pkgid="${pkgid}-$(cat "${__object}/parameter/flavor")" -fi - - -pkg_info -q -I "inst:${pkgid}" >/dev/null 2>&1 \ - && echo 'present' || echo 'absent' - -exit 0 diff --git a/cdist/conf/type/__package_pkgng_freebsd/explorer/pkg_version b/cdist/conf/type/__package_pkg_openbsd/explorer/pkg_version similarity index 72% rename from cdist/conf/type/__package_pkgng_freebsd/explorer/pkg_version rename to cdist/conf/type/__package_pkg_openbsd/explorer/pkg_version index 92ce0623..bc23a85d 100755 --- a/cdist/conf/type/__package_pkgng_freebsd/explorer/pkg_version +++ b/cdist/conf/type/__package_pkg_openbsd/explorer/pkg_version @@ -1,6 +1,6 @@ #!/bin/sh # -# 2014 Jake Guffey (jake.guffey at eprotex.com) +# 2011 Andi Brönnimann (andi-cdist at v-net.ch) # # This file is part of cdist. # @@ -27,11 +27,5 @@ else name="$__object_id" fi -# Don't produce "no pkgs installed" output -- breaks things -PKG_OUTPUT=$(pkg info 2>&1) -printf "%s" "$(echo "$PKG_OUTPUT" \ - | awk '{print $1}' \ - | sed 's/^\(.*\)-\([^-]*\)$/name:\1 ver:\2/g' \ - | grep "name:$name ver:" \ - | sed 's/^.*ver:\(.*\)/\1/g')" - +#TODO: Is there a better way? +pkg_info | grep "$name" | sed 's .*\(-[0-9.][0-9.]*\).* \1 ' | sed 's/-//' diff --git a/cdist/conf/type/__package_pkg_openbsd/gencode-remote b/cdist/conf/type/__package_pkg_openbsd/gencode-remote index 5a21ce12..08e15e89 100755 --- a/cdist/conf/type/__package_pkg_openbsd/gencode-remote +++ b/cdist/conf/type/__package_pkg_openbsd/gencode-remote @@ -1,8 +1,7 @@ -#!/bin/sh -e +#!/bin/sh # # 2011 Andi Brönnimann (andi-cdist at v-net.ch) # 2012 Nico Schottelius (nico-cdist at schottelius.org) -# 2018 Takashi Yoshi # # This file is part of cdist. # @@ -23,96 +22,87 @@ # Manage packages with pkg on OpenBSD # -os_version=$(cat "${__global}/explorer/os_version") -machine=$(cat "${__global}/explorer/machine") +# Debug +# exec >&2 +# set -x -if [ -f "${__object}/parameter/version" ]; then - version=$(cat "${__object}/parameter/version") +os_version="$(cat "$__global/explorer/os_version")" +machine="$(cat "$__global/explorer/machine")" + +if [ -f "$__object/parameter/flavor" ]; then + flavor="$(cat "$__object/parameter/flavor")" fi -if [ -f "${__object}/parameter/flavor" ]; then - flavor=$(cat "${__object}/parameter/flavor") -fi +# do not show progress bar +pkgopts="-x" -# Do not show progress bar -pkgopts='-x' - -name="${__object_id}" -if [ -f "${__object}/parameter/name" ]; then - name=$(cat "${__object}/parameter/name") -fi - -if [ -n "${version}" ] && [ -n "${flavor}" ]; then - pkgid="${name}-${version}-${flavor}" -elif [ -n "${version}" ]; then - pkgid="${name}-${version}" -elif [ -f "${__object}/parameter/flavor" ]; then - pkgid="${name}--${flavor}" +if [ -f "$__object/parameter/name" ]; then + name="$__object/parameter/name" else - pkgid="${name}" + name="$__object_id" fi -state_should=$(cat "${__object}/parameter/state") - -if [ -f "${__object}/parameter/pkg_path" ]; then - pkg_path=$(cat "${__object}/parameter/pkg_path") +if [ -f "$__object/parameter/state" ]; then + state_should="$(cat "$__object/parameter/state")" else - has_installurl=$(cat "${__object}/explorer/has_installurl") - if [ 'yes' != "${has_installurl}" ]; then - # There is no default PKG_PATH, try to provide one - pkg_path="ftp://ftp.openbsd.org/pub/OpenBSD/${os_version}/packages/${machine}/" - fi + state_should="present" fi -state_is=$(cat "${__object}/explorer/pkg_state") -[ "${state_is}" = "${state_should}" ] && exit 0 +pkg_version="$(cat "$__object/explorer/pkg_version")" -case "${state_should}" in - present) - if [ -n "${pkg_path}" ]; then - echo "export PKG_PATH='${pkg_path}'" - fi +if [ -f "$__object/parameter/pkg_path" ]; then + pkg_path="$(cat "$__object/parameter/pkg_path")" +else + pkg_path="ftp://ftp.openbsd.org/pub/OpenBSD/$os_version/packages/$machine/" +fi - # Use this because pkg_add doesn't properly handle errors - cat <&1 || true) - -if ! pkg_info -q -I 'inst:${pkgid}' | grep -q '^${name}-${version}.*${flavor}$' 2>/dev/null -then - # We didn't find the package in the list of 'installed packages', so it failed. - # This is necessary because pkg_add doesn't return properly - - if [ -z "\${status}" ]; then - status='Failed to add package, uncaught exception.' - fi - echo "Error: \${status}" >&2 - exit 1 +if [ "$pkg_version" ]; then + state_is="present" +else + state_is="absent" fi -EOF - echo 'installed' >> "${__messages_out}" - ;; - absent) - # Use this because pkg_delete doesn't properly handle errors - cat <&1 || true) +[ "$state_is" = "$state_should" ] && exit 0 -if pkg_info -q -I 'inst:${pkgid}' | grep -q '^${name}-${version}.*${flavor}' 2>/dev/null -then - # We found the package in the list of 'installed packages'. - # This would indicate that pkg_delete failed, send the output of pkg_delete +case "$state_should" in + present) + # use this because pkg_add doesn't properly handle errors + cat << eof +export PKG_PATH="$pkg_path" +status=\$(pkg_add "$pkgopts" "$name--$flavor" 2>&1) +pkg_info | grep "^${name}.*${flavor}" > /dev/null 2>&1 - if [ -z "\${status}" ]; then - status='Failed to remove package, uncaught exception.' - fi - echo "Error: \${status}" >&2 - exit 1 +# We didn't find the package in the list of 'installed packages', so it failed +# This is necessary because pkg_add doesn't return properly +if [ \$? -ne 0 ]; then + if [ -z "\${status}" ]; then + status="Failed to add package, uncaught exception." + fi + echo "Error: \$status" + exit 1 fi -EOF - echo 'removed' >> "${__messages_out}" - ;; - *) - echo "Unknown state: ${state_should}" >&2 +eof + ;; + + absent) + # use this because pkg_add doesn't properly handle errors + cat << eof +status=\$(pkg_delete "$pkgopts" "$name--$flavor") +pkg_info | grep "^${name}.*${flavor}" > /dev/null 2>&1 + +# We found the package in the list of 'installed packages' +# This would indicate that pkg_delete failed, send the output of pkg_delete +if [ \$? -eq 0 ]; then + if [ -z "\${status}" ]; then + status="Failed to remove package, uncaught exception." + fi + echo "Error: \$status" + exit 1 +fi +eof + ;; + *) + echo "Unknown state: $state_should" >&2 exit 1 - ;; + ;; esac diff --git a/cdist/conf/type/__package_pkg_openbsd/man.rst b/cdist/conf/type/__package_pkg_openbsd/man.rst deleted file mode 100644 index dcfd0719..00000000 --- a/cdist/conf/type/__package_pkg_openbsd/man.rst +++ /dev/null @@ -1,71 +0,0 @@ -cdist-type__package_pkg(7) -========================== - -NAME ----- -cdist-type__package_pkg - Manage OpenBSD packages - - -DESCRIPTION ------------ -This type is usually used on OpenBSD to manage packages. - - -REQUIRED PARAMETERS -------------------- -None - - -OPTIONAL PARAMETERS -------------------- -name - If supplied, use the name and not the object id as the package name. - -flavor - If supplied, use to avoid ambiguity. - -version - If supplied, use to avoid ambiguity. - -state - Either "present" or "absent", defaults to "present" - -pkg_path - Manually specify a PKG_PATH to add packages from. - -EXAMPLES --------- - -.. code-block:: sh - - # Ensure zsh is installed - __package_pkg_openbsd zsh --state present - - # Ensure vim is installed, use flavor no_x11 - __package_pkg_openbsd vim --state present --flavor no_x11 - - # If you don't want to follow pythonX packages, but always use python - __package_pkg_openbsd python --state present --name python2 - - # Remove obsolete package - __package_pkg_openbsd puppet --state absent - - # Add a package using a particular mirror - __package_pkg_openbsd bash \ - --pkg_path http://openbsd.mirrorcatalogs.com/snapshots/packages/amd64 - - -SEE ALSO --------- -:strong:`cdist-type__package`\ (7) - - -AUTHORS -------- -Andi Brönnimann - - -COPYING -------- -Copyright \(C) 2011 Andi Brönnimann. 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/__package_pkg_openbsd/man.text b/cdist/conf/type/__package_pkg_openbsd/man.text new file mode 100644 index 00000000..c7de2652 --- /dev/null +++ b/cdist/conf/type/__package_pkg_openbsd/man.text @@ -0,0 +1,66 @@ +cdist-type__package_pkg(7) +========================== +Andi Brönnimann + + +NAME +---- +cdist-type__package_pkg_openbsd - Manage OpenBSD packages + + +DESCRIPTION +----------- +This type is usually used on OpenBSD to manage packages. + + +REQUIRED PARAMETERS +------------------- +None + + +OPTIONAL PARAMETERS +------------------- +name:: + If supplied, use the name and not the object id as the package name. + +flavor:: + If supplied, use to avoid ambiguity. + +state:: + Either "present" or "absent", defaults to "present" + +pkg_path:: + Manually specify a PKG_PATH to add packages from. + +EXAMPLES +-------- + +-------------------------------------------------------------------------------- +# Ensure zsh is installed +__package_pkg_openbsd zsh --state present + +# Ensure vim is installed, use flavor no_x11 +__package_pkg_openbsd vim --state present --flavor no_x11 + +# If you don't want to follow pythonX packages, but always use python +__package_pkg_openbsd python --state present --name python2 + +# Remove obsolete package +__package_pkg_openbsd puppet --state absent + +# Add a package using a particular mirror +__package_pkg_openbsd bash \ + --pkg_path http://openbsd.mirrorcatalogs.com/snapshots/packages/amd64 +-------------------------------------------------------------------------------- + + +SEE ALSO +-------- +- cdist-type(7) +- cdist-type__package(7) + + +COPYING +------- +Copyright \(C) 2011 Andi Brönnimann. 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/__package_pkg_openbsd/nonparallel b/cdist/conf/type/__package_pkg_openbsd/nonparallel deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/conf/type/__package_pkg_openbsd/parameter/default/state b/cdist/conf/type/__package_pkg_openbsd/parameter/default/state deleted file mode 100644 index e7f6134f..00000000 --- a/cdist/conf/type/__package_pkg_openbsd/parameter/default/state +++ /dev/null @@ -1 +0,0 @@ -present diff --git a/cdist/conf/type/__package_pkg_openbsd/parameter/optional b/cdist/conf/type/__package_pkg_openbsd/parameter/optional index 6a5f9277..43278d16 100644 --- a/cdist/conf/type/__package_pkg_openbsd/parameter/optional +++ b/cdist/conf/type/__package_pkg_openbsd/parameter/optional @@ -1,5 +1,4 @@ name -version flavor state pkg_path diff --git a/cdist/conf/type/__package_pkgng_freebsd/gencode-remote b/cdist/conf/type/__package_pkgng_freebsd/gencode-remote deleted file mode 100755 index dd36efda..00000000 --- a/cdist/conf/type/__package_pkgng_freebsd/gencode-remote +++ /dev/null @@ -1,130 +0,0 @@ -#!/bin/sh -e -# -# 2014 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 . -# -# -# Manage packages with pkg on FreeBSD -# - -# Debug -#exec >&2 -#set -x - -if [ -f "$__object/parameter/name" ]; then - name="$(cat "$__object/parameter/name")" -else - name="$__object_id" -fi - -flavor="$(cat "$__object/parameter/flavor")" -version="$(cat "$__object/parameter/version")" - -if [ -f "$__object/parameter/upgrade" ]; then - upgrade="true" -else - upgrade="false" -fi - -repo="$(cat "$__object/parameter/repo")" -state="$(cat "$__object/parameter/state")" -curr_version="$(cat "$__object/explorer/pkg_version")" -add_cmd="pkg install -y" -rm_cmd="pkg delete -y" -upg_cmd="pkg upgrade -y" -cmd="" - -# Print the command to be executed -# Parms: $1 -- mode, "rm", "add", or "upg" -# $2 -- the command to be echoed -execcmd(){ - _cmd="" - - case "$1" in - add) - _cmd="${add_cmd} $2" - echo "installed" >> "$__messages_out" - ;; - rm) - _cmd="${rm_cmd} $2" - echo "removed" >> "$__messages_out" - ;; - upg) - _cmd="${upg_cmd} $2" - echo "installed" >> "$__messages_out" - ;; - *) - printf "Error. Don't understand command: %s" "$1" >&2 - exit 1 - ;; - esac - - echo "$_cmd >/dev/null 2>&1" # Silence the output of the command - echo "status=\$?" - echo "if [ \"\$status\" -ne \"0\" ]; then" - echo " echo \"Error: ${_cmd} exited nonzero with \$status\"'!' >&2" - echo " exit 1" - echo "fi" -} - -if [ -n "$curr_version" ]; then # PKG *is* installed - if [ -n "$repo" ]; then - cmd="-r ${repo} ${name}" - else - cmd="${name}" - fi - if [ -n "$flavor" ]; then - cmd="${cmd}-${flavor}" - fi - # PKG is supposed to be removed - if [ "$state" = "absent" ]; then - execcmd "rm" "${cmd}" - # PKG is supposed to be installed to a particular version - elif [ -n "$version" ] && [ "$version" != "$curr_version" ]; then - if [ "$upgrade" = "true" ]; then - execcmd "upg" "${cmd}" - else - printf 'Version %s is already installed and pkg-ng cannot upgrade directly to version %s.\nTo upgrade to the latest version, use the --upgrade flag.\n' "$curr_version" "$version" >&2 - exit 1 - fi - # PKG is supposed to be installed to the latest version - else - : # Do nothing. - fi -else # PKG *isn't* installed - if [ "$state" = "absent" ]; then # Shouldn't be installed - exit 0 - else # Should be installed - if [ -n "$repo" ]; then - cmd="-r ${repo} ${name}" - else - cmd="${name}" - fi - if [ -n "$flavor" ]; then - cmd="${cmd}-${flavor}" - fi - if [ -n "$version" ]; then - cmd="${cmd}-${version}" - fi - - execcmd "add" "$cmd" - exit 0 - fi -fi - -# Debug -#set +x diff --git a/cdist/conf/type/__package_pkgng_freebsd/man.rst b/cdist/conf/type/__package_pkgng_freebsd/man.rst deleted file mode 100644 index 251e2c5f..00000000 --- a/cdist/conf/type/__package_pkgng_freebsd/man.rst +++ /dev/null @@ -1,101 +0,0 @@ -cdist-type__package_pkgng_freebsd(7) -==================================== - -NAME ----- -cdist-type__package_pkgng_freebsd - Manage FreeBSD packages with pkg-ng - - -DESCRIPTION ------------ -This type is usually used on FreeBSD to manage packages. - - -REQUIRED PARAMETERS -------------------- -None - - -OPTIONAL PARAMETERS -------------------- -name - If supplied, use the name and not the object id as the package name. - -flavor - If supplied, use to avoid ambiguity. - -version - If supplied, use to install a specific version of the package named. - -repo - If supplied, use to install the package named from a particular repo. - -state - Either "present" or "absent", defaults to "present" - - -BOOLEAN PARAMETERS ------------------- -upgrade - If supplied, allow upgrading to the latest version of a package. - - -CAVEATS -------- -This type requires that repository definitions already exist in /etc/pkg/\*.conf. -Ensure that they exist prior to use of this type with __file. - -pkg-ng can't upgrade a package to a specific version. If this type needs to -upgrade a package, it can only ugprade to the latest available version. If the -"upgrade" parameter is not given and an upgrade needs to occur, an error will result. - - -MESSAGES --------- -install - The package was installed -remove - The package was removed -upgrade - The package was upgraded -exist - The package was already present and thus not installed - - -EXAMPLES --------- - -.. code-block:: sh - - # Ensure zsh is installed - __package_pkgng_freebsd zsh --state present - - # Ensure vim is installed, use flavor no_x11 - __package_pkgng_freebsd vim --state present --flavor no_x11 - - # If you don't want to follow pythonX packages, but always use python - __package_pkgng_freebsd python --state present --name python2 - - # Install a package from a particular repository when multiples exist - __package_pkgng_freebsd bash --state present --repo myrepo - - # Remove obsolete package - __package_pkgng_freebsd puppet --state absent - - -SEE ALSO --------- -:strong:`cdist-type__package`\ (7) - - -AUTHORS -------- -Jake Guffey - - -COPYING -------- -Copyright \(C) 2014 Jake Guffey. 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. diff --git a/cdist/conf/type/__package_pkgng_freebsd/nonparallel b/cdist/conf/type/__package_pkgng_freebsd/nonparallel deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/conf/type/__package_pkgng_freebsd/parameter/boolean b/cdist/conf/type/__package_pkgng_freebsd/parameter/boolean deleted file mode 100644 index 007ead00..00000000 --- a/cdist/conf/type/__package_pkgng_freebsd/parameter/boolean +++ /dev/null @@ -1 +0,0 @@ -upgrade \ No newline at end of file diff --git a/cdist/conf/type/__package_pkgng_freebsd/parameter/default/flavor b/cdist/conf/type/__package_pkgng_freebsd/parameter/default/flavor deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/conf/type/__package_pkgng_freebsd/parameter/default/repo b/cdist/conf/type/__package_pkgng_freebsd/parameter/default/repo deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/conf/type/__package_pkgng_freebsd/parameter/default/state b/cdist/conf/type/__package_pkgng_freebsd/parameter/default/state deleted file mode 100644 index e7f6134f..00000000 --- a/cdist/conf/type/__package_pkgng_freebsd/parameter/default/state +++ /dev/null @@ -1 +0,0 @@ -present diff --git a/cdist/conf/type/__package_pkgng_freebsd/parameter/default/version b/cdist/conf/type/__package_pkgng_freebsd/parameter/default/version deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/conf/type/__package_pkgng_freebsd/parameter/optional b/cdist/conf/type/__package_pkgng_freebsd/parameter/optional deleted file mode 100644 index 6e67f838..00000000 --- a/cdist/conf/type/__package_pkgng_freebsd/parameter/optional +++ /dev/null @@ -1,5 +0,0 @@ -name -flavor -version -repo -state diff --git a/cdist/conf/type/__package_rubygem/gencode-remote b/cdist/conf/type/__package_rubygem/gencode-remote index abb40653..6256e308 100755 --- a/cdist/conf/type/__package_rubygem/gencode-remote +++ b/cdist/conf/type/__package_rubygem/gencode-remote @@ -1,4 +1,4 @@ -#!/bin/sh -e +#!/bin/sh # # 2011 Chase Allen James # @@ -27,7 +27,11 @@ else name="$__object_id" fi -state_should="$(cat "$__object/parameter/state")" +if [ -f "$__object/parameter/state" ]; then + state_should="$(cat "$__object/parameter/state")" +else + state_should="present" +fi if grep -q true "$__object/explorer/pkg_status"; then state_is="present" @@ -39,12 +43,10 @@ fi case "$state_should" in present) - echo "gem install '$name' --no-ri --no-rdoc" - echo "installed" >> "$__messages_out" + echo gem install \"$name\" --no-ri --no-rdoc ;; absent) - echo "gem uninstall '$name'" - echo "removed" >> "$__messages_out" + echo gem uninstall \"$name\" ;; *) echo "Unknown state: $state_should" >&2 diff --git a/cdist/conf/type/__package_rubygem/man.rst b/cdist/conf/type/__package_rubygem/man.text similarity index 53% rename from cdist/conf/type/__package_rubygem/man.rst rename to cdist/conf/type/__package_rubygem/man.text index 96ad21f7..a808c2aa 100644 --- a/cdist/conf/type/__package_rubygem/man.rst +++ b/cdist/conf/type/__package_rubygem/man.text @@ -1,5 +1,7 @@ cdist-type__package_rubygem(7) ============================== +Chase Allen James + NAME ---- @@ -18,39 +20,32 @@ None OPTIONAL PARAMETERS ------------------- -name +name:: If supplied, use the name and not the object id as the package name. -state +state:: Either "present" or "absent", defaults to "present" EXAMPLES -------- -.. code-block:: sh +-------------------------------------------------------------------------------- +# Ensure sinatra is installed +__package_rubygem sinatra --state present - # Ensure sinatra is installed - __package_rubygem sinatra --state present - - # Remove package - __package_rubygem rails --state absent +# Remove package +__package_rubygem rails --state absent +-------------------------------------------------------------------------------- SEE ALSO -------- -:strong:`cdist-type__package`\ (7) - - -AUTHORS -------- -Chase Allen James +- cdist-type(7) +- cdist-type__package(7) COPYING ------- - -Copyright \(C) 2011 Chase Allen James. 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. +Copyright \(C) 2011 Chase Allen James. 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/__package_rubygem/nonparallel b/cdist/conf/type/__package_rubygem/nonparallel deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/conf/type/__package_rubygem/parameter/default/state b/cdist/conf/type/__package_rubygem/parameter/default/state deleted file mode 100644 index e7f6134f..00000000 --- a/cdist/conf/type/__package_rubygem/parameter/default/state +++ /dev/null @@ -1 +0,0 @@ -present diff --git a/cdist/conf/type/__package_update_index/explorer/currage b/cdist/conf/type/__package_update_index/explorer/currage deleted file mode 100644 index 3539b8e1..00000000 --- a/cdist/conf/type/__package_update_index/explorer/currage +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/sh -# -# 2018 Thomas Eckert (tom at it-eckert.de) -# -# 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 . - -type="$("$__type_explorer/type")" - -case "$type" in - apt) - if [ -f "/var/cache/apt/pkgcache.bin" ]; then - echo $(($(date +"%s")-$(stat --format '%Y' /var/cache/apt/pkgcache.bin))) - else - echo 0 - fi - ;; - pacman) - if [ -d "/var/lib/pacman/sync" ]; then - echo $(($(date +"%s")-$(stat --format '%Y' /var/lib/pacman/sync))) - else - echo 0 - fi - ;; - *) echo "Your specified type ($type) is currently not supported." >&2 - echo "Please contribute an implementation for it if you can." >&2 - ;; -esac diff --git a/cdist/conf/type/__package_update_index/explorer/type b/cdist/conf/type/__package_update_index/explorer/type deleted file mode 100644 index 35254c5f..00000000 --- a/cdist/conf/type/__package_update_index/explorer/type +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/sh -# -# 2018 Stu Zhao (z12y12l12 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 . - -if [ -f "$__object/parameter/type" ]; then - cat "$__object/parameter/type" -else - # By default determine package manager based on operating system - os="$("$__explorer/os")" - case "$os" in - amazon|scientific|centos|fedora|redhat) echo "yum" ;; - debian|ubuntu|devuan) echo "apt" ;; - archlinux) echo "pacman" ;; - *) - echo "Don't know how to manage packages on: $os" >&2 - exit 1 - ;; - esac -fi diff --git a/cdist/conf/type/__package_update_index/gencode-remote b/cdist/conf/type/__package_update_index/gencode-remote deleted file mode 100755 index 738d38eb..00000000 --- a/cdist/conf/type/__package_update_index/gencode-remote +++ /dev/null @@ -1,54 +0,0 @@ -#!/bin/sh -e -# -# 2014 Ricardo Catalinas Jiménez (jimenezrick 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 . -# -# -# Update the package index with the appropriate package manager -# - -type=$(cat "$__object/explorer/type") -currage="$(cat "$__object/explorer/currage")" -if [ -f "$__object/parameter/maxage" ]; then - maxage="$(cat "$__object/parameter/maxage")" -fi - -if [ -n "$maxage" ]; then - if [ "$type" != "apt" ] && [ "$type" != "pacman" ]; then - echo "ERROR: \"--maxage\" only supported for \"apt\" or \"pacman\" pkg-manager." >&2 - exit 1 - elif [ "$currage" -lt "$maxage" ]; then - exit 0 # no need to update - fi -fi - - -case "$type" in - yum) ;; - apt) - echo "apt-get --quiet update" - echo "apt-cache updated (age was: $currage)" >> "$__messages_out" - ;; - pacman) - echo "pacman --noprogressbar --sync --refresh" - echo "pacman package database synced (age was: $currage)" >> "$__messages_out" - ;; - *) - echo "Don't know how to manage packages for type: $type" >&2 - exit 1 - ;; -esac diff --git a/cdist/conf/type/__package_update_index/man.rst b/cdist/conf/type/__package_update_index/man.rst deleted file mode 100644 index 3cd787b9..00000000 --- a/cdist/conf/type/__package_update_index/man.rst +++ /dev/null @@ -1,71 +0,0 @@ -cdist-type__package_update_index(7) -=================================== - -NAME ----- -cdist-type__update_index - Update the package index - - -DESCRIPTION ------------ -This cdist type allows you to update the package index on the target. -It will automatically use the appropriate package manager. - - -REQUIRED PARAMETERS -------------------- -None - - -OPTIONAL PARAMETERS -------------------- -type - The package manager to use. Default is determined based on the $os - explorer variable. - e.g. - * apt for Debian - * yum for Red Hat - * pacman for Arch Linux - -maxage - Available for package manager apt and pacman, max time in seconds since - last update. Repo update is skipped if maxage is not reached yet. - -MESSAGES --------- -apt-cache updated (age was: currage) - apt-cache was updated (run of `apt-get update`). `currage` is the time - in seconds since the previous run. - - -EXAMPLES --------- - -.. code-block:: sh - - # Update the package index on the target - __package_update_index - - # Force use of a specific package manager - __package_update_index --type apt - - # Only update every hour: - __package_update_index --maxage 3600 --type apt - - # same as above (on apt-type systems): - __package_update_index --maxage 3600 - -AUTHORS -------- -| Ricardo Catalinas Jiménez -| Thomas Eckert -| Stu Zhao - - -COPYING -------- - -Copyright \(C) 2014 Ricardo Catalinas Jiménez. 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. diff --git a/cdist/conf/type/__package_update_index/nonparallel b/cdist/conf/type/__package_update_index/nonparallel deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/conf/type/__package_update_index/parameter/optional b/cdist/conf/type/__package_update_index/parameter/optional deleted file mode 100644 index 7a0be716..00000000 --- a/cdist/conf/type/__package_update_index/parameter/optional +++ /dev/null @@ -1,2 +0,0 @@ -type -maxage diff --git a/cdist/conf/type/__package_update_index/singleton b/cdist/conf/type/__package_update_index/singleton deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/conf/type/__package_upgrade_all/gencode-remote b/cdist/conf/type/__package_upgrade_all/gencode-remote deleted file mode 100755 index 38aa001e..00000000 --- a/cdist/conf/type/__package_upgrade_all/gencode-remote +++ /dev/null @@ -1,73 +0,0 @@ -#!/bin/sh -e -# -# 2014 Ricardo Catalinas Jiménez (jimenezrick 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 . -# -# -# Upgrade all the already installed packages with the appropriate package -# manager -# - -type="$__object/parameter/type" - -apt_clean="$__object/parameter/apt-clean" - -apt_dist_upgrade="$__object/parameter/apt-dist-upgrade" - -if [ -f "$type" ]; then - type="$(cat "$type")" -else - # By default determine package manager based on operating system - os="$(cat "$__global/explorer/os")" - case "$os" in - amazon|scientific|centos|fedora|redhat) type="yum" ;; - debian|ubuntu|devuan) type="apt" ;; - archlinux) type="pacman" ;; - *) - echo "Don't know how to manage packages on: $os" >&2 - exit 1 - ;; - esac -fi - -aptget="DEBIAN_FRONTEND=noninteractive apt-get --quiet --yes --no-install-recommends -o Dpkg::Options::=\"--force-confdef\" -o Dpkg::Options::=\"--force-confold\"" - -case "$type" in - yum) - echo "yum --quiet --assumeyes update" - echo "yum --quiet clean all" - ;; - apt) - if [ -f "$apt_dist_upgrade" ] - then echo "$aptget dist-upgrade" - else echo "$aptget upgrade" - fi - - if [ -f "$apt_clean" ] - then echo "apt-get --quiet clean" - else echo "apt-get --quiet autoclean" - fi - ;; - pacman) - echo "pacman --noprogressbar --noconfirm --sync --sysupgrade" - echo "pacman --noprogressbar --noconfirm --sync --clean" - ;; - *) - echo "Don't know how to manage packages on: $os" >&2 - exit 1 - ;; -esac diff --git a/cdist/conf/type/__package_upgrade_all/man.rst b/cdist/conf/type/__package_upgrade_all/man.rst deleted file mode 100644 index e9e2b8ce..00000000 --- a/cdist/conf/type/__package_upgrade_all/man.rst +++ /dev/null @@ -1,62 +0,0 @@ -cdist-type__package_upgrade_all(7) -================================== - -NAME ----- -cdist-type__package_upgrade_all - Upgrade all the installed packages - - -DESCRIPTION ------------ -This cdist type allows you to upgrade all the installed packages on the -target. It will automatically use the appropriate package manager. - - -REQUIRED PARAMETERS -------------------- -None - - -OPTIONAL PARAMETERS -------------------- -type - The package manager to use. Default is determined based on the $os - explorer variable. - e.g. - * apt for Debian - * yum for Red Hat - * pacman for Arch Linux - - -BOOLEAN PARAMETERS ------------------- -apt-dist-upgrade - Do dist-upgrade instead of upgrade. - -apt-clean - Clean out the local repository of retrieved package files. - - -EXAMPLES --------- - -.. code-block:: sh - - # Upgrade all the installed packages on the target - __package_upgrade_all - - # Force use of a specific package manager - __package_upgrade_all --type apt - - -AUTHORS -------- -Ricardo Catalinas Jiménez - -COPYING -------- - -Copyright \(C) 2014 Ricardo Catalinas Jiménez. 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. diff --git a/cdist/conf/type/__package_upgrade_all/nonparallel b/cdist/conf/type/__package_upgrade_all/nonparallel deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/conf/type/__package_upgrade_all/parameter/boolean b/cdist/conf/type/__package_upgrade_all/parameter/boolean deleted file mode 100644 index 7a56a34b..00000000 --- a/cdist/conf/type/__package_upgrade_all/parameter/boolean +++ /dev/null @@ -1,2 +0,0 @@ -apt-clean -apt-dist-upgrade diff --git a/cdist/conf/type/__package_upgrade_all/parameter/optional b/cdist/conf/type/__package_upgrade_all/parameter/optional deleted file mode 100644 index aa80e646..00000000 --- a/cdist/conf/type/__package_upgrade_all/parameter/optional +++ /dev/null @@ -1 +0,0 @@ -type diff --git a/cdist/conf/type/__package_upgrade_all/singleton b/cdist/conf/type/__package_upgrade_all/singleton deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/conf/type/__package_yum/explorer/pkg_version b/cdist/conf/type/__package_yum/explorer/pkg_version index b81b0fe9..fb3b7753 100755 --- a/cdist/conf/type/__package_yum/explorer/pkg_version +++ b/cdist/conf/type/__package_yum/explorer/pkg_version @@ -27,4 +27,4 @@ else name="$__object_id" fi -rpm -q "$name" 2>/dev/null || rpm -q --whatprovides "$name" 2>/dev/null || true +rpm -q --whatprovides "$name" 2>/dev/null || true diff --git a/cdist/conf/type/__package_yum/gencode-remote b/cdist/conf/type/__package_yum/gencode-remote index b52953f6..32a794a0 100755 --- a/cdist/conf/type/__package_yum/gencode-remote +++ b/cdist/conf/type/__package_yum/gencode-remote @@ -1,4 +1,4 @@ -#!/bin/sh -e +#!/bin/sh # # 2011-2014 Nico Schottelius (nico-cdist at schottelius.org) # @@ -37,21 +37,16 @@ fi state_should="$(cat "$__object/parameter/state")" -if grep -q -E "(scientific|centos|redhat|amazon)" "$__global/explorer/os"; then +if grep -q -E "(centos|redhat|amazon)" "$__global/explorer/os"; then opts="-y --quiet" else opts="--assumeyes --quiet" fi -not_provided="^no package provides" -not_installed='is not installed$' +not_installed="^no package provides" -if grep -q "$not_provided" "$__object/explorer/pkg_version"; then - if grep -q "$not_installed" "$__object/explorer/pkg_version"; then - state_is="absent" - else - state_is="present" - fi +if grep -q "$not_installed" "$__object/explorer/pkg_version"; then + state_is="absent" else state_is="present" fi @@ -60,12 +55,10 @@ fi case "$state_should" in present) - echo "yum $opts install '$install_name'" - echo "installed" >> "$__messages_out" + echo yum $opts install \"$install_name\" ;; absent) - echo "yum $opts remove '$name'" - echo "removed" >> "$__messages_out" + echo yum $opts remove \"$name\" ;; *) echo "Unknown state: $state_should" >&2 diff --git a/cdist/conf/type/__package_yum/man.rst b/cdist/conf/type/__package_yum/man.rst deleted file mode 100644 index 45ad9a55..00000000 --- a/cdist/conf/type/__package_yum/man.rst +++ /dev/null @@ -1,65 +0,0 @@ -cdist-type__package_yum(7) -========================== - -NAME ----- -cdist-type__package_yum - Manage packages with yum - - -DESCRIPTION ------------ -Yum is usually used on the Fedora distribution to manage packages. -If you specify an unknown package, yum will display the -slightly confusing error message "Error: Nothing to do". - - -REQUIRED PARAMETERS -------------------- -None - - -OPTIONAL PARAMETERS -------------------- -name - If supplied, use the name and not the object id as the package name. - -state - Either "present" or "absent", defaults to "present" -url - URL to use for the package - - -EXAMPLES --------- - -.. code-block:: sh - - # Ensure zsh in installed - __package_yum zsh --state present - - # If you don't want to follow pythonX packages, but always use python - __package_yum python --state present --name python2 - - # Remove obsolete package - __package_yum puppet --state absent - - __package epel-release-6-8 \ - --url http://mirror.switch.ch/ftp/mirror/epel/6/i386/epel-release-6-8.noarch.rpm - - -SEE ALSO --------- -:strong:`cdist-type__package`\ (7) - - -AUTHORS -------- -Nico Schottelius - - -COPYING -------- -Copyright \(C) 2011-2012 Nico Schottelius. 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. diff --git a/cdist/conf/type/__package_yum/man.text b/cdist/conf/type/__package_yum/man.text new file mode 100644 index 00000000..65e1be67 --- /dev/null +++ b/cdist/conf/type/__package_yum/man.text @@ -0,0 +1,61 @@ +cdist-type__package_yum(7) +========================== +Nico Schottelius + + +NAME +---- +cdist-type__package_yum - Manage packages with yum + + +DESCRIPTION +----------- +Yum is usually used on the Fedora distribution to manage packages. +If you specify an unknown package, yum will display the +slightly confusing error message "Error: Nothing to do". + + +REQUIRED PARAMETERS +------------------- +None + + +OPTIONAL PARAMETERS +------------------- +name:: + If supplied, use the name and not the object id as the package name. + +state:: + Either "present" or "absent", defaults to "present" +url:: + URL to use for the package + + +EXAMPLES +-------- + +-------------------------------------------------------------------------------- +# Ensure zsh in installed +__package_yum zsh --state present + +# If you don't want to follow pythonX packages, but always use python +__package_yum python --state present --name python2 + +# Remove obsolete package +__package_yum puppet --state absent + +__package epel-release-6-8 \ + --url http://mirror.switch.ch/ftp/mirror/epel/6/i386/epel-release-6-8.noarch.rpm +-------------------------------------------------------------------------------- + + +SEE ALSO +-------- +- cdist-type(7) +- cdist-type__package(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/cdist/conf/type/__package_yum/nonparallel b/cdist/conf/type/__package_yum/nonparallel deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/conf/type/__package_zypper/explorer/pkg_version b/cdist/conf/type/__package_zypper/explorer/pkg_version index 83bf6dab..7f203067 100644 --- a/cdist/conf/type/__package_zypper/explorer/pkg_version +++ b/cdist/conf/type/__package_zypper/explorer/pkg_version @@ -42,7 +42,7 @@ case "$ptype" in zypper search --match-exact --installed-only --type "$ptype" "$name" | grep -E '^i' | cut -d " " -f 3 || true ;; *) - echo "unknown ptype in __package_zypper explorer" >&2 + echo "unknown ptype in __package_zypper explorer" &>2 exit 1 ;; esac diff --git a/cdist/conf/type/__package_zypper/gencode-remote b/cdist/conf/type/__package_zypper/gencode-remote old mode 100755 new mode 100644 index e45dd9ff..d9f16f8d --- a/cdist/conf/type/__package_zypper/gencode-remote +++ b/cdist/conf/type/__package_zypper/gencode-remote @@ -1,4 +1,4 @@ -#!/bin/sh -e +#!/bin/sh # # 2012 Nico Schottelius (nico-cdist at schottelius.org) # 2013 Daniel Heule (hda at sfs.biz) @@ -61,18 +61,15 @@ case "$state_should" in present) if [ -z "$version_should" ]; then [ "$state_is" = "present" ] && exit 0 # if state is present, we dont need to do anything - echo "zypper $globalopts install --type '$ptype' --auto-agree-with-licenses '$name' >/dev/null" - echo "removed" >> "$__messages_out" + echo zypper $globalopts install --type \"$ptype\" --auto-agree-with-licenses \"$name\" ">/dev/null" else [ "$state_is" = "present" ] && [ "$version_should" = "$version_is" ] && exit 0 # if state is present and version is correct, we dont need to do anything - echo "zypper $globalopts install --oldpackage --type '$ptype' --auto-agree-with-licenses '$name' = '$version_should' >/dev/null" - echo "installed" >> "$__messages_out" + echo zypper $globalopts install --oldpackage --type \"$ptype\" --auto-agree-with-licenses \"$name\" = \"$version_should\" ">/dev/null" fi ;; absent) [ "$state_is" = "absent" ] && exit 0 # if state is absent, we dont need to do anything - echo "zypper $globalopts remove --type '$ptype' '$name' >/dev/null" - echo "removed" >> "$__messages_out" + echo zypper $globalopts remove --type \"$ptype\" \"$name\" ">/dev/null" ;; *) echo "Unknown state: $state_should" >&2 diff --git a/cdist/conf/type/__package_zypper/man.rst b/cdist/conf/type/__package_zypper/man.rst deleted file mode 100644 index 0051359b..00000000 --- a/cdist/conf/type/__package_zypper/man.rst +++ /dev/null @@ -1,73 +0,0 @@ -cdist-type__package_zypper(7) -============================= - -NAME ----- -cdist-type__package_zypper - Manage packages with zypper - - -DESCRIPTION ------------ -Zypper is usually used on the SuSE distribution to manage packages. - - -REQUIRED PARAMETERS -------------------- -None - - -OPTIONAL PARAMETERS -------------------- -name - If supplied, use the name and not the object id as the package name. - -state - Either "present" or "absent", defaults to "present" - -version - The version of the package to install. Default is to install the version - chosen by the local package manager. For a list of available versions, - have a look at the output of "zypper se -s packagename" - -ptype - Either "package", "patch", "pattern", "product" or "srcpackage", defaults to "package". For a description see man zypper. - - -EXAMPLES --------- - -.. code-block:: sh - - # Ensure zsh is installed - __package_zypper zsh --state present - - # If you don't want to follow pythonX packages, but always use python - __package_zypper python --state present --name python2 - - # Ensure binutils is installed and the version is forced to be 2.23.1-0.19.2 - __package_zypper binutils --state present --version 2.23.1-0.19.2 - - # Remove package - __package_zypper cfengine --state absent - - # install all packages which belongs to pattern x11 - __package_zypper x11 --ptype pattern --state present - - -SEE ALSO --------- -:strong:`cdist-type__package`\ (7) - - -AUTHORS -------- -Daniel Heule - - -COPYING -------- -Copyright \(C) 2012 Nico Schottelius. -Copyright \(C) 2013 Daniel Heule. -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. diff --git a/cdist/conf/type/__package_zypper/man.text b/cdist/conf/type/__package_zypper/man.text new file mode 100644 index 00000000..104d3a7a --- /dev/null +++ b/cdist/conf/type/__package_zypper/man.text @@ -0,0 +1,69 @@ +cdist-type__package_zypper(7) +============================= +Daniel Heule + + +NAME +---- +cdist-type__package_zypper - Manage packages with zypper + + +DESCRIPTION +----------- +Zypper is usually used on the SuSE distribution to manage packages. + + +REQUIRED PARAMETERS +------------------- +None + + +OPTIONAL PARAMETERS +------------------- +name:: + If supplied, use the name and not the object id as the package name. + +state:: + Either "present" or "absent", defaults to "present" + +version:: + The version of the package to install. Default is to install the version + choosen by the local package manager. For a list of available versions, + have a look at the output of "zypper se -s packagename" + +ptype:: + Either "package", "patch", "pattern", "product" or "srcpackage", defaults to "package". For a description see man zypper. + + +EXAMPLES +-------- + +-------------------------------------------------------------------------------- +# Ensure zsh is installed +__package_zypper zsh --state present + +# If you don't want to follow pythonX packages, but always use python +__package_zypper python --state present --name python2 + +# Ensure binutils is installed and the version is forced to be 2.23.1-0.19.2 +__package_zypper binutils --state present --version 2.23.1-0.19.2 + +# Remove package +__package_zypper cfengine --state absent + +# install all packages which belongs to pattern x11 +__package_zypper x11 --ptype pattern --state present +-------------------------------------------------------------------------------- + + +SEE ALSO +-------- +- cdist-type(7) +- cdist-type__package(7) + + +COPYING +------- +Copyright \(C) 2012 Nico Schottelius. +Copyright \(C) 2013 Daniel Heule. +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/__package_zypper/nonparallel b/cdist/conf/type/__package_zypper/nonparallel deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/conf/type/__pacman_conf/man.rst b/cdist/conf/type/__pacman_conf/man.rst deleted file mode 100644 index 6b8adfc9..00000000 --- a/cdist/conf/type/__pacman_conf/man.rst +++ /dev/null @@ -1,75 +0,0 @@ -cdist-type__pacman_conf(7) -========================== - -NAME ----- -cdist-type__pacman_conf - Manage pacman configuration - - -DESCRIPTION ------------ -The type allows you to configure options section, add or delete repositories and manage mirrorlists - - -REQUIRED PARAMETERS -------------------- -section - 'options' for configure options section - - Otherwise it specifies a repository or a plain file - -key - Specifies the key which will be set - - If section = 'options' or file is not set the key will - be checked against available keys from pacman.conf - -value - Specifies the value which will be set against the key - - -OPTIONAL PARAMETERS -------------------- -state - 'present' or 'absent', defaults to 'present' - -file - Specifies the filename. - - The managed file will be named like 'plain_file_filename' - - If supplied the key will not be checked. - - -EXAMPLES --------- - -.. code-block:: sh - - # Manage options section in pacman.conf - __pacman_conf options_Architecture --section options --key Architecture --value auto - - # Add new repository - __pacman_conf localrepo_Server --section localrepo --key Server --value "file:///var/cache/pacman/pkg" - - # Add mirror to a mirrorlist - __pacman_conf customlist_Server --file customlist --section customlist --key Server\ - --value "file:///var/cache/pacman/pkg" - - -SEE ALSO --------- -:strong:`grep`\ (1) - - -AUTHORS -------- -Dominique Roux - - -COPYING -------- -Copyright \(C) 2015 Dominique Roux. 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. diff --git a/cdist/conf/type/__pacman_conf/manifest b/cdist/conf/type/__pacman_conf/manifest deleted file mode 100755 index a43f18a1..00000000 --- a/cdist/conf/type/__pacman_conf/manifest +++ /dev/null @@ -1,133 +0,0 @@ -#!/bin/sh -e -# -# 2015 Dominique Roux (dominique.roux4 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 . -# - -#get params -section=$(cat "$__object/parameter/section") -key=$(cat "$__object/parameter/key") -value=$(cat "$__object/parameter/value") -file=$(cat "$__object/parameter/file" 2>/dev/null) -state=$(cat "$__object/parameter/state" 2>/dev/null) - -#path variable default /etc/pacman.d -sec_path="/etc/pacman.d" - -#allowed keys (from man pacman.conf) -allowed_option_keys="RootDir DBPath CacheDir GPGDir LogFile HoldPkg IgnorePkg IgnoreGroup Include Architecture XferCommand NoUpgrade NoExtract CleanMethod SigLevel LocalFileSigLevel RemoteFileSigLevel" -boolean_option_keys="UseSyslog Color UseDelta TotalDownload CheckSpace VerbosePkgLists" -allowed_repo_keys="Include Server SigLevel Usage" - -#set global variables -MATCH=0 - -#function for check if array contain string -contains_element() { - - MATCH=0 - - target=$1 - shift - - for key in "$@"; do - if [ "${key}" = "${target}" ]; then - MATCH=1 - return 0 - fi - done - MATCH=0 -} - -if [ "${file}" ]; then - __file "${sec_path}/plain_file_${file}"\ - --state exists --mode 666 - - if [ "${state}" = "present" ]; then - - require="__file/${sec_path}/plain_file_${file}" __key_value "${file}_${key}" \ - --file "${sec_path}/plain_file_${file}" --key "${key}" --value "${value}" --delimiter ' = ' - - exit 0 - - elif [ "${state}" = "absent" ]; then - require="__file/${sec_path}/plain_file_${file}" __key_value "${file}_${key}" \ - --state absent - exit 0 - - else - echo "ERROR: Unknown state: ${state}" >&2 - exit 0 - fi -fi - -if [ "${section}" = "options" ]; then - - __file "${sec_path}/${section}"\ - --state exists --mode 666 --source - << eof -[${section}] -eof - #check if key is valid - #check for boolean value - contains_element "${key}" "${boolean_option_keys}" - - if [ "${MATCH}" -eq 1 ]; then - if [ "${value}" = "on" ]; then - require="__file/${sec_path}/${section}" __line "${key}_${value}" \ - --file "${sec_path}/${section}" --line "${key}" - elif [ "${value}" = "off" ]; then - require="__file/${sec_path}/${section}" __line "${key}_${value}" \ - --file "${sec_path}/${section}" --line "${key}" --state absent - fi - - else - contains_element "${key}" "${allowed_option_keys}" - - if [ "${MATCH}" -eq 1 ]; then - require="__file/${sec_path}/${section}" __key_value "${section}_${key}" \ - --file "${sec_path}/${section}" --key "${key}" --value "${value}" --delimiter ' = ' - else - echo "Key: ${key} is not valid. Have a look at man pacman.conf" >&2 - fi - fi - -else - __file "${sec_path}/repo_${section}"\ - --state exists --mode 666 --source - << eof -[${section}] -eof - if [ "${state}" = "present" ]; then - - #check if key is valid - contains_element "${key}" "${allowed_repo_keys}" - if [ ${MATCH} -eq 0 ]; then - exit - fi - - require="__file/${sec_path}/repo_${section}" __key_value "${section}_${key}" \ - --file "${sec_path}/repo_${section}" --key "${key}" --value "${value}" --delimiter ' = ' - - elif [ "${state}" = "absent" ]; then - - require="__file/${sec_path}/repo_${section}" __key_value "${section}_${key}" \ - --state absent - - else - echo "ERROR: Unknown state: ${state}" >&2 - fi - -fi diff --git a/cdist/conf/type/__pacman_conf/parameter/default/file b/cdist/conf/type/__pacman_conf/parameter/default/file deleted file mode 100644 index 139597f9..00000000 --- a/cdist/conf/type/__pacman_conf/parameter/default/file +++ /dev/null @@ -1,2 +0,0 @@ - - diff --git a/cdist/conf/type/__pacman_conf/parameter/default/state b/cdist/conf/type/__pacman_conf/parameter/default/state deleted file mode 100644 index e7f6134f..00000000 --- a/cdist/conf/type/__pacman_conf/parameter/default/state +++ /dev/null @@ -1 +0,0 @@ -present diff --git a/cdist/conf/type/__pacman_conf/parameter/optional b/cdist/conf/type/__pacman_conf/parameter/optional deleted file mode 100644 index 5d52aa2e..00000000 --- a/cdist/conf/type/__pacman_conf/parameter/optional +++ /dev/null @@ -1,2 +0,0 @@ -file -state diff --git a/cdist/conf/type/__pacman_conf/parameter/required b/cdist/conf/type/__pacman_conf/parameter/required deleted file mode 100644 index 2f9d59e0..00000000 --- a/cdist/conf/type/__pacman_conf/parameter/required +++ /dev/null @@ -1,3 +0,0 @@ -section -key -value diff --git a/cdist/conf/type/__pacman_conf_integrate/files/mirrorlist b/cdist/conf/type/__pacman_conf_integrate/files/mirrorlist deleted file mode 100644 index a378fb50..00000000 --- a/cdist/conf/type/__pacman_conf_integrate/files/mirrorlist +++ /dev/null @@ -1,344 +0,0 @@ -## -## Arch Linux repository mirrorlist -## Generated on 2015-03-15 -## - -## Worldwide -#Server = http://mirror.rackspace.com/archlinux/$repo/os/$arch - -## Australia -#Server = http://mirror.aarnet.edu.au/pub/archlinux/$repo/os/$arch -#Server = http://archlinux.mirror.digitalpacific.com.au/$repo/os/$arch -#Server = http://ftp.iinet.net.au/pub/archlinux/$repo/os/$arch -#Server = http://mirror.internode.on.net/pub/archlinux/$repo/os/$arch -#Server = http://mirror.rackcentral.com.au/archlinux/$repo/os/$arch -#Server = http://ftp.swin.edu.au/archlinux/$repo/os/$arch -#Server = http://archlinux.mirror.uber.com.au/$repo/os/$arch - -## Austria -#Server = http://mirror.easyname.at/archlinux/$repo/os/$arch -#Server = http://mirror1.htu.tugraz.at/archlinux/$repo/os/$arch - -## Bangladesh -#Server = http://mirrors.ispros.com.bd/archlinux/$repo/os/$arch - -## Belarus -#Server = http://ftp.byfly.by/pub/archlinux/$repo/os/$arch -#Server = http://mirror.datacenter.by/pub/archlinux/$repo/os/$arch - -## Belgium -#Server = http://archlinux.cu.be/$repo/os/$arch -#Server = http://archlinux.mirror.kangaroot.net/$repo/os/$arch - -## Brazil -#Server = http://archlinux.c3sl.ufpr.br/$repo/os/$arch -#Server = http://www.las.ic.unicamp.br/pub/archlinux/$repo/os/$arch -#Server = http://pet.inf.ufsc.br/mirrors/archlinux/$repo/os/$arch - -## Bulgaria -#Server = http://mirror.telepoint.bg/archlinux/$repo/os/$arch - -## Canada -#Server = http://archlinux.dropswitch.net/archlinux/$repo/os/$arch -#Server = http://mirror.clibre.uqam.ca/archlinux/$repo/os/$arch -#Server = http://mirror.csclub.uwaterloo.ca/archlinux/$repo/os/$arch -#Server = http://mirror.its.dal.ca/archlinux/$repo/os/$arch -#Server = http://archlinux.mirror.rafal.ca/$repo/os/$arch -#Server = http://archlinux.mirror.vexxhost.com/$repo/os/$arch - -## Chile -#Server = http://mirror.archlinux.cl/$repo/os/$arch - -## China -#Server = http://mirrors.163.com/archlinux/$repo/os/$arch -#Server = http://mirror.bjtu.edu.cn/archlinux/$repo/os/$arch -#Server = http://mirrors.cqu.edu.cn/archlinux/$repo/os/$arch -#Server = http://mirrors.hust.edu.cn/archlinux/$repo/os/$arch -#Server = http://mirrors.hustunique.com/archlinux/$repo/os/$arch -#Server = http://mirrors.neusoft.edu.cn/archlinux/$repo/os/$arch -#Server = http://run.hit.edu.cn/archlinux/$repo/os/$arch -#Server = http://mirrors.tuna.tsinghua.edu.cn/archlinux/$repo/os/$arch -#Server = http://mirrors.ustc.edu.cn/archlinux/$repo/os/$arch -#Server = https://mirrors.ustc.edu.cn/archlinux/$repo/os/$arch -#Server = http://mirrors.zju.edu.cn/archlinux/$repo/os/$arch - -## Colombia -#Server = http://mirror.edatel.net.co/archlinux/$repo/os/$arch -#Server = http://www.laqee.unal.edu.co/archlinux/$repo/os/$arch - -## Croatia -#Server = http://archlinux.iskon.hr/$repo/os/$arch - -## Czech Republic -#Server = http://archlinux.mirror.dkm.cz/pub/archlinux/$repo/os/$arch -#Server = http://gluttony.sin.cvut.cz/arch/$repo/os/$arch -#Server = http://mirror.oss.maxcdn.com/archlinux/$repo/os/$arch -#Server = http://mirrors.nic.cz/archlinux/$repo/os/$arch -#Server = http://mirror.vpsfree.cz/archlinux/$repo/os/$arch - -## Denmark -#Server = http://mirrors.dotsrc.org/archlinux/$repo/os/$arch -#Server = http://mirror.one.com/archlinux/$repo/os/$arch - -## Ecuador -#Server = http://mirror.cedia.org.ec/archlinux/$repo/os/$arch -#Server = http://mirror.espoch.edu.ec/archlinux/$repo/os/$arch -#Server = http://mirror.uta.edu.ec/archlinux/$repo/os/$arch - -## Estonia -#Server = http://ftp.eenet.ee/pub/archlinux/$repo/os/$arch - -## France -#Server = http://archlinux.aubrac-medical.fr/$repo/os/$arch -#Server = http://mirror.archlinux.ikoula.com/archlinux/$repo/os/$arch -#Server = http://archlinux.vi-di.fr/$repo/os/$arch -#Server = http://mir.art-software.fr/arch/$repo/os/$arch -#Server = http://fooo.biz/archlinux/$repo/os/$arch -#Server = https://fooo.biz/archlinux/$repo/os/$arch -#Server = http://mirror.lastmikoi.net/archlinux/$repo/os/$arch -#Server = http://mirror.lightcone.eu/archlinux/$repo/os/$arch -#Server = http://archlinux.mailtunnel.eu/$repo/os/$arch -#Server = https://www.mailtunnel.eu/archlinux/$repo/os/$arch -#Server = http://mir.archlinux.fr/$repo/os/$arch -#Server = http://arch.nimukaito.net/$repo/os/$arch -#Server = http://archlinux.mirrors.ovh.net/archlinux/$repo/os/$arch -#Server = http://archlinux.mirror.pkern.at/$repo/os/$arch -#Server = https://archlinux.mirror.pkern.at/$repo/os/$arch -#Server = http://archlinux.polymorf.fr/$repo/os/$arch -#Server = http://arch.static.lu/$repo/os/$arch -#Server = https://arch.static.lu/$repo/os/$arch -#Server = http://arch.tamcore.eu/$repo/os/$arch -#Server = http://mirror.tyborek.pl/arch/$repo/os/$arch -#Server = http://ftp.u-strasbg.fr/linux/distributions/archlinux/$repo/os/$arch -#Server = http://arch.yourlabs.org/$repo/os/$arch - -## Germany -#Server = http://mirror.23media.de/archlinux/$repo/os/$arch -#Server = http://archlinux.limun.org/$repo/os/$arch -#Server = https://archlinux.limun.org/$repo/os/$arch -#Server = http://artfiles.org/archlinux.org/$repo/os/$arch -#Server = http://ftp.fau.de/archlinux/$repo/os/$arch -#Server = https://ftp.fau.de/archlinux/$repo/os/$arch -#Server = http://mirror.flipez.de/archlinux/$repo/os/$arch -#Server = http://mirror.fluxent.de/archlinux/$repo/os/$arch -#Server = http://mirror.gnomus.de/$repo/os/$arch -#Server = http://arch.packages.gnp-tec.net/$repo/os/$arch -#Server = http://ftp5.gwdg.de/pub/linux/archlinux/$repo/os/$arch -#Server = http://mirror.hactar.bz/$repo/os/$arch -#Server = http://ftp.hawo.stw.uni-erlangen.de/archlinux/$repo/os/$arch -#Server = http://ftp.hosteurope.de/mirror/ftp.archlinux.org/$repo/os/$arch -#Server = http://ftp-stud.hs-esslingen.de/pub/Mirrors/archlinux/$repo/os/$arch -#Server = http://mirror.js-webcoding.de/pub/archlinux/$repo/os/$arch -#Server = http://mirror.k42.ch/archlinux/$repo/os/$arch -#Server = http://mirror.de.leaseweb.net/archlinux/$repo/os/$arch -#Server = http://mirror.metalgamer.eu/archlinux/$repo/os/$arch -#Server = http://mirror.michael-eckert.net/archlinux/$repo/os/$arch -#Server = http://archlinux.my-universe.com/$repo/os/$arch -#Server = https://archlinux.my-universe.com/$repo/os/$arch -#Server = http://mirrors.n-ix.net/archlinux/$repo/os/$arch -#Server = http://mirror.netcologne.de/archlinux/$repo/os/$arch -#Server = http://mirrors.niyawe.de/archlinux/$repo/os/$arch -#Server = http://ftp.halifax.rwth-aachen.de/archlinux/$repo/os/$arch -#Server = http://linux.rz.rub.de/archlinux/$repo/os/$arch -#Server = http://mirror.selfnet.de/archlinux/$repo/os/$arch -#Server = http://ftp.spline.inf.fu-berlin.de/mirrors/archlinux/$repo/os/$arch -#Server = http://ftp.tu-chemnitz.de/pub/linux/archlinux/$repo/os/$arch -#Server = http://ftp.tuxdroid.org/archlinux/$repo/os/$arch -#Server = http://ftp.uni-bayreuth.de/linux/archlinux/$repo/os/$arch -#Server = http://ftp.uni-hannover.de/archlinux/$repo/os/$arch -#Server = http://ftp.uni-kl.de/pub/linux/archlinux/$repo/os/$arch -#Server = http://mirror.united-gameserver.de/archlinux/$repo/os/$arch - -## Greece -#Server = http://ftp.cc.uoc.gr/mirrors/linux/archlinux/$repo/os/$arch -#Server = http://foss.aueb.gr/mirrors/linux/archlinux/$repo/os/$arch -#Server = https://foss.aueb.gr/mirrors/linux/archlinux/$repo/os/$arch -#Server = http://mirrors.myaegean.gr/linux/archlinux/$repo/os/$arch -#Server = http://ftp.ntua.gr/pub/linux/archlinux/$repo/os/$arch -#Server = http://ftp.otenet.gr/linux/archlinux/$repo/os/$arch - -## Hungary -#Server = http://ftp.mfa.kfki.hu/pub/mirrors/ftp.archlinux.org/$repo/os/$arch - -## Iceland -#Server = http://mirror.system.is/arch/$repo/os/$arch -#Server = https://mirror.system.is/arch/$repo/os/$arch - -## India -#Server = http://mirror.cse.iitk.ac.in/archlinux/$repo/os/$arch -#Server = http://ftp.iitm.ac.in/archlinux/$repo/os/$arch - -## Indonesia -#Server = http://mirror.kavalinux.com/archlinux/$repo/os/$arch -#Server = http://mirror.poliwangi.ac.id/archlinux/$repo/os/$arch -#Server = http://suro.ubaya.ac.id/archlinux/$repo/os/$arch - -## Iran -#Server = http://mirror.yazd.ac.ir/arch/$repo/os/$arch - -## Ireland -#Server = http://ftp.heanet.ie/mirrors/ftp.archlinux.org/$repo/os/$arch - -## Israel -#Server = http://mirror.isoc.org.il/pub/archlinux/$repo/os/$arch - -## Italy -#Server = http://archlinux.openlabto.org/archlinux/$repo/os/$arch -#Server = http://archlinux.beccacervello.it/archlinux/$repo/os/$arch -#Server = http://mirrors.prometeus.net/archlinux/$repo/os/$arch - -## Japan -#Server = http://ftp.tsukuba.wide.ad.jp/Linux/archlinux/$repo/os/$arch -#Server = http://ftp.jaist.ac.jp/pub/Linux/ArchLinux/$repo/os/$arch - -## Kazakhstan -#Server = http://mirror.neolabs.kz/archlinux/$repo/os/$arch - -## Latvia -#Server = http://archlinux.koyanet.lv/archlinux/$repo/os/$arch - -## Lithuania -#Server = http://archlinux.akmc.lt/$repo/os/$arch -#Server = http://atviras.lt/veidrodziai/archlinux/$repo/os/$arch - -## Luxembourg -#Server = http://archlinux.mirror.root.lu/$repo/os/$arch - -## Macedonia -#Server = http://arch.softver.org.mk/archlinux/$repo/os/$arch -#Server = http://mirror.t-home.mk/archlinux/$repo/os/$arch - -## Netherlands -#Server = http://arch.apt-get.eu/$repo/os/$arch -#Server = http://mirror.i3d.net/pub/archlinux/$repo/os/$arch -#Server = https://mirror.i3d.net/pub/archlinux/$repo/os/$arch -#Server = http://mirror.nl.leaseweb.net/archlinux/$repo/os/$arch -#Server = http://ftp.nluug.nl/os/Linux/distr/archlinux/$repo/os/$arch -#Server = http://ftp.snt.utwente.nl/pub/os/linux/archlinux/$repo/os/$arch - -## New Caledonia -#Server = http://mirror.lagoon.nc/pub/archlinux/$repo/os/$arch -#Server = http://archlinux.nautile.nc/archlinux/$repo/os/$arch - -## New Zealand -#Server = http://mirror.xnet.co.nz/pub/archlinux/$repo/os/$arch - -## Norway -#Server = http://mirror.archlinux.no/$repo/os/$arch -#Server = http://archlinux.uib.no/$repo/os/$arch -#Server = http://archlinux.neuf.no/$repo/os/$arch - -## Philippines -#Server = http://mirror.pregi.net/pub/Linux/archlinux/$repo/os/$arch - -## Poland -#Server = http://mirror.chmuri.net/archmirror/$repo/os/$arch -#Server = http://arch.midov.pl/arch/$repo/os/$arch -#Server = http://piotrkosoft.net/pub/mirrors/ftp.archlinux.org/$repo/os/$arch -#Server = http://ftp.vectranet.pl/archlinux/$repo/os/$arch - -## Portugal -#Server = http://archlinux.dcc.fc.up.pt/$repo/os/$arch -#Server = http://ftp.rnl.tecnico.ulisboa.pt/pub/archlinux/$repo/os/$arch - -## Romania -#Server = http://mirror.archlinux.ro/archlinux/$repo/os/$arch -#Server = http://archlinux.mirrors.linux.ro/$repo/os/$arch - -## Russia -#Server = http://mirror.rol.ru/archlinux/$repo/os/$arch -#Server = http://mirror.yandex.ru/archlinux/$repo/os/$arch - -## Serbia -#Server = http://mirror.pmf.kg.ac.rs/archlinux/$repo/os/$arch - -## Singapore -#Server = http://download.nus.edu.sg/mirror/arch/$repo/os/$arch -#Server = http://mirror.nus.edu.sg/archlinux/$repo/os/$arch - -## Slovakia -#Server = http://mirror.lnx.sk/pub/linux/archlinux/$repo/os/$arch -#Server = http://tux.rainside.sk/archlinux/$repo/os/$arch - -## South Africa -#Server = http://ftp.wa.co.za/pub/archlinux/$repo/os/$arch - -## South Korea -#Server = http://ftp.kaist.ac.kr/ArchLinux/$repo/os/$arch -#Server = http://mirror.premi.st/archlinux/$repo/os/$arch - -## Spain -#Server = http://osl.ugr.es/archlinux/$repo/os/$arch -#Server = http://sunsite.rediris.es/mirror/archlinux/$repo/os/$arch - -## Sweden -#Server = http://ftp.df.lth.se/pub/archlinux/$repo/os/$arch -#Server = http://ftp.lysator.liu.se/pub/archlinux/$repo/os/$arch -#Server = https://ftp.lysator.liu.se/pub/archlinux/$repo/os/$arch -#Server = http://ftp.myrveln.se/pub/linux/archlinux/$repo/os/$arch -#Server = http://ftp.portlane.com/pub/os/linux/archlinux/$repo/os/$arch - -## Switzerland -#Server = http://archlinux.puzzle.ch/$repo/os/$arch - -## Taiwan -#Server = http://archlinux.cs.nctu.edu.tw/$repo/os/$arch -#Server = http://shadow.ind.ntou.edu.tw/archlinux/$repo/os/$arch -#Server = http://ftp.tku.edu.tw/Linux/ArchLinux/$repo/os/$arch -#Server = http://ftp.yzu.edu.tw/Linux/archlinux/$repo/os/$arch - -## Turkey -#Server = http://ftp.linux.org.tr/archlinux/$repo/os/$arch - -## Ukraine -#Server = http://mirrors.nix.org.ua/linux/archlinux/$repo/os/$arch - -## United Kingdom -#Server = http://mirror.bytemark.co.uk/archlinux/$repo/os/$arch -#Server = http://mirror.cinosure.com/archlinux/$repo/os/$arch -#Server = http://mirrors.manchester.m247.com/arch-linux/$repo/os/$arch -#Server = http://www.mirrorservice.org/sites/ftp.archlinux.org/$repo/os/$arch -#Server = http://arch.serverspace.co.uk/arch/$repo/os/$arch -#Server = http://archlinux.mirrors.uk2.net/$repo/os/$arch - -## United States -#Server = http://mirrors.abscission.net/archlinux/$repo/os/$arch -#Server = http://mirrors.acm.wpi.edu/archlinux/$repo/os/$arch -#Server = http://mirrors.advancedhosters.com/archlinux/$repo/os/$arch -#Server = http://mirrors.aggregate.org/archlinux/$repo/os/$arch -#Server = http://archlinux.surlyjake.com/archlinux/$repo/os/$arch -#Server = http://mirrors.cat.pdx.edu/archlinux/$repo/os/$arch -#Server = http://mirror.cc.columbia.edu/pub/linux/archlinux/$repo/os/$arch -#Server = http://mirrors.cdndepo.com/archlinux/$repo/os/$arch -#Server = https://mirrors.cdndepo.com/archlinux/$repo/os/$arch -#Server = http://mirrors.cecsresearch.org/archlinux/$repo/os/$arch -#Server = http://cosmos.cites.illinois.edu/pub/archlinux/$repo/os/$arch -#Server = http://mirror.cs.pitt.edu/archlinux/$repo/os/$arch -#Server = http://mirror.es.its.nyu.edu/archlinux/$repo/os/$arch -#Server = http://mirrors.gigenet.com/archlinux/$repo/os/$arch -#Server = http://mirror.grig.io/archlinux/$repo/os/$arch -#Server = http://www.gtlib.gatech.edu/pub/archlinux/$repo/os/$arch -#Server = http://mirror.ancl.hawaii.edu/linux/archlinux/$repo/os/$arch -#Server = http://mirror.jmu.edu/pub/archlinux/$repo/os/$arch -#Server = http://mirrors.kernel.org/archlinux/$repo/os/$arch -#Server = https://mirrors.kernel.org/archlinux/$repo/os/$arch -#Server = http://mirror.us.leaseweb.net/archlinux/$repo/os/$arch -#Server = http://mirrors.liquidweb.com/archlinux/$repo/os/$arch -#Server = http://arch.localmsp.org/arch/$repo/os/$arch -#Server = https://arch.localmsp.org/arch/$repo/os/$arch -#Server = http://lug.mtu.edu/archlinux/$repo/os/$arch -#Server = http://mirror.metrocast.net/archlinux/$repo/os/$arch -#Server = http://mirror.nexcess.net/archlinux/$repo/os/$arch -#Server = http://ftp.osuosl.org/pub/archlinux/$repo/os/$arch -#Server = http://archlinux.pallissard.net/archlinux/$repo/os/$arch -#Server = http://mirror.rit.edu/archlinux/$repo/os/$arch -#Server = http://mirrors.rutgers.edu/archlinux/$repo/os/$arch -#Server = http://mirror.umd.edu/archlinux/$repo/os/$arch -#Server = http://mirror.vtti.vt.edu/archlinux/$repo/os/$arch -#Server = http://mirrors.xmission.com/archlinux/$repo/os/$arch -#Server = http://mirror.yellowfiber.net/archlinux/$repo/os/$arch - -## Vietnam -#Server = http://f.archlinuxvn.org/archlinux/$repo/os/$arch -#Server = http://mirror-fpt-telecom.fpt.net/archlinux/$repo/os/$arch - diff --git a/cdist/conf/type/__pacman_conf_integrate/files/options b/cdist/conf/type/__pacman_conf_integrate/files/options deleted file mode 100644 index 68273e49..00000000 --- a/cdist/conf/type/__pacman_conf_integrate/files/options +++ /dev/null @@ -1,6 +0,0 @@ -[options] -HoldPkg = pacman glibc -Architecture = auto -CheckSpace -SigLevel = Required DatabaseOptional -LocalFileSigLevel = Optional diff --git a/cdist/conf/type/__pacman_conf_integrate/files/pacman.conf.cdist b/cdist/conf/type/__pacman_conf_integrate/files/pacman.conf.cdist deleted file mode 100644 index 88e6e623..00000000 --- a/cdist/conf/type/__pacman_conf_integrate/files/pacman.conf.cdist +++ /dev/null @@ -1,6 +0,0 @@ -# -# cdist managed - do not change -# -Include = /etc/pacman.d/options -Include = /etc/pacman.d/repo_* -Include = /etc/pacman.d/plain_file_* diff --git a/cdist/conf/type/__pacman_conf_integrate/files/pacman.conf.pacman b/cdist/conf/type/__pacman_conf_integrate/files/pacman.conf.pacman deleted file mode 100644 index f43fe397..00000000 --- a/cdist/conf/type/__pacman_conf_integrate/files/pacman.conf.pacman +++ /dev/null @@ -1,99 +0,0 @@ -# -# /etc/pacman.conf -# -# See the pacman.conf(5) manpage for option and repository directives - -# -# GENERAL OPTIONS -# -[options] -# The following paths are commented out with their default values listed. -# If you wish to use different paths, uncomment and update the paths. -#RootDir = / -#DBPath = /var/lib/pacman/ -#CacheDir = /var/cache/pacman/pkg/ -#LogFile = /var/log/pacman.log -#GPGDir = /etc/pacman.d/gnupg/ -HoldPkg = pacman glibc -#XferCommand = /usr/bin/curl -C - -f %u > %o -#XferCommand = /usr/bin/wget --passive-ftp -c -O %o %u -#CleanMethod = KeepInstalled -#UseDelta = 0.7 -Architecture = auto - -# Pacman won't upgrade packages listed in IgnorePkg and members of IgnoreGroup -#IgnorePkg = -#IgnoreGroup = - -#NoUpgrade = -#NoExtract = - -# Misc options -#UseSyslog -#Color -#TotalDownload -CheckSpace -#VerbosePkgLists - -# By default, pacman accepts packages signed by keys that its local keyring -# trusts (see pacman-key and its man page), as well as unsigned packages. -SigLevel = Required DatabaseOptional -LocalFileSigLevel = Optional -#RemoteFileSigLevel = Required - -# NOTE: You must run `pacman-key --init` before first using pacman; the local -# keyring can then be populated with the keys of all official Arch Linux -# packagers with `pacman-key --populate archlinux`. - -# -# REPOSITORIES -# - can be defined here or included from another file -# - pacman will search repositories in the order defined here -# - local/custom mirrors can be added here or in separate files -# - repositories listed first will take precedence when packages -# have identical names, regardless of version number -# - URLs will have $repo replaced by the name of the current repo -# - URLs will have $arch replaced by the name of the architecture -# -# Repository entries are of the format: -# [repo-name] -# Server = ServerName -# Include = IncludePath -# -# The header [repo-name] is crucial - it must be present and -# uncommented to enable the repo. -# - -# The testing repositories are disabled by default. To enable, uncomment the -# repo name header and Include lines. You can add preferred servers immediately -# after the header, and they will be used before the default mirrors. - -#[testing] -#Include = /etc/pacman.d/mirrorlist - -[core] -Include = /etc/pacman.d/mirrorlist - -[extra] -Include = /etc/pacman.d/mirrorlist - -#[community-testing] -#Include = /etc/pacman.d/mirrorlist - -[community] -Include = /etc/pacman.d/mirrorlist - -# If you want to run 32 bit applications on your x86_64 system, -# enable the multilib repositories as required here. - -#[multilib-testing] -#Include = /etc/pacman.d/mirrorlist - -#[multilib] -#Include = /etc/pacman.d/mirrorlist - -# An example of a custom package repository. See the pacman manpage for -# tips on creating your own repositories. -#[custom] -#SigLevel = Optional TrustAll -#Server = file:///home/custompkgs diff --git a/cdist/conf/type/__pacman_conf_integrate/man.rst b/cdist/conf/type/__pacman_conf_integrate/man.rst deleted file mode 100644 index c21b56d8..00000000 --- a/cdist/conf/type/__pacman_conf_integrate/man.rst +++ /dev/null @@ -1,51 +0,0 @@ -cdist-type__pacman_conf_integrate(7) -==================================== - -NAME ----- -cdist-type__pacman_conf_integrate - Integrate default pacman.conf to cdist conform and vice versa - - -DESCRIPTION ------------ -The type allows you to convert the default pacman.conf to a cdist conform one and vice versa - - -REQUIRED PARAMETERS -------------------- -None. - -OPTIONAL PARAMETERS -------------------- -state - 'present' or 'absent', defaults to 'present' - - -EXAMPLES --------- - -.. code-block:: sh - - # Convert normal to cdist conform - __pacman_conf_integrate convert - - # Convert cdist conform to normal - __pacman_conf_integrate convert --state absent - - -SEE ALSO --------- -:strong:`grep`\ (1) - - -AUTHORS -------- -Dominique Roux - - -COPYING -------- -Copyright \(C) 2015 Dominique Roux. 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. diff --git a/cdist/conf/type/__pacman_conf_integrate/manifest b/cdist/conf/type/__pacman_conf_integrate/manifest deleted file mode 100755 index 0ce0bee5..00000000 --- a/cdist/conf/type/__pacman_conf_integrate/manifest +++ /dev/null @@ -1,57 +0,0 @@ -#!/bin/sh -e -# -# 2015 Dominique Roux (dominique.roux4 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 . -# - -state=$(cat "$__object/parameter/state" 2>/dev/null) - -if [ "${state}" = "present" ]; then - __file /etc/pacman.conf\ - --owner root --group root --mode 644 --source "$__type/files/pacman.conf.cdist" - - __file /etc/pacman.d/options\ - --owner root --group root --mode 644 --source "$__type/files/options" - - __file /etc/pacman.d/repo_empty_placeholder\ - --owner root --group root --mode 644 - - __file /etc/pacman.d/plain_file_empty_placeholder\ - --owner root --group root --mode 644 - -elif [ "${state}" = "absent" ]; then - - __file /etc/pacman.conf\ - --owner root --group root --mode 644 --source "$__type/files/pacman.conf.pacman" - - __file /etc/pacman.d/mirrorlist\ - --owner root --group root --mode 644 --source "$__type/files/mirrorlist" - - __file /etc/pacman.d/options\ - --state absent - - __file /etc/pacman.d/repo_empty_placeholder\ - --state absent - - __file /etc/pacman.d/plain_file_empty_placeholder\ - --state absent - -else - - echo "ERROR: Unknown state: ${state}" >&2 - -fi diff --git a/cdist/conf/type/__pacman_conf_integrate/parameter/default/state b/cdist/conf/type/__pacman_conf_integrate/parameter/default/state deleted file mode 100644 index e7f6134f..00000000 --- a/cdist/conf/type/__pacman_conf_integrate/parameter/default/state +++ /dev/null @@ -1 +0,0 @@ -present diff --git a/cdist/conf/type/__pacman_conf_integrate/parameter/optional b/cdist/conf/type/__pacman_conf_integrate/parameter/optional deleted file mode 100644 index ff72b5c7..00000000 --- a/cdist/conf/type/__pacman_conf_integrate/parameter/optional +++ /dev/null @@ -1 +0,0 @@ -state diff --git a/cdist/conf/type/__pf_apply/explorer/rcvar b/cdist/conf/type/__pf_apply/explorer/rcvar index 7c8d535f..20e9dfcc 100755 --- a/cdist/conf/type/__pf_apply/explorer/rcvar +++ b/cdist/conf/type/__pf_apply/explorer/rcvar @@ -29,7 +29,7 @@ RC="/etc/rc.conf" PFCONF="$(grep '^pf_rules=' ${RC} | cut -d= -f2 | sed 's/"//g')" -echo "${PFCONF:-"/etc/pf.conf"}" +echo ${PFCONF:-"/etc/pf.conf"} # Debug #set +x diff --git a/cdist/conf/type/__pf_apply/gencode-remote b/cdist/conf/type/__pf_apply/gencode-remote index c8f7a25a..f7c889b4 100755 --- a/cdist/conf/type/__pf_apply/gencode-remote +++ b/cdist/conf/type/__pf_apply/gencode-remote @@ -1,4 +1,4 @@ -#!/bin/sh -e +#!/bin/sh # # 2012 Jake Guffey (jake.guffey at eprotex.com) # diff --git a/cdist/conf/type/__pf_apply/man.rst b/cdist/conf/type/__pf_apply/man.rst deleted file mode 100644 index eee345e7..00000000 --- a/cdist/conf/type/__pf_apply/man.rst +++ /dev/null @@ -1,55 +0,0 @@ -cdist-type__pf_apply(7) -======================= - -NAME ----- -cdist-type__pf_apply - Apply pf(4) ruleset on \*BSD - - -DESCRIPTION ------------ -This type is used on \*BSD systems to manage the pf firewall's active ruleset. - - -REQUIRED PARAMETERS -------------------- -NONE - - -OPTIONAL PARAMETERS -------------------- -NONE - - -EXAMPLES --------- - -.. code-block:: sh - - # Modify the ruleset on $__target_host: - __pf_ruleset --state present --source /my/pf/ruleset.conf - require="__pf_ruleset" \ - __pf_apply - - # Remove the ruleset on $__target_host (implies disabling pf(4): - __pf_ruleset --state absent - require="__pf_ruleset" \ - __pf_apply - - -SEE ALSO --------- -:strong:`pf`\ (4), :strong:`cdist-type__pf_ruleset`\ (7) - - -AUTHORS -------- -Jake Guffey - - -COPYING -------- -Copyright \(C) 2012 Jake Guffey. 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. diff --git a/cdist/conf/type/__pf_apply/man.text b/cdist/conf/type/__pf_apply/man.text new file mode 100644 index 00000000..2e0d7802 --- /dev/null +++ b/cdist/conf/type/__pf_apply/man.text @@ -0,0 +1,52 @@ +cdist-type__pf_apply(7) +======================= +Jake Guffey + + +NAME +---- +cdist-type__pf_apply - Apply pf(4) ruleset on *BSD + + +DESCRIPTION +----------- +This type is used on *BSD systems to manage the pf firewall's active ruleset. + + +REQUIRED PARAMETERS +------------------- +NONE + + +OPTIONAL PARAMETERS +------------------- +NONE + + +EXAMPLES +-------- + +-------------------------------------------------------------------------------- +# Modify the ruleset on $__target_host: +__pf_ruleset --state present --source /my/pf/ruleset.conf +require="__pf_ruleset" \ + __pf_apply + +# Remove the ruleset on $__target_host (implies disabling pf(4): +__pf_ruleset --state absent +require="__pf_ruleset" \ + __pf_apply +-------------------------------------------------------------------------------- + + +SEE ALSO +-------- +- cdist-type(7) +- cdist-type__pf_ruleset(7) +- pf(4) + + +COPYING +------- +Copyright \(C) 2012 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/__pf_ruleset/explorer/cksum b/cdist/conf/type/__pf_ruleset/explorer/cksum index 9be6c901..f8679836 100755 --- a/cdist/conf/type/__pf_ruleset/explorer/cksum +++ b/cdist/conf/type/__pf_ruleset/explorer/cksum @@ -33,7 +33,7 @@ TMP="$(grep '^pf_rules=' ${RC} | cut -d= -f2 | sed 's/"//g')" PFCONF="${TMP:-"/etc/pf.conf"}" if [ -f "${PFCONF}" ]; then # The pf config file exists, find its cksum. - cksum -o 1 "${PFCONF}" | cut -d= -f2 | awk '{print $1}' + cksum -o 1 ${PFCONF} | cut -d= -f2 | awk '{print $1}' fi # Debug diff --git a/cdist/conf/type/__pf_ruleset/explorer/rcvar b/cdist/conf/type/__pf_ruleset/explorer/rcvar index 7c8d535f..20e9dfcc 100755 --- a/cdist/conf/type/__pf_ruleset/explorer/rcvar +++ b/cdist/conf/type/__pf_ruleset/explorer/rcvar @@ -29,7 +29,7 @@ RC="/etc/rc.conf" PFCONF="$(grep '^pf_rules=' ${RC} | cut -d= -f2 | sed 's/"//g')" -echo "${PFCONF:-"/etc/pf.conf"}" +echo ${PFCONF:-"/etc/pf.conf"} # Debug #set +x diff --git a/cdist/conf/type/__pf_ruleset/gencode-local b/cdist/conf/type/__pf_ruleset/gencode-local old mode 100755 new mode 100644 index 11bfb0b1..c2495509 --- a/cdist/conf/type/__pf_ruleset/gencode-local +++ b/cdist/conf/type/__pf_ruleset/gencode-local @@ -1,4 +1,4 @@ -#!/bin/sh -e +#!/bin/sh # # 2012 Jake Guffey (jake.guffey at eprotex.com) # @@ -54,25 +54,17 @@ case $uname in currentSum=\$(cksum -o 1 ${source} | cut -d= -f2 | sed 's/ //g') ;; *) - echo "Sorry, I do not know how to find a cksum on ${uname}." >&2 + echo "Sorry, I do not know how to find a cksum on ${UNAME}." >&2 exit 1 ;; esac -# IPv6 fix -if $(echo "${__target_host}" | grep -q -E '^[0-9a-fA-F:]+$') -then - my_target_host="[${__target_host}]" -else - my_target_host="${__target_host}" -fi - if [ -n "${cksum}" ]; then if [ ! "\${currentSum}" = "${cksum}" ]; then - $__remote_copy "${source}" "\${my_target_host}:${rcvar}.new" + $__remote_copy "${source}" "$__target_host:${rcvar}.new" fi else # File just doesn't exist yet - $__remote_copy "${source}" "\${my_target_host}:${rcvar}.new" + $__remote_copy "${source}" "$__target_host:${rcvar}.new" fi EOF diff --git a/cdist/conf/type/__pf_ruleset/gencode-remote b/cdist/conf/type/__pf_ruleset/gencode-remote old mode 100755 new mode 100644 index 12760fdf..6e9030ea --- a/cdist/conf/type/__pf_ruleset/gencode-remote +++ b/cdist/conf/type/__pf_ruleset/gencode-remote @@ -1,4 +1,4 @@ -#!/bin/sh -e +#!/bin/sh # # 2012 Jake Guffey (jake.guffey at eprotex.com) # diff --git a/cdist/conf/type/__pf_ruleset/man.rst b/cdist/conf/type/__pf_ruleset/man.text similarity index 51% rename from cdist/conf/type/__pf_ruleset/man.rst rename to cdist/conf/type/__pf_ruleset/man.text index 5719e94e..29efe065 100644 --- a/cdist/conf/type/__pf_ruleset/man.rst +++ b/cdist/conf/type/__pf_ruleset/man.text @@ -1,5 +1,7 @@ cdist-type__pf_ruleset(7) ========================= +Jake Guffey + NAME ---- @@ -8,18 +10,18 @@ cdist-type__pf_ruleset - Copy a pf(4) ruleset to $__target_host DESCRIPTION ----------- -This type is used on \*BSD systems to manage the pf firewall's ruleset. +This type is used on *BSD systems to manage the pf firewall's ruleset. REQUIRED PARAMETERS ------------------- -state +state:: Either "absent" (no ruleset at all) or "present", defaults to "present". OPTIONAL PARAMETERS ------------------- -source +source:: If supplied, use to define the ruleset to load onto the $__target_host for pf(4). Note that this type is almost useless without a ruleset defined, but it's technically not needed, e.g. for the case of disabling the firewall temporarily. @@ -28,28 +30,23 @@ source EXAMPLES -------- -.. code-block:: sh +-------------------------------------------------------------------------------- +# Remove the current ruleset in place +__pf_ruleset --state absent - # Remove the current ruleset in place - __pf_ruleset --state absent +# Enable the firewall with the ruleset defined in $__manifest/files/pf.conf +__pf_ruleset --state present --source $__manifest/files/pf.conf - # Enable the firewall with the ruleset defined in $__manifest/files/pf.conf - __pf_ruleset --state present --source $__manifest/files/pf.conf +-------------------------------------------------------------------------------- SEE ALSO -------- -:strong:`pf`\ (4) - - -AUTHORS -------- -Jake Guffey +- cdist-type(7) +- pf(4) COPYING ------- -Copyright \(C) 2012 Jake Guffey. 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. +Copyright \(C) 2012 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/__ping/gencode-remote b/cdist/conf/type/__ping/gencode-remote deleted file mode 100644 index 1341b954..00000000 --- a/cdist/conf/type/__ping/gencode-remote +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh -e -# -# Copyright (C) 2018 Olliver Schinagl -# -# SPDX-License-Identifier: GPL-3.0+ -# - -set -eu - -echo "echo 'pong'" - -exit 0 diff --git a/cdist/conf/type/__ping/man.rst b/cdist/conf/type/__ping/man.rst deleted file mode 100644 index e08643dc..00000000 --- a/cdist/conf/type/__ping/man.rst +++ /dev/null @@ -1,43 +0,0 @@ -cdist-type__ping(7) -================================== - -NAME ----- -cdist-type__ping - Try to connect to host and return 'pong' on success - - -DESCRIPTION ------------ -A simple type which tries to connect to a remote host and runs a simple command -to ensure everything is working. - - -REQUIRED PARAMETERS -------------------- -None. - - -OPTIONAL PARAMETERS -------------------- -None. - - -EXAMPLES --------- - -.. code-block:: sh - - __ping - - -AUTHORS -------- -Olliver Schinagl - - -COPYING -------- -Copyright \(C) 2018 Schinagl. 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. diff --git a/cdist/conf/type/__ping/singleton b/cdist/conf/type/__ping/singleton deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/conf/type/__postfix/man.rst b/cdist/conf/type/__postfix/man.rst deleted file mode 100644 index 43b158e0..00000000 --- a/cdist/conf/type/__postfix/man.rst +++ /dev/null @@ -1,42 +0,0 @@ -cdist-type__postfix(7) -====================== - -NAME ----- -cdist-type__postfix - Install postfix - - -DESCRIPTION ------------ -This space intentionally left blank. - - -REQUIRED PARAMETERS -------------------- -None. - - -OPTIONAL PARAMETERS -------------------- -None. - - -EXAMPLES --------- - -.. code-block:: sh - - __postfix - - -AUTHORS -------- -Steven Armstrong - - -COPYING -------- -Copyright \(C) 2012 Steven Armstrong. 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. diff --git a/cdist/conf/type/__postfix/man.text b/cdist/conf/type/__postfix/man.text new file mode 100644 index 00000000..1a91723a --- /dev/null +++ b/cdist/conf/type/__postfix/man.text @@ -0,0 +1,42 @@ +cdist-type__postfix(7) +====================== +Steven Armstrong + + +NAME +---- +cdist-type__postfix - install postfix + + +DESCRIPTION +----------- +This space intentionally left blank. + + +REQUIRED PARAMETERS +------------------- +None. + + +OPTIONAL PARAMETERS +------------------- +None. + + +EXAMPLES +-------- + +-------------------------------------------------------------------------------- +__postfix +-------------------------------------------------------------------------------- + + +SEE ALSO +-------- +- cdist-type(7) + + +COPYING +------- +Copyright \(C) 2012 Steven Armstrong. Free use of this software is +granted under the terms of the GNU General Public License version 3 (GPLv3). diff --git a/cdist/conf/type/__postfix/manifest b/cdist/conf/type/__postfix/manifest index f3616979..52a13919 100755 --- a/cdist/conf/type/__postfix/manifest +++ b/cdist/conf/type/__postfix/manifest @@ -1,7 +1,6 @@ -#!/bin/sh -e +#!/bin/sh # -# 2012-2014 Steven Armstrong (steven-cdist at armstrong.cc) -# 2019 Nico Schottelius (nico-cdist at schottelius.org) +# 2012 Steven Armstrong (steven-cdist at armstrong.cc) # # This file is part of cdist. # @@ -23,7 +22,7 @@ os=$(cat "$__global/explorer/os") case "$os" in - alpine|ubuntu|debian|archlinux|suse|scientific|centos|devuan) + ubuntu|debian|archlinux|suse) __package postfix --state present ;; *) diff --git a/cdist/conf/type/__postfix_master/gencode-remote b/cdist/conf/type/__postfix_master/gencode-remote index 7c109a69..51edc668 100755 --- a/cdist/conf/type/__postfix_master/gencode-remote +++ b/cdist/conf/type/__postfix_master/gencode-remote @@ -1,4 +1,4 @@ -#!/bin/sh -e +#!/bin/sh # # 2012 Steven Armstrong (steven-cdist at armstrong.cc) # diff --git a/cdist/conf/type/__postfix_master/man.rst b/cdist/conf/type/__postfix_master/man.rst deleted file mode 100644 index 07756f74..00000000 --- a/cdist/conf/type/__postfix_master/man.rst +++ /dev/null @@ -1,84 +0,0 @@ -cdist-type__postfix_master(7) -============================= - -NAME ----- -cdist-type__postfix_master - Configure postfix master.cf - - -DESCRIPTION ------------ -See master(5) for more information. - - -REQUIRED PARAMETERS -------------------- -type - See master(5) -command - See master(5) - - -BOOLEAN PARAMETERS ------------------- -noreload - don't reload postfix after changes - - -OPTIONAL PARAMETERS -------------------- -state - present or absent, defaults to present - -service - -private - -unpriv - -chroot - -wakeup - -maxproc - -option - Pass an option to a service. Same as using -o in master.cf. - Can be specified multiple times. - -comment - a textual comment to add with the master.cf entry - - -EXAMPLES --------- - -.. code-block:: sh - - __postfix_master smtp --type inet --command smtpd - - __postfix_master smtp --type inet --chroot y --command smtpd \ - --option smtpd_enforce_tls=yes \ - --option smtpd_sasl_auth_enable=yes \ - --option smtpd_client_restrictions=permit_sasl_authenticated,reject - - __postfix_master submission --type inet --command smtpd \ - --comment "Run alternative smtp on submission port" - - -SEE ALSO --------- -:strong:`master`\ (5) - - -AUTHORS -------- -Steven Armstrong - - -COPYING -------- -Copyright \(C) 2012 Steven Armstrong. 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. diff --git a/cdist/conf/type/__postfix_master/man.text b/cdist/conf/type/__postfix_master/man.text new file mode 100644 index 00000000..0ec78752 --- /dev/null +++ b/cdist/conf/type/__postfix_master/man.text @@ -0,0 +1,73 @@ +cdist-type__postfix_master(7) +============================= +Steven Armstrong + + +NAME +---- +cdist-type__postfix_master - configure postfix master.cf + + +DESCRIPTION +----------- +See master(5) for more information. + + +REQUIRED PARAMETERS +------------------- +type:: + See master(5) +command:: + See master(5) + + +BOOLEAN PARAMETERS +------------------ +noreload:: + don't reload postfix after changes + + +OPTIONAL PARAMETERS +------------------- +state:: + present or absent, defaults to present +service:: +private:: +unpriv:: +chroot:: +wakeup:: +maxproc:: +option:: + Pass an option to a service. Same as using -o in master.cf. + Can be specified multiple times. +comment:: + a textual comment to add with the master.cf entry + + +EXAMPLES +-------- + +-------------------------------------------------------------------------------- +__postfix_master smtp --type inet --command smtpd + +__postfix_master smtp --type inet --chroot y --command smtpd \ + --option smtpd_enforce_tls=yes \ + --option smtpd_sasl_auth_enable=yes \ + --option smtpd_client_restrictions=permit_sasl_authenticated,reject + +__postfix_master submission --type inet --command smtpd \ + --comment "Run alternative smtp on submission port" +-------------------------------------------------------------------------------- + + +SEE ALSO +-------- +- cdist-type(7) +- master(5) + + +COPYING +------- +Copyright \(C) 2012 Steven Armstrong. Free use of this software is +granted under the terms of the GNU General Public License version 3 (GPLv3). + diff --git a/cdist/conf/type/__postfix_master/manifest b/cdist/conf/type/__postfix_master/manifest index 0960ea41..87e2329b 100755 --- a/cdist/conf/type/__postfix_master/manifest +++ b/cdist/conf/type/__postfix_master/manifest @@ -1,6 +1,6 @@ -#!/bin/sh -e +#!/bin/sh # -# 2012-2014 Steven Armstrong (steven-cdist at armstrong.cc) +# 2012 - 2013 Steven Armstrong (steven-cdist at armstrong.cc) # # This file is part of cdist. # @@ -22,7 +22,7 @@ os=$(cat "$__global/explorer/os") case "$os" in - ubuntu|debian|archlinux|scientific|centos|devuan) + ubuntu|debian|archlinux) : ;; *) @@ -36,6 +36,7 @@ __postfix # Default to object_id service="$(cat "$__object/parameter/service" 2>/dev/null || echo "$__object_id")" +state="$(cat "$__object/parameter/state")" # NOTE: keep variables in sync in manifest,explorer,gencode-* prefix="#cdist:$__object_name" @@ -50,6 +51,7 @@ entry="$__object/files/entry" echo "# $(cat "$__object/parameter/comment")" fi printf "%s " "$service" + printf "%s " "$type" for parameter in type private unpriv chroot wakeup maxproc; do printf "%s " "$(cat "$__object/parameter/$parameter")" done diff --git a/cdist/conf/type/__postfix_postconf/explorer/value b/cdist/conf/type/__postfix_postconf/explorer/value index 67dacad8..e08c6da6 100755 --- a/cdist/conf/type/__postfix_postconf/explorer/value +++ b/cdist/conf/type/__postfix_postconf/explorer/value @@ -1,6 +1,6 @@ #!/bin/sh # -# 2012-2014 Steven Armstrong (steven-cdist at armstrong.cc) +# 2012 Steven Armstrong (steven-cdist at armstrong.cc) # # This file is part of cdist. # @@ -22,7 +22,7 @@ os=$("$__explorer/os") case "$os" in - alpine|ubuntu|debian|archlinux|suse|scientific|centos|devuan) + ubuntu|debian|archlinux|suse) : ;; *) diff --git a/cdist/conf/type/__postfix_postconf/gencode-remote b/cdist/conf/type/__postfix_postconf/gencode-remote index 279dddd4..43c0482e 100755 --- a/cdist/conf/type/__postfix_postconf/gencode-remote +++ b/cdist/conf/type/__postfix_postconf/gencode-remote @@ -1,7 +1,6 @@ -#!/bin/sh -e +#!/bin/sh # -# 2012-2014 Steven Armstrong (steven-cdist at armstrong.cc) -# 2019 Nico Schottelius (nico-cdist at schottelius.org) +# 2012 Steven Armstrong (steven-cdist at armstrong.cc) # # This file is part of cdist. # @@ -22,7 +21,7 @@ os=$(cat "$__global/explorer/os") case "$os" in - alpine|archlinux|centos|debian|devuan|suse|scientific|ubuntu) + ubuntu|debian|archlinux|suse) : ;; *) diff --git a/cdist/conf/type/__postfix_postconf/man.rst b/cdist/conf/type/__postfix_postconf/man.text similarity index 50% rename from cdist/conf/type/__postfix_postconf/man.rst rename to cdist/conf/type/__postfix_postconf/man.text index 3222d4a7..727637b1 100644 --- a/cdist/conf/type/__postfix_postconf/man.rst +++ b/cdist/conf/type/__postfix_postconf/man.text @@ -1,9 +1,11 @@ cdist-type__postfix_postconf(7) =============================== +Steven Armstrong + NAME ---- -cdist-type__postfix_postconf - Configure postfix main.cf +cdist-type__postfix_postconf - configure postfix main.cf DESCRIPTION @@ -16,39 +18,34 @@ It does not make changes to /etc/postfix/main.cf itself. REQUIRED PARAMETERS ------------------- -value +value:: the value for the postfix parameter OPTIONAL PARAMETERS ------------------- -key +key:: the name of the parameter. Defaults to __object_id EXAMPLES -------- -.. code-block:: sh +-------------------------------------------------------------------------------- +__postfix_postconf mydomain --value somedomain.com - __postfix_postconf mydomain --value somedomain.com +__postfix_postconf bind-to-special-ip --key smtp_bind_address --value 127.0.0.5 - __postfix_postconf bind-to-special-ip --key smtp_bind_address --value 127.0.0.5 +-------------------------------------------------------------------------------- SEE ALSO -------- -:strong:`postconf`\ (5) - - -AUTHORS -------- -Steven Armstrong +- cdist-type(7) +- postconf(5) COPYING ------- -Copyright \(C) 2012 Steven Armstrong. 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. +Copyright \(C) 2012 Steven Armstrong. Free use of this software is +granted under the terms of the GNU General Public License version 3 (GPLv3). diff --git a/cdist/conf/type/__postfix_postconf/manifest b/cdist/conf/type/__postfix_postconf/manifest index a82e13d7..0dde64e9 100755 --- a/cdist/conf/type/__postfix_postconf/manifest +++ b/cdist/conf/type/__postfix_postconf/manifest @@ -1,6 +1,6 @@ -#!/bin/sh -e +#!/bin/sh # -# 2012-2014 Steven Armstrong (steven-cdist at armstrong.cc) +# 2012 - 2013 Steven Armstrong (steven-cdist at armstrong.cc) # # This file is part of cdist. # diff --git a/cdist/conf/type/__postfix_postmap/gencode-remote b/cdist/conf/type/__postfix_postmap/gencode-remote index edb7711f..1b370001 100755 --- a/cdist/conf/type/__postfix_postmap/gencode-remote +++ b/cdist/conf/type/__postfix_postmap/gencode-remote @@ -1,4 +1,4 @@ -#!/bin/sh -e +#!/bin/sh # # 2012 Steven Armstrong (steven-cdist at armstrong.cc) # diff --git a/cdist/conf/type/__postfix_postmap/man.rst b/cdist/conf/type/__postfix_postmap/man.rst deleted file mode 100644 index 2a82b44a..00000000 --- a/cdist/conf/type/__postfix_postmap/man.rst +++ /dev/null @@ -1,42 +0,0 @@ -cdist-type__postfix_postmap(7) -============================== - -NAME ----- -cdist-type__postfix_postmap - Run postmap on the given file - - -DESCRIPTION ------------ -This space intentionally left blank. - - -REQUIRED PARAMETERS -------------------- -None. - - -OPTIONAL PARAMETERS -------------------- -None. - - -EXAMPLES --------- - -.. code-block:: sh - - __postfix_postmap /etc/postfix/generic - - -AUTHORS -------- -Steven Armstrong - - -COPYING -------- -Copyright \(C) 2012 Steven Armstrong. 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. diff --git a/cdist/conf/type/__postfix_postmap/man.text b/cdist/conf/type/__postfix_postmap/man.text new file mode 100644 index 00000000..37060d04 --- /dev/null +++ b/cdist/conf/type/__postfix_postmap/man.text @@ -0,0 +1,42 @@ +cdist-type__postfix_postmap(7) +============================== +Steven Armstrong + + +NAME +---- +cdist-type__postfix_postmap - run postmap on the given file + + +DESCRIPTION +----------- +This space intentionally left blank. + + +REQUIRED PARAMETERS +------------------- +None. + + +OPTIONAL PARAMETERS +------------------- +None. + + +EXAMPLES +-------- + +-------------------------------------------------------------------------------- +__postfix_postmap /etc/postfix/generic +-------------------------------------------------------------------------------- + + +SEE ALSO +-------- +- cdist-type(7) + + +COPYING +------- +Copyright \(C) 2012 Steven Armstrong. Free use of this software is +granted under the terms of the GNU General Public License version 3 (GPLv3). diff --git a/cdist/conf/type/__postfix_postmap/manifest b/cdist/conf/type/__postfix_postmap/manifest index a82e13d7..0dde64e9 100755 --- a/cdist/conf/type/__postfix_postmap/manifest +++ b/cdist/conf/type/__postfix_postmap/manifest @@ -1,6 +1,6 @@ -#!/bin/sh -e +#!/bin/sh # -# 2012-2014 Steven Armstrong (steven-cdist at armstrong.cc) +# 2012 - 2013 Steven Armstrong (steven-cdist at armstrong.cc) # # This file is part of cdist. # diff --git a/cdist/conf/type/__postfix_reload/gencode-remote b/cdist/conf/type/__postfix_reload/gencode-remote index 7720dc49..5822f1e3 100755 --- a/cdist/conf/type/__postfix_reload/gencode-remote +++ b/cdist/conf/type/__postfix_reload/gencode-remote @@ -1,6 +1,6 @@ -#!/bin/sh -e +#!/bin/sh # -# 2012-2014 Steven Armstrong (steven-cdist at armstrong.cc) +# 2012 Steven Armstrong (steven-cdist at armstrong.cc) # # This file is part of cdist. # @@ -22,7 +22,7 @@ os=$(cat "$__global/explorer/os") case "$os" in - ubuntu|debian|archlinux|scientific|centos|devuan) + ubuntu|debian|archlinux) echo "postfix reload" ;; *) diff --git a/cdist/conf/type/__postfix_reload/man.rst b/cdist/conf/type/__postfix_reload/man.rst deleted file mode 100644 index 944e22fa..00000000 --- a/cdist/conf/type/__postfix_reload/man.rst +++ /dev/null @@ -1,42 +0,0 @@ -cdist-type__postfix_reload(7) -============================= - -NAME ----- -cdist-type__postfix_reload - Tell postfix to reload its configuration - - -DESCRIPTION ------------ -This space intentionally left blank. - - -REQUIRED PARAMETERS -------------------- -None. - - -OPTIONAL PARAMETERS -------------------- -None. - - -EXAMPLES --------- - -.. code-block:: sh - - __postfix_reload - - -AUTHORS -------- -Steven Armstrong - - -COPYING -------- -Copyright \(C) 2012 Steven Armstrong. 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. diff --git a/cdist/conf/type/__postfix_reload/man.text b/cdist/conf/type/__postfix_reload/man.text new file mode 100644 index 00000000..c63356b5 --- /dev/null +++ b/cdist/conf/type/__postfix_reload/man.text @@ -0,0 +1,42 @@ +cdist-type__postfix_reload(7) +============================= +Steven Armstrong + + +NAME +---- +cdist-type__postfix_reload - tell postfix to reload its configuration + + +DESCRIPTION +----------- +This space intentionally left blank. + + +REQUIRED PARAMETERS +------------------- +None. + + +OPTIONAL PARAMETERS +------------------- +None. + + +EXAMPLES +-------- + +-------------------------------------------------------------------------------- +__postfix_reload +-------------------------------------------------------------------------------- + + +SEE ALSO +-------- +- cdist-type(7) + + +COPYING +------- +Copyright \(C) 2012 Steven Armstrong. Free use of this software is +granted under the terms of the GNU General Public License version 3 (GPLv3). diff --git a/cdist/conf/type/__postfix_reload/manifest b/cdist/conf/type/__postfix_reload/manifest index a82e13d7..0dde64e9 100755 --- a/cdist/conf/type/__postfix_reload/manifest +++ b/cdist/conf/type/__postfix_reload/manifest @@ -1,6 +1,6 @@ -#!/bin/sh -e +#!/bin/sh # -# 2012-2014 Steven Armstrong (steven-cdist at armstrong.cc) +# 2012 - 2013 Steven Armstrong (steven-cdist at armstrong.cc) # # This file is part of cdist. # diff --git a/cdist/conf/type/__postgres_database/explorer/state b/cdist/conf/type/__postgres_database/explorer/state index d68d4120..dc9659e2 100755 --- a/cdist/conf/type/__postgres_database/explorer/state +++ b/cdist/conf/type/__postgres_database/explorer/state @@ -18,25 +18,10 @@ # along with cdist. If not, see . # -case "$("${__explorer}/os")" -in - netbsd) - postgres_user='pgsql' - ;; - openbsd) - postgres_user='_postgresql' - ;; - *) - postgres_user='postgres' - ;; -esac - - name="$__object_id" -if test -n "$(su - "$postgres_user" -c "psql postgres -twAc \"SELECT 1 FROM pg_database WHERE datname='$name'\"")" -then - echo 'present' +if su - postgres -c "echo '\q' | psql '$name'" 2>/dev/null; then + echo "present" else - echo 'absent' + echo "absent" fi diff --git a/cdist/conf/type/__postgres_database/gencode-remote b/cdist/conf/type/__postgres_database/gencode-remote index 61cfa50d..c097efce 100755 --- a/cdist/conf/type/__postgres_database/gencode-remote +++ b/cdist/conf/type/__postgres_database/gencode-remote @@ -1,4 +1,4 @@ -#!/bin/sh -e +#!/bin/sh # # 2011 Steven Armstrong (steven-cdist at armstrong.cc) # @@ -18,20 +18,6 @@ # along with cdist. If not, see . # -case "$(cat "${__global}/explorer/os")" -in - netbsd) - postgres_user='pgsql' - ;; - openbsd) - postgres_user='_postgresql' - ;; - *) - postgres_user='postgres' - ;; -esac - - name="$__object_id" state_should="$(cat "$__object/parameter/state")" state_is="$(cat "$__object/explorer/state")" @@ -43,10 +29,10 @@ if [ "$state_should" != "$state_is" ]; then if [ -f "$__object/parameter/owner" ]; then owner="-O '$(cat "$__object/parameter/owner")'" fi - echo "su - '$postgres_user' -c \"createdb $owner '$name'\"" + echo "su - postgres -c \"createdb $owner '$name'\"" ;; absent) - echo "su - '$postgres_user' -c \"dropdb '$name'\"" + echo "su - postgres -c \"dropdb '$name'\"" ;; esac fi diff --git a/cdist/conf/type/__postgres_database/man.rst b/cdist/conf/type/__postgres_database/man.rst deleted file mode 100644 index acceec9b..00000000 --- a/cdist/conf/type/__postgres_database/man.rst +++ /dev/null @@ -1,46 +0,0 @@ -cdist-type__postgres_database(7) -================================ - -NAME ----- -cdist-type__postgres_database - Create/drop postgres databases - - -DESCRIPTION ------------ -This cdist type allows you to create or drop postgres databases. - - -OPTIONAL PARAMETERS -------------------- -state - either 'present' or 'absent', defaults to 'present'. - -owner - the role owning this database - - -EXAMPLES --------- - -.. code-block:: sh - - __postgres_database mydbname --owner mydbusername - - -SEE ALSO --------- -:strong:`cdist-type__postgres_role`\ (7) - - -AUTHORS -------- -Steven Armstrong - - -COPYING -------- -Copyright \(C) 2011 Steven Armstrong. 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. diff --git a/cdist/conf/type/__postgres_database/man.text b/cdist/conf/type/__postgres_database/man.text new file mode 100644 index 00000000..c7c0d3cd --- /dev/null +++ b/cdist/conf/type/__postgres_database/man.text @@ -0,0 +1,42 @@ +cdist-type__postgres_database(7) +================================ +Steven Armstrong + + +NAME +---- +cdist-type__postgres_database - create/drop postgres databases + + +DESCRIPTION +----------- +This cdist type allows you to create or drop postgres databases. + + +OPTIONAL PARAMETERS +------------------- +state:: + either 'present' or 'absent', defaults to 'present'. + +owner:: + the role owning this database + + +EXAMPLES +-------- + +-------------------------------------------------------------------------------- +__postgres_database mydbname --owner mydbusername +-------------------------------------------------------------------------------- + + +SEE ALSO +-------- +- cdist-type(7) +- cdist-type__postgres_role(7) + + +COPYING +------- +Copyright \(C) 2011 Steven Armstrong. Free use of this software is +granted under the terms of the GNU General Public License version 3 (GPLv3). diff --git a/cdist/conf/type/__postgres_extension/gencode-remote b/cdist/conf/type/__postgres_extension/gencode-remote deleted file mode 100755 index af9c97f1..00000000 --- a/cdist/conf/type/__postgres_extension/gencode-remote +++ /dev/null @@ -1,53 +0,0 @@ -#!/bin/sh -e -# -# 2011 Steven Armstrong (steven-cdist at armstrong.cc) -# 2013 Tomas Pospisek (tpo_deb at sourcepole.ch) -# -# This type was created by Tomas Pospisek based on the -#__postgres_role type by Steven Armstrong -# -# 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 . -# - -case "$(cat "${__global}/explorer/os")" -in - netbsd) - postgres_user='pgsql' - ;; - openbsd) - postgres_user='_postgresql' - ;; - *) - postgres_user='postgres' - ;; -esac - - -dbname=$( echo "$__object_id" | cut -d":" -f1 ) -extension=$( echo "$__object_id" | cut -d":" -f2 ) - -state_should=$( cat "$__object/parameter/state" ) - -case "$state_should" in - present) - cmd="CREATE EXTENSION IF NOT EXISTS $extension" - echo "su - '$postgres_user' -c 'psql -c \"$cmd\" \"$dbname\"'" - ;; - absent) - cmd="DROP EXTENSION IF EXISTS $extension" - echo "su - '$postgres_user' -c 'psql -c \"$cmd\" \"$dbname\"'" - ;; -esac diff --git a/cdist/conf/type/__postgres_extension/man.rst b/cdist/conf/type/__postgres_extension/man.rst deleted file mode 100644 index 79645b2b..00000000 --- a/cdist/conf/type/__postgres_extension/man.rst +++ /dev/null @@ -1,59 +0,0 @@ -cdist-type__postgres_extension(7) -================================= - -NAME ----- -cdist-type__postgres_extension - manage postgres extensions - - -DESCRIPTION ------------ -This cdist type allows you to create or drop postgres extensions. - -The object you need to pass to __postgres_extension consists of -the database name and the extension name joined by a colon in the -following form: - -.. code-block:: sh - - dbname:extension - -f.ex. - -.. code-block:: sh - - rails_test:unaccent - - -OPTIONAL PARAMETERS -------------------- -state - either "present" or "absent", defaults to "present" - - -EXAMPLES --------- - -.. code-block:: sh - - __postgres_extension rails_test:unaccent - __postgres_extension --present rails_test:unaccent - __postgres_extension --absent rails_test:unaccent - - -SEE ALSO --------- -:strong:`cdist-type__postgre_database`\ (7) - -Postgres "Create Extension" documentation at: . - -AUTHOR -------- -Tomas Pospisek - -COPYING -------- -Copyright \(C) 2014 Tomas Pospisek. 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. diff --git a/cdist/conf/type/__postgres_extension/parameter/default/state b/cdist/conf/type/__postgres_extension/parameter/default/state deleted file mode 100644 index e7f6134f..00000000 --- a/cdist/conf/type/__postgres_extension/parameter/default/state +++ /dev/null @@ -1 +0,0 @@ -present diff --git a/cdist/conf/type/__postgres_extension/parameter/optional b/cdist/conf/type/__postgres_extension/parameter/optional deleted file mode 100644 index ff72b5c7..00000000 --- a/cdist/conf/type/__postgres_extension/parameter/optional +++ /dev/null @@ -1 +0,0 @@ -state diff --git a/cdist/conf/type/__postgres_role/explorer/state b/cdist/conf/type/__postgres_role/explorer/state index c8e1fa9d..8c102df9 100755 --- a/cdist/conf/type/__postgres_role/explorer/state +++ b/cdist/conf/type/__postgres_role/explorer/state @@ -18,25 +18,10 @@ # along with cdist. If not, see . # -case "$("${__explorer}/os")" -in - netbsd) - postgres_user='pgsql' - ;; - openbsd) - postgres_user='_postgresql' - ;; - *) - postgres_user='postgres' - ;; -esac - - name="$__object_id" -if test -n "$(su - "$postgres_user" -c "psql postgres -twAc \"SELECT 1 FROM pg_roles WHERE rolname='$name'\"")" -then - echo 'present' +if su - postgres -c "psql -c '\du' | grep -q '^ *$name *|'"; then + echo "present" else - echo 'absent' + echo "absent" fi diff --git a/cdist/conf/type/__postgres_role/gencode-remote b/cdist/conf/type/__postgres_role/gencode-remote index fd56e85d..0230e48e 100755 --- a/cdist/conf/type/__postgres_role/gencode-remote +++ b/cdist/conf/type/__postgres_role/gencode-remote @@ -1,4 +1,4 @@ -#!/bin/sh -e +#!/bin/sh # # 2011 Steven Armstrong (steven-cdist at armstrong.cc) # @@ -18,20 +18,6 @@ # along with cdist. If not, see . # -case "$(cat "${__global}/explorer/os")" -in - netbsd) - postgres_user='pgsql' - ;; - openbsd) - postgres_user='_postgresql' - ;; - *) - postgres_user='postgres' - ;; -esac - - name="$__object_id" state_is="$(cat "$__object/explorer/state")" state_should="$(cat "$__object/parameter/state")" @@ -48,16 +34,16 @@ case "$state_should" in if [ ! -f "$__object/parameter/$boolean" ]; then boolean="no${boolean}" fi - upper=$(echo $boolean | tr '[:lower:]' '[:upper:]') + upper=$(echo $boolean | tr '[a-z]' '[A-Z]') booleans="$booleans $upper" done - [ -n "$password" ] && password="PASSWORD '$password'" + [ -n "$password" ] && password="PASSWORD '$password'" - cmd="CREATE ROLE $name WITH $password $booleans" - echo "su - '$postgres_user' -c \"psql postgres -wc \\\"$cmd\\\"\"" + cmd="CREATE ROLE $name WITH $password $booleans" + echo "su - postgres -c \"psql -c \\\"$cmd\\\"\"" ;; absent) - echo "su - '$postgres_user' -c \"dropuser \\\"$name\\\"\"" + echo "su - postgres -c \"dropuser \\\"$name\\\"\"" ;; esac diff --git a/cdist/conf/type/__postgres_role/man.rst b/cdist/conf/type/__postgres_role/man.rst deleted file mode 100644 index 11fd73d5..00000000 --- a/cdist/conf/type/__postgres_role/man.rst +++ /dev/null @@ -1,67 +0,0 @@ -cdist-type__postgres_role(7) -============================ - -NAME ----- -cdist-type__postgres_role - Manage postgres roles - - -DESCRIPTION ------------ -This cdist type allows you to create or drop postgres roles. - - -OPTIONAL PARAMETERS -------------------- -state - Either "present" or "absent", defaults to "present" - -All other parameters map directly to the corresponding postgres createrole -parameters. - -password - -BOOLEAN PARAMETERS ------------------- -All parameter map directly to the corresponding postgres createrole -parameters. - -login -createdb -createrole -superuser -inherit - -EXAMPLES --------- - -.. code-block:: sh - - __postgres_role myrole - - __postgres_role myrole --password 'secret' - - __postgres_role admin --password 'very-secret' --superuser - - __postgres_role dbcustomer --password 'bla' --createdb - - -SEE ALSO --------- -:strong:`cdist-type__postgres_database`\ (7) - -postgresql documentation at: -. - - -AUTHORS -------- -Steven Armstrong - - -COPYING -------- -Copyright \(C) 2011 Steven Armstrong. 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. diff --git a/cdist/conf/type/__postgres_role/man.text b/cdist/conf/type/__postgres_role/man.text new file mode 100644 index 00000000..ac87754b --- /dev/null +++ b/cdist/conf/type/__postgres_role/man.text @@ -0,0 +1,61 @@ +cdist-type__postgres_role(7) +============================ +Steven Armstrong + + +NAME +---- +cdist-type__postgres_role - manage postgres roles + + +DESCRIPTION +----------- +This cdist type allows you to create or drop postgres roles. + + +OPTIONAL PARAMETERS +------------------- +state:: + Either "present" or "absent", defaults to "present" + +All other parameters map directly to the corresponding postgres createrole +parameters. + +password:: + +BOOLEAN PARAMETERS +------------------ +All parameter map directly to the corresponding postgres createrole +parameters. + +login:: +createdb:: +createrole:: +superuser:: +inherit:: + +EXAMPLES +-------- + +-------------------------------------------------------------------------------- +__postgres_role myrole + +__postgres_role myrole --password 'secret' + +__postgres_role admin --password 'very-secret' --superuser + +__postgres_role dbcustomer --password 'bla' --createdb +-------------------------------------------------------------------------------- + + +SEE ALSO +-------- +- cdist-type(7) +- cdist-type__postgres_database(7) +- http://www.postgresql.org/docs/current/static/sql-createrole.html + + +COPYING +------- +Copyright \(C) 2011 Steven Armstrong. Free use of this software is +granted under the terms of the GNU General Public License version 3 (GPLv3). diff --git a/cdist/conf/type/__process/gencode-remote b/cdist/conf/type/__process/gencode-remote index ec9691b9..639940d9 100755 --- a/cdist/conf/type/__process/gencode-remote +++ b/cdist/conf/type/__process/gencode-remote @@ -1,8 +1,7 @@ -#!/bin/sh -e +#!/bin/sh # # 2011-2012 Nico Schottelius (nico-cdist at schottelius.org) # 2014 Steven Armstrong (steven-cdist at armstrong.cc) -# 2017 Thomas Eckert (tom at it-eckert.de) # # This file is part of cdist. # @@ -46,15 +45,13 @@ case "$state_should" in else echo "$name" fi - echo "started" >> "$__messages_out" ;; absent) - if [ -f "$__object/parameter/stop" ]; then + if [ -f "$__object/parameter/stop" ]; then cat "$__object/parameter/stop" - else - echo kill "$(cat "$__object/parameter/runs")" - fi - echo "stopped" >> "$__messages_out" + else + echo kill "${runs}" + fi ;; *) echo "Unknown state: $state_should" >&2 diff --git a/cdist/conf/type/__process/man.rst b/cdist/conf/type/__process/man.rst deleted file mode 100644 index e7303c55..00000000 --- a/cdist/conf/type/__process/man.rst +++ /dev/null @@ -1,84 +0,0 @@ -cdist-type__process(7) -====================== - -NAME ----- -cdist-type__process - Start or stop process - - -DESCRIPTION ------------ -This cdist type allows you to define the state of a process. - - -OPTIONAL PARAMETERS -------------------- -state - Either "present" or "absent", defaults to "present" - -name - Process name to match on when using pgrep -f -x. - - This is useful, if the name starts with a "/", - because the leading slash is stripped away from - the object id by cdist. - -stop - Executable to use for stopping the process. - -start - Executable to use for starting the process. - - -MESSAGES --------- -started - The process was started. - -stopped - The process was stopped. - - -EXAMPLES --------- - -.. code-block:: sh - - # Start if not running - __process /usr/sbin/syslog-ng --state present - - # Start if not running with a different binary - __process /usr/sbin/nginx --state present --start "/etc/rc.d/nginx start" - - # Stop the process using kill (the type default) - DO NOT USE THIS - __process /usr/sbin/sshd --state absent - - # Stop the process using /etc/rc.d/sshd stop - THIS ONE NOT AS WELL - __process /usr/sbin/sshd --state absent --stop "/etc/rc.d/sshd stop" - - # Ensure cups is running, which runs with -C ...: - __process cups --start "/etc/rc.d/cups start" --state present \ - --name "/usr/sbin/cupsd -C /etc/cups/cupsd.conf" - - # Ensure rpc.statd is running (which usually runs with -L) using a regexp - __process rpcstatd --state present --start "/etc/init.d/statd start" \ - --name "rpc.statd.*" - - -SEE ALSO --------- -:strong:`cdist-type__start_on_boot`\ (7) - - -AUTHORS -------- -| Nico Schottelius -| Thomas Eckert - - -COPYING -------- -Copyright \(C) 2011-2012 Nico Schottelius. 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. diff --git a/cdist/conf/type/__process/man.text b/cdist/conf/type/__process/man.text new file mode 100644 index 00000000..2fdd27aa --- /dev/null +++ b/cdist/conf/type/__process/man.text @@ -0,0 +1,70 @@ +cdist-type__process(7) +====================== +Nico Schottelius + + +NAME +---- +cdist-type__process - Start or stop process + + +DESCRIPTION +----------- +This cdist type allows you to define the state of a process. + + +OPTIONAL PARAMETERS +------------------- +state:: + Either "present" or "absent", defaults to "present" + +name:: + Process name to match on when using pgrep -f -x. + + This is useful, if the name starts with a "/", + because the leading slash is stripped away from + the object id by cdist. + +stop:: + Executable to use for stopping the process. + +start:: + Executable to use for starting the process. + + +EXAMPLES +-------- + +-------------------------------------------------------------------------------- +# Start if not running +__process /usr/sbin/syslog-ng --state present + +# Start if not running with a different binary +__process /usr/sbin/nginx --state present --start "/etc/rc.d/nginx start" + +# Stop the process using kill (the type default) - DO NOT USE THIS +__process /usr/sbin/sshd --state absent + +# Stop the process using /etc/rc.d/sshd stop - THIS ONE NOT AS WELL +__process /usr/sbin/sshd --state absent --stop "/etc/rc.d/sshd stop" + +# Ensure cups is running, which runs with -C ...: +__process cups --start "/etc/rc.d/cups start" --state present \ + --name "/usr/sbin/cupsd -C /etc/cups/cupsd.conf" + +# Ensure rpc.statd is running (which usually runs with -L) using a regexp +__process rpcstatd --state present --start "/etc/init.d/statd start" \ + --name "rpc.statd.*" +-------------------------------------------------------------------------------- + + +SEE ALSO +-------- +- cdist-type(7) +- cdist-type__start_on_boot(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/cdist/conf/type/__prometheus_alertmanager/man.rst b/cdist/conf/type/__prometheus_alertmanager/man.rst deleted file mode 100644 index 67e97eaf..00000000 --- a/cdist/conf/type/__prometheus_alertmanager/man.rst +++ /dev/null @@ -1,61 +0,0 @@ -cdist-type__prometheus_alertmanager(7) -====================================== - -NAME ----- -cdist-type__prometheus_alertmanager - install Alertmanager - - -DESCRIPTION ------------ -Install and configure Prometheus Alertmanager (https://prometheus.io/docs/alerting/alertmanager/). - -Note that due to significant differences between Prometheus 1.x and 2.x, only 2.x is supported. It is your responsibility to make sure that your package manager installs 2.x. (On Devuan Ascii, the parameter `--install-from-backports` helps.) - - -REQUIRED PARAMETERS -------------------- -config - Alertmanager configuration file. It will be saved as /etc/alertmanager/alertmanager.yml on the target. - - -OPTIONAL PARAMETERS -------------------- -storage-path - Where to put data. Default: /data/alertmanager. (Directory will be created if needed.) -retention-days - How long to retain data. Default: 90 days. - - -BOOLEAN PARAMETERS ------------------- -install-from-backports - Valid on Devuan only. Will enable the backports apt source and install the package from there. Useful for getting a newer version. - - -EXAMPLES --------- - -.. code-block:: sh - - __prometheus_alertmanager \ - --install-from-backports \ - --config "$__manifest/files/alertmanager.yml" \ - --storage-path /data/alertmanager - - -SEE ALSO --------- -:strong:`cdist-type__prometheus_server`\ (7), :strong:`cdist-type__grafana_dashboard`\ (7), -Prometheus alerting documentation: https://prometheus.io/docs/alerting/overview/ - -AUTHORS -------- -Kamila Součková - -COPYING -------- -Copyright \(C) 2018 Kamila Součková. 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. diff --git a/cdist/conf/type/__prometheus_alertmanager/manifest b/cdist/conf/type/__prometheus_alertmanager/manifest deleted file mode 100755 index 8ee818c3..00000000 --- a/cdist/conf/type/__prometheus_alertmanager/manifest +++ /dev/null @@ -1,64 +0,0 @@ -#!/bin/sh -e - -##### HARD-CODED CONFIG ##################################################### - -CONF_DIR=/etc/prometheus -CONF=$CONF_DIR/alertmanager.yml - -##### GET SETTINGS ########################################################## - -config="$(cat "$__object/parameter/config")" -retention_days="$(cat "$__object/parameter/retention-days")" -storage_path="$(cat "$__object/parameter/storage-path")" -# listen_address="$(cat "$__object/parameter/listen-address")" - -##### INSTALL THE PACKAGE ################################################### - -require_pkg="" # what to require if I want to require "the package" -require="" -if [ -f "$__object/parameter/install-from-backports" ]; then - os=$(cat "$__global/explorer/os") - os_version=$(cat "$__global/explorer/os_version") - - case $os in - devuan) - [ "$os_version" = "ascii/ceres" ] && os_version='ascii' # "ascii" used in the repo URLs - __apt_source backports --uri http://auto.mirror.devuan.org/merged --distribution $os_version-backports --component main - require="$require __apt_source/backports" __package_apt prometheus-alertmanager --target-release $os_version-backports - require_pkg="__package_apt/prometheus-alertmanager" - ;; - *) - echo "--install-from-backports is only supported on Devuan -- ignoring." >&2 - echo "Send a pull request if you require it." >&2 - ;; - esac -else - __package prometheus-alertmanager - require_pkg="__package/prometheus-alertmanager" -fi - -##### PREPARE PATHS AND SUCH ################################################ - -require="$require $require_pkg" __directory "$storage_path" --owner prometheus --parents - -# TODO this is a bug in the init script, patching it like this is awful and it should be reported -require="$require $require_pkg" \ -__key_value alertmanager_fix_init_script --file /etc/init.d/prometheus-alertmanager \ - --key "NAME" --value "prometheus-alertmanager" --delimiter "=" \ - --onchange "service prometheus-alertmanager restart" - -##### CONFIGURE ############################################################# - -FLAGS="--storage.path $storage_path --data.retention $((retention_days*24))h --web.listen-address [::]:9093 --cluster.advertise-address [::]:9093" - -require="$require $require_pkg" \ -__key_value alertmanager_args --file /etc/default/prometheus-alertmanager \ - --key "ARGS" --value "\"$FLAGS\"" --delimiter "=" \ - --onchange "service prometheus-alertmanager restart" - -require="$require __directory/$storage_path $require_pkg" \ -__config_file $CONF \ - --source "$config" \ - --group prometheus --mode 640 \ - --onchange "service prometheus-alertmanager reload" # TODO when a config-check tool is available, check config here - diff --git a/cdist/conf/type/__prometheus_alertmanager/parameter/boolean b/cdist/conf/type/__prometheus_alertmanager/parameter/boolean deleted file mode 100644 index 5d15e93d..00000000 --- a/cdist/conf/type/__prometheus_alertmanager/parameter/boolean +++ /dev/null @@ -1 +0,0 @@ -install-from-backports diff --git a/cdist/conf/type/__prometheus_alertmanager/parameter/default/retention-days b/cdist/conf/type/__prometheus_alertmanager/parameter/default/retention-days deleted file mode 100644 index d61f00d8..00000000 --- a/cdist/conf/type/__prometheus_alertmanager/parameter/default/retention-days +++ /dev/null @@ -1 +0,0 @@ -90 diff --git a/cdist/conf/type/__prometheus_alertmanager/parameter/default/storage-path b/cdist/conf/type/__prometheus_alertmanager/parameter/default/storage-path deleted file mode 100644 index 4f3e7559..00000000 --- a/cdist/conf/type/__prometheus_alertmanager/parameter/default/storage-path +++ /dev/null @@ -1 +0,0 @@ -/data/alertmanager diff --git a/cdist/conf/type/__prometheus_alertmanager/parameter/optional b/cdist/conf/type/__prometheus_alertmanager/parameter/optional deleted file mode 100644 index 7fe79009..00000000 --- a/cdist/conf/type/__prometheus_alertmanager/parameter/optional +++ /dev/null @@ -1,2 +0,0 @@ -storage-path -retention-days diff --git a/cdist/conf/type/__prometheus_alertmanager/parameter/required b/cdist/conf/type/__prometheus_alertmanager/parameter/required deleted file mode 100644 index 04204c7c..00000000 --- a/cdist/conf/type/__prometheus_alertmanager/parameter/required +++ /dev/null @@ -1 +0,0 @@ -config diff --git a/cdist/conf/type/__prometheus_alertmanager/singleton b/cdist/conf/type/__prometheus_alertmanager/singleton deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/conf/type/__prometheus_exporter/files/blackbox.yml b/cdist/conf/type/__prometheus_exporter/files/blackbox.yml deleted file mode 100644 index e567c127..00000000 --- a/cdist/conf/type/__prometheus_exporter/files/blackbox.yml +++ /dev/null @@ -1,63 +0,0 @@ -modules: - http_2xx: - prober: http - timeout: 3s - http: - method: GET - no_follow_redirects: false - fail_if_ssl: false - fail_if_not_ssl: false - # http_post_2xx: - # prober: http - # timeout: 5s - # http: - # method: POST - # headers: - # Content-Type: application/json - # body: '{}' - # tcp_connect_v4_example: - # prober: tcp - # timeout: 5s - # tcp: - # protocol: "tcp4" - # irc_banner_example: - # prober: tcp - # timeout: 5s - # tcp: - # query_response: - # - send: "NICK prober" - # - send: "USER prober prober prober :prober" - # - expect: "PING :([^ ]+)" - # send: "PONG ${1}" - # - expect: "^:[^ ]+ 001" - # icmp_example: - # prober: icmp - # timeout: 5s - # icmp: - # protocol: "icmp" - # preferred_ip_protocol: "ip4" - # dns_udp_example: - # prober: dns - # timeout: 5s - # dns: - # query_name: "www.prometheus.io" - # query_type: "A" - # valid_rcodes: - # - NOERROR - # validate_answer_rrs: - # fail_if_matches_regexp: - # - ".*127.0.0.1" - # fail_if_not_matches_regexp: - # - "www.prometheus.io.\t300\tIN\tA\t127.0.0.1" - # validate_authority_rrs: - # fail_if_matches_regexp: - # - ".*127.0.0.1" - # validate_additional_rrs: - # fail_if_matches_regexp: - # - ".*127.0.0.1" - # dns_tcp_example: - # prober: dns - # dns: - # protocol: "tcp" # accepts "tcp/tcp4/tcp6/udp/udp4/udp6", defaults to "udp" - # preferred_ip_protocol: "ip4" # used for "udp/tcp", defaults to "ip6" - # query_name: "www.prometheus.io" diff --git a/cdist/conf/type/__prometheus_exporter/man.rst b/cdist/conf/type/__prometheus_exporter/man.rst deleted file mode 100644 index 3b1ee4d7..00000000 --- a/cdist/conf/type/__prometheus_exporter/man.rst +++ /dev/null @@ -1,70 +0,0 @@ -cdist-type__prometheus_exporter(7) -================================== - -NAME ----- -cdist-type__prometheus_exporter - install some Prometheus exporters - - -DESCRIPTION ------------ -Install and configure some exporters to be used by the Prometheus monitoring system (https://prometheus.io/). - -This type creates a daemontools-compatible service directory under /service/$__object_id. -Daemontools (or something compatible) must be installed (in particular, the command `svc` must be executable). - -This type installs and builds the latest version from git, using go get. A recent version of golang as well -as build tools (make, g++, etc.) must be available. - -Currently supported exporters: - -- node -- blackbox -- ceph - - -REQUIRED PARAMETERS -------------------- -None - - -OPTIONAL PARAMETERS -------------------- -exporter - Which exporter to install and configure. Default: $__object_id. - Currently supported: node, blackbox, ceph. - - -BOOLEAN PARAMETERS ------------------- -add-consul-service - Add this exporter as a Consul service for automatic service discovery. - - -EXAMPLES --------- - -.. code-block:: sh - - __daemontools - __golang_from_vendor --version 1.9 # required for prometheus and many exporters - - require="__daemontools __golang_from_vendor" __prometheus_exporter node - - -SEE ALSO --------- -:strong:`cdist-type__daemontools`\ (7), :strong:`cdist-type__golang_from_vendor`\ (7), -:strong:`cdist-type__prometheus_server`\ (7), -Prometheus documentation: https://prometheus.io/docs/introduction/overview/ - -AUTHORS -------- -Kamila Součková - -COPYING -------- -Copyright \(C) 2017 Kamila Součková. 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. diff --git a/cdist/conf/type/__prometheus_exporter/manifest b/cdist/conf/type/__prometheus_exporter/manifest deleted file mode 100644 index b9e14531..00000000 --- a/cdist/conf/type/__prometheus_exporter/manifest +++ /dev/null @@ -1,50 +0,0 @@ -#!/bin/sh - -export GOBIN=/opt/gocode/bin # where to find go binaries - -exporter="$(cat "$__object/parameter/exporter")" -[ -z "$exporter" ] && exporter="$__object_id" - -__user prometheus --system - -require="" -case $exporter in - node) - TEXTFILES=/service/node-exporter/textfiles # path for the textfiles collector - __directory $TEXTFILES --parents --mode 777 - require="$require __golang_from_vendor" __go_get github.com/prometheus/node_exporter - - port=9100 - run="setuidgid prometheus $GOBIN/node_exporter -web.listen-address :$port -collector.textfile.directory=$TEXTFILES" - ;; - blackbox) - require="$require __daemontools_service/${exporter}-exporter __user/prometheus" __config_file "/service/${exporter}-exporter/blackbox.yml" \ - --source "$__type/files/blackbox.yml" \ - --group prometheus --mode 640 \ - --onchange "svc -h /service/${exporter}-exporter" - require="$require __golang_from_vendor" __go_get github.com/prometheus/blackbox_exporter - - port=9115 - run="setuidgid prometheus $GOBIN/blackbox_exporter -config.file=/service/${exporter}-exporter/blackbox.yml" - ;; - ceph) - __package librados-dev # dependency of ceph_exporter - require="$require __golang_from_vendor __package/librados-dev" __go_get github.com/digitalocean/ceph_exporter - - port=9128 - run="setuidgid ceph $GOBIN/ceph_exporter -ceph.config /etc/ceph/ceph.conf -telemetry.addr :$port" - ;; - *) - echo "Unsupported exporter: $exporter." >&2 - exit 1 - ;; -esac - -require="$require __daemontools" __daemontools_service "${exporter}-exporter" --run "$run" -if [ -f "$__object/parameter/add-consul-service" ]; then - __consul_service "${exporter}-exporter" --port "$port" --check-http "http://localhost:$port/metrics" --check-interval 10s -fi - -#__daemontools --install-init-script -__daemontools -__golang_from_vendor --version 1.9 # required for many exporters diff --git a/cdist/conf/type/__prometheus_exporter/parameter/boolean b/cdist/conf/type/__prometheus_exporter/parameter/boolean deleted file mode 100644 index 004af844..00000000 --- a/cdist/conf/type/__prometheus_exporter/parameter/boolean +++ /dev/null @@ -1 +0,0 @@ -add-consul-service diff --git a/cdist/conf/type/__prometheus_exporter/parameter/default/exporter b/cdist/conf/type/__prometheus_exporter/parameter/default/exporter deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/conf/type/__prometheus_exporter/parameter/optional b/cdist/conf/type/__prometheus_exporter/parameter/optional deleted file mode 100644 index 9cfaec5a..00000000 --- a/cdist/conf/type/__prometheus_exporter/parameter/optional +++ /dev/null @@ -1 +0,0 @@ -exporter diff --git a/cdist/conf/type/__prometheus_server/man.rst b/cdist/conf/type/__prometheus_server/man.rst deleted file mode 100644 index ab6a3c9b..00000000 --- a/cdist/conf/type/__prometheus_server/man.rst +++ /dev/null @@ -1,67 +0,0 @@ -cdist-type__prometheus_server(7) -================================ - -NAME ----- -cdist-type__prometheus_server - install Prometheus - - -DESCRIPTION ------------ -Install and configure Prometheus (https://prometheus.io/). - -Note that due to significant differences between Prometheus 1.x and 2.x, only 2.x is supported. It is your responsibility to make sure that your package manager installs 2.x. (On Devuan Ascii, the parameter `--install-from-backports` helps.) - -REQUIRED PARAMETERS -------------------- -config - Prometheus configuration file. It will be saved as /etc/prometheus/prometheus.yml on the target. - - -OPTIONAL PARAMETERS -------------------- -retention-days - How long to keep data. Default: 30 -rule-files - Path to rule files. They will be installed under /etc/prometheus/. You need to include `rule_files: [/etc/prometheus/]` in the config file if you use this. -storage-path - Where to put data. Default: /data/prometheus. (Directory will be created if needed.) - - -BOOLEAN PARAMETERS ------------------- -install-from-backports - Valid on Devuan only. Will enable the backports apt source and install the package from there. Useful for getting a newer version. - - -EXAMPLES --------- - -.. code-block:: sh - - PROMPORT=9090 - ALERTPORT=9093 - - __prometheus_server \ - --install-from-backports \ - --config "$__manifest/files/prometheus.yml" \ - --retention-days 14 \ - --storage-path /data/prometheus \ - --rule-files "$__manifest/files/*.rules" - - -SEE ALSO --------- -:strong:`cdist-type__prometheus_alertmanager`\ (7), :strong:`cdist-type__grafana_dashboard`\ (7), -Prometheus documentation: https://prometheus.io/docs/introduction/overview/ - -AUTHORS -------- -Kamila Součková - -COPYING -------- -Copyright \(C) 2018 Kamila Součková. 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. diff --git a/cdist/conf/type/__prometheus_server/manifest b/cdist/conf/type/__prometheus_server/manifest deleted file mode 100755 index 8685130f..00000000 --- a/cdist/conf/type/__prometheus_server/manifest +++ /dev/null @@ -1,71 +0,0 @@ -#!/bin/sh -e - -##### HARD-CODED CONFIG ##################################################### - -CONF_DIR=/etc/prometheus -CONF=$CONF_DIR/prometheus.yml - -##### GET SETTINGS ########################################################## - -config="$(cat "$__object/parameter/config")" -retention_days="$(cat "$__object/parameter/retention-days")" -storage_path="$(cat "$__object/parameter/storage-path")" -rule_files="$(cat "$__object/parameter/rule-files")" - -# explorer in kB => convert; by default we go with 1/2 RAM -[ "$target_heap_size" = "auto" ] && target_heap_size=$(($(cat "$__global/explorer/memory")*1024/2)) - -##### INSTALL THE PACKAGE ################################################### - -require_pkg="" # what to require if I want to require "the package" -require="" -if [ -f "$__object/parameter/install-from-backports" ]; then - os=$(cat "$__global/explorer/os") - os_version=$(cat "$__global/explorer/os_version") - - case $os in - devuan) - [ "$os_version" = "ascii/ceres" ] && os_version='ascii' # "ascii" used in the repo URLs - __apt_source backports --uri http://auto.mirror.devuan.org/merged --distribution $os_version-backports --component main - require="$require __apt_source/backports" __package_apt prometheus --target-release $os_version-backports - require_pkg="__package_apt/prometheus" - ;; - *) - echo "--install-from-backports is only supported on Devuan -- ignoring." >&2 - echo "Send a pull request if you require it." >&2 - ;; - esac -else - __package prometheus - require_pkg="__package/prometheus" -fi - -##### PREPARE PATHS AND SUCH ################################################ - -require="$require $require_pkg" __directory "$storage_path" --owner prometheus --parents - -##### CONFIGURE ############################################################# - -FLAGS="--storage.tsdb.path $storage_path --storage.tsdb.retention $((retention_days*24))h --web.listen-address [::]:9090" - -# TODO it would be neat to restart prometheus on change -- __key_value really should have an --onchange parameter -require="$require $require_pkg" \ -__key_value prometheus_args --file /etc/default/prometheus \ - --key "ARGS" --value "\"$FLAGS\"" --delimiter "=" \ - --onchange "service prometheus restart" - -require="$require __directory/$storage_path $require_pkg" \ -__config_file $CONF \ - --source "$config" \ - --group prometheus --mode 640 \ - --onchange "promtool check config $CONF && service prometheus reload" - -for file in $rule_files; do - dest=$CONF_DIR/$(basename "$file") - require="$require $require_pkg" \ - __config_file "$dest" \ - --source "$file" \ - --owner prometheus \ - --onchange "promtool check rules '$dest' && service prometheus reload" -done - diff --git a/cdist/conf/type/__prometheus_server/parameter/boolean b/cdist/conf/type/__prometheus_server/parameter/boolean deleted file mode 100644 index 5d15e93d..00000000 --- a/cdist/conf/type/__prometheus_server/parameter/boolean +++ /dev/null @@ -1 +0,0 @@ -install-from-backports diff --git a/cdist/conf/type/__prometheus_server/parameter/default/retention-days b/cdist/conf/type/__prometheus_server/parameter/default/retention-days deleted file mode 100644 index 64bb6b74..00000000 --- a/cdist/conf/type/__prometheus_server/parameter/default/retention-days +++ /dev/null @@ -1 +0,0 @@ -30 diff --git a/cdist/conf/type/__prometheus_server/parameter/default/rule-files b/cdist/conf/type/__prometheus_server/parameter/default/rule-files deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/conf/type/__prometheus_server/parameter/default/storage-path b/cdist/conf/type/__prometheus_server/parameter/default/storage-path deleted file mode 100644 index fc05f8f3..00000000 --- a/cdist/conf/type/__prometheus_server/parameter/default/storage-path +++ /dev/null @@ -1 +0,0 @@ -/data/prometheus diff --git a/cdist/conf/type/__prometheus_server/parameter/optional b/cdist/conf/type/__prometheus_server/parameter/optional deleted file mode 100644 index cb437211..00000000 --- a/cdist/conf/type/__prometheus_server/parameter/optional +++ /dev/null @@ -1,3 +0,0 @@ -retention-days -rule-files -storage-path diff --git a/cdist/conf/type/__prometheus_server/parameter/required b/cdist/conf/type/__prometheus_server/parameter/required deleted file mode 100644 index 04204c7c..00000000 --- a/cdist/conf/type/__prometheus_server/parameter/required +++ /dev/null @@ -1 +0,0 @@ -config diff --git a/cdist/conf/type/__prometheus_server/singleton b/cdist/conf/type/__prometheus_server/singleton deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/conf/type/__pyvenv/explorer/group b/cdist/conf/type/__pyvenv/explorer/group deleted file mode 100755 index a655bda7..00000000 --- a/cdist/conf/type/__pyvenv/explorer/group +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh - -destination="/$__object_id" - -stat --print "%G" "${destination}" 2>/dev/null || exit 0 diff --git a/cdist/conf/type/__pyvenv/explorer/owner b/cdist/conf/type/__pyvenv/explorer/owner deleted file mode 100755 index 8b3c7f8e..00000000 --- a/cdist/conf/type/__pyvenv/explorer/owner +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/sh - -destination="/$__object_id" - -stat --print "%U" "${destination}" 2>/dev/null || exit 0 diff --git a/cdist/conf/type/__pyvenv/explorer/state b/cdist/conf/type/__pyvenv/explorer/state deleted file mode 100755 index ffe3cbbd..00000000 --- a/cdist/conf/type/__pyvenv/explorer/state +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh - -destination="/$__object_id" - -if [ -d "$destination" ]; then - echo present -else - echo absent -fi diff --git a/cdist/conf/type/__pyvenv/gencode-remote b/cdist/conf/type/__pyvenv/gencode-remote deleted file mode 100755 index 04700683..00000000 --- a/cdist/conf/type/__pyvenv/gencode-remote +++ /dev/null @@ -1,67 +0,0 @@ -#!/bin/sh -e -# -# 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 . -# -# - -state_is="$(cat "$__object/explorer/state")" -owner_is="$(cat "$__object/explorer/owner")" -group_is="$(cat "$__object/explorer/group")" - -state_should="$(cat "$__object/parameter/state")" - -owner="$(cat "$__object/parameter/owner")" -group="$(cat "$__object/parameter/group")" -mode="$(cat "$__object/parameter/mode")" - -[ "$state_should" = "$state_is" ] && \ -[ "$owner" = "$owner_is" ] && \ -[ "$group" = "$group_is" ] && \ -[ -n "$mode" ] && exit 0 - -destination="/$__object_id" -venvparams="$(cat "$__object/parameter/venvparams")" -pyvenvparam="$__object/parameter/pyvenv" -if [ -f "$pyvenvparam" ] -then - pyvenv=$(cat "$pyvenvparam") -else - pyvenv="pyvenv" -fi - -case $state_should in - present) - if [ "$state_should" != "$state_is" ]; then - echo "$pyvenv $venvparams $destination" - fi - if { [ -n "$owner" ] && [ "$owner_is" != "$owner" ]; } || \ - { [ -n "$group" ] && [ "$group_is" != "$group" ]; }; then - echo chown -R "${owner}:${group}" "$destination" - fi - if [ -n "$mode" ]; then - echo chmod -R "$mode" "$destination" - fi - ;; - absent) - ;; - - *) - echo "Unknown state: $state_should" >&2 - exit 1 - ;; -esac diff --git a/cdist/conf/type/__pyvenv/man.rst b/cdist/conf/type/__pyvenv/man.rst deleted file mode 100644 index d7de92fa..00000000 --- a/cdist/conf/type/__pyvenv/man.rst +++ /dev/null @@ -1,79 +0,0 @@ -cdist-type__pyvenv(7) -===================== - -NAME ----- -cdist-type__pyvenv - Create or remove python virtual environment - - -DESCRIPTION ------------ -This cdist type allows you to create or remove python virtual -environment using pyvenv. -It assumes pyvenv is already installed. Concrete package depends -on concrete OS and/or OS version/distribution. -Ensure this for e.g. in your init manifest as in the following example: - -.. code-block sh - - case "$__target_host" in - localhost) - __package python3-venv --state present - require="__package/python3-venv" __pyvenv /home/darko/testenv --pyvenv "pyvenv-3.4" --owner darko --group darko --mode 740 --state present - require="__pyvenv/home/darko/testenv" __package_pip docopt --pip /home/darko/testenv/bin/pip --runas darko --state present - ;; - esac - - -REQUIRED PARAMETERS -------------------- -None - -OPTIONAL PARAMETERS -------------------- -state - Either "present" or "absent", defaults to "present" - -group - Group to chgrp to - -mode - Unix permissions, suitable for chmod - -owner - User to chown to - -pyvenv - Use this specific pyvenv - -venvparams - Specific parameters to pass to pyvenv invocation - - -EXAMPLES --------- - -.. code-block:: sh - - __pyvenv /home/services/djangoenv - - # Use specific pyvenv - __pyvenv /home/foo/fooenv --pyvenv /usr/local/bin/pyvenv-3.4 - - # Create python virtualenv for user foo. - __pyvenv /home/foo/fooenv --group foo --user foo - - # Create python virtualenv with specific parameters. - __pyvenv /home/services/djangoenv --venvparams "--copies --system-site-packages" - - -AUTHORS -------- -Darko Poljak - - -COPYING -------- -Copyright \(C) 2016 Darko Poljak. Free use of this software is -granted under the terms of the GNU General Public License v3 or later (GPLv3+). - diff --git a/cdist/conf/type/__pyvenv/manifest b/cdist/conf/type/__pyvenv/manifest deleted file mode 100755 index 5d6a12e8..00000000 --- a/cdist/conf/type/__pyvenv/manifest +++ /dev/null @@ -1,46 +0,0 @@ -#!/bin/sh -e -# -# 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 . -# - -# It assumes pyvenv is already installed. Concrete packages -# or installation procedures depend on concrete OS and/or OS -# version/distribution. - -state_should="$(cat "$__object/parameter/state")" -owner="$(cat "$__object/parameter/owner")" -group="$(cat "$__object/parameter/group")" -mode="$(cat "$__object/parameter/mode")" - -case "$state_should" in - present) - : - ;; - - absent) - __directory "$__object_id" --state absent \ - --owner "$owner" \ - --group "$group" \ - --mode "$mode" - ;; - - *) - echo "Unknown state: $state_should" >&2 - exit 1 - ;; -esac diff --git a/cdist/conf/type/__pyvenv/parameter/default/group b/cdist/conf/type/__pyvenv/parameter/default/group deleted file mode 100755 index 8b137891..00000000 --- a/cdist/conf/type/__pyvenv/parameter/default/group +++ /dev/null @@ -1 +0,0 @@ - diff --git a/cdist/conf/type/__pyvenv/parameter/default/mode b/cdist/conf/type/__pyvenv/parameter/default/mode deleted file mode 100755 index 8b137891..00000000 --- a/cdist/conf/type/__pyvenv/parameter/default/mode +++ /dev/null @@ -1 +0,0 @@ - diff --git a/cdist/conf/type/__pyvenv/parameter/default/owner b/cdist/conf/type/__pyvenv/parameter/default/owner deleted file mode 100755 index 8b137891..00000000 --- a/cdist/conf/type/__pyvenv/parameter/default/owner +++ /dev/null @@ -1 +0,0 @@ - diff --git a/cdist/conf/type/__pyvenv/parameter/default/state b/cdist/conf/type/__pyvenv/parameter/default/state deleted file mode 100755 index e7f6134f..00000000 --- a/cdist/conf/type/__pyvenv/parameter/default/state +++ /dev/null @@ -1 +0,0 @@ -present diff --git a/cdist/conf/type/__pyvenv/parameter/default/venvparams b/cdist/conf/type/__pyvenv/parameter/default/venvparams deleted file mode 100644 index 8b137891..00000000 --- a/cdist/conf/type/__pyvenv/parameter/default/venvparams +++ /dev/null @@ -1 +0,0 @@ - diff --git a/cdist/conf/type/__pyvenv/parameter/optional b/cdist/conf/type/__pyvenv/parameter/optional deleted file mode 100755 index ed2218b1..00000000 --- a/cdist/conf/type/__pyvenv/parameter/optional +++ /dev/null @@ -1,6 +0,0 @@ -state -group -owner -mode -venvparams -pyvenv diff --git a/cdist/conf/type/__qemu_img/gencode-remote b/cdist/conf/type/__qemu_img/gencode-remote old mode 100755 new mode 100644 index 94816f58..6e4bb4d0 --- a/cdist/conf/type/__qemu_img/gencode-remote +++ b/cdist/conf/type/__qemu_img/gencode-remote @@ -1,5 +1,3 @@ -#!/bin/sh -e -# ################################################################################ # State: absent is handled by manifest - we need only to do stuff if image is # not existing and state != absent @@ -18,4 +16,4 @@ format="$(cat "$__object/parameter/format")" size="$(cat "$__object/parameter/size")" diskimage="/$__object_id" -echo "qemu-img create -f '$format' '$diskimage' '$size'" +echo qemu-img create -f \"$format\" \"$diskimage\" \"$size\" diff --git a/cdist/conf/type/__qemu_img/man.rst b/cdist/conf/type/__qemu_img/man.rst deleted file mode 100644 index 210c7f5f..00000000 --- a/cdist/conf/type/__qemu_img/man.rst +++ /dev/null @@ -1,53 +0,0 @@ -cdist-type__qemu_img(7) -======================= - -NAME ----- -cdist-type__qemu_img - Manage VM disk images - - -DESCRIPTION ------------ -The qemu-img program is used to create qemu images for -qemu and (qemu-)kvm. - - - -OPTIONAL PARAMETERS -------------------- -state - Either "present" or "absent", defaults to "present" -size - Size of the image in qemu-img compatible units. - - Required if state is "present". - - -EXAMPLES --------- - -.. code-block:: sh - - # Create a 50G size image - __qemu_img /home/services/kvm/vm/myvmname/system-disk --size 50G - - # Remove image - __qemu_img /home/services/kvm/vm/myoldvm/system-disk --state absent - - -SEE ALSO --------- -:strong:`qemu-img`\ (1) - - -AUTHORS -------- -Nico Schottelius - - -COPYING -------- -Copyright \(C) 2012-2014 Nico Schottelius. 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. diff --git a/cdist/conf/type/__qemu_img/man.text b/cdist/conf/type/__qemu_img/man.text new file mode 100644 index 00000000..0fe2bbec --- /dev/null +++ b/cdist/conf/type/__qemu_img/man.text @@ -0,0 +1,49 @@ +cdist-type__qemu_img(7) +======================== +Nico Schottelius + + +NAME +---- +cdist-type__qemu_img - Manage VM disk images + + +DESCRIPTION +----------- +The qemu-img program is used to create qemu images for +qemu and (qemu-)kvm. + + + +OPTIONAL PARAMETERS +------------------- +state:: + Either "present" or "absent", defaults to "present" +size:: + Size of the image in qemu-img compatible units. + + Required if state is "present". + + +EXAMPLES +-------- + +-------------------------------------------------------------------------------- +# Create a 50G size image +__qemu_img /home/services/kvm/vm/myvmname/system-disk --size 50G + +# Remove image +__qemu_img /home/services/kvm/vm/myoldvm/system-disk --state absent +-------------------------------------------------------------------------------- + + +SEE ALSO +-------- +- cdist-type(7) +- qemu-img(1) + + +COPYING +------- +Copyright \(C) 2012-2014 Nico Schottelius. Free use of this software is +granted under the terms of the GNU General Public License version 3 (GPLv3). diff --git a/cdist/conf/type/__qemu_img/manifest b/cdist/conf/type/__qemu_img/manifest old mode 100755 new mode 100644 index 55f3bf16..bb2c9366 --- a/cdist/conf/type/__qemu_img/manifest +++ b/cdist/conf/type/__qemu_img/manifest @@ -1,9 +1,8 @@ -#!/bin/sh -e -# ################################################################################ # Default settings # +format="$(cat "$__object/parameter/format")" state_should="$(cat "$__object/parameter/state")" diskimage="/$__object_id" diff --git a/cdist/conf/type/__rbenv/man.rst b/cdist/conf/type/__rbenv/man.rst deleted file mode 100644 index 607019cf..00000000 --- a/cdist/conf/type/__rbenv/man.rst +++ /dev/null @@ -1,49 +0,0 @@ -cdist-type__rbenv(7) -==================== - -NAME ----- -cdist-type__rbenv - Manage rbenv installation - - -DESCRIPTION ------------ -This cdist type allows you to manage rbenv installations. -It also installs ruby-build. - - -OPTIONAL PARAMETERS -------------------- -state - Either "present" or "absent", defaults to "present" - -owner - Which user should own the rbenv installation, defaults to root - - -EXAMPLES --------- - -.. code-block:: sh - - # Install rbenv including ruby-build for nico - __rbenv /home/nico - - # Install rbenv including ruby-build for nico - __rbenv /home/nico --owner nico - - # Bastian does not need rbenv anymore, he began to code C99 - __rbenv /home/bastian --state absent - - -AUTHORS -------- -Nico Schottelius - - -COPYING -------- -Copyright \(C) 2012-2014 Nico Schottelius. 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. diff --git a/cdist/conf/type/__rbenv/man.text b/cdist/conf/type/__rbenv/man.text new file mode 100644 index 00000000..c6ed5de2 --- /dev/null +++ b/cdist/conf/type/__rbenv/man.text @@ -0,0 +1,49 @@ +cdist-type__rbenv(7) +==================== +Nico Schottelius + + +NAME +---- +cdist-type__rbenv - Manage rbenv installation + + +DESCRIPTION +----------- +This cdist type allows you to manage rbenv installations. +It also installs ruby-build. + + +OPTIONAL PARAMETERS +------------------- +state:: + Either "present" or "absent", defaults to "present" + +owner:: + Which user should own the rbenv installation, defaults to root + + +EXAMPLES +-------- + +-------------------------------------------------------------------------------- +# Install rbenv including ruby-build for nico +__rbenv /home/nico + +# Install rbenv including ruby-build for nico +__rbenv /home/nico --owner nico + +# Bastian does not need rbenv anymore, he began to code C99 +__rbenv /home/bastian --state absent +-------------------------------------------------------------------------------- + + +SEE ALSO +-------- +- cdist-type(7) + + +COPYING +------- +Copyright \(C) 2012-2014 Nico Schottelius. Free use of this software is +granted under the terms of the GNU General Public License version 3 (GPLv3). diff --git a/cdist/conf/type/__rbenv/manifest b/cdist/conf/type/__rbenv/manifest old mode 100755 new mode 100644 index e5c3d2f8..767abdba --- a/cdist/conf/type/__rbenv/manifest +++ b/cdist/conf/type/__rbenv/manifest @@ -1,4 +1,4 @@ -#!/bin/sh -e +#!/bin/sh # # 2012-2014 Nico Schottelius (nico-cdist at schottelius.org) # diff --git a/cdist/conf/type/__rsync/gencode-local b/cdist/conf/type/__rsync/gencode-local deleted file mode 100755 index e36ded2f..00000000 --- a/cdist/conf/type/__rsync/gencode-local +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/sh -e -# -# 2015 Dominique Roux (dominique.roux4 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 . -# - -source=$(cat "$__object/parameter/source") -remote_user=$(cat "$__object/parameter/remote-user") - -if [ -f "$__object/parameter/destination" ]; then - destination=$(cat "$__object/parameter/destination") -else - destination="/$__object_id" -fi - -set -- -if [ -f "$__object/parameter/rsync-opts" ]; then - while read -r opts; do - set -- "$@" "--$opts" - done < "$__object/parameter/rsync-opts" -fi - -echo rsync -a \ - --no-owner --no-group \ - -q "$@" "${source}/" "${remote_user}@${__target_host}:${destination}" diff --git a/cdist/conf/type/__rsync/gencode-remote b/cdist/conf/type/__rsync/gencode-remote deleted file mode 100755 index 074246af..00000000 --- a/cdist/conf/type/__rsync/gencode-remote +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/sh -e -# -# 2015 Dominique Roux (dominique.roux4 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 . -# - -if [ -f "$__object/parameter/destination" ]; then - destination=$(cat "$__object/parameter/destination") -else - destination="/$__object_id" -fi - -ownergroup="" -if [ -f "$__object/parameter/owner" ]; then - ownergroup=$(cat "$__object/parameter/owner") -fi -if [ -f "$__object/parameter/group" ]; then - ownergroup="${ownergroup}:$(cat "$__object/parameter/group")" -fi - -if [ "$ownergroup" ]; then - echo chown -R "$ownergroup" "$destination" -fi diff --git a/cdist/conf/type/__rsync/man.rst b/cdist/conf/type/__rsync/man.rst deleted file mode 100644 index 94b06d63..00000000 --- a/cdist/conf/type/__rsync/man.rst +++ /dev/null @@ -1,114 +0,0 @@ -cdist-type__rsync(7) -==================== - -NAME ----- -cdist-type__rsync - Mirror directories using rsync - - -DESCRIPTION ------------ -WARNING: This type is of BETA quality: - -- it has not been tested widely -- interfaces *may* change -- if there is a better approach to solve the problem -> the type may even vanish - -If you are fine with these constraints, please read on. - - -This cdist type allows you to mirror local directories to the -target host using rsync. Rsync will be installed in the manifest of the type. -If group or owner are giveng, a recursive chown will be executed on the -target host. - -A slash will be appended to the source directory so that only the contents -of the directory are taken and not the directory name itself. - - -REQUIRED PARAMETERS -------------------- -source - Where to take files from - - -OPTIONAL PARAMETERS -------------------- -group - Group to chgrp to. - -owner - User to chown to. - -destination - Use this as the base destination instead of the object id - -remote-user - Use this user instead of the default "root" for rsync operations. - - -OPTIONAL MULTIPLE PARAMETERS ----------------------------- -rsync-opts - Use this option to give rsync options with. - See rsync(1) for available options. - Only "--" options are supported. - Write the options without the beginning "--" - Can be specified multiple times. - - -MESSAGES --------- -NONE - - -EXAMPLES --------- - -.. code-block:: sh - - # You can use any source directory - __rsync /tmp/testdir \ - --source /etc - - # Use source from type - __rsync /etc \ - --source "$__type/files/package" - - # Allow multiple __rsync objects to write to the same dir - __rsync mystuff \ - --destination /usr/local/bin \ - --source "$__type/files/package" - - __rsync otherstuff \ - --destination /usr/local/bin \ - --source "$__type/files/package2" - - # Use rsync option --exclude - __rsync /tmp/testdir \ - --source /etc \ - --rsync-opts exclude=sshd_conf - - # Use rsync with multiple options --exclude --dry-run - __rsync /tmp/testing \ - --source /home/tester \ - --rsync-opts exclude=id_rsa \ - --rsync-opts dry-run - - -SEE ALSO --------- -:strong:`rsync`\ (1) - - -AUTHORS -------- -Nico Schottelius - - -COPYING -------- -Copyright \(C) 2015 Nico Schottelius. 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. diff --git a/cdist/conf/type/__rsync/manifest b/cdist/conf/type/__rsync/manifest deleted file mode 100755 index 9bd44c6d..00000000 --- a/cdist/conf/type/__rsync/manifest +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/sh -e -# -# 2015 Dominique Roux (dominique.roux4 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 . -# - -__package rsync diff --git a/cdist/conf/type/__rsync/parameter/default/remote-user b/cdist/conf/type/__rsync/parameter/default/remote-user deleted file mode 100644 index d8649da3..00000000 --- a/cdist/conf/type/__rsync/parameter/default/remote-user +++ /dev/null @@ -1 +0,0 @@ -root diff --git a/cdist/conf/type/__rsync/parameter/optional b/cdist/conf/type/__rsync/parameter/optional deleted file mode 100644 index ac2b2390..00000000 --- a/cdist/conf/type/__rsync/parameter/optional +++ /dev/null @@ -1,4 +0,0 @@ -destination -owner -group -remote-user diff --git a/cdist/conf/type/__rsync/parameter/optional_multiple b/cdist/conf/type/__rsync/parameter/optional_multiple deleted file mode 100644 index fdb7cd88..00000000 --- a/cdist/conf/type/__rsync/parameter/optional_multiple +++ /dev/null @@ -1 +0,0 @@ -rsync-opts diff --git a/cdist/conf/type/__rsync/parameter/required b/cdist/conf/type/__rsync/parameter/required deleted file mode 100644 index 5a18cd2f..00000000 --- a/cdist/conf/type/__rsync/parameter/required +++ /dev/null @@ -1 +0,0 @@ -source diff --git a/cdist/conf/type/__rvm/explorer/state b/cdist/conf/type/__rvm/explorer/state index 74d17048..f43f5509 100755 --- a/cdist/conf/type/__rvm/explorer/state +++ b/cdist/conf/type/__rvm/explorer/state @@ -28,7 +28,7 @@ if [ "$user" = "root" ]; then echo absent fi else - if su - "$user" -c "[ -d \"\$HOME/.rvm\" ]" ; then + if su - $user -c "[ -d \"\$HOME/.rvm\" ]" ; then echo "present" else echo "absent" diff --git a/cdist/conf/type/__rvm/gencode-remote b/cdist/conf/type/__rvm/gencode-remote index 993191c1..dbc6ba60 100755 --- a/cdist/conf/type/__rvm/gencode-remote +++ b/cdist/conf/type/__rvm/gencode-remote @@ -1,4 +1,4 @@ -#!/bin/sh -e +#!/bin/sh # # 2012 Evax Software # 2012 Nico Schottelius (nico-cdist at schottelius.org) @@ -34,7 +34,7 @@ DONE absent) cat << DONE su - $user -c "rm -Rf \"\\\$HOME/.rvm\"; -sed '/rvm\\/scripts\\/rvm/d' \"\\\$HOME/.bashrc\" > \"\\\$HOME/.bashrc.cdist-tmp\" +sed '/rvm\/scripts\/rvm/d' \"\\\$HOME/.bashrc\" > \"\\\$HOME/.bashrc.cdist-tmp\" mv \"\\\$HOME/.bashrc.cdist-tmp\" \"\\\$HOME/.bashrc\"" DONE ;; diff --git a/cdist/conf/type/__rvm/man.rst b/cdist/conf/type/__rvm/man.text similarity index 59% rename from cdist/conf/type/__rvm/man.rst rename to cdist/conf/type/__rvm/man.text index 3a914304..0408d125 100644 --- a/cdist/conf/type/__rvm/man.rst +++ b/cdist/conf/type/__rvm/man.text @@ -1,5 +1,7 @@ cdist-type__rvm(7) ================== +Evax Software + NAME ---- @@ -13,31 +15,28 @@ RVM is the Ruby enVironment Manager for the Ruby programming language. REQUIRED PARAMETERS ------------------- -state +state:: Either "present" or "absent", defaults to "present". EXAMPLES -------- -.. code-block:: sh +-------------------------------------------------------------------------------- +# Install rvm for user billie +__rvm billie --state present - # Install rvm for user billie - __rvm billie --state present - - # Remove rvm - __rvm billie --state absent +# Remove rvm +__rvm billie --state absent +-------------------------------------------------------------------------------- SEE ALSO -------- -:strong:`cdist-type__rvm_gem`\ (7), :strong:`cdist-type__rvm_gemset`\ (7), -:strong:`cdist-type__rvm_ruby`\ (7) - - -AUTHORS -------- -Evax Software +- cdist-type(7) +- cdist-type__rvm_ruby(7) +- cdist-type__rvm_gemset(7) +- cdist-type__rvm_gem(7) COPYING diff --git a/cdist/conf/type/__rvm/manifest b/cdist/conf/type/__rvm/manifest index 0230156b..482c0d17 100755 --- a/cdist/conf/type/__rvm/manifest +++ b/cdist/conf/type/__rvm/manifest @@ -1,4 +1,4 @@ -#!/bin/sh -e +#!/bin/sh # # 2012 Evax Software # diff --git a/cdist/conf/type/__rvm_gem/gencode-remote b/cdist/conf/type/__rvm_gem/gencode-remote index 9212de91..1fe6e78e 100755 --- a/cdist/conf/type/__rvm_gem/gencode-remote +++ b/cdist/conf/type/__rvm_gem/gencode-remote @@ -20,6 +20,8 @@ gem="$__object_id" gemset="$(cat "$__object/parameter/gemset")" +ruby="$(echo "$gemset" | cut -d '@' -f 1)" +gemsetname="$(echo "$gemset" | cut -d '@' -f 2)" state_is="$(cat "$__object/explorer/state")" user="$(cat "$__object/parameter/user")" state_should="$(cat "$__object/parameter/state")" diff --git a/cdist/conf/type/__rvm_gem/man.rst b/cdist/conf/type/__rvm_gem/man.rst deleted file mode 100644 index 5f3fba97..00000000 --- a/cdist/conf/type/__rvm_gem/man.rst +++ /dev/null @@ -1,58 +0,0 @@ -cdist-type__rvm_gemset(7) -========================== - -NAME ----- -cdist-type__rvm_gemset - Manage Ruby gems through rvm - - -DESCRIPTION ------------ -RVM is the Ruby enVironment Manager for the Ruby programming language. - - -REQUIRED PARAMETERS -------------------- -user - The remote user account to use -gemset - The gemset to use -state - Either "present" or "absent", defaults to "present". - -OPTIONAL PARAMETERS -------------------- -default - Make the selected gemset the default - -EXAMPLES --------- - -.. code-block:: sh - - # Install the rails gem in gemset ruby-1.9.3-p0@myset for user bill - __rvm_gemset rails --gemset ruby-1.9.3-p0@myset --user bill --state present - - # Do the same and also make ruby-1.9.3-p0@myset the default gemset - __rvm_gemset rails --gemset ruby-1.9.3-p0@myset --user bill \ - --state present --default - - # Remove it - __rvm_ruby rails --gemset ruby-1.9.3-p0@myset --user bill --state absent - - -SEE ALSO --------- -:strong:`cdist-type__rvm`\ (7), :strong:`cdist-type__rvm_gemset`\ (7), -:strong:`cdist-type__rvm_ruby`\ (7) - - -AUTHORS -------- -Evax Software - - -COPYING -------- -Copyright \(C) 2012 Evax Software. 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/__rvm_gem/man.text b/cdist/conf/type/__rvm_gem/man.text new file mode 100644 index 00000000..d7eff3be --- /dev/null +++ b/cdist/conf/type/__rvm_gem/man.text @@ -0,0 +1,57 @@ +cdist-type__rvm_gemset(7) +========================== +Evax Software + + +NAME +---- +cdist-type__rvm_gem - Manage Ruby gems through rvm + + +DESCRIPTION +----------- +RVM is the Ruby enVironment Manager for the Ruby programming language. + + +REQUIRED PARAMETERS +------------------- +user:: + The remote user account to use +gemset:: + The gemset to use +state:: + Either "present" or "absent", defaults to "present". + +OPTIONAL PARAMETERS +------------------- +default:: + Make the selected gemset the default + +EXAMPLES +-------- + +-------------------------------------------------------------------------------- +# Install the rails gem in gemset ruby-1.9.3-p0@myset for user bill +__rvm_gemset rails --gemset ruby-1.9.3-p0@myset --user bill --state present + +# Do the same and also make ruby-1.9.3-p0@myset the default gemset +__rvm_gemset rails --gemset ruby-1.9.3-p0@myset --user bill \ + --state present --default + +# Remove it +__rvm_ruby rails --gemset ruby-1.9.3-p0@myset --user bill --state absent +-------------------------------------------------------------------------------- + + +SEE ALSO +-------- +- cdist-type(7) +- cdist-type__rvm(7) +- cdist-type__rvm_ruby(7) +- cdist-type__rvm_gemset(7) + + +COPYING +------- +Copyright \(C) 2012 Evax Software. 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/__rvm_gemset/explorer/state b/cdist/conf/type/__rvm_gemset/explorer/state index e300453b..fa643a6e 100755 --- a/cdist/conf/type/__rvm_gemset/explorer/state +++ b/cdist/conf/type/__rvm_gemset/explorer/state @@ -18,6 +18,9 @@ # along with cdist. If not, see . # +gemset="$__object_id" +ruby="$(echo "$gemset" | cut -d '@' -f 1)" +gemsetname="$(echo "$gemset" | cut -d '@' -f2)" user="$(cat "$__object/parameter/user")" if [ ! -e "~$user/.rvm/scripts/rvm" ] ; then @@ -25,9 +28,7 @@ if [ ! -e "~$user/.rvm/scripts/rvm" ] ; then exit 0 fi -# shellcheck disable=SC2016 if su - "$user" -c 'source ~/.rvm/scripts/rvm; rvm list strings | grep -q "^$ruby\$"'; then - # shellcheck disable=SC2016 if su - "$user" -c 'source ~/.rvm/scripts/rvm; rvm use "$ruby" > /dev/null; rvm gemset list strings | cut -f 1 -d " " | grep -q "^$gemsetname\$"'; then echo "present" exit 0 diff --git a/cdist/conf/type/__rvm_gemset/gencode-remote b/cdist/conf/type/__rvm_gemset/gencode-remote index 3cdc66a6..f0c0052b 100755 --- a/cdist/conf/type/__rvm_gemset/gencode-remote +++ b/cdist/conf/type/__rvm_gemset/gencode-remote @@ -1,4 +1,4 @@ -#!/bin/sh -e +#!/bin/sh # # 2012 Evax Software # 2012 Nico Schottelius (nico-cdist at schottelius.org) @@ -33,7 +33,7 @@ case "$state_should" in cat << DONE su - "$user" -c "source ~/.rvm/scripts/rvm; rvm $gemset --create" DONE - if [ -f "$__object/parameter/default" ]; then + if -f "$__object/parameter/default"; then cat << DONE su - "$user" -c "source ~/.rvm/scripts/rvm; rvm use --default $gemset" DONE diff --git a/cdist/conf/type/__rvm_gemset/man.rst b/cdist/conf/type/__rvm_gemset/man.text similarity index 51% rename from cdist/conf/type/__rvm_gemset/man.rst rename to cdist/conf/type/__rvm_gemset/man.text index fca4c36a..e85425f3 100644 --- a/cdist/conf/type/__rvm_gemset/man.rst +++ b/cdist/conf/type/__rvm_gemset/man.text @@ -1,5 +1,7 @@ cdist-type__rvm_gemset(7) ========================== +Evax Software + NAME ---- @@ -13,41 +15,38 @@ RVM is the Ruby enVironment Manager for the Ruby programming language. REQUIRED PARAMETERS ------------------- -user +user:: The remote user account to use -state +state:: Either "present" or "absent", defaults to "present". BOOLEAN PARAMETERS ------------------- -default +default:: If present, set the given gemset as default. EXAMPLES -------- -.. code-block:: sh +-------------------------------------------------------------------------------- +# Install the gemset @myset for user charles on based on ruby-1.9.3-0 +__rvm_gemset ruby-1.9.3-p0@myset --user charles --state present - # Install the gemset @myset for user charles on based on ruby-1.9.3-0 - __rvm_gemset ruby-1.9.3-p0@myset --user charles --state present +# Do the same and make ruby-1.9.3-p0@myset the default gemset +__rvm_gemset ruby-1.9.3-p0@myset --user charles --state present --default - # Do the same and make ruby-1.9.3-p0@myset the default gemset - __rvm_gemset ruby-1.9.3-p0@myset --user charles --state present --default - - # Remove the gemset @myset for user john - __rvm_ruby ruby-1.9.3-p0@myset --user john --state absent +# Remove the gemset @myset for user john +__rvm_ruby ruby-1.9.3-p0@myset --user john --state absent +-------------------------------------------------------------------------------- SEE ALSO -------- -:strong:`cdist-type__rvm`\ (7), :strong:`cdist-type__rvm_gem`\ (7), -:strong:`cdist-type__rvm_ruby`\ (7) - - -AUTHORS -------- -Evax Software +- cdist-type(7) +- cdist-type__rvm(7) +- cdist-type__rvm_ruby(7) +- cdist-type__rvm_gem(7) COPYING diff --git a/cdist/conf/type/__rvm_ruby/gencode-remote b/cdist/conf/type/__rvm_ruby/gencode-remote index f2fd41ef..f1de3906 100755 --- a/cdist/conf/type/__rvm_ruby/gencode-remote +++ b/cdist/conf/type/__rvm_ruby/gencode-remote @@ -1,4 +1,4 @@ -#!/bin/sh -e +#!/bin/sh # # 2012 Evax Software # @@ -21,6 +21,7 @@ ruby="$__object_id" state_is="$(cat "$__object/explorer/state")" user="$(cat "$__object/parameter/user")" +default="$(cat "$__object/parameter/default" 2>/dev/null || true)" state_should="$(cat "$__object/parameter/state")" [ "$state_is" = "$state_should" ] && exit 0 diff --git a/cdist/conf/type/__rvm_ruby/man.rst b/cdist/conf/type/__rvm_ruby/man.text similarity index 51% rename from cdist/conf/type/__rvm_ruby/man.rst rename to cdist/conf/type/__rvm_ruby/man.text index f6e71e12..6419a4d4 100644 --- a/cdist/conf/type/__rvm_ruby/man.rst +++ b/cdist/conf/type/__rvm_ruby/man.text @@ -1,5 +1,7 @@ cdist-type__rvm_ruby(7) ======================= +Evax Software + NAME ---- @@ -13,42 +15,37 @@ RVM is the Ruby enVironment Manager for the Ruby programming language. REQUIRED PARAMETERS ------------------- -user +user:: The remote user account to use -state +state:: Either "present" or "absent", defaults to "present". - BOOLEAN PARAMETERS ------------------ -default +default: Set the given version as default - EXAMPLES -------- -.. code-block:: sh +-------------------------------------------------------------------------------- +# Install ruby 1.9.3 through rvm for user thelonious +__rvm_ruby ruby-1.9.3-p0 --user thelonious --state present - # Install ruby 1.9.3 through rvm for user thelonious - __rvm_ruby ruby-1.9.3-p0 --user thelonious --state present +# Install ruby 1.9.3 through rvm for user ornette and make it the default +__rvm_ruby ruby-1.9.3-p0 --user ornette --state present --default - # Install ruby 1.9.3 through rvm for user ornette and make it the default - __rvm_ruby ruby-1.9.3-p0 --user ornette --state present --default - - # Remove ruby 1.9.3 for user john - __rvm_ruby ruby-1.9.3-p0 --user john --state absent +# Remove ruby 1.9.3 for user john +__rvm_ruby ruby-1.9.3-p0 --user john --state absent +-------------------------------------------------------------------------------- SEE ALSO -------- -:strong:`cdist-type__rvm`\ (7), :strong:`cdist-type__rvm_gem`\ (7), -:strong:`cdist-type__rvm_gemset`\ (7) - - -AUTHORS -------- -Evax Software +- cdist-type(7) +- cdist-type__rvm(7) +- cdist-type__rvm_gemset(7) +- cdist-type__rvm_gem(7) COPYING diff --git a/cdist/conf/type/__rvm_ruby/manifest b/cdist/conf/type/__rvm_ruby/manifest index 3f63eb11..db8fd830 100755 --- a/cdist/conf/type/__rvm_ruby/manifest +++ b/cdist/conf/type/__rvm_ruby/manifest @@ -1,4 +1,4 @@ -#!/bin/sh -e +#!/bin/sh # # 2012 Nico Schottelius (nico-cdist at schottelius.org) # diff --git a/cdist/conf/type/__ssh_authorized_key/explorer/entry b/cdist/conf/type/__ssh_authorized_key/explorer/entry deleted file mode 100755 index ccab0afc..00000000 --- a/cdist/conf/type/__ssh_authorized_key/explorer/entry +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/sh -# -# 2014 Steven Armstrong (steven-cdist at armstrong.cc) -# -# This file is part of cdist. -# -# cdist is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# cdist is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with cdist. If not, see . -# - -# extract the keytype and base64 encoded key ignoring any options and comment -type_and_key="$(tr ' ' '\n' < "$__object/parameter/key"| awk '/^(ssh|ecdsa)-[^ ]+/ { printf $1" "; getline; printf $1 }')" -# If type_and_key is empty, which is the case with an invalid key, do not grep $file because it results -# in greping everything in file and all entries from file are removed. -if [ -n "${type_and_key}" ] -then - file="$(cat "$__object/parameter/file")" - - # get any entries that match the type and key - - # NOTE: Do not match from the beginning of the line as there may be options - # preceeding the key. - grep "${type_and_key}\\([ \\n].*\\)*$" "$file" || true -fi diff --git a/cdist/conf/type/__ssh_authorized_key/gencode-remote b/cdist/conf/type/__ssh_authorized_key/gencode-remote deleted file mode 100755 index f37aa565..00000000 --- a/cdist/conf/type/__ssh_authorized_key/gencode-remote +++ /dev/null @@ -1,120 +0,0 @@ -#!/bin/sh -e -# -# 2014 Steven Armstrong (steven-cdist at armstrong.cc) -# -# This file is part of cdist. -# -# cdist is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# cdist is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with cdist. If not, see . -# - -set -u - -the_key="$(cat "$__object/parameter/key")" -# validate key -validated_key="$(echo "${the_key}" | tr ' ' '\n' | awk '/^(ssh|ecdsa)-[^ ]+/ { printf $1" "; getline; printf $1 }')" -if [ -z "${validated_key}" ] -then - echo "Key is invalid: \"${the_key}\"" >&2 - exit 1 -fi - -remove_line() { - file="$1" - line="$2" - cat << DONE -tmpfile=\$(mktemp ${file}.cdist.XXXXXXXXXX) -# preserve ownership and permissions of existing file -if [ -f "$file" ]; then - cp -p "$file" "\$tmpfile" -fi -grep -v -F -x '$line' '$file' > \$tmpfile || true -mv -f "\$tmpfile" "$file" -DONE -} - -add_line() { - file="$1" - line="$2" - # escape single quotes - line_sanitised=$(echo "$line" | sed -e "s/'/'\"'\"'/g") - printf '%s' "printf '%s\\n' '$line_sanitised' >> $file" -} - - -file="$(cat "$__object/parameter/file")" -mkdir "$__object/files" - -# Generate the entry as it should be -( - if [ -f "$__object/parameter/option" ]; then - # comma seperated list of options - options="$(tr '\n' ',' < "$__object/parameter/option")" - printf '%s ' "${options%*,}" - fi - if [ -f "$__object/parameter/comment" ]; then - # extract the keytype and base64 encoded key ignoring any options and comment - printf '%s ' "$(echo "${the_key}" | tr ' ' '\n' | awk '/^(ssh|ecdsa)-[^ ]+/ { printf $1" "; getline; printf $1 }')" - # override the comment with the one explicitly given - printf '%s' "$(cat "$__object/parameter/comment")" - else - printf '%s' "${the_key}" - fi - printf '\n' -) > "$__object/files/should" - -# Remove conflicting entries if any -if [ -s "$__object/explorer/entry" ]; then - # Note that the files have to be sorted for comparison with `comm`. - sort "$__object/explorer/entry" > "$__object/files/is" - comm -13 "$__object/files/should" "$__object/files/is" | { - while read -r entry; do - remove_line "$file" "$entry" - done - } -fi - -# Determine the current state -entry="$(cat "$__object/files/should")" -state_should="$(cat "$__object/parameter/state")" -num_existing_entries=$(grep -c -F -x "$entry" "$__object/explorer/entry" || true) -if [ "$num_existing_entries" -eq 1 ]; then - state_is="present" -else - # Posix grep does not define the -m option, so we can not remove a single - # occurence of a string from a file in the `remove_line` function. Instead - # _all_ occurences are removed. - # By using `comm` to detect conflicting entries this could lead to the - # situation that the key we want to add is actually removed. - # To workaround this we must treat 0 or more then 1 existing entries to - # mean current state is 'absent'. By doing this, the key is readded - # again after cleaning up conflicting entries. - state_is="absent" -fi - -# Manage the actual entry as it should be -if [ "$state_should" = "$state_is" ]; then - # Nothing to do - exit 0 -fi - -case "$state_should" in - present) - add_line "$file" "$entry" - echo "added to $file ($entry)" >> "$__messages_out" - ;; - absent) - remove_line "$file" "$entry" - echo "removed from $file ($entry)" >> "$__messages_out" - ;; -esac diff --git a/cdist/conf/type/__ssh_authorized_key/man.rst b/cdist/conf/type/__ssh_authorized_key/man.rst deleted file mode 100644 index 087a3dae..00000000 --- a/cdist/conf/type/__ssh_authorized_key/man.rst +++ /dev/null @@ -1,80 +0,0 @@ -cdist-type__ssh_authorized_key(7) -================================= - -NAME ----- -cdist-type__ssh_authorized_key - Manage a single ssh authorized key entry - - -DESCRIPTION ------------ -Manage a single authorized key entry in an authorized_key file. -This type was created to be used by the __ssh_authorized_keys type. - - -REQUIRED PARAMETERS -------------------- -file - the authorized_keys file to which the given key should be added - -key - a string containing the ssh keytype, base 64 encoded key and optional - trailing comment which shall be added to the given authorized_keys file. - - -OPTIONAL PARAMETERS -------------------- -comment - explicit comment instead of the one which may be trailing the given key - -option - an option to set for this authorized_key entry. - Can be specified multiple times. - See sshd(8) for available options. - -state - if the given keys should be 'present' or 'absent', defaults to 'present'. - - -MESSAGES --------- -added to `file` (`entry`) - The key `entry` (with optional comment) was added to `file`. - -removed from `file` (`entry`) - The key `entry` (with optional comment) was removed from `file`. - - -EXAMPLES --------- - -.. code-block:: sh - - __ssh_authorized_key some-id \ - --file "/home/user/.ssh/autorized_keys" \ - --key "$(cat ~/.ssh/id_rsa.pub)" - - __ssh_authorized_key some-id \ - --file "/home/user/.ssh/autorized_keys" \ - --key "$(cat ~/.ssh/id_rsa.pub)" \ - --option 'command="/path/to/script"' \ - --option 'environment="FOO=bar"' \ - --comment 'one to rule them all' - - -SEE ALSO --------- -:strong:`cdist__ssh_authorized_keys`\ (7), :strong:`sshd`\ (8) - - -AUTHORS -------- -Steven Armstrong - - -COPYING -------- -Copyright \(C) 2014 Steven Armstrong. 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. diff --git a/cdist/conf/type/__ssh_authorized_key/parameter/default/state b/cdist/conf/type/__ssh_authorized_key/parameter/default/state deleted file mode 100644 index e7f6134f..00000000 --- a/cdist/conf/type/__ssh_authorized_key/parameter/default/state +++ /dev/null @@ -1 +0,0 @@ -present diff --git a/cdist/conf/type/__ssh_authorized_key/parameter/optional b/cdist/conf/type/__ssh_authorized_key/parameter/optional deleted file mode 100644 index 89e8d966..00000000 --- a/cdist/conf/type/__ssh_authorized_key/parameter/optional +++ /dev/null @@ -1,2 +0,0 @@ -comment -state diff --git a/cdist/conf/type/__ssh_authorized_key/parameter/optional_multiple b/cdist/conf/type/__ssh_authorized_key/parameter/optional_multiple deleted file mode 100644 index 01925a15..00000000 --- a/cdist/conf/type/__ssh_authorized_key/parameter/optional_multiple +++ /dev/null @@ -1 +0,0 @@ -option diff --git a/cdist/conf/type/__ssh_authorized_key/parameter/required b/cdist/conf/type/__ssh_authorized_key/parameter/required deleted file mode 100644 index d51426c3..00000000 --- a/cdist/conf/type/__ssh_authorized_key/parameter/required +++ /dev/null @@ -1,2 +0,0 @@ -file -key diff --git a/cdist/conf/type/__ssh_authorized_keys/explorer/file b/cdist/conf/type/__ssh_authorized_keys/explorer/file deleted file mode 100755 index 5a02721a..00000000 --- a/cdist/conf/type/__ssh_authorized_keys/explorer/file +++ /dev/null @@ -1,27 +0,0 @@ -#!/bin/sh -# -# 2014 Steven Armstrong (steven-cdist at armstrong.cc) -# -# This file is part of cdist. -# -# cdist is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# cdist is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with cdist. If not, see . -# - -if [ -f "$__object/parameter/file" ]; then - cat "$__object/parameter/file" -else - owner="$(cat "$__object/parameter/owner" 2>/dev/null || echo "$__object_id")" - home=$(getent passwd "$owner" | cut -d':' -f 6) - echo "$home/.ssh/authorized_keys" -fi diff --git a/cdist/conf/type/__ssh_authorized_keys/explorer/group b/cdist/conf/type/__ssh_authorized_keys/explorer/group index 72a4e314..cdea6fe7 100755 --- a/cdist/conf/type/__ssh_authorized_keys/explorer/group +++ b/cdist/conf/type/__ssh_authorized_keys/explorer/group @@ -18,6 +18,5 @@ # along with cdist. If not, see . # -owner="$(cat "$__object/parameter/owner" 2>/dev/null || echo "$__object_id")" -gid="$(getent passwd "$owner" | cut -d':' -f 4)" +gid="$("$__type_explorer/passwd" | cut -d':' -f 4)" getent group "$gid" || true diff --git a/cdist/conf/type/__ssh_dot_ssh/explorer/passwd b/cdist/conf/type/__ssh_authorized_keys/explorer/passwd similarity index 90% rename from cdist/conf/type/__ssh_dot_ssh/explorer/passwd rename to cdist/conf/type/__ssh_authorized_keys/explorer/passwd index 3fbad06f..e6352ee0 100755 --- a/cdist/conf/type/__ssh_dot_ssh/explorer/passwd +++ b/cdist/conf/type/__ssh_authorized_keys/explorer/passwd @@ -1,7 +1,6 @@ #!/bin/sh # # 2012 Steven Armstrong (steven-cdist at armstrong.cc) -# 2014 Nico Schottelius (nico-cdist at schottelius.org) # # This file is part of cdist. # @@ -19,6 +18,6 @@ # along with cdist. If not, see . # -owner="$__object_id" +owner="$(cat "$__object/parameter/owner" 2>/dev/null || echo "$__object_id")" getent passwd "$owner" || true diff --git a/cdist/conf/type/__ssh_authorized_keys/man.rst b/cdist/conf/type/__ssh_authorized_keys/man.rst deleted file mode 100644 index ba310ff9..00000000 --- a/cdist/conf/type/__ssh_authorized_keys/man.rst +++ /dev/null @@ -1,121 +0,0 @@ -cdist-type__ssh_authorized_keys(7) -================================== - -NAME ----- -cdist-type__ssh_authorized_keys - Manage ssh authorized_keys files - - -DESCRIPTION ------------ -Adds or removes ssh keys from a authorized_keys file. - -This type uses the __ssh_dot_ssh type to manage the directory containing -the authorized_keys file. You can disable this feature with the --noparent -boolean parameter. - -The existence, ownership and permissions of the authorized_keys file itself are -also managed. This can be disabled with the --nofile boolean parameter. It is -then left to the user to ensure that the file exists and that ownership and -permissions work with ssh. - - -REQUIRED PARAMETERS -------------------- -key - the ssh key which shall be added to this authorized_keys file. - Must be a string and can be specified multiple times. - - -OPTIONAL PARAMETERS -------------------- -comment - explicit comment instead of the one which may be trailing the given key - -file - an alternative destination file, defaults to ~$owner/.ssh/authorized_keys - -option - an option to set for all created authorized_key entries. - Can be specified multiple times. - See sshd(8) for available options. - -owner - the user owning the authorized_keys file, defaults to object_id. - -state - if the given keys should be 'present' or 'absent', defaults to 'present'. - - -BOOLEAN PARAMETERS ------------------- -noparent - don't create or change ownership and permissions of the directory containing - the authorized_keys file - -nofile - don't manage existence, ownership and permissions of the the authorized_keys - file - - -EXAMPLES --------- - -.. code-block:: sh - - # add your ssh key to remote root's authorized_keys file - __ssh_authorized_keys root \ - --key "$(cat ~/.ssh/id_rsa.pub)" - - # allow key to login as user-name - __ssh_authorized_keys user-name \ - --key "ssh-rsa AXYZAAB3NzaC1yc2..." - - # allow key to login as user-name with options and expicit comment - __ssh_authorized_keys user-name \ - --key "ssh-rsa AXYZAAB3NzaC1yc2..." \ - --option no-agent-forwarding \ - --option 'from="*.example.com"' \ - --comment 'backup server' - - # same as above, but with explicit owner and two keys - # note that the options are set for all given keys - __ssh_authorized_keys some-fancy-id \ - --owner user-name \ - --key "ssh-rsa AXYZAAB3NzaC1yc2..." \ - --key "ssh-rsa AZXYAAB3NzaC1yc2..." \ - --option no-agent-forwarding \ - --option 'from="*.example.com"' \ - --comment 'backup server' - - # authorized_keys file in non standard location - __ssh_authorized_keys some-fancy-id \ - --file /etc/ssh/keys/user-name/authorized_keys \ - --owner user-name \ - --key "ssh-rsa AXYZAAB3NzaC1yc2..." - - # same as above, but directory and authorized_keys file is created elswhere - __ssh_authorized_keys some-fancy-id \ - --file /etc/ssh/keys/user-name/authorized_keys \ - --owner user-name \ - --noparent \ - --nofile \ - --key "ssh-rsa AXYZAAB3NzaC1yc2..." - - -SEE ALSO --------- -:strong:`sshd`\ (8) - - -AUTHORS -------- -Steven Armstrong - - -COPYING -------- -Copyright \(C) 2012-2014 Steven Armstrong. 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. diff --git a/cdist/conf/type/__ssh_authorized_keys/man.text b/cdist/conf/type/__ssh_authorized_keys/man.text new file mode 100644 index 00000000..9fd683fd --- /dev/null +++ b/cdist/conf/type/__ssh_authorized_keys/man.text @@ -0,0 +1,97 @@ +cdist-type__ssh_authorized_keys(7) +================================== +Steven Armstrong + + +NAME +---- +cdist-type__ssh_authorized_keys - manage ssh authorized_keys files + + +DESCRIPTION +----------- +Adds or removes ssh keys from a authorized_keys file. + +This type also manages the directory containing the authorized_keys +file and sets strict ownership and permissions. You can disable this feature +with the --noparent boolean parameter. + +The existence, ownership and permissions of the authorized_keys file itself are +also managed. This can be disabled with the --nofile boolean parameter. It is +then left to the user to ensure that the file exists and that ownership and +permissions work with ssh. + + +REQUIRED PARAMETERS +------------------- +key:: + the ssh key which shall be added to this authorized_keys file. + Must be a string and can be specified multiple times. + + +OPTIONAL PARAMETERS +------------------- +owner:: + the user owning the authorized_keys file, defaults to object_id. + +state:: + if the given keys should be 'present' or 'absent', defaults to 'present'. + +file:: + an alternative destination file, defaults to ~$owner/.ssh/authorized_keys + + +BOOLEAN PARAMETERS +------------------ +noparent:: + don't create or change ownership and permissions of the directory containing + the authorized_keys file + +nofile:: + don't manage existence, ownership and permissions of the the authorized_keys + file + + +EXAMPLES +-------- + +-------------------------------------------------------------------------------- +# add your ssh key to remote root's authorized_keys file +__ssh_authorized_keys root \ + --key "$(cat ~/.ssh/id_rsa.pub)" + +# allow key to login as user-name +__ssh_authorized_keys user-name \ + --key "ssh-rsa AXYZAAB3NzaC1yc2..." + +# same as above, but with explicit owner and two keys +__ssh_authorized_keys some-fancy-id \ + --owner user-name \ + --key "ssh-rsa AXYZAAB3NzaC1yc2..." \ + --key "ssh-rsa AZXYAAB3NzaC1yc2..." + +# same as above, but authorized_keys file in non standard location +__ssh_authorized_keys some-fancy-id \ + --file /etc/ssh/keys/user-name/authorized_keys \ + --owner user-name \ + --key "ssh-rsa AXYZAAB3NzaC1yc2..." + +# same as above, but directory and authorized_keys file is created elswhere +__ssh_authorized_keys some-fancy-id \ + --file /etc/ssh/keys/user-name/authorized_keys \ + --owner user-name \ + --noparent \ + --nofile \ + --key "ssh-rsa AXYZAAB3NzaC1yc2..." +-------------------------------------------------------------------------------- + + +SEE ALSO +-------- +- cdist-type(7) + + +COPYING +------- +Copyright \(C) 2012-2014 Steven Armstrong. Free use of this software is +granted under the terms of the GNU General Public License version 3 (GPLv3). diff --git a/cdist/conf/type/__ssh_authorized_keys/manifest b/cdist/conf/type/__ssh_authorized_keys/manifest index b507c7ff..1c9df208 100755 --- a/cdist/conf/type/__ssh_authorized_keys/manifest +++ b/cdist/conf/type/__ssh_authorized_keys/manifest @@ -1,4 +1,4 @@ -#!/bin/sh -e +#!/bin/sh # # 2012-2014 Steven Armstrong (steven-cdist at armstrong.cc) # 2014 Nico Schottelius (nico-cdist at schottelius.org) @@ -21,9 +21,18 @@ owner="$(cat "$__object/parameter/owner" 2>/dev/null || echo "$__object_id")" state="$(cat "$__object/parameter/state" 2>/dev/null)" -file="$(cat "$__object/explorer/file")" +if [ -f "$__object/parameter/file" ]; then + file="$(cat "$__object/parameter/file")" +else + home="$(cut -d':' -f 6 "$__object/explorer/passwd")" + if [ -z "$home" ]; then + echo "Failed to get home directory from explorer." >&2 + exit 1 + fi + file="$home/.ssh/authorized_keys" +fi -if [ ! -f "$__object/parameter/noparent" ] || [ ! -f "$__object/parameter/nofile" ]; then +if [ ! -f "$__object/parameter/noparent" -o ! -f "$__object/parameter/nofile" ]; then group="$(cut -d':' -f 1 "$__object/explorer/group")" if [ -z "$group" ]; then echo "Failed to get owners group from explorer." >&2 @@ -31,8 +40,12 @@ if [ ! -f "$__object/parameter/noparent" ] || [ ! -f "$__object/parameter/nofile fi if [ ! -f "$__object/parameter/noparent" ]; then - __ssh_dot_ssh "$owner" - export require="__ssh_dot_ssh/$owner" + # Ensure that the directory in which the authorized_keys shall be exists and + # has the right permissions. + ssh_directory="${file%/*}" + __directory "$ssh_directory" --state present --parents \ + --owner "$owner" --group "$group" --mode 0700 + export require="__directory/$ssh_directory" fi if [ ! -f "$__object/parameter/nofile" ]; then # Ensure that authorized_keys file exists and has the right permissions. @@ -41,28 +54,35 @@ if [ ! -f "$__object/parameter/noparent" ] || [ ! -f "$__object/parameter/nofile --group "$group" \ --mode 0600 \ --state exists - export require="__file/$file" fi fi +# Remove legacy blocks created by old versions of this type +# FIXME: remove me in 3.2+ +__block "$__object_name" \ + --file "$file" \ + --prefix "#cdist:$__object_name" \ + --suffix "#/cdist:$__object_name" \ + --state 'absent' \ + --text - << DONE +remove legacy block +DONE + _cksum() { echo "$1" | cksum | cut -d' ' -f 1 } -while read -r key; do - type_and_key="$(echo "$key" | tr ' ' '\n' | awk '/^(ssh|ecdsa)-[^ ]+/ { printf $1" "; getline; printf $1 }')" - object_id="$(_cksum "$file")-$(_cksum "$type_and_key")" - set -- "$object_id" +while read key; do + cksum_key="$(_cksum "$key")" + line_id="${owner}-${cksum_key}" + + set -- "$line_id" set -- "$@" --file "$file" - set -- "$@" --key "$key" + set -- "$@" --regex ".*$key.*" + if [ "$state" = 'present' ]; then + set -- "$@" --line "$key" + fi set -- "$@" --state "$state" - if [ -f "$__object/parameter/option" ]; then - # shellcheck disable=SC2046 - set -- "$@" $(printf -- '--option %s ' $(cat "$__object/parameter/option")) - fi - if [ -f "$__object/parameter/comment" ]; then - set -- "$@" --comment "$(cat "$__object/parameter/comment")" - fi - # Ensure __ssh_authorized_key does not read stdin - __ssh_authorized_key "$@" < /dev/null + # Ensure __line does not read stdin + require="__block/$__object_name" __line "$@" < /dev/null done < "$__object/parameter/key" diff --git a/cdist/conf/type/__ssh_authorized_keys/parameter/optional b/cdist/conf/type/__ssh_authorized_keys/parameter/optional index 21f9bc29..989750b3 100644 --- a/cdist/conf/type/__ssh_authorized_keys/parameter/optional +++ b/cdist/conf/type/__ssh_authorized_keys/parameter/optional @@ -1,5 +1,3 @@ -comment -file -option owner state +file diff --git a/cdist/conf/type/__ssh_dot_ssh/explorer/group b/cdist/conf/type/__ssh_dot_ssh/explorer/group deleted file mode 100755 index cdea6fe7..00000000 --- a/cdist/conf/type/__ssh_dot_ssh/explorer/group +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/sh -# -# 2014 Steven Armstrong (steven-cdist at armstrong.cc) -# -# This file is part of cdist. -# -# cdist is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# cdist is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with cdist. If not, see . -# - -gid="$("$__type_explorer/passwd" | cut -d':' -f 4)" -getent group "$gid" || true diff --git a/cdist/conf/type/__ssh_dot_ssh/man.rst b/cdist/conf/type/__ssh_dot_ssh/man.rst deleted file mode 100644 index 7d35affa..00000000 --- a/cdist/conf/type/__ssh_dot_ssh/man.rst +++ /dev/null @@ -1,49 +0,0 @@ -cdist-type__ssh_dot_ssh(7) -========================== - -NAME ----- -cdist-type__ssh_dot_ssh - Manage .ssh directory - - -DESCRIPTION ------------ -Adds or removes .ssh directory to a user home. - -This type is being used by __ssh_authorized_keys. - - -OPTIONAL PARAMETERS -------------------- -state - if the directory should be 'present' or 'absent', defaults to 'present'. - - -EXAMPLES --------- - -.. code-block:: sh - - # Ensure root has ~/.ssh with the right permissions - __ssh_dot_ssh root - - # Nico does not need ~/.ssh anymore - __ssh_dot_ssh nico --state absent - - -SEE ALSO --------- -:strong:`cdist-type__ssh_authorized_keys`\ (7) - - -AUTHORS -------- -Nico Schottelius - - -COPYING -------- -Copyright \(C) 2014 Nico Schottelius. 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. diff --git a/cdist/conf/type/__ssh_dot_ssh/manifest b/cdist/conf/type/__ssh_dot_ssh/manifest deleted file mode 100755 index bc3a3952..00000000 --- a/cdist/conf/type/__ssh_dot_ssh/manifest +++ /dev/null @@ -1,44 +0,0 @@ -#!/bin/sh -e -# -# 2012-2014 Steven Armstrong (steven-cdist at armstrong.cc) -# 2014 Nico Schottelius (nico-cdist at schottelius.org) -# -# This file is part of cdist. -# -# cdist is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# cdist is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with cdist. If not, see . -# -# Hacked in Kalamata, Greece -# - -owner="$__object_id" -state="$(cat "$__object/parameter/state")" - -group="$(cut -d':' -f 1 "$__object/explorer/group")" -if [ -z "$group" ]; then - echo "Failed to get owners group from explorer." >&2 - exit 1 -fi - -home="$(cut -d':' -f 6 "$__object/explorer/passwd")" -if [ -z "$home" ]; then - echo "Failed to get home directory from explorer." >&2 - exit 1 -fi -ssh_directory="${home}/.ssh" - -# Ensure that the directory in which the authorized_keys shall be exists and -# has the right permissions. -__directory "$ssh_directory" \ - --state "$state" \ - --owner "$owner" --group "$group" --mode 0700 diff --git a/cdist/conf/type/__ssh_dot_ssh/parameter/default/state b/cdist/conf/type/__ssh_dot_ssh/parameter/default/state deleted file mode 100644 index e7f6134f..00000000 --- a/cdist/conf/type/__ssh_dot_ssh/parameter/default/state +++ /dev/null @@ -1 +0,0 @@ -present diff --git a/cdist/conf/type/__ssh_dot_ssh/parameter/optional b/cdist/conf/type/__ssh_dot_ssh/parameter/optional deleted file mode 100644 index ff72b5c7..00000000 --- a/cdist/conf/type/__ssh_dot_ssh/parameter/optional +++ /dev/null @@ -1 +0,0 @@ -state diff --git a/cdist/conf/type/__staged_file/gencode-local b/cdist/conf/type/__staged_file/gencode-local deleted file mode 100755 index ba9e8798..00000000 --- a/cdist/conf/type/__staged_file/gencode-local +++ /dev/null @@ -1,104 +0,0 @@ -#!/bin/sh -e -# -# 2015 Steven Armstrong (steven-cdist at armstrong.cc) -# 2015 Nico Schottelius (nico-cdist at schottelius.org) -# -# This file is part of cdist. -# -# cdist is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# cdist is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with cdist. If not, see . -# - -#set -x - -destination="$__object_id" -source="$(cat "$__object/parameter/source")" -stage_dir="$(cat "$__object/parameter/stage-dir")" -state="$(cat "$__object/parameter/state")" -fetch_command="$(cat "$__object/parameter/fetch-command")" -stage_file="${stage_dir}/${destination}" -stage_file_dir="${stage_file%/*}" -source_file_name="${source##*/}" - -if [ "$state" = "absent" ]; then - # nothing to do - exit 0 -fi - -#printf 'set -x\n' - -if [ ! -d "$stage_dir" ]; then - printf 'mkdir -p "%s"\n' "$stage_dir" - printf 'chmod 700 "%s"\n' "$stage_dir" -fi - -if [ ! -d "$stage_file_dir" ]; then - printf 'mkdir -p "%s"\n' "$stage_file_dir" -fi - - -get_file() { - if [ -f "$__object/parameter/prepare-command" ]; then - fetch_and_prepare_file - else - fetch_file - fi -} - -fetch_file() { - # shellcheck disable=SC2059 - printf "$fetch_command" "$source" - printf ' > "%s"\n' "$stage_file" -} - -fetch_and_prepare_file() { - # shellcheck disable=SC2016 - printf 'tmpdir="$(mktemp -d -p "/tmp" "%s")"\n' "${__type##*/}.XXXXXXXXXX" - # shellcheck disable=SC2016 - printf 'cd "$tmpdir"\n' - # shellcheck disable=SC2059 - printf "$fetch_command > \"%s\"\\n" "$source" "$source_file_name" - prepare_command="$(cat "$__object/parameter/prepare-command")" - # shellcheck disable=SC2059 - printf "$prepare_command > \"%s\"\\n" "$source_file_name" "$stage_file" - printf 'cd - >/dev/null\n' - # shellcheck disable=SC2016 - printf 'rm -rf "$tmpdir"\n' -} - -cat << DONE -verify_cksum() { - cksum_is="\$(cksum "$stage_file" | cut -d' ' -f1,2)" - cksum_should="$(cut -d' ' -f1,2 "$__object/parameter/cksum")" - if [ "\$cksum_is" = "\$cksum_should" ]; then - return 0 - else - return 1 - fi -} -DONE - -if [ ! -f "$stage_file" ]; then - get_file -else - printf 'verify_cksum || {\n' - get_file - printf '}\n' -fi - -cat << DONE -verify_cksum || { - echo "Failed to verify checksum for $__object_name" >&2 - exit 1 -} -DONE diff --git a/cdist/conf/type/__staged_file/man.rst b/cdist/conf/type/__staged_file/man.rst deleted file mode 100644 index 9a6ba732..00000000 --- a/cdist/conf/type/__staged_file/man.rst +++ /dev/null @@ -1,115 +0,0 @@ -cdist-type__staged_file(7) -========================== - -NAME ----- -cdist-type__staged_file - Manage staged files - - -DESCRIPTION ------------ -Manages a staged file that is downloaded on the server (the machine running -cdist) and then deployed to the target host using the __file type. - - -REQUIRED PARAMETERS -------------------- -source - the URL from which to retrieve the source file. - e.g. - - * https://dl.bintray.com/mitchellh/consul/0.4.1_linux_amd64.zip - * file:///path/to/local/file - -cksum - the output of running the command: `cksum $source-file` - e.g.:: - - $ echo foobar > /tmp/foobar - $ cksum /tmp/foobar - 857691210 7 /tmp/foobar - - If either checksum or file size has changed the file will be - (re)fetched from the --source. The file name can be omitted and is - ignored if given. - - -OPTIONAL PARAMETERS -------------------- -fetch-command - the command used to fetch the staged file using printf formatting. - Where a single %s will be replaced with the value of the given --source - parameter. The --fetch-command is expected to output the fetched file to - stdout. - Defaults to 'curl -s -L "%s"'. - -group - see cdist-type__file - -owner - see cdist-type__file - -mode - see cdist-type__file - -prepare-command - the optional command used to prepare or preprocess the staged file for later - use by the file type. - If given, it must be a string in printf formatting where a single %s will - be replaced with the last segment (filename) of the value of the given - --source parameter. - It is executed in the same directory into which the fetched file has been - saved. The --prepare-command is expected to output the final file to stdout. - - So for example given a --source of https://example.com/my-zip.zip, and a - --prepare-command of 'unzip -p "%s"', the code `unzip -p "my-zip.zip"` will - be executed in the folder containing the downloaded file my-zip.zip. - A more complex example might be --prepare-command 'tar -xz "%s"; cat path/from/archive' -stage-dir - the directory in which to store downloaded and prepared files. - Defaults to '/var/tmp/cdist/__staged_file' - -state - see cdist-type__file - - -EXAMPLES --------- - -.. code-block:: sh - - __staged_file /usr/local/bin/consul \ - --source file:///path/to/local/copy/consul \ - --cksum '428915666 15738724' \ - --state present \ - --group root \ - --owner root \ - --mode 755 - - __staged_file /usr/local/bin/consul \ - --source https://dl.bintray.com/mitchellh/consul/0.4.1_linux_amd64.zip \ - --cksum '428915666 15738724' \ - --fetch-command 'curl -s -L "%s"' \ - --prepare-command 'unzip -p "%s"' \ - --state present \ - --group root \ - --owner root \ - --mode 755 - - -SEE ALSO --------- -:strong:`cdist-type__file`\ (7) - - -AUTHORS -------- -Steven Armstrong - - -COPYING -------- -Copyright \(C) 2015 Steven Armstrong. 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. diff --git a/cdist/conf/type/__staged_file/manifest b/cdist/conf/type/__staged_file/manifest deleted file mode 100755 index c8e1fbbb..00000000 --- a/cdist/conf/type/__staged_file/manifest +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/sh -e -# -# 2015 Steven Armstrong (steven-cdist at armstrong.cc) -# -# This file is part of cdist. -# -# cdist is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# cdist is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with cdist. If not, see . -# - -destination="$__object_id" -stage_dir="$(cat "$__object/parameter/stage-dir")" -stage_file="${stage_dir}/${destination}" - -set -- "/${destination}" -for param in owner group mode state; do - if [ -f "$__object/parameter/$param" ]; then - set -- "$@" "--${param}" "$(cat "$__object/parameter/$param")" - fi -done -set -- "$@" --source "$stage_file" - -require="$__object_name" \ - __file "$@" diff --git a/cdist/conf/type/__staged_file/parameter/default/fetch-command b/cdist/conf/type/__staged_file/parameter/default/fetch-command deleted file mode 100644 index b4dc1211..00000000 --- a/cdist/conf/type/__staged_file/parameter/default/fetch-command +++ /dev/null @@ -1 +0,0 @@ -curl -s -L "%s" diff --git a/cdist/conf/type/__staged_file/parameter/default/stage-dir b/cdist/conf/type/__staged_file/parameter/default/stage-dir deleted file mode 100644 index 9420b510..00000000 --- a/cdist/conf/type/__staged_file/parameter/default/stage-dir +++ /dev/null @@ -1 +0,0 @@ -/var/tmp/cdist/__staged_file diff --git a/cdist/conf/type/__staged_file/parameter/default/state b/cdist/conf/type/__staged_file/parameter/default/state deleted file mode 100644 index e7f6134f..00000000 --- a/cdist/conf/type/__staged_file/parameter/default/state +++ /dev/null @@ -1 +0,0 @@ -present diff --git a/cdist/conf/type/__staged_file/parameter/optional b/cdist/conf/type/__staged_file/parameter/optional deleted file mode 100644 index 18f4e87a..00000000 --- a/cdist/conf/type/__staged_file/parameter/optional +++ /dev/null @@ -1,7 +0,0 @@ -fetch-command -group -owner -mode -prepare-command -stage-dir -state diff --git a/cdist/conf/type/__staged_file/parameter/required b/cdist/conf/type/__staged_file/parameter/required deleted file mode 100644 index bfb1d5bf..00000000 --- a/cdist/conf/type/__staged_file/parameter/required +++ /dev/null @@ -1,2 +0,0 @@ -cksum -source diff --git a/cdist/conf/type/__start_on_boot/explorer/state b/cdist/conf/type/__start_on_boot/explorer/state old mode 100644 new mode 100755 index b7a6cf0f..e9e4318e --- a/cdist/conf/type/__start_on_boot/explorer/state +++ b/cdist/conf/type/__start_on_boot/explorer/state @@ -1,6 +1,6 @@ #!/bin/sh # -# 2012-2019 Nico Schottelius (nico-cdist at schottelius.org) +# 2012-2013 Nico Schottelius (nico-cdist at schottelius.org) # 2013 Daniel Heule (hda at sfs.biz) # # This file is part of cdist. @@ -24,81 +24,42 @@ os=$("$__explorer/os") runlevel=$("$__explorer/runlevel") -init=$("$__explorer/init") target_runlevel="$(cat "$__object/parameter/target_runlevel")" name="$__object_id" -if [ "$init" = 'systemd' ]; then - # this handles ALL linux distros with systemd - # e.g. archlinux, gentoo, new RHEL and SLES versions - state=$(systemctl is-enabled "$name" >/dev/null 2>&1 \ - && echo present \ - || echo absent) +case "$os" in + archlinux) + state=$(systemctl is-enabled "$name" >/dev/null 2>&1 \ + && echo present \ + || echo absent) + ;; -else - case "$os" in - debian|openwrt|devuan) - state="absent" - for file in "/etc/rc$runlevel.d/S"??"$name" - do - if [ -f "$file" ] - then - state="present" - break - fi - done - ;; - ubuntu) - state="absent" - for file in "/etc/rc$runlevel.d/S"??"$name" - do - if [ -f "$file" ] - then - state="present" - break - fi - done + debian|ubuntu|openwrt) + state="present" + [ -f "/etc/rc$runlevel.d/S"??"$name" ] || state="absent" + ;; - [ -f "/etc/init/${name}.conf" ] && state="present" - ;; - - amazon|scientific|centos|fedora|owl|redhat) - state=$(chkconfig --level "$runlevel" "$name" || echo absent) - [ "$state" ] || state="present" - ;; - suse) - # check for target if set, usable for boot. services in runlevel B - if [ "$target_runlevel" != 'default' ]; then - runlevel="$target_runlevel" - fi - # suses chkconfig has the same name, but works different ... - state=$(chkconfig --check "$name" "$runlevel" || echo absent) - [ "$state" ] || state="present" - ;; - gentoo|alpine) - state="absent" - for d in /etc/runlevels/*; do - if [ -f "/etc/runlevels/${d}/${name}" ];then - state="present" - break - fi - done - ;; - freebsd) - state="absent" - service -e | grep "/$name$" && state="present" - ;; - openbsd) - state='absent' - # OpenBSD 5.7 and higher - rcctl ls on | grep "^${name}$" && state='present' - ;; - - *) - echo "Unsupported os: $os" >&2 - exit 1 - ;; - esac -fi + amazon|centos|fedora|owl|redhat) + state=$(chkconfig --level "$runlevel" "$name" || echo absent) + [ "$state" ] || state="present" + ;; + suse) + # check for target if set, usable for boot. services in runlevel B + if [ "$target_runlevel" != 'default' ]; then + runlevel="$target_runlevel" + fi + # suses chkconfig has the same name, but works different ... + state=$(chkconfig --check "$name" "$runlevel" || echo absent) + [ "$state" ] || state="present" + ;; + gentoo) + state="present" + [ -f "/etc/runlevels/${target_runlevel}/${name}" ] || state="absent" + ;; + *) + echo "Unsupported os: $os" >&2 + exit 1 + ;; +esac echo $state diff --git a/cdist/conf/type/__start_on_boot/gencode-remote b/cdist/conf/type/__start_on_boot/gencode-remote index c900933f..61b2b9fe 100755 --- a/cdist/conf/type/__start_on_boot/gencode-remote +++ b/cdist/conf/type/__start_on_boot/gencode-remote @@ -1,7 +1,7 @@ -#!/bin/sh -e +#!/bin/sh # # 2012-2013 Nico Schottelius (nico-cdist at schottelius.org) -# 2016 Daniel Heule (hda at sfs.biz) +# 2013 Daniel Heule (hda at sfs.biz) # # This file is part of cdist. # @@ -22,113 +22,73 @@ state_should="$(cat "$__object/parameter/state")" state_is=$(cat "$__object/explorer/state") -init=$(cat "$__global/explorer/init") target_runlevel="$(cat "$__object/parameter/target_runlevel")" # Short circuit if nothing is to be done [ "$state_should" = "$state_is" ] && exit 0 os=$(cat "$__global/explorer/os") -os_version=$(cat "$__global/explorer/os_version") name="$__object_id" case "$state_should" in present) - if [ "$init" = 'systemd' ]; then - # this handles ALL linux distros with systemd - # e.g. archlinux, gentoo in some cases, new RHEL and SLES versions - echo "systemctl -q enable '$name'" - else - case "$os" in - debian) - case "$os_version" in - [1-7]*) - echo "update-rc.d '$name' defaults >/dev/null" - ;; - 8*) - echo "systemctl enable '$name'" - ;; - *) - echo "Unsupported version $os_version of $os" >&2 - exit 1 - ;; - esac - ;; - devuan) - echo "update-rc.d '$name' defaults >/dev/null" - ;; + case "$os" in + archlinux) + echo "systemctl enable \"$name\"" + ;; + debian|ubuntu) + echo "update-rc.d \"$name\" defaults >/dev/null" + ;; - alpine|gentoo) - echo "rc-update add '$name' '$target_runlevel'" - ;; + gentoo) + echo rc-update add \"$name\" \"$target_runlevel\" + ;; - amazon|scientific|centos|fedora|owl|redhat|suse) - echo "chkconfig '$name' on" - ;; + amazon|centos|fedora|owl|redhat|suse) + echo chkconfig \"$name\" on + ;; - openwrt) - # 'enable' can be successful and still return a non-zero exit - # code, deal with it by checking for success ourselves in that - # case (the || ... part). - echo "'/etc/init.d/$name' enable || [ -f /etc/rc.d/S??'$name' ]" - ;; + openwrt) + # 'enable' can be successful and still return a non-zero exit + # code, deal with it by checking for success ourselves in that + # case (the || ... part). + echo "/etc/init.d/\"$name\" enable || [ -f /etc/rc.d/S??\"$name\" ]" + ;; - ubuntu) - echo "update-rc.d '$name' defaults >/dev/null" - ;; - - freebsd) - : # handled in manifest - ;; - - openbsd) - # OpenBSD 5.7 and higher - echo "rcctl enable '$name'" - ;; - - *) - echo "Unsupported os: $os" >&2 - exit 1 - ;; - esac - fi + *) + echo "Unsupported os: $os" >&2 + exit 1 + ;; + esac ;; absent) - if [ "$init" = 'systemd' ]; then - # this handles ALL linux distros with systemd - # e.g. archlinux, gentoo in some cases, new RHEL and SLES versions - echo "systemctl -q disable '$name'" + case "$os" in + archlinux) + echo "systemctl disable \"$name\"" + ;; + debian|ubuntu) + echo update-rc.d -f \"$name\" remove + ;; - else - case "$os" in - debian|ubuntu|devuan) - echo "update-rc.d -f '$name' remove" - ;; + gentoo) + echo rc-update del \"$name\" \"$target_runlevel\" + ;; - alpine|gentoo) - echo "rc-update del '$name' '$target_runlevel'" - ;; + centos|fedora|owl|redhat|suse) + echo chkconfig \"$name\" off + ;; - centos|fedora|owl|redhat|suse) - echo "chkconfig '$name' off" - ;; + openwrt) + echo "\"/etc/init.d/$name\" disable" + ;; - openwrt) - echo "'/etc/init.d/$name' disable" - ;; - - openbsd) - # OpenBSD 5.7 and higher - echo "rcctl disable '$name'" - ;; - - *) - echo "Unsupported os: $os" >&2 - exit 1 - ;; - esac - fi + *) + echo "Unsupported os: $os" >&2 + exit 1 + ;; + esac + ;; *) diff --git a/cdist/conf/type/__start_on_boot/man.rst b/cdist/conf/type/__start_on_boot/man.text similarity index 51% rename from cdist/conf/type/__start_on_boot/man.rst rename to cdist/conf/type/__start_on_boot/man.text index b7c73ab1..dfada6d8 100644 --- a/cdist/conf/type/__start_on_boot/man.rst +++ b/cdist/conf/type/__start_on_boot/man.text @@ -1,5 +1,7 @@ cdist-type__start_on_boot(7) ============================ +Nico Schottelius + NAME ---- @@ -12,50 +14,43 @@ This cdist type allows you to enable or disable stuff to be started at boot of your operating system. Warning: This type has not been tested intensively and is not fully -supported (i.e. \*BSD are not implemented). +supported (i.e. *bsd are not implemented). REQUIRED PARAMETERS ------------------- None. - OPTIONAL PARAMETERS ------------------- -state +state:: Either "present" or "absent", defaults to "present" -target_runlevel +target_runlevel:: Runlevel which should be modified, defaults to "default" (only used on gentoo systems). EXAMPLES -------- -.. code-block:: sh +-------------------------------------------------------------------------------- +# Ensure snmpd is started at boot +__start_on_boot snmpd - # Ensure snmpd is started at boot - __start_on_boot snmpd +# Same, but more explicit +__start_on_boot snmpd --state present - # Same, but more explicit - __start_on_boot snmpd --state present - - # Ensure legacy configuration management will not be started - __start_on_boot puppet --state absent +# Ensure legacy configuration management will not be started +__start_on_boot puppet --state absent +-------------------------------------------------------------------------------- SEE ALSO -------- -:strong:`cdist-type__process`\ (7) - - -AUTHORS -------- -Nico Schottelius +- cdist-type(7) +- cdist-type__process(7) COPYING ------- -Copyright \(C) 2012-2019 Nico Schottelius. 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. +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/cdist/conf/type/__start_on_boot/manifest b/cdist/conf/type/__start_on_boot/manifest deleted file mode 100644 index c1c983ec..00000000 --- a/cdist/conf/type/__start_on_boot/manifest +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/sh -e - -state_should="$(cat "$__object/parameter/state")" -state_is=$(cat "$__object/explorer/state") -name="$__object_id" - -# Short circuit if nothing is to be done -[ "$state_should" = "$state_is" ] && exit 0 - -os=$(cat "$__global/explorer/os") - -case "$os" in - freebsd) - if [ "$state_should" = 'present' ]; then - value='YES' - else - value='NO' - fi - __key_value "rcconf-$name-enable" \ - --file /etc/rc.conf \ - --key "${name}_enable" \ - --value "\"$value\"" \ - --delimiter '=' - ;; - *) - : # handled in gencode-remote - ;; -esac diff --git a/cdist/conf/type/__sysctl/explorer/conf-path b/cdist/conf/type/__sysctl/explorer/conf-path deleted file mode 100755 index ba35c4c6..00000000 --- a/cdist/conf/type/__sysctl/explorer/conf-path +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/sh -# -# 2018 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 . -# - -if [ -d "/etc/sysctl.d" ]; then - echo "/etc/sysctl.d/99-Z-sysctl-cdist.conf"; -else - echo "/etc/sysctl.conf"; -fi diff --git a/cdist/conf/type/__sysctl/explorer/value b/cdist/conf/type/__sysctl/explorer/value deleted file mode 100755 index fc85b3d8..00000000 --- a/cdist/conf/type/__sysctl/explorer/value +++ /dev/null @@ -1,22 +0,0 @@ -#!/bin/sh -# -# 2014 Steven Armstrong (steven-cdist at armstrong.cc) -# -# This file is part of cdist. -# -# cdist is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# cdist is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with cdist. If not, see . -# - -# get the current runtime value -sysctl -n "$__object_id" || true diff --git a/cdist/conf/type/__sysctl/gencode-remote b/cdist/conf/type/__sysctl/gencode-remote deleted file mode 100755 index 711d54e5..00000000 --- a/cdist/conf/type/__sysctl/gencode-remote +++ /dev/null @@ -1,55 +0,0 @@ -#!/bin/sh -e -# -# 2014 Steven Armstrong (steven-cdist at armstrong.cc) -# 2018 Takashi Yoshi (takashi at yoshi.email) -# -# 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 . -# - -value_should="$(cat "$__object/parameter/value")" -value_is="$(cat "$__object/explorer/value")" - -if [ "$value_should" = "$value_is" ]; then - # Nothing to do - exit 0 -fi - -os=$(cat "$__global/explorer/os") -case "$os" in - # Linux - redhat|centos|ubuntu|debian|devuan|archlinux|gentoo|coreos) - flag='-w' - ;; - # BusyBox - alpine|openwrt) - flag='-w' - ;; - macosx) - # NOTE: Older versions of Mac OS X require the -w option. - # Even though the flag is not mentioned in new man pages anymore, - # it still works. - flag='-w' - ;; - netbsd) - flag='-w' - ;; - freebsd|openbsd) - flag='' - ;; -esac - -# set the current runtime value -printf 'sysctl %s %s="%s"\n' "$flag" "$__object_id" "$value_should" diff --git a/cdist/conf/type/__sysctl/man.rst b/cdist/conf/type/__sysctl/man.rst deleted file mode 100644 index 6873003e..00000000 --- a/cdist/conf/type/__sysctl/man.rst +++ /dev/null @@ -1,39 +0,0 @@ -cdist-type__sysctl(7) -===================== - -NAME ----- -cdist-type__sysctl - manage sysctl settings - - -DESCRIPTION ------------ -Manages permanent as well as runtime sysctl settings. -Permament settings are set by managing entries in /etc/sysctl.conf. -Runtime settings are set by directly calling the sysctl executable. - - -REQUIRED PARAMETERS -------------------- -value - The value to set for the given key (object_id) - - -EXAMPLES --------- - -.. code-block:: sh - - __sysctl net.ipv4.ip_forward --value 1 - - -AUTHORS -------- -Steven Armstrong - - -COPYING -------- -Copyright \(C) 2014 Steven Armstrong. Free use of this software is -granted under the terms of the GNU General Public License version 3 or -later (GPLv3+). diff --git a/cdist/conf/type/__sysctl/manifest b/cdist/conf/type/__sysctl/manifest deleted file mode 100755 index b4e2e902..00000000 --- a/cdist/conf/type/__sysctl/manifest +++ /dev/null @@ -1,47 +0,0 @@ -#!/bin/sh -e -# -# 2014 Steven Armstrong (steven-cdist at armstrong.cc) -# 2018 Takashi Yoshi (takashi at yoshi.email) -# -# This file is part of cdist. -# -# cdist is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# cdist is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with cdist. If not, see . -# - - -os=$(cat "$__global/explorer/os") - -case "$os" in - # Linux - redhat|centos|ubuntu|debian|devuan|archlinux|coreos) - : - ;; - # BSD - freebsd|macosx|netbsd|openbsd) - : - ;; - *) - echo "Your operating system ($os) is currently not supported by this type (${__type##*/})." >&2 - echo "Please contribute an implementation for it if you can." >&2 - exit 1 - ;; -esac - -conf_path=$(cat "$__object/explorer/conf-path") - -__key_value "$__object_name" \ - --key "$__object_id" \ - --file "${conf_path}" \ - --value "$(cat "$__object/parameter/value")" \ - --delimiter '=' diff --git a/cdist/conf/type/__sysctl/parameter/required b/cdist/conf/type/__sysctl/parameter/required deleted file mode 100644 index 6d4e1507..00000000 --- a/cdist/conf/type/__sysctl/parameter/required +++ /dev/null @@ -1 +0,0 @@ -value diff --git a/cdist/conf/type/__systemd_unit/explorer/enablement-state b/cdist/conf/type/__systemd_unit/explorer/enablement-state deleted file mode 100644 index 5a5a4462..00000000 --- a/cdist/conf/type/__systemd_unit/explorer/enablement-state +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/sh -# -# 2017 Ľubomír Kučera -# -# 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 . -# - -systemctl is-enabled "${__object_id}" 2>/dev/null || true diff --git a/cdist/conf/type/__systemd_unit/explorer/systemctl-present b/cdist/conf/type/__systemd_unit/explorer/systemctl-present deleted file mode 100644 index 7218affc..00000000 --- a/cdist/conf/type/__systemd_unit/explorer/systemctl-present +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/sh -# -# 2017 Ľubomír Kučera -# -# 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 . -# - -command -v systemctl > /dev/null 2>&1 && echo 0 || echo 1 diff --git a/cdist/conf/type/__systemd_unit/explorer/unit-status b/cdist/conf/type/__systemd_unit/explorer/unit-status deleted file mode 100644 index b68e5169..00000000 --- a/cdist/conf/type/__systemd_unit/explorer/unit-status +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/sh -# -# 2017 Ľubomír Kučera -# -# 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 . -# - -systemctl is-active "${__object_id}" || true diff --git a/cdist/conf/type/__systemd_unit/gencode-remote b/cdist/conf/type/__systemd_unit/gencode-remote deleted file mode 100644 index 967a6c87..00000000 --- a/cdist/conf/type/__systemd_unit/gencode-remote +++ /dev/null @@ -1,76 +0,0 @@ -#!/bin/sh -e -# -# 2017 Ľubomír Kučera -# -# This file is part of cdist. -# -# cdist is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# cdist is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with cdist. If not, see . -# - -name="${__object_id}" -state=$(cat "${__object}/parameter/state") -current_enablement_state=$(cat "${__object}/explorer/enablement-state") - -if [ "${state}" = "absent" ]; then - if [ -n "${current_enablement_state}" ]; then - echo "systemctl --now disable ${name}" - echo "rm -f /etc/systemd/system/${name}" - echo "systemctl daemon-reload" - fi - - exit 0 -fi - -unit_status=$(cat "${__object}/explorer/unit-status") -desired_enablement_state=$(cat "${__object}/parameter/enablement-state") - -if [ "${current_enablement_state}" = "masked" ] && \ - [ "${desired_enablement_state}" != "masked" ]; then - echo "systemctl unmask ${name}" -fi - -if [ -f "${__object}/parameter/restart" ]; then - if [ "${desired_enablement_state}" = "masked" ]; then - if [ "${unit_status}" = "active" ]; then - echo "systemctl stop ${name}" - fi - elif grep -q "^__file/etc/systemd/system/${name}" "${__messages_in}" || \ - [ "${unit_status}" != "active" ]; then - echo "systemctl restart ${name} || true" - fi -fi - -if [ "${current_enablement_state}" = "${desired_enablement_state}" ]; then - exit 0 -fi - -case "${desired_enablement_state}" in - "") - # Do nothing - : - ;; - enabled) - echo "systemctl enable ${name}" - ;; - disabled) - echo "systemctl disable ${name}" - ;; - masked) - echo "systemctl mask ${name}" - ;; - *) - echo "Unsupported unit status: ${desired_enablement_state}" >&2 - exit 1 - ;; -esac diff --git a/cdist/conf/type/__systemd_unit/man.rst b/cdist/conf/type/__systemd_unit/man.rst deleted file mode 100644 index 25a4e501..00000000 --- a/cdist/conf/type/__systemd_unit/man.rst +++ /dev/null @@ -1,89 +0,0 @@ -cdist-type__systemd_unit(7) -=========================== - -NAME ----- - -cdist-type__systemd_unit - Install a systemd unit - -DESCRIPTION ------------ - -This type manages systemd units in ``/etc/systemd/system/``. It can install, -enable and start a systemd unit. This is particularly useful on systems which -take advantage of systemd heavily (e.g., CoreOS). For more information about -systemd units, see SYSTEMD.UNIT(5). - -REQUIRED PARAMETERS -------------------- - -None. - -OPTIONAL PARAMETERS -------------------- - -enablement-state - 'enabled', 'disabled' or 'masked', where: - - enabled - enables the unit - disabled - disables the unit - masked - masks the unit - -source - Path to the config file. If source is '-' (dash), take what was written to - stdin as the config file content. - -state - 'present' or 'absent', defaults to 'present' where: - - present - the unit (or its mask) is installed - absent - The unit is stopped, disabled and uninstalled. If the unit was masked, - the mask is removed. - -BOOLEAN PARAMETERS ------------------- - -restart - Start the unit if it was inactive. Restart the unit if the unit file - changed. Stop the unit if new ``enablement-state`` is ``masked``. - -MESSAGES --------- - -None. - -EXAMPLES --------- - -.. code-block:: sh - - # Installs, enables and starts foobar.service - __systemd_unit foobar.service \ - --source "${__manifest}/files/foobar.service" \ - --enablement-state enabled \ - --restart - - # Disables the unit - __systemd_unit foobar.service --enablement-state disabled - - # Stops, disables and uninstalls foobar.service - __systemd_unit foobar.service --state absent - - -AUTHORS -------- - -Ľubomír Kučera - -COPYING -------- - -Copyright \(C) 2017 Ľubomír Kučera. 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. diff --git a/cdist/conf/type/__systemd_unit/manifest b/cdist/conf/type/__systemd_unit/manifest deleted file mode 100644 index 688a00b1..00000000 --- a/cdist/conf/type/__systemd_unit/manifest +++ /dev/null @@ -1,58 +0,0 @@ -#!/bin/sh -e -# -# 2017 Ľubomír Kučera -# -# 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 . -# - -systemctl_present=$(cat "${__object}/explorer/systemctl-present") - -if [ "${systemctl_present}" -ne 0 ]; then - echo "systemctl does not seem to be present on this system" >&2 - - exit 1 -fi - -name="${__object_id}" -source=$(cat "${__object}/parameter/source") -state=$(cat "${__object}/parameter/state") -enablement_state=$(cat "${__object}/parameter/enablement-state") - -# The unit must be disabled before removing its unit file. The unit file is -# therefore removed by gencode-remote of this type, not here. -if [ -z "${source}" ] || [ "${state}" = "absent" ]; then - exit 0 -fi - -# stdin is not propagated automatically to sub-objects -if [ "${source}" = "-" ]; then - source="${__object}/stdin" -fi - -unitfile_state="${state}" -if [ "${enablement_state}" = "masked" ]; then - # Masking creates a symlink from /etc/systemd/system/ to /dev/null. - # This process fails with "Failed to execute operation: Invalid argument" - # if file /etc/systemd/system/ already exists. We must therefore - # remove it. - unitfile_state="absent" -fi - -__config_file "/etc/systemd/system/${name}" \ - --mode 644 \ - --onchange "systemctl daemon-reload" \ - --source "${source}" \ - --state "${unitfile_state}" diff --git a/cdist/conf/type/__systemd_unit/parameter/boolean b/cdist/conf/type/__systemd_unit/parameter/boolean deleted file mode 100644 index eea5a271..00000000 --- a/cdist/conf/type/__systemd_unit/parameter/boolean +++ /dev/null @@ -1 +0,0 @@ -restart diff --git a/cdist/conf/type/__systemd_unit/parameter/default/enablement-state b/cdist/conf/type/__systemd_unit/parameter/default/enablement-state deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/conf/type/__systemd_unit/parameter/default/source b/cdist/conf/type/__systemd_unit/parameter/default/source deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/conf/type/__systemd_unit/parameter/default/state b/cdist/conf/type/__systemd_unit/parameter/default/state deleted file mode 100644 index e7f6134f..00000000 --- a/cdist/conf/type/__systemd_unit/parameter/default/state +++ /dev/null @@ -1 +0,0 @@ -present diff --git a/cdist/conf/type/__systemd_unit/parameter/optional b/cdist/conf/type/__systemd_unit/parameter/optional deleted file mode 100644 index e7cc7acf..00000000 --- a/cdist/conf/type/__systemd_unit/parameter/optional +++ /dev/null @@ -1,3 +0,0 @@ -enablement-state -source -state diff --git a/cdist/conf/type/__timezone/explorer/timezone_is b/cdist/conf/type/__timezone/explorer/timezone_is deleted file mode 100755 index a1aa813f..00000000 --- a/cdist/conf/type/__timezone/explorer/timezone_is +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/sh -e -# -# 2017 Ander Punnar (cdist at kvlt.ee) -# -# 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 . -# - -[ -f /etc/timezone ] && cat /etc/timezone - -exit 0 diff --git a/cdist/conf/type/__timezone/gencode-remote b/cdist/conf/type/__timezone/gencode-remote index 5299f548..b4782d4b 100755 --- a/cdist/conf/type/__timezone/gencode-remote +++ b/cdist/conf/type/__timezone/gencode-remote @@ -1,7 +1,6 @@ -#!/bin/sh -e +#!/bin/sh # # 2012 Steven Armstrong (steven-cdist at armstrong.cc) -# 2019 Nico Schottelius (nico-cdist at schottelius.org) # # This file is part of cdist. # @@ -21,16 +20,11 @@ # # This type allows to configure the desired localtime timezone. -timezone_is=$(cat "$__object/explorer/timezone_is") -timezone_should="$__object_id" +timezone="$__object_id" os=$(cat "$__global/explorer/os") -if [ "$timezone_is" = "$timezone_should" ]; then - exit 0 -fi - case "$os" in - ubuntu|debian|devuan|coreos|alpine) - echo "echo \"$timezone_should\" > /etc/timezone" + ubuntu|debian) + echo "echo \"$timezone\" > /etc/timezone" ;; esac diff --git a/cdist/conf/type/__timezone/man.rst b/cdist/conf/type/__timezone/man.text similarity index 55% rename from cdist/conf/type/__timezone/man.rst rename to cdist/conf/type/__timezone/man.text index 8a945c16..6f0c5101 100644 --- a/cdist/conf/type/__timezone/man.rst +++ b/cdist/conf/type/__timezone/man.text @@ -1,9 +1,11 @@ cdist-type__timezone(7) ======================= +Ramon Salvadó + NAME ---- -cdist-type__timezone - Allows one to configure the desired localtime timezone. +cdist-type__timezone - Allows to configure the desired localtime timezone. DESCRIPTION @@ -25,18 +27,18 @@ None. EXAMPLES -------- -.. code-block:: sh +-------------------------------------------------------------------------------- +#Set up Europe/Andorra as our timezone. +__timezone Europe/Andorra - #Set up Europe/Andorra as our timezone. - __timezone Europe/Andorra - - #Set up US/Central as our timezone. - __timezone US/Central +#Set up US/Central as our timezone. +__timezone US/Central +-------------------------------------------------------------------------------- -AUTHORS -------- -Ramon Salvadó +SEE ALSO +-------- +- cdist-type(7) COPYING diff --git a/cdist/conf/type/__timezone/manifest b/cdist/conf/type/__timezone/manifest index 3d28ccba..81de0217 100755 --- a/cdist/conf/type/__timezone/manifest +++ b/cdist/conf/type/__timezone/manifest @@ -1,8 +1,8 @@ -#!/bin/sh -e +#!/bin/sh # # 2011 Ramon Salvadó (rsalvado at gnuine dot com) -# 2012-2015 Steven Armstrong (steven-cdist at armstrong.cc) -# 2012-2019 Nico Schottelius (nico-cdist at schottelius.org) +# 2012 Steven Armstrong (steven-cdist at armstrong.cc) +# 2012 Nico Schottelius (nico-cdist at schottelius.org) # # This file is part of cdist. # @@ -24,43 +24,16 @@ timezone="$__object_id" os=$(cat "$__global/explorer/os") - + case "$os" in - archlinux|debian|ubuntu|devuan|alpine) - __package tzdata - export require="__package/tzdata" - ;; - suse) - __package timezone - export require="__package/timezone" - ;; - freebsd|netbsd|openbsd) - # whitelist - : - ;; - coreos) - # whitelist - : - ;; - scientific|centos) + archlinux|debian|ubuntu) __package tzdata --state present - export require="__package/tzdata" - __file /etc/sysconfig/clock \ - --owner root --group root --mode 644 \ - --state exists - require="__file/etc/sysconfig/clock" \ - __key_value ZONE \ - --file /etc/sysconfig/clock \ - --delimiter '=' \ - --value "\"$timezone\"" + require="__package/tzdata" __link /etc/localtime \ + --source "/usr/share/zoneinfo/${timezone}" \ + --type symbolic ;; *) - echo "Your operating system ($os) is currently not supported by this type (${__type##*/})." >&2 - echo "Please contribute an implementation for it if you can." >&2 + echo "Unsupported OS $os" >&2 exit 1 ;; esac - -__link /etc/localtime \ - --source "/usr/share/zoneinfo/${timezone}" \ - --type symbolic diff --git a/cdist/conf/type/__ufw/gencode-remote b/cdist/conf/type/__ufw/gencode-remote deleted file mode 100644 index fc62b591..00000000 --- a/cdist/conf/type/__ufw/gencode-remote +++ /dev/null @@ -1,62 +0,0 @@ -#!/bin/sh -e -# -# 2019 Mark Polyakov (mark--@--markasoftware.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 . -# - -state="$(cat "$__object/parameter/state")" - -case "$state" in - enabled) - echo 'ufw --force enable' - ;; - - present) - echo 'ufw --force disable' - ;; - # absent will be uninstalled in manifest -esac - -if [ "$state" != absent ]; then - if [ -f "$__object/parameter/logging" ]; then - logging="$(cat "$__object/parameter/logging")" - case "$logging" in - off|low|medium|high|full) - echo "ufw --force logging $logging" - ;; - *) - echo 'Logging parameter must be off, low, medium, high, or full!' >&2 - exit 1 - ;; - esac - fi - - for direction in incoming outgoing routed; do - if [ -f "$__object/parameter/default_$direction" ]; then - treatment="$(cat "$__object/parameter/default_$direction")" - case "$treatment" in - allow|deny|reject) - echo "ufw --force default $treatment $direction" - ;; - *) - echo 'UFW default policies must be either "allow", "deny", or "reject".' >&2 - exit 1 - ;; - esac - fi - done -fi diff --git a/cdist/conf/type/__ufw/man.rst b/cdist/conf/type/__ufw/man.rst deleted file mode 100644 index cc64fbb5..00000000 --- a/cdist/conf/type/__ufw/man.rst +++ /dev/null @@ -1,59 +0,0 @@ -cdist-type__ufw(7) -================== - -NAME ----- -cdist-type__ufw - Install the Uncomplicated FireWall - - -DESCRIPTION ------------ -Installs the Uncomplicated FireWall. Most modern distributions carry UFW in their main repositories, but on CentOS this type will automatically enable the EPEL repository. - -Some global configuration can also be set with this type. - -OPTIONAL PARAMETERS -------------------- -state - Either "enabled", "running", "present", or "absent". Defaults to "enabled", which registers UFW to start on boot. - -logging - Either "off", "low", "medium", "high", or "full". Will be passed to `ufw logging`. If not specified, logging level is not modified. - -default_incoming - Either "allow", "deny", or "reject". The default policy for dealing with ingress packets. - -default_outgoing - Either "allow", "deny", or "reject". The default policy for dealing with egress packets. - -default_routed - Either "allow", "deny", or "reject". The default policy for dealing with routed packets (passing through this machine). - - -EXAMPLES --------- - -.. code-block:: sh - - # Install UFW - __ufw - # Setup UFW with maximum logging and no restrictions on routed packets. - __ufw --logging full --default_routed allow - - -SEE ALSO --------- -:strong:`ufw`\ (8) - - -AUTHORS -------- -Mark Polyakov - - -COPYING -------- -Copyright \(C) 2019 Mark Polyakov. 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. diff --git a/cdist/conf/type/__ufw/manifest b/cdist/conf/type/__ufw/manifest deleted file mode 100755 index 54309ff5..00000000 --- a/cdist/conf/type/__ufw/manifest +++ /dev/null @@ -1,67 +0,0 @@ -#!/bin/sh -e -# -# 2019 Mark Polyakov (mark--@--markasoftware.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 . -# - -state="$(cat "$__object/parameter/state")" - -case "$state" in - present|enabled) - os="$(cat "$__global/explorer/os")" - - case "$os" in - centos) - # shellcheck source=/dev/null - if (. "$__global/explorer/os_release" && [ "${VERSION_ID}" = "7" ]); then - __package epel-release - require='__package/epel-release' __package ufw - else - echo 'CentOS version 7 is required!' - exit 1 - fi - ;; - *) - __package ufw - ;; - esac - - # ufw expects to always be enabled, then uses a switch in /etc to - # determine whether to "actually start" after the init system calls it. - # So, we have to both enable on bootup through init and run `ufw enable` - - # operators ae left-associative, so if !enabled it will never run - if [ "$(cat "$__global/explorer/os")" != ubuntu ] || \ - [ "$(cat "$__global/explorer/init")" != init ] && \ - [ "$state" = enabled ]; then - # Why don't we disable start_on_boot when state=present|absent? - # Because UFW should always be enabled at boot -- /etc/ufw/ufw.conf - # will stop it from "really" starting - require='__package/ufw' __start_on_boot ufw - fi - ;; - - absent) - __package ufw --state absent - ;; - - *) - echo 'State must be "enabled", "present", or "absent".' - exit 1 - ;; -esac - diff --git a/cdist/conf/type/__ufw/parameter/default/state b/cdist/conf/type/__ufw/parameter/default/state deleted file mode 100644 index 26ed6c9b..00000000 --- a/cdist/conf/type/__ufw/parameter/default/state +++ /dev/null @@ -1 +0,0 @@ -enabled \ No newline at end of file diff --git a/cdist/conf/type/__ufw/parameter/optional b/cdist/conf/type/__ufw/parameter/optional deleted file mode 100644 index 0a4dec97..00000000 --- a/cdist/conf/type/__ufw/parameter/optional +++ /dev/null @@ -1,5 +0,0 @@ -state -logging -default_incoming -default_outgoing -default_routed \ No newline at end of file diff --git a/cdist/conf/type/__ufw/singleton b/cdist/conf/type/__ufw/singleton deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/conf/type/__ufw_rule/gencode-remote b/cdist/conf/type/__ufw_rule/gencode-remote deleted file mode 100755 index 4f1bf2c9..00000000 --- a/cdist/conf/type/__ufw_rule/gencode-remote +++ /dev/null @@ -1,45 +0,0 @@ -#!/bin/sh -e -# -# 2019 Mark Polyakov (mark@markasoftware.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 type does not bother with checking the current state of the rules. -# While it is possible to retrieve the list of rules in a consistent format from -# `ufw status`, it is a completely different format than the one used on the -# command line. I also do not suspect it is any faster. - -ufw='ufw --force rule' - -case "$(cat "$__object/parameter/state")" in - present) ;; - absent) - ufw="$ufw delete" - ;; - *) - echo 'State must be "present" or "absent".' >&2 - exit 1 - ;; -esac - -if [ -f "$__object/parameter/rule" ]; then - ufw="$ufw $(cat "$__object/parameter/rule")" -else - ufw="$ufw allow $__object_id" -fi - -echo "$ufw" diff --git a/cdist/conf/type/__ufw_rule/man.rst b/cdist/conf/type/__ufw_rule/man.rst deleted file mode 100644 index 996557f8..00000000 --- a/cdist/conf/type/__ufw_rule/man.rst +++ /dev/null @@ -1,53 +0,0 @@ -cdist-type__ufw_rule(7) -======================= - -NAME ----- -cdist-type__ufw_rule - A single UFW rule - - -DESCRIPTION ------------ -Adds or removes a single UFW rule. This type supports adding and deleting rules for port ranges or applications. - -Understanding what is "to" and what is "from" can be confusing. If the rule is ingress (default), then "from" is the remote machine and "to" is the local one. The opposite is true for egress traffic (--out). - -OPTIONAL PARAMETERS -------------------- -state - Either "present" or "absent". Defaults to "present". If "absent", only removes rules that exactly match the rule expected. - -rule - A firewall rule in UFW syntax. This is what you would usually write after `ufw` on the command line. Defaults to "allow" followed by the object ID. You can use either the short syntax (just allow|deny|reject|limit followed by a port or application name) or the full syntax. Do not include `delete` in your command. Set `--state absent` instead. - -EXAMPLES --------- - -.. code-block:: sh - - # open port 80 (ufw allow 80) - __ufw_rule 80 - # Allow mosh application (if installed) - __ufw_rule mosh - # Allow all traffic from local network (ufw allow from 10.0.0.0/24) - __ufw_rule local --rule 'allow from 10.0.0.0/24' - # Block egress traffic from port 25 to 111.55.55.55 on interface eth0 - __ufw_rule block_smtp --rule 'deny out on eth0 from any port 25 to 111.55.55.55' - - -SEE ALSO --------- -:strong:`ufw`\ (8) - - -AUTHORS -------- -Mark Polyakov - - -COPYING -------- -Copyright \(C) 2019 Mark Polyakov. 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. diff --git a/cdist/conf/type/__ufw_rule/parameter/default/state b/cdist/conf/type/__ufw_rule/parameter/default/state deleted file mode 100644 index e7f6134f..00000000 --- a/cdist/conf/type/__ufw_rule/parameter/default/state +++ /dev/null @@ -1 +0,0 @@ -present diff --git a/cdist/conf/type/__ufw_rule/parameter/optional b/cdist/conf/type/__ufw_rule/parameter/optional deleted file mode 100644 index 0732d53d..00000000 --- a/cdist/conf/type/__ufw_rule/parameter/optional +++ /dev/null @@ -1,2 +0,0 @@ -state -rule diff --git a/cdist/conf/type/__update_alternatives/gencode-remote b/cdist/conf/type/__update_alternatives/gencode-remote index 0e7b0d89..19ea9968 100755 --- a/cdist/conf/type/__update_alternatives/gencode-remote +++ b/cdist/conf/type/__update_alternatives/gencode-remote @@ -1,4 +1,4 @@ -#!/bin/sh -e +#!/bin/sh # # 2013 Nico Schottelius (nico-cdist at schottelius.org) # diff --git a/cdist/conf/type/__update_alternatives/man.rst b/cdist/conf/type/__update_alternatives/man.text similarity index 51% rename from cdist/conf/type/__update_alternatives/man.rst rename to cdist/conf/type/__update_alternatives/man.text index 73d82d11..2bcc1874 100644 --- a/cdist/conf/type/__update_alternatives/man.rst +++ b/cdist/conf/type/__update_alternatives/man.text @@ -1,5 +1,7 @@ cdist-type__update_alternatives(7) ================================== +Nico Schottelius + NAME ---- @@ -15,32 +17,27 @@ One of the most common used targets is the "editor". REQUIRED PARAMETERS ------------------- -path +path:: Use this path for the given alternative EXAMPLES -------- -.. code-block:: sh - - # Setup vim as the default editor - __update_alternatives editor --path /usr/bin/vim.basic +-------------------------------------------------------------------------------- +# Setup vim as the default editor +__update_alternatives editor --path /usr/bin/vim.basic +-------------------------------------------------------------------------------- SEE ALSO -------- -:strong:`cdist-type__debconf_set_selections`\ (7), :strong:`update-alternatives`\ (8) - - -AUTHORS -------- -Nico Schottelius +- cdist-type(7) +- cdist-type__debconf_set_selections(7) +- update-alternatives(8) COPYING ------- -Copyright \(C) 2013 Nico Schottelius. 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. +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/cdist/conf/type/__user/explorer/group b/cdist/conf/type/__user/explorer/group index 2aae2973..98ce39c6 100755 --- a/cdist/conf/type/__user/explorer/group +++ b/cdist/conf/type/__user/explorer/group @@ -23,11 +23,6 @@ if [ -f "$__object/parameter/gid" ]; then gid=$(cat "$__object/parameter/gid") - getent=$(command -v getent) - if [ X != X"${getent}" ]; then - "${getent}" group "$gid" || true - elif [ -f /etc/group ]; then - grep -E "^(${gid}|([^:]+:){2}${gid}):" /etc/group || true - fi + getent group "$gid" || true fi diff --git a/cdist/conf/type/__user/explorer/passwd b/cdist/conf/type/__user/explorer/passwd index 677e3ff0..fdbfb193 100755 --- a/cdist/conf/type/__user/explorer/passwd +++ b/cdist/conf/type/__user/explorer/passwd @@ -23,9 +23,5 @@ name=$__object_id -getent=$(command -v getent) -if [ X != X"${getent}" ]; then - "${getent}" passwd "$name" || true -elif [ -f /etc/passwd ]; then - grep "^${name}:" /etc/passwd || true -fi +getent passwd "$name" || true + diff --git a/cdist/conf/type/__user/explorer/shadow b/cdist/conf/type/__user/explorer/shadow index c49992d5..59abaa8a 100755 --- a/cdist/conf/type/__user/explorer/shadow +++ b/cdist/conf/type/__user/explorer/shadow @@ -22,18 +22,14 @@ # name=$__object_id -os="$("$__explorer/os")" +os="$($__explorer/os)" # Default to using shadow passwords database="shadow" case "$os" in - "freebsd"|"netbsd"|"openbsd") database="passwd";; + "freebsd"|"openbsd") database="passwd";; esac -getent=$(command -v getent) -if [ X != X"${getent}" ]; then - "${getent}" "$database" "$name" || true -elif [ -f /etc/shadow ]; then - grep "^${name}:" /etc/shadow || true -fi +getent "$database" "$name" || true + diff --git a/cdist/conf/type/__user/gencode-remote b/cdist/conf/type/__user/gencode-remote index ee18c18f..463fbe49 100755 --- a/cdist/conf/type/__user/gencode-remote +++ b/cdist/conf/type/__user/gencode-remote @@ -1,9 +1,8 @@ -#!/bin/sh -e +#!/bin/sh # # 2011 Steven Armstrong (steven-cdist at armstrong.cc) # 2011 Nico Schottelius (nico-cdist at schottelius.org) # 2013 Daniel Heule (hda at sfs.biz) -# 2018 Thomas Eckert (tom at it-eckert.de) # # This file is part of cdist. # @@ -53,7 +52,7 @@ shorten_property() { if [ "$state" = "present" ]; then cd "$__object/parameter" if grep -q "^${name}:" "$__object/explorer/passwd"; then - for property in *; do + for property in $(ls .); do new_value="$(cat "$property")" unset current_value @@ -61,7 +60,7 @@ if [ "$state" = "present" ]; then case "$property" in gid) - if echo "$new_value" | grep -q '^[0-9][0-9]*$'; then + if $(echo "$new_value" | grep -q '^[0-9][0-9]*$'); then field=4 else # We were passed a group name. Compare the gid in @@ -98,14 +97,14 @@ if [ "$state" = "present" ]; then fi if [ "$new_value" != "$current_value" ]; then - set -- "$@" "$(shorten_property "$property")" \'"$new_value"\' + set -- "$@" "$(shorten_property $property)" \'$new_value\' fi done if [ $# -gt 0 ]; then echo mod >> "$__messages_out" if [ "$os" = "freebsd" ]; then - echo pw usermod "$@" -n "$name" + echo pw usermod "$@" "$name" else echo usermod "$@" "$name" fi @@ -114,34 +113,30 @@ if [ "$state" = "present" ]; then fi else echo add >> "$__messages_out" - for property in *; do + for property in $(ls .); do [ "$property" = "state" ] && continue [ "$property" = "remove-home" ] && continue new_value="$(cat "$property")" if [ -z "$new_value" ];then # Boolean values have no value - set -- "$@" "$(shorten_property "$property")" + set -- "$@" "$(shorten_property $property)" else - set -- "$@" "$(shorten_property "$property")" \'"$new_value"\' + set -- "$@" "$(shorten_property $property)" \'$new_value\' fi done if [ "$os" = "freebsd" ]; then - echo pw useradd "$@" -n "$name" + echo pw useradd "$@" "$name" else echo useradd "$@" "$name" fi fi -elif [ "$state" = "absent" ]; then +else if grep -q "^${name}:" "$__object/explorer/passwd"; then #user exists, but state != present, so delete it if [ -f "$__object/parameter/remove-home" ]; then - printf "userdel -r '%s' >/dev/null 2>&1\\n" "${name}" - echo "userdel -r" >> "$__messages_out" + echo userdel -r "${name}" else - printf "userdel '%s' >/dev/null 2>&1\\n" "${name}" - echo "userdel" >> "$__messages_out" + echo userdel "${name}" fi fi -else - echo "Invalid state $state" >&2 fi diff --git a/cdist/conf/type/__user/man.rst b/cdist/conf/type/__user/man.rst deleted file mode 100644 index ef6b77af..00000000 --- a/cdist/conf/type/__user/man.rst +++ /dev/null @@ -1,105 +0,0 @@ -cdist-type__user(7) -=================== - -NAME ----- -cdist-type__user - Manage users - - -DESCRIPTION ------------ -This cdist type allows you to create or modify users on the target. - - -REQUIRED PARAMETERS -------------------- -None. - - -OPTIONAL PARAMETERS -------------------- -state - absent or present, defaults to present - -comment - see usermod(8) - -home - see above - -gid - see above - -password - see above - -shell - see above - -uid - see above - - -BOOLEAN PARAMETERS ------------------- -system - see useradd(8), apply only on user create - -create-home - see useradd(8), apply only on user create - -remove-home - see userdel(8), apply only on user delete - - -MESSAGES --------- -mod - User is modified - -add - New user added - -userdel -r - If user was deleted with homedir - -userdel - If user was deleted (keeping homedir) - -EXAMPLES --------- - -.. code-block:: sh - - # Create user account for foobar with operating system default settings - __user foobar - - # Same but with a different shell - __user foobar --shell /bin/zsh - - # Same but for a system account - __user foobar --system - - # Set explicit uid and home - __user foobar --uid 1001 --shell /bin/zsh --home /home/foobar - - # Drop user if exists - __user foobar --state absent - - -SEE ALSO --------- -:strong:`pw`\ (8), :strong:`usermod`\ (8) - - -AUTHORS -------- -Steven Armstrong - - -COPYING -------- -Copyright \(C) 2011 Steven Armstrong. 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. diff --git a/cdist/conf/type/__user/man.text b/cdist/conf/type/__user/man.text new file mode 100644 index 00000000..be70ec12 --- /dev/null +++ b/cdist/conf/type/__user/man.text @@ -0,0 +1,86 @@ +cdist-type__user(7) +=================== +Steven Armstrong + + +NAME +---- +cdist-type__user - Manage users + + +DESCRIPTION +----------- +This cdist type allows you to create or modify users on the target. + + +REQUIRED PARAMETERS +------------------- +None. + + +OPTIONAL PARAMETERS +------------------- +state:: + absent or present, defaults to present +comment:: + see usermod(8) +home:: + see above +gid:: + see above +password:: + see above +shell:: + see above +uid:: + see above + +BOOLEAN PARAMETERS +------------------ +system:: + see useradd(8), apply only on user create +create-home:: + see useradd(8), apply only on user create +remove-home:: + see userdel(8), apply only on user delete + + +MESSAGES +-------- +mod:: + User is modified +add:: + New user added + + +EXAMPLES +-------- + +-------------------------------------------------------------------------------- +# Create user account for foobar with operating system default settings +__user foobar + +# Same but with a different shell +__user foobar --shell /bin/zsh + +# Same but for a system account +__user foobar --system + +# Set explicit uid and home +__user foobar --uid 1001 --shell /bin/zsh --home /home/foobar + +# Drop user if exists +__user foobar --state absent +-------------------------------------------------------------------------------- + + +SEE ALSO +-------- +- cdist-type(7) +- usermod(8) or pw(8) + + +COPYING +------- +Copyright \(C) 2011 Steven Armstrong. Free use of this software is +granted under the terms of the GNU General Public License version 3 (GPLv3). diff --git a/cdist/conf/type/__user/manifest b/cdist/conf/type/__user/manifest deleted file mode 100644 index 8f10b38c..00000000 --- a/cdist/conf/type/__user/manifest +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/sh -e -# -# 2019 Nico Schottelius (nico-cdist at schottelius.org) -# -# This file is part of cdist. -# -# cdist is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# cdist is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with cdist. If not, see . -# -# -# Manage users. - -os=$(cat "$__global/explorer/os") - -case "$os" in - alpine) - __package shadow - ;; - *) - : - ;; -esac diff --git a/cdist/conf/type/__user_groups/explorer/group b/cdist/conf/type/__user_groups/explorer/group index 5bad9a0b..a8cb63af 100755 --- a/cdist/conf/type/__user_groups/explorer/group +++ b/cdist/conf/type/__user_groups/explorer/group @@ -20,4 +20,4 @@ user="$(cat "$__object/parameter/user" 2>/dev/null || echo "$__object_id")" -(id -G -n "$user" | tr ' ' '\n' | sort) 2>/dev/null || true +(id --groups --name "$user" | tr ' ' '\n' | sort) 2>/dev/null || true diff --git a/cdist/conf/type/__user_groups/explorer/oldusermod b/cdist/conf/type/__user_groups/explorer/oldusermod deleted file mode 100644 index 6ef25b13..00000000 --- a/cdist/conf/type/__user_groups/explorer/oldusermod +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/sh -# -# 2015 Heule Daniel (hda at sfs.biz) -# -# 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 . -# - -usermod --help | grep -q -- '-A group' && echo true || echo false diff --git a/cdist/conf/type/__user_groups/gencode-remote b/cdist/conf/type/__user_groups/gencode-remote index 8120761a..9f11dd16 100755 --- a/cdist/conf/type/__user_groups/gencode-remote +++ b/cdist/conf/type/__user_groups/gencode-remote @@ -1,4 +1,4 @@ -#!/bin/sh -e +#!/bin/sh # # 2012 Steven Armstrong (steven-cdist at armstrong.cc) # @@ -20,8 +20,6 @@ user="$(cat "$__object/parameter/user" 2>/dev/null || echo "$__object_id")" state_should="$(cat "$__object/parameter/state")" -oldusermod="$(cat "$__object/explorer/oldusermod")" -os=$(cat "$__global/explorer/os") mkdir "$__object/files" # file has to be sorted for comparison with `comm` @@ -30,9 +28,11 @@ sort "$__object/parameter/group" > "$__object/files/group.sorted" case "$state_should" in present) changed_groups="$(comm -13 "$__object/explorer/group" "$__object/files/group.sorted")" + action="-a" ;; absent) changed_groups="$(comm -12 "$__object/explorer/group" "$__object/files/group.sorted")" + action="-d" ;; esac @@ -42,25 +42,5 @@ if [ -z "$changed_groups" ]; then fi for group in $changed_groups; do - if [ "$os" = "netbsd" ] || [ "$os" = "openbsd" ]; then - case "$state_should" in - present) echo "usermod -G \"$group\" \"$user\"" ;; - absent) echo 'NetBSD and OpenBSD do not have a command to remove a user from a group' >&2 ; exit 1 ;; - esac - elif [ "$os" = "freebsd" ]; then - case "$state_should" in - present) echo "pw groupmod \"$group\" -m \"$user\"" ;; - absent) echo "pw groupmod \"$group\" -d \"$user\"" ;; - esac - elif [ "$oldusermod" = "true" ]; then - case "$state_should" in - present) echo "usermod -A \"$group\" \"$user\"" ;; - absent) echo "usermod -R \"$group\" \"$user\"" ;; - esac - else - case "$state_should" in - present) echo "gpasswd -a \"$user\" \"$group\"" ;; - absent) echo "gpasswd -d \"$user\" \"$group\"" ;; - esac - fi + echo "gpasswd $action \"$user\" \"$group\"" done diff --git a/cdist/conf/type/__user_groups/man.rst b/cdist/conf/type/__user_groups/man.rst deleted file mode 100644 index 6767b7a8..00000000 --- a/cdist/conf/type/__user_groups/man.rst +++ /dev/null @@ -1,52 +0,0 @@ -cdist-type__user_groups(7) -========================== - -NAME ----- -cdist-type__user_groups - Manage user groups - - -DESCRIPTION ------------ -Adds or removes a user from one or more groups. - - -REQUIRED PARAMETERS -------------------- -group - the group to which this user should be added or removed. - Can be specified multiple times. - - -OPTIONAL PARAMETERS -------------------- -user - the name of the user. Defaults to object_id - -state - absent or present. Defaults to present. - - -EXAMPLES --------- - -.. code-block:: sh - - __user_groups nginx --group webuser1 --group webuser2 - - # remove user nginx from groups webuser2 - __user_groups nginx-webuser2 --user nginx \ - --group webuser2 --state absent - - -AUTHORS -------- -Steven Armstrong - - -COPYING -------- -Copyright \(C) 2012 Steven Armstrong. 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. diff --git a/cdist/conf/type/__user_groups/man.text b/cdist/conf/type/__user_groups/man.text new file mode 100644 index 00000000..d45784fe --- /dev/null +++ b/cdist/conf/type/__user_groups/man.text @@ -0,0 +1,52 @@ +cdist-type__user_groups(7) +========================== +Steven Armstrong + + +NAME +---- +cdist-type__user_groups - manage user groups + + +DESCRIPTION +----------- +Adds or removes a user from one or more groups. + + +REQUIRED PARAMETERS +------------------- +group:: + the group to which this user should be added or removed. + Can be specified multiple times. + + +OPTIONAL PARAMETERS +------------------- +user:: + the name of the user. Defaults to object_id + +state:: + absent or present. Defaults to present. + + +EXAMPLES +-------- + +-------------------------------------------------------------------------------- +__user_groups nginx --group webuser1 --group webuser2 + +# remove user nginx from groups webuser2 +__user_groups nginx-webuser2 --user nginx \ + --group webuser2 --state absent +-------------------------------------------------------------------------------- + + +SEE ALSO +-------- +- cdist-type(7) + + +COPYING +------- +Copyright \(C) 2012 Steven Armstrong. Free use of this software is +granted under the terms of the GNU General Public License version 3 (GPLv3). diff --git a/cdist/conf/type/__yum_repo/files/repo.template b/cdist/conf/type/__yum_repo/files/repo.template index 18ea9d2b..3e14c8b6 100755 --- a/cdist/conf/type/__yum_repo/files/repo.template +++ b/cdist/conf/type/__yum_repo/files/repo.template @@ -43,7 +43,7 @@ for key in baseurl gpgkey; do if [ -f "$__object/parameter/$key" ]; then printf '%s=' "$key" prefix='' - while read -r line; do + while read line; do printf '%s%s\n' "$prefix" "$line" prefix=' ' done < "$__object/parameter/$key" diff --git a/cdist/conf/type/__yum_repo/man.rst b/cdist/conf/type/__yum_repo/man.rst deleted file mode 100644 index 94366c3a..00000000 --- a/cdist/conf/type/__yum_repo/man.rst +++ /dev/null @@ -1,124 +0,0 @@ -cdist-type__yum_repo(7) -======================= - -NAME ----- -cdist-type__yum_repo - Manage yum repositories - - -DESCRIPTION ------------ -For all undocumented parameters see yum.conf(5). - - -REQUIRED PARAMETERS -------------------- -None. - - -OPTIONAL PARAMETERS -------------------- -state - 'present' or 'absent'. Defaults to 'present' - -repositoryid - Defaults to __object_id. - -name - -baseurl - Can be specified multiple times. - -metalink - -mirrorlist - -gpgkey - Can be specified multiple times. - -gpgcakey - -gpgcheck - -exclude - -includepkgs - -failovermethod - -timeout - -http_caching - -retries - -throttle - -bandwidth - -sslcacert - -sslverify - -sslclientcert - -sslclientkey - -ssl_check_cert_permissions - -metadata_expire - -mirrorlist_expire - -proxy - -proxy_username - -proxy_password - -username - -password - -cost - - -BOOLEAN PARAMETERS ------------------- -enabled - -repo_gpgcheck - -disablegroups - ! enablegroups - -keepalive - -skip_if_unavailable - - -EXAMPLES --------- - -.. code-block:: sh - - __yum_repo epel \ - --name 'Extra Packages for Enterprise Linux 6 - $basearch' \ - --mirrorlist 'https://mirrors.fedoraproject.org/metalink?repo=epel-$releasever&arch=$basearch' \ - --failovermethod priority \ - --enabled \ - --gpgcheck 1 \ - --gpgkey https://fedoraproject.org/static/0608B895.txt - - -AUTHORS -------- -Steven Armstrong - - -COPYING -------- -Copyright \(C) 2014 Steven Armstrong. 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. diff --git a/cdist/conf/type/__yum_repo/man.text b/cdist/conf/type/__yum_repo/man.text new file mode 100644 index 00000000..549cf336 --- /dev/null +++ b/cdist/conf/type/__yum_repo/man.text @@ -0,0 +1,91 @@ +cdist-type__yum_repo(7) +======================= +Steven Armstrong + + +NAME +---- +cdist-type__yum_repo - manage yum repositories + + +DESCRIPTION +----------- +For all undocumented parameters see yum.conf(5). + + +REQUIRED PARAMETERS +------------------- +None. + + +OPTIONAL PARAMETERS +------------------- +state:: + 'present' or 'absent'. Defaults to 'present' +repositoryid:: + Defaults to __object_id. +name:: +baseurl:: + Can be specified multiple times. +metalink:: +mirrorlist:: +gpgkey:: + Can be specified multiple times. +gpgcakey:: +gpgcheck:: +exclude:: +includepkgs:: +failovermethod:: +timeout:: +http_caching:: +retries:: +throttle:: +bandwidth:: +sslcacert:: +sslverify:: +sslclientcert:: +sslclientkey:: +ssl_check_cert_permissions:: +metadata_expire:: +mirrorlist_expire:: +proxy:: +proxy_username:: +proxy_password:: +username:: +password:: +cost:: + + +BOOLEAN PARAMETERS +------------------ +enabled:: +repo_gpgcheck:: +disablegroups:: + ! enablegroups +keepalive:: +skip_if_unavailable:: + + +EXAMPLES +-------- + +-------------------------------------------------------------------------------- +__yum_repo epel \ + --name 'Extra Packages for Enterprise Linux 6 - $basearch' \ + --mirrorlist 'https://mirrors.fedoraproject.org/metalink?repo=epel-$releasever&arch=$basearch' \ + --failovermethod priority \ + --enabled \ + --gpgcheck 1 \ + --gpgkey https://fedoraproject.org/static/0608B895.txt +-------------------------------------------------------------------------------- + + +SEE ALSO +-------- +- cdist-type(7) + + +COPYING +------- +Copyright \(C) 2014 Steven Armstrong. Free use of this software is +granted under the terms of the GNU General Public License version 3 (GPLv3). diff --git a/cdist/conf/type/__yum_repo/manifest b/cdist/conf/type/__yum_repo/manifest index 5f60d32c..9bb63c3c 100755 --- a/cdist/conf/type/__yum_repo/manifest +++ b/cdist/conf/type/__yum_repo/manifest @@ -1,4 +1,4 @@ -#!/bin/sh -e +#!/bin/sh # # 2014 Steven Armstrong (steven-cdist at armstrong.cc) # @@ -22,7 +22,7 @@ os=$(cat "$__global/explorer/os") state="$(cat "$__object/parameter/state")" case "$os" in - scientific|centos) + 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/explorer/all_repo_ids b/cdist/conf/type/__zypper_repo/explorer/all_repo_ids index 7953158a..b37d8ac5 100644 --- a/cdist/conf/type/__zypper_repo/explorer/all_repo_ids +++ b/cdist/conf/type/__zypper_repo/explorer/all_repo_ids @@ -21,5 +21,4 @@ # Retrieve all repo id nummbers - parsed zypper output # # -# shellcheck disable=SC2005,SC2046 echo $(zypper lr | cut -d'|' -f 1 | grep -E '^[0-9]') diff --git a/cdist/conf/type/__zypper_repo/explorer/enabled_repo_ids b/cdist/conf/type/__zypper_repo/explorer/enabled_repo_ids index 261d6073..2dfb946f 100644 --- a/cdist/conf/type/__zypper_repo/explorer/enabled_repo_ids +++ b/cdist/conf/type/__zypper_repo/explorer/enabled_repo_ids @@ -23,6 +23,4 @@ # # simpler command which works only on SLES11 SP3 or newer: # echo $(zypper lr -E | cut -d'|' -f 1 | grep -E '^[0-9]') -# -# shellcheck disable=SC2005,SC2046 echo $(zypper lr | grep -E '^[0-9]([^|]+\|){3,3} Yes' | cut -d'|' -f 1) diff --git a/cdist/conf/type/__zypper_repo/explorer/repo_id b/cdist/conf/type/__zypper_repo/explorer/repo_id index d55a5cac..be0b9771 100644 --- a/cdist/conf/type/__zypper_repo/explorer/repo_id +++ b/cdist/conf/type/__zypper_repo/explorer/repo_id @@ -1,6 +1,6 @@ #!/bin/sh # -# 2013-2014 Daniel Heule (hda at sfs.biz) +# 2013 Daniel Heule (hda at sfs.biz) # # This file is part of cdist. # @@ -26,5 +26,4 @@ if [ -f "$__object/parameter/uri" ]; then else uri="$__object_id" fi -# shellcheck disable=SC2005,SC2046 -echo $(zypper lr -u | grep -F "$uri" | cut -d'|' -f 1 | grep -E '^[0-9]') +echo $(zypper lr -u | grep -E "\<$uri\>" | cut -d'|' -f 1 | grep -E '^[0-9]' ) diff --git a/cdist/conf/type/__zypper_repo/gencode-remote b/cdist/conf/type/__zypper_repo/gencode-remote old mode 100755 new mode 100644 index 336488ae..26199c75 --- a/cdist/conf/type/__zypper_repo/gencode-remote +++ b/cdist/conf/type/__zypper_repo/gencode-remote @@ -1,4 +1,4 @@ -#!/bin/sh -e +#!/bin/sh # # 2013 Daniel Heule (hda at sfs.biz) # @@ -70,25 +70,25 @@ case "$state" in fi if [ -z "$repo_id" ]; then # Repo not present, so we need to create it - echo "zypper $zypper_def_opts addrepo '$uri' '$desc'" + echo zypper $zypper_def_opts addrepo "'$uri'" "'$desc'" fi ;; absent) - if [ -n "$act_id" ]; then + if [ ! -z "$act_id" ]; then # Repo present (act_id not ""), so we ned to delete it - echo "zypper $zypper_def_opts removerepo $act_id" + echo zypper $zypper_def_opts removerepo "$act_id" fi ;; enabled) - if [ -n "$act_id" ] && [ "$repostate" = "disabled" ]; then + if [ ! -z "$act_id" ] && [ "$repostate" = "disabled" ]; then # Repo present (act_id not "") and repostate not enabled, so a enable call is needed - echo "zypper $zypper_def_opts modifyrepo -e $act_id" + echo zypper $zypper_def_opts modifyrepo -e "$act_id" fi ;; disabled) - if [ -n "$act_id" ] && [ "$repostate" = "enabled" ]; then + if [ ! -z "$act_id" ] && [ "$repostate" = "enabled" ]; then # Repo present (act_id not "") and repostate enabled, so a disable call is needed - echo "zypper $zypper_def_opts modifyrepo -d $act_id" + echo zypper $zypper_def_opts modifyrepo -d "$act_id" fi ;; *) diff --git a/cdist/conf/type/__zypper_repo/man.rst b/cdist/conf/type/__zypper_repo/man.rst deleted file mode 100644 index 73799d91..00000000 --- a/cdist/conf/type/__zypper_repo/man.rst +++ /dev/null @@ -1,73 +0,0 @@ -cdist-type__zypper_repo(7) -========================== - -NAME ----- -cdist-type__zypper_repo - Repository management with zypper - - -DESCRIPTION ------------ -zypper is usually used on the SuSE distribution to manage repositories. - - -REQUIRED PARAMETERS -------------------- -None - - -OPTIONAL PARAMETERS -------------------- -state - Either "present" or "absent" or "enabled" or "disabled", defaults to "present" - - * **present** - make sure that the repo is available, needs uri and repo_desc for all following states, the repo can be searched via repo_id or uri - * **absent** - drop the repo if found + - * **enabled** - a repo can have state disabled if installed via zypper service (ris), in this case, you can enable the repo - * **disabled** - instead of absent (drop), a repo can also set to disabled, which makes it inaccessible - -uri - If supplied, use the uri and not the object id as repo uri. - -repo_desc - If supplied, use the description and not the object id as repo description, only used if the state is present and the repo has to be created - -repo_id - If supplied, use the id and not the object id as repo id, can be used with state absent, enabled and disabled - - -EXAMPLES --------- - -.. code-block:: sh - - # Ensure testrepo in installed - __zypper_repo testrepo --state present --uri http://url.to.your.repo/with/path - - # Drop repo by repo uri - __zypper_repo testrepo --state absent --uri http://url.to.your.repo/with/path - - # Drop repo by id number (attention: repos are always numbered from 1 to max) - __zypper_repo testrepo --state absent --repo_id 1 - - # enable repo by id - __zypper_repo testrepo2 --state enabled --repo_id 2 - - # enable repo by uri - __zypper_repo testrepo3 --state enabled --uri http://url.to.your.repo/with/path - - # disable a repo works like enabling it - __zypper_repo testrepo4 --state disabled --repo_id 4 - - -AUTHORS -------- -Daniel Heule - - -COPYING -------- -Copyright \(C) 2013 Daniel Heule. 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. diff --git a/cdist/conf/type/__zypper_repo/man.text b/cdist/conf/type/__zypper_repo/man.text new file mode 100644 index 00000000..e8024ce5 --- /dev/null +++ b/cdist/conf/type/__zypper_repo/man.text @@ -0,0 +1,73 @@ +cdist-type__zypper_repo(7) +========================== +Daniel Heule + + +NAME +---- +cdist-type__zypper_repo - repository management with zypper + + +DESCRIPTION +----------- +zypper is usually used on the SuSE distribution to manage repositories. + + +REQUIRED PARAMETERS +------------------- +None + + +OPTIONAL PARAMETERS +------------------- +state:: + Either "present" or "absent" or "enabled" or "disabled", defaults to "present" + + #present# - make sure that the repo is aviable, needs uri and repo_desc + + for all following states, the repo can be searched via repo_id or uri + + #absent# - drop the repo if found + + #enabled# - a repo can have state disabled if installed via zypper service (ris), in this case, you can enable the repo + + #disabled# - instead of absent (drop), a repo can also set to disabled, wich makes it inaccessible + + +uri:: + If supplied, use the uri and not the object id as repo uri. + +repo_desc:: + If supplied, use the description and not the object id as repo description, only used if the state is present and the repo has to be created + +repo_id:: + If supplied, use the id and not the object id as repo id, can be used with state absent, enabled and disabled + + +EXAMPLES +-------- + +-------------------------------------------------------------------------------- +# Ensure testrepo in installed +__zypper_repo testrepo --state present --uri http://url.to.your.repo/with/path + +# Drop repo by repo uri +__zypper_repo testrepo --state absent --uri http://url.to.your.repo/with/path + +# Drop repo by id number (attention: repos are always numbered from 1 to max) +__zypper_repo testrepo --state absent --repo_id 1 + +# enable repo by id +__zypper_repo testrepo2 --state enabled --repo_id 2 + +# enable repo by uri +__zypper_repo testrepo3 --state enabled --uri http://url.to.your.repo/with/path + +# disable a repo works like enabling it +__zypper_repo testrepo4 --state disabled --repo_id 4 +-------------------------------------------------------------------------------- + + +SEE ALSO +-------- +- cdist-type(7) + + +COPYING +------- +Copyright \(C) 2013 Daniel Heule. 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/__zypper_service/explorer/repo_ids b/cdist/conf/type/__zypper_service/explorer/repo_ids index da506fea..e831b76c 100644 --- a/cdist/conf/type/__zypper_service/explorer/repo_ids +++ b/cdist/conf/type/__zypper_service/explorer/repo_ids @@ -24,6 +24,4 @@ # simpler command which works only on SLES11 SP3 or newer: # echo $(zypper lr -u -E | cut -d'|' -f 1 | grep -E '^[0-9]') # on older systems, zypper doesn't know the parameter -E -# -# shellcheck disable=SC2005,SC2046 echo $(zypper lr -u | grep -E '^([^|]+\|){3,3} Yes' | cut -d'|' -f 1 | grep -E '^[0-9]') diff --git a/cdist/conf/type/__zypper_service/explorer/service_id b/cdist/conf/type/__zypper_service/explorer/service_id index fbb983c8..bf5f0260 100644 --- a/cdist/conf/type/__zypper_service/explorer/service_id +++ b/cdist/conf/type/__zypper_service/explorer/service_id @@ -27,6 +27,4 @@ else fi # simpler command which works only on SLES11 SP3 or newer: # echo $(zypper ls -u -E | grep -E "\<$uri\>" | cut -d'|' -f 1 ) -# -# shellcheck disable=SC2005,SC2046 -echo $(zypper ls -u | grep -E '^([^|]+\|){3,3} Yes' | grep -E "\\<$uri\\>" | cut -d'|' -f 1) +echo $(zypper ls -u | grep -E '^([^|]+\|){3,3} Yes' | grep -E "\<$uri\>" | cut -d'|' -f 1 ) diff --git a/cdist/conf/type/__zypper_service/explorer/service_ids b/cdist/conf/type/__zypper_service/explorer/service_ids index 5a26740e..0f1f4186 100644 --- a/cdist/conf/type/__zypper_service/explorer/service_ids +++ b/cdist/conf/type/__zypper_service/explorer/service_ids @@ -22,6 +22,4 @@ # # simpler command which works only on SLES11 SP3 or newer: # echo $(zypper ls -u -E | cut -d'|' -f 1 | grep -E '^[0-9]') -# -# shellcheck disable=SC2005,SC2046 echo $(zypper ls -u | grep -E '^([^|]+\|){3,3} Yes' | cut -d'|' -f 1 | grep -E '^[0-9]') diff --git a/cdist/conf/type/__zypper_service/explorer/service_uri b/cdist/conf/type/__zypper_service/explorer/service_uri index 2f3d0f94..bcad4ec8 100644 --- a/cdist/conf/type/__zypper_service/explorer/service_uri +++ b/cdist/conf/type/__zypper_service/explorer/service_uri @@ -25,5 +25,6 @@ if [ -f "$__object/parameter/uri" ]; then else uri="/$__object_id" fi -# shellcheck disable=SC2005,SC2046 -echo $(zypper ls -u | awk 'BEGIN { FS = "[ ]+\\|[ ]+" } ; $4 == "Yes" && $NF == "'"$uri"'" {print $NF}') +# simpler command which works only on SLES11 SP3 or newer: +# echo $(zypper ls -u -E | grep -E "\<$uri\>" | cut -d'|' -f 7) +echo $(zypper ls -u | grep -E '^([^|]+\|){3,3} Yes' | grep -E "\<$uri\>" | cut -d'|' -f 7 ) diff --git a/cdist/conf/type/__zypper_service/gencode-remote b/cdist/conf/type/__zypper_service/gencode-remote old mode 100755 new mode 100644 index 4ccfe301..d16ba8ee --- a/cdist/conf/type/__zypper_service/gencode-remote +++ b/cdist/conf/type/__zypper_service/gencode-remote @@ -1,4 +1,4 @@ -#!/bin/sh -e +#!/bin/sh # # 2013 Daniel Heule (hda at sfs.biz) # @@ -46,7 +46,7 @@ exp_uri="$(cat "$__object/explorer/service_uri")" exp_id="$(cat "$__object/explorer/service_id")" # we need this list to remove ids, but we must do this in reverse order -exp_ids="$(rev "$__object/explorer/service_ids")" +exp_ids="$(cat "$__object/explorer/service_ids" | rev)" if [ "$uri" = "$exp_uri" ] ; then state_is="present" @@ -59,10 +59,10 @@ if [ -f "$__object/parameter/remove-all-other-services" ]; then # file exists -> True for i in $exp_ids; do if [ "$i" != "$exp_id" ] ; then - echo "zypper $zypper_def_opts removeservice $i &>/dev/null" + echo zypper $zypper_def_opts removeservice "$i" "&>/dev/null" fi done - echo "zypper $zypper_def_opts refs &>/dev/null" + echo zypper $zypper_def_opts refs "&>/dev/null" fi @@ -71,14 +71,14 @@ fi case "$state_should" in present) - echo "zypper $zypper_def_opts addservice -t $stype $uri '$desc'" - echo "zypper $zypper_def_opts refs" - echo "zypper $zypper_def_opts ref" + echo zypper $zypper_def_opts addservice -t "$stype" "$uri" \"$desc\" + echo zypper $zypper_def_opts refs + echo zypper $zypper_def_opts ref ;; absent) - echo "zypper $zypper_def_opts removeservice $exp_id" - echo "zypper $zypper_def_opts refs" - echo "zypper $zypper_def_opts ref" + echo zypper $zypper_def_opts removeservice "$service_id" + echo zypper $zypper_def_opts refs + echo zypper $zypper_def_opts ref ;; *) echo "Unknown state: $state_should" >&2 diff --git a/cdist/conf/type/__zypper_service/man.rst b/cdist/conf/type/__zypper_service/man.rst deleted file mode 100644 index e082dc02..00000000 --- a/cdist/conf/type/__zypper_service/man.rst +++ /dev/null @@ -1,66 +0,0 @@ -cdist-type__zypper_service(7) -============================= - -NAME ----- -cdist-type__zypper_service - Service management with zypper - - -DESCRIPTION ------------ -zypper is usually used on SuSE systems to manage services. - - -REQUIRED PARAMETERS -------------------- -uri - Uri of the service - - -OPTIONAL PARAMETERS -------------------- -service_desc - If supplied, use the service_desc and not the object id as description for the service. - -state - Either "present" or "absent", defaults to "present" - -type - Defaults to "ris", the standard type of services at SLES11. For other values, see manpage of zypper. - - -BOOLEAN PARAMETERS ------------------- -remove-all-other-services - Drop all other services found on the target host before adding the new one. - -remove-all-repos - If supplied, remove all existing repos prior to setup the new service. - - -EXAMPLES --------- - -.. code-block:: sh - - # Ensure that internal SLES11 SP3 RIS is in installed and all other services and repos are discarded - __zypper_service INTERNAL_SLES11_SP3 --service_desc "Internal SLES11 SP3 RIS" --uri "http://path/to/your/ris/dir" --remove-all-other-services --remove-all-repos - - # Ensure that internal SLES11 SP3 RIS is in installed, no changes to other services or repos - __zypper_service INTERNAL_SLES11_SP3 --service_desc "Internal SLES11 SP3 RIS" --uri "http://path/to/your/ris/dir" - - # Drop service by uri, no changes to other services or repos - __zypper_service INTERNAL_SLES11_SP3 --state absent --uri "http://path/to/your/ris/dir" - - -AUTHORS -------- -Daniel Heule - - -COPYING -------- -Copyright \(C) 2013 Daniel Heule. 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. diff --git a/cdist/conf/type/__zypper_service/man.text b/cdist/conf/type/__zypper_service/man.text new file mode 100644 index 00000000..b6bba660 --- /dev/null +++ b/cdist/conf/type/__zypper_service/man.text @@ -0,0 +1,67 @@ +cdist-type__zypper_service(7) +============================= +Daniel Heule + + +NAME +---- +cdist-type__zypper_service - service management with zypper + + +DESCRIPTION +----------- +zypper is usually used on SuSE systems to manage services. + + +REQUIRED PARAMETERS +------------------- +uri:: + Uri of the service + + +OPTIONAL PARAMETERS +------------------- +service_desc:: + If supplied, use the service_desc and not the object id as descritpion for the service. + +state:: + Either "present" or "absent", defaults to "present" + +type:: + Defaults to "ris", the standard type of services at SLES11. For other values, see manpage of zypper. + + +BOOLEAN PARAMETERS +------------------ +remove-all-other-services:: + Drop all other services found on the target host before adding the new one. + +remove-all-repos:: + If supplied, remove all existing repos prior to setup the new service. + + +EXAMPLES +-------- + +-------------------------------------------------------------------------------- +# Ensure that internal SLES11 SP3 RIS is in installed and all other services and repos are discarded +__zypper_service INTERNAL_SLES11_SP3 --service_desc "Internal SLES11 SP3 RIS" --uri "http://path/to/your/ris/dir" --remove-all-other-services --remove-all-repos + +# Ensure that internal SLES11 SP3 RIS is in installed, no changes to ohter services or repos +__zypper_service INTERNAL_SLES11_SP3 --service_desc "Internal SLES11 SP3 RIS" --uri "http://path/to/your/ris/dir" + +# Drop service by uri, no changes to ohter services or repos +__zypper_service INTERNAL_SLES11_SP3 --state absent --uri "http://path/to/your/ris/dir" + +-------------------------------------------------------------------------------- + + +SEE ALSO +-------- +- cdist-type(7) + + +COPYING +------- +Copyright \(C) 2013 Daniel Heule. 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/__zypper_service/manifest b/cdist/conf/type/__zypper_service/manifest old mode 100755 new mode 100644 index 42a56830..7f853b3b --- a/cdist/conf/type/__zypper_service/manifest +++ b/cdist/conf/type/__zypper_service/manifest @@ -1,4 +1,4 @@ -#!/bin/sh -e +#!/bin/sh # # 2013 Daniel Heule (hda at sfs.biz) # @@ -47,7 +47,7 @@ fi [ "$state_is" = "$state_should" ] && exit 0 # we need this list to remove ids, but we must do this in reverse order -exp_repos="$(rev "$__object/explorer/repo_ids")" +exp_repos="$(cat "$__object/explorer/repo_ids" | rev)" # boolean parameter if [ -f "$__object/parameter/remove-all-repos" ]; then diff --git a/cdist/config.py b/cdist/config.py index 26d07fc4..73ba4710 100644 --- a/cdist/config.py +++ b/cdist/config.py @@ -1,9 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# 2010-2015 Nico Schottelius (nico-cdist at schottelius.org) -# 2013-2017 Steven Armstrong (steven-cdist at armstrong.cc) -# 2016-2017 Darko Poljak (darko.poljak at gmail.com) +# 2010-2013 Nico Schottelius (nico-cdist at schottelius.org) # # This file is part of cdist. # @@ -24,686 +22,181 @@ import logging import os +import shutil import sys import time -import itertools -import tempfile -import multiprocessing -from cdist.mputil import mp_pool_run, mp_sig_handler -import atexit -import shutil -import socket +import pprint + import cdist -import cdist.hostsource + import cdist.exec.local import cdist.exec.remote -import cdist.util.ipaddr as ipaddr -import cdist.configuration -from cdist import core, inventory -from cdist.util.remoteutil import inspect_ssh_mux_opts - - -def graph_check_cycle(graph): - # Start from each node in the graph and check for cycle starting from it. - for node in graph: - # Cycle path. - path = [node] - has_cycle = _graph_dfs_cycle(graph, node, path) - if has_cycle: - return has_cycle, path - return False, None - - -def _graph_dfs_cycle(graph, node, path): - for neighbour in graph.get(node, ()): - # If node is already in path then this is cycle. - if neighbour in path: - path.append(neighbour) - return True - path.append(neighbour) - rv = _graph_dfs_cycle(graph, neighbour, path) - if rv: - return True - # Remove last item from list - neighbour whose DFS path we have have - # just checked. - del path[-1] - return False +from cdist import core class Config(object): """Cdist main class to hold arbitrary data""" - # list of paths (files and/or directories) that will be removed on finish - _paths_for_removal = [] + def __init__(self, local, remote, dry_run=False): - @classmethod - def _register_path_for_removal(cls, path): - cls._paths_for_removal.append(path) + self.local = local + self.remote = remote + self.log = logging.getLogger(self.local.target_host) + self.dry_run = dry_run - @classmethod - def _remove_paths(cls): - while cls._paths_for_removal: - path = cls._paths_for_removal.pop() - if os.path.isfile(path): - os.remove(path) - else: - shutil.rmtree(path) - - def __init__(self, local, remote, dry_run=False, jobs=None, - cleanup_cmds=None, remove_remote_files_dirs=False): - - self.local = local - self.remote = remote - self._open_logger() - self.dry_run = dry_run - self.jobs = jobs - if cleanup_cmds: - self.cleanup_cmds = cleanup_cmds - else: - self.cleanup_cmds = [] - self.remove_remote_files_dirs = remove_remote_files_dirs - - self.explorer = core.Explorer(self.local.target_host, self.local, - self.remote, jobs=self.jobs, - dry_run=self.dry_run) - self.manifest = core.Manifest(self.local.target_host, self.local, - dry_run=self.dry_run) - self.code = core.Code(self.local.target_host, self.local, self.remote, - dry_run=self.dry_run) + 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) def _init_files_dirs(self): """Prepare files and directories for the run""" self.local.create_files_dirs() self.remote.create_files_dirs() - def _remove_remote_files_dirs(self): - """Remove remote files and directories for the run""" - self.remote.remove_files_dirs() - - def _remove_files_dirs(self): - """Remove files and directories for the run""" - if self.remove_remote_files_dirs: - self._remove_remote_files_dirs() - - @staticmethod - def hosts(source): - try: - yield from cdist.hostsource.HostSource(source)() - except (IOError, OSError, UnicodeError) as e: - raise cdist.Error( - "Error reading hosts from \'{}\': {}".format( - source, e)) - - @staticmethod - def construct_remote_exec_copy_patterns(args): - # default remote cmd patterns - args.remote_cmds_cleanup_pattern = "" - args.remote_exec_pattern = None - args.remote_copy_pattern = None - - # Determine forcing IPv4/IPv6 options if any, only for - # default remote commands. - if args.force_ipv: - force_addr_opt = " -{}".format(args.force_ipv) - else: - force_addr_opt = "" - - args_dict = vars(args) - # if remote-exec and/or remote-copy args are None then user - # 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): - mux_opts = inspect_ssh_mux_opts() - if args_dict['remote_exec'] is None: - args.remote_exec_pattern = (cdist.REMOTE_EXEC + - force_addr_opt + mux_opts) - if args_dict['remote_copy'] is None: - args.remote_copy_pattern = (cdist.REMOTE_COPY + - force_addr_opt + mux_opts) - if mux_opts: - cleanup_pattern = cdist.REMOTE_CMDS_CLEANUP_PATTERN - else: - cleanup_pattern = "" - args.remote_cmds_cleanup_pattern = cleanup_pattern - - @classmethod - def _check_and_prepare_args(cls, args): - if args.manifest == '-' and args.hostfile == '-': - 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 = '-' - - if args.manifest == '-': - # read initial manifest from stdin - try: - 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)) - - args.manifest = initial_manifest_temp_path - atexit.register(lambda: os.remove(initial_manifest_temp_path)) - @classmethod def commandline(cls, args): """Configure remote system""" + import multiprocessing - if (args.parallel and args.parallel != 1) or args.jobs: - if args.timestamp: - cdist.log.setupTimestampingParallelLogging() - else: - cdist.log.setupParallelLogging() - elif args.timestamp: - cdist.log.setupTimestampingLogging() - log = logging.getLogger("config") - - # No new child process if only one host at a time. - if args.parallel == 1: - log.debug("Only 1 parallel process, doing it sequentially") - args.parallel = 0 - - if args.parallel: - import signal - - signal.signal(signal.SIGTERM, mp_sig_handler) - signal.signal(signal.SIGHUP, mp_sig_handler) - - cls._check_and_prepare_args(args) - + # FIXME: Refactor relict - remove later + log = logging.getLogger("cdist") + + 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.') + 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) + + args.manifest = initial_manifest_temp_path + import atexit + atexit.register(lambda: os.remove(initial_manifest_temp_path)) + + process = {} failed_hosts = [] time_start = time.time() - - cls.construct_remote_exec_copy_patterns(args) - base_root_path = cls.create_base_root_path(args.out_path) - - hostcnt = 0 - - cfg = cdist.configuration.Configuration(args) - configuration = cfg.get_config(section='GLOBAL') - - if args.tag or args.all_tagged_hosts: - inventory.determine_default_inventory_dir(args, configuration) - if args.all_tagged_hosts: - inv_list = inventory.InventoryList( - hosts=None, istag=True, hostfile=None, - db_basedir=args.inventory_dir) - else: - inv_list = inventory.InventoryList( - hosts=args.host, istag=True, hostfile=args.hostfile, - db_basedir=args.inventory_dir, - has_all_tags=args.has_all_tags) - it = inv_list.entries() - else: - it = itertools.chain(cls.hosts(args.host), - cls.hosts(args.hostfile)) - - process_args = [] - if args.parallel: - log.trace("Processing hosts in parallel") - else: - log.trace("Processing hosts sequentially") - for entry in it: - if isinstance(entry, tuple): - # if configuring by specified tags - host = entry[0] - host_tags = entry[1] - else: - # if configuring by host then check inventory for tags - host = entry - inventory.determine_default_inventory_dir(args, configuration) - inv_list = inventory.InventoryList( - hosts=(host,), db_basedir=args.inventory_dir) - inv = tuple(inv_list.entries()) - if inv: - # host is present in inventory and has tags - host_tags = inv[0][1] - else: - # host is not present in inventory or has no tags - host_tags = None - host_base_path, hostdir = cls.create_host_base_dirs( - host, base_root_path) - log.debug("Base root path for target host \"{}\" is \"{}\"".format( - host, host_base_path)) - - hostcnt += 1 + + for host in args.host: if args.parallel: - pargs = (host, host_tags, host_base_path, hostdir, args, True, - configuration) - log.trace(("Args for multiprocessing operation " - "for host {}: {}".format(host, pargs))) - process_args.append(pargs) + log.debug("Creating child process for %s", host) + process[host] = multiprocessing.Process(target=cls.onehost, args=(host, args, True)) + process[host].start() else: try: - cls.onehost(host, host_tags, host_base_path, hostdir, - args, parallel=False, - configuration=configuration) - except cdist.Error: + cls.onehost(host, args, parallel=False) + except cdist.Error as e: failed_hosts.append(host) - if args.parallel and len(process_args) == 1: - log.debug("Only 1 host for parallel processing, doing it " - "sequentially") - try: - cls.onehost(*process_args[0]) - except cdist.Error: - failed_hosts.append(host) - elif args.parallel: - log.trace("Multiprocessing start method is {}".format( - multiprocessing.get_start_method())) - log.trace(("Starting multiprocessing Pool for {} " - "parallel host operation".format(args.parallel))) - - results = mp_pool_run(cls.onehost, - process_args, - jobs=args.parallel) - log.trace(("Multiprocessing for parallel host operation " - "finished")) - log.trace("Multiprocessing for parallel host operation " - "results: %s", results) - - failed_hosts = [host for host, result in results if not result] - + + # 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.verbose("Total processing time for %s host(s): %s", hostcnt, + log.info("Total processing time for %s host(s): %s", len(args.host), (time_end - time_start)) - + if len(failed_hosts) > 0: - raise cdist.Error("Failed to configure the following hosts: " + - " ".join(failed_hosts)) - elif not args.out_path: - # If tmp out path created then remove it, but only if no failed - # hosts. - shutil.rmtree(base_root_path) - + raise cdist.Error("Failed to configure the following hosts: " + + " ".join(failed_hosts)) + @classmethod - def _resolve_ssh_control_path(cls): - base_path = tempfile.mkdtemp() - cls._register_path_for_removal(base_path) - control_path = os.path.join(base_path, "s") - return control_path - - @classmethod - def _resolve_remote_cmds(cls, args): - if (args.remote_exec_pattern or - args.remote_copy_pattern or - args.remote_cmds_cleanup_pattern): - control_path = cls._resolve_ssh_control_path() - # If we constructed patterns for remote commands then there is - # placeholder for ssh ControlPath, format it and we have unique - # ControlPath for each host. - # - # If not then use args.remote_exec/copy that user specified. - if args.remote_exec_pattern: - remote_exec = args.remote_exec_pattern.format(control_path) - else: - remote_exec = args.remote_exec - if args.remote_copy_pattern: - remote_copy = args.remote_copy_pattern.format(control_path) - else: - remote_copy = args.remote_copy - if args.remote_cmds_cleanup_pattern: - remote_cmds_cleanup = args.remote_cmds_cleanup_pattern.format( - control_path) - else: - remote_cmds_cleanup = "" - return (remote_exec, remote_copy, remote_cmds_cleanup, ) - - @staticmethod - def _address_family(args): - if args.force_ipv == 4: - family = socket.AF_INET - elif args.force_ipv == 6: - family = socket.AF_INET6 - else: - family = 0 - return family - - @staticmethod - def resolve_target_addresses(host, family): - try: - return ipaddr.resolve_target_addresses(host, family) - except: - e = sys.exc_info()[1] - raise cdist.Error(("Error resolving target addresses for host '{}'" - ": {}").format(host, e)) - - @classmethod - def onehost(cls, host, host_tags, host_base_path, host_dir_name, args, - parallel, configuration, remove_remote_files_dirs=False): - """Configure ONE system. - If operating in parallel then return tuple (host, True|False, ) - so that main process knows for which host function was successful. - """ + def onehost(cls, host, args, parallel): + """Configure ONE system""" log = logging.getLogger(host) - + try: - remote_exec, remote_copy, cleanup_cmd = cls._resolve_remote_cmds( - args) - log.debug("remote_exec for host \"{}\": {}".format( - host, remote_exec)) - log.debug("remote_copy for host \"{}\": {}".format( - host, remote_copy)) - - family = cls._address_family(args) - log.debug("address family: {}".format(family)) - target_host = cls.resolve_target_addresses(host, family) - log.debug("target_host for host \"{}\": {}".format( - host, target_host)) - local = cdist.exec.local.Local( - target_host=target_host, - target_host_tags=host_tags, - base_root_path=host_base_path, - host_dir_name=host_dir_name, + target_host=host, initial_manifest=args.manifest, - add_conf_dirs=args.conf_dir, - cache_path_pattern=args.cache_path_pattern, - quiet_mode=args.quiet, - configuration=configuration, - exec_path=sys.argv[0], - save_output_streams=args.save_output_streams) + base_path=args.out_path, + add_conf_dirs=args.conf_dir) remote = cdist.exec.remote.Remote( - target_host=target_host, - remote_exec=remote_exec, - remote_copy=remote_copy, - base_path=args.remote_out_path, - quiet_mode=args.quiet, - archiving_mode=args.use_archiving, - configuration=configuration, - stdout_base_path=local.stdout_base_path, - stderr_base_path=local.stderr_base_path, - save_output_streams=args.save_output_streams) - - cleanup_cmds = [] - if cleanup_cmd: - cleanup_cmds.append(cleanup_cmd) - c = cls(local, remote, dry_run=args.dry_run, jobs=args.jobs, - cleanup_cmds=cleanup_cmds, - remove_remote_files_dirs=remove_remote_files_dirs) + target_host=host, + remote_exec=args.remote_exec, + remote_copy=args.remote_copy) + + c = cls(local, remote, dry_run=args.dry_run) c.run() - cls._remove_paths() - + except cdist.Error as e: log.error(e) if parallel: - return (host, False, ) + # We are running in our own process here, need to sys.exit! + sys.exit(1) + else: + raise + + except KeyboardInterrupt: + # Ignore in parallel mode, we are existing anyway + if parallel: + sys.exit(0) + # Pass back to controlling code in sequential mode else: raise - - if parallel: - return (host, True, ) - - @staticmethod - def create_base_root_path(out_path=None): - if out_path: - base_root_path = out_path - else: - base_root_path = tempfile.mkdtemp() - - return base_root_path - - @staticmethod - def create_host_base_dirs(host, base_root_path): - hostdir = cdist.str_hash(host) - host_base_path = os.path.join(base_root_path, hostdir) - - return (host_base_path, hostdir) def run(self): """Do what is most often done: deploy & cleanup""" start_time = time.time() - self.log.info("Starting {} run".format( - 'dry' if self.dry_run else 'configuration')) - self._init_files_dirs() self.explorer.run_global_explorers(self.local.global_explorer_out_path) - try: - self.manifest.run_initial_manifest(self.local.initial_manifest) - except cdist.Error as e: - which = "init" - stdout_path = os.path.join(self.local.stdout_base_path, which) - stderr_path = os.path.join(self.local.stderr_base_path, which) - raise cdist.InitialManifestError(self.local.initial_manifest, - stdout_path, stderr_path, e) + self.manifest.run_initial_manifest(self.local.initial_manifest) self.iterate_until_finished() - self.cleanup() - self._remove_files_dirs() - self.local.save_cache(start_time) - self.log.info("Finished {} run in {:.2f} seconds".format( - 'dry' if self.dry_run else 'successful', - time.time() - start_time)) + self.local.save_cache() + self.log.info("Finished successful run in %s seconds", time.time() - start_time) - def cleanup(self): - self.log.debug("Running cleanup commands") - for cleanup_cmd in self.cleanup_cmds: - cmd = cleanup_cmd.split() - cmd.append(self.local.target_host[0]) - try: - if self.log.getEffectiveLevel() <= logging.DEBUG: - quiet_mode = False - else: - quiet_mode = True - self.local.run(cmd, return_output=False, save_output=False, - quiet_mode=quiet_mode) - except cdist.Error as e: - # Log warning but continue. - self.log.warning("Cleanup command failed: %s", e) 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): 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 """ - if self.jobs: - objects_changed = self._iterate_once_parallel() - else: - objects_changed = self._iterate_once_sequential() - return objects_changed - - def _iterate_once_sequential(self): - self.log.debug("Iteration in sequential mode") - objects_changed = False + objects_changed = False for cdist_object in self.object_list(): - if cdist_object.requirements_unfinished( - cdist_object.requirements): + 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 - """ + + if cdist_object.requirements_unfinished(cdist_object.autorequire): + """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_once_parallel(self): - self.log.debug("Iteration in parallel mode in {} jobs".format( - self.jobs)) - objects_changed = False - - cargo = [] - 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 - cargo.append(cdist_object) - - n = len(cargo) - if n == 1: - self.log.debug("Only one object, preparing sequentially") - self.object_prepare(cargo[0]) - objects_changed = True - elif cargo: - self.log.trace("Multiprocessing start method is {}".format( - multiprocessing.get_start_method())) - - self.log.trace("Multiprocessing cargo: %s", cargo) - - cargo_types = set() - for c in cargo: - cargo_types.add(c.cdist_type) - self.log.trace("Multiprocessing cargo_types: %s", cargo_types) - nt = len(cargo_types) - if nt == 1: - self.log.debug(("Only one type, transferring explorers " - "sequentially")) - self.explorer.transfer_type_explorers(cargo_types.pop()) - else: - self.log.trace(("Starting multiprocessing Pool for {} " - "parallel types explorers transferring".format( - nt))) - args = [ - (ct, ) for ct in cargo_types - ] - mp_pool_run(self.explorer.transfer_type_explorers, args, - jobs=self.jobs) - self.log.trace(("Multiprocessing for parallel transferring " - "types' explorers finished")) - - self.log.trace(("Starting multiprocessing Pool for {} parallel " - "objects preparation".format(n))) - args = [ - (c, False, ) for c in cargo - ] - mp_pool_run(self.object_prepare, args, jobs=self.jobs) - self.log.trace(("Multiprocessing for parallel object " - "preparation finished")) - objects_changed = True - - del cargo[:] - 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_PREPARED: - if cdist_object.requirements_unfinished( - cdist_object.autorequire): - """The previous step created objects we depend on - - wait for them - """ - continue - - # self.object_run(cdist_object) - # objects_changed = True - - # put objects in chuncks of distinct types - # so that there is no more than one object - # of the same type in one chunk because there is a - # possibility of object's process locking which - # prevents parallel execution at remote - # and do this only for nonparallel marked types - for chunk in cargo: - for obj in chunk: - if (obj.cdist_type == cdist_object.cdist_type and - cdist_object.cdist_type.is_nonparallel): - break - else: - chunk.append(cdist_object) - break - else: - chunk = [cdist_object, ] - cargo.append(chunk) - - for chunk in cargo: - self.log.trace("Running chunk: %s", chunk) - n = len(chunk) - if n == 1: - self.log.debug("Only one object, running sequentially") - self.object_run(chunk[0]) - objects_changed = True - elif chunk: - self.log.trace("Multiprocessing start method is {}".format( - multiprocessing.get_start_method())) - self.log.trace(("Starting multiprocessing Pool for {} " - "parallel object run".format(n))) - args = [ - (c, ) for c in chunk - ] - mp_pool_run(self.object_run, args, jobs=self.jobs) - self.log.trace(("Multiprocessing for parallel object " - "run finished")) - objects_changed = True - - return objects_changed - - def _open_logger(self): - self.log = logging.getLogger(self.local.target_host[0]) - - # logger is not pickable, so remove it when we pickle - def __getstate__(self): - state = self.__dict__.copy() - if 'log' in state: - del state['log'] - return state - - # recreate logger when we unpickle - def __setstate__(self, state): - self.__dict__.update(state) - self._open_logger() - - def _validate_dependencies(self): - ''' - Build dependency graph for unfinished objects and - check for cycles. - ''' - graph = {} - for cdist_object in self.object_list(): - obj_name = cdist_object.name - if obj_name not in graph: - graph[obj_name] = [] - if cdist_object.state == cdist_object.STATE_DONE: - continue - - for requirement in cdist_object.requirements_unfinished( - cdist_object.requirements): - graph[obj_name].append(requirement.name) - - for requirement in cdist_object.requirements_unfinished( - cdist_object.autorequire): - graph[obj_name].append(requirement.name) - return graph_check_cycle(graph) def iterate_until_finished(self): """ @@ -714,12 +207,6 @@ class Config(object): objects_changed = True while objects_changed: - # Check for cycles as early as possible. - has_cycle, path = self._validate_dependencies() - if has_cycle: - raise cdist.UnresolvableRequirementsError( - "Cycle detected in object dependencies:\n{}!".format( - " -> ".join(path))) objects_changed = self.iterate_once() # Check whether all objects have been finished @@ -736,93 +223,55 @@ 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))) + requirements = ", ".join(requirement_names) + autorequire = ", ".join(autorequire_names) + info_string.append("%s requires: %s autorequires: %s" % (cdist_object.name, requirements, 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: %s" % + ("; ".join(info_string))) - def _handle_deprecation(self, cdist_object): - cdist_type = cdist_object.cdist_type - deprecated = cdist_type.deprecated - if deprecated is not None: - if deprecated: - self.log.warning("Type %s is deprecated: %s", cdist_type.name, - deprecated) - else: - self.log.warning("Type %s is deprecated.", cdist_type.name) - for param in cdist_object.parameters: - if param in cdist_type.deprecated_parameters: - msg = cdist_type.deprecated_parameters[param] - if msg: - format = "%s parameter of type %s is deprecated: %s" - args = [param, cdist_type.name, msg] - else: - format = "%s parameter of type %s is deprecated." - args = [param, cdist_type.name] - self.log.warning(format, *args) - - def object_prepare(self, cdist_object, transfer_type_explorers=True): + def object_prepare(self, cdist_object): """Prepare object: Run type explorer + manifest""" - self._handle_deprecation(cdist_object) - self.log.verbose("Preparing object {}".format(cdist_object.name)) - self.log.verbose( - "Running manifest and explorers for " + cdist_object.name) - self.explorer.run_type_explorers(cdist_object, transfer_type_explorers) - try: - self.manifest.run_type_manifest(cdist_object) - cdist_object.state = core.CdistObject.STATE_PREPARED - except cdist.Error as e: - raise cdist.CdistObjectError(cdist_object, e) + 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 def object_run(self, cdist_object): """Run gencode and code for an object""" - try: - self.log.verbose("Running object " + cdist_object.name) - if cdist_object.state == core.CdistObject.STATE_DONE: - raise cdist.Error(("Attempting to run an already finished " - "object: %s"), cdist_object) - # Generate - self.log.debug("Generating code for %s" % (cdist_object.name)) - cdist_object.code_local = self.code.run_gencode_local(cdist_object) - cdist_object.code_remote = self.code.run_gencode_remote( - cdist_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) + + cdist_type = cdist_object.cdist_type + + # Generate + self.log.info("Generating code for %s" % (cdist_object.name)) + cdist_object.code_local = self.code.run_gencode_local(cdist_object) + cdist_object.code_remote = self.code.run_gencode_remote(cdist_object) + if cdist_object.code_local or cdist_object.code_remote: + cdist_object.changed = True + + # Execute + if not self.dry_run: if cdist_object.code_local or cdist_object.code_remote: - cdist_object.changed = True + self.log.info("Executing code for %s" % (cdist_object.name)) + if cdist_object.code_local: + self.code.run_code_local(cdist_object) + if cdist_object.code_remote: + self.code.transfer_code_remote(cdist_object) + self.code.run_code_remote(cdist_object) + else: + self.log.info("Skipping code execution due to DRY RUN") - # Execute - if cdist_object.code_local or cdist_object.code_remote: - self.log.info("Processing %s" % (cdist_object.name)) - if not self.dry_run: - if cdist_object.code_local: - self.log.trace("Executing local code for %s" - % (cdist_object.name)) - self.code.run_code_local(cdist_object) - if cdist_object.code_remote: - self.log.trace("Executing remote code for %s" - % (cdist_object.name)) - self.code.transfer_code_remote(cdist_object) - self.code.run_code_remote(cdist_object) - # Mark this object as done - self.log.trace("Finishing run of " + cdist_object.name) - cdist_object.state = core.CdistObject.STATE_DONE - except cdist.Error as e: - raise cdist.CdistObjectError(cdist_object, e) + # 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/configuration.py b/cdist/configuration.py deleted file mode 100644 index f05a5963..00000000 --- a/cdist/configuration.py +++ /dev/null @@ -1,497 +0,0 @@ -# -*- coding: utf-8 -*- -# -# 2017 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 configparser -import os -import cdist -import cdist.argparse -import re -import multiprocessing -import logging - - -class Singleton(type): - instance = None - - def __call__(cls, *args, **kwargs): - if 'singleton' in kwargs and not kwargs['singleton']: - return super(Singleton, cls).__call__(*args, **kwargs) - else: - if not cls.instance: - cls.instance = super(Singleton, cls).__call__(*args, **kwargs) - return cls.instance - - -_VERBOSITY_VALUES = ( - 'ERROR', 'WARNING', 'INFO', 'VERBOSE', 'DEBUG', 'TRACE', 'OFF', -) -_ARCHIVING_VALUES = ( - 'tar', 'tgz', 'tbz2', 'txz', 'none', -) - - -class OptionBase: - def __init__(self, name): - self.name = name - - def get_converter(self, *args, **kwargs): - raise NotImplementedError('Subclass should implement this method') - - def translate(self, val): - return val - - def update_value(self, currval, newval, update_appends=False): - '''Update current option value currval with new option value newval. - If update_appends is True and if currval and newval are lists then - resulting list contains all values in currval plus all values in - newval. Otherwise, newval is returned. - ''' - if (isinstance(currval, list) and isinstance(newval, list) and - update_appends): - rv = [] - if currval: - rv.extend(currval) - if newval: - rv.extend(newval) - if not rv: - rv = None - return rv - else: - return newval - - def should_override(self, currval, newval): - return True - - -class StringOption(OptionBase): - def __init__(self, name): - super().__init__(name) - - def get_converter(self): - def string_converter(val): - return self.translate(str(val)) - return string_converter - - def translate(self, val): - if val: - return val - else: - return None - - -class BooleanOption(OptionBase): - BOOLEAN_STATES = configparser.ConfigParser.BOOLEAN_STATES - - # If default_overrides is False then previous config value will not be - # overriden with default_value. - def __init__(self, name, default_overrides=True, default_value=True): - super().__init__(name) - self.default_overrides = default_overrides - self.default_value = default_value - - def get_converter(self): - def boolean_converter(val): - v = val.lower() - if v not in self.BOOLEAN_STATES: - raise ValueError('Invalid {} boolean value: {}'.format( - self.name, val)) - return self.translate(v) - return boolean_converter - - def translate(self, val): - return self.BOOLEAN_STATES[val] - - def should_override(self, currval, newval): - if not self.default_overrides: - return newval != self.default_value - return True - - -class IntOption(OptionBase): - def __init__(self, name): - super().__init__(name) - - def get_converter(self): - def int_converter(val): - return self.translate(int(val)) - return int_converter - - -class LowerBoundIntOption(IntOption): - def __init__(self, name, lower_bound): - super().__init__(name) - self.lower_bound = lower_bound - - def get_converter(self): - def lower_bound_converter(val): - converted = super(LowerBoundIntOption, self).get_converter()(val) - if converted < self.lower_bound: - raise ValueError("Invalid {} value: {} < {}".format( - self.name, val, self.lower_bound)) - return converted - return lower_bound_converter - - -class SpecialCasesLowerBoundIntOption(LowerBoundIntOption): - def __init__(self, name, lower_bound, special_cases_mapping): - super().__init__(name, lower_bound) - self.special_cases_mapping = special_cases_mapping - - def translate(self, val): - if val in self.special_cases_mapping: - return self.special_cases_mapping[val] - else: - return val - - -class JobsOption(SpecialCasesLowerBoundIntOption): - def __init__(self, name): - super().__init__(name, -1, {-1: multiprocessing.cpu_count()}) - - -class SelectOption(OptionBase): - def __init__(self, name, valid_values): - super().__init__(name) - self.valid_values = valid_values - - def get_converter(self): - def select_converter(val): - if val in self.valid_values: - return self.translate(val) - else: - raise ValueError("Invalid {} value: {}.".format( - self.name, val)) - return select_converter - - -class VerbosityOption(SelectOption): - def __init__(self): - super().__init__('verbosity', _VERBOSITY_VALUES) - - def translate(self, val): - name = 'VERBOSE_' + val - verbose = getattr(cdist.argparse, name) - return verbose - - -class DelimitedValuesOption(OptionBase): - def __init__(self, name, delimiter): - super().__init__(name) - self.delimiter = delimiter - - def get_converter(self): - def delimited_values_converter(val): - vals = re.split(r'(? - ('__type_name', 'the/object_id') + """split_name('__type_name/the/object_id') -> ('__type_name', 'the/object_id') Split the given object name into it's type and object_id parts. @@ -121,9 +113,7 @@ class CdistObject(object): @staticmethod def join_name(type_name, object_id): - """join_name('__type_name', 'the/object_id') - -> - __type_name/the/object_id' + """join_name('__type_name', 'the/object_id') -> __type_name/the/object_id' Join the given type_name and object_id into an object name. @@ -132,61 +122,45 @@ 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 an ' - 'object_id')) + raise IllegalObjectIdError('singleton objects can\'t have a 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) + if OBJECT_MARKER in self.object_id.split(os.sep): + raise IllegalObjectIdError(self.object_id, 'object_id may not contain \'%s\'' % OBJECT_MARKER) if '//' in self.object_id: - raise IllegalObjectIdError( - self.object_id, 'object_id may not contain //') - - _invalid_object_ids = ('.', '/', ) - for ioid in _invalid_object_ids: - if self.object_id == ioid: - raise IllegalObjectIdError( - self.object_id, - 'object_id may not be a {}'.format(ioid)) + 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 .') # 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. + """Convenience method for creating an object instance from an object name. Mainly intended to create objects when resolving requirements. e.g: - .object_from_name('__other/object') -> - + .object_from_name('__other/object') -> """ base_path = self.base_path type_path = self.cdist_type.base_path - object_marker = self.object_marker type_name, object_id = self.split_name(object_name) 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_id=object_id) def __repr__(self): return '' % self.name @@ -194,7 +168,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) @@ -227,22 +201,14 @@ 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): @@ -253,14 +219,11 @@ class CdistObject(object): """Create this cdist object on the filesystem. """ try: - for path in (self.absolute_path, - os.path.join(self.base_path, self.parameter_path), - self.stdout_path, - self.stderr_path): - os.makedirs(path, exist_ok=allow_overwrite) + os.makedirs(self.absolute_path, exist_ok=allow_overwrite) + absolute_parameter_path = os.path.join(self.base_path, self.parameter_path) + os.makedirs(absolute_parameter_path, exist_ok=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 4500f50d..ff1ebaec 100644 --- a/cdist/core/cdist_type.py +++ b/cdist/core/cdist_type.py @@ -21,21 +21,17 @@ # import os + import cdist -import cdist.core -import logging - -class InvalidTypeError(cdist.Error): +class NoSuchTypeError(cdist.Error): def __init__(self, name, type_path, type_absolute_path): self.name = name self.type_path = type_path self.type_absolute_path = type_absolute_path - self.source_path = os.path.realpath(self.type_absolute_path) def __str__(self): - return "Invalid type '%s' at '%s' defined at '%s'" % ( - self.type_path, self.type_absolute_path, self.source_path) + return "Type '%s' does not exist at %s" % (self.type_path, self.type_absolute_path) class CdistType(object): @@ -47,15 +43,13 @@ class CdistType(object): """ - log = logging.getLogger("cdist-type") - def __init__(self, base_path, name): self.base_path = base_path self.name = name self.path = self.name self.absolute_path = os.path.join(self.base_path, self.path) if not os.path.isdir(self.absolute_path): - raise InvalidTypeError(self.name, self.path, self.absolute_path) + raise NoSuchTypeError(self.name, self.path, self.absolute_path) self.manifest_path = os.path.join(self.name, "manifest") self.explorer_path = os.path.join(self.name, "explorer") self.gencode_local_path = os.path.join(self.name, "gencode-local") @@ -69,40 +63,25 @@ class CdistType(object): self.__optional_multiple_parameters = None self.__boolean_parameters = None self.__parameter_defaults = None - self.__deprecated_parameters = None - - def __hash__(self): - return hash(self.name) @classmethod def list_types(cls, base_path): """Return a list of type instances""" for name in cls.list_type_names(base_path): - try: - yield cls(base_path, name) - except InvalidTypeError as e: - # ignore invalid type, log warning and continue - msg = "Ignoring invalid type '%s' at '%s' defined at '%s'" % ( - e.type_path, e.type_absolute_path, e.source_path) - cls.log.warning(msg) - # remove invalid from runtime conf dir - os.remove(e.type_absolute_path) + yield cls(base_path, name) @classmethod def list_type_names(cls, base_path): """Return a list of type names""" - return cdist.core.listdir(base_path) + return os.listdir(base_path) + _instances = {} - - def __getnewargs__(self): - return self.base_path, self.name - def __new__(cls, *args, **kwargs): """only one instance of each named type may exist""" # name is second argument name = args[1] - if name not in cls._instances: + if not name in cls._instances: instance = super(CdistType, cls).__new__(cls) cls._instances[name] = instance # return instance so __init__ is called @@ -124,34 +103,15 @@ 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 - def is_nonparallel(self): - """Check whether a type is a non parallel, i.e. its objects - cannot run in parallel.""" - return os.path.isfile(os.path.join(self.absolute_path, "nonparallel")) - - @property - def deprecated(self): - """Get type deprecation message. If message is None then type - is not deprecated.""" - deprecated_path = os.path.join(self.absolute_path, "deprecated") - try: - with open(deprecated_path, 'r') as f: - return f.read() - except FileNotFoundError: - return None - @property def explorers(self): """Return a list of available explorers""" if not self.__explorers: try: - self.__explorers = cdist.core.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 = [] @@ -163,13 +123,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: - line = line.strip() - if line: - parameters.append(line) + parameters.append(line.strip()) except EnvironmentError: # error ignored pass @@ -183,13 +139,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: - line = line.strip() - if line: - parameters.append(line) + parameters.append(line.strip()) except EnvironmentError: # error ignored pass @@ -203,13 +155,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: - line = line.strip() - if line: - parameters.append(line) + parameters.append(line.strip()) except EnvironmentError: # error ignored pass @@ -223,13 +171,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: - line = line.strip() - if line: - parameters.append(line) + parameters.append(line.strip()) except EnvironmentError: # error ignored pass @@ -243,13 +187,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: - line = line.strip() - if line: - parameters.append(line) + parameters.append(line.strip()) except EnvironmentError: # error ignored pass @@ -262,37 +202,13 @@ class CdistType(object): if not self.__parameter_defaults: defaults = {} try: - defaults_dir = os.path.join(self.absolute_path, - "parameter", - "default") - for name in cdist.core.listdir(defaults_dir): - try: - with open(os.path.join(defaults_dir, name)) as fd: - defaults[name] = fd.read().strip() - except EnvironmentError: - pass # Swallow errors raised by open() or read() + defaults_dir = os.path.join(self.absolute_path, "parameter", "default") + for name in os.listdir(defaults_dir): + with open(os.path.join(defaults_dir, name)) as fd: + defaults[name] = fd.read().strip() except EnvironmentError: - pass # Swallow error raised by os.listdir() + # error ignored + pass finally: self.__parameter_defaults = defaults return self.__parameter_defaults - - @property - def deprecated_parameters(self): - if not self.__deprecated_parameters: - deprecated = {} - try: - deprecated_dir = os.path.join(self.absolute_path, - "parameter", - "deprecated") - for name in cdist.core.listdir(deprecated_dir): - try: - with open(os.path.join(deprecated_dir, name)) as fd: - deprecated[name] = fd.read().strip() - except EnvironmentError: - pass # Swallow errors raised by open() or read() - except EnvironmentError: - pass # Swallow error raised by os.listdir() - finally: - self.__deprecated_parameters = deprecated - return self.__deprecated_parameters diff --git a/cdist/core/code.py b/cdist/core/code.py index 1550880a..5374bcdf 100644 --- a/cdist/core/code.py +++ b/cdist/core/code.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -# 2011-2017 Steven Armstrong (steven-cdist at armstrong.cc) +# 2011 Steven Armstrong (steven-cdist at armstrong.cc) # 2011-2013 Nico Schottelius (nico-cdist at schottelius.org) # 2014 Daniel Heule (hda at sfs.biz) # @@ -21,8 +21,12 @@ # # +import logging import os -from . import util + +import cdist + +log = logging.getLogger(__name__) ''' @@ -32,30 +36,20 @@ common: env: PATH: prepend directory with type emulator symlinks == local.bin_path __target_host: the target host we are working on - __target_hostname: the target hostname provided from __target_host - __target_fqdn: the target's fully qualified domain name provided from - __target_host __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 - __target_hostname: the target hostname provided from __target_host - __target_fqdn: the target's fully qualified domain name provided from - __target_host - __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 - __target_host_tags: comma spearated list of host tags returns: string containing the generated code or None @@ -64,17 +58,11 @@ gencode-remote env: __target_host: the target host we are working on - __target_hostname: the target hostname provided from __target_host - __target_fqdn: the target's fully qualified domain name provided from - __target_host - __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 - __target_host_tags: comma spearated list of host tags returns: string containing the generated code or None @@ -96,30 +84,18 @@ class Code(object): """Generates and executes cdist code scripts. """ - # target_host is tuple (target_host, target_hostname, target_fqdn) - def __init__(self, target_host, local, remote, dry_run=False): + def __init__(self, target_host, local, remote): self.target_host = target_host self.local = local self.remote = remote self.env = { - '__target_host': self.target_host[0], - '__target_hostname': self.target_host[1], - '__target_fqdn': self.target_host[2], + '__target_host': self.target_host, '__global': self.local.base_path, - '__files': self.local.files_path, - '__target_host_tags': self.local.target_host_tags, - '__cdist_log_level': util.log_level_env_var_val(local.log), - '__cdist_log_level_name': util.log_level_name_env_var_val( - local.log), } - if dry_run: - self.env['__cdist_dry_run'] = '1' - 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) @@ -129,19 +105,8 @@ class Code(object): '__object_id': cdist_object.object_id, '__object_name': cdist_object.name, }) - message_prefix = cdist_object.name - if self.local.save_output_streams: - stderr_path = os.path.join(cdist_object.stderr_path, - 'gencode-' + which) - with open(stderr_path, 'ba+') as stderr: - return self.local.run_script(script, env=env, - return_output=True, - message_prefix=message_prefix, - stderr=stderr) - else: - 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.""" @@ -152,35 +117,21 @@ 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) - self.remote.mkdir(os.path.dirname(destination)) + """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)) - if which_exec.save_output_streams: - stderr_path = os.path.join(cdist_object.stderr_path, - 'code-' + which) - stdout_path = os.path.join(cdist_object.stdout_path, - 'code-' + which) - with open(stderr_path, 'ba+') as stderr, \ - open(stdout_path, 'ba+') as stdout: - return which_exec.run_script(script, env=env, stdout=stdout, - stderr=stderr) - else: - return which_exec.run_script(script, env=env) + 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({ @@ -190,13 +141,10 @@ 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 353d7681..41851bd6 100644 --- a/cdist/core/explorer.py +++ b/cdist/core/explorer.py @@ -23,18 +23,15 @@ import logging import os import glob -import multiprocessing + import cdist -from cdist.mputil import mp_pool_run -from . import util ''' 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: @@ -55,8 +52,7 @@ 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 @@ -67,34 +63,20 @@ class Explorer(object): """Executes cdist explorers. """ - def __init__(self, target_host, local, remote, jobs=None, dry_run=False): + def __init__(self, target_host, local, remote): self.target_host = target_host - self._open_logger() + self.log = logging.getLogger(target_host) self.local = local self.remote = remote self.env = { - '__target_host': self.target_host[0], - '__target_hostname': self.target_host[1], - '__target_fqdn': self.target_host[2], + '__target_host': self.target_host, '__explorer': self.remote.global_explorer_path, - '__target_host_tags': self.local.target_host_tags, - '__cdist_log_level': util.log_level_env_var_val(self.log), - '__cdist_log_level_name': util.log_level_name_env_var_val( - self.log), } - - if dry_run: - self.env['__cdist_dry_run'] = '1' - self._type_explorers_transferred = [] - self.jobs = jobs - def _open_logger(self): - self.log = logging.getLogger(self.target_host[0]) - - # global + ### global def list_global_explorer_names(self): """Return a list of global explorer names.""" @@ -105,71 +87,26 @@ class Explorer(object): out_path directory. """ - self.log.verbose("Running global explorers") + self.log.info("Running global explorers") self.transfer_global_explorers() - if self.jobs is None: - self._run_global_explorers_seq(out_path) - else: - self._run_global_explorers_parallel(out_path) - - def _run_global_explorer(self, explorer, out_path): - try: - path = os.path.join(out_path, explorer) + for explorer in self.list_global_explorer_names(): output = self.run_global_explorer(explorer) + path = os.path.join(out_path, explorer) with open(path, 'w') as fd: fd.write(output) - except cdist.Error as e: - local_path = os.path.join(self.local.global_explorer_path, - explorer) - stderr_path = os.path.join(self.local.stderr_base_path, "remote") - raise cdist.GlobalExplorerError(explorer, local_path, stderr_path, - e) - - def _run_global_explorers_seq(self, out_path): - self.log.debug("Running global explorers sequentially") - for explorer in self.list_global_explorer_names(): - self._run_global_explorer(explorer, out_path) - - def _run_global_explorers_parallel(self, out_path): - self.log.debug("Running global explorers in {} parallel jobs".format( - self.jobs)) - self.log.trace("Multiprocessing start method is {}".format( - multiprocessing.get_start_method())) - self.log.trace(("Starting multiprocessing Pool for global " - "explorers run")) - args = [ - (e, out_path, ) for e in self.list_global_explorer_names() - ] - mp_pool_run(self._run_global_explorer, args, jobs=self.jobs) - self.log.trace(("Multiprocessing run for global explorers " - "finished")) - - # logger is not pickable, so remove it when we pickle - def __getstate__(self): - state = self.__dict__.copy() - if 'log' in state: - del state['log'] - return state - - # recreate logger when we unpickle - def __setstate__(self, state): - self.__dict__.update(state) - self._open_logger() def transfer_global_explorers(self): """Transfer the global explorers to the remote side.""" - self.remote.transfer(self.local.global_explorer_path, - self.remote.global_explorer_path, - self.jobs) - self.remote.run(["chmod", "0700", - "%s/*" % (self.remote.global_explorer_path)]) + 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)]) 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.""" @@ -179,70 +116,43 @@ class Explorer(object): except EnvironmentError: return [] - def run_type_explorers(self, cdist_object, transfer_type_explorers=True): + def run_type_explorers(self, cdist_object): """Run the type explorers for the given object and save their output in the object. """ - self.log.verbose("Running type explorers for {}".format( - cdist_object.cdist_type)) - if transfer_type_explorers: - self.log.trace("Transferring type explorers for type: %s", - cdist_object.cdist_type) - self.transfer_type_explorers(cdist_object.cdist_type) - else: - self.log.trace(("No need for transferring type explorers for " - "type: %s"), - cdist_object.cdist_type) - self.log.trace("Transferring object parameters for object: %s", - cdist_object.name) + 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.transfer_object_parameters(cdist_object) - cdist_type = cdist_object.cdist_type - for explorer in self.list_type_explorer_names(cdist_type): - self.log.trace("Running type explorer '%s' for object '%s'", - explorer, cdist_object.name) - try: - output = self.run_type_explorer(explorer, cdist_object) - cdist_object.explorers[explorer] = output - except cdist.Error as e: - path = os.path.join(self.local.type_path, - cdist_type.explorer_path, - explorer) - stderr_path = os.path.join(self.local.stderr_base_path, - "remote") - raise cdist.CdistObjectExplorerError( - cdist_object, explorer, path, stderr_path, e) + 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) + 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.trace(("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)]) self._type_explorers_transferred.append(cdist_type.name) @@ -250,8 +160,7 @@ 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 07af0ef8..95bf4c25 100644 --- a/cdist/core/manifest.py +++ b/cdist/core/manifest.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -# 2011-2013 Steven Armstrong (steven-cdist at armstrong.cc) +# 2011 Steven Armstrong (steven-cdist at armstrong.cc) # 2011-2013 Nico Schottelius (nico-cdist at schottelius.org) # # This file is part of cdist. @@ -24,7 +24,6 @@ import logging import os import cdist -from . import util ''' common: @@ -33,17 +32,10 @@ common: env: PATH: prepend directory with type emulator symlinks == local.bin_path __target_host: the target host we are working on - __target_hostname: the target hostname provided from __target_host - __target_fqdn: the target's fully qualified domain name provided from - __target_host - __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 - __target_host_tags: comma spearated list of host tags initial manifest is: script: full qualified path to the initial manifest @@ -65,7 +57,6 @@ type manifeste is: creates: new objects through type emulator ''' - class NoInitialManifestError(cdist.Error): """ Display missing initial manifest: @@ -80,9 +71,7 @@ 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: @@ -96,44 +85,21 @@ class Manifest(object): """Executes cdist manifests. """ - def __init__(self, target_host, local, dry_run=False): + def __init__(self, target_host, local): self.target_host = target_host self.local = local - self._open_logger() + self.log = logging.getLogger(self.target_host) self.env = { 'PATH': "%s:%s" % (self.local.bin_path, os.environ['PATH']), - # for use in type emulator - '__cdist_type_base_path': self.local.type_path, + '__cdist_type_base_path': self.local.type_path, # for use in type emulator '__global': self.local.base_path, - '__target_host': self.target_host[0], - '__target_hostname': self.target_host[1], - '__target_fqdn': self.target_host[2], - '__files': self.local.files_path, - '__target_host_tags': self.local.target_host_tags, - '__cdist_log_level': util.log_level_env_var_val(self.log), - '__cdist_log_level_name': util.log_level_name_env_var_val( - self.log), + '__target_host': self.target_host, } + if self.log.getEffectiveLevel() == logging.DEBUG: + self.env.update({'__cdist_debug': "yes" }) - if dry_run: - self.env['__cdist_dry_run'] = '1' - - def _open_logger(self): - self.log = logging.getLogger(self.target_host[0]) - - # logger is not pickable, so remove it when we pickle - def __getstate__(self): - state = self.__dict__.copy() - if 'log' in state: - del state['log'] - return state - - # recreate logger when we unpickle - def __setstate__(self, state): - self.__dict__.update(state) - self._open_logger() def env_initial_manifest(self, initial_manifest): env = os.environ.copy() @@ -151,31 +117,16 @@ class Manifest(object): else: user_supplied = True + self.log.info("Running initial manifest " + initial_manifest) + if not os.path.isfile(initial_manifest): raise NoInitialManifestError(initial_manifest, user_supplied) - message_prefix = "initialmanifest" - self.log.verbose("Running initial manifest " + initial_manifest) - which = "init" - if self.local.save_output_streams: - stderr_path = os.path.join(self.local.stderr_base_path, which) - stdout_path = os.path.join(self.local.stdout_base_path, which) - with open(stderr_path, 'ba+') as stderr, \ - open(stdout_path, 'ba+') as stdout: - self.local.run_script( - initial_manifest, - env=self.env_initial_manifest(initial_manifest), - message_prefix=message_prefix, - stdout=stdout, stderr=stderr) - else: - 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({ @@ -190,25 +141,7 @@ 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 - which = 'manifest' if os.path.isfile(type_manifest): - self.log.verbose("Running type manifest %s for object %s", - type_manifest, cdist_object.name) - if self.local.save_output_streams: - stderr_path = os.path.join(cdist_object.stderr_path, which) - stdout_path = os.path.join(cdist_object.stdout_path, which) - with open(stderr_path, 'ba+') as stderr, \ - open(stdout_path, 'ba+') as stdout: - self.local.run_script( - type_manifest, - env=self.env_type_manifest(cdist_object), - message_prefix=message_prefix, - stdout=stdout, stderr=stderr) - else: - 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)) diff --git a/cdist/core/util.py b/cdist/core/util.py deleted file mode 100644 index 64570d34..00000000 --- a/cdist/core/util.py +++ /dev/null @@ -1,45 +0,0 @@ -# -*- coding: utf-8 -*- -# -# 2017 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 os -import logging - - -def listdir(path='.', include_dot=False): - """os.listdir but do not include entries whose names begin with a dot('.') - if include_dot is False. - """ - if include_dot: - return os.listdir(path) - else: - return [x for x in os.listdir(path) if not _ishidden(x)] - - -def _ishidden(path): - return path[0] in ('.', b'.'[0]) - - -def log_level_env_var_val(log): - return str(log.getEffectiveLevel()) - - -def log_level_name_env_var_val(log): - return logging.getLevelName(log.getEffectiveLevel()) diff --git a/cdist/emulator.py b/cdist/emulator.py index 3cf82f84..41834fbf 100644 --- a/cdist/emulator.py +++ b/cdist/emulator.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # -# 2011-2015 Nico Schottelius (nico-cdist at schottelius.org) -# 2012-2013 Steven Armstrong (steven-cdist at armstrong.cc) +# 2011-2013 Nico Schottelius (nico-cdist at schottelius.org) +# 2012 Steven Armstrong (steven-cdist at armstrong.cc) # 2014 Daniel Heule (hda at sfs.biz) # # This file is part of cdist. @@ -28,14 +28,11 @@ import sys import cdist from cdist import core -from cdist import flock - 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 @@ -44,7 +41,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 [] @@ -57,24 +54,19 @@ 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.env['__target_hostname'], - self.env['__target_fqdn'] - ) + self.global_path = self.env['__global'] + self.target_host = self.env['__target_host'] - # Internal variables - self.object_source = self.env['__cdist_manifest'] + # Internally only + 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'] except KeyError as e: raise MissingRequiredEnvironmentVariableError(e.args[0]) @@ -82,12 +74,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) - - # If set then object alreay exists and this var holds existing - # requirements. - self._existing_reqs = None + self.type_name = os.path.basename(argv[0]) + self.cdist_type = core.CdistType(self.type_base_path, self.type_name) self.__init_log() @@ -95,66 +83,44 @@ class Emulator(object): """Emulate type commands (i.e. __file and co)""" self.commandline() - self.init_object() - - # locking for parallel execution - with flock.Flock(self.flock_path): - self.setup_object() - self.save_stdin() - self.record_requirements() - self.record_auto_requirements() - self.log.trace("Finished %s %s" % ( - self.cdist_object.path, self.parameters)) + self.setup_object() + self.save_stdin() + self.record_requirements() + self.record_auto_requirements() + self.log.debug("Finished %s %s" % (self.cdist_object.path, self.parameters)) def __init_log(self): """Setup logging facility""" - if '__cdist_log_level' in self.env: - try: - loglevel = self.env['__cdist_log_level'] - level = int(loglevel) - except ValueError: - level = logging.WARNING + if '__cdist_debug' in self.env: + logging.root.setLevel(logging.DEBUG) else: - level = logging.WARNING - try: - logging.root.setLevel(level) - except (ValueError, TypeError): - # if invalid __cdist_log_level value - logging.root.setLevel(logging.WARNING) + logging.root.setLevel(logging.INFO) - self.log = logging.getLogger(self.target_host[0]) + 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 - default = self.cdist_type.parameter_defaults.get(parameter, None) - parser.add_argument(argument, dest=parameter, action='store', - required=False, default=default) + parser.add_argument(argument, dest=parameter, action='store', required=False, + default=self.cdist_type.parameter_defaults.get(parameter, None)) for parameter in self.cdist_type.optional_multiple_parameters: argument = "--" + parameter - default = DefaultList.create( - self.cdist_type.parameter_defaults.get( - parameter, None)) - parser.add_argument(argument, dest=parameter, action='append', - required=False, default=default) + parser.add_argument(argument, dest=parameter, action='append', required=False, + default=DefaultList.create(self.cdist_type.parameter_defaults.get(parameter, None))) 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: @@ -162,74 +128,31 @@ class Emulator(object): # And finally parse/verify parameter self.args = parser.parse_args(self.argv[1:]) - self.log.trace('Args: %s' % self.args) + self.log.debug('Args: %s' % self.args) - def init_object(self): - # Initialize object - and ensure it is not in args - if self.cdist_type.is_singleton: - self.object_id = '' - else: + def setup_object(self): + # Setup object_id - FIXME: unset / do not setup anymore! + if not self.cdist_type.is_singleton: self.object_id = self.args.object_id[0] 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) - lockfname = ('.' + self.cdist_type.name + - self.object_id + '_' + - self.object_marker + '.lock') - lockfname = lockfname.replace(os.sep, '_') - self.flock_path = os.path.join(self.object_base_path, lockfname) + self.cdist_object = core.CdistObject(self.cdist_type, self.object_base_path, self.object_id) - def _object_params_in_context(self): - ''' Get cdist_object parameters dict adopted by context. - Context consists of cdist_type boolean, optional, required, - optional_multiple and required_multiple parameters. If parameter - is multiple parameter then its value is a list. - This adaptation works on cdist_object.parameters which are read from - directory based dict where it is unknown what kind of data is in - file. If there is only one line in the file it is unknown if this - is a value of required/optional parameter or if it is one value of - multiple values parameter. - ''' - params = {} - if self.cdist_object.exists: - for param in self.cdist_object.parameters: - value = ('' if param in self.cdist_type.boolean_parameters - else self.cdist_object.parameters[param]) - if ((param in self.cdist_type.required_multiple_parameters or - param in self.cdist_type.optional_multiple_parameters) and - not isinstance(value, list)): - value = [value] - params[param] = value - return params - - def setup_object(self): # 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 'CDIST_OVERRIDE' not in self.env: - # Make existing requirements a set so that we can compare it - # later with new requirements. - self._existing_reqs = set(self.cdist_object.requirements) - obj_params = self._object_params_in_context() - if obj_params != 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), - obj_params, - self.object_source, - self.parameters)) - raise cdist.Error(errmsg) + if self.cdist_object.exists and not 'CDIST_OVERRIDE' in self.env: + if self.cdist_object.parameters != self.parameters: + raise cdist.Error("Object %s already exists with conflicting parameters:\n%s: %s\n%s: %s" + % (self.cdist_object.name, " ".join(self.cdist_object.source), self.cdist_object.parameters, self.object_source, self.parameters) + ) else: 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() @@ -242,7 +165,6 @@ 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) @@ -264,118 +186,63 @@ 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.InvalidTypeError 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: - 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 for %s", - requirement, self.cdist_object.name) - - # 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.""" + """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 - 'CDIST_OVERRIDE' not in self.env): - # load object name created befor this one from typeorder file ... + # 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: + # load object name created bevor this one from typeorder file ... with open(self.typeorder_path, 'r') as typecreationfile: typecreationorder = typecreationfile.readlines() - # get the type created before this one ... + # get the type created bevore this one ... try: lastcreatedtype = typecreationorder[-2].strip() - # __object_name is the name of the object whose type - # manifest is currently executed - __object_name = self.env.get('__object_name', None) - if lastcreatedtype == __object_name: - self.log.debug(("Not injecting require for " - "CDIST_ORDER_DEPENDENCY: %s for %s," - " %s's type manifest is currently" - " being executed"), - lastcreatedtype, - self.cdist_object.name, - lastcreatedtype) + if 'require' in self.env: + self.env['require'] += " " + lastcreatedtype else: - if 'require' in self.env: - appendix = " " + lastcreatedtype - if appendix not in self.env['require']: - self.env['require'] += appendix - else: - self.env['require'] = lastcreatedtype - self.log.debug(("Injecting require for " - "CDIST_ORDER_DEPENDENCY: %s for %s"), - lastcreatedtype, - self.cdist_object.name) + self.env['require'] = lastcreatedtype + 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 - reqs = set() + 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 - object_name = self.record_requirement(requirement) - reqs.add(object_name) - if self._existing_reqs is not None: - # If object exists then compare existing and new requirements. - if self._existing_reqs != reqs: - warnmsg = ("Object {} already exists with requirements:\n" - "{}: {}\n" - "{}: {}\n" - "Dependency resolver could not handle dependencies " - "as expected.".format( - self.cdist_object.name, - " ".join(self.cdist_object.source), - self._existing_reqs, - self.object_source, - reqs - )) - self.log.warning(warnmsg) + 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) 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 parent.name not in current_object.requirements: - self.log.debug("Recording autorequirement %s for %s", - current_object.name, parent.name) + if not parent.name in current_object.requirements: parent.autorequire.append(current_object.name) diff --git a/cdist/exec/local.py b/cdist/exec/local.py index f83c85df..2f75ffd4 100644 --- a/cdist/exec/local.py +++ b/cdist/exec/local.py @@ -1,8 +1,7 @@ # -*- coding: utf-8 -*- # -# 2011-2017 Steven Armstrong (steven-cdist at armstrong.cc) -# 2011-2015 Nico Schottelius (nico-cdist at schottelius.org) -# 2016-2017 Darko Poljak (darko.poljak at gmail.com) +# 2011 Steven Armstrong (steven-cdist at armstrong.cc) +# 2011-2013 Nico Schottelius (nico-cdist at schottelius.org) # # This file is part of cdist. # @@ -21,6 +20,7 @@ # # +import io import os import sys import re @@ -28,16 +28,10 @@ import subprocess import shutil import logging import tempfile -import time -import datetime import cdist import cdist.message from cdist import core -import cdist.exec.util as util - -CONF_SUBDIRS_LINKED = ["explorer", "files", "manifest", "type", ] - class Local(object): """Execute commands locally. @@ -48,67 +42,46 @@ class Local(object): """ def __init__(self, target_host, - target_host_tags, - base_root_path, - host_dir_name, exec_path=sys.argv[0], initial_manifest=None, - add_conf_dirs=None, - cache_path_pattern=None, - quiet_mode=False, - configuration=None, - save_output_streams=True): + base_path=None, + add_conf_dirs=None): self.target_host = target_host - if target_host_tags is None: - self.target_host_tags = "" + + # FIXME: stopped: create base that does not require moving later + if base_path: + self.base_path = base_path else: - self.target_host_tags = ",".join(target_host_tags) - self.hostdir = host_dir_name - self.base_path = os.path.join(base_root_path, "data") + self.base_path = tempfile.mkdtemp() + + # FIXME: as well + self._init_cache_dir(None) self.exec_path = exec_path self.custom_initial_manifest = initial_manifest + self._add_conf_dirs = add_conf_dirs - self.cache_path_pattern = cache_path_pattern - self.quiet_mode = quiet_mode - if configuration: - self.configuration = configuration - else: - self.configuration = {} - self.save_output_streams = save_output_streams self._init_log() self._init_permissions() - self.mkdir(self.base_path) - self._init_cache_dir(None) self._init_paths() - self._init_object_marker() self._init_conf_dirs() + @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): - return cdist.home_dir() + if 'HOME' in os.environ: + return os.path.join(os.environ['HOME'], ".cdist") + else: + return None def _init_log(self): - self.log = logging.getLogger(self.target_host[0]) - - # logger is not pickable, so remove it when we pickle - def __getstate__(self): - state = self.__dict__.copy() - if 'log' in state: - del state['log'] - return state - - # recreate logger when we unpickle - def __setstate__(self, state): - self.__dict__.update(state) - self._init_log() + self.log = logging.getLogger(self.target_host) def _init_permissions(self): # Setup file permissions using umask @@ -118,28 +91,18 @@ 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.stdout_base_path = os.path.join(self.base_path, "stdout") - self.stderr_base_path = os.path.join(self.base_path, "stderr") # Depending on conf_path - self.files_path = os.path.join(self.conf_path, "files") 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") - def _init_object_marker(self): - self.object_marker_file = os.path.join(self.base_path, "object_marker") - - # Does not need to be secure - just randomly different from .cdist - self.object_marker_name = tempfile.mktemp(prefix='.cdist-', dir='') - def _init_conf_dirs(self): self.conf_dirs = [] @@ -150,14 +113,10 @@ class Local(object): self.conf_dirs.append(self.home_dir) # Add directories defined in the CDIST_PATH environment variable - # if 'CDIST_PATH' in os.environ: - # cdist_path_dirs = re.split(r'(? %s", source, destination) - # self.rmdir(destination) + self.log.debug("Remote transfer: %s -> %s", source, destination) + self.rmdir(destination) if os.path.isdir(source): self.mkdir(destination) - used_archiving = False - if self.archiving_mode: - self.log.trace("Remote transfer in archiving mode") - import cdist.autil as autil - - # create archive - tarpath, fcnt = autil.tar(source, self.archiving_mode) - if tarpath is None: - self.log.trace(("Files count {} is lower than {} limit, " - "skipping archiving").format( - fcnt, autil.FILES_LIMIT)) - else: - self.log.trace(("Archiving mode, tarpath: %s, file count: " - "%s"), tarpath, fcnt) - # get archive name - tarname = os.path.basename(tarpath) - self.log.trace("Archiving mode tarname: %s", tarname) - # archive path at the remote - desttarpath = os.path.join(destination, tarname) - self.log.trace( - "Archiving mode desttarpath: %s", desttarpath) - # transfer archive to the remote side - self.log.trace("Archiving mode: transferring") - self._transfer_file(tarpath, desttarpath) - # extract archive at the remote - self.log.trace("Archiving mode: extracting") - self.extract_archive(desttarpath, self.archiving_mode) - # remove remote archive - self.log.trace("Archiving mode: removing remote archive") - self.rmfile(desttarpath) - # remove local archive - self.log.trace("Archiving mode: removing local archive") - os.remove(tarpath) - used_archiving = True - if not used_archiving: - self._transfer_dir(source, destination) - elif jobs: - raise cdist.Error("Source {} is not a directory".format(source)) + 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)]) + self._run_command(command) else: - self._transfer_file(source, destination) + command = self._copy.split() + command.extend([source, '{0}:{1}'.format(self.target_host, destination)]) + self._run_command(command) - def _transfer_dir(self, source, destination): - command = self._copy.split() - for f in glob.glob1(source, '*'): - path = os.path.join(source, f) - command.extend([path]) - command.extend(['{0}:{1}'.format( - _wrap_addr(self.target_host[0]), destination)]) - self._run_command(command) - - def run_script(self, script, env=None, return_output=False, stdout=None, - stderr=None): + def run_script(self, script, env=None, return_output=False): """Run the given script with the given environment on the remote side. Return the output as a string. """ - command = [ - self.configuration.get('remote_shell', "/bin/sh"), - "-e" - ] + command = [ os.environ.get('CDIST_REMOTE_SHELL',"/bin/sh") , "-e"] command.append(script) - return self.run(command, env=env, return_output=return_output, - stdout=stdout, stderr=stderr) + return self.run(command, env, return_output) - def run(self, command, env=None, return_output=False, stdout=None, - stderr=None): + def run(self, command, env=None, return_output=False): """Run the given command with the given environment on the remote side. Return the output as a string. """ # prefix given command with remote_exec cmd = self._exec.split() - cmd.append(self.target_host[0]) + cmd.append(self.target_host) + # FIXME: replace this by -o SendEnv name -o SendEnv name ... to ssh? # can't pass environment to remote side, so prepend command with # variable declarations - - # cdist command prepended with variable assignments expects - # POSIX shell (bourne, bash) at the remote as user default shell. - # If remote user shell isn't POSIX shell, but for e.g. csh/tcsh - # then these var assignments are not var assignments for this - # remote shell, it tries to execute it as a command and fails. - # So really do this by default: - # /bin/sh -c 'export ; command' - # so that constructed remote command isn't dependent on remote - # shell. Do this only if env is not None. env breaks this. - # Explicitly use /bin/sh, because var assignments assume POSIX - # shell already. - # This leaves the posibility to write script that needs to be run - # remotely in e.g. csh and setting up CDIST_REMOTE_SHELL to e.g. - # /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) + "'") - cmd.append(string_cmd) - else: - cmd.extend(command) - return self._run_command(cmd, env=env, return_output=return_output, - stdout=stdout, stderr=stderr) + remote_env = ["%s=%s" % item for item in env.items()] + cmd.extend(remote_env) - def _run_command(self, command, env=None, return_output=False, stdout=None, - stderr=None): + cmd.extend(command) + + return self._run_command(cmd, env=env, return_output=return_output) + + def _run_command(self, command, env=None, return_output=False): """Run the given command with the given environment. 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 - if return_output and stdout is not subprocess.PIPE: - self.log.debug("return_output is True, ignoring stdout") - - close_stdout = False - close_stderr = False - if self.save_output_streams: - if not return_output and stdout is None: - stdout = util.get_std_fd(self.stdout_base_path, 'remote') - close_stdout = True - if stderr is None: - stderr = util.get_std_fd(self.stderr_base_path, 'remote') - close_stderr = True - - # export target_host, target_hostname, target_fqdn - # for use in __remote_{exec,copy} scripts + # export target_host for use in __remote_{exec,copy} scripts os_environ = os.environ.copy() - os_environ['__target_host'] = self.target_host[0] - os_environ['__target_hostname'] = self.target_host[1] - os_environ['__target_fqdn'] = self.target_host[2] + os_environ['__target_host'] = self.target_host - self.log.trace("Remote run: %s", command) + self.log.debug("Remote run: %s", command) try: - if self.quiet_mode: - stderr = subprocess.DEVNULL - close_stderr = False if return_output: - output = subprocess.check_output(command, env=os_environ, - stderr=stderr).decode() + return subprocess.check_output(command, env=os_environ).decode() else: - subprocess.check_call(command, env=os_environ, stdout=stdout, - stderr=stderr) - output = None - - if self.save_output_streams: - util.log_std_fd(self.log, command, stderr, 'Remote stderr') - util.log_std_fd(self.log, command, stdout, 'Remote stdout') - - return output - except (OSError, subprocess.CalledProcessError) as error: - raise cdist.Error(" ".join(command) + ": " + str(error.args[1])) + subprocess.check_call(command, env=os_environ) + except subprocess.CalledProcessError: + raise cdist.Error("Command failed: " + " ".join(command)) + except OSError as error: + raise cdist.Error(" ".join(command) + ": " + error.args[1]) except UnicodeDecodeError: raise DecodeError(command) - finally: - if close_stdout: - stdout.close() - if close_stderr: - stderr.close() diff --git a/cdist/exec/util.py b/cdist/exec/util.py deleted file mode 100644 index c96f757b..00000000 --- a/cdist/exec/util.py +++ /dev/null @@ -1,177 +0,0 @@ -# -*- coding: utf-8 -*- -# -# 2016-2017 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 os -from tempfile import TemporaryFile - -import cdist - - -# IMPORTANT: -# with the code below in python 3.5 when command is executed and error -# occurs then stderr is not captured. -# As it seems from documentation, it is only captured when using -# subprocess.run method with stderr=subprocess.PIPE and is captured -# into CompletedProcess resulting object or into CalledProcessError -# in case of error (only if specified capturing). -# -# If using PIPE then the run is slow. run method uses communicate method -# and internally it uses buffering. -# -# For now we will use capturing only stdout. stderr is written directly to -# stderr from child process. -# -# 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 - -# -# The code below with bufsize=0 does not work either, communicate -# internally uses buffering. It works in case of error, but if everything -# is ok and there is no output in stderr then execution is very very slow. -# -# 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)) -# -# result = subprocess.run(command, env=env, bufsize=0, -# stdout=subprocess.PIPE, stderr=subprocess.PIPE, check=True) -# -# return (result.stdout, result.stderr) - - -# Currently not used. -def call_get_output(command, env=None, stderr=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)) - return (_call_get_stdout(command, env, stderr), None) - - -# Currently not used. -def handle_called_process_error(err, command): - # Currently, stderr is not captured. - # errout = None - # raise cdist.Error("Command failed: " + " ".join(command) + - # (" with returncode: {}\n" - # "stdout: {}\n" - # "stderr: {}").format( - # err.returncode, err.output, errout)) - if err.output: - output = err.output - else: - output = '' - raise cdist.Error(("Command failed: '{}'\n" - "return code: {}\n" - "---- BEGIN stdout ----\n" - "{}" + ("\n" if output else "") + - "---- END stdout ----").format( - " ".join(command), err.returncode, output)) - - -# Currently not used. -def _call_get_stdout(command, env=None, stderr=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, stderr=stderr) - fout.seek(0) - output = fout.read() - - return output - - -def get_std_fd(base_path, name): - path = os.path.join(base_path, name) - stdfd = open(path, 'ba+') - return stdfd - - -def log_std_fd(log, command, stdfd, prefix): - if stdfd is not None and stdfd != subprocess.DEVNULL: - stdfd.seek(0, 0) - log.trace("Command: {}; {}: {}".format( - command, prefix, stdfd.read().decode())) diff --git a/cdist/flock.py b/cdist/flock.py deleted file mode 100644 index d8bac916..00000000 --- a/cdist/flock.py +++ /dev/null @@ -1,58 +0,0 @@ -# -*- coding: utf-8 -*- -# -# 2017 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 fcntl -import logging -import os - - -log = logging.getLogger('cdist-flock') - - -class Flock(): - def __init__(self, path): - self.path = path - self.lockfd = None - - def flock(self): - log.debug('Acquiring lock on %s', self.path) - self.lockfd = open(self.path, 'w+') - fcntl.flock(self.lockfd, fcntl.LOCK_EX) - log.debug('Acquired lock on %s', self.path) - - def funlock(self): - log.debug('Releasing lock on %s', self.path) - fcntl.flock(self.lockfd, fcntl.LOCK_UN) - self.lockfd.close() - self.lockfd = None - try: - os.remove(self.path) - except FileNotFoundError: - pass - log.debug('Released lock on %s', self.path) - - def __enter__(self): - self.flock() - return self - - def __exit__(self, *args): - self.funlock() - return False diff --git a/cdist/hostsource.py b/cdist/hostsource.py deleted file mode 100644 index a7b8f0b4..00000000 --- a/cdist/hostsource.py +++ /dev/null @@ -1,76 +0,0 @@ -# -*- coding: utf-8 -*- -# -# 2016-2017 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 fileinput - - -def hostfile_process_line(line, strip_func=str.strip): - """Return entry from read line or None if no entry present.""" - if not line: - return None - # remove comment if present - comment_index = line.find('#') - if comment_index >= 0: - foo = line[:comment_index] - else: - foo = line - # remove leading and trailing whitespaces - foo = strip_func(foo) - # skip empty lines - if foo: - return foo - else: - return None - - -class HostSource(object): - """ - Host source object. - Source can be a sequence or filename (stdin if \'-\'). - In case of filename each line represents one host. - """ - def __init__(self, source): - self.source = source - - def _process_file_line(self, line): - return hostfile_process_line(line) - - def _hosts_from_sequence(self): - for host in self.source: - yield host - - def _hosts_from_file(self): - for line in fileinput.input(files=(self.source)): - host = self._process_file_line(line) - if host: - yield host - - def hosts(self): - if not self.source: - return - - if isinstance(self.source, str): - yield from self._hosts_from_file() - else: - yield from self._hosts_from_sequence() - - def __call__(self): - yield from self.hosts() diff --git a/cdist/install.py b/cdist/install.py deleted file mode 100644 index b88ad016..00000000 --- a/cdist/install.py +++ /dev/null @@ -1,39 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- -# -# 2013 Steven Armstrong (steven-cdist at armstrong.cc) -# -# This file is part of cdist. -# -# cdist is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# cdist is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with cdist. If not, see . -# -# - -import cdist.config -import cdist.core - - -class Install(cdist.config.Config): - def object_list(self): - """Short name for object list retrieval. - In install mode, we only care about install objects. - """ - for cdist_object in cdist.core.CdistObject.list_objects( - self.local.object_path, self.local.type_path, - self.local.object_marker_name): - if cdist_object.cdist_type.is_install: - yield cdist_object - else: - self.log.debug("Running in install mode, ignoring non install" - "object: {0}".format(cdist_object)) diff --git a/cdist/integration.py b/cdist/integration.py deleted file mode 100644 index ee742cc5..00000000 --- a/cdist/integration.py +++ /dev/null @@ -1,155 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- -# -# 2017 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 cdist -# needed for cdist.argparse -import cdist.banner -import cdist.config -import cdist.install -import cdist.shell -import cdist.inventory -import cdist.argparse -import cdist.log -import cdist.config -import cdist.install -import sys -import os -import os.path -import collections -import uuid -import shutil - - -def find_cdist_exec_in_path(): - """Search cdist executable in os.get_exec_path() entries. - """ - for path in os.get_exec_path(): - cdist_path = os.path.join(path, 'cdist') - if os.access(cdist_path, os.X_OK): - return cdist_path - return None - - -_mydir = os.path.dirname(__file__) - - -def find_cdist_exec(): - """Search cdist executable starting from local lib directory. - - Detect if ../scripts/cdist (from local lib direcotry) exists and - if it is executable. If not then try to find cdist exec path in - os.get_exec_path() entries. If no cdist path is found rasie - cdist.Error. - """ - cdist_path = os.path.abspath(os.path.join(_mydir, '..', 'scripts', - 'cdist')) - if os.access(cdist_path, os.X_OK): - return cdist_path - cdist_path = find_cdist_exec_in_path() - if not cdist_path: - raise cdist.Error('Cannot find cdist executable from local lib ' - 'directory: {}, nor in PATH: {}.'.format( - _mydir, os.environ.get('PATH'))) - return cdist_path - - -ACTION_CONFIG = 'config' -ACTION_INSTALL = 'install' - - -def _process_hosts_simple(action, host, manifest, verbose, - cdist_path=None): - """Perform cdist action ('config' or 'install') on hosts with specified - manifest using default other cdist options. host parameter can be a - string or iterbale of hosts. verbose is a desired verbosity level - which defaults to VERBOSE_INFO. cdist_path is path to cdist executable, - if it is None then integration lib tries to find it. - """ - if isinstance(host, str): - hosts = [host, ] - elif isinstance(host, collections.Iterable): - hosts = host - else: - raise cdist.Error('Invalid host argument: {}'.format(host)) - - # Setup sys.argv[0] since cdist relies on command line invocation. - if not cdist_path: - cdist_path = find_cdist_exec() - sys.argv[0] = cdist_path - - cname = action.title() - module = getattr(cdist, action) - theclass = getattr(module, cname) - - # Build argv for cdist and use argparse for argument parsing. - remote_out_dir_base = os.path.join('/', 'var', 'lib', 'cdist') - uid = str(uuid.uuid1()) - out_dir = remote_out_dir_base + uid - cache_path_pattern = '%h-' + uid - argv = [action, '-i', manifest, '-r', out_dir, '-C', cache_path_pattern, ] - for i in range(verbose): - argv.append('-v') - for x in hosts: - argv.append(x) - - parser, cfg = cdist.argparse.parse_and_configure(argv, singleton=False) - args = cfg.get_args() - configuration = cfg.get_config(section='GLOBAL') - - theclass.construct_remote_exec_copy_patterns(args) - base_root_path = theclass.create_base_root_path(None) - - for target_host in args.host: - host_base_path, hostdir = theclass.create_host_base_dirs( - target_host, base_root_path) - theclass.onehost(target_host, None, host_base_path, hostdir, args, - parallel=False, configuration=configuration, - remove_remote_files_dirs=True) - shutil.rmtree(base_root_path) - - -def configure_hosts_simple(host, manifest, - verbose=cdist.argparse.VERBOSE_INFO, - cdist_path=None): - """Configure hosts with specified manifest using default other cdist - options. host parameter can be a string or iterbale of hosts. verbose - is a desired verbosity level which defaults to VERBOSE_INFO. - cdist_path is path to cdist executable, if it is None then integration - lib tries to find it. - """ - _process_hosts_simple(action=ACTION_CONFIG, host=host, - manifest=manifest, verbose=verbose, - cdist_path=cdist_path) - - -def install_hosts_simple(host, manifest, - verbose=cdist.argparse.VERBOSE_INFO, - cdist_path=None): - """Install hosts with specified manifest using default other cdist - options. host parameter can be a string or iterbale of hosts. verbose - is a desired verbosity level which defaults to VERBOSE_INFO. - cdist_path is path to cdist executable, if it is None then integration - lib tries to find it. - """ - _process_hosts_simple(action=ACTION_INSTALL, host=host, - manifest=manifest, verbose=verbose, - cdist_path=cdist_path) diff --git a/cdist/inventory.py b/cdist/inventory.py deleted file mode 100644 index 138a2034..00000000 --- a/cdist/inventory.py +++ /dev/null @@ -1,405 +0,0 @@ -#!/usr/bin/env python3 -# -*- 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 cdist -import logging -import os -import os.path -import itertools -import sys -import cdist.configuration -from cdist.hostsource import hostfile_process_line - -DIST_INVENTORY_DB_NAME = "inventory" - -dist_inventory_db = os.path.abspath(os.path.join( - os.path.dirname(cdist.__file__), DIST_INVENTORY_DB_NAME)) - - -def determine_default_inventory_dir(args, configuration): - # The order of inventory dir setting by decreasing priority - # 1. inventory_dir from configuration - # 2. ~/.cdist/inventory if HOME env var is set - # 3. distribution inventory directory - inventory_dir_set = False - if 'inventory_dir' in configuration: - val = configuration['inventory_dir'] - if val: - args.inventory_dir = val - inventory_dir_set = True - if not inventory_dir_set: - home = cdist.home_dir() - if home: - args.inventory_dir = os.path.join(home, DIST_INVENTORY_DB_NAME) - else: - args.inventory_dir = dist_inventory_db - - -def contains_all(big, little): - """Return True if big contains all elements from little, - False otherwise. - """ - return set(little).issubset(set(big)) - - -def contains_any(big, little): - """Return True if big contains any element from little, - False otherwise. - """ - for x in little: - if x in big: - return True - return False - - -def check_always_true(x, y): - return True - - -def rstrip_nl(s): - '''str.rstrip "\n" from s''' - return str.rstrip(s, "\n") - - -class Inventory(object): - """Inventory main class""" - - def __init__(self, db_basedir=dist_inventory_db, configuration=None): - self.db_basedir = db_basedir - if configuration: - self.configuration = configuration - else: - self.configuration = {} - self.log = logging.getLogger("inventory") - self.init_db() - - def init_db(self): - self.log.trace("Init db: {}".format(self.db_basedir)) - if not os.path.exists(self.db_basedir): - os.makedirs(self.db_basedir, exist_ok=True) - elif not os.path.isdir(self.db_basedir): - raise cdist.Error(("Invalid inventory db basedir \'{}\'," - " must be a directory").format(self.db_basedir)) - - @staticmethod - def strlist_to_list(slist): - if slist: - result = [x for x in slist.split(',') if x] - else: - result = [] - return result - - def _input_values(self, source): - """Yield input values from source. - Source can be a sequence or filename (stdin if '-'). - In case of filename each line represents one input value. - """ - if isinstance(source, str): - import fileinput - try: - with fileinput.FileInput(files=(source)) as f: - for x in f: - result = hostfile_process_line(x, strip_func=rstrip_nl) - if result: - yield result - except (IOError, OSError) as e: - raise cdist.Error("Error reading from \'{}\'".format( - source)) - else: - if source: - for x in source: - if x: - yield x - - def _host_path(self, host): - hostpath = os.path.join(self.db_basedir, host) - return hostpath - - def _all_hosts(self): - return os.listdir(self.db_basedir) - - def _check_host(self, hostpath): - if not os.path.exists(hostpath): - return False - else: - if not os.path.isfile(hostpath): - raise cdist.Error(("Host path \'{}\' exists, but is not" - " a valid file").format(hostpath)) - return True - - def _read_host_tags(self, hostpath): - result = set() - with open(hostpath, "rt") as f: - for tag in f: - tag = tag.rstrip("\n") - if tag: - result.add(tag) - return result - - def _get_host_tags(self, host): - hostpath = self._host_path(host) - if self._check_host(hostpath): - return self._read_host_tags(hostpath) - else: - return None - - def _write_host_tags(self, host, tags): - hostpath = self._host_path(host) - if self._check_host(hostpath): - with open(hostpath, "wt") as f: - for tag in tags: - f.write("{}\n".format(tag)) - return True - else: - return False - - @classmethod - def commandline(cls, args): - """Manipulate inventory db""" - log = logging.getLogger("inventory") - if 'taglist' in args: - args.taglist = cls.strlist_to_list(args.taglist) - - cfg = cdist.configuration.Configuration(args) - configuration = cfg.get_config(section='GLOBAL') - determine_default_inventory_dir(args, configuration) - - log.debug("Using inventory: {}".format(args.inventory_dir)) - log.trace("Inventory args: {}".format(vars(args))) - log.trace("Inventory command: {}".format(args.subcommand)) - - if args.subcommand == "list": - c = InventoryList(hosts=args.host, istag=args.tag, - hostfile=args.hostfile, - db_basedir=args.inventory_dir, - list_only_host=args.list_only_host, - has_all_tags=args.has_all_tags, - configuration=configuration) - elif args.subcommand == "add-host": - c = InventoryHost(hosts=args.host, hostfile=args.hostfile, - db_basedir=args.inventory_dir, - configuration=configuration) - elif args.subcommand == "del-host": - c = InventoryHost(hosts=args.host, hostfile=args.hostfile, - all=args.all, db_basedir=args.inventory_dir, - action="del", configuration=configuration) - elif args.subcommand == "add-tag": - c = InventoryTag(hosts=args.host, tags=args.taglist, - hostfile=args.hostfile, tagfile=args.tagfile, - db_basedir=args.inventory_dir, - configuration=configuration) - elif args.subcommand == "del-tag": - c = InventoryTag(hosts=args.host, tags=args.taglist, - hostfile=args.hostfile, tagfile=args.tagfile, - all=args.all, db_basedir=args.inventory_dir, - action="del", configuration=configuration) - else: - raise cdist.Error("Unknown inventory command \'{}\'".format( - args.subcommand)) - c.run() - - -class InventoryList(Inventory): - def __init__(self, hosts=None, istag=False, hostfile=None, - list_only_host=False, has_all_tags=False, - db_basedir=dist_inventory_db, configuration=None): - super().__init__(db_basedir, configuration) - self.hosts = hosts - self.istag = istag - self.hostfile = hostfile - self.list_only_host = list_only_host - self.has_all_tags = has_all_tags - - def _print(self, host, tags): - if self.list_only_host: - print("{}".format(host)) - else: - print("{} {}".format(host, ",".join(sorted(tags)))) - - def _do_list(self, it_tags, it_hosts, check_func): - if (it_tags is not None): - param_tags = set(it_tags) - self.log.trace("param_tags: {}".format(param_tags)) - else: - param_tags = set() - for host in it_hosts: - self.log.trace("host: {}".format(host)) - tags = self._get_host_tags(host) - if tags is None: - self.log.debug("Host \'{}\' not found, skipped".format(host)) - continue - self.log.trace("tags: {}".format(tags)) - if check_func(tags, param_tags): - yield host, tags - - def entries(self): - if not self.hosts and not self.hostfile: - self.log.trace("Listing all hosts") - it_hosts = self._all_hosts() - it_tags = None - check_func = check_always_true - else: - it = itertools.chain(self._input_values(self.hosts), - self._input_values(self.hostfile)) - if self.istag: - self.log.trace("Listing by tag(s)") - it_hosts = self._all_hosts() - it_tags = it - if self.has_all_tags: - check_func = contains_all - else: - check_func = contains_any - else: - self.log.trace("Listing by host(s)") - it_hosts = it - it_tags = None - check_func = check_always_true - for host, tags in self._do_list(it_tags, it_hosts, check_func): - yield host, tags - - def host_entries(self): - for host, tags in self.entries(): - yield host - - def run(self): - for host, tags in self.entries(): - self._print(host, tags) - - -class InventoryHost(Inventory): - def __init__(self, hosts=None, hostfile=None, - db_basedir=dist_inventory_db, all=False, action="add", - configuration=None): - super().__init__(db_basedir, configuration) - self.actions = ("add", "del") - if action not in self.actions: - raise cdist.Error("Invalid action \'{}\', valid actions are:" - " {}\n".format(action, self.actions.keys())) - self.action = action - self.hosts = hosts - self.hostfile = hostfile - self.all = all - - if not self.hosts and not self.hostfile: - self.hostfile = "-" - - def _new_hostpath(self, hostpath): - # create empty file - with open(hostpath, "w"): - pass - - def _action(self, host): - if self.action == "add": - self.log.debug("Adding host \'{}\'".format(host)) - elif self.action == "del": - self.log.debug("Deleting host \'{}\'".format(host)) - hostpath = self._host_path(host) - self.log.trace("hostpath: {}".format(hostpath)) - if self.action == "add" and not os.path.exists(hostpath): - self._new_hostpath(hostpath) - else: - if not os.path.isfile(hostpath): - raise cdist.Error(("Host path \'{}\' is" - " not a valid file").format(hostpath)) - if self.action == "del": - os.remove(hostpath) - - def run(self): - if self.action == "del" and self.all: - self.log.trace("Doing for all hosts") - it = self._all_hosts() - else: - self.log.trace("Doing for specified hosts") - it = itertools.chain(self._input_values(self.hosts), - self._input_values(self.hostfile)) - for host in it: - self._action(host) - - -class InventoryTag(Inventory): - def __init__(self, hosts=None, tags=None, hostfile=None, tagfile=None, - db_basedir=dist_inventory_db, all=False, action="add", - configuration=None): - super().__init__(db_basedir, configuration) - self.actions = ("add", "del") - if action not in self.actions: - raise cdist.Error("Invalid action \'{}\', valid actions are:" - " {}\n".format(action, self.actions.keys())) - self.action = action - self.hosts = hosts - self.tags = tags - self.hostfile = hostfile - self.tagfile = tagfile - self.all = all - - if not self.hosts and not self.hostfile: - self.allhosts = True - else: - self.allhosts = False - if not self.tags and not self.tagfile: - self.tagfile = "-" - - if self.hostfile == "-" and self.tagfile == "-": - raise cdist.Error("Cannot read both, hosts and tags, from stdin") - - def _read_input_tags(self): - self.input_tags = set() - for tag in itertools.chain(self._input_values(self.tags), - self._input_values(self.tagfile)): - self.input_tags.add(tag) - - def _action(self, host): - host_tags = self._get_host_tags(host) - if host_tags is None: - print("Host \'{}\' does not exist, skipping".format(host), - file=sys.stderr) - return - self.log.trace("existing host_tags: {}".format(host_tags)) - if self.action == "del" and self.all: - host_tags = set() - else: - for tag in self.input_tags: - if self.action == "add": - self.log.debug("Adding tag \'{}\' for host \'{}\'".format( - tag, host)) - host_tags.add(tag) - elif self.action == "del": - self.log.debug("Deleting tag \'{}\' for host " - "\'{}\'".format(tag, host)) - if tag in host_tags: - host_tags.remove(tag) - self.log.trace("new host tags: {}".format(host_tags)) - if not self._write_host_tags(host, host_tags): - self.log.trace("{} does not exist, skipped".format(host)) - - def run(self): - if self.allhosts: - self.log.trace("Doing for all hosts") - it = self._all_hosts() - else: - self.log.trace("Doing for specified hosts") - it = itertools.chain(self._input_values(self.hosts), - self._input_values(self.hostfile)) - if not(self.action == "del" and self.all): - self._read_input_tags() - for host in it: - self._action(host) diff --git a/cdist/log.py b/cdist/log.py index 5d431130..8c3aac79 100644 --- a/cdist/log.py +++ b/cdist/log.py @@ -21,120 +21,18 @@ # import logging -import sys -import datetime - -# Define additional cdist logging levels. -logging.OFF = logging.CRITICAL + 10 # disable logging -logging.addLevelName(logging.OFF, 'OFF') - -logging.VERBOSE = logging.INFO - 5 -logging.addLevelName(logging.VERBOSE, 'VERBOSE') - - -def _verbose(msg, *args, **kwargs): - logging.log(logging.VERBOSE, msg, *args, **kwargs) - - -logging.verbose = _verbose - -logging.TRACE = logging.DEBUG - 5 -logging.addLevelName(logging.TRACE, 'TRACE') - - -def _trace(msg, *args, **kwargs): - logging.log(logging.TRACE, msg, *args, **kwargs) - - -logging.trace = _trace - - -class DefaultLog(logging.Logger): - - FORMAT = '%(levelname)s: %(message)s' - - class StdoutFilter(logging.Filter): - def filter(self, rec): - return rec.levelno != logging.ERROR - - class StderrFilter(logging.Filter): - def filter(self, rec): - return rec.levelno == logging.ERROR +class Log(logging.Logger): def __init__(self, name): + + self.name = name super().__init__(name) - - formatter = logging.Formatter(self.FORMAT) - self.addFilter(self) - stdout_handler = logging.StreamHandler(sys.stdout) - stdout_handler.addFilter(self.StdoutFilter()) - stdout_handler.setLevel(logging.TRACE) - stdout_handler.setFormatter(formatter) - - stderr_handler = logging.StreamHandler(sys.stderr) - stderr_handler.addFilter(self.StderrFilter()) - stderr_handler.setLevel(logging.ERROR) - stderr_handler.setFormatter(formatter) - - self.addHandler(stdout_handler) - self.addHandler(stderr_handler) - def filter(self, record): """Prefix messages with logger name""" record.msg = self.name + ": " + str(record.msg) return True - - def verbose(self, msg, *args, **kwargs): - self.log(logging.VERBOSE, msg, *args, **kwargs) - - def trace(self, msg, *args, **kwargs): - self.log(logging.TRACE, msg, *args, **kwargs) - - -class TimestampingLog(DefaultLog): - - def filter(self, record): - """Add timestamp to messages""" - - super().filter(record) - now = datetime.datetime.now() - timestamp = now.strftime("%Y%m%d%H%M%S.%f") - record.msg = "[" + timestamp + "] " + str(record.msg) - - return True - - -class ParallelLog(DefaultLog): - FORMAT = '%(levelname)s: [%(process)d]: %(message)s' - - -class TimestampingParallelLog(TimestampingLog, ParallelLog): - pass - - -def setupDefaultLogging(): - del logging.getLogger().handlers[:] - logging.setLoggerClass(DefaultLog) - - -def setupTimestampingLogging(): - del logging.getLogger().handlers[:] - logging.setLoggerClass(TimestampingLog) - - -def setupTimestampingParallelLogging(): - del logging.getLogger().handlers[:] - logging.setLoggerClass(TimestampingParallelLog) - - -def setupParallelLogging(): - del logging.getLogger().handlers[:] - logging.setLoggerClass(ParallelLog) - - -setupDefaultLogging() diff --git a/cdist/message.py b/cdist/message.py index 450fc3c3..b840a84d 100644 --- a/cdist/message.py +++ b/cdist/message.py @@ -24,6 +24,8 @@ import os import shutil import tempfile +import cdist + log = logging.getLogger(__name__) @@ -35,19 +37,16 @@ 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') - - os.close(in_fd) - os.close(out_fd) + self.messages_in = tempfile.mkstemp(suffix='.cdist_message_in')[1] + self.messages_out = tempfile.mkstemp(suffix='.cdist_message_out')[1] self._copy_messages() + @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/mputil.py b/cdist/mputil.py deleted file mode 100644 index 56fcfe39..00000000 --- a/cdist/mputil.py +++ /dev/null @@ -1,65 +0,0 @@ -# -*- coding: utf-8 -*- -# -# 2016-2017 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 multiprocessing -import concurrent.futures as cf -import itertools -import os -import signal -import logging - - -log = logging.getLogger("cdist-mputil") - - -def mp_sig_handler(signum, frame): - log.trace("signal %s, SIGKILL whole process group", signum) - os.killpg(os.getpgrp(), signal.SIGKILL) - - -def mp_pool_run(func, args=None, kwds=None, jobs=multiprocessing.cpu_count()): - """Run func using concurrent.futures.ProcessPoolExecutor with jobs jobs - and supplied iterables of args and kwds with one entry for each - parallel func instance. - Return list of results. - """ - if args and kwds: - fargs = zip(args, kwds) - elif args: - fargs = zip(args, itertools.repeat({})) - elif kwds: - fargs = zip(itertools.repeat(()), kwds) - else: - return [func(), ] - - retval = [] - with cf.ProcessPoolExecutor(jobs) as executor: - try: - results = [ - executor.submit(func, *a, **k) for a, k in fargs - ] - for f in cf.as_completed(results): - retval.append(f.result()) - return retval - except KeyboardInterrupt: - mp_sig_handler(signal.SIGINT, None) - raise diff --git a/cdist/shell.py b/cdist/shell.py index 60b6a9f0..8ca68115 100644 --- a/cdist/shell.py +++ b/cdist/shell.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # -# 2013-2015 Nico Schottelius (nico-cdist at schottelius.org) +# 2013 Nico Schottelius (nico-cdist at schottelius.org) # # This file is part of cdist. # @@ -21,7 +21,7 @@ import logging import os -import tempfile +import subprocess # initialise cdist import cdist.exec.local @@ -31,54 +31,35 @@ import cdist.config log = logging.getLogger(__name__) - class Shell(object): - + def __init__(self, shell=None): self.shell = shell - self.target_host = ( - "cdist-shell-no-target-host", - "cdist-shell-no-target-host", - "cdist-shell-no-target-host", - ) - self.target_host_tags = "" - - host_dir_name = cdist.str_hash(self.target_host[0]) - base_root_path = tempfile.mkdtemp() - host_base_path = os.path.join(base_root_path, host_dir_name) - + self.target_host = "cdist-shell-no-target-host" self.local = cdist.exec.local.Local( - target_host=self.target_host, - target_host_tags=self.target_host_tags, - base_root_path=host_base_path, - host_dir_name=host_dir_name) + target_host=self.target_host) def _init_shell(self): """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']), - # for use in type emulator - '__cdist_type_base_path': self.local.type_path, + '__cdist_type_base_path': self.local.type_path, # for use in type emulator '__cdist_manifest': "cdist shell", '__global': self.local.base_path, - '__target_host': self.target_host[0], - '__target_hostname': self.target_host[1], - '__target_fqdn': self.target_host[2], + '__target_host': self.target_host, '__manifest': self.local.manifest_path, '__explorer': self.local.global_explorer_path, - '__files': self.local.files_path, - '__target_host_tags': self.local.target_host_tags, } self.env.update(additional_env) @@ -88,9 +69,9 @@ class Shell(object): self._init_files_dirs() self._init_environment() - log.trace("Starting shell...") - self.local.run([self.shell], self.env, save_output=False) - log.trace("Finished shell.") + log.info("Starting shell...") + self.local.run([self.shell], self.env) + log.info("Finished shell.") @classmethod def commandline(cls, args): diff --git a/cdist/sphinxext/__init__.py b/cdist/sphinxext/__init__.py deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/sphinxext/manpage.py b/cdist/sphinxext/manpage.py deleted file mode 100644 index 135fe22e..00000000 --- a/cdist/sphinxext/manpage.py +++ /dev/null @@ -1,83 +0,0 @@ -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' - default_translator_class = ManualPageTranslator - - 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 faa3686a..ab767699 100644 --- a/cdist/test/__init__.py +++ b/cdist/test/__init__.py @@ -28,21 +28,14 @@ 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): remote_exec = os.path.join(global_fixtures_dir, "remote", "exec") remote_copy = os.path.join(global_fixtures_dir, "remote", "copy") - target_host = ( - 'cdisttesthost', - 'cdisttesthost', - 'cdisttesthost', - ) - target_host_tags = "tag1,tag2,tag3" + target_host = 'cdisttesthost' def mkdtemp(self, **kwargs): return tempfile.mkdtemp(prefix='tmp.cdist.test.', **kwargs) diff --git a/cdist/test/__main__.py b/cdist/test/__main__.py index c8c7df3b..08e839d1 100644 --- a/cdist/test/__main__.py +++ b/cdist/test/__main__.py @@ -45,5 +45,4 @@ for test_module in test_modules: suites.append(suite) all_suites = unittest.TestSuite(suites) -rv = unittest.TextTestRunner(verbosity=2).run(all_suites).wasSuccessful() -sys.exit(not rv) +unittest.TextTestRunner(verbosity=2).run(all_suites) diff --git a/cdist/test/autil/__init__.py b/cdist/test/autil/__init__.py deleted file mode 100644 index a78feaad..00000000 --- a/cdist/test/autil/__init__.py +++ /dev/null @@ -1,57 +0,0 @@ -# -*- coding: utf-8 -*- -# -# 2017 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 . -# -# - -from cdist import test -import cdist.autil as autil -import os -import os.path as op -import tarfile - - -my_dir = op.abspath(op.dirname(__file__)) -fixtures = op.join(my_dir, 'fixtures') -explorers_path = op.join(fixtures, 'explorer') - - -class AUtilTestCase(test.CdistTestCase): - def test_tar(self): - test_modes = { - 'tar': 'r:', - 'tgz': 'r:gz', - 'tbz2': 'r:bz2', - 'txz': 'r:xz', - } - source = explorers_path - for mode in test_modes: - tarpath, fcnt = autil.tar(source, mode) - self.assertIsNotNone(tarpath) - fcnt = 0 - with tarfile.open(tarpath, test_modes[mode]) as tar: - for tarinfo in tar: - fcnt += 1 - os.remove(tarpath) - self.assertGreater(fcnt, 0) - - -if __name__ == "__main__": - import unittest - - unittest.main() diff --git a/cdist/test/autil/fixtures/explorer/cpu_cores b/cdist/test/autil/fixtures/explorer/cpu_cores deleted file mode 100755 index 7f7a955e..00000000 --- a/cdist/test/autil/fixtures/explorer/cpu_cores +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/sh -# -# 2014 Daniel Heule (hda at sfs.biz) -# 2014 Thomas Oettli (otho at sfs.biz) -# -# 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 . -# -# - -# FIXME: other system types (not linux ...) - -os=$("$__explorer/os") -case "$os" in - "macosx") - echo "$(sysctl -n hw.physicalcpu)" - ;; - - *) - if [ -r /proc/cpuinfo ]; then - cores="$(grep "core id" /proc/cpuinfo | sort | uniq | wc -l)" - if [ ${cores} -eq 0 ]; then - cores="1" - fi - echo "$cores" - fi - ;; -esac diff --git a/cdist/test/autil/fixtures/explorer/cpu_sockets b/cdist/test/autil/fixtures/explorer/cpu_sockets deleted file mode 100755 index 8a8194df..00000000 --- a/cdist/test/autil/fixtures/explorer/cpu_sockets +++ /dev/null @@ -1,40 +0,0 @@ -#!/bin/sh -# -# 2014 Daniel Heule (hda at sfs.biz) -# 2014 Thomas Oettli (otho at sfs.biz) -# -# 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 . -# -# - -# FIXME: other system types (not linux ...) - -os=$("$__explorer/os") -case "$os" in - "macosx") - echo "$(system_profiler SPHardwareDataType | grep "Number of Processors" | awk -F': ' '{print $2}')" - ;; - - *) - if [ -r /proc/cpuinfo ]; then - sockets="$(grep "physical id" /proc/cpuinfo | sort | uniq | wc -l)" - if [ ${sockets} -eq 0 ]; then - sockets="$(cat /proc/cpuinfo | grep "processor" | wc -l)" - fi - echo "${sockets}" - fi - ;; -esac diff --git a/cdist/test/autil/fixtures/explorer/disks b/cdist/test/autil/fixtures/explorer/disks deleted file mode 100644 index 52fef81e..00000000 --- a/cdist/test/autil/fixtures/explorer/disks +++ /dev/null @@ -1,2 +0,0 @@ -cd /dev -echo sd? hd? vd? diff --git a/cdist/test/autil/fixtures/explorer/hostname b/cdist/test/autil/fixtures/explorer/hostname deleted file mode 100755 index 7715c6b0..00000000 --- a/cdist/test/autil/fixtures/explorer/hostname +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/sh -# -# 2010-2014 Nico Schottelius (nico-cdist at schottelius.org) -# 2012 Steven Armstrong (steven-cdist at armstrong.cc) -# -# This file is part of cdist. -# -# cdist is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# cdist is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with cdist. If not, see . -# -# - -if command -v uname >/dev/null; then - uname -n -fi diff --git a/cdist/test/autil/fixtures/explorer/init b/cdist/test/autil/fixtures/explorer/init deleted file mode 100755 index 2693a0d3..00000000 --- a/cdist/test/autil/fixtures/explorer/init +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/sh -# -# 2016 Daniel Heule (hda at sfs.biz) -# -# 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 . -# -# -# Returns the process name of pid 1 ( normaly the init system ) -# for example at linux this value is "init" or "systemd" in most cases -# - -uname_s="$(uname -s)" - -case "$uname_s" in - Linux|FreeBSD) - ps -o comm= -p 1 || true - ;; - *) - # return a empty string as unknown value - echo "" - ;; -esac diff --git a/cdist/test/autil/fixtures/explorer/interfaces b/cdist/test/autil/fixtures/explorer/interfaces deleted file mode 100755 index c1f2a57a..00000000 --- a/cdist/test/autil/fixtures/explorer/interfaces +++ /dev/null @@ -1,51 +0,0 @@ -#!/bin/sh -# -# 2012 Sébastien Gross -# -# 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 . -# -# -# List all network interfaces in explorer/ifaces. One interface per line. -# -# If your OS is not supported please provide a ifconfig output -# - -# Use ip, if available -if command -v ip >/dev/null; then - ip -o link show | sed -n 's/^[0-9]\+: \(.\+\): <.*/\1/p' - exit 0 -fi - -if ! command -v ifconfig >/dev/null; then - # no ifconfig, nothing we could do - exit 0 -fi - -uname_s="$(uname -s)" -REGEXP='s/^(.*)(:[[:space:]]*flags=|Link encap).*/\1/p' - -case "$uname_s" in - Darwin) - ifconfig -a | sed -n -E "$REGEXP" - ;; - Linux|*BSD) - ifconfig -a | sed -n -r "$REGEXP" - ;; - *) - echo "Unsupported ifconfig output for $uname_s" >&2 - exit 1 - ;; -esac diff --git a/cdist/test/autil/fixtures/explorer/kernel_name b/cdist/test/autil/fixtures/explorer/kernel_name deleted file mode 100644 index 98ebac2a..00000000 --- a/cdist/test/autil/fixtures/explorer/kernel_name +++ /dev/null @@ -1 +0,0 @@ -uname -s diff --git a/cdist/test/autil/fixtures/explorer/lsb_codename b/cdist/test/autil/fixtures/explorer/lsb_codename deleted file mode 100755 index eebd3e0f..00000000 --- a/cdist/test/autil/fixtures/explorer/lsb_codename +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/sh -# -# 2011 Steven Armstrong (steven-cdist at armstrong.cc) -# -# This file is part of cdist. -# -# cdist is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# cdist is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with cdist. If not, see . -# -# - -set +e -case "$($__explorer/os)" in - openwrt) - (. /etc/openwrt_release && echo "$DISTRIB_CODENAME") - ;; - *) - lsb_release=$(command -v lsb_release) - if [ -x "$lsb_release" ]; then - $lsb_release --short --codename - fi - ;; -esac diff --git a/cdist/test/autil/fixtures/explorer/lsb_description b/cdist/test/autil/fixtures/explorer/lsb_description deleted file mode 100755 index 23f45421..00000000 --- a/cdist/test/autil/fixtures/explorer/lsb_description +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/sh -# -# 2011 Steven Armstrong (steven-cdist at armstrong.cc) -# -# This file is part of cdist. -# -# cdist is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# cdist is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with cdist. If not, see . -# -# - -set +e -case "$($__explorer/os)" in - openwrt) - (. /etc/openwrt_release && echo "$DISTRIB_DESCRIPTION") - ;; - *) - lsb_release=$(command -v lsb_release) - if [ -x "$lsb_release" ]; then - $lsb_release --short --description - fi - ;; -esac diff --git a/cdist/test/autil/fixtures/explorer/lsb_id b/cdist/test/autil/fixtures/explorer/lsb_id deleted file mode 100755 index 9754eb63..00000000 --- a/cdist/test/autil/fixtures/explorer/lsb_id +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/sh -# -# 2011 Steven Armstrong (steven-cdist at armstrong.cc) -# -# This file is part of cdist. -# -# cdist is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# cdist is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with cdist. If not, see . -# -# - -set +e -case "$($__explorer/os)" in - openwrt) - (. /etc/openwrt_release && echo "$DISTRIB_ID") - ;; - *) - lsb_release=$(command -v lsb_release) - if [ -x "$lsb_release" ]; then - $lsb_release --short --id - fi - ;; -esac diff --git a/cdist/test/autil/fixtures/explorer/lsb_release b/cdist/test/autil/fixtures/explorer/lsb_release deleted file mode 100755 index 35b5547c..00000000 --- a/cdist/test/autil/fixtures/explorer/lsb_release +++ /dev/null @@ -1,33 +0,0 @@ -#!/bin/sh -# -# 2011 Steven Armstrong (steven-cdist at armstrong.cc) -# -# This file is part of cdist. -# -# cdist is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# cdist is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with cdist. If not, see . -# -# - -set +e -case "$($__explorer/os)" in - openwrt) - (. /etc/openwrt_release && echo "$DISTRIB_RELEASE") - ;; - *) - lsb_release=$(command -v lsb_release) - if [ -x "$lsb_release" ]; then - $lsb_release --short --release - fi - ;; -esac diff --git a/cdist/test/autil/fixtures/explorer/machine_type b/cdist/test/autil/fixtures/explorer/machine_type deleted file mode 100755 index eb3c9d36..00000000 --- a/cdist/test/autil/fixtures/explorer/machine_type +++ /dev/null @@ -1,66 +0,0 @@ -#!/bin/sh -# -# 2014 Daniel Heule (hda at sfs.biz) -# 2014 Thomas Oettli (otho at sfs.biz) -# -# 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 . -# -# - -# 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 - if grep -q "hypervisor" /proc/cpuinfo; then - # this file is aviable in xen guest systems - if [ -r /sys/hypervisor/type ]; then - if grep -q -i "xen" /sys/hypervisor/type; then - echo virtual_by_xen - exit - fi - else - if [ -r /sys/class/dmi/id/product_name ]; then - if grep -q -i 'vmware' /sys/class/dmi/id/product_name; then - echo "virtual_by_vmware" - exit - 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 - echo "virtual_by_unknown" - else - echo "physical" - fi -else - echo "unknown" -fi diff --git a/cdist/test/autil/fixtures/explorer/memory b/cdist/test/autil/fixtures/explorer/memory deleted file mode 100755 index 05db865f..00000000 --- a/cdist/test/autil/fixtures/explorer/memory +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/sh -# -# 2014 Daniel Heule (hda at sfs.biz) -# 2014 Thomas Oettli (otho at sfs.biz) -# -# 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 . -# -# - -# FIXME: other system types (not linux ...) - -os=$("$__explorer/os") -case "$os" in - "macosx") - echo "$(sysctl -n hw.memsize)/1024" | bc - ;; - - *) - if [ -r /proc/meminfo ]; then - grep "MemTotal:" /proc/meminfo | awk '{print $2}' - fi - ;; -esac diff --git a/cdist/test/autil/fixtures/explorer/os b/cdist/test/autil/fixtures/explorer/os deleted file mode 100755 index 094685ea..00000000 --- a/cdist/test/autil/fixtures/explorer/os +++ /dev/null @@ -1,143 +0,0 @@ -#!/bin/sh -# -# 2010-2011 Nico Schottelius (nico-cdist at schottelius.org) -# -# This file is part of cdist. -# -# cdist is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# cdist is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with cdist. If not, see . -# -# -# All os variables are lower case. Keep this file in alphabetical -# order by os variable except in cases where order otherwise matters, -# in which case keep the primary os and its derivatives together in -# a block (see Debian and Redhat examples below). -# - -if grep -q ^Amazon /etc/system-release 2>/dev/null; then - echo amazon - exit 0 -fi - -if [ -f /etc/arch-release ]; then - echo archlinux - exit 0 -fi - -if [ -f /etc/cdist-preos ]; then - echo cdist-preos - exit 0 -fi - -if [ -d /gnu/store ]; then - echo guixsd - exit 0 -fi - -### Debian and derivatives -if grep -q ^DISTRIB_ID=Ubuntu /etc/lsb-release 2>/dev/null; then - echo ubuntu - exit 0 -fi - -if [ -f /etc/debian_version ]; then - echo debian - exit 0 -fi - -if [ -f /etc/devuan_version ]; then - echo devuan - exit 0 -fi -### - -if [ -f /etc/gentoo-release ]; then - echo gentoo - exit 0 -fi - -if [ -f /etc/openwrt_version ]; then - echo openwrt - exit 0 -fi - -if [ -f /etc/owl-release ]; then - echo owl - exit 0 -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 -fi - -if grep -q ^Fedora /etc/redhat-release 2>/dev/null; then - echo fedora - exit 0 -fi - -if grep -q ^Mitel /etc/redhat-release 2>/dev/null; then - echo mitel - exit 0 -fi - -if [ -f /etc/redhat-release ]; then - echo redhat - exit 0 -fi -### - -if [ -f /etc/SuSE-release ]; then - echo suse - exit 0 -fi - -if [ -f /etc/slackware-version ]; then - echo slackware - exit 0 -fi - -uname_s="$(uname -s)" - -# Assume there is no tr on the client -> do lower case ourselves -case "$uname_s" in - Darwin) - echo macosx - exit 0 - ;; - NetBSD) - echo netbsd - exit 0 - ;; - FreeBSD) - echo freebsd - exit 0 - ;; - OpenBSD) - echo openbsd - exit 0 - ;; - SunOS) - echo solaris - exit 0 - ;; -esac - -echo "Unknown OS" >&2 -exit 1 diff --git a/cdist/test/autil/fixtures/explorer/os_version b/cdist/test/autil/fixtures/explorer/os_version deleted file mode 100755 index 380782cc..00000000 --- a/cdist/test/autil/fixtures/explorer/os_version +++ /dev/null @@ -1,73 +0,0 @@ -#!/bin/sh -# -# 2010-2011 Nico Schottelius (nico-cdist at schottelius.org) -# -# This file is part of cdist. -# -# cdist is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# cdist is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with cdist. If not, see . -# -# -# All os variables are lower case -# -# - -case "$($__explorer/os)" in - amazon) - cat /etc/system-release - ;; - archlinux) - # empty, but well... - cat /etc/arch-release - ;; - debian) - cat /etc/debian_version - ;; - devuan) - cat /etc/devuan_version - ;; - fedora) - cat /etc/fedora-release - ;; - gentoo) - cat /etc/gentoo-release - ;; - macosx) - sw_vers -productVersion - ;; - *bsd|solaris) - uname -r - ;; - openwrt) - cat /etc/openwrt_version - ;; - owl) - cat /etc/owl-release - ;; - redhat|centos|mitel|scientific) - cat /etc/redhat-release - ;; - slackware) - cat /etc/slackware-version - ;; - suse) - if [ -f /etc/os-release ]; then - cat /etc/os-release - else - cat /etc/SuSE-release - fi - ;; - ubuntu) - lsb_release -sr - ;; -esac diff --git a/cdist/test/autil/fixtures/explorer/runlevel b/cdist/test/autil/fixtures/explorer/runlevel deleted file mode 100755 index 02d3a245..00000000 --- a/cdist/test/autil/fixtures/explorer/runlevel +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/sh -# -# 2012 Nico Schottelius (nico-cdist at schottelius.org) -# -# This file is part of cdist. -# -# cdist is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# cdist is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with cdist. If not, see . -# -# - -set +e -executable=$(command -v runlevel) -if [ -x "$executable" ]; then - "$executable" | awk '{ print $2 }' -fi diff --git a/cdist/test/banner/__init__.py b/cdist/test/banner/__init__.py index 957b7b12..4b0ab6ac 100644 --- a/cdist/test/banner/__init__.py +++ b/cdist/test/banner/__init__.py @@ -27,7 +27,6 @@ import unittest import cdist import cdist.banner - class Banner(unittest.TestCase): def setUp(self): self.banner = cdist.BANNER + "\n" @@ -39,5 +38,5 @@ class Banner(unittest.TestCase): sys.stdout = output cdist.banner.banner(None) - + self.assertEqual(output.getvalue(), self.banner) diff --git a/cdist/test/capture_output/__init__.py b/cdist/test/capture_output/__init__.py deleted file mode 100644 index 229cbf70..00000000 --- a/cdist/test/capture_output/__init__.py +++ /dev/null @@ -1,137 +0,0 @@ -# -*- coding: utf-8 -*- -# -# 2011-2013 Steven Armstrong (steven-cdist at armstrong.cc) -# 2012-2013 Nico Schottelius (nico-cdist at schottelius.org) -# -# This file is part of cdist. -# -# cdist is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# cdist is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with cdist. If not, see . -# -# - -import os -import shutil - -import cdist -from cdist import core -from cdist import test -from cdist.exec import local -from cdist.exec import remote -from cdist.core import code -from cdist.core import manifest - -import os.path as op -my_dir = op.abspath(op.dirname(__file__)) -fixtures = op.join(my_dir, 'fixtures') -conf_dir = op.join(fixtures, 'conf') - - -class CaptureOutputTestCase(test.CdistTestCase): - - def setUp(self): - # logging.root.setLevel(logging.TRACE) - self.temp_dir = self.mkdtemp() - - self.local_dir = os.path.join(self.temp_dir, "local") - self.hostdir = cdist.str_hash(self.target_host[0]) - self.host_base_path = os.path.join(self.local_dir, self.hostdir) - os.makedirs(self.host_base_path) - self.local = local.Local( - target_host=self.target_host, - target_host_tags=None, - base_root_path=self.host_base_path, - host_dir_name=self.hostdir, - exec_path=cdist.test.cdist_exec_path, - add_conf_dirs=[conf_dir]) - self.local.create_files_dirs() - - self.remote_dir = self.mkdtemp() - remote_exec = self.remote_exec - remote_copy = self.remote_copy - self.remote = remote.Remote( - target_host=self.target_host, - remote_exec=remote_exec, - remote_copy=remote_copy, - base_path=self.remote_dir, - stdout_base_path=self.local.stdout_base_path, - stderr_base_path=self.local.stderr_base_path) - self.remote.create_files_dirs() - - self.code = code.Code(self.target_host, self.local, self.remote) - - self.manifest = manifest.Manifest(self.target_host, self.local) - - self.cdist_type = core.CdistType(self.local.type_path, - '__write_to_stdout_and_stderr') - self.cdist_object = core.CdistObject(self.cdist_type, - self.local.object_path, - self.local.object_marker_name, - '') - self.cdist_object.create() - self.output_dirs = { - 'object': { - 'stdout': os.path.join(self.cdist_object.absolute_path, - 'stdout'), - 'stderr': os.path.join(self.cdist_object.absolute_path, - 'stderr'), - }, - 'init': { - 'stdout': os.path.join(self.local.base_path, 'stdout'), - 'stderr': os.path.join(self.local.base_path, 'stderr'), - }, - } - - def tearDown(self): - shutil.rmtree(self.local_dir) - shutil.rmtree(self.remote_dir) - shutil.rmtree(self.temp_dir) - - def _test_output(self, which, target, streams=('stdout', 'stderr')): - for stream in streams: - _should = '{0}: {1}\n'.format(which, stream) - stream_path = os.path.join(self.output_dirs[target][stream], which) - with open(stream_path, 'r') as fd: - _is = fd.read() - self.assertEqual(_should, _is) - - def test_capture_code_output(self): - self.cdist_object.code_local = self.code.run_gencode_local( - self.cdist_object) - self._test_output('gencode-local', 'object', ('stderr',)) - - self.code.run_code_local(self.cdist_object) - self._test_output('code-local', 'object') - - self.cdist_object.code_remote = self.code.run_gencode_remote( - self.cdist_object) - self._test_output('gencode-remote', 'object', ('stderr',)) - - self.code.transfer_code_remote(self.cdist_object) - self.code.run_code_remote(self.cdist_object) - self._test_output('code-remote', 'object') - - def test_capture_manifest_output(self): - self.manifest.run_type_manifest(self.cdist_object) - self._test_output('manifest', 'object') - - def test_capture_init_manifest_output(self): - initial_manifest = os.path.join(conf_dir, 'manifest', 'init') - self.manifest.run_initial_manifest(initial_manifest) - self._test_output('init', 'init') - - -if __name__ == "__main__": - import unittest - - unittest.main() diff --git a/cdist/test/capture_output/fixtures/conf/manifest/init b/cdist/test/capture_output/fixtures/conf/manifest/init deleted file mode 100755 index 68d7da97..00000000 --- a/cdist/test/capture_output/fixtures/conf/manifest/init +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh - -echo "init: stdout" -echo "init: stderr" >&2 diff --git a/cdist/test/capture_output/fixtures/conf/type/__write_to_stdout_and_stderr/gencode-local b/cdist/test/capture_output/fixtures/conf/type/__write_to_stdout_and_stderr/gencode-local deleted file mode 100755 index 1946dbd3..00000000 --- a/cdist/test/capture_output/fixtures/conf/type/__write_to_stdout_and_stderr/gencode-local +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh - -echo "gencode-local: stderr" >&2 - -echo "echo \"code-local: stdout\"" -echo "echo \"code-local: stderr\" >&2" diff --git a/cdist/test/capture_output/fixtures/conf/type/__write_to_stdout_and_stderr/gencode-remote b/cdist/test/capture_output/fixtures/conf/type/__write_to_stdout_and_stderr/gencode-remote deleted file mode 100755 index f713b932..00000000 --- a/cdist/test/capture_output/fixtures/conf/type/__write_to_stdout_and_stderr/gencode-remote +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh - -echo "gencode-remote: stderr" >&2 - -echo "echo \"code-remote: stdout\"" -echo "echo \"code-remote: stderr\" >&2" diff --git a/cdist/test/capture_output/fixtures/conf/type/__write_to_stdout_and_stderr/manifest b/cdist/test/capture_output/fixtures/conf/type/__write_to_stdout_and_stderr/manifest deleted file mode 100755 index 4f122f25..00000000 --- a/cdist/test/capture_output/fixtures/conf/type/__write_to_stdout_and_stderr/manifest +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh - -echo "manifest: stdout" -echo "manifest: stderr" >&2 diff --git a/cdist/test/capture_output/fixtures/conf/type/__write_to_stdout_and_stderr/singleton b/cdist/test/capture_output/fixtures/conf/type/__write_to_stdout_and_stderr/singleton deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/test/capture_output_disabled/__init__.py b/cdist/test/capture_output_disabled/__init__.py deleted file mode 100644 index 828e80f1..00000000 --- a/cdist/test/capture_output_disabled/__init__.py +++ /dev/null @@ -1,140 +0,0 @@ -# -*- coding: utf-8 -*- -# -# 2018 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 os -import shutil - -import cdist -from cdist import core -from cdist import test -from cdist.exec import local -from cdist.exec import remote -from cdist.core import code -from cdist.core import manifest - -import os.path as op -my_dir = op.abspath(op.dirname(__file__)) -fixtures = op.join(my_dir, 'fixtures') -conf_dir = op.join(fixtures, 'conf') - - -class CaptureOutputDisabledTestCase(test.CdistTestCase): - - def setUp(self): - # logging.root.setLevel(logging.TRACE) - save_output_streams = False - self.temp_dir = self.mkdtemp() - - self.local_dir = os.path.join(self.temp_dir, "local") - self.hostdir = cdist.str_hash(self.target_host[0]) - self.host_base_path = os.path.join(self.local_dir, self.hostdir) - os.makedirs(self.host_base_path) - self.local = local.Local( - target_host=self.target_host, - target_host_tags=None, - base_root_path=self.host_base_path, - host_dir_name=self.hostdir, - exec_path=cdist.test.cdist_exec_path, - add_conf_dirs=[conf_dir], - save_output_streams=save_output_streams) - self.local.create_files_dirs() - - self.remote_dir = self.mkdtemp() - remote_exec = self.remote_exec - remote_copy = self.remote_copy - self.remote = remote.Remote( - target_host=self.target_host, - remote_exec=remote_exec, - remote_copy=remote_copy, - base_path=self.remote_dir, - stdout_base_path=self.local.stdout_base_path, - stderr_base_path=self.local.stderr_base_path, - save_output_streams=save_output_streams) - self.remote.create_files_dirs() - - self.code = code.Code(self.target_host, self.local, self.remote) - - self.manifest = manifest.Manifest(self.target_host, self.local) - - self.cdist_type = core.CdistType(self.local.type_path, - '__write_to_stdout_and_stderr') - self.cdist_object = core.CdistObject(self.cdist_type, - self.local.object_path, - self.local.object_marker_name, - '') - self.cdist_object.create() - self.output_dirs = { - 'object': { - 'stdout': os.path.join(self.cdist_object.absolute_path, - 'stdout'), - 'stderr': os.path.join(self.cdist_object.absolute_path, - 'stderr'), - }, - 'init': { - 'stdout': os.path.join(self.local.base_path, 'stdout'), - 'stderr': os.path.join(self.local.base_path, 'stderr'), - }, - } - - def tearDown(self): - shutil.rmtree(self.local_dir) - shutil.rmtree(self.remote_dir) - shutil.rmtree(self.temp_dir) - - def _test_output(self, which, target, streams=('stdout', 'stderr')): - for stream in streams: - stream_path = os.path.join(self.output_dirs[target][stream], which) - if os.path.exists(stream_path): - with open(stream_path, 'r') as fd: - _is = fd.read() - self.assertEqual("", _is) - # else ok when not exists - - def test_capture_code_output_disabled(self): - self.cdist_object.code_local = self.code.run_gencode_local( - self.cdist_object) - self._test_output('gencode-local', 'object', ('stderr',)) - - self.code.run_code_local(self.cdist_object) - self._test_output('code-local', 'object') - - self.cdist_object.code_remote = self.code.run_gencode_remote( - self.cdist_object) - self._test_output('gencode-remote', 'object', ('stderr',)) - - self.code.transfer_code_remote(self.cdist_object) - self.code.run_code_remote(self.cdist_object) - self._test_output('code-remote', 'object') - - def test_capture_manifest_output_disabled(self): - self.manifest.run_type_manifest(self.cdist_object) - self._test_output('manifest', 'object') - - def test_capture_init_manifest_output_disabled(self): - initial_manifest = os.path.join(conf_dir, 'manifest', 'init') - self.manifest.run_initial_manifest(initial_manifest) - self._test_output('init', 'init') - - -if __name__ == "__main__": - import unittest - - unittest.main() diff --git a/cdist/test/capture_output_disabled/fixtures/conf/manifest/init b/cdist/test/capture_output_disabled/fixtures/conf/manifest/init deleted file mode 100755 index 68d7da97..00000000 --- a/cdist/test/capture_output_disabled/fixtures/conf/manifest/init +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh - -echo "init: stdout" -echo "init: stderr" >&2 diff --git a/cdist/test/capture_output_disabled/fixtures/conf/type/__write_to_stdout_and_stderr/gencode-local b/cdist/test/capture_output_disabled/fixtures/conf/type/__write_to_stdout_and_stderr/gencode-local deleted file mode 100755 index 1946dbd3..00000000 --- a/cdist/test/capture_output_disabled/fixtures/conf/type/__write_to_stdout_and_stderr/gencode-local +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh - -echo "gencode-local: stderr" >&2 - -echo "echo \"code-local: stdout\"" -echo "echo \"code-local: stderr\" >&2" diff --git a/cdist/test/capture_output_disabled/fixtures/conf/type/__write_to_stdout_and_stderr/gencode-remote b/cdist/test/capture_output_disabled/fixtures/conf/type/__write_to_stdout_and_stderr/gencode-remote deleted file mode 100755 index f713b932..00000000 --- a/cdist/test/capture_output_disabled/fixtures/conf/type/__write_to_stdout_and_stderr/gencode-remote +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh - -echo "gencode-remote: stderr" >&2 - -echo "echo \"code-remote: stdout\"" -echo "echo \"code-remote: stderr\" >&2" diff --git a/cdist/test/capture_output_disabled/fixtures/conf/type/__write_to_stdout_and_stderr/manifest b/cdist/test/capture_output_disabled/fixtures/conf/type/__write_to_stdout_and_stderr/manifest deleted file mode 100755 index 4f122f25..00000000 --- a/cdist/test/capture_output_disabled/fixtures/conf/type/__write_to_stdout_and_stderr/manifest +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh - -echo "manifest: stdout" -echo "manifest: stderr" >&2 diff --git a/cdist/test/capture_output_disabled/fixtures/conf/type/__write_to_stdout_and_stderr/singleton b/cdist/test/capture_output_disabled/fixtures/conf/type/__write_to_stdout_and_stderr/singleton deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/test/cdist_object/__init__.py b/cdist/test/cdist_object/__init__.py index a9c20cd3..3c25a959 100644 --- a/cdist/test/cdist_object/__init__.py +++ b/cdist/test/cdist_object/__init__.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # # 2010-2011 Steven Armstrong (steven-cdist at armstrong.cc) -# 2012-2015 Nico Schottelius (nico-cdist at schottelius.org) +# 2012 Nico Schottelius (nico-cdist at schottelius.org) # 2014 Daniel Heule (hda at sfs.biz) # # This file is part of cdist. @@ -23,7 +23,6 @@ import os import shutil -import tempfile from cdist import test from cdist import core @@ -33,61 +32,42 @@ import cdist import os.path as op my_dir = op.abspath(op.dirname(__file__)) fixtures = op.join(my_dir, 'fixtures') +object_base_path = op.join(fixtures, 'object') type_base_path = op.join(fixtures, 'type') -OBJECT_MARKER_NAME = '.cdist-pseudo-random' - -expected_object_names = sorted([ - '__first/child', - '__first/dog', - '__first/man', - '__first/woman', - '__second/on-the', - '__second/under-the', - '__third/moon']) - - class ObjectClassTestCase(test.CdistTestCase): def setUp(self): - - self.tempdir = tempfile.mkdtemp(prefix="cdist.test") - self.object_base_path = self.tempdir + self.expected_object_names = sorted([ + '__first/child', + '__first/dog', + '__first/man', + '__first/woman', + '__second/on-the', + '__second/under-the', + '__third/moon']) self.expected_objects = [] - for cdist_object_name in expected_object_names: + for cdist_object_name in self.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.create() + cdist_object = core.CdistObject(core.CdistType(type_base_path, cdist_type), object_base_path, cdist_object_id) 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(object_base_path))) + self.assertEqual(found_object_names, self.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(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(object_base_path, type_base_path))) 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): @@ -96,86 +76,42 @@ 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): - self.tempdir = tempfile.mkdtemp(prefix="cdist.test") - self.object_base_path = self.tempdir - - 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.create() - self.expected_objects.append(cdist_object) - - def tearDown(self): - shutil.rmtree(self.tempdir) - def test_object_id_contains_double_slash(self): 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, object_base_path, 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' % core.OBJECT_MARKER with self.assertRaises(core.IllegalObjectIdError): - core.CdistObject(cdist_type, self.object_base_path, - OBJECT_MARKER_NAME, illegal_object_id) + core.CdistObject(cdist_type, object_base_path, 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' % core.OBJECT_MARKER + core.CdistObject(cdist_type, object_base_path, 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) - - def test_object_id_equals_slash(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, object_base_path, 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, object_base_path, illegal_object_id) class ObjectTestCase(test.CdistTestCase): def setUp(self): - self.tempdir = tempfile.mkdtemp(prefix="cdist.test") - 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.create() - - self.cdist_object.parameters['planet'] = 'Saturn' - self.cdist_object.parameters['name'] = 'Prometheus' + self.cdist_object = core.CdistObject(self.cdist_type, object_base_path, 'moon') def tearDown(self): self.cdist_object.prepared = False @@ -185,8 +121,6 @@ class ObjectTestCase(test.CdistTestCase): self.cdist_object.code_remote = '' self.cdist_object.state = '' - shutil.rmtree(self.tempdir) - def test_name(self): self.assertEqual(self.cdist_object.name, '__third/moon') @@ -194,29 +128,22 @@ 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/.cdist') 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(object_base_path, '__third/moon/.cdist')) 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/.cdist/code-local') 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/.cdist/code-remote') 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/.cdist/parameter') 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/.cdist/explorer') def test_parameters(self): expected_parameters = {'planet': 'Saturn', 'name': 'Prometheus'} @@ -225,39 +152,32 @@ 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 = [] @@ -268,18 +188,15 @@ 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/fixtures/__not_nonparallel/.keep b/cdist/test/cdist_object/fixtures/object/__first/.keep similarity index 100% rename from cdist/test/cdist_type/fixtures/__not_nonparallel/.keep rename to cdist/test/cdist_object/fixtures/object/__first/.keep diff --git a/cdist/test/config/fixtures/type/__a/.keep b/cdist/test/cdist_object/fixtures/object/__first/child/.cdist/.keep similarity index 100% rename from cdist/test/config/fixtures/type/__a/.keep rename to cdist/test/cdist_object/fixtures/object/__first/child/.cdist/.keep diff --git a/cdist/test/config/fixtures/type/__b/.keep b/cdist/test/cdist_object/fixtures/object/__first/dog/.cdist/.keep similarity index 100% rename from cdist/test/config/fixtures/type/__b/.keep rename to cdist/test/cdist_object/fixtures/object/__first/dog/.cdist/.keep diff --git a/cdist/test/config/fixtures/type/__c/.keep b/cdist/test/cdist_object/fixtures/object/__first/man/.cdist/.keep similarity index 100% rename from cdist/test/config/fixtures/type/__c/.keep rename to cdist/test/cdist_object/fixtures/object/__first/man/.cdist/.keep diff --git a/cdist/test/config/fixtures/type/__d/.keep b/cdist/test/cdist_object/fixtures/object/__first/woman/.cdist/.keep similarity index 100% rename from cdist/test/config/fixtures/type/__d/.keep rename to cdist/test/cdist_object/fixtures/object/__first/woman/.cdist/.keep diff --git a/cdist/test/config/fixtures/type/__e/.keep b/cdist/test/cdist_object/fixtures/object/__second/.keep similarity index 100% rename from cdist/test/config/fixtures/type/__e/.keep rename to cdist/test/cdist_object/fixtures/object/__second/.keep diff --git a/cdist/test/config/fixtures/type/__f/.keep b/cdist/test/cdist_object/fixtures/object/__second/on-the/.cdist/.keep similarity index 100% rename from cdist/test/config/fixtures/type/__f/.keep rename to cdist/test/cdist_object/fixtures/object/__second/on-the/.cdist/.keep diff --git a/cdist/test/config/fixtures/type/__g/.keep b/cdist/test/cdist_object/fixtures/object/__second/under-the/.cdist/.keep similarity index 100% rename from cdist/test/config/fixtures/type/__g/.keep rename to cdist/test/cdist_object/fixtures/object/__second/under-the/.cdist/.keep diff --git a/cdist/test/config/fixtures/type/__h/.keep b/cdist/test/cdist_object/fixtures/object/__third/.keep similarity index 100% rename from cdist/test/config/fixtures/type/__h/.keep rename to cdist/test/cdist_object/fixtures/object/__third/.keep diff --git a/cdist/test/config/fixtures/type/__i/.keep b/cdist/test/cdist_object/fixtures/object/__third/moon/.cdist/.keep similarity index 100% rename from cdist/test/config/fixtures/type/__i/.keep rename to cdist/test/cdist_object/fixtures/object/__third/moon/.cdist/.keep diff --git a/cdist/test/cdist_object/fixtures/object/__third/moon/.cdist/parameter/name b/cdist/test/cdist_object/fixtures/object/__third/moon/.cdist/parameter/name new file mode 100644 index 00000000..4129a761 --- /dev/null +++ b/cdist/test/cdist_object/fixtures/object/__third/moon/.cdist/parameter/name @@ -0,0 +1 @@ +Prometheus diff --git a/cdist/test/cdist_object/fixtures/object/__third/moon/.cdist/parameter/planet b/cdist/test/cdist_object/fixtures/object/__third/moon/.cdist/parameter/planet new file mode 100644 index 00000000..8e6ee422 --- /dev/null +++ b/cdist/test/cdist_object/fixtures/object/__third/moon/.cdist/parameter/planet @@ -0,0 +1 @@ +Saturn diff --git a/cdist/test/cdist_type/__init__.py b/cdist/test/cdist_type/__init__.py index a51a1e6f..36a524b4 100644 --- a/cdist/test/cdist_type/__init__.py +++ b/cdist/test/cdist_type/__init__.py @@ -34,8 +34,7 @@ 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') @@ -55,8 +54,7 @@ class TypeTestCase(test.CdistTestCase): def test_nonexistent_type(self): base_path = fixtures - self.assertRaises(core.InvalidTypeError, 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 @@ -76,32 +74,27 @@ 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 @@ -113,36 +106,6 @@ class TypeTestCase(test.CdistTestCase): cdist_type = core.CdistType(base_path, '__not_singleton') self.assertFalse(cdist_type.is_singleton) - def test_nonparallel_is_nonparallel(self): - base_path = fixtures - cdist_type = core.CdistType(base_path, '__nonparallel') - self.assertTrue(cdist_type.is_nonparallel) - - def test_not_nonparallel_is_nonparallel(self): - base_path = fixtures - cdist_type = core.CdistType(base_path, '__not_nonparallel') - self.assertFalse(cdist_type.is_nonparallel) - - def test_deprecated(self): - base_path = fixtures - cdist_type = core.CdistType(base_path, '__deprecated') - self.assertIsNotNone(cdist_type.deprecated) - - def test_not_deprecated(self): - base_path = fixtures - cdist_type = core.CdistType(base_path, '__not_deprecated') - self.assertIsNone(cdist_type.deprecated) - - def test_install_is_install(self): - base_path = fixtures - cdist_type = core.CdistType(base_path, '__install') - self.assertTrue(cdist_type.is_install) - - def test_not_install_is_install(self): - base_path = fixtures - cdist_type = core.CdistType(base_path, '__not_install') - self.assertFalse(cdist_type.is_install) - def test_with_explorers(self): base_path = fixtures cdist_type = core.CdistType(base_path, '__with_explorers') @@ -156,20 +119,17 @@ 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 @@ -179,8 +139,7 @@ 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 @@ -194,24 +153,3 @@ class TypeTestCase(test.CdistTestCase): self.assertFalse('optional2' in cdist_type.parameter_defaults) self.assertEqual(cdist_type.parameter_defaults['optional1'], 'value1') - def test_directory_in_default(self): - base_path = fixtures - cdist_type = core.CdistType(base_path, '__directory_in_default') - self.assertEqual( - list(sorted(cdist_type.parameter_defaults.keys())), - ['bar', 'foo']) - - def test_without_deprecated_parameters(self): - base_path = fixtures - cdist_type = core.CdistType(base_path, - '__without_deprecated_parameters') - self.assertEqual(cdist_type.deprecated_parameters, {}) - - def test_with_deprecated_parameters(self): - base_path = fixtures - cdist_type = core.CdistType(base_path, '__with_deprecated_parameters') - self.assertTrue('eggs' in cdist_type.deprecated_parameters) - self.assertTrue('spam' in cdist_type.deprecated_parameters) - self.assertEqual(cdist_type.deprecated_parameters['eggs'], - 'Deprecated') - self.assertEqual(cdist_type.deprecated_parameters['spam'], '') diff --git a/cdist/test/cdist_type/fixtures/__deprecated/deprecated b/cdist/test/cdist_type/fixtures/__deprecated/deprecated deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/test/cdist_type/fixtures/__directory_in_default/parameter/default/a/.gitkeep b/cdist/test/cdist_type/fixtures/__directory_in_default/parameter/default/a/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/test/cdist_type/fixtures/__directory_in_default/parameter/default/bar b/cdist/test/cdist_type/fixtures/__directory_in_default/parameter/default/bar deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/test/cdist_type/fixtures/__directory_in_default/parameter/default/foo b/cdist/test/cdist_type/fixtures/__directory_in_default/parameter/default/foo deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/test/cdist_type/fixtures/__directory_in_default/parameter/optional b/cdist/test/cdist_type/fixtures/__directory_in_default/parameter/optional deleted file mode 100644 index 3bd1f0e2..00000000 --- a/cdist/test/cdist_type/fixtures/__directory_in_default/parameter/optional +++ /dev/null @@ -1,2 +0,0 @@ -foo -bar diff --git a/cdist/test/cdist_type/fixtures/__nonparallel/nonparallel b/cdist/test/cdist_type/fixtures/__nonparallel/nonparallel deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/test/cdist_type/fixtures/__with_deprecated_parameters/parameter/deprecated/eggs b/cdist/test/cdist_type/fixtures/__with_deprecated_parameters/parameter/deprecated/eggs deleted file mode 100644 index 69d9f456..00000000 --- a/cdist/test/cdist_type/fixtures/__with_deprecated_parameters/parameter/deprecated/eggs +++ /dev/null @@ -1 +0,0 @@ -Deprecated diff --git a/cdist/test/cdist_type/fixtures/__with_deprecated_parameters/parameter/deprecated/spam b/cdist/test/cdist_type/fixtures/__with_deprecated_parameters/parameter/deprecated/spam deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/test/cdist_type/fixtures/__with_deprecated_parameters/parameter/optional b/cdist/test/cdist_type/fixtures/__with_deprecated_parameters/parameter/optional deleted file mode 100644 index bfe09199..00000000 --- a/cdist/test/cdist_type/fixtures/__with_deprecated_parameters/parameter/optional +++ /dev/null @@ -1,3 +0,0 @@ -spam -eggs -sausage diff --git a/cdist/test/code/__init__.py b/cdist/test/code/__init__.py index bf80110d..796e8a51 100644 --- a/cdist/test/code/__init__.py +++ b/cdist/test/code/__init__.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # -# 2011-2017 Steven Armstrong (steven-cdist at armstrong.cc) -# 2012-2015 Nico Schottelius (nico-cdist at schottelius.org) +# 2011 Steven Armstrong (steven-cdist at armstrong.cc) +# 2012-2013 Nico Schottelius (nico-cdist at schottelius.org) # # This file is part of cdist. # @@ -23,7 +23,6 @@ import getpass import os import shutil -import logging import cdist from cdist import core @@ -37,20 +36,15 @@ 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.hostdir = cdist.str_hash(self.target_host[0]) - self.host_base_path = os.path.join(self.local_dir, self.hostdir) self.local = local.Local( - target_host=self.target_host, - target_host_tags=self.target_host_tags, - base_root_path=self.host_base_path, - host_dir_name=self.hostdir, - 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() @@ -58,21 +52,16 @@ 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, - stdout_base_path=self.local.stdout_base_path, - stderr_base_path=self.local.stderr_base_path) + 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.cdist_object.create() def tearDown(self): @@ -84,77 +73,42 @@ 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[0]) - self.assertEqual(output_dict['__target_hostname'], - self.local.target_host[1]) - self.assertEqual(output_dict['__target_fqdn'], - self.local.target_host[2]) + 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) - self.assertEqual(output_dict['__target_host_tags'], - self.local.target_host_tags) - self.assertEqual(output_dict['__cdist_log_level'], - str(logging.WARNING)) - self.assertEqual(output_dict['__cdist_log_level_name'], 'WARNING') 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[0]) - self.assertEqual(output_dict['__target_hostname'], - self.local.target_host[1]) - self.assertEqual(output_dict['__target_fqdn'], - self.local.target_host[2]) + 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) - self.assertEqual(output_dict['__target_host_tags'], - self.local.target_host_tags) - self.assertEqual(output_dict['__cdist_log_level'], - str(logging.WARNING)) - self.assertEqual(output_dict['__cdist_log_level_name'], 'WARNING') 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 2829d633..771894fb 100755 --- a/cdist/test/code/fixtures/conf/type/__dump_environment/gencode-local +++ b/cdist/test/code/fixtures/conf/type/__dump_environment/gencode-local @@ -1,14 +1,8 @@ #!/bin/sh echo "echo __target_host: $__target_host" -echo "echo __target_hostname: $__target_hostname" -echo "echo __target_fqdn: $__target_fqdn" echo "echo __global: $__global" echo "echo __type: $__type" echo "echo __object: $__object" echo "echo __object_id: $__object_id" echo "echo __object_name: $__object_name" -echo "echo __files: $__files" -echo "echo __target_host_tags: $__target_host_tags" -echo "echo __cdist_log_level: $__cdist_log_level" -echo "echo __cdist_log_level_name: $__cdist_log_level_name" diff --git a/cdist/test/config/__init__.py b/cdist/test/config/__init__.py index 499593e3..70501c89 100644 --- a/cdist/test/config/__init__.py +++ b/cdist/test/config/__init__.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # -# 2010-2017 Steven Armstrong (steven-cdist at armstrong.cc) -# 2012-2015 Nico Schottelius (nico-cdist at schottelius.org) +# 2010-2011 Steven Armstrong (steven-cdist at armstrong.cc) +# 2012-2013 Nico Schottelius (nico-cdist at schottelius.org) # 2014 Daniel Heule (hda at sfs.biz) # # This file is part of cdist. @@ -35,28 +35,10 @@ import cdist.core.cdist_object import os.path as op my_dir = op.abspath(op.dirname(__file__)) fixtures = op.join(my_dir, 'fixtures') +object_base_path = op.join(fixtures, 'object') type_base_path = op.join(fixtures, 'type') add_conf_dir = op.join(fixtures, 'conf') -expected_object_names = sorted([ - '__first/man', - '__second/on-the', - '__third/moon']) - - -class CdistObjectErrorContext(object): - def __init__(self, original_error): - self.original_error = original_error - - def __enter__(self): - return self - - def __exit__(self, exc_type, exc_value, tb): - if exc_type is not None: - if exc_value.original_error: - raise exc_value.original_error - - class ConfigRunTestCase(test.CdistTestCase): def setUp(self): @@ -67,31 +49,10 @@ class ConfigRunTestCase(test.CdistTestCase): self.temp_dir = self.mkdtemp() self.local_dir = os.path.join(self.temp_dir, "local") - self.hostdir = cdist.str_hash(self.target_host[0]) - self.host_base_path = os.path.join(self.local_dir, self.hostdir) - os.makedirs(self.host_base_path) + os.mkdir(self.local_dir) self.local = cdist.exec.local.Local( target_host=self.target_host, - target_host_tags=self.target_host_tags, - base_root_path=self.host_base_path, - host_dir_name=self.hostdir) - - # Setup test objects - self.object_base_path = op.join(self.temp_dir, 'object') - - 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.create() - self.objects.append(cdist_object) - - self.object_index = dict((o.name, o) for o in self.objects) - self.object_names = [o.name for o in self.objects] + base_path=self.local_dir) self.remote_dir = os.path.join(self.temp_dir, "remote") os.mkdir(self.remote_dir) @@ -99,15 +60,17 @@ class ConfigRunTestCase(test.CdistTestCase): target_host=self.target_host, remote_copy=self.remote_copy, remote_exec=self.remote_exec, - base_path=self.remote_dir, - stdout_base_path=self.local.stdout_base_path, - stderr_base_path=self.local.stderr_base_path) + base_path=self.remote_dir) - self.local.object_path = self.object_base_path - self.local.type_path = type_base_path + self.local.object_path = object_base_path + self.local.type_path = type_base_path self.config = cdist.config.Config(self.local, self.remote) + self.objects = list(core.CdistObject.list_objects(object_base_path, type_base_path)) + self.object_index = dict((o.name, o) for o in self.objects) + self.object_names = [o.name for o in self.objects] + def tearDown(self): for o in self.objects: o.requirements = [] @@ -116,29 +79,15 @@ class ConfigRunTestCase(test.CdistTestCase): os.environ = self.orig_environ shutil.rmtree(self.temp_dir) - def assertRaisesCdistObjectError(self, original_error, callable_obj): - """ - Test if a raised CdistObjectError was caused by the given - original_error. - """ - with self.assertRaises(original_error): - try: - callable_obj() - except cdist.CdistObjectError as e: - if e.original_error: - raise e.original_error - else: - raise - 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) @@ -146,11 +95,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) @@ -159,140 +108,51 @@ 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] - self.assertRaisesCdistObjectError( - cdist.UnresolvableRequirementsError, - self.config.iterate_until_finished) + with self.assertRaises(cdist.UnresolvableRequirementsError): + self.config.iterate_until_finished() def test_missing_requirements(self): """Throw an error if requiring something non-existing""" first = self.object_index['__first/man'] first.requirements = ['__first/not/exist'] - self.assertRaisesCdistObjectError( - cdist.UnresolvableRequirementsError, - self.config.iterate_until_finished) + with self.assertRaises(cdist.UnresolvableRequirementsError): + self.config.iterate_until_finished() def test_requirement_broken_type(self): """Unknown type should be detected in the resolving process""" first = self.object_index['__first/man'] first.requirements = ['__nosuchtype/not/exist'] - self.assertRaisesCdistObjectError( - cdist.core.cdist_type.InvalidTypeError, - self.config.iterate_until_finished) + with self.assertRaises(cdist.core.cdist_type.NoSuchTypeError): + self.config.iterate_until_finished() def test_requirement_singleton_where_no_singleton(self): """Missing object id should be detected in the resolving process""" first = self.object_index['__first/man'] first.requirements = ['__first'] - self.assertRaisesCdistObjectError( - cdist.core.cdist_object.MissingObjectIdError, - self.config.iterate_until_finished) + 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, - target_host_tags=self.target_host_tags, - base_root_path=self.host_base_path, - host_dir_name=self.hostdir, - # 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]) + 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 ] ) dryrun = cdist.config.Config(drylocal, self.remote, dry_run=True) dryrun.run() # if we are here, dryrun works like expected - - def test_deps_resolver(self): - """Test to show dependency resolver warning message.""" - local = cdist.exec.local.Local( - target_host=self.target_host, - target_host_tags=self.target_host_tags, - base_root_path=self.host_base_path, - host_dir_name=self.hostdir, - exec_path=os.path.abspath(os.path.join( - my_dir, '../../../scripts/cdist')), - initial_manifest=os.path.join( - fixtures, 'manifest/init-deps-resolver'), - add_conf_dirs=[fixtures]) - - # dry_run is ok for dependency testing - config = cdist.config.Config(local, self.remote, dry_run=True) - config.run() - - def test_graph_check_cycle_empty(self): - graph = {} - has_cycle, path = cdist.config.graph_check_cycle(graph) - self.assertFalse(has_cycle) - - def test_graph_check_cycle_1(self): - # - # a -> b -> c - # | - # +--> d -> e - graph = { - 'a': ['b', ], - 'b': ['c', 'd', ], - 'd': ['e', ], - } - has_cycle, path = cdist.config.graph_check_cycle(graph) - self.assertFalse(has_cycle) - - def test_graph_check_cycle_2(self): - # - # a -> b -> c - # /\ | - # \ | - # +-------+ - graph = { - 'a': ['b', ], - 'b': ['c', ], - 'c': ['a', ], - } - has_cycle, path = cdist.config.graph_check_cycle(graph) - self.assertTrue(has_cycle) - self.assertGreater(path.count(path[-1]), 1) - - def test_graph_check_cycle_3(self): - # - # a -> b -> c - # \ \ - # \ +--> g - # \ /\ - # \ /| - # +-> d -> e | - # \ | - # + --> f - # - # h -> i --> j - # | /\ | - # \/ | \/ - # n m <- k - graph = { - 'a': ['b', 'd', ], - 'b': ['c', ], - 'c': ['g', ], - 'd': ['e', 'f', ], - 'e': ['g', ], - 'f': ['g', ], - 'h': ['i', 'n', ], - 'i': ['j', ], - 'j': ['k', ], - 'k': ['m', ], - 'm': ['i', ], - } - has_cycle, path = cdist.config.graph_check_cycle(graph) - self.assertTrue(has_cycle) - self.assertGreater(path.count(path[-1]), 1) - + # 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 @@ -304,8 +164,3 @@ class ConfigRunTestCase(test.CdistTestCase): # first.requirements = ['__singleton_test/foo'] # with self.assertRaises(cdist.core.?????): # self.config.iterate_until_finished() - -if __name__ == "__main__": - import unittest - - unittest.main() diff --git a/cdist/test/config/fixtures/manifest/init-deps-resolver b/cdist/test/config/fixtures/manifest/init-deps-resolver deleted file mode 100644 index f67ab61c..00000000 --- a/cdist/test/config/fixtures/manifest/init-deps-resolver +++ /dev/null @@ -1,8 +0,0 @@ -__a a -require="__e/e" __b b -require="__f/f" __c c -__e e -__f f -require="__c/c" __d d -__g g -__h h diff --git a/cdist/test/config/fixtures/type/__g/manifest b/cdist/test/config/fixtures/type/__g/manifest deleted file mode 100644 index 107dbda4..00000000 --- a/cdist/test/config/fixtures/type/__g/manifest +++ /dev/null @@ -1 +0,0 @@ -require="__c/c __d/d" __a a diff --git a/cdist/test/config/fixtures/type/__h/manifest b/cdist/test/config/fixtures/type/__h/manifest deleted file mode 100644 index ce3d8fb7..00000000 --- a/cdist/test/config/fixtures/type/__h/manifest +++ /dev/null @@ -1,3 +0,0 @@ -# require="__b/b" __a a -require="__j/j" __i i -__j j diff --git a/cdist/test/config/fixtures/type/__j/.keep b/cdist/test/config/fixtures/type/__j/.keep deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/test/configuration/__init__.py b/cdist/test/configuration/__init__.py deleted file mode 100644 index 182868a6..00000000 --- a/cdist/test/configuration/__init__.py +++ /dev/null @@ -1,1415 +0,0 @@ -# -*- coding: utf-8 -*- -# -# 2017 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 configparser -import os -import multiprocessing -import cdist.configuration as cc -import os.path as op -import argparse -from cdist import test -import cdist.argparse as cap -import logging - -my_dir = op.abspath(op.dirname(__file__)) -fixtures = op.join(my_dir, 'fixtures') -interpolation_config_file = op.join(fixtures, "interpolation-test.cfg") - - -def newConfigParser(): - return configparser.ConfigParser(interpolation=None) - - -class ConfigurationOptionsTestCase(test.CdistTestCase): - - def test_OptionBase(self): - option = cc.OptionBase('test') - test_cases = ( - ([], [], True, None, ), - (['spam', 'eggs', ], [], True, ['spam', 'eggs', ], ), - ([], ['spam', 'eggs', ], True, ['spam', 'eggs', ], ), - ( - ['spam', 'eggs', ], - ['ham', 'spamspam', ], - True, - ['spam', 'eggs', 'ham', 'spamspam', ], - ), - (['spam', 'eggs', ], 'spam:eggs', True, 'spam:eggs', ), - ('spam:eggs', ['spam', 'eggs', ], True, ['spam', 'eggs', ], ), - ('spam', 'eggs', True, 'eggs', ), - - (['spam', 'eggs', ], 'spam:eggs', True, 'spam:eggs', ), - - ('spam:eggs', ['spam', 'eggs', ], False, ['spam', 'eggs', ], ), - ('spam', 'eggs', False, 'eggs', ), - ( - ['spam', 'eggs', ], - ['ham', 'spamspam', ], - False, - ['ham', 'spamspam', ], - ), - ) - for currval, newval, update_appends, expected in test_cases: - self.assertEqual( - option.update_value(currval, newval, - update_appends=update_appends), - expected) - - def test_StringOption(self): - option = cc.StringOption('test') - self.assertIsNone(option.translate('')) - self.assertEqual(option.translate('spam'), 'spam') - converter = option.get_converter() - self.assertEqual(converter('spam'), 'spam') - self.assertIsNone(converter('')) - - def test_BooleanOption(self): - option = cc.BooleanOption('test') - for x in cc.BooleanOption.BOOLEAN_STATES: - self.assertEqual(option.translate(x), - cc.BooleanOption.BOOLEAN_STATES[x]) - converter = option.get_converter() - self.assertRaises(ValueError, converter, 'of') - for x in cc.BooleanOption.BOOLEAN_STATES: - self.assertEqual(converter(x), cc.BooleanOption.BOOLEAN_STATES[x]) - - def test_IntOption(self): - option = cc.IntOption('test') - converter = option.get_converter() - self.assertRaises(ValueError, converter, 'x') - for x in range(-5, 10): - self.assertEqual(converter(str(x)), x) - - def test_LowerBoundIntOption(self): - option = cc.LowerBoundIntOption('test', -1) - converter = option.get_converter() - self.assertRaises(ValueError, converter, -2) - for x in range(-1, 10): - self.assertEqual(converter(str(x)), x) - - def test_SpecialCasesLowerBoundIntOption(self): - special_cases = { - -1: 8, - -2: 10, - } - option = cc.SpecialCasesLowerBoundIntOption('test', -1, special_cases) - for x in special_cases: - self.assertEqual(option.translate(x), special_cases[x]) - - def test_SelectOption(self): - valid_values = ('spam', 'eggs', 'ham', ) - option = cc.SelectOption('test', valid_values) - converter = option.get_converter() - self.assertRaises(ValueError, converter, 'spamspam') - for x in valid_values: - self.assertEqual(converter(x), x) - - def test_DelimitedValuesOption(self): - option = cc.DelimitedValuesOption('test', ':') - converter = option.get_converter() - value = 'spam:eggs::ham' - self.assertEqual(converter(value), ['spam', 'eggs', 'ham', ]) - self.assertIsNone(converter('')) - - def test_LogLevelOption(self): - option = cc.LogLevelOption() - converter = option.get_converter() - value = str(logging.DEBUG) - conv_val = converter(value) - self.assertEqual(conv_val, cap.VERBOSE_DEBUG) - value = str(logging.INFO) - conv_val = converter(value) - self.assertEqual(conv_val, cap.VERBOSE_INFO) - for value in ('11', '80', 'a'): - self.assertRaises(ValueError, converter, value) - - -class ConfigurationTestCase(test.CdistTestCase): - - def setUp(self): - # Create test config file. - config = newConfigParser() - config['GLOBAL'] = { - 'beta': 'off', - 'local_shell': '/bin/sh', - 'remote_shell': '/bin/sh', - 'inventory_dir': '', - 'cache_path_pattern': '', - 'conf_dir': '', - 'init_manifest': '', - 'out_path': '', - 'remote_out_path': '', - 'remote_copy': '', - 'remote_exec': '', - 'jobs': '0', - 'parallel': '-1', - 'verbosity': 'INFO', - 'archiving': 'none', - } - config_custom = newConfigParser() - config_custom['GLOBAL'] = { - 'parallel': '4', - 'archiving': 'txz', - } - - config_custom2 = newConfigParser() - config_custom2['GLOBAL'] = { - 'parallel': '16', - 'archiving': 'tbz2', - 'remote_copy': 'myscp', - } - - self.expected_config_dict = { - 'GLOBAL': { - 'beta': False, - 'local_shell': '/bin/sh', - 'remote_shell': '/bin/sh', - 'inventory_dir': None, - 'cache_path_pattern': None, - 'conf_dir': None, - 'init_manifest': None, - 'out_path': None, - 'remote_out_path': None, - 'remote_copy': None, - 'remote_exec': None, - 'jobs': 0, - 'parallel': multiprocessing.cpu_count(), - 'verbosity': cap.VERBOSE_INFO, - 'archiving': None, - }, - } - - self.config_file = os.path.join(fixtures, 'cdist.cfg') - with open(self.config_file, 'w') as f: - config.write(f) - - self.custom_config_file = os.path.join(fixtures, 'cdist_custom.cfg') - with open(self.custom_config_file, 'w') as f: - config_custom.write(f) - - self.custom_config_file2 = os.path.join(fixtures, 'cdist_custom2.cfg') - with open(self.custom_config_file2, 'w') as f: - config_custom2.write(f) - - config['TEST'] = {} - self.invalid_config_file1 = os.path.join(fixtures, - 'cdist_invalid1.cfg') - with open(self.invalid_config_file1, 'w') as f: - config.write(f) - - del config['TEST'] - config['GLOBAL']['test'] = 'test' - self.invalid_config_file2 = os.path.join(fixtures, - 'cdist_invalid2.cfg') - with open(self.invalid_config_file2, 'w') as f: - config.write(f) - - del config['GLOBAL']['test'] - config['GLOBAL']['archiving'] = 'zip' - self.invalid_config_file3 = os.path.join(fixtures, - 'cdist_invalid3.cfg') - with open(self.invalid_config_file3, 'w') as f: - config.write(f) - - self.maxDiff = None - - def tearDown(self): - os.remove(self.config_file) - os.remove(self.custom_config_file) - os.remove(self.custom_config_file2) - os.remove(self.invalid_config_file1) - os.remove(self.invalid_config_file2) - os.remove(self.invalid_config_file3) - - # remove files from tests - global_config_file = os.path.join(fixtures, 'cdist-global.cfg') - local_config_file = os.path.join(fixtures, 'cdist-local.cfg') - custom_config_file = os.path.join(fixtures, 'cdist-custom.cfg') - if os.path.exists(global_config_file): - os.remove(global_config_file) - if os.path.exists(local_config_file): - os.remove(local_config_file) - if os.path.exists(custom_config_file): - os.remove(custom_config_file) - - def test_singleton(self): - x = cc.Configuration(None, env={}, config_files=()) - args = argparse.Namespace() - args.a = 'a' - y = cc.Configuration(args, env={}, config_files=()) - self.assertIs(x, y) - - def test_non_singleton(self): - x = cc.Configuration(None, env={}, config_files=(), singleton=False) - args = argparse.Namespace() - args.a = 'a' - y = cc.Configuration(args, env={}, config_files=(), singleton=False) - self.assertIsNot(x, y) - - def test_read_config_file(self): - config = cc.Configuration(None, env={}, config_files=()) - d = config._read_config_file(self.config_file) - self.assertEqual(d, self.expected_config_dict) - - for x in range(1, 4): - config_file = getattr(self, 'invalid_config_file' + str(x)) - with self.assertRaises(ValueError): - config._read_config_file(config_file) - - def test_read_env_var_config(self): - config = cc.Configuration(None, env={}, config_files=()) - env = { - 'a': 'a', - 'CDIST_BETA': '1', - 'CDIST_PATH': '/usr/local/cdist:~/.cdist', - } - expected = { - 'beta': True, - 'conf_dir': ['/usr/local/cdist', '~/.cdist', ], - } - section = 'GLOBAL' - d = config._read_env_var_config(env, section) - self.assertEqual(d, expected) - - del env['CDIST_BETA'] - del expected['beta'] - d = config._read_env_var_config(env, section) - self.assertEqual(d, expected) - - def test_read_args_config(self): - config = cc.Configuration(None, env={}, config_files=()) - args = argparse.Namespace() - args.beta = False - args.conf_dir = ['/usr/local/cdist1', ] - args.verbose = 3 - args.tag = 'test' - - expected = { - 'conf_dir': ['/usr/local/cdist1', ], - 'verbosity': 3, - 'beta': False, - } - args_dict = vars(args) - d = config._read_args_config(args_dict) - self.assertEqual(d, expected) - self.assertNotEqual(d, args_dict) - - def test_update_config_dict(self): - config = { - 'GLOBAL': { - 'conf_dir': ['/usr/local/cdist', ], - 'parallel': -1, - }, - } - newconfig = { - 'GLOBAL': { - 'conf_dir': ['~/.cdist', ], - 'parallel': 2, - 'local_shell': '/usr/local/bin/sh', - }, - } - expected = { - 'GLOBAL': { - 'conf_dir': ['/usr/local/cdist', '~/.cdist', ], - 'parallel': 2, - 'local_shell': '/usr/local/bin/sh', - }, - } - configuration = cc.Configuration(None, env={}, config_files=()) - configuration._update_config_dict(config, newconfig, - update_appends=True) - self.assertEqual(config, expected) - expected = { - 'GLOBAL': { - 'conf_dir': ['~/.cdist', ], - 'parallel': 2, - 'local_shell': '/usr/local/bin/sh', - }, - } - configuration._update_config_dict(config, newconfig, - update_appends=False) - self.assertEqual(config, expected) - - def test_update_config_dict_section(self): - config = { - 'GLOBAL': { - 'conf_dir': ['/usr/local/cdist', ], - 'parallel': -1, - }, - } - newconfig = { - 'conf_dir': ['~/.cdist', ], - 'parallel': 2, - 'local_shell': '/usr/local/bin/sh', - } - expected = { - 'GLOBAL': { - 'conf_dir': ['/usr/local/cdist', '~/.cdist', ], - 'parallel': 2, - 'local_shell': '/usr/local/bin/sh', - }, - } - configuration = cc.Configuration(None, env={}, config_files=()) - configuration._update_config_dict_section('GLOBAL', config, newconfig, - update_appends=True) - self.assertEqual(config, expected) - expected = { - 'GLOBAL': { - 'conf_dir': ['~/.cdist', ], - 'parallel': 2, - 'local_shell': '/usr/local/bin/sh', - }, - } - configuration._update_config_dict_section('GLOBAL', config, newconfig, - update_appends=False) - self.assertEqual(config, expected) - - def test_configuration1(self): - env = { - 'PATH': '/usr/local/bin:/usr/bin:/bin', - 'TEST': 'test', - } - args = argparse.Namespace() - expected_config_dict = { - 'GLOBAL': { - 'verbosity': 0, - }, - } - - # bypass singleton so we can test further - cc.Configuration.instance = None - configuration = cc.Configuration(args, env=env, - config_files=('cdist.cfg')) - self.assertIsNotNone(configuration.args) - self.assertIsNotNone(configuration.env) - self.assertIsNotNone(configuration.config_files) - self.assertEqual(configuration.config, expected_config_dict) - - def test_configuration2(self): - env = { - 'PATH': '/usr/local/bin:/usr/bin:/bin', - 'TEST': 'test', - } - args = argparse.Namespace() - - config = newConfigParser() - config['GLOBAL'] = { - 'beta': 'off', - 'local_shell': '/bin/sh', - 'remote_shell': '/bin/sh', - 'inventory_dir': '', - 'cache_path_pattern': '', - 'conf_dir': '', - 'init_manifest': '', - 'out_path': '', - 'remote_out_path': '', - 'remote_copy': '', - 'remote_exec': '', - 'jobs': '0', - 'parallel': '-1', - 'verbosity': 'INFO', - 'archiving': 'none', - } - - global_config_file = os.path.join(fixtures, 'cdist-global.cfg') - with open(global_config_file, 'w') as f: - config.write(f) - - expected_config_dict = { - 'GLOBAL': { - 'beta': False, - 'local_shell': '/bin/sh', - 'remote_shell': '/bin/sh', - 'inventory_dir': None, - 'cache_path_pattern': None, - 'conf_dir': None, - 'init_manifest': None, - 'out_path': None, - 'remote_out_path': None, - 'remote_copy': None, - 'remote_exec': None, - 'jobs': 0, - 'parallel': multiprocessing.cpu_count(), - 'verbosity': cap.VERBOSE_INFO, - 'archiving': None, - }, - } - config_files = (global_config_file, ) - - # bypass singleton so we can test further - cc.Configuration.instance = None - - configuration = cc.Configuration(args, env=env, - config_files=config_files) - self.assertEqual(configuration.config, expected_config_dict) - - def test_configuration3(self): - env = { - 'PATH': '/usr/local/bin:/usr/bin:/bin', - 'TEST': 'test', - } - args = argparse.Namespace() - - config = newConfigParser() - config['GLOBAL'] = { - 'beta': 'off', - 'local_shell': '/bin/sh', - 'remote_shell': '/bin/sh', - 'inventory_dir': '', - 'cache_path_pattern': '', - 'conf_dir': '', - 'init_manifest': '', - 'out_path': '', - 'remote_out_path': '', - 'remote_copy': '', - 'remote_exec': '', - 'jobs': '0', - 'parallel': '-1', - 'verbosity': 'INFO', - 'archiving': 'none', - } - - global_config_file = os.path.join(fixtures, 'cdist-global.cfg') - with open(global_config_file, 'w') as f: - config.write(f) - - config = newConfigParser() - config['GLOBAL'] = { - 'beta': 'on', - 'local_shell': '/usr/bin/sh', - 'remote_shell': '/usr/bin/sh', - 'inventory_dir': '/var/db/cdist/inventory', - 'conf_dir': '/opt/cdist', - 'remote_copy': 'myscp', - 'remote_exec': 'myexec', - 'parallel': '-1', - 'archiving': 'tar', - } - - local_config_file = os.path.join(fixtures, 'cdist-local.cfg') - with open(local_config_file, 'w') as f: - config.write(f) - - expected_config_dict = { - 'GLOBAL': { - 'beta': True, - 'local_shell': '/usr/bin/sh', - 'remote_shell': '/usr/bin/sh', - 'inventory_dir': '/var/db/cdist/inventory', - 'cache_path_pattern': None, - 'conf_dir': ['/opt/cdist', ], - 'init_manifest': None, - 'out_path': None, - 'remote_out_path': None, - 'remote_copy': 'myscp', - 'remote_exec': 'myexec', - 'jobs': 0, - 'parallel': multiprocessing.cpu_count(), - 'verbosity': cap.VERBOSE_INFO, - 'archiving': 'tar', - }, - } - config_files = (global_config_file, local_config_file, ) - - # bypass singleton so we can test further - cc.Configuration.instance = None - - configuration = cc.Configuration(args, env=env, - config_files=config_files) - self.assertEqual(configuration.config, expected_config_dict) - - def test_configuration4(self): - env = { - 'PATH': '/usr/local/bin:/usr/bin:/bin', - 'TEST': 'test', - 'CDIST_PATH': '/opt/cdist/conf:/usr/local/share/cdist/conf', - 'REMOTE_COPY': 'scp', - 'REMOTE_EXEC': 'ssh', - 'CDIST_BETA': '1', - 'CDIST_LOCAL_SHELL': '/usr/bin/sh', - 'CDIST_REMOTE_SHELL': '/usr/bin/sh', - } - args = argparse.Namespace() - - config = newConfigParser() - config['GLOBAL'] = { - 'beta': 'off', - 'local_shell': '/bin/sh', - 'remote_shell': '/bin/sh', - 'inventory_dir': '', - 'cache_path_pattern': '', - 'conf_dir': '', - 'init_manifest': '', - 'out_path': '', - 'remote_out_path': '', - 'remote_copy': '', - 'remote_exec': '', - 'jobs': '0', - 'parallel': '-1', - 'verbosity': 'INFO', - 'archiving': 'none', - } - - global_config_file = os.path.join(fixtures, 'cdist-global.cfg') - with open(global_config_file, 'w') as f: - config.write(f) - - expected_config_dict = { - 'GLOBAL': { - 'beta': True, - 'local_shell': '/usr/bin/sh', - 'remote_shell': '/usr/bin/sh', - 'inventory_dir': None, - 'cache_path_pattern': None, - 'conf_dir': [ - '/opt/cdist/conf', - '/usr/local/share/cdist/conf', - ], - 'init_manifest': None, - 'out_path': None, - 'remote_out_path': None, - 'remote_copy': None, - 'remote_exec': None, - 'jobs': 0, - 'parallel': multiprocessing.cpu_count(), - 'verbosity': cap.VERBOSE_INFO, - 'archiving': None, - }, - } - config_files = (global_config_file, ) - - # bypass singleton so we can test further - cc.Configuration.instance = None - - configuration = cc.Configuration(args, env=env, - config_files=config_files) - self.assertEqual(configuration.config, expected_config_dict) - - def test_configuration5(self): - env = { - 'PATH': '/usr/local/bin:/usr/bin:/bin', - 'TEST': 'test', - 'CDIST_PATH': '/opt/cdist/conf:/usr/local/share/cdist/conf', - 'REMOTE_COPY': 'scp', - 'REMOTE_EXEC': 'ssh', - 'CDIST_BETA': '1', - 'CDIST_LOCAL_SHELL': '/usr/bin/sh', - 'CDIST_REMOTE_SHELL': '/usr/bin/sh', - } - args = argparse.Namespace() - - config = newConfigParser() - config['GLOBAL'] = { - 'beta': 'off', - 'local_shell': '/bin/sh', - 'remote_shell': '/bin/sh', - 'inventory_dir': '', - 'cache_path_pattern': '', - 'conf_dir': '', - 'init_manifest': '', - 'out_path': '', - 'remote_out_path': '', - 'remote_copy': '', - 'remote_exec': '', - 'jobs': '0', - 'parallel': '-1', - 'verbosity': 'INFO', - 'archiving': 'none', - } - - global_config_file = os.path.join(fixtures, 'cdist-global.cfg') - with open(global_config_file, 'w') as f: - config.write(f) - - config = newConfigParser() - config['GLOBAL'] = { - 'beta': 'on', - 'local_shell': '/usr/bin/sh', - 'remote_shell': '/usr/bin/sh', - 'inventory_dir': '/var/db/cdist/inventory', - 'conf_dir': '/opt/cdist', - 'remote_copy': 'myscp', - 'remote_exec': 'myexec', - 'parallel': '-1', - 'archiving': 'tar', - } - - local_config_file = os.path.join(fixtures, 'cdist-local.cfg') - with open(local_config_file, 'w') as f: - config.write(f) - - expected_config_dict = { - 'GLOBAL': { - 'beta': True, - 'local_shell': '/usr/bin/sh', - 'remote_shell': '/usr/bin/sh', - 'inventory_dir': '/var/db/cdist/inventory', - 'cache_path_pattern': None, - 'conf_dir': [ - '/opt/cdist/conf', - '/usr/local/share/cdist/conf', - ], - 'init_manifest': None, - 'out_path': None, - 'remote_out_path': None, - 'remote_copy': 'myscp', - 'remote_exec': 'myexec', - 'jobs': 0, - 'parallel': multiprocessing.cpu_count(), - 'verbosity': cap.VERBOSE_INFO, - 'archiving': 'tar', - }, - } - config_files = (global_config_file, local_config_file, ) - - # bypass singleton so we can test further - cc.Configuration.instance = None - - configuration = cc.Configuration(args, env=env, - config_files=config_files) - self.assertEqual(configuration.config, expected_config_dict) - - def test_update_defaults_for_unset(self): - config = { - 'GLOBAL': { - }, - } - expected_config = { - 'GLOBAL': { - 'verbosity': 0, - }, - } - cfg = cc.Configuration(None, env={}, config_files=()) - cfg._update_defaults_for_unset(config) - self.assertEqual(config, expected_config) - - def test_configuration6(self): - env = { - 'PATH': '/usr/local/bin:/usr/bin:/bin', - 'TEST': 'test', - 'CDIST_PATH': '/opt/cdist/conf:/usr/local/share/cdist/conf', - 'REMOTE_COPY': 'scp', - 'REMOTE_EXEC': 'ssh', - 'CDIST_BETA': '1', - 'CDIST_LOCAL_SHELL': '/usr/bin/sh', - 'CDIST_REMOTE_SHELL': '/usr/bin/sh', - } - args = argparse.Namespace() - - config = newConfigParser() - config['GLOBAL'] = { - 'beta': 'off', - 'local_shell': '/bin/sh', - 'remote_shell': '/bin/sh', - 'inventory_dir': '', - 'cache_path_pattern': '', - 'conf_dir': '', - 'init_manifest': '', - 'out_path': '', - 'remote_out_path': '', - 'remote_copy': '', - 'remote_exec': '', - 'jobs': '0', - 'parallel': '-1', - 'verbosity': 'INFO', - 'archiving': 'none', - } - - global_config_file = os.path.join(fixtures, 'cdist-global.cfg') - with open(global_config_file, 'w') as f: - config.write(f) - - config = newConfigParser() - config['GLOBAL'] = { - 'beta': 'on', - 'local_shell': '/usr/bin/sh', - 'remote_shell': '/usr/bin/sh', - 'inventory_dir': '/var/db/cdist/inventory', - 'conf_dir': '/opt/cdist', - 'remote_copy': 'myscp', - 'remote_exec': 'myexec', - 'parallel': '-1', - 'archiving': 'tar', - } - - local_config_file = os.path.join(fixtures, 'cdist-local.cfg') - with open(local_config_file, 'w') as f: - config.write(f) - - args.inventory_dir = '/opt/sysadmin/cdist/inventory' - args.conf_dir = ['/opt/sysadmin/cdist/conf', ] - args.manifest = '/opt/sysadmin/cdist/conf/manifest/init' - args.jobs = 10 - args.verbose = None - - expected_config_dict = { - 'GLOBAL': { - 'beta': True, - 'local_shell': '/usr/bin/sh', - 'remote_shell': '/usr/bin/sh', - 'inventory_dir': '/opt/sysadmin/cdist/inventory', - 'cache_path_pattern': None, - 'conf_dir': [ - '/opt/cdist/conf', - '/usr/local/share/cdist/conf', - '/opt/sysadmin/cdist/conf', - ], - 'init_manifest': '/opt/sysadmin/cdist/conf/manifest/init', - 'out_path': None, - 'remote_out_path': None, - 'remote_copy': 'myscp', - 'remote_exec': 'myexec', - 'jobs': 10, - 'parallel': multiprocessing.cpu_count(), - 'verbosity': cap.VERBOSE_INFO, - 'archiving': 'tar', - }, - } - config_files = (global_config_file, local_config_file, ) - - # bypass singleton so we can test further - cc.Configuration.instance = None - - configuration = cc.Configuration(args, env=env, - config_files=config_files) - self.assertEqual(configuration.config, expected_config_dict) - - def test_configuration7(self): - env = { - 'PATH': '/usr/local/bin:/usr/bin:/bin', - 'TEST': 'test', - 'CDIST_PATH': '/opt/cdist/conf:/usr/local/share/cdist/conf', - 'REMOTE_COPY': 'scp', - 'REMOTE_EXEC': 'ssh', - 'CDIST_BETA': '1', - 'CDIST_LOCAL_SHELL': '/usr/bin/sh', - 'CDIST_REMOTE_SHELL': '/usr/bin/sh', - } - args = argparse.Namespace() - - config = newConfigParser() - config['GLOBAL'] = { - 'beta': 'off', - 'local_shell': '/bin/sh', - 'remote_shell': '/bin/sh', - 'inventory_dir': '', - 'cache_path_pattern': '', - 'conf_dir': '', - 'init_manifest': '', - 'out_path': '', - 'remote_out_path': '', - 'remote_copy': '', - 'remote_exec': '', - 'jobs': '0', - 'parallel': '-1', - 'verbosity': 'INFO', - 'archiving': 'none', - } - - global_config_file = os.path.join(fixtures, 'cdist-global.cfg') - with open(global_config_file, 'w') as f: - config.write(f) - - config = newConfigParser() - config['GLOBAL'] = { - 'beta': 'on', - 'local_shell': '/usr/bin/sh', - 'remote_shell': '/usr/bin/sh', - 'inventory_dir': '/var/db/cdist/inventory', - 'conf_dir': '/opt/cdist', - 'remote_copy': 'myscp', - 'remote_exec': 'myexec', - 'parallel': '-1', - 'archiving': 'tar', - } - - local_config_file = os.path.join(fixtures, 'cdist-local.cfg') - with open(local_config_file, 'w') as f: - config.write(f) - - config = newConfigParser() - config['GLOBAL'] = { - 'conf_dir': '/opt/conf/cdist', - 'remote_copy': 'scpcustom', - 'remote_exec': 'sshcustom', - 'parallel': '15', - 'archiving': 'txz', - } - - custom_config_file = os.path.join(fixtures, 'cdist-custom.cfg') - with open(custom_config_file, 'w') as f: - config.write(f) - - expected_config_dict = { - 'GLOBAL': { - 'beta': True, - 'local_shell': '/usr/bin/sh', - 'remote_shell': '/usr/bin/sh', - 'inventory_dir': '/var/db/cdist/inventory', - 'cache_path_pattern': None, - 'conf_dir': [ - '/opt/conf/cdist', - ], - 'init_manifest': None, - 'out_path': None, - 'remote_out_path': None, - 'remote_copy': 'scpcustom', - 'remote_exec': 'sshcustom', - 'jobs': 0, - 'parallel': 15, - 'verbosity': cap.VERBOSE_INFO, - 'archiving': 'txz', - }, - } - - config_files = (global_config_file, local_config_file, ) - - args.config_file = custom_config_file - - # bypass singleton so we can test further - cc.Configuration.instance = None - - configuration = cc.Configuration(args, env=env, - config_files=config_files) - self.assertEqual(configuration.config, expected_config_dict) - - def test_configuration8(self): - env = { - 'PATH': '/usr/local/bin:/usr/bin:/bin', - 'TEST': 'test', - 'CDIST_PATH': '/opt/cdist/conf:/usr/local/share/cdist/conf', - 'REMOTE_COPY': 'scp', - 'REMOTE_EXEC': 'ssh', - 'CDIST_BETA': '1', - 'CDIST_LOCAL_SHELL': '/usr/bin/sh', - 'CDIST_REMOTE_SHELL': '/usr/bin/sh', - } - args = argparse.Namespace() - - config = newConfigParser() - config['GLOBAL'] = { - 'beta': 'off', - 'local_shell': '/bin/sh', - 'remote_shell': '/bin/sh', - 'inventory_dir': '', - 'cache_path_pattern': '', - 'conf_dir': '', - 'init_manifest': '', - 'out_path': '', - 'remote_out_path': '', - 'remote_copy': '', - 'remote_exec': '', - 'jobs': '0', - 'parallel': '-1', - 'verbosity': 'INFO', - 'archiving': 'none', - } - - global_config_file = os.path.join(fixtures, 'cdist-global.cfg') - with open(global_config_file, 'w') as f: - config.write(f) - - config = newConfigParser() - config['GLOBAL'] = { - 'beta': 'on', - 'local_shell': '/usr/bin/sh', - 'remote_shell': '/usr/bin/sh', - 'inventory_dir': '/var/db/cdist/inventory', - 'conf_dir': '/opt/cdist', - 'remote_copy': 'myscp', - 'remote_exec': 'myexec', - 'parallel': '-1', - 'archiving': 'tar', - } - - local_config_file = os.path.join(fixtures, 'cdist-local.cfg') - with open(local_config_file, 'w') as f: - config.write(f) - - config = newConfigParser() - config['GLOBAL'] = { - 'conf_dir': '/opt/conf/cdist', - 'remote_copy': 'scpcustom', - 'remote_exec': 'sshcustom', - 'parallel': '15', - 'archiving': 'txz', - } - - custom_config_file = os.path.join(fixtures, 'cdist-custom.cfg') - with open(custom_config_file, 'w') as f: - config.write(f) - - expected_config_dict = { - 'GLOBAL': { - 'beta': True, - 'local_shell': '/usr/bin/sh', - 'remote_shell': '/usr/bin/sh', - 'inventory_dir': '/var/db/cdist/inventory', - 'cache_path_pattern': None, - 'conf_dir': [ - '/opt/conf/cdist', - ], - 'init_manifest': None, - 'out_path': None, - 'remote_out_path': None, - 'remote_copy': 'scpcustom', - 'remote_exec': 'sshcustom', - 'jobs': 0, - 'parallel': 15, - 'verbosity': cap.VERBOSE_INFO, - 'archiving': 'txz', - }, - } - - config_files = (global_config_file, local_config_file, ) - - os.environ['CDIST_CONFIG_FILE'] = custom_config_file - - # bypass singleton so we can test further - cc.Configuration.instance = None - - configuration = cc.Configuration(args, env=env, - config_files=config_files) - self.assertEqual(configuration.config, expected_config_dict) - - def test_configuration_get_args(self): - env = { - 'PATH': '/usr/local/bin:/usr/bin:/bin', - 'TEST': 'test', - 'CDIST_PATH': '/opt/cdist/conf:/usr/local/share/cdist/conf', - 'REMOTE_COPY': 'scp', - 'REMOTE_EXEC': 'ssh', - 'CDIST_BETA': '1', - 'CDIST_LOCAL_SHELL': '/usr/bin/sh', - 'CDIST_REMOTE_SHELL': '/usr/bin/sh', - } - args = argparse.Namespace() - - config = newConfigParser() - config['GLOBAL'] = { - 'beta': 'off', - 'local_shell': '/bin/sh', - 'remote_shell': '/bin/sh', - 'inventory_dir': '', - 'cache_path_pattern': '', - 'conf_dir': '', - 'init_manifest': '', - 'out_path': '', - 'remote_out_path': '', - 'remote_copy': '', - 'remote_exec': '', - 'jobs': '0', - 'parallel': '-1', - 'verbosity': 'INFO', - 'archiving': 'none', - } - - global_config_file = os.path.join(fixtures, 'cdist-global.cfg') - with open(global_config_file, 'w') as f: - config.write(f) - - config = newConfigParser() - config['GLOBAL'] = { - 'beta': 'on', - 'local_shell': '/usr/bin/sh', - 'remote_shell': '/usr/bin/sh', - 'inventory_dir': '/var/db/cdist/inventory', - 'conf_dir': '/opt/cdist', - 'remote_copy': 'myscp', - 'remote_exec': 'myexec', - 'parallel': '-1', - 'archiving': 'tar', - } - - local_config_file = os.path.join(fixtures, 'cdist-local.cfg') - with open(local_config_file, 'w') as f: - config.write(f) - - config = newConfigParser() - config['GLOBAL'] = { - 'conf_dir': '/opt/conf/cdist', - 'remote_copy': 'scpcustom', - 'remote_exec': 'sshcustom', - 'parallel': '15', - 'archiving': 'txz', - } - - custom_config_file = os.path.join(fixtures, 'cdist-custom.cfg') - with open(custom_config_file, 'w') as f: - config.write(f) - - expected_config_dict = { - 'GLOBAL': { - 'beta': True, - 'local_shell': '/usr/bin/sh', - 'remote_shell': '/usr/bin/sh', - 'inventory_dir': '/var/db/cdist/inventory', - 'cache_path_pattern': None, - 'conf_dir': [ - '/opt/conf/cdist', - ], - 'init_manifest': None, - 'out_path': None, - 'remote_out_path': None, - 'remote_copy': 'scpcustom', - 'remote_exec': 'sshcustom', - 'jobs': 0, - 'parallel': 15, - 'verbosity': cap.VERBOSE_INFO, - 'archiving': 'txz', - }, - } - - config_files = (global_config_file, local_config_file, ) - - os.environ['CDIST_CONFIG_FILE'] = custom_config_file - - # bypass singleton so we can test further - cc.Configuration.instance = None - - configuration = cc.Configuration(args, env=env, - config_files=config_files) - self.assertEqual(configuration.config, expected_config_dict) - - args = configuration.get_args() - dargs = vars(args) - expected_args = { - 'beta': True, - 'inventory_dir': '/var/db/cdist/inventory', - 'cache_path_pattern': None, - 'conf_dir': [ - '/opt/conf/cdist', - ], - 'manifest': None, - 'out_path': None, - 'remote_out_path': None, - 'remote_copy': 'scpcustom', - 'remote_exec': 'sshcustom', - 'jobs': 0, - 'parallel': 15, - 'verbose': cap.VERBOSE_INFO, - 'use_archiving': 'txz', - } - - self.assertEqual(dargs, expected_args) - - def test_configuration_empty_value_in_file(self): - config = newConfigParser() - config['GLOBAL'] = { - 'inventory_dir': '', - 'conf_dir': '', - } - - config_file = os.path.join(fixtures, 'cdist-local.cfg') - with open(config_file, 'w') as f: - config.write(f) - - expected_config_dict = { - 'GLOBAL': { - 'inventory_dir': None, - 'conf_dir': None, - 'verbosity': 0, - }, - } - - config_files = (config_file, ) - - # bypass singleton so we can test further - cc.Configuration.instance = None - - args = argparse.Namespace() - configuration = cc.Configuration(args, env={}, - config_files=config_files) - self.assertEqual(configuration.config, expected_config_dict) - - def test_configuration_cdist_log_level_env_var(self): - env = { - '__cdist_log_level': str(logging.DEBUG), - } - args = argparse.Namespace() - - expected_config_dict = { - 'GLOBAL': { - 'verbosity': cap.VERBOSE_DEBUG, - }, - } - - # bypass singleton so we can test further - cc.Configuration.instance = None - - configuration = cc.Configuration(args, env=env, - config_files=()) - self.assertEqual(configuration.config, expected_config_dict) - - # bypass singleton so we can test further - cc.Configuration.instance = None - env['__cdist_log_level'] = '80' - with self.assertRaises(ValueError): - configuration = cc.Configuration(args, env=env, - config_files=()) - - # bypass singleton so we can test further - cc.Configuration.instance = None - env['__cdist_log_level'] = 'x' - with self.assertRaises(ValueError): - configuration = cc.Configuration(args, env=env, - config_files=()) - - def test_configuration_disable_saving_output_streams1(self): - config = newConfigParser() - config['GLOBAL'] = { - 'save_output_streams': 'True', - } - - global_config_file = os.path.join(fixtures, 'cdist-global.cfg') - with open(global_config_file, 'w') as f: - config.write(f) - - expected_config_dict = { - 'GLOBAL': { - 'save_output_streams': True, - 'verbosity': 0, - }, - } - - config_files = (global_config_file, ) - - # bypass singleton so we can test further - cc.Configuration.instance = None - - args = argparse.Namespace() - args.save_output_streams = True - configuration = cc.Configuration(args, env=None, - config_files=config_files) - self.assertEqual(configuration.config, expected_config_dict) - - def test_configuration_disable_saving_output_streams2(self): - config = newConfigParser() - config['GLOBAL'] = { - 'save_output_streams': 'False', - } - - global_config_file = os.path.join(fixtures, 'cdist-global.cfg') - with open(global_config_file, 'w') as f: - config.write(f) - - expected_config_dict = { - 'GLOBAL': { - 'save_output_streams': False, - 'verbosity': 0, - }, - } - - config_files = (global_config_file, ) - - # bypass singleton so we can test further - cc.Configuration.instance = None - - args = argparse.Namespace() - args.save_output_streams = True - configuration = cc.Configuration(args, env=None, - config_files=config_files) - self.assertEqual(configuration.config, expected_config_dict) - - def test_configuration_disable_saving_output_streams3(self): - config = newConfigParser() - config['GLOBAL'] = { - 'save_output_streams': 'False', - } - - global_config_file = os.path.join(fixtures, 'cdist-global.cfg') - with open(global_config_file, 'w') as f: - config.write(f) - - expected_config_dict = { - 'GLOBAL': { - 'save_output_streams': False, - 'verbosity': 0, - }, - } - - config_files = (global_config_file, ) - - # bypass singleton so we can test further - cc.Configuration.instance = None - - args = argparse.Namespace() - args.save_output_streams = False - configuration = cc.Configuration(args, env=None, - config_files=config_files) - self.assertEqual(configuration.config, expected_config_dict) - - def test_configuration_disable_saving_output_streams4(self): - config = newConfigParser() - config['GLOBAL'] = { - 'save_output_streams': 'True', - } - - global_config_file = os.path.join(fixtures, 'cdist-global.cfg') - with open(global_config_file, 'w') as f: - config.write(f) - - expected_config_dict = { - 'GLOBAL': { - 'save_output_streams': False, - 'verbosity': 0, - }, - } - - config_files = (global_config_file, ) - - # bypass singleton so we can test further - cc.Configuration.instance = None - - args = argparse.Namespace() - args.save_output_streams = False - configuration = cc.Configuration(args, env=None, - config_files=config_files) - self.assertEqual(configuration.config, expected_config_dict) - - def test_read_config_file_with_interpolation(self): - try: - config = cc.Configuration(None, env={}, config_files=()) - d = config._read_config_file(interpolation_config_file) - val = d['GLOBAL']['cache_path_pattern'] - self.assertIsNotNone(val) - self.assertEqual(val, '%N') - except configparser.InterpolationSyntaxError as e: - self.fail("Exception should not have been raised: {}".format( - e)) - - def test_configuration_timestamping_log_1(self): - config = newConfigParser() - config['GLOBAL'] = { - 'timestamp': 'True', - } - - global_config_file = os.path.join(fixtures, 'cdist-global.cfg') - with open(global_config_file, 'w') as f: - config.write(f) - - expected_config_dict = { - 'GLOBAL': { - 'timestamp': True, - 'verbosity': 0, - }, - } - - config_files = (global_config_file, ) - - # bypass singleton so we can test further - cc.Configuration.instance = None - - args = argparse.Namespace() - args.timestamp = True - configuration = cc.Configuration(args, env=None, - config_files=config_files) - self.assertEqual(configuration.config, expected_config_dict) - - def test_configuration_timestamping_log_2(self): - config = newConfigParser() - config['GLOBAL'] = { - 'timestamp': 'False', - } - - global_config_file = os.path.join(fixtures, 'cdist-global.cfg') - with open(global_config_file, 'w') as f: - config.write(f) - - expected_config_dict = { - 'GLOBAL': { - 'timestamp': True, - 'verbosity': 0, - }, - } - - config_files = (global_config_file, ) - - # bypass singleton so we can test further - cc.Configuration.instance = None - - args = argparse.Namespace() - args.timestamp = True - configuration = cc.Configuration(args, env=None, - config_files=config_files) - self.assertEqual(configuration.config, expected_config_dict) - - def test_configuration_timestamping_log_3(self): - config = newConfigParser() - config['GLOBAL'] = { - 'timestamp': 'False', - } - - global_config_file = os.path.join(fixtures, 'cdist-global.cfg') - with open(global_config_file, 'w') as f: - config.write(f) - - expected_config_dict = { - 'GLOBAL': { - 'timestamp': False, - 'verbosity': 0, - }, - } - - config_files = (global_config_file, ) - - # bypass singleton so we can test further - cc.Configuration.instance = None - - args = argparse.Namespace() - args.timestamp = False - configuration = cc.Configuration(args, env=None, - config_files=config_files) - self.assertEqual(configuration.config, expected_config_dict) - - def test_configuration_timestamping_log_4(self): - config = newConfigParser() - config['GLOBAL'] = { - 'timestamp': 'True', - } - - global_config_file = os.path.join(fixtures, 'cdist-global.cfg') - with open(global_config_file, 'w') as f: - config.write(f) - - expected_config_dict = { - 'GLOBAL': { - 'timestamp': False, - 'verbosity': 0, - }, - } - - config_files = (global_config_file, ) - - # bypass singleton so we can test further - cc.Configuration.instance = None - - args = argparse.Namespace() - args.timestamp = False - configuration = cc.Configuration(args, env=None, - config_files=config_files) - self.assertEqual(configuration.config, expected_config_dict) - - -if __name__ == "__main__": - import unittest - - unittest.main() diff --git a/cdist/test/configuration/fixtures/.nonempty b/cdist/test/configuration/fixtures/.nonempty deleted file mode 100644 index e69de29b..00000000 diff --git a/cdist/test/configuration/fixtures/interpolation-test.cfg b/cdist/test/configuration/fixtures/interpolation-test.cfg deleted file mode 100644 index df723121..00000000 --- a/cdist/test/configuration/fixtures/interpolation-test.cfg +++ /dev/null @@ -1,2 +0,0 @@ -[GLOBAL] -cache_path_pattern = %N diff --git a/cdist/test/emulator/__init__.py b/cdist/test/emulator/__init__.py index 5691093c..870d6245 100644 --- a/cdist/test/emulator/__init__.py +++ b/cdist/test/emulator/__init__.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- # # 2010-2011 Steven Armstrong (steven-cdist at armstrong.cc) -# 2012-2015 Nico Schottelius (nico-cdist at schottelius.org) +# 2012-2013 Nico Schottelius (nico-cdist at schottelius.org) # 2014 Daniel Heule (hda at sfs.biz) # # This file is part of cdist. @@ -27,7 +27,6 @@ import shutil import string import filecmp import random -import logging import cdist from cdist import test @@ -41,7 +40,6 @@ 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): @@ -49,46 +47,33 @@ class EmulatorTestCase(test.CdistTestCase): handle, self.script = self.mkstemp(dir=self.temp_dir) os.close(handle) base_path = self.temp_dir - hostdir = cdist.str_hash(self.target_host[0]) - host_base_path = os.path.join(base_path, hostdir) self.local = local.Local( target_host=self.target_host, - target_host_tags=self.target_host_tags, - base_root_path=host_base_path, - host_dir_name=hostdir, + 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 - if '__cdist_log_level' in self.env: - del self.env['__cdist_log_level'] def tearDown(self): shutil.rmtree(self.temp_dir) -# def test_missing_object_marker_variable(self): -# del self.env['__cdist_object_marker'] -# self.assertRaises(KeyError, emulator.Emulator, argv, env=self.env) - def test_nonexistent_type_exec(self): argv = ['__does-not-exist'] - self.assertRaises(core.cdist_type.InvalidTypeError, 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'] self.env['require'] = '__does-not-exist/some-id' emu = emulator.Emulator(argv, env=self.env) - self.assertRaises(core.cdist_type.InvalidTypeError, emu.run) + self.assertRaises(core.cdist_type.NoSuchTypeError, emu.run) 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/.cdist/inside' emu = emulator.Emulator(argv, env=self.env) self.assertRaises(core.IllegalObjectIdError, emu.run) @@ -118,31 +103,6 @@ class EmulatorTestCase(test.CdistTestCase): emu = emulator.Emulator(argv, env=self.env) # if we get here all is fine - def test_loglevel(self): - argv = ['__file', '/tmp/foobar'] - self.env['require'] = '__file/etc/*' - emu = emulator.Emulator(argv, env=self.env) - emu_loglevel = emu.log.getEffectiveLevel() - self.assertEqual(emu_loglevel, logging.WARNING) - self.env['__cdist_log_level'] = str(logging.DEBUG) - emu = emulator.Emulator(argv, env=self.env) - emu_loglevel = emu.log.getEffectiveLevel() - self.assertEqual(emu_loglevel, logging.DEBUG) - del self.env['__cdist_log_level'] - - def test_invalid_loglevel_value(self): - argv = ['__file', '/tmp/foobar'] - self.env['require'] = '__file/etc/*' - emu = emulator.Emulator(argv, env=self.env) - emu_loglevel = emu.log.getEffectiveLevel() - self.assertEqual(emu_loglevel, logging.WARNING) - # lowercase is invalid - self.env['__cdist_log_level'] = 'debug' - emu = emulator.Emulator(argv, env=self.env) - emu_loglevel = emu.log.getEffectiveLevel() - self.assertEqual(emu_loglevel, logging.WARNING) - del self.env['__cdist_log_level'] - def test_requirement_via_order_dependency(self): self.env['CDIST_ORDER_DEPENDENCY'] = 'on' argv = ['__planet', 'erde'] @@ -158,14 +118,10 @@ 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, 'erde') + mars_object = core.CdistObject(cdist_type, self.local.object_path, '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, '/tmp/cdisttest') # now test the recorded requirements self.assertTrue(len(erde_object.requirements) == 0) self.assertEqual(list(mars_object.requirements), ['__planet/erde']) @@ -173,112 +129,15 @@ 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 - hostdir = cdist.str_hash(self.target_host[0]) - host_base_path = os.path.join(base_path, hostdir) - - self.local = local.Local( - target_host=self.target_host, - target_host_tags=self.target_host_tags, - base_root_path=host_base_path, - host_dir_name=hostdir, - 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): self.temp_dir = self.mkdtemp() base_path = os.path.join(self.temp_dir, "out") - hostdir = cdist.str_hash(self.target_host[0]) - host_base_path = os.path.join(base_path, hostdir) self.local = local.Local( target_host=self.target_host, - target_host_tags=self.target_host_tags, - base_root_path=host_base_path, - host_dir_name=hostdir, + base_path=base_path, exec_path=test.cdist_exec_path, add_conf_dirs=[conf_dir]) self.local.create_files_dirs() @@ -291,13 +150,11 @@ 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.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): @@ -305,21 +162,16 @@ class OverrideTestCase(test.CdistTestCase): handle, self.script = self.mkstemp(dir=self.temp_dir) os.close(handle) base_path = self.temp_dir - hostdir = cdist.str_hash(self.target_host[0]) - host_base_path = os.path.join(base_path, hostdir) self.local = local.Local( target_host=self.target_host, - target_host_tags=self.target_host_tags, - base_root_path=host_base_path, - host_dir_name=hostdir, + 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) @@ -328,7 +180,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) @@ -336,7 +188,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() @@ -347,39 +199,30 @@ class ArgumentsTestCase(test.CdistTestCase): def setUp(self): self.temp_dir = self.mkdtemp() base_path = self.temp_dir - hostdir = cdist.str_hash(self.target_host[0]) - host_base_path = os.path.join(base_path, hostdir) handle, self.script = self.mkstemp(dir=self.temp_dir) os.close(handle) self.local = local.Local( target_host=self.target_host, - target_host_tags=self.target_host_tags, - base_root_path=host_base_path, - host_dir_name=hostdir, + 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_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, 'some-id') self.assertTrue('with-dash' in cdist_object.parameters) def test_boolean(self): @@ -391,9 +234,7 @@ 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, object_id) self.assertTrue('boolean1' in cdist_object.parameters) self.assertFalse('boolean2' in cdist_object.parameters) # empty file -> True @@ -401,46 +242,22 @@ class ArgumentsTestCase(test.CdistTestCase): def test_required_arguments(self): """check whether assigning required parameter works""" - 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] +# print(self.env) 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, object_id) self.assertTrue('required1' in cdist_object.parameters) self.assertTrue('required2' in cdist_object.parameters) self.assertEqual(cdist_object.parameters['required1'], value) self.assertEqual(cdist_object.parameters['required2'], value) - def test_required_multiple_arguments(self): - """check whether assigning required multiple parameter works""" - - type_name = '__arguments_required_multiple' - object_id = 'some-id' - value1 = 'value1' - value2 = 'value2' - argv = [type_name, object_id, '--required1', value1, - '--required1', value2] - 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) - self.assertTrue('required1' in cdist_object.parameters) - self.assertTrue(value1 in cdist_object.parameters['required1']) - self.assertTrue(value2 in cdist_object.parameters['required1']) - # def test_required_missing(self): # type_name = '__arguments_required' # object_id = 'some-id' @@ -461,32 +278,11 @@ 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, object_id) self.assertTrue('optional1' in cdist_object.parameters) self.assertFalse('optional2' in cdist_object.parameters) self.assertEqual(cdist_object.parameters['optional1'], value) - def test_optional_multiple(self): - type_name = '__arguments_optional_multiple' - object_id = 'some-id' - value1 = 'value1' - value2 = 'value2' - argv = [type_name, object_id, '--optional1', value1, '--optional1', - value2] - 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) - self.assertTrue('optional1' in cdist_object.parameters) - self.assertTrue(value1 in cdist_object.parameters['optional1']) - self.assertTrue(value2 in cdist_object.parameters['optional1']) - def test_argument_defaults(self): type_name = '__argument_defaults' object_id = 'some-id' @@ -497,36 +293,11 @@ 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, object_id) self.assertTrue('optional1' in cdist_object.parameters) self.assertFalse('optional2' in cdist_object.parameters) self.assertEqual(cdist_object.parameters['optional1'], value) - def test_object_params_in_context(self): - type_name = '__arguments_all' - object_id = 'some-id' - argv = [type_name, object_id, '--opt', 'opt', '--req', 'req', - '--bool', '--optmul', 'val1', '--optmul', 'val2', - '--reqmul', 'val3', '--reqmul', 'val4', - '--optmul1', 'val5', '--reqmul1', 'val6'] - os.environ.update(self.env) - emu = emulator.Emulator(argv) - emu.run() - - obj_params = emu._object_params_in_context() - obj_params_expected = { - 'bool': '', - 'opt': 'opt', - 'optmul1': ['val5', ], - 'optmul': ['val1', 'val2', ], - 'req': 'req', - 'reqmul1': ['val6', ], - 'reqmul': ['val3', 'val4', ], - } - self.assertEqual(obj_params, obj_params_expected) - class StdinTestCase(test.CdistTestCase): @@ -536,19 +307,19 @@ class StdinTestCase(test.CdistTestCase): self.temp_dir = self.mkdtemp() base_path = os.path.join(self.temp_dir, "out") - hostdir = cdist.str_hash(self.target_host[0]) - host_base_path = os.path.join(base_path, hostdir) self.local = local.Local( target_host=self.target_host, - target_host_tags=self.target_host_tags, - base_root_path=host_base_path, - host_dir_name=hostdir, + base_path=base_path, exec_path=test.cdist_exec_path, add_conf_dirs=[conf_dir]) self.local.create_files_dirs() + self.manifest = core.Manifest( + target_host=self.target_host, + local = self.local) + def tearDown(self): os.environ = self.orig_environ shutil.rmtree(self.temp_dir) @@ -569,18 +340,13 @@ class StdinTestCase(test.CdistTestCase): object_id = "cdist-test-id" argv = [type_name, object_id] - env = os.environ.copy() - env['__cdist_manifest'] = "/cdist-test/path/that/does/not/exist" - env['__cdist_object_marker'] = self.local.object_marker_name - env['__cdist_type_base_path'] = self.local.type_path - env['__global'] = self.local.base_path + initial_manifest_path = "/cdist-test/path/that/does/not/exist" + env = self.manifest.env_initial_manifest(initial_manifest_path) ###################################################################### # 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, object_id) stdin_out_path = os.path.join(cdist_object.absolute_path, 'stdin') ###################################################################### @@ -594,63 +360,3 @@ class StdinTestCase(test.CdistTestCase): stdin_saved_by_emulator = fd.read() self.assertEqual(random_string, stdin_saved_by_emulator) - - -class EmulatorAlreadyExistingRequirementsWarnTestCase(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 - hostdir = cdist.str_hash(self.target_host[0]) - host_base_path = os.path.join(base_path, hostdir) - - self.local = local.Local( - target_host=self.target_host, - target_host_tags=self.target_host_tags, - base_root_path=host_base_path, - host_dir_name=hostdir, - 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_existing_requirements_req_none(self): - """Test to show dependency resolver warning message.""" - 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) - - def test_object_existing_requirements_none_req(self): - """Test to show dependency resolver warning message.""" - 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) - - -if __name__ == '__main__': - import unittest - unittest.main() diff --git a/cdist/test/emulator/fixtures/conf/type/__arguments_all/parameter/boolean b/cdist/test/emulator/fixtures/conf/type/__arguments_all/parameter/boolean deleted file mode 100644 index 46a27912..00000000 --- a/cdist/test/emulator/fixtures/conf/type/__arguments_all/parameter/boolean +++ /dev/null @@ -1 +0,0 @@ -bool diff --git a/cdist/test/emulator/fixtures/conf/type/__arguments_all/parameter/optional b/cdist/test/emulator/fixtures/conf/type/__arguments_all/parameter/optional deleted file mode 100644 index d6eba11a..00000000 --- a/cdist/test/emulator/fixtures/conf/type/__arguments_all/parameter/optional +++ /dev/null @@ -1 +0,0 @@ -opt diff --git a/cdist/test/emulator/fixtures/conf/type/__arguments_all/parameter/optional_multiple b/cdist/test/emulator/fixtures/conf/type/__arguments_all/parameter/optional_multiple deleted file mode 100644 index 04893522..00000000 --- a/cdist/test/emulator/fixtures/conf/type/__arguments_all/parameter/optional_multiple +++ /dev/null @@ -1,2 +0,0 @@ -optmul -optmul1 diff --git a/cdist/test/emulator/fixtures/conf/type/__arguments_all/parameter/required b/cdist/test/emulator/fixtures/conf/type/__arguments_all/parameter/required deleted file mode 100644 index da45f08d..00000000 --- a/cdist/test/emulator/fixtures/conf/type/__arguments_all/parameter/required +++ /dev/null @@ -1 +0,0 @@ -req diff --git a/cdist/test/emulator/fixtures/conf/type/__arguments_all/parameter/required_multiple b/cdist/test/emulator/fixtures/conf/type/__arguments_all/parameter/required_multiple deleted file mode 100644 index 28c1a19b..00000000 --- a/cdist/test/emulator/fixtures/conf/type/__arguments_all/parameter/required_multiple +++ /dev/null @@ -1,2 +0,0 @@ -reqmul -reqmul1 diff --git a/cdist/test/emulator/fixtures/conf/type/__arguments_optional_multiple/parameter/optional_multiple b/cdist/test/emulator/fixtures/conf/type/__arguments_optional_multiple/parameter/optional_multiple deleted file mode 100644 index 31647628..00000000 --- a/cdist/test/emulator/fixtures/conf/type/__arguments_optional_multiple/parameter/optional_multiple +++ /dev/null @@ -1 +0,0 @@ -optional1 diff --git a/cdist/test/emulator/fixtures/conf/type/__arguments_required_multiple/parameter/required_multiple b/cdist/test/emulator/fixtures/conf/type/__arguments_required_multiple/parameter/required_multiple deleted file mode 100644 index 180d60c7..00000000 --- a/cdist/test/emulator/fixtures/conf/type/__arguments_required_multiple/parameter/required_multiple +++ /dev/null @@ -1 +0,0 @@ -required1 diff --git a/cdist/test/exec/__init__.py b/cdist/test/exec/__init__.py index b55cffa9..e69de29b 100644 --- a/cdist/test/exec/__init__.py +++ b/cdist/test/exec/__init__.py @@ -1,7 +0,0 @@ -from .local import * - - -if __name__ == "__main__": - import unittest - - unittest.main() diff --git a/cdist/test/exec/fixtures/conf/type/__cdist_test_type/gencode-local b/cdist/test/exec/fixtures/conf/type/__cdist_test_type/gencode-local deleted file mode 100755 index 3d568ad3..00000000 --- a/cdist/test/exec/fixtures/conf/type/__cdist_test_type/gencode-local +++ /dev/null @@ -1,10 +0,0 @@ -#!/bin/sh - -echo "echo __target_host: $__target_host" -echo "echo __target_hostname: $__target_hostname" -echo "echo __target_fqdn: $__target_fqdn" -echo "echo __global: $__global" -echo "echo __type: $__type" -echo "echo __object: $__object" -echo "echo __object_id: $__object_id" -echo "echo __object_name: $__object_name" diff --git a/cdist/test/exec/fixtures/conf/type/__cdist_test_type/gencode-remote b/cdist/test/exec/fixtures/conf/type/__cdist_test_type/gencode-remote deleted file mode 120000 index 7b427cac..00000000 --- a/cdist/test/exec/fixtures/conf/type/__cdist_test_type/gencode-remote +++ /dev/null @@ -1 +0,0 @@ -gencode-local \ No newline at end of file diff --git a/cdist/test/exec/local.py b/cdist/test/exec/local.py index 0865b7dc..6cb0c605 100644 --- a/cdist/test/exec/local.py +++ b/cdist/test/exec/local.py @@ -2,7 +2,6 @@ # # 2010-2011 Steven Armstrong (steven-cdist at armstrong.cc) # 2012 Nico Schottelius (nico-cdist at schottelius.org) -# 2016 Darko Poljak (darko.poljak at gmail.com) # # This file is part of cdist. # @@ -26,12 +25,8 @@ import getpass import shutil import string import random -import time -import datetime -import argparse import cdist -import cdist.configuration as cc from cdist import test from cdist.exec import local @@ -40,30 +35,17 @@ my_dir = op.abspath(op.dirname(__file__)) fixtures = op.join(my_dir, 'fixtures') conf_dir = op.join(fixtures, "conf") -bin_true = "true" -bin_false = "false" - - class LocalTestCase(test.CdistTestCase): def setUp(self): - target_host = ( - 'localhost', - 'localhost', - 'localhost', - ) + target_host = 'localhost' self.temp_dir = self.mkdtemp() - self.out_parent_path = self.temp_dir - self.hostdir = cdist.str_hash(target_host[0]) - self.host_base_path = op.join(self.out_parent_path, self.hostdir) - self.out_path = op.join(self.host_base_path, "data") + self.out_path = self.temp_dir self.local = local.Local( target_host=target_host, - target_host_tags=None, - base_root_path=self.host_base_path, - host_dir_name=self.hostdir, + out_path=self.out_path, exec_path=test.cdist_exec_path ) @@ -72,62 +54,47 @@ 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) + self.assertEqual(self.local.out_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', - 'localhost', - 'localhost', - ), - target_host_tags=None, - base_root_path=self.host_base_path, - host_dir_name=self.hostdir, + target_host='localhost', + out_path=self.out_path, exec_path=test.cdist_exec_path, ) @@ -138,20 +105,13 @@ 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', - 'localhost', - 'localhost', - ), - target_host_tags=None, - base_root_path=self.host_base_path, - host_dir_name=self.hostdir, + target_host='localhost', + out_path=self.out_path, exec_path=test.cdist_exec_path, add_conf_dirs=[conf_dir] ) @@ -163,30 +123,16 @@ 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 - # bypass singleton from other tests if any - cc.Configuration.instance = None - - configuration = cc.Configuration(argparse.Namespace(), - env=os.environ) - link_test_local = local.Local( - target_host=( - 'localhost', - 'localhost', - 'localhost', - ), - target_host_tags=None, - base_root_path=self.host_base_path, - host_dir_name=self.hostdir, + target_host='localhost', + out_path=self.out_path, exec_path=test.cdist_exec_path, - configuration=configuration.get_config(section='GLOBAL') ) link_test_local._create_conf_path_and_link_conf_dirs() @@ -195,37 +141,31 @@ class LocalTestCase(test.CdistTestCase): self.assertTrue(os.path.isdir(our_type_dir)) - # other tests + ### other tests def test_run_success(self): - self.local.create_files_dirs() - self.local.run([bin_true]) + self.local.run(['/bin/true']) def test_run_fail(self): - self.local.create_files_dirs() - self.assertRaises(cdist.Error, self.local.run, [bin_false]) + self.assertRaises(cdist.Error, self.local.run, ['/bin/false']) def test_run_script_success(self): - self.local.create_files_dirs() handle, script = self.mkstemp(dir=self.temp_dir) with os.fdopen(handle, "w") as fd: - fd.writelines(["#!/bin/sh\n", bin_true]) + fd.writelines(["#!/bin/sh\n", "/bin/true"]) self.local.run_script(script) def test_run_script_fail(self): - self.local.create_files_dirs() handle, script = self.mkstemp(dir=self.temp_dir) with os.fdopen(handle, "w") as fd: - fd.writelines(["#!/bin/sh\n", bin_false]) + fd.writelines(["#!/bin/sh\n", "/bin/false"]) self.assertRaises(cdist.Error, self.local.run_script, script) def test_run_script_get_output(self): - self.local.create_files_dirs() 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) @@ -240,46 +180,6 @@ class LocalTestCase(test.CdistTestCase): def test_create_files_dirs(self): self.local.create_files_dirs() - self.assertTrue(os.path.isdir(self.local.base_path)) + self.assertTrue(os.path.isdir(self.local.out_path)) self.assertTrue(os.path.isdir(self.local.bin_path)) self.assertTrue(os.path.isdir(self.local.conf_path)) - - def test_cache_subpath(self): - start_time = time.time() - dt = datetime.datetime.fromtimestamp(start_time) - pid = str(os.getpid()) - cases = [ - ['', self.local.hostdir, ], - ['/', self.local.hostdir, ], - ['//', self.local.hostdir, ], - ['/%%h', '%h', ], - ['%%h', '%h', ], - ['%P', pid, ], - ['x%P', 'x' + pid, ], - ['%h', self.hostdir, ], - ['%h/%Y-%m-%d/%H%M%S%f%P', - dt.strftime(self.hostdir + '/%Y-%m-%d/%H%M%S%f') + pid, ], - ['/%h/%Y-%m-%d/%H%M%S%f%P', - dt.strftime(self.hostdir + '/%Y-%m-%d/%H%M%S%f') + pid, ], - ['%Y-%m-%d/%H%M%S%f%P/%h', - dt.strftime('%Y-%m-%d/%H%M%S%f' + pid + os.sep + self.hostdir), ], - ['///%Y-%m-%d/%H%M%S%f%P/%h', - dt.strftime('%Y-%m-%d/%H%M%S%f' + pid + os.sep + self.hostdir), ], - ['%h/%Y-%m-%d/%H%M%S-%P', - dt.strftime(self.hostdir + '/%Y-%m-%d/%H%M%S-') + pid, ], - ['%Y-%m-%d/%H%M%S-%P/%h', - dt.strftime('%Y-%m-%d/%H%M%S-') + pid + os.sep + self.hostdir, ], - ['%N', self.local.target_host[0], ], - ] - for x in cases: - x.append(self.local._cache_subpath(start_time, x[0])) - # for fmt, expected, actual in cases: - # print('\'{}\' \'{}\' \'{}\''.format(fmt, expected, actual)) - for fmt, expected, actual in cases: - self.assertEqual(expected, actual) - - -if __name__ == "__main__": - import unittest - - unittest.main() diff --git a/cdist/test/exec/remote.py b/cdist/test/exec/remote.py index a7fe384d..8e7d408a 100644 --- a/cdist/test/exec/remote.py +++ b/cdist/test/exec/remote.py @@ -22,7 +22,8 @@ import os import getpass import shutil -import multiprocessing +import string +import random import cdist from cdist import test @@ -33,81 +34,55 @@ class RemoteTestCase(test.CdistTestCase): def setUp(self): self.temp_dir = self.mkdtemp() - self.target_host = ( - 'localhost', - 'localhost', - 'localhost', - ) - # another temp dir for remote base path - self.base_path = self.mkdtemp() - self.remote = self.create_remote() - - def create_remote(self, *args, **kwargs): - if not args: - args = (self.target_host,) - kwargs.setdefault('base_path', self.base_path) + self.target_host = 'localhost' + self.base_path = self.temp_dir user = getpass.getuser() - kwargs.setdefault('remote_exec', 'ssh -o User=%s -q' % user) - kwargs.setdefault('remote_copy', 'scp -o User=%s -q' % user) - if 'stdout_base_path' not in kwargs: - stdout_path = os.path.join(self.temp_dir, 'stdout') - os.makedirs(stdout_path, exist_ok=True) - kwargs['stdout_base_path'] = stdout_path - if 'stderr_base_path' not in kwargs: - stderr_path = os.path.join(self.temp_dir, 'stderr') - os.makedirs(stderr_path, exist_ok=True) - kwargs['stderr_base_path'] = stderr_path - return remote.Remote(*args, **kwargs) + remote_exec = "ssh -o User=%s -q" % user + remote_copy = "scp -o User=%s -q" % user + self.remote = remote.Remote(self.target_host, self.base_path, remote_exec, remote_copy) def tearDown(self): shutil.rmtree(self.temp_dir) - shutil.rmtree(self.base_path) - # 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(['true']) + self.remote.run(['/bin/true']) def test_run_fail(self): - self.assertRaises(cdist.Error, self.remote.run, ['false']) + self.assertRaises(cdist.Error, self.remote.run, ['/bin/false']) def test_run_script_success(self): handle, script = self.mkstemp(dir=self.temp_dir) with os.fdopen(handle, "w") as fd: - fd.writelines(["#!/bin/sh\n", "true"]) + fd.writelines(["#!/bin/sh\n", "/bin/true"]) self.remote.run_script(script) def test_run_script_fail(self): handle, script = self.mkstemp(dir=self.temp_dir) with os.fdopen(handle, "w") as fd: - fd.writelines(["#!/bin/sh\n", "false"]) - self.assertRaises(cdist.Error, self.remote.run_script, - script) + fd.writelines(["#!/bin/sh\n", "/bin/false"]) + 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 +100,7 @@ class RemoteTestCase(test.CdistTestCase): os.close(handle) target = self.mkdtemp(dir=self.temp_dir) self.remote.transfer(source, target) - self.assertTrue(os.path.isfile( - os.path.join(target, os.path.basename(source)))) + self.assertTrue(os.path.isfile(target)) def test_transfer_dir(self): source = self.mkdtemp(dir=self.temp_dir) @@ -139,24 +113,8 @@ class RemoteTestCase(test.CdistTestCase): # test if the payload file is in the target directory self.assertTrue(os.path.isfile(os.path.join(target, source_file_name))) - def test_transfer_dir_parallel(self): - source = self.mkdtemp(dir=self.temp_dir) - # put 8 files in the directory as payload - filenames = [] - for x in range(8): - handle, source_file = self.mkstemp(dir=source) - os.close(handle) - source_file_name = os.path.split(source_file)[-1] - filenames.append(source_file_name) - target = self.mkdtemp(dir=self.temp_dir) - self.remote.transfer(source, target, - multiprocessing.cpu_count()) - # test if the payload files are in the target directory - for filename in filenames: - self.assertTrue(os.path.isfile(os.path.join(target, filename))) - - def test_create_files_dirs(self): - self.remote.create_files_dirs() + def test_create_directories(self): + self.remote.create_directories() self.assertTrue(os.path.isdir(self.remote.base_path)) self.assertTrue(os.path.isdir(self.remote.conf_path)) @@ -167,10 +125,8 @@ class RemoteTestCase(test.CdistTestCase): os.chmod(remote_exec_path, 0o755) remote_exec = remote_exec_path remote_copy = "echo" - r = self.create_remote(remote_exec=remote_exec, - remote_copy=remote_copy) - self.assertEqual(r.run('true', return_output=True), - "%s\n" % self.target_host[0]) + r = remote.Remote(self.target_host, self.base_path, remote_exec, 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) @@ -179,48 +135,8 @@ class RemoteTestCase(test.CdistTestCase): os.chmod(remote_exec_path, 0o755) remote_exec = remote_exec_path remote_copy = "echo" - r = self.create_remote(remote_exec=remote_exec, - remote_copy=remote_copy) + r = remote.Remote(self.target_host, self.base_path, remote_exec, remote_copy) handle, script = self.mkstemp(dir=self.temp_dir) with os.fdopen(handle, "w") as fd: - fd.writelines(["#!/bin/sh\n", "true"]) - self.assertEqual(r.run_script(script, return_output=True), - "%s\n" % self.target_host[0]) - - 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')]) - os.chmod(script, 0o755) - handle, remote_exec_path = self.mkstemp(dir=self.temp_dir) - with os.fdopen(handle, 'w') as fd: - fd.writelines(["#!/bin/sh\n", 'shift; cmd=$1; shift; $cmd "$@"\n']) - os.chmod(remote_exec_path, 0o755) - remote_exec = remote_exec_path - remote_copy = "echo" - r = self.create_remote(remote_exec=remote_exec, - remote_copy=remote_copy) - output = r.run_script(script, return_output=True) - self.assertEqual(output, "no_env\n") - - handle, remote_exec_path = self.mkstemp(dir=self.temp_dir) - with os.fdopen(handle, 'w') as fd: - fd.writelines(["#!/bin/sh\n", 'shift; cmd=$1; eval $cmd\n']) - os.chmod(remote_exec_path, 0o755) - remote_exec = remote_exec_path - env = { - '__object': 'test_object', - } - r = self.create_remote(remote_exec=remote_exec, - remote_copy=remote_copy) - output = r.run_script(script, env=env, return_output=True) - self.assertEqual(output, "test_object\n") - - -if __name__ == '__main__': - import unittest - - unittest.main() + fd.writelines(["#!/bin/sh\n", "/bin/true"]) + self.assertEqual(r.run_script(script, return_output=True), "%s\n" % self.target_host) diff --git a/cdist/test/explorer/__init__.py b/cdist/test/explorer/__init__.py index 1c4e4bc4..92ef75a3 100644 --- a/cdist/test/explorer/__init__.py +++ b/cdist/test/explorer/__init__.py @@ -23,7 +23,6 @@ import os import shutil import getpass -import multiprocessing import cdist from cdist import core @@ -31,29 +30,23 @@ from cdist import test from cdist.exec import local from cdist.exec import remote from cdist.core import explorer -import logging import os.path as op 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") - hostdir = cdist.str_hash(self.target_host[0]) - base_root_path = os.path.join(self.local_path, hostdir) - 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( target_host=self.target_host, - target_host_tags=self.target_host_tags, - base_root_path=base_root_path, - host_dir_name=hostdir, + base_path=self.local_path, exec_path=test.cdist_exec_path, add_conf_dirs=[conf_dir], ) @@ -61,17 +54,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, - stdout_base_path=self.local.stdout_base_path, - stderr_base_path=self.local.stderr_base_path) + 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): @@ -88,8 +79,7 @@ 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""" @@ -111,16 +101,14 @@ 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): @@ -128,8 +116,7 @@ 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) @@ -140,108 +127,24 @@ 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, '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, '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, 'whatever') cdist_object.create() self.explorer.run_type_explorers(cdist_object) self.assertEqual(cdist_object.explorers, {'world': 'hello'}) - - def test_jobs_parameter(self): - self.assertIsNone(self.explorer.jobs) - expl = explorer.Explorer( - self.target_host, - self.local, - self.remote, - jobs=8) - self.assertEqual(expl.jobs, 8) - - def test_transfer_global_explorers_parallel(self): - expl = explorer.Explorer( - self.target_host, - self.local, - self.remote, - jobs=multiprocessing.cpu_count()) - self.assertIsNotNone(expl.jobs) - - expl.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))) - - def test_run_parallel_jobs(self): - expl = explorer.Explorer( - self.target_host, - self.local, - self.remote, - jobs=multiprocessing.cpu_count()) - self.assertIsNotNone(expl.jobs) - out_path = self.mkdtemp() - - expl.run_global_explorers(out_path) - names = sorted(expl.list_global_explorer_names()) - output = sorted(os.listdir(out_path)) - - self.assertEqual(names, output) - shutil.rmtree(out_path) - - def test_explorer_environment(self): - cdist_type = core.CdistType(self.local.type_path, '__dump_env') - 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('dump', cdist_object) - - output_dict = {} - for line in output.split('\n'): - if line: - key, value = line.split(': ') - output_dict[key] = value - self.assertEqual(output_dict['__target_host'], - self.local.target_host[0]) - self.assertEqual(output_dict['__target_hostname'], - self.local.target_host[1]) - self.assertEqual(output_dict['__target_fqdn'], - self.local.target_host[2]) - self.assertEqual(output_dict['__explorer'], - self.remote.global_explorer_path) - self.assertEqual(output_dict['__target_host_tags'], - self.local.target_host_tags) - self.assertEqual(output_dict['__cdist_log_level'], - str(logging.WARNING)) - self.assertEqual(output_dict['__cdist_log_level_name'], 'WARNING') - - -if __name__ == '__main__': - import unittest - - unittest.main() diff --git a/cdist/test/explorer/fixtures/conf/type/__dump_env/explorer/dump b/cdist/test/explorer/fixtures/conf/type/__dump_env/explorer/dump deleted file mode 100755 index 3682816b..00000000 --- a/cdist/test/explorer/fixtures/conf/type/__dump_env/explorer/dump +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh - -echo "__target_host: $__target_host" -echo "__target_hostname: $__target_hostname" -echo "__target_fqdn: $__target_fqdn" -echo "__explorer: $__explorer" -echo "__target_host_tags: $__target_host_tags" -echo "__cdist_log_level: $__cdist_log_level" -echo "__cdist_log_level_name: $__cdist_log_level_name" diff --git a/cdist/test/inventory/__init__.py b/cdist/test/inventory/__init__.py deleted file mode 100644 index 287c855c..00000000 --- a/cdist/test/inventory/__init__.py +++ /dev/null @@ -1,477 +0,0 @@ -# -*- 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 os -import shutil -import cdist -import os.path as op -import unittest -import sys -from cdist import test -from cdist import inventory -from io import StringIO - -my_dir = op.abspath(op.dirname(__file__)) -fixtures = op.join(my_dir, 'fixtures') -inventory_dir = op.join(fixtures, "inventory") - - -class InventoryTestCase(test.CdistTestCase): - - def _create_host_with_tags(self, host, tags): - os.makedirs(inventory_dir, exist_ok=True) - hostfile = op.join(inventory_dir, host) - with open(hostfile, "w") as f: - for x in tags: - f.write("{}\n".format(x)) - - def setUp(self): - self.maxDiff = None - self.db = { - "loadbalancer1": ["loadbalancer", "all", "europe", ], - "loadbalancer2": ["loadbalancer", "all", "europe", ], - "loadbalancer3": ["loadbalancer", "all", "africa", ], - "loadbalancer4": ["loadbalancer", "all", "africa", ], - "web1": ["web", "all", "static", ], - "web2": ["web", "all", "dynamic", ], - "web3": ["web", "all", "dynamic", ], - "shell1": ["shell", "all", "free", ], - "shell2": ["shell", "all", "free", ], - "shell3": ["shell", "all", "charge", ], - "shell4": ["shell", "all", "charge", ], - "monty": ["web", "python", "shell", ], - "python": ["web", "python", "shell", ], - } - for x in self.db: - self.db[x] = sorted(self.db[x]) - for host in self.db: - self._create_host_with_tags(host, self.db[host]) - self.sys_stdout = sys.stdout - out = StringIO() - sys.stdout = out - - def _get_output(self): - sys.stdout.flush() - output = sys.stdout.getvalue().strip() - return output - - def tearDown(self): - sys.stdout = self.sys_stdout - shutil.rmtree(inventory_dir) - - def test_inventory_create_db(self): - dbdir = op.join(fixtures, "foo") - inv = inventory.Inventory(db_basedir=dbdir) - self.assertTrue(os.path.isdir(dbdir)) - self.assertEqual(inv.db_basedir, dbdir) - shutil.rmtree(inv.db_basedir) - - # InventoryList - def test_inventory_list_print(self): - invList = inventory.InventoryList(db_basedir=inventory_dir) - invList.run() - output = self._get_output() - self.assertTrue(' ' in output) - - def test_inventory_list_print_host_only(self): - invList = inventory.InventoryList(db_basedir=inventory_dir, - list_only_host=True) - invList.run() - output = self._get_output() - self.assertFalse(' ' in output) - - def test_inventory_list_all(self): - invList = inventory.InventoryList(db_basedir=inventory_dir) - entries = invList.entries() - db = {host: sorted(tags) for host, tags in entries} - self.assertEqual(db, self.db) - - def test_inventory_list_by_host_hosts(self): - hosts = ("web1", "web2", "web3",) - invList = inventory.InventoryList(db_basedir=inventory_dir, - hosts=hosts) - entries = invList.entries() - db = {host: sorted(tags) for host, tags in entries} - expected_db = {host: sorted(self.db[host]) for host in hosts} - self.assertEqual(db, expected_db) - - def test_inventory_list_by_host_hostfile(self): - hosts = ("web1", "web2", "web3",) - hostfile = op.join(fixtures, "hosts") - with open(hostfile, "w") as f: - for x in hosts: - f.write("{}\n".format(x)) - invList = inventory.InventoryList(db_basedir=inventory_dir, - hostfile=hostfile) - entries = invList.entries() - db = {host: sorted(tags) for host, tags in entries} - expected_db = {host: sorted(self.db[host]) for host in hosts} - self.assertEqual(db, expected_db) - os.remove(hostfile) - - def test_inventory_list_by_host_hosts_hostfile(self): - hosts = ("shell1", "shell4",) - hostsf = ("web1", "web2", "web3",) - hostfile = op.join(fixtures, "hosts") - with open(hostfile, "w") as f: - for x in hostsf: - f.write("{}\n".format(x)) - invList = inventory.InventoryList(db_basedir=inventory_dir, - hosts=hosts, hostfile=hostfile) - entries = invList.entries() - db = {host: sorted(tags) for host, tags in entries} - import itertools - expected_db = {host: sorted(self.db[host]) for host in - itertools.chain(hostsf, hosts)} - self.assertEqual(db, expected_db) - os.remove(hostfile) - - def _gen_expected_db_for_tags(self, tags): - db = {} - for host in self.db: - for tag in tags: - if tag in self.db[host]: - db[host] = self.db[host] - break - return db - - def _gen_expected_db_for_has_all_tags(self, tags): - db = {} - for host in self.db: - if set(tags).issubset(set(self.db[host])): - db[host] = self.db[host] - return db - - def test_inventory_list_by_tag_hosts(self): - tags = ("web", "shell",) - invList = inventory.InventoryList(db_basedir=inventory_dir, - istag=True, hosts=tags) - entries = invList.entries() - db = {host: sorted(tags) for host, tags in entries} - expected_db = self._gen_expected_db_for_tags(tags) - self.assertEqual(db, expected_db) - - def test_inventory_list_by_tag_hostfile(self): - tags = ("web", "shell",) - tagfile = op.join(fixtures, "tags") - with open(tagfile, "w") as f: - for x in tags: - f.write("{}\n".format(x)) - invList = inventory.InventoryList(db_basedir=inventory_dir, - istag=True, hostfile=tagfile) - entries = invList.entries() - db = {host: sorted(tags) for host, tags in entries} - expected_db = self._gen_expected_db_for_tags(tags) - self.assertEqual(db, expected_db) - os.remove(tagfile) - - def test_inventory_list_by_tag_hosts_hostfile(self): - tags = ("web", "shell",) - tagsf = ("dynamic", "europe",) - tagfile = op.join(fixtures, "tags") - with open(tagfile, "w") as f: - for x in tagsf: - f.write("{}\n".format(x)) - invList = inventory.InventoryList(db_basedir=inventory_dir, - istag=True, hosts=tags, - hostfile=tagfile) - entries = invList.entries() - db = {host: sorted(tags) for host, tags in entries} - import itertools - expected_db = self._gen_expected_db_for_tags(tags + tagsf) - self.assertEqual(db, expected_db) - os.remove(tagfile) - - def test_inventory_list_by_tag_has_all_tags(self): - tags = ("web", "python", "shell",) - invList = inventory.InventoryList(db_basedir=inventory_dir, - istag=True, hosts=tags, - has_all_tags=True) - entries = invList.entries() - db = {host: sorted(tags) for host, tags in entries} - expected_db = self._gen_expected_db_for_has_all_tags(tags) - self.assertEqual(db, expected_db) - - # InventoryHost - def test_inventory_host_add_hosts(self): - hosts = ("spam", "eggs", "foo",) - invHost = inventory.InventoryHost(db_basedir=inventory_dir, - action="add", hosts=hosts) - invHost.run() - invList = inventory.InventoryList(db_basedir=inventory_dir) - expected_hosts = tuple(x for x in invList.host_entries() if x in hosts) - self.assertEqual(sorted(hosts), sorted(expected_hosts)) - - def test_inventory_host_add_hostfile(self): - hosts = ("spam-new", "eggs-new", "foo-new",) - hostfile = op.join(fixtures, "hosts") - with open(hostfile, "w") as f: - for x in hosts: - f.write("{}\n".format(x)) - invHost = inventory.InventoryHost(db_basedir=inventory_dir, - action="add", hostfile=hostfile) - invHost.run() - invList = inventory.InventoryList(db_basedir=inventory_dir) - expected_hosts = tuple(x for x in invList.host_entries() if x in hosts) - self.assertEqual(sorted(hosts), sorted(expected_hosts)) - os.remove(hostfile) - - def test_inventory_host_add_hosts_hostfile(self): - hosts = ("spam-spam", "eggs-spam", "foo-spam",) - hostf = ("spam-eggs-spam", "spam-foo-spam",) - hostfile = op.join(fixtures, "hosts") - with open(hostfile, "w") as f: - for x in hostf: - f.write("{}\n".format(x)) - invHost = inventory.InventoryHost(db_basedir=inventory_dir, - action="add", hosts=hosts, - hostfile=hostfile) - invHost.run() - invList = inventory.InventoryList(db_basedir=inventory_dir, - hosts=hosts + hostf) - expected_hosts = tuple(invList.host_entries()) - self.assertEqual(sorted(hosts + hostf), sorted(expected_hosts)) - os.remove(hostfile) - - def test_inventory_host_del_hosts(self): - hosts = ("web1", "shell1",) - invHost = inventory.InventoryHost(db_basedir=inventory_dir, - action="del", hosts=hosts) - invHost.run() - invList = inventory.InventoryList(db_basedir=inventory_dir, - hosts=hosts) - expected_hosts = tuple(invList.host_entries()) - self.assertTupleEqual(expected_hosts, ()) - - def test_inventory_host_del_hostfile(self): - hosts = ("loadbalancer3", "loadbalancer4",) - hostfile = op.join(fixtures, "hosts") - with open(hostfile, "w") as f: - for x in hosts: - f.write("{}\n".format(x)) - invHost = inventory.InventoryHost(db_basedir=inventory_dir, - action="del", hostfile=hostfile) - invHost.run() - invList = inventory.InventoryList(db_basedir=inventory_dir, - hosts=hosts) - expected_hosts = tuple(invList.host_entries()) - self.assertTupleEqual(expected_hosts, ()) - os.remove(hostfile) - - def test_inventory_host_del_hosts_hostfile(self): - hosts = ("loadbalancer1", "loadbalancer2",) - hostf = ("web2", "shell2",) - hostfile = op.join(fixtures, "hosts") - with open(hostfile, "w") as f: - for x in hostf: - f.write("{}\n".format(x)) - invHost = inventory.InventoryHost(db_basedir=inventory_dir, - action="del", hosts=hosts, - hostfile=hostfile) - invHost.run() - invList = inventory.InventoryList(db_basedir=inventory_dir, - hosts=hosts + hostf) - expected_hosts = tuple(invList.host_entries()) - self.assertTupleEqual(expected_hosts, ()) - os.remove(hostfile) - - @unittest.expectedFailure - def test_inventory_host_invalid_host(self): - try: - invalid_hostfile = op.join(inventory_dir, "invalid") - os.mkdir(invalid_hostfile) - hosts = ("invalid",) - invHost = inventory.InventoryHost(db_basedir=inventory_dir, - action="del", hosts=hosts) - invHost.run() - except e: - os.rmdir(invalid_hostfile) - raise e - - # InventoryTag - def test_inventory_tag_init(self): - invTag = inventory.InventoryTag(db_basedir=inventory_dir, - action="add") - self.assertTrue(invTag.allhosts) - self.assertEqual(invTag.tagfile, "-") - - def test_inventory_tag_stdin_multiple_hosts(self): - try: - invTag = inventory.InventoryTag(db_basedir=inventory_dir, - action="add", tagfile="-", - hosts=("host1", "host2",)) - except e: - self.fail() - - def test_inventory_tag_stdin_hostfile(self): - try: - invTag = inventory.InventoryTag(db_basedir=inventory_dir, - action="add", tagfile="-", - hostfile="hosts") - except e: - self.fail() - - @unittest.expectedFailure - def test_inventory_tag_stdin_both(self): - invTag = inventory.InventoryTag(db_basedir=inventory_dir, - action="add", tagfile="-", - hostfile="-") - - def test_inventory_tag_add_for_all_hosts(self): - tags = ("spam-spam-spam", "spam-spam-eggs",) - tagsf = ("spam-spam-spam-eggs", "spam-spam-eggs-spam",) - tagfile = op.join(fixtures, "tags") - with open(tagfile, "w") as f: - for x in tagsf: - f.write("{}\n".format(x)) - invTag = inventory.InventoryTag(db_basedir=inventory_dir, - action="add", tags=tags, - tagfile=tagfile) - invTag.run() - invList = inventory.InventoryList(db_basedir=inventory_dir) - failed = False - for host, taglist in invList.entries(): - for x in tagsf + tags: - if x not in taglist: - failed = True - break - if failed: - break - os.remove(tagfile) - if failed: - self.fail() - - def test_inventory_tag_add(self): - tags = ("spam-spam-spam", "spam-spam-eggs",) - tagsf = ("spam-spam-spam-eggs", "spam-spam-eggs-spam",) - hosts = ("loadbalancer1", "loadbalancer2", "shell2",) - hostsf = ("web2", "web3",) - tagfile = op.join(fixtures, "tags") - with open(tagfile, "w") as f: - for x in tagsf: - f.write("{}\n".format(x)) - hostfile = op.join(fixtures, "hosts") - with open(hostfile, "w") as f: - for x in hostsf: - f.write("{}\n".format(x)) - invTag = inventory.InventoryTag(db_basedir=inventory_dir, - action="add", tags=tags, - tagfile=tagfile, hosts=hosts, - hostfile=hostfile) - invTag.run() - invList = inventory.InventoryList(db_basedir=inventory_dir, - hosts=hosts + hostsf) - failed = False - for host, taglist in invList.entries(): - if host not in hosts + hostsf: - failed = True - break - for x in tagsf + tags: - if x not in taglist: - failed = True - break - if failed: - break - os.remove(tagfile) - os.remove(hostfile) - if failed: - self.fail() - - def test_inventory_tag_del_for_all_hosts(self): - tags = ("all",) - tagsf = ("charge",) - tagfile = op.join(fixtures, "tags") - with open(tagfile, "w") as f: - for x in tagsf: - f.write("{}\n".format(x)) - invTag = inventory.InventoryTag(db_basedir=inventory_dir, - action="del", tags=tags, - tagfile=tagfile) - invTag.run() - invList = inventory.InventoryList(db_basedir=inventory_dir) - failed = False - for host, taglist in invList.entries(): - for x in tagsf + tags: - if x in taglist: - failed = True - break - if failed: - break - os.remove(tagfile) - if failed: - self.fail() - - def test_inventory_tag_del(self): - tags = ("europe", "africa",) - tagsf = ("free", ) - hosts = ("loadbalancer1", "loadbalancer2", "shell2",) - hostsf = ("web2", "web3",) - tagfile = op.join(fixtures, "tags") - with open(tagfile, "w") as f: - for x in tagsf: - f.write("{}\n".format(x)) - hostfile = op.join(fixtures, "hosts") - with open(hostfile, "w") as f: - for x in hostsf: - f.write("{}\n".format(x)) - invTag = inventory.InventoryTag(db_basedir=inventory_dir, - action="del", tags=tags, - tagfile=tagfile, hosts=hosts, - hostfile=hostfile) - invTag.run() - invList = inventory.InventoryList(db_basedir=inventory_dir, - hosts=hosts + hostsf) - failed = False - for host, taglist in invList.entries(): - if host not in hosts + hostsf: - failed = True - break - for x in tagsf + tags: - if x in taglist: - failed = True - break - if failed: - break - os.remove(tagfile) - os.remove(hostfile) - if failed: - self.fail() - - def test_inventory_tag_del_all_tags(self): - hosts = ("web3", "shell1",) - hostsf = ("shell2", "loadbalancer1",) - hostfile = op.join(fixtures, "hosts") - with open(hostfile, "w") as f: - for x in hostsf: - f.write("{}\n".format(x)) - invHost = inventory.InventoryHost(db_basedir=inventory_dir, - action="del", all=True, - hosts=hosts, hostfile=hostfile) - invHost.run() - invList = inventory.InventoryList(db_basedir=inventory_dir, - hosts=hosts + hostsf) - for host, htags in invList.entries(): - self.assertEqual(htags, ()) - os.remove(hostfile) - - -if __name__ == "__main__": - unittest.main() diff --git a/cdist/test/manifest/__init__.py b/cdist/test/manifest/__init__.py index 68e777a4..c375a80f 100644 --- a/cdist/test/manifest/__init__.py +++ b/cdist/test/manifest/__init__.py @@ -40,7 +40,6 @@ 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): @@ -49,116 +48,67 @@ class ManifestTestCase(test.CdistTestCase): self.temp_dir = self.mkdtemp() out_path = self.temp_dir - hostdir = cdist.str_hash(self.target_host[0]) - base_root_path = os.path.join(out_path, hostdir) self.local = local.Local( target_host=self.target_host, - target_host_tags=self.target_host_tags, - base_root_path=base_root_path, - host_dir_name=hostdir, - exec_path=cdist.test.cdist_exec_path, + base_path=out_path, + exec_path = cdist.test.cdist_exec_path, add_conf_dirs=[conf_dir]) self.local.create_files_dirs() self.manifest = manifest.Manifest(self.target_host, self.local) - self.log = logging.getLogger(self.target_host[0]) + self.log = logging.getLogger(self.target_host) def tearDown(self): os.environ = self.orig_environ 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 - old_loglevel = logging.root.getEffectiveLevel() - self.log.setLevel(logging.VERBOSE) - manifest = cdist.core.manifest.Manifest(self.target_host, self.local) - manifest.run_initial_manifest(initial_manifest) + self.manifest.run_initial_manifest(initial_manifest) with open(output_file, 'r') as fd: output_string = fd.read() 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[0]) - self.assertEqual(output_dict['__target_hostname'], - self.local.target_host[1]) - self.assertEqual(output_dict['__target_fqdn'], - self.local.target_host[2]) + 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) - self.assertEqual(output_dict['__target_host_tags'], - self.local.target_host_tags) - self.assertEqual(output_dict['__cdist_log_level'], - str(logging.VERBOSE)) - self.assertEqual(output_dict['__cdist_log_level_name'], 'VERBOSE') - self.log.setLevel(old_loglevel) 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.create() + cdist_object = core.CdistObject(cdist_type, self.local.object_path, 'whatever') handle, output_file = self.mkstemp(dir=self.temp_dir) os.close(handle) os.environ['__cdist_test_out'] = output_file - old_loglevel = self.log.getEffectiveLevel() - self.log.setLevel(logging.VERBOSE) - manifest = cdist.core.manifest.Manifest(self.target_host, self.local) - manifest.run_type_manifest(cdist_object) + self.manifest.run_type_manifest(cdist_object) with open(output_file, 'r') as fd: output_string = fd.read() 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[0]) - self.assertEqual(output_dict['__target_hostname'], - self.local.target_host[1]) - self.assertEqual(output_dict['__target_fqdn'], - self.local.target_host[2]) + 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) - self.assertEqual(output_dict['__target_host_tags'], - self.local.target_host_tags) - self.assertEqual(output_dict['__cdist_log_level'], - str(logging.VERBOSE)) - self.assertEqual(output_dict['__cdist_log_level_name'], 'VERBOSE') - self.log.setLevel(old_loglevel) - def test_loglevel_env_setup(self): + def test_debug_env_setup(self): current_level = self.log.getEffectiveLevel() self.log.setLevel(logging.DEBUG) manifest = cdist.core.manifest.Manifest(self.target_host, self.local) - self.assertTrue("__cdist_log_level" in manifest.env) - self.assertTrue("__cdist_log_level_name" in manifest.env) - self.assertEqual(manifest.env["__cdist_log_level"], - str(logging.DEBUG)) - self.assertEqual(manifest.env["__cdist_log_level_name"], 'DEBUG') + 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 8057ca42..7ce983ab 100755 --- a/cdist/test/manifest/fixtures/conf/manifest/dump_environment +++ b/cdist/test/manifest/fixtures/conf/manifest/dump_environment @@ -3,13 +3,7 @@ cat > $__cdist_test_out << DONE PATH: $PATH __target_host: $__target_host -__target_hostname: $__target_hostname -__target_fqdn: $__target_fqdn __global: $__global __cdist_type_base_path: $__cdist_type_base_path __manifest: $__manifest -__files: $__files -__target_host_tags: $__target_host_tags -__cdist_log_level: $__cdist_log_level -__cdist_log_level_name: $__cdist_log_level_name DONE diff --git a/cdist/test/manifest/fixtures/conf/type/__dump_environment/manifest b/cdist/test/manifest/fixtures/conf/type/__dump_environment/manifest index a38050f9..e135de35 100755 --- a/cdist/test/manifest/fixtures/conf/type/__dump_environment/manifest +++ b/cdist/test/manifest/fixtures/conf/type/__dump_environment/manifest @@ -3,8 +3,6 @@ cat > $__cdist_test_out << DONE PATH: $PATH __target_host: $__target_host -__target_hostname: $__target_hostname -__target_fqdn: $__target_fqdn __global: $__global __cdist_type_base_path: $__cdist_type_base_path __type: $__type @@ -12,8 +10,4 @@ __self: $__self __object: $__object __object_id: $__object_id __object_name: $__object_name -__files: $__files -__target_host_tags: $__target_host_tags -__cdist_log_level: $__cdist_log_level -__cdist_log_level_name: $__cdist_log_level_name DONE diff --git a/cdist/test/message/__init__.py b/cdist/test/message/__init__.py index 61cd5d97..653847f1 100644 --- a/cdist/test/message/__init__.py +++ b/cdist/test/message/__init__.py @@ -25,15 +25,14 @@ 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) @@ -49,6 +48,7 @@ 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 5a27c9d7..98de09f8 100644 --- a/cdist/util/fsproperty.py +++ b/cdist/util/fsproperty.py @@ -58,7 +58,7 @@ class FileList(collections.MutableSequence): with open(self.path) as fd: for line in fd: lines.append(line.rstrip('\n')) - except EnvironmentError: + except EnvironmentError as e: # error ignored pass return lines @@ -127,16 +127,7 @@ class DirectoryDict(collections.MutableMapping): def __getitem__(self, key): try: with open(os.path.join(self.path, key), "r") as fd: - value = fd.read().splitlines() - # if there is no value/empty line then return '' - # if there is only one value then return that value - # if there are multiple lines in file then return list - if not value: - return '' - elif len(value) == 1: - return value[0] - else: - return value + return fd.read().rstrip('\n') except EnvironmentError: raise KeyError(key) @@ -145,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: @@ -184,19 +175,14 @@ 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/cdist/util/ipaddr.py b/cdist/util/ipaddr.py deleted file mode 100644 index 9b730225..00000000 --- a/cdist/util/ipaddr.py +++ /dev/null @@ -1,92 +0,0 @@ -# -*- 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 socket -import logging - - -def resolve_target_addresses(host, family=0): - host_name = resolve_target_host_name(host, family) - host_fqdn = resolve_target_fqdn(host) - return (host, host_name, host_fqdn) - - -def resolve_target_host_name(host, family=0): - log = logging.getLogger(host) - try: - # getaddrinfo returns a list of 5-tuples: - # (family, type, proto, canonname, sockaddr) - # where sockaddr is: - # (address, port) for AF_INET, - # (address, port, flow_info, scopeid) for AF_INET6 - ip_addr = socket.getaddrinfo( - host, None, family=family, type=socket.SOCK_STREAM)[0][4][0] - # gethostbyaddr returns triple - # (hostname, aliaslist, ipaddrlist) - host_name = socket.gethostbyaddr(ip_addr)[0] - log.debug("derived host_name for host \"{}\": {}".format( - host, host_name)) - except (socket.gaierror, socket.herror) as e: - log.warning("Could not derive host_name for {}" - ", $host_name will be empty. Error is: {}".format(host, e)) - # in case of error provide empty value - host_name = '' - return host_name - - -def resolve_target_fqdn(host): - log = logging.getLogger(host) - try: - host_fqdn = socket.getfqdn(host) - log.debug("derived host_fqdn for host \"{}\": {}".format( - host, host_fqdn)) - except socket.herror as e: - log.warning("Could not derive host_fqdn for {}" - ", $host_fqdn will be empty. Error is: {}".format(host, e)) - # in case of error provide empty value - host_fqdn = '' - return host_fqdn - - -# check whether addr is IPv6 -try: - # python 3.3+ - import ipaddress - - def is_ipv6(addr): - try: - return ipaddress.ip_address(addr).version == 6 - except ValueError: - return False -except ImportError: - # fallback for older python versions - def is_ipv6(addr): - try: - socket.inet_aton(addr) - return False - except socket.error: - pass - try: - socket.inet_pton(socket.AF_INET6, addr) - return True - except socket.error: - pass - return False diff --git a/cdist/util/remoteutil.py b/cdist/util/remoteutil.py deleted file mode 100644 index 505c4598..00000000 --- a/cdist/util/remoteutil.py +++ /dev/null @@ -1,50 +0,0 @@ -# -*- 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 . -# -# - - -def inspect_ssh_mux_opts(): - """Inspect whether or not ssh supports multiplexing options. - - Return string containing multiplexing options if supported. - If ControlPath is supported then placeholder for that path is - specified and can be used for final string formatting. - For example, this function can return string: - "-o ControlMaster=auto -o ControlPersist=125 -o ControlPath={}". - Then it can be formatted: - mux_opts_string.format('/tmp/tmpxxxxxx/ssh-control-path'). - """ - import subprocess - - wanted_mux_opts = { - "ControlPath": "{}", - "ControlMaster": "auto", - "ControlPersist": "2h", - } - mux_opts = " ".join([" -o {}={}".format( - x, wanted_mux_opts[x]) for x in wanted_mux_opts]) - try: - subprocess.check_output("ssh {}".format(mux_opts), - stderr=subprocess.STDOUT, shell=True) - except subprocess.CalledProcessError as e: - subproc_output = e.output.decode().lower() - if "bad configuration option" in subproc_output: - return "" - return mux_opts diff --git a/completions/bash/cdist-completion.bash b/completions/bash/cdist-completion.bash deleted file mode 100644 index 1311384a..00000000 --- a/completions/bash/cdist-completion.bash +++ /dev/null @@ -1,102 +0,0 @@ -_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 -q --quiet -v --verbose -V --version" - cmds="banner config install inventory shell" - - case "${prevprev}" in - shell) - case "${prev}" in - -s|--shell) - shells=$(grep -v '^#' /etc/shells) - COMPREPLY=( $(compgen -W "${shells}" -- ${cur}) ) - return 0 - ;; - esac - ;; - inventory) - case "${prev}" in - list) - opts="-h --help -q --quiet -v --verbose -b --beta \ - -I --invento/y -a --all -f --file -H --host-only \ - -t --tag" - COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) - return 0 - ;; - add-host) - opts="-h --help -q --quiet -v --verbose -b --beta \ - -I --inventory -f --file" - COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) - return 0 - ;; - del-host) - opts="-h --help -q --quiet -v --verbose -b --beta \ - -I --inventory -a --all -f --file" - COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) - return 0 - ;; - add-tag) - opts="-h --help -q --quiet -v --verbose -b --beta \ - -I --inventory -f --file -T --tag-file -t --taglist" - COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) - return 0 - ;; - del-tag) - opts="-h --help -q --quiet -v --verbose -b --beta \ - -I --inventory -a --all -f --file -T --tag-file -t --taglist" - COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) - return 0 - ;; - esac - ;; - esac - - case "${prev}" in - -*) - COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) - return 0 - ;; - banner) - opts="-h --help -q --quiet -v --verbose" - COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) - return 0 - ;; - shell) - opts="-h --help -q --quiet -v --verbose -s --shell" - COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) - return 0 - ;; - config|install) - opts="-h --help -q --quiet -v --verbose -b --beta \ - -I --inventory -C --cache-path-pattern -c --conf-dir \ - -f --file -i --initial-manifest -A --all-tagged \ - -j --jobs -n --dry-run -o --out-dir -p --parallel \ - -r --remote-out-dir \ - -s --sequential --remote-copy --remote-exec -t --tag -a --all" - COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) - return 0 - ;; - inventory) - cmds="list add-host del-host add-tag del-tag" - opts="-h --help -q --quiet -v --verbose" - COMPREPLY=( $(compgen -W "${opts} ${cmds}" -- ${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 deleted file mode 100644 index 405023ed..00000000 --- a/completions/zsh/_cdist +++ /dev/null @@ -1,77 +0,0 @@ -#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 install inventory shell -h --help -q --quiet -v --verbose -V --version)' - ;; - *) - case $words[2] in - -*) - opts=(-h --help -q --quiet -v --verbose -V --version) - compadd "$@" -- $opts - ;; - banner) - opts=(-h --help -q --quiet -v --verbose) - compadd "$@" -- $opts - ;; - shell) - case $words[3] in - -s|--shell) - shells=($(grep -v '^#' /etc/shells)) - compadd "$@" -- $shells - ;; - *) - opts=(-h --help -q --quiet -v --verbose -s --shell) - compadd "$@" -- $opts - ;; - esac - ;; - config|install) - opts=(-h --help -q --quiet -v --verbose -a --all -b --beta -C --cache-path-pattern -c --conf-dir -f --file -i --initial-manifest -j --jobs -n --dry-run -o --out-dir -p --parallel -r --remote-out-dir -s --sequential --remote-copy --remote-exec -t --tag -I --inventory -A --all-tagged) - compadd "$@" -- $opts - ;; - inventory) - case $words[3] in - list) - opts=(-h --help -q --quiet -v --verbose -b --beta -I --inventory -a --all -f --file -H --host-only -t --tag) - compadd "$@" -- $opts - ;; - add-host) - opts=(-h --help -q --quiet -v --verbose -b --beta -I --inventory -f --file) - compadd "$@" -- $opts - ;; - del-host) - opts=(-h --help -q --quiet -v --verbose -b --beta -I --inventory -a --all -f --file) - compadd "$@" -- $opts - ;; - add-tag) - opts=(-h --help -q --quiet -v --verbose -b --beta -I --inventory -f --file -T --tag-file -t --taglist) - compadd "$@" -- $opts - ;; - del-tag) - opts=(-h --help -q --quiet -v --verbose -b --beta -I --inventory -a --all -f --file -T --tag-file -t --taglist) - compadd "$@" -- $opts - ;; - *) - cmds=(list add-host del-host add-tag del-tag) - opts=(-h --help -q --quiet -v --verbose) - compadd "$@" -- $cmds $opts - ;; - esac - ;; - *) - ;; - esac - esac -} - -_cdist "$@" diff --git a/configuration/cdist.cfg.skeleton b/configuration/cdist.cfg.skeleton deleted file mode 100644 index 22c1ccaf..00000000 --- a/configuration/cdist.cfg.skeleton +++ /dev/null @@ -1,73 +0,0 @@ -[GLOBAL] -# archiving -# Use specified archiving. Valid values include: -# none, tar, tgz, tbz2 and txz. -# archiving = tar -# -# beta -# Enable beta functionality. It recognizes boolean values from -# yes/no, on/off, true/false and 1/0 -# beta = no -# -# cache_path_pattern -# Specify cache path pattern. -# cache_path_pattern = %h -# -# conf_dir -# List of configuration directories separated with the character conventionally -# used by the operating system to separate search path components (as in PATH), -# such as ':' for POSIX or ';' for Windows. -# If also specified at command line then values from command line are -# appended to this value. -# conf_dir = : -# -# init_manifest -# Specify default initial manifest. -# init_mainfest = -# -# inventory_dir -# Specify inventory directory. -# inventory_dir = -# -# jobs -# Specify number of jobs for parallel processing. If -1 then the default, -# number of CPU's in the system is used. If 0 then parallel processing in -# jobs is disabled. If set to positive number then specified maximum -# number of processes will be used. -# jobs = 0 -# -# local_shell -# Shell command used for local execution. -# local_shell = /bin/sh -# -# out_path -# Directory to save cdist output in. -# out_path = -# -# parallel -# Process hosts in parallel. If -1 then the default, number of CPU's in -# the system is used. If 0 then parallel processing of hosts is disabled. -# If set to positive number then specified maximum number of processes -# will be used. -# parallel = 0 -# -# remote_copy -# Command to use for remote copy (should behave like scp). -# remote_copy = -# -# remote_exec -# Command to use for remote execution (should behave like ssh). -# remote_exec = -# -# remote_out_path -# Directory to save cdist output in on the target host. -# remote_out_path = /var/lib/cdist -# -# remote_shell -# Shell command at remote host used for remote execution. -# remote_shell = /bin/sh -# -# verbosity -# Set verbosity level. Valid values are: -# ERROR, WARNING, INFO, VERBOSE, DEBUG, TRACE and OFF. -# verbosity = INFO diff --git a/docs/2016-06-06.org b/docs/2016-06-06.org deleted file mode 100644 index 8e3624a8..00000000 --- a/docs/2016-06-06.org +++ /dev/null @@ -1,7 +0,0 @@ -* 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 7594a6d4..e40dd5c0 100644 --- a/docs/changelog +++ b/docs/changelog @@ -1,523 +1,9 @@ Changelog --------- -5.1.3: 2019-08-30 - * Build: Overcome bash CDPATH when building docs (Dmitry Bogatov) - * Type __grafana_dashboard: Update distribution name, package signing key URI and repository URI (Dominique Roux) - * Type __letsencrypt_cert: Add Devuan Beowulf support (Nico Schottelius) - * Type __letsencrypt_cert: Fix Devuan Ascii: support (Nico Schottelius) - * Type __docker: Add devuan support (Dominique Roux) - * Type __docker_swarm: Fix for Docker 19.03 (Ľubomír Kučera) + * Changes are always commented with their author in (braces) + * Exception: No braces means author == Nico Schottelius -5.1.2: 2019-06-21 - * Core: Add support for type parameters deprecation (Darko Poljak) - * Type __acl: Rewrite and improve (Ander Punnar) - -5.1.1: 2019-05-28 - * Type __apt_key: Use gpg key, fallback to deprecated apt-key (Ander Punnar) - * Type __acl: Fix and improve (Ander Punnar) - * Documentation: Document type stdin inside loop caveats (Darko Poljak) - -5.1.0: 2019-05-22 - * Type __consul: Add alpine support (Nico Schottelius) - * Type __consul: Add version 1.5.0 (Nico Schottelius) - * Type __consul_agent: Add alpine support (Nico Schottelius) - * New helper script: cdist-new-type (Steven Armstrong, Darko Poljak) - * Core: Add support for deprecated type marker (Darko Poljak) - -5.0.2: 2019-05-17 - * Type __package_apk: Fix @repo handling in explorer (Nico Schottelius) - * Type __postfix: Add alpine support (Nico Schottelius) - * Type __postfix_postconf: Add alpine support (Nico Schottelius) - * Type __user: Add alpine support (Nico Schottelius) - * Core: Set __cdist_dry_run env var (Ander Punnar) - -5.0.1: 2019-05-09 - * Documentation: Add 'Perils of CDIST_ORDER_DEPENDENCY' sub-section (Darko Poljak) - * Build: Clean and separate end user targets into Makefile and maintainer targets into build-helper (Darko Poljak) - * Core: Update residual references to old cdist homepage (Darko Poljak) - * Documentation: Update residual references to old cdist homepage and git source (Darko Poljak) - * Type __cdist: Fix non working 'git://' protocol source (Darko Poljak) - -5.0.0: 2019-05-05 - * Type __zypper_service: Fix spelling error in manpage (Dmitry Bogatov) - * Explorer init: Add support for OpenBSD (sideeffect42) - * Type __postgres_database: Run psql with -w (no-password) (sideeffect42) - * Type __postgres_role: Run psql with -w (no-password) (sideeffect42) - * Type __block: Quote prefix/suffix - fix when prefix/suffix contains quotes (sideeffect42) - * Build: Update due to migration to code.ungleich.ch (Darko Poljak) - * Documentation: Update due to migration to code.ungleich.ch (Darko Poljak) - * Core: Detect and report dependency cycle as soon as possible (Darko Poljak) - * Core, documentation: Release -j/--jobs option, i.e. make it non-beta (Darko Poljak) - * Documentation: Update due to new cdist website (Darko Poljak) - * Build: Update due to new cdist website (Darko Poljak) - -4.11.1: 2019-04-22 - * Core: Improve explorer error reporting (Darko Poljak) - * Type __directory: explorer stat: add support for Solaris (Ander Punnar) - * Type __file: explorer stat: add support for Solaris (Ander Punnar) - * Type __ssh_authorized_keys: Remove legacy code (Ander Punnar) - * Explorer disks: Bugfix: do not break config in case of unsupported OS - which was introduced in 4.11.0, print message to stderr and empty disk list - to stdout instead (Darko Poljak) - -4.11.0: 2019-04-20 - * Type __package: Add __package_apk support (Nico Schottelius) - * Type __directory: Add alpine support (Nico Schottelius) - * Type __file: Add alpine support (Nico Schottelius) - * Type __hostname: Add alpine support (Nico Schottelius) - * Type __locale: Add alpine support (Nico Schottelius) - * Type __start_on_boot: Add alpine support (Nico Schottelius) - * Type __timezone: Add alpine support (Nico Schottelius) - * Type __start_on_boot: gentoo: check all runlevels in explorer (Nico Schottelius) - * New type: __package_apk (Nico Schottelius) - * Type __acl: Add support for ACL mask (Dimitrios Apostolou) - * Core: Fix circular dependency for CDIST_ORDER_DEPENDENCY (Darko Poljak) - * Type __acl: Improve the type (Ander Punnar) - * Explorer interfaces: Simplify code, be more compatible (Ander Punnar) - * Explorer disks: Remove assumable default/fallback, for now explicitly support only Linux and BSDs (Ander Punnar, Darko Poljak) - -4.10.11: 2019-04-13 - * Core: Fix broken quiet mode (Darko Poljak) - * Build: Add version.py into generated raw source archive (Darko Poljak) - * Explorer disks: Fix detecting disks, fix/add support for BSDs (Ander Punnar) - * Type __file: Fix stat explorer for BSDs (Ander Punnar) - * Type __directory: Fix stat explorer for BSDs (Ander Punnar) - -4.10.10: 2019-04-11 - * New types: __ufw and __ufw_rule (Mark Polyakov) - * Type __link: Add messaging (Ander Punnar) - * Debugging: Rename debug-dump.sh to cdist-dump (Darko Poljak) - * Documentation: Add cdist-dump man page (Darko Poljak) - -4.10.9: 2019-04-09 - * Type __ssh_authorized_keys: Properly handle multiple --option params (Steven Armstrong) - * Debugging: Add debug dump helper script (Darko Poljak) - * Type __file: Bugfix: fire onchange for present and exists states if no attribute is changed (Darko Poljak) - -4.10.8: 2019-04-06 - * Type __clean_path: Fix list explorer exit code if path not directory or does not exist (Ander Punnar) - * New type: __check_messages (Ander Punnar) - -4.10.7: 2019-03-30 - * Build: Migrate from pep8 to pycodestyle (Darko Poljak) - * Type __start_on_boot: Implement state absent for OpenBSD (Daniel Néri) - * Explorers cpu_cores, disks: Add support for OpenBSD (Daniel Néri) - * Type __staged_file: Use portable -p instead of --tmpdir for mktemp (Silas Silva) - * Type __line: Add onchange parameter (Ander Punnar) - * Type __file: Add onchange parameter (Ander Punnar) - * New type: __clean_path (Ander Punnar) - -4.10.6: 2019-02-15 - * Type __prometheus_alertmanager: Add startup flag (Dominique Roux) - * Types __zypper_repo, __zypper_service: Re-add the use of echo in explorers (Daniel Heule) - -4.10.5: 2018-12-21 - * Type __group: Fix/remove '--' from echo command (Dimitrios Apostolou) - * New type: __ping (Olliver Schinagl) - * Type __postgres_role: Fix broken syntax (Nico Schottelius, Darko Poljak) - * Type __consul_agent: Add Debian 9 support (Jin-Guk Kwon) - * Documentation: Fix broken links (Rage ) - * Type __docker: Add version parameter (Jonas Weber) - * Type __sysctl: Refactor for better OS support (Takashi Yoshi) - * Types __package_*: Add messaging upon installation/removal (Takashi Yoshi) - * Type __package_pkg_openbsd: Reworked (Takashi Yoshi) - -4.10.4: 2018-11-03 - * Core: Transfer all files of a directory at once instead of calling copy once per file (myeisha) - * Core: Add timestamp (optional) to log messages (Darko Poljak) - * Explorers and types: Fix shellcheck found problems and encountered bugs (Jonas Weber, Thomas Eckert, Darko Poljak) - * Build: Add shellcheck makefile target and check when doing release (Darko Poljak) - * Type __consul: Add newest versions (Dominique Roux) - * Type __user: Remove annoying output, handle state param gracefully, add messages for removal (Thomas Eckert) - * Core: Fix checking for conflicting parameters for multiple values parameters (Darko Poljak) - * Documentation: Various fixes (Thomas Eckert) - * Various types: Improve OpenBSD support (sideeffect42) - -4.10.3: 2018-09-23 - * New global explorer: os_release (Ľubomír Kučera) - * Type __docker: Update type, install docker CE (Ľubomír Kučera) - * Type __package_apt: Write a message when a package is installed or removed; shellcheck (Jonas Weber) - * Documentation: Add 'Dive into real world cdist' walkthrough chapter (Darko Poljak) - * Core: Remove duplicate remote mkdir calls in explorer transfer (myeisha) - -4.10.2: 2018-09-06 - * Type __letsencrypt_cert: Add support for devuan ascii (Darko Poljak) - * Type __systemd_unit: Fix minor issues and add masking unit files support (Adam Dej) - * Type __grafana_dashboard: Fix devuan ascii support (Dominique Roux) - * Type __apt_source: Add nonparallel marker (Darko Poljak) - * Type __package_update_index: Fix error when using OS not using apt (Stu Zhao) - * Type __package_update_index: Support --maxage for type pacman (Stu Zhao) - * Type __letsencrypt_cert: Fix explorers: check that certbot exists before using it (Darko Poljak) - -4.10.1: 2018-06-21 - * Type __letsencrypt_cert: Fix temp file location and removal (Darko Poljak) - * Type __line: Handle missing file in __line explorer gracefully (Jonas Weber) - * Documentation: Add env vars usage idiom for writing types (Darko Poljak) - -4.10.0: 2018-06-17 - * New type: __acl (Ander Punnar) - * Core: Disable config parser interpolation (Darko Poljak) - * Type __sysctl: Use sysctl.d location if exists (Darko Poljak) - * Type __line: Rewrite and support --before and --after (Steven Armstrong) - -4.9.1: 2018-05-30 - * New type: __install_coreos (Ľubomír Kučera) - * Type __consul_agent: Add LSB init header (Nico Schottelius) - * Type __package_yum: Fix explorer when name contains package name with exact version specified (Aleksandr Dinu) - * Type __letsencrypt_cert: Use object id as domain if domain param is not specified (Darko Poljak) - -4.9.0: 2018-05-17 - * Type __docker_stack: Use --with-registry-auth option (Ľubomír Kučera) - * New type: __docker_config (Ľubomír Kučera) - * New type: __docker_secret (Ľubomír Kučera) - * Type __letsencrypt_cert: Rewritten; WARN: breaks backward compatibility (Ľubomír Kučera) - * Core: Fix NameError: name 'cdist_object' is not defined (Darko Poljak) - -4.8.4: 2018-04-20 - * Documentation, type manpages: Fix spelling (Dmitry Bogatov) - * New explorer: is-freebsd-jail (Kamila Součková) - * Types __hostname, __start_on_boot, __sysctl: Support FreeBSD (Kamila Součková) - * Type __install_config: set environment variable to distinguish between - install-config and regular config (Steven Armstrong) - * Core: Improve error reporting (Darko Poljak) - -4.8.3: 2018-03-16 - * Type __key_value: Add onchange parameter (Kamila Součková) - * Types __prometheus_server, __prometheus_alertmanager, __grafana_dashboard: - Work with packages instead of go get, remove __daemontools dependency and clean up (Kamila Součková) - * Documentation: Fix manpage generation (Darko Poljak) - * New type: __docker_swarm (Ľubomír Kučera) - * New type: __docker_stack (Ľubomír Kučera) - -4.8.2: 2018-03-10 - * Core: Fix quiet argument access for bare cdist command (Darko Poljak) - -4.8.1: 2018-03-09 - * Type __consul: Add option for directly downloading on target host (Darko Poljak) - * Core: Add -4 and -6 params to force IPv4, IPv6 addresses respectively (Darko Poljak) - * Type __package_update_index: Fix messaging (Thomas Eckert) - * Type __package_dpkg: Add state parameter and messaging (Thomas Eckert) - * Core: Fix a case when HOME is set but empty (Darko Poljak) - * Core: Fix non-existent manifest non graceful handling (Darko Poljak) - * Core: Fix main and inventory parent argparse options (Darko Poljak) - * Core: Fix lost error info with parallel jobs (option -j) (Darko Poljak) - * Core: Fix determining beta value through configuration (Darko Poljak) - * Core: Fix determining save_output_streams value through configuration (Darko Poljak) - * Core: Support in-distribution config file (Darko Poljak) - * New type: __apt_default_release (Matthijs Kooijman) - * Type __file: Add pre-exists state (Matthijs Kooijman) - * Type __grafana_dashboard: Add support for stretch + ascii (Nico Schottelius) - * Core: Fix idna (getaddrinfo) unicode tracebak for invalid host name (Darko Poljak) - -4.8.0: 2018-02-14 - * Core: Skip empty lines in parameter files (Darko Poljak) - * Explorer memory: Support OpenBSD (Philippe Gregoire) - * Type __install_config: re-export cdist log level during installation (Steven Armstrong) - * Type __sysctl: Add support for CoreOS (Ľubomír Kučera) - * Type __systemd_unit: Various improvements (Ľubomír Kučera) - * Type __line: Support regex beginning with '-' (Philippe Gregoire) - * Type __letsencrypt_cert: Add nonparallel; make admin-email required (Kamila Součková) - * Type __package_pkgng_freebsd: Redirect stdout and stderr to /dev/null instead of closing them (michal-hanu-la) - * Type __daemontools: Make it more robust and clean up the code (Kamila Součková) - * Core: Save output streams (Steven Armstrong, Darko Poljak) - * Documentation: Add local cache overview (Darko Poljak) - * Type __systemd_unit: Fix handling stdin (Jonas Weber) - * Type __package_apt: Add --purge-if-absent parameter (Jonas Weber) - * Type __package_update_index: Add --maxage parameter for apt and add message if index was updated(Thomas Eckert) - * Type __motd: Support reading from stdin (Jonas Weber) - * Type __issue: Support reading from stdin (Jonas Weber) - * Type __package_apt: Add support for --version parameter (Darko Poljak) - * Type __letsencrypt_cert: Add --renew-hook parameter(Darko Poljak) - * Core: Support disabling saving output streams (Darko Poljak) - * Type __apt_source: Remove update index dependency; call index update in gencode-remote (Darko Poljak) - -4.7.3: 2017-11-10 - * Type __ccollect_source: Add create destination parameter (Dominique Roux) - * Type __ssh_authorized_key: Add messaging (Thomas Eckert) - * New type: __letsencrypt_cert (Nico Schottelius, Kamila Součková) - * Core: Warn about invalid type in conf dir and continue instead of error (Darko Poljak) - * New type: __systemd_unit (Ľubomír Kučera) - * Type __letsencrypt_cert: Add support for debian stretch (Daniel Tschada) - * Type __line: Fix a case for absent when line contains single quotes (Darko Poljak) - * Type __config_file: Fix onchange command not being executed (Ľubomír Kučera) - -4.7.2: 2017-10-22 - * Type __hostname: Add support for CoreOS (Ľubomír Kučera) - * Type __timezone: Add support for CoreOS (Ľubomír Kučera) - * Explorer os: Fix for devuan ascii (Kamila Součková) - -4.7.1: 2017-10-01 - * Type __line: Add messaging (Thomas Eckert) - * Documentation: Fix documentation for building custom man-pages from non-standard path (Thomas Eckert) - * Core: Fix running scripts with execute bit when name without path is specified (Ander Punnar) - * Type __process: Add messaging (Thomas Eckert) - -4.7.0: 2017-09-22 - * Core: Add configuration/config file support (Darko Poljak) - * Core: Implement simple integration API (unstable) (Darko Poljak) - * Explorer machine_type: Detect kvm on proxmox (Sven Wick) - * Types __prometheus_server, __prometheus_alertmanager: Bugfixes (Kamila Součková) - * New type: __prometheus_exporter (Kamila Součková) - * Type __daemontools: Improve it on FreeBSD (Kamila Součková) - * Type __package_pkg_openbsd: Fix use of --name (Philippe Gregoire) - * Type __package_pkg_openbsd: Fix pkg_version explorer (Philippe Gregoire) - * Type __prometheus_exporter: Fixes + go version bump (Kamila Součková) - * Core, types: __cdist_loglevel -> __cdist_log_level (Darko Poljak) - * Core, types: Add __cdist_log_level_name env var with vlaue of log level name (Darko Poljak) - * Core: Make cdist honor __cdist_log_level env var (Darko Poljak) - * Core: Add -l/--log-level option (Darko Poljak) - * Type __install_stage: Fix __debug -> __cdist_log_level (Darko Poljak) - * Documentation: Document __cdist_log_level (Darko Poljak) - * Core: Log ERROR to stderr and rest to stdout (Darko Poljak, Steven Armstrong) - * Type __ssh_authorized_key: Bugfix the case where invalid key clears a file and add key validation (Darko Poljak) - -4.6.1: 2017-08-30 - * Type __user: Explore with /etc files (passwd, group, shadow) (Philippe Gregoire) - * Explorer init: Use pgrep instead of ps for Linux (Philippe Gregoire) - * Type __apt_key_uri: Redirect stderr of apt-key to /dev/null (Mark Verboom) - * Type __package_pkg_openbsd: Support the empty flavor (Philippe Gregoire) - * Type __package_pkg_openbsd: Support using /etc/installurl (Philippe Gregoire) - * Type __user_groups: Support OpenBSD (Philippe Gregoire) - * Type __hostname: Allow hostnamectl to fail silently (Steven Armstrong) - * Type __install_config: Use default default __remote_{copy,exec} in custom __remote_{copy,exec} scripts (Steven Armstrong) - * Type __ssh_authorized_key: Fix removing ssh key that is last one in the file (Darko Poljak) - -4.6.0: 2017-08-25 - * Core: Add inventory functionality (Darko Poljak) - * Core: Expose inventory host tags in __target_host_tags env var (Darko Poljak) - * Type __timezone: Check current timezone before doing anything (Ander Punnar) - * Core: Add -p HOST_MAX argument (Darko Poljak) - * Core: Add archiving support for transferring directory - new -R beta option (Darko Poljak) - * Core: Fix ssh connection multiplexing race condition (Darko Poljak) - * Core: Fix emulator race conditions with -j option (Darko Poljak) - * Documentation: Cleanup (Darko Poljak) - * Explorer os: Get ID from /etc/os-release (Philippe Gregoire) - -4.5.0: 2017-07-20 - * Types: Fix install types (Steven Armstrong) - * Core: Add -r command line option for setting remote base path (Steven Armstrong) - * Core: Allow manifest and gencode scripts to be written in any language (Darko Poljak) - * Documentation: Improvements to the english and fix typos (Mesar Hameed) - * Core: Merge -C custom cache path pattern option from beta branch (Darko Poljak) - * Core: Improve and cleanup logging (Darko Poljak, Steven Armstrong) - * Core: Remove deprecated -d option (Darko Poljak) - * Type __file: If no --source then create only if there is no file (Ander Punnar) - * Core: Ignore directory entries that begin with dot('.') (Darko Poljak) - * Core: Fix parallel object prepare and run steps and add nonparallel type marker (Darko Poljak) - -4.4.4: 2017-06-16 - * Core: Support -j parallelization for object prepare and object run (Darko Poljak) - * Type __install_mkfs: mkfs.vfat does not support -q (Nico Schottelius) - * Types __go_get, __daemontools*, __prometheus*: Fix missing dependencies, fix arguments (Kamila Součková) - -4.4.3: 2017-06-13 - * Type __golang_from_vendor: Install golang from https://golang.org/dl/ (Kamila Součková) - * Type __go_get: Install go packages using go get (Kamila Součková) - * Explorer kernel_name: uname -s (Kamila Součková) - * Type __sysctl: Add devuan support (Nico Schottelius) - * Type __start_on_boot: Add devuan support (Nico Schottelius) - * Core: Shorten ssh control path (Darko Poljak) - * Type __consul: Add new version and add http check (Kamila Součková) - * New types: __daemontools and __daemontools_service (Kamila Součková) - * New types: __prometheus_server and __prometheus_alertmanager (Kamila Součková) - * New type: __grafana_dashboard (Kamila Součková) - -4.4.2: 2017-03-08 - * Core: Fix suppression of manifests' outputs (Darko Poljak) - * Type __user_groups: Support FreeBSD (Andres Erbsen) - * Type __cron: Fix filter for new cron on sles12 sp2 (Daniel Heule) - * Type __docker: Support absent state (Dominique Roux) - * Type __docker_compose: Support absent state (Dominique Roux) - * New type: __hosts (Dmitry Bogatov) - * New type: __dot_file (Dmitry Bogatov) - -4.4.1: 2016-12-17 - * Documentation: Update docs for types that used man.rst as symbolic links (Darko Poljak) - * Type __cron: Remove '# marker' for raw_command due to cron security (Daniel Heule) - * New type: __docker_compose (Dominique Roux) - * Type __apt_mark: Check supported apt version and if package is installed (Ander Punnar) - * New type: __docker (Steven Armstrong) - * New type: __package_dpkg (Tomas Pospisek) - -4.4.0: 2016-12-03 - * Core: Deprecate -d option and make -v option log level counter (Darko Poljak) - * New type: __postgres_extension (Tomas Pospisek) - * Core, types: Support IPv6 (Darko Poljak) - * Type __consul: Add source and cksum files for Consul 0.7.0 and 0.7.1 (Carlos Ortigoza) - * Type __user: FreeBSD fix (Kamila Souckova) - * New type: __apt_mark (Ander Punnar) - * Type __package_upgrade_all: Do not dist-upgrade by default, add apt-clean and apt-dist-upgrade options (Ander Punnar) - * Core: Correct target_host var in code.py (Darko Poljak) - * All: Merge install feature from 4.0-pre-not-stable (Darko Poljak) - -4.3.2: 2016-10-13 - * Documentation: Update no longer existing links (Simon Walter) - * Core: Add warning message for faulty dependencies case (Darko Poljak) - * Explorer os_version: Use /etc/os-release instead of /etc/SuSE-release (Daniel Heule) - * Type __package: Call __package_pkg_openbsd on openbsd (Andres Erbsen) - * Type __package_pkg_openbsd: Support --version (Andres Erbsen) - * Type __hostname: Support openbsd (Andres Erbsen) - * New type: __firewalld_start: start/stop firewalld and/or enable/disable start on boot (Darko Poljak) - * Bugfix __consul_agent: Config option was misnamed 'syslog' instead of 'enable_syslog' (Steven Armstrong) - -4.3.1: 2016-08-22 - * Documentation: Spelling fixes (Darko Poljak) - * Type __filesystem: Spelling fixes (Dmitry Bogatov) - * Core: Add target_host file to cache since cache dir name can be hash (Darko Poljak) - * Core: Improve hostfile: support comments, skip empty lines (Darko Poljak) - -4.3.0: 2016-08-19 - * Documentation: Add Parallelization chapter (Darko Poljak) - * Core: Add -b, --enable-beta option for enabling beta functionalities (Darko Poljak) - * Core: Add -j, --jobs option for parallel execution and add parallel support for global explorers (currently in beta) (Darko Poljak) - * Core: Add derived env vars for target hostname and fqdn (Darko Poljak) - * New type: __keyboard: Set keyboard layout (Carlos Ortigoza) - * Documentation: Re-license types' man pages to GPLV3+ (Dmitry Bogatov, Darko Poljak) - * New type __filesystem: manage filesystems on devices (Daniel Heule) - * New type: __locale_system (Steven Armstrong, Carlos Ortigoza, Nico Schottelius) - * New type: __sysctl (Steven Armstrong) - -4.2.2: 2016-07-26 - * Core: Fix ssh ControlPath socket file error (Darko Poljak) - * Documentation: Update cdist man page and cdist-references (Darko Poljak) - * Documentation: Change cdist and cdist-type__pyvenv man page licenses to GPLv3+ (Darko Poljak) - * Documentation: Add FILES to cdist man page (Darko Poljak) - -4.2.1: 2016-07-18 - * Build: Fix signed release (Darko Poljak) - * Build: Fix building docs (Darko Poljak) - * Documentation: Fix man pages (Dmitry Bogatov) - * Documentation: Fix spellings (Dmitry Bogatov) - -4.2.0: 2016-07-16 - * Build: Make github signed release (Darko Poljak) - * Core: Fix hostdir: use hash instead of target host (Steven Armstrong) - * 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) - * Type __apt_key: Use pool.sks-keyservers.net as keyserver (Steven Armstrong) - -4.0.0: 2016-05-04 - * Core: Fix bug with parallel hosts operation when output path is specifed (Darko Poljak) - * Type __package_pip: Add support for running as specified user (useful for pip in venv) (Darko Poljak) - * New type: __pyvenv: Manage python virtualenv (Darko Poljak) - * Core: Add CDIST_REMOTE_COPY/EXEC env variables and multiplexing options for default scp/ssh (Darko Poljak) - * Types: Remove bashisms in scripts (Darko Poljak) - * Core: Fix bug in remote command with environment (Darko Poljak) - * Core: Fix bug in local code execution (Darko Poljak) - * Documentation: Fix spelling in manual pages (Dmitry Bogatov) - * New type: __pacman_conf: Manage pacman.conf (Dominique Roux) - * New type: __pacman_conf_integrate: cdist compatible pacman.conf (Dominique Roux) - * Type __consul: Do not install unused package unzip (Steven Armstrong) - * Type __consul: Add source & cksum for 0.5.2 (Steven Armstrong) - * Core: Support object ids '.cdist' (Nico Schottelius) - * Type __apt_norecommends: Also setup autoremove options (Dmitry Bogatov) - * Type __user_groups: Add NetBSD support (Jonathan A. Kollasch) - * Type __timezone: Add NetBSD support (Jonathan A. Kollasch) - * Type __ccollect_source: Add NetBSD support (Jonathan A. Kollasch) - * Type __directory: Add NetBSD support (Jonathan A. Kollasch) - * Type __file: Add NetBSD support (Jonathan A. Kollasch) - * Type __group: Add NetBSD support (Jonathan A. Kollasch) - * Type __consul: Add new consul versions (Nico Schottelius) - * Type __apt_ppa: Do not install legacy package python-software-properties (Steven Armstrong) - -3.1.13: 2015-05-16 - * Type __block: Fix support for non stdin blocks (Dominique Roux) - * Type __consul: Install package unzip (Nico Schottelius) - * Type __consul: Add source & cksum for 0.5.1 (Nico Schottelius) - * Type __consul_agent: Use systemd for Debian 8 (Nico Schottelius) - * Type __firewalld_rule: Ensure firewalld package is present (David Hürlimann) - * Type __locale: Support CentOS (David Hürlimann) - * Type __staged_file: Fix comparison operator (Nico Schottelius) - * Type __user_groups: Support old Linux versions (Daniel Heule) - -3.1.12: 2015-03-19 - * Core: Support object ids '.cdist' (Nico Schottelius) - * New type: __firewalld_rule (Nico Schottelius) - * Type __consul_agent: add support for acl options (Steven Armstrong) - * Type __consul_agent: add support for Debian (Nico Schottelius) - * Type __package_apt: Use default parameters (Antoine Catton) - * Type __package_luarocks: Use default parameters (Antoine Catton) - * Type __package_opkg: Use default parameters (Antoine Catton) - * Type __package_pacman: Use default parameters (Antoine Catton) - * Type __package_pip: Use default parameters (Antoine Catton) - * Type __package_pkg_freebsd: Use default parameters (Antoine Catton) - * Type __package_pkg_openbsd: Use default parameters (Antoine Catton) - * Type __package_pkgng_openbsd: Use default parameters (Antoine Catton) - -3.1.11: 2015-02-27 - * New type: __staged_file: Manage staged files (Steven Armstrong) - * New type: __config_file: Manage configuration files and run code on change (Steven Armstrong) - * New type: __consul: install consul (Steven Armstrong) - * New type: __consul_agent: manage the consul agent (Steven Armstrong) - * New type: __consul_check: manages consul checks (Steven Armstrong) - * New type: __consul_reload: reload consul (Steven Armstrong) - * New type: __consul_service: manages consul services (Steven Armstrong) - * New type: __consul_template: manage the consul-template service (Steven Armstrong) - * New type: __consul_template_template: manage consul-template templates (Steven Armstrong) - * New type: __consul_watch_checks: manages consul checks watches (Steven Armstrong) - * New type: __consul_watch_event: manages consul event watches (Steven Armstrong) - * New type: __consul_watch_key: manages consul key watches (Steven Armstrong) - * New type: __consul_watch_keyprefix: manages consul keyprefix watches (Steven Armstrong) - * New type: __consul_watch_nodes: manages consul nodes watches (Steven Armstrong) - * New type: __consul_watch_service: manages consul service watches (Steven Armstrong) - * New type: __consul_watch_services: manages consul services watches (Steven Armstrong) - * New Type: __rsync (Nico Schottelius) - * Type __start_on_boot: Support Ubuntu upstart (Nico Schottelius) - * Type __timezone: Added support for FreeBSD (Christian Kruse) - -3.1.10: 2015-02-10 - * Core: Fix too many open files bug (#343) - * Type __ssh_authorized_keys: Remove unneeded explorer (Steven Armstrong) - * Type __ssh_authorized_keys: Fix empty output bug of entry explorer (Steven Armstrong) - * Type __package_apt: Add support for --target-release (Nico Schottelius) - * Type __locale: Add support for Ubuntu (Nico Schottelius) - * Type __group: Rewrite (Steven Armstrong) - * Documentation: Fix typo in maintainer file (Stephan Kulla) - -3.1.9: 2014-10-17 - * Type __package_emerge: Fix handling of slotted packages (Daniel Heule) - * Type __package_apt: Use --force-confdef (Ricardo Catalinas Jiménez) - * Type __package_update_index: Decrease verbosity (Ricardo Catalinas Jiménez) - * Type __package_upgrade_all: Decrease verbosity (Ricardo Catalinas Jiménez) - -3.1.8: 2014-10-01 - * New Type: __package_update_index (Ricardo Catalinas Jiménez) - * New Type: __package_upgrade_all (Ricardo Catalinas Jiménez) - -3.1.7: 2014-09-29 - * Type __cdistmarker: Fix typo (Ricardo Catalinas Jiménez) - * Core: Bugfix: Export messaging to manifests (Ricardo Catalinas Jiménez) - * Explorer cpu_cores, cpu_sockets, memory: Add Mac OS X support (Manuel Hutter) - * Type __ssh_authorized_keys: Ensure keys are correctly added (Steven Armstrong) - * New Type: __ssh_authorized_key (Steven Armstrong) - * New Type: __package_pkgng_freebsd (Jake Guffey) - -3.1.6: 2014-08-18 - * New Type: __ssh_dot_ssh (Nico Schottelius) - * Type __package_yum: Support retrieving package via URL (Nico Schottelius) - * Type __hostname: Support SuSE and have CentOS use sysconfig value (Nico Schottelius) - * Type __locale: Support SuSE (Nico Schottelius) - * Type __locale: Support Archlinux (Nico Schottelius) - * Type __timezone: Support SuSE (Nico Schottelius) - * Type __file: Support MacOS X (Manuel Hutter) - * Type __iptables_apply: Add "reset" to init.d script of iptables (Nico Schottelius) - * Type __ssh_authorized_key: Use new type __ssh_dot_ssh (Nico Schottelius) - * Type __zypper_repo: Bugfix for pattern matching (Daniel Heule) 3.1.5: 2014-05-05 * Type __zypper_repo: Automatically import gpg keys (Daniel Heule) @@ -528,16 +14,16 @@ Changelog * Documentation: Cleanup up, added HTML links (Tomas Pospisek) * Explorer interfaces: Remove test output (Daniel Heule) * Type __jail: Add messaging support (Jake Guffey) - + 3.1.3: 2014-04-29 * New Type: __yum_repo (Steven Armstrong) - * Type __hostname: Add support for CentOS (Nico Schottelius) + * Type __hostname: Add support for CentOS 3.1.2: 2014-04-12 - * Documentation: Add missing environment variables to reference (Nico Schottelius) - * Type __qemu_img: size is optional, if state is not present (Nico Schottelius) + * Documentation: Add missing environment variables to reference + * Type __qemu_img: size is optional, if state is not present * Type __key_value: Rewrite using awk (Daniel Heule) - * New Type: __dog_vdi (Nico Schottelius) + * New Type: __dog_vdi 3.1.1: 2014-03-26 * Core: Make __object and __object_id available to code (Daniel Heule) @@ -551,11 +37,11 @@ Changelog * Type __package_pkg_openbsd: Improve error handling (og) 3.1.0: 2014-03-19 - * New Type: __rbenv (Nico Schottelius) + * New Type: __rbenv * Type __file: Enhance OpenBSD Support (og) - * Type __git: Pass onwer/group/mode values to __directory (Nico Schottelius) + * Type __git: Pass onwer/group/mode values to __directory * Type __iptable_rule: Fix example documentation (Antoine Catton) - * Type __key_value: Add messaging support (Nico Schottelius) + * Type __key_value: Add messaging support * Type __package_pkg_openbsd: Allow to change PKG_PATH (og) * Type __ssh_authorized_keys: Allow managing existing keys (Steven Armstrong) * Type __user: Enhance OpenBSD Support (og) @@ -563,7 +49,7 @@ Changelog 3.0.9: 2014-02-14 * Core: Ignore order dependencies if override is set (Daniel Heule) * Core: Improve Mac OS X support for unit tests (Steven Armstrong) - * Type __locale: Error out in case of unsupported OS (Nico Schottelius) + * Type __locale: Error out in case of unsupported OS * Type __jail: Use default parameters for state (Daniel Heule) * Type __pf_ruleset: Use default parameters for state (Daniel Heule) * Type __postgres_database: Use default parameters for state (Daniel Heule) @@ -587,7 +73,7 @@ Changelog * New Type: __apt_key_uri (Steven Armstrong) * New Type: __apt_norecommends (Steven Armstrong) * New Type: __apt_source (Steven Armstrong) - * New Type: __ccollect_source (Nico Schottelius) + * New Type: __ccollect_source * Type __git: Use default parameters (Daniel Heule) * Type __jail: Use default parameters (Daniel Heule) * Type __package_yum: Use default parameters (Daniel Heule) @@ -597,24 +83,24 @@ Changelog 3.0.5: 2014-02-05 * Core: Introduce override concept (Daniel Heule) * Type __process: Make --state absent work (Steven Armstrong) - * Documentation: Update documentation for environment variables (Nico Schottelius) + * Documentation: Update documentation for environment variables 3.0.4: 2014-01-29 - * Core: Ignore install types in config mode (Nico Schottelius) - * Documentation: Update reference (files path in object space) (Nico Schottelius) - * Documentation: Update best practise: Replaces templates/ with files/ (Nico Schottelius) + * Core: Ignore install types in config mode + * Documentation: Update reference (files path in object space) + * Documentation: Update best practise: Replaces templates/ with files/ * Type __apt_ppa: Install required software (Steven Armstrong) - * Type __debconf_set_selections: Support --file - to read from stdin (Nico Schottelius) + * Type __debconf_set_selections: Support --file - to read from stdin * Type __jail: Fix jaildir parameter handling (Jake Guffey) 3.0.3: 2014-01-22 - * Core: Enhance error message when requirement is missing object id (Nico Schottelius) + * Core: Enhance error message when requirement is missing object id * Core: Add environment variable to select shell for executing scripts (Daniel Heule) - * Explorer hostname: Return host name by using uname -n (Nico Schottelius) + * Explorer hostname: Return host name by using uname -n * New Type: __hostname (Steven Armstrong) * Type __cdist: Use default paremeters (Daniel Heule) * Type __key_value: Use default paremeters (Daniel Heule) - * Type __line: Use printf instead of echo for printing user input (Nico Schottelius) + * Type __line: Use printf instead of echo for printing user input * Type __qemu_img: Use default paremeters (Daniel Heule) * Type __zypper_repo: Use default paremeters (Daniel Heule) * Type __zypper_service: Use default paremeters (Daniel Heule) @@ -628,16 +114,16 @@ Changelog 3.0.1: 2014-01-14 * Core: Copy only files, not directories (Steven Armstrong) - * Core: Allow hostnames to start with / (Nico Schottelius) - * Type __line: Remove unnecessary backslash escape (Nico Schottelius) + * Core: Allow hostnames to start with / + * Type __line: Remove unecessary backslash escape * Type __directory: Add messaging support (Daniel Heule) * Type __directory: Do not generate code if mode is 0xxx (Daniel Heule) * Type __package: Fix typo in optional parameter ptype (Daniel Heule) * Type __start_on_boot: Fix for SuSE's chkconfig (Daniel Heule) 3.0.0: 2013-12-24 - * Core: Added messaging support (Nico Schottelius) - * Core: Removed unused "changed" attribute of objects (Nico Schottelius) + * Core: Added messaging support + * Core: Removed unused "changed" attribute of objects * Core: Support default values for multiple parameters (Steven Armstrong) * Core: Ensure Object Parameter file contains \n (Steven Armstrong) * New Type: __zypper_repo (Daniel Heule) @@ -647,8 +133,8 @@ Changelog * Type __cron: Add support for raw lines (Daniel Heule) * Type __cron: Suppress stderr output from crontab (Daniel Heule) * Type __cron: Fix quoting issue (Daniel Heule) - * Type __file: Do not generate code if mode is 0xxx (Nico Schottelius) - * Type __iptables_rule: Use default parameter (Nico Schottelius) + * Type __file: Do not generate code if mode is 0xxx + * Type __iptables_rule: Use default parameter * Type __key_value: Fix quoting issue (Steven Armstrong) * Type __package: Use state --present by default (Steven Armstrong) * Type __package_zypper: Support non packages as well (Daniel Heule) @@ -656,7 +142,7 @@ Changelog * Type __postfix_*: Depend on __postfix Type (Steven Armstrong) * Type __postfix_postconf: Enable support for SuSE (Daniel Heule) * Type __postfix: Enable support for SuSE (Daniel Heule) - * Type __start_on_boot: Use default parameter state (Nico Schottelius) + * Type __start_on_boot: Use default parameter state * Type __start_on_boot: Add support for gentoo (Daniel Heule) * Type __user: Add support for state parameter (Daniel Heule) * Type __user: Add support for system users (Daniel Heule) @@ -668,19 +154,19 @@ Changelog * Type __file: Only remove file when state is absent (Steven Armstrong) * Type __link: Only remove link when state is absent (Steven Armstrong) * Type __directory: Only remove directory when state is absent (Steven Armstrong) - * Type __directory: Fix newly introduced quoting issue (Nico Schottelius) + * Type __directory: Fix newly introduced quoting issue * Type __package_zypper: Fix explorer and parameter issue (Daniel Heule) - * Core: Fix backtrace when cache cannot be deleted (Nico Schottelius) + * Core: Fix backtrace when cache cannot be deleted 2.3.6: 2013-11-25 - * New Type: __locale (Nico Schottelius) - * Type __line: Ensure special characters are not interpreted (Nico Schottelius) + * New Type: __locale + * Type __line: Ensure special characters are not interpreted 2.3.5: 2013-10-10 * Core: Unit test fix for remote_copy (Steven Armstrong) * Documentation: Updated manpages of __package and __file (Alex Greif) * Documentation: Add more examples to cdist-manifest (Dan Levin) - * Type __package_apt: Do not install recommends by default (Nico Schottelius) + * Type __package_apt: Do not install recommends by default 2.3.4: 2013-10-03 * Core: Add missing bits to support dry run (Steven Armstrong) @@ -690,7 +176,7 @@ Changelog * New Type: __postfix_postconf (Steven Armstrong) * New Type: __postfix_postmap (Steven Armstrong) * New Type: __postfix_reload (Steven Armstrong) - * Type __line: Ensure regex does not contain / + * Type __line: Ensure regex does not contain / * Type __ssh_authorized_keys: Bugfix: Preserve ownership (Steven Armstrong) 2.3.3: 2013-09-09 @@ -698,51 +184,51 @@ Changelog * Type __start_on_boot: Bugfix for systemd (Steven Armstrong) 2.3.2: 2013-09-05 - * Build: Ensure tests don't change attributes of non-test files (Nico Schottelius) - * Core: Fix typo in argument parser (Nico Schottelius) + * Build: Ensure tests don't change attributes of non-test files + * Core: Fix typo in argument parser * Core: Code cleanup: Remove old install code (Steven Armstrong) - * Core: Improve error message when using non-existing type in requirement (Nico Schottelius) - * New Type: __iptables_rule (Nico Schottelius) - * New Type: __iptables_apply (Nico Schottelius) - * Type __cdist: Also create home directory (Nico Schottelius) - * Type __cdist: Add support for --shell parameter (Nico Schottelius) - * Type __motd: Regenerate motd on Debian and Ubuntu (Nico Schottelius) + * Core: Improve error message when using non-existing type in requirement + * New Type: __iptables_rule + * New Type: __iptables_apply + * Type __cdist: Also create home directory + * Type __cdist: Add support for --shell parameter + * Type __motd: Regenerate motd on Debian and Ubuntu 2.3.1: 2013-08-28 - * Core: Support relative paths for configuration directories (Nico Schottelius) - * Core: Code cleanup (removed context class, added log class) (Nico Schottelius) - * Documentation: Add more best practises (Nico Schottelius) - * Documentation: Add troubleshooting chapter (Nico Schottelius) + * Core: Support relative paths for configuration directories + * Core: Code cleanup (removed context class, added log class) + * Documentation: Add more best practises + * Documentation: Add troubleshooting chapter * Type __key_value: Fix quoting problem (Steven Armstrong) 2.3.0: 2013-08-12 - * Core: Added support for cdist shell (Nico Schottelius) - * Documentation: Improved some manpages (Nico Schottelius) + * Core: Added support for cdist shell + * Documentation: Improved some manpages 2.2.0: 2013-07-12 - * Build: Cleanup the Makefile (Nico Schottelius) - * Type __package_opkg: Use shortcut version (Nico Schottelius) + * Build: Cleanup the Makefile + * Type __package_opkg: Use shortcut version * Core: Remove old pseudo object id "singleton" (Steven Armstrong) 2.1.2: 2013-07-09 - * Build: Change clean-dist target to "distclean" (Nico Schottelius) + * Build: Change clean-dist target to "distclean" * Build: Moved a lot of build logic into Makefile for dependency resolution * Core: Make global explorers available to initial manifest (Arkaitz Jimenez) - * Core: Change execution order to run object as one unit (Nico Schottelius) + * Core: Change execution order to run object as one unit * Documentation: Improved documentation (Tomáš Pospíšek) * New Remote Example: Add support for sudo operations (Chase James) - * New Type: __update_alternatives (Nico Schottelius) - * New Type: __cdist (Nico Schottelius) + * New Type: __update_alternatives + * New Type: __cdist * Type __apt_ppa: Fix comparison operator (Tyler Akins) - * Type __start_on_boot: Archlinux changed to use systemd - adapt type (Nico Schottelius) + * Type __start_on_boot: Archlinux changed to use systemd - adapt type * Type __git: Missing quotes added (Chase James) * Type __postgres_database: Make state parameter optional (Chase James) * Type __postgres_role: Make state parameter optional, fix password bug (Chase James) - * Type __process: Make state parameter optional (Nico Schottelius) - * Type __cron: Simplyfied and syntax change (Nico Schottelius) + * Type __process: Make state parameter optional + * Type __cron: Simplyfied and syntax change 2.1.1: 2013-04-08 - * Core: Use dynamic dependency resolver to allow indirect self dependencies (Nico Schottelius) + * Core: Use dynamic dependency resolver to allow indirect self dependencies * Core: Remove umask call - protect /var/lib/cdist only (Arkaitz Jimenez) * Explorer os: Added Slackware support (Eivind Uggedal) * Type __git: Support mode and fix owner/group settings (contradict) @@ -752,90 +238,90 @@ Changelog * Type __user: Add support for creating user home (Arkaitz Jimenez) 2.1.0: 2012-12-09 - * Core: Ensure global explorers are executable (Nico Schottelius) + * Core: Ensure global explorers are executable * Core: Ensure type explorers are executable (Steven Armstrong) - * New Type: __git (Nico Schottelius) + * New Type: __git * New Type: __ssh_authorized_keys (Steven Armstrong) * New Type: __user_groups (Steven Armstrong) - * Type __rvm_gemset: Change parameter "default" to be boolean (Nico Schottelius) + * Type __rvm_gemset: Change parameter "default" to be boolean * Type __user: Remove --groups support (now provided by __user_groups) * Type __apt_ppa: Bugfix: Installeded ppa detection (Steven Armstrong) * Type __jail: Change optional parameter "started" to boolean "stopped" parameter, change optional parameter "devfs-enable" to boolean "devfs-disable" parameter and - change optional parameter "onboot" to boolean. (Nico Schottelius) - * Type __package_pip: Bugfix: Installeded the package, not pyro (Nico Schottelius) - * Remove Type __ssh_authorized_key: Superseeded by __ssh_authorized_keys (Nico Schottelius) + change optional parameter "onboot" to boolean. + * Type __package_pip: Bugfix: Installeded the package, not pyro + * Remove Type __ssh_authorized_key: Superseeded by __ssh_authorized_keys * Support for CDIST_PATH (Steven Armstrong) 2.1.0pre8: 2012-11-15 - * Type cleanup: __apt_ppa, __apt_ppa_update_index, __file, + * Type cleanup: __apt_ppa, __apt_ppa_update_index, __file, __ssh_authorized_key, __timezone, all install types (Steven Armstrong) - * Types: Remove all parameter changing code (Nico Schottelius) - * Type __rvm_ruby: Change parameter "default" to be boolean (Nico Schottelius) - * Documentation: Web documentation clean up (Nico Schottelius) + * Types: Remove all parameter changing code + * Type __rvm_ruby: Change parameter "default" to be boolean + * Documentation: Web documentation clean up 2.1.0pre7: 2012-11-07 - * Core: All unit tests restored back to working (Nico Schottelius) - * Core: Print error message when missing the initial manifest (Nico Schottelius) + * Core: All unit tests restored back to working + * Core: Print error message when missing the initial manifest 2.1.0pre6: 2012-11-05 - * New Example: Turn remote calls into local calls (used for unittesting) (Nico Schottelius) - * Core: Export PYTHONPATH, it's also needed by emulator (Nico Schottelius) - * Bugfix Type __rvm_ruby: Add clean package dependencies (Nico Schottelius) - * Bugfix Type __rvm_gem: Run rvm as user, not as root (Nico Schottelius) - * Cleanup Type __rvm, __rvm_gemset: Use shortcut version (Nico Schottelius) - * Bugfix __rvm_gemset: Correctly check for gemsets (Nico Schottelius) + * New Example: Turn remote calls into local calls (used for unittesting) + * Core: Export PYTHONPATH, it's also needed by emulator + * Bugfix Type __rvm_ruby: Add clean package dependencies + * Bugfix Type __rvm_gem: Run rvm as user, not as root + * Cleanup Type __rvm, __rvm_gemset: Use shortcut version + * Bugfix __rvm_gemset: Correctly check for gemsets * Cleanup Type __postgres_database, __postgres_role: Reference each other - in documentation (Nico Schottelius) - * Cleanp Type __postgres_role: Use boolean parameters where appropriate (Nico Schottelius) - * Cleanp Type __postgres_role: Use shortcut version (Nico Schottelius) + in documentation + * Cleanp Type __postgres_role: Use boolean parameters where appropriate + * Cleanp Type __postgres_role: Use shortcut version 2.1.0pre5: 2012-11-01 - * Core: First round of tests updated to work with multiple configuration directories (Nico Schottelius) + * Core: First round of tests updated to work with multiple configuration directories 2.1.0pre4: 2012-10-31 - * Dist: PyPi: Moved cdist.py to script/cdist to avoid double import (Nico Schottelius) - * Core: Added support for multiple configuration directories (no documentation) (Nico Schottelius) + * Dist: PyPi: Moved cdist.py to script/cdist to avoid double import + * Core: Added support for multiple configuration directories (no documentation) 2.1.0pre3: 2012-10-30 - * Dist: PyPi: Types and explorer included as package data (Nico Schottelius) + * Dist: PyPi: Types and explorer included as package data 2.1.0pre2: 2012-10-26 - * Dist: PyPi: Add conf/ directory to distribution (Nico Schottelius) - * Dist: Initial support for archlinux packaging (Nico Schottelius) + * Dist: PyPi: Add conf/ directory to distribution + * Dist: Initial support for archlinux packaging 2.1.0pre1: 2012-10-26 - * Core: Removed obsolete variable __self (Nico Schottelius) - * Removed type __addifnosuchline (replaced by __line) (Nico Schottelius) - * Removed type __removeline (replaced by __line) (Nico Schottelius) - * Type __directory: Parameter --parents and --recursive are now boolean (Nico Schottelius) + * Core: Removed obsolete variable __self + * Removed type __addifnosuchline (replaced by __line) + * Removed type __removeline (replaced by __line) + * Type __directory: Parameter --parents and --recursive are now boolean * Type __package_apt, __package_luarocks, __package_opkg, __package_pacman, __package_pkg_freebsd, __package_pkg_openbsd, __package_rubygem, __package_yum, __process: - Parameter state accepts only "present" and "absent" (Nico Schottelius) - * Dist: Initial support for pypi packaging (Nico Schottelius) + Parameter state accepts only "present" and "absent" + * Dist: Initial support for pypi packaging 2.0.15: 2012-11-02 * Core: Make variable __object_name available in type explorers (Steven Armtrong) - * New Type: __qemu_img (Nico Schottelius) - * New Type: __line (Nico Schottelius) + * New Type: __qemu_img + * New Type: __line * New Type: __pf_apply (Jake Guffey) * New Type: __pf_ruleset (Jake Guffey) - * Bugfix Type: __rvm: Make type work if rvm is already installed (Nico Schottelius) + * Bugfix Type: __rvm: Make type work if rvm is already installed 2.0.14: 2012-09-07 * Bugfix Type: __jail: Use correct variable (Jake Guffey) * Change Type: __jail: Parameter jailbase now optional (Jake Guffey) * Bugfix Type: __user: Use passwd database on FreeBSD (Jake Guffey) - * Bugfix Type: __start_on_boot: Do not change parameters (Nico Schottelius) + * Bugfix Type: __start_on_boot: Do not change parameters * Feature __user: Added support for BSDs (Sébastien Gross) * Feature __group: Added support for FreeBSD (Jake Guffey) - * New Type: __package_zypper (Nico Schottelius) - * Feature Types: Initial Support for SuSE Linux (Nico Schottelius) - + * New Type: __package_zypper + * Feature Types: Initial Support for SuSE Linux + 2.0.13: 2012-06-05 * Bugfix __ssh_authorized_key: Ensure it sets proper group (contradict) - * Bugfix __addifnosuchline: Fixed quotes/interpolation bug ("a b" became "a b") (Nico Schottelius) + * Bugfix __addifnosuchline: Fixed quotes/interpolation bug ("a b" became "a b") * New Explorer: interfaces (Sébastien Gross) * Feature core: Support reading from stdin in types (Steven Armstrong) * Feature core: Support multiple parameters for types (Steven Armstrong) @@ -843,28 +329,28 @@ Changelog 2.0.12: 2012-05-29 * Core: Correctly raise error on Python < 3.2 (Steven Armtrong) - * Core: Add support for --remote-exec and --remote-copy parameters (Nico Schottelius) + * Core: Add support for --remote-exec and --remote-copy parameters * Documentation: Debian Squeeze hints (Sébastien Gross) 2.0.11: 2012-05-23 - * Fix insecure file/directory creation: Use umask 077 (Nico Schottelius) + * Fix insecure file/directory creation: Use umask 077 2.0.10: 2012-05-18 * Cleanup __group: No getent gshadow in old Redhat, use groupmod -g (Matt Coddington) - * Bugfix __package_yum: Missing cat (Nico Schottelius) + * Bugfix __package_yum: Missing cat * Bugfix __start_on_boot: Correctly use sed and quotes (Steven Armstrong) * Feature __file: Support for --state exists (Steven Armstrong) - * Feature core: Make variable __manifest available to type manifests (Nico Schottelius) + * Feature core: Make variable __manifest available to type manifests * Feature core: Correct parent dependency handling (Steven Armstrong) * Bugfix several types: Fix sed for FreeBSD (Istvan Beregszaszi) * New Type: __jail (Jake Guffey) * Change Type: __rvm*: --state present/absent not installed/remvoed (Evax Software) - * Bugfix Type: __cron: Hide error output from crontab (Nico Schottelius) + * Bugfix Type: __cron: Hide error output from crontab * Various smaller bugfixes (Chris Lamb) 2.0.9: 2012-03-12 - * Cleanup documentation: Fix environment variable list to be properly + * Cleanup documentation: Fix environment variable list to be properly displayed (Giel van Schijndel) * Cleanup documentation: Some minor corrections * New Type: __package_opkg (Giel van Schijndel) @@ -873,20 +359,20 @@ Changelog * Feature __package: Support for OpenWRT (Giel van Schijndel) * Feature __start_on_boot: Support for OpenWRT (Giel van Schijndel) * Feature __start_on_boot: Support for Amazon Linux (Matt Coddington) - * New Example: Use rsync to backup files (Matt Coddington) - * Feature core: Exit non-zero, if configuration failed (Nico Schottelius) + * New Example: Use rsync to backup files (Matt Coddington) + * Feature core: Exit non-zero, if configuration failed * Documentation: Describe how to do templating (Aurélien Bondis) 2.0.8: 2012-02-20 - * Bugfix core: Remove another nasty traceback when sending SIGINT (aka Ctrl-C) (Nico Schottelius) - * Cleanup: Better hint to source of error (Nico Schottelius) - * Cleanup: Do not output failing script, but path to script only (Nico Schottelius) + * Bugfix core: Remove another nasty traceback when sending SIGINT (aka Ctrl-C) + * Cleanup: Better hint to source of error + * Cleanup: Do not output failing script, but path to script only * Cleanup: Remove support for __debug variable in manifests (Type != Core - debugging) (Nico Schottelius) + debugging) * Cleanup: Change __package_* to support absent/present (default state - name now). The values removed/installed will be removed in cdist 2.1. (Nico Schottelius) + name now). The values removed/installed will be removed in cdist 2.1. * Cleanup: Change __process to support absent/present (default state - name now). The values running/stopped will be removed in cdist 2.1. (Nico Schottelius) + name now). The values running/stopped will be removed in cdist 2.1. * Feature Core: Support boolean parameters (Steven Armstrong) 2.0.7: 2012-02-13 @@ -895,9 +381,9 @@ Changelog * Bugfix __link: Properly handle existing links (Steven Armstrong) * Bugfix __key_value: More robust implementation (Steven Armstrong) * Bugfix __user: Fix for changing a user's group by name (Matt Coddington) - * New Type: __package_pip (Nico Schottelius) + * New Type: __package_pip * Bugfix/Cleanup: Correctly allow Object ID to start and end with /, but - not contain //. (Nico Schottelius) + not contain //. 2.0.6: 2012-01-28 * Bugfix __apt_ppa: @@ -916,9 +402,9 @@ Changelog 2.0.5: 2012-01-18 * Bugfix __key_value: Use correct delimiters (Steven Armstrong, Daniel Maher) - * Cleanup: Explicitly require Python >= 3.2 (do not fail implicitly) (Nico Schottelius) - * Documentation: (Re)write of the tutorial (Nico Schottelius) - * Feature: __addifnosuchline supports matching on + * Cleanup: Explicitly require Python >= 3.2 (do not fail implicitly) + * Documentation: (Re)write of the tutorial + * Feature: __addifnosuchline supports matching on regular expressions (Daniel Maher) * Feature: __directory, __file, __link: Add --state parameter (Steven Armstrong) @@ -926,11 +412,11 @@ Changelog * New Type: __cdistmarker (Daniel Maher) 2.0.4: 2011-11-18 - * Bugfix core: Remove traceback when sending SIGINT (aka Ctrl-C) (Nico Schottelius) + * Bugfix core: Remove traceback when sending SIGINT (aka Ctrl-C) * Bugfix core: Accept parameters with - in the name (Steven Armstrong) - * Cleanup: __object_fq variable removed (never used) (Nico Schottelius) - * Cleanup: Environment variable __self DEPRECATED, use __object_name instead (Nico Schottelius) - * Cleanup: Environment variable __self scheduled for removal in cdist 2.1 (Nico Schottelius) + * Cleanup: __object_fq variable removed (never used) + * Cleanup: Environment variable __self DEPRECATED, use __object_name instead + * Cleanup: Environment variable __self scheduled for removal in cdist 2.1 * Documentation: Many examples for use of __remote_* (Steven Armstrong) * Feature: Automatically require all used objects (Steven Armstrong) * New Type: __cron (Steven Armstrong) @@ -938,28 +424,28 @@ Changelog 2.0.3: 2011-10-18 * Improved logging, added --verbose, by more quiet by default * Bugfix __user: Correct quoting (Steven Armstrong) - * Bugfix __addifnosuchline: Falsely exited (Nico Schottelius) - * Bugfix requirements: Restore original require="" behaviour (Nico Schottelius) - * Feature requirements: Check for broken object_ids and abort (Nico Schottelius) + * Bugfix __addifnosuchline: Falsely exited + * Bugfix requirements: Restore original require="" behaviour + * Feature requirements: Check for broken object_ids and abort * Massive refactoring and unittesting introduced (Steven Armstrong) 2.0.2: 2011-09-27 * Add support for detection of OpenWall Linux (Matthias Teege) - * Add support for __debug variable in manifests (Nico Schottelius) - * Bugfix core: Various issues with type emulator (Nico Schottelius) + * Add support for __debug variable in manifests + * Bugfix core: Various issues with type emulator 2.0.1: 2011-09-23 - * Bugfix core: Always print source of error in case of exec errors (Nico Schottelius) - * Bugfix core: Various smaller bugs in string concatenation (Nico Schottelius) - * Feature: Add marker "changed" to changed objects (Nico Schottelius) + * Bugfix core: Always print source of error in case of exec errors + * Bugfix core: Various smaller bugs in string concatenation + * Feature: Add marker "changed" to changed objects 2.0.0: 2011-09-16 * New Type: __package_rubygem (Chase Allen James) - * __self replaced by __object_fq (Nico Schottelius) - * Rewrote cdist in Python (Nico Schottelius) + * __self replaced by __object_fq + * Rewrote cdist in Python 1.7.1: 2011-07-26 - * Documentation: Add explorers to reference (Nico Schottelius) + * Documentation: Add explorers to reference * Documentation: Typo cleanup (Derek Brost) * Type __key_value: Bugfix (Steven Armstrong) * New Type: __postgres_role (Steven Armstrong) @@ -969,42 +455,42 @@ Changelog * Bugfix type __package_yum: Fix redhat support (Ramon Salvadó) * Improved type __package_yum: Add centos support (Ramon Salvadó) * New Type: __timezone (Ramon Salvadó) - * Renamed explorer: hardware_type to machine (Nico Schottelius) - * Core: Do not execute empty code fragments (Nico Schottelius) + * Renamed explorer: hardware_type to machine + * Core: Do not execute empty code fragments 1.6.2: 2011-04-19 - * Core: Introduce __cdist_tmp_base_dir (Nico Schottelius) - * Core: Cleanup and enhance cdist-type-template (Nico Schottelius) - * Core: cdist-mass-deploy: Report failed cdist-deploy-to instances (Nico Schottelius) + * Core: Introduce __cdist_tmp_base_dir + * Core: Cleanup and enhance cdist-type-template + * Core: cdist-mass-deploy: Report failed cdist-deploy-to instances * New Type: __ssh_authorized_key (Aurélien Bondis) 1.6.1: 2011-04-07 - * Improved logging: Show code responsible for abort (Nico Schottelius) - * Improved logging: Consistently prefix with current object or core (Nico Schottelius) - * Bugfix: Type __debconf_set_selections used wrong contens for selection (Nico Schottelius) - * Bugfix: Don't fail, if cache directory is not existing (Nico Schottelius) - * Bugfix: __user and __group exited non-zero if no change was necessary (Nico Schottelius) - * New Explorer: hardware_type (Nico Schottelius) + * Improved logging: Show code responsible for abort + * Improved logging: Consistently prefix with current object or core + * Bugfix: Type __debconf_set_selections used wrong contens for selection + * Bugfix: Don't fail, if cache directory is not existing + * Bugfix: __user and __group exited non-zero if no change was necessary + * New Explorer: hardware_type * New Type: __package_pkg_openbsd (Andi Brönnimann) * New Type: __autofs_map (Steven Armstrong) * New Type: __autofs_master (Steven Armstrong) 1.6.0: 2011-04-06 - * New Type: __package_yum (Nico Schottelius) - * New type: __debconf_set_selections (Nico Schottelius) - * New explorer: os_version (Nico Schottelius) - * Bugfix: Type __group failed in case of __group NAME syntax (Nico Schottelius) + * New Type: __package_yum + * New type: __debconf_set_selections + * New explorer: os_version + * Bugfix: Type __group failed in case of __group NAME syntax * Bugfix: __package* types: consistently name --state removed instead of - uninstalled or deinstalled (Nico Schottelius) - * Type __package: Added Fedora support (Nico Schottelius) - * Type __package_apt: Removed --preseed support (Nico Schottelius) - * Explorer os gained Fedora support (Nico Schottelius) - * Simplified types __user and __group (Nico Schottelius) - * New helper binary: cdist-mass-deploy (Nico Schottelius) + uninstalled or deinstalled + * Type __package: Added Fedora support + * Type __package_apt: Removed --preseed support + * Explorer os gained Fedora support + * Simplified types __user and __group + * New helper binary: cdist-mass-deploy 1.5.0: 2011-04-01 - * Add basic cache functionality (Nico Schottelius) - * New type: __process (Nico Schottelius) + * Add basic cache functionality + * New type: __process * Restructured execution: (Steven Armstrong) Orientate processing on objects, resolve dependencies and ensure correct execution order. @@ -1014,77 +500,77 @@ Changelog 1.4.1: 2011-03-25 * New type: __key_value (Steven Armstrong) * New type: __apt_ppa (Steven Armstrong) - * Documentation: Manpage generation cleanup (Nico Schottelius) + * Documentation: Manpage generation cleanup * Documentation: Manpage fix for __apt_ppa 1.4.0: 2011-03-24 - * Add --recursive to __directory (Nico Schottelius) - * Move cdist generated stuff to .cdist of an object (Nico Schottelius) - * Allow objects to be redefined (Nico Schottelius) + * Add --recursive to __directory + * Move cdist generated stuff to .cdist of an object + * Allow objects to be redefined 1.3.2: 2011-03-21 - * Add --source to __motd (Nico Schottelius) - * Add --preseed to __package_apt (Nico Schottelius) - * Include HTML documentation of manpages and publish them (Nico Schottelius) + * Add --source to __motd + * Add --preseed to __package_apt + * Include HTML documentation of manpages and publish them 1.3.1: 2011-03-21 - * Document: cdist-type-build-emulation (Nico Schottelius) - * Document: cdist-type-emulator (Nico Schottelius) - * Document: cdist-remote-explorer-run (Nico Schottelius) - * Fix dependencies in cdist-code-run (Nico Schottelius) - * Fix dependencies in cdist-manifest-run-all (Nico Schottelius) - * Add --source to __issue and fix os check (Nico Schottelius) + * Document: cdist-type-build-emulation + * Document: cdist-type-emulator + * Document: cdist-remote-explorer-run + * Fix dependencies in cdist-code-run + * Fix dependencies in cdist-manifest-run-all + * Add --source to __issue and fix os check 1.3.0: 2011-03-20 - * Add support for local and remote code generation and execution (Nico Schottelius) - * Bugfix: Remove obsolete $@ call in cdist-remote-explorer-run (Nico Schottelius) - * Bugfix: Correct manpage for __removeline (broke manpage generation) (Nico Schottelius) + * Add support for local and remote code generation and execution + * Bugfix: Remove obsolete $@ call in cdist-remote-explorer-run + * Bugfix: Correct manpage for __removeline (broke manpage generation) 1.2.0: 2011-03-19 - * Added dependencies (see cdist-type(7)) (Nico Schottelius) + * Added dependencies (see cdist-type(7)) * New type: __removeline (Daniel Roth) * New type: __group (Steven Armstrong) * New type: __user (Steven Armstrong) - * Documentation: cdist-run-remote (Nico Schottelius) - * Documentation: cdist-code-run-all (Nico Schottelius) - * Documentation: cdist-object-gencode (Nico Schottelius) - * Documentation: cdist-explorer-run-global (Nico Schottelius) - * Documentation: cdist-manifest-run-init (Nico Schottelius) - * Documentation: cdist-manifest-run-all (Nico Schottelius) - * Documentation: cdist-object-gencode-all (Nico Schottelius) - * Documentation: cdist-manifest-run (Nico Schottelius) + * Documentation: cdist-run-remote + * Documentation: cdist-code-run-all + * Documentation: cdist-object-gencode + * Documentation: cdist-explorer-run-global + * Documentation: cdist-manifest-run-init + * Documentation: cdist-manifest-run-all + * Documentation: cdist-object-gencode-all + * Documentation: cdist-manifest-run 1.1.0: 2011-03-16 - * Replace type __file with __file, __directory, __link (Nico Schottelius) - * Documentation: cdist-env (Nico Schottelius) - * Documentation: cdist-config (Nico Schottelius) - * Documentation: cdist-dir (Nico Schottelius) - * Documentation: cdist-quickstart (Nico Schottelius) + * Replace type __file with __file, __directory, __link + * Documentation: cdist-env + * Documentation: cdist-config + * Documentation: cdist-dir + * Documentation: cdist-quickstart 1.0.4: 2011-03-15 - * New type: __motd (Nico Schottelius) + * New type: __motd * New type: __addifnosuchline (Daniel Roth) - * New type: __user (Nico Schottelius) - * Document type: __issue (Nico Schottelius) - * Document type: __package (Nico Schottelius) - * Document type: __package_pacman (Nico Schottelius) - * Document type: __package_apt (Nico Schottelius) - * New parameter for __file: --owner and --group (Nico Schottelius) + * New type: __user + * Document type: __issue + * Document type: __package + * Document type: __package_pacman + * Document type: __package_apt + * New parameter for __file: --owner and --group 1.0.3: 2011-03-11 - * Update regexp used for sane characters (Nico Schottelius) - * Allow types without parameters (Nico Schottelius) - * Allow type to be singleton (Nico Schottelius) - * Type __file learned --type symlink (Nico Schottelius) + * Update regexp used for sane characters + * Allow types without parameters + * Allow type to be singleton + * Type __file learned --type symlink 1.0.2: 2011-03-09 - * Add manpages: cdist-type, cdist-type__file, cdist-reference, cdist-explorer (Nico Schottelius) - * Make doc/man/ usable as MANPATH entry (Nico Schottelius) + * Add manpages: cdist-type, cdist-type__file, cdist-reference, cdist-explorer + * Make doc/man/ usable as MANPATH entry 1.0.1: 2011-03-08 - * Added cdist-type-template including manpage (Nico Schottelius) - * Fix manpage building (Nico Schottelius) - * Add new manpages: cdist-stages, cdist-bin-transfer (Nico Schottelius) + * Added cdist-type-template including manpage + * Fix manpage building + * Add new manpages: cdist-stages, cdist-bin-transfer 1.0.0: 2011-03-07 - * Initial release (Nico Schottelius) + * Initial release diff --git a/docs/dev/fancy-ideas b/docs/dev/fancy-ideas new file mode 100644 index 00000000..8ee290cd --- /dev/null +++ b/docs/dev/fancy-ideas @@ -0,0 +1,17 @@ +== types with namespaces == +- allow types to have namespaces, e.g. + __path/my/type +implemented as a proof of concept at: +https://github.com/asteven/cdist/tree/type-namespaces + + + +Execute all global explorers only when needed #286 + +My intention is to create a brunch of global explorer which are of use in some cases and makes cdist more userfriendly. But now, all global explorers are allways executed, even the return value of the explorers is never used. + +I think a possible approach can be to replace the result files with pipes, and on first read of the pipe, the explorer is executed by the core, all following read calls from the pipe are answered from the core with the result of the first real execute of the explorer. + +So cdist can have an unlimited number of global explorers and only used explorers are executed on the target host, all other explorers laying around are simply ignored. + +Also a possible approach would be to create a new explorer type (dynamic explorers) which are sitting in a different directory to (for example dynexploer) and only this ones are executed with the conditional approach explained above. So the overhead to create pipes and monitor it is only in place on explorers which are not interesting for everyone ... diff --git a/docs/dev/git-post-commit-hook b/docs/dev/git-post-commit-hook new file mode 100755 index 00000000..b16caa2a --- /dev/null +++ b/docs/dev/git-post-commit-hook @@ -0,0 +1,108 @@ +#!/usr/bin/env bash +# Distributed under the terms of the GNU General Public License v2 +# Copyright (c) 2006 Fernando J. Pereda +# +# Git CIA bot in bash. (no, not the POSIX shell, bash). +# It is *heavily* based on Git ciabot.pl by Petr Baudis. +# +# It is meant to be run either on a post-commit hook or in an update +# hook: +# +# post-commit: It parses latest commit and current HEAD to get the +# information it needs. +# +# update: You have to call it once per merged commit: +# +# refname=$1 +# oldhead=$2 +# newhead=$3 +# for merged in $(git rev-list ${oldhead}..${newhead} | tac) ; do +# /path/to/ciabot.bash ${refname} ${merged} +# done +# + +# The project as known to CIA +project="cdist" + +# Set to true if you want the full log to be sent +noisy=false + +# Addresses for the e-mail +from="nico-cia.vc@schottelius.org" +to="cia@cia.vc" + +# SMTP client to use +sendmail="/usr/sbin/sendmail -f ${from} ${to}" + +# Changeset URL +url="http://git.schottelius.org/?p=${project};a=commit;h=@@sha1@@" + +# You shouldn't be touching anything else. +if [[ $# = 0 ]] ; then + refname=$(git symbolic-ref HEAD 2>/dev/null) + merged=$(git rev-parse HEAD) +else + refname=$1 + merged=$2 +fi + +refname=${refname##refs/heads/} + +gitver=$(git --version) +gitver=${gitver##* } + +rev=$(git describe ${merged} 2>/dev/null) +[[ -z ${rev} ]] && rev=${merged:0:12} + +rawcommit=$(git cat-file commit ${merged}) + +author=$(sed -n -e '/^author .*<\([^@]*\).*$/s--\1-p' \ + <<< "${rawcommit}") + +logmessage=$(sed -e '1,/^$/d' <<< "${rawcommit}") +${noisy} || logmessage=$(head -n 1 <<< "${logmessage}") +logmessage=${logmessage//&/&} +logmessage=${logmessage///>} + +ts=$(sed -n -e '/^author .*> \([0-9]\+\).*$/s--\1-p' \ + <<< "${rawcommit}") + +out=" + + + CIA Bash client for Git + ${gitver} + http://dev.gentoo.org/~ferdy/stuff/ciabot.bash + + + ${project} + ${refname} + + ${ts} + + + ${author} + ${rev} + + $(git diff-tree -r --name-only ${merged} | + sed -e '1d' -e 's-.*-&-') + + +${logmessage} + + ${url//@@sha1@@/${merged}} + + +" + +${sendmail} << EOM +Message-ID: <${merged:0:12}.${author}@${project}> +From: ${from} +To: ${to} +Content-type: text/xml +Subject: DeliverXML +${out} +EOM + +# vim: set tw=70 : diff --git a/docs/dev/github-gitlab-migration/release b/docs/dev/github-gitlab-migration/release deleted file mode 100755 index c973f0f1..00000000 --- a/docs/dev/github-gitlab-migration/release +++ /dev/null @@ -1,50 +0,0 @@ -#!/bin/sh -e - -set -x - -printf "Enter tag name: " -read tag -printf "Enter repository authentication token: " -read token - -git tag -d "${tag}" || : - -git tag "${tag}" -m "Release ${tag}" -git push origin "${tag}" - -echo 'foo' > foo -echo 'foo signature' > foo.asc - -archivename="foo" - -project="poljakowski%2Fmy-cdist-testing" -sed_cmd='s/^.*"markdown":"\([^"]*\)".*$/\1/' - -# upload archive -response_archive=$(curl -f -X POST \ - -H "PRIVATE-TOKEN: ${token}" \ - -F "file=@${archivename}" \ - "https://code.ungleich.ch/api/v4/projects/${project}/uploads" \ - | sed "${sed_cmd}") || exit 1 - -# upload archive signature -response_archive_sig=$(curl -f -X POST \ - -H "PRIVATE-TOKEN: ${token}" \ - -F "file=@${archivename}.asc" \ - "https://code.ungleich.ch/api/v4/projects/${project}/uploads" \ - | sed "${sed_cmd}") || exit 1 - -# make release -curl -f -X POST \ - -H "PRIVATE-TOKEN: ${token}" \ - -F "description=Release ${tag}
${response_archive}
${response_archive_sig}" \ - "https://code.ungleich.ch/api/v4/projects/${project}/repository/tags/${tag}/release" \ - || exit 1 - -# get tag -curl -f -X GET \ - -H "PRIVATE-TOKEN: ${token}" \ - "https://code.ungleich.ch/api/v4/projects/${project}/repository/tags/${tag}" \ - || exit 1 - -rm -f foo foo.asc diff --git a/docs/dev/logs/2013-11-28.preos b/docs/dev/logs/2013-11-28.preos deleted file mode 100644 index f8561135..00000000 --- a/docs/dev/logs/2013-11-28.preos +++ /dev/null @@ -1,2 +0,0 @@ -- debootstrap for the moment -- add triggers: https://github.com/telmich/cdist/issues/214 diff --git a/docs/dev/logs/2014-01-09.preos b/docs/dev/logs/2014-01-09.preos deleted file mode 100644 index 1a3f2ddc..00000000 --- a/docs/dev/logs/2014-01-09.preos +++ /dev/null @@ -1,109 +0,0 @@ -- debootstrap - x setup arch - x allow cdist to configure debootstrapped directory using cdist - x include sshd - x configure network (eth0, dhcp) - x various mkfs variants - - various fdisk tools - - x add option for different initial manifest - x allow -, stdin usage - x allow to replace current manifest (later) - - x trigger - - can be handled in the manifest of the user - - - remove /var/cache/apt/archives/* ? - - later, optimisation level - - - - bug: cdist config als root! - - - fix linux-image name (amd64) - - - ln -s /sbin/init /init - - - blog! - - self configuring - - x pxe - /pxe/ - - pxelinux.0 - - linux - - initramfs - - pxelinux.cfg/ - - default - - - iso - - later - - usb stick (+efi version) - - later - - - add unit tests - -- testing with qemu - [22:43] bento:vm-tests% qemu-system-x86_64 -m 2G -boot order=cn -drive file=testhd1,if=virtio -net nic -net user,tftp=$(pwd -P)/tftp,bootfile=/pxelinux.0,hostfwd=tcp::7777-:22 -enable-kvm - -- create preos - [22:43] bento:preos-tests% echo __panter_root_ssh_keys | sudo cdist preos -vp /home/users/nico/vm-tests/tftp -c /home/users/nico/preos-tests/preos03/ -i - - - --------------------------------------------------------------------------------- - -[1:16] bento:~% sudo cdist preos -vc ~nico/preos-tests/preos03 -INFO: cdist: version 3.0.0-38-gea286c6 -INFO: /home/users/nico/preos-tests/preos03: Running global explorers -INFO: /home/users/nico/preos-tests/preos03: Running initial manifest /tmp/tmpxbquwe/manifest -INFO: /home/users/nico/preos-tests/preos03: Running manifest and explorers for __file/etc/network/interfaces -INFO: /home/users/nico/preos-tests/preos03: Generating code for __file/etc/network/interfaces -INFO: /home/users/nico/preos-tests/preos03: Running manifest and explorers for __package/xfsprogs -INFO: /home/users/nico/preos-tests/preos03: Running manifest and explorers for __package/reiser4progs -INFO: /home/users/nico/preos-tests/preos03: Running manifest and explorers for __package/jfsutils -INFO: /home/users/nico/preos-tests/preos03: Running manifest and explorers for __package/e2fsprogs -INFO: /home/users/nico/preos-tests/preos03: Running manifest and explorers for __package/btrfs-tools -INFO: /home/users/nico/preos-tests/preos03: Running manifest and explorers for __package/file -INFO: /home/users/nico/preos-tests/preos03: Running manifest and explorers for __package/syslinux -INFO: /home/users/nico/preos-tests/preos03: Running manifest and explorers for __package/openssh-server -INFO: /home/users/nico/preos-tests/preos03: Running manifest and explorers for __package/linux-image-amd64 -INFO: /home/users/nico/preos-tests/preos03: Running manifest and explorers for __package_apt/linux-image-amd64 -INFO: /home/users/nico/preos-tests/preos03: Generating code for __package_apt/linux-image-amd64 -INFO: /home/users/nico/preos-tests/preos03: Running manifest and explorers for __package_apt/openssh-server -INFO: /home/users/nico/preos-tests/preos03: Generating code for __package_apt/openssh-server -INFO: /home/users/nico/preos-tests/preos03: Running manifest and explorers for __package_apt/syslinux -INFO: /home/users/nico/preos-tests/preos03: Generating code for __package_apt/syslinux -INFO: /home/users/nico/preos-tests/preos03: Running manifest and explorers for __package_apt/file -INFO: /home/users/nico/preos-tests/preos03: Generating code for __package_apt/file -INFO: /home/users/nico/preos-tests/preos03: Running manifest and explorers for __package_apt/btrfs-tools -INFO: /home/users/nico/preos-tests/preos03: Generating code for __package_apt/btrfs-tools -INFO: /home/users/nico/preos-tests/preos03: Running manifest and explorers for __package_apt/e2fsprogs -INFO: /home/users/nico/preos-tests/preos03: Generating code for __package_apt/e2fsprogs -INFO: /home/users/nico/preos-tests/preos03: Running manifest and explorers for __package_apt/jfsutils -INFO: /home/users/nico/preos-tests/preos03: Generating code for __package_apt/jfsutils -INFO: /home/users/nico/preos-tests/preos03: Running manifest and explorers for __package_apt/reiser4progs -INFO: /home/users/nico/preos-tests/preos03: Generating code for __package_apt/reiser4progs -INFO: /home/users/nico/preos-tests/preos03: Running manifest and explorers for __package_apt/xfsprogs -INFO: /home/users/nico/preos-tests/preos03: Generating code for __package_apt/xfsprogs -INFO: /home/users/nico/preos-tests/preos03: Generating code for __package/xfsprogs -INFO: /home/users/nico/preos-tests/preos03: Generating code for __package/reiser4progs -INFO: /home/users/nico/preos-tests/preos03: Generating code for __package/jfsutils -INFO: /home/users/nico/preos-tests/preos03: Generating code for __package/e2fsprogs -INFO: /home/users/nico/preos-tests/preos03: Generating code for __package/btrfs-tools -INFO: /home/users/nico/preos-tests/preos03: Generating code for __package/file -INFO: /home/users/nico/preos-tests/preos03: Generating code for __package/syslinux -INFO: /home/users/nico/preos-tests/preos03: Generating code for __package/openssh-server -INFO: /home/users/nico/preos-tests/preos03: Generating code for __package/linux-image-amd64 -INFO: /home/users/nico/preos-tests/preos03: Finished successful run in 2.546635866165161 seconds -[1:16] bento:~% - --------------------------------------------------------------------------------- -[21:14] bento:vm-tests% qemu-system-x86_64 -m 2G -boot order=cn -drive file=testhd1,if=virtio -net nic -net user,tftp=$(pwd -P)/tftp,bootfile=/pxelinux.0 - --------------------------------------------------------------------------------- -[21:16] bento:preos-tests% sudo cdist preos -vp /home/users/nico/vm-tests/tftp /home/users/nico/preos-tests/preos03/ -INFO: cdist: version 3.0.0-42-g0d78ab3 -INFO: cdist.preos: Creating kernel ... -INFO: cdist.preos: Creating initramfs ... -760780 blocks -INFO: cdist.preos: Creating pxe configuration ... -INFO: cdist.preos: Creating pxelinux.0 ... - diff --git a/docs/dev/logs/2014-05-06.object-marker b/docs/dev/logs/2014-05-06.object-marker deleted file mode 100644 index 4878a2f5..00000000 --- a/docs/dev/logs/2014-05-06.object-marker +++ /dev/null @@ -1,14 +0,0 @@ -Change object marker from .cdist to .cdist-TEMPNAME to allow using -object ids that contain / are .cdist. - -Changes required: - - cdist/emulator.py: - needs to know suffix/name - tests: - allow object id named /.cdist - tests: - many - cdist/config.py: - have suffix - diff --git a/docs/dev/logs/2014-09-10.preos-keys b/docs/dev/logs/2014-09-10.preos-keys deleted file mode 100644 index 53d3721a..00000000 --- a/docs/dev/logs/2014-09-10.preos-keys +++ /dev/null @@ -1,18 +0,0 @@ - -cdist preos keyramfs --keyfile --keyfile - -[17:51] freiheit:vcs% mkdir preos-keys -[17:51] freiheit:vcs% mkdir -p preos-keys/root/.ssh -[17:56] freiheit:vcs% - -chown root:root -R preos-keys/ -chmod 0600 preos-keys/root/.ssh/authorized_keys - -chmod 0700 preos-keys/root/ -chmod 0700 preos-keys/root/.ssh/ - -[18:20:17] freiheit:/home/users/nico/.ungleich/ungleich/vcs/preos-keys# find . | cpio -H newc -o | gzip -9 > ../initramfs.cpio.gz -4 blocks -[18:21:08] freiheit:/home/users/nico/.ungleich/ungleich/vcs/preos-keys# - - diff --git a/docs/dev/logs/2014-11-11.discussion b/docs/dev/logs/2014-11-11.discussion deleted file mode 100644 index a04d2823..00000000 --- a/docs/dev/logs/2014-11-11.discussion +++ /dev/null @@ -1,104 +0,0 @@ -- logging/cache destination - local: - ~/.cdist/log/by-host/$__target/host/config/YYYY/MM/DD/hhmmss/ - ~/.cdist/log/by-session/YYYY/MM/DD/hhmmss/$__target_host/ - config/ - install/ - export/ - remote: - /var/lib/cdist/YYYY-MM-DD-hhmmss-$sourcehost.$pid - - rm old directories on remote side - -- support for tags - - for partial configuration - - supports also install - - on object definition, define - - a) don't care (i.e. no tags) - - b) require tag (only if this tag is setup) - - c) require not tag (only if this tag is *not* setup) - - d) what if both given (conflicting) - - names for parameters: - - cdist config / cdist type - --if-tag / --not-if-tag / --require-tag - --not-if-tag - -- logging - - command line - - stdin of cdist - - stdout/stderr/stdin of types - - new: stdout/stderr - - initial manifest - - if coming from stdin - -- logging configurable - - to be discussed - -- sudo remote - - cp to tmp & mv - - umask issue? - -- install - - via tagged types - - - -- export - - one /export script per type - - exports of type running after object's code is done - - global export should also exist after everything - - PR & merge - - change DONE status to CODE_DONE - - introduce EXPORT_DONE - - -- preos - - merge with debian support only - - we are open to support --os-type later - -- stackable remotes - - change API for remote_exec and remote_copy - - new minor version - - PR & merge - -- locking - - optional - - remote lock - - based on $(ls /var/lib/cdist/) > 0 - -- ideas for parallelisation - - run explorer in parallel - - type - - object - - objects without dependencies can be run in parallel - -- connection test - - just implement - -- multi user environment - - not really needed [at the moment] - - can be implemented by - - git branches - - setting the output dir - -- python2 support with __future__ - - steven votes against it - - nico does not care too much to object - - -- pull based - - sshd / stdin + stdout - - use Use ProxyCommand with stdin/stdout - - http://www.nico.schottelius.org/blog/openssh-6.2-add-callback-functionality-using-dynamic-remote-port-forwarding/ - - - cdist grant-pull-access - - generate user - - ssh pubkeypair - - call wraper script on targethost - - it is shell! - - ssh cdistuser@controlhost - -- config replay/redo/undo - - not now - - -- have a new discussion about handling uris diff --git a/docs/dev/logs/2015-02-10.installation_from_usb_stick b/docs/dev/logs/2015-02-10.installation_from_usb_stick deleted file mode 100644 index b655bc18..00000000 --- a/docs/dev/logs/2015-02-10.installation_from_usb_stick +++ /dev/null @@ -1,49 +0,0 @@ -Objective: - - Create a bootable media that contains everything to install and configure a system. - -Ideas: - -* usb stick -** uefi vs. bios -** contains cdist config -** static ip (?) (if at all) -** hostname setup to localhost -** install and config support -* preos from existing OS? -** requires kernel -** requires initramfs (self build) -** missing tools: cdist preos --config hostname... -* testing with qemu -* syslinux/isolinux? - -Program: - -- get tools -- get kernel - - provide fallback on cdist page - - archlinux: /boot/vmlinuz-linux -- create initramfs? -- create bootable media - - iso - - uefi-usb - - bios-usb - -Tasks: - -- Setup test environment - - qemu launcher - /usr/bin/qemu-system-x86_64 -boot d -m 256 -cdrom '/home/users/nico/oeffentlich/rechner/projekte/cdist/cdist/cdist-preos.iso' -- Create bootable image -- Test image - -Log: - -mkdir iso -cp /boot/vmlinuz-linux iso/ -cp /usr/lib/syslinux/bios/isolinux.bin iso/ - -[22:36] freiheit:cdist% genisoimage -v -V "cdist preos v0.1" -cache-inodes -J -l -no-emul-boot -boot-load-size 4 -b isolinux.bin -c boot.cat -o cdist-preos.iso iso - -[22:38] freiheit:cdist% genisoimage -r -V "cdist preos v0.2" -cache-inodes -J -l -no-emul-boot -boot-load-size 4 -b isolinux.bin -c boot.cat -o cdist-preos.iso iso - diff --git a/docs/dev/logs/2015-02-22.allow_dot_cdist b/docs/dev/logs/2015-02-22.allow_dot_cdist deleted file mode 100644 index 58a1b041..00000000 --- a/docs/dev/logs/2015-02-22.allow_dot_cdist +++ /dev/null @@ -1,29 +0,0 @@ -- locate code that references .cdist - - cdist_object.py -- need to change code that handles objects? - - setup object marker - exec/local.py - - cdist/emulator.py - - need to know the marker name - - shell.py - - test/manifest/__init__.py - - core/code.py: - - core/manifest.py: - - core/manifest.py: - - list_object_names() needs to know the marker -- used BY: - - list_objects - - cdist/test/cdist_object/__init__.py - - cdist/config.py - - cdist/test/cdist_object/__init__.py - - - list_object_names - - needs to have object_marker - -- or modify object code to load name -- setup a per-run random name - - local.py -- use the per-run random name -- create test - - def __init__(self, cdist_type, base_path, object_marker=".cdist", object_id=''): - diff --git a/docs/dev/logs/2015-03-28.preos-from-os b/docs/dev/logs/2015-03-28.preos-from-os deleted file mode 100644 index 93dc9e79..00000000 --- a/docs/dev/logs/2015-03-28.preos-from-os +++ /dev/null @@ -1,32 +0,0 @@ -- basics of config - - wrapping to config - - testbed for CaaS! -- allow to include .cdist -- generate - - pxe - - iso -- package... - - mkfs - - fdisk* - - kernel - -- types (?) - - iso? - - - -- based on Arch Linux - -- new types for iso? - -- change __cdistmarker to accept prefix - -- ISO / USB - genisoimage -r -V "cdist preos v0.2" -cache-inodes -J -l -no-emul-boot -boot-load-size 4 -b isolinux.bin -c boot.cat -o cdist-preos.iso iso - - - have a look at archiso? - - http://www.syslinux.org/wiki/index.php/Isohybrid - -> uefi - -> mbr - -- PXE diff --git a/docs/dev/logs/2017-04-27.execution-order.org b/docs/dev/logs/2017-04-27.execution-order.org deleted file mode 100644 index 5ee32062..00000000 --- a/docs/dev/logs/2017-04-27.execution-order.org +++ /dev/null @@ -1,5 +0,0 @@ -* After constructs don't exist - Flow as implemented on 2013-04-12 has the problem of not allowing - *after* constructs. -* "Type explorer & manifests only" is broken - Doesn't catch external dependencies diff --git a/docs/dev/logs/dependency-tree-with-fruits b/docs/dev/logs/dependency-tree-with-fruits deleted file mode 100644 index 322dc6e3..00000000 --- a/docs/dev/logs/dependency-tree-with-fruits +++ /dev/null @@ -1,29 +0,0 @@ -1. Manifests need type explorers to be run before - Only this way the manifest can use the values - -2. Type explorers can depend on the (successful) execution of other objects - A type explorer may lookup values (ownership, size, processes, etc.) - that are depending on the code of other objects. - -3. The 'require="a" b' dependency specifies only that execution of b needs to wait until a is finished - Other requirements given at another position may not be - executed before b, as cdist interprets require="a" as - "a is everything that is needed to realise b" - -4. The 'require' state is thus *not* suitable to trigger reloads - A type b, which uses the require="" statement to wait for all - require="" dependencies, may be executed in an incomplete - status. - -5. Depending on multiple dependencies defined at different locations requires all objects to be present - Because otherwise the dependent object cannot be sure that the - list of objects it waits for is complete. - -6. If a statement requires all objects to be present, all manifests must have run already. - If all manifests have run already, also all type explorers have run already (#1). - If all type explorers have run already, some objects may have been finished completly already (#2). - -7. Because of #4 and #6, we need to introduce another dependency that allows reloading after - -8. Because the object could be finished already due to a 'require' dependency, we need another script - Maybe "gen-post-run-local", "gen-post-run-remote" diff --git a/cdist/test/autil/fixtures/explorer/machine b/docs/dev/show_all_exported_variables similarity index 81% rename from cdist/test/autil/fixtures/explorer/machine rename to docs/dev/show_all_exported_variables index d4a0e106..18acceca 100755 --- a/cdist/test/autil/fixtures/explorer/machine +++ b/docs/dev/show_all_exported_variables @@ -1,6 +1,6 @@ #!/bin/sh # -# 2010-2011 Andi Brönnimann (andi-cdist at v-net.ch) +# 2010-2011 Nico Schottelius (nico-cdist at schottelius.org) # # This file is part of cdist. # @@ -18,10 +18,8 @@ # along with cdist. If not, see . # # -# All os variables are lower case -# +# Generate documentation of exported variables # -if command -v uname 2>&1 >/dev/null; then - uname -m -fi + +cat bin/* | awk '/^export/ { print $2 }' diff --git a/cdist/conf/type/__package/explorer/pkgng_exists b/docs/dev/sync-to-testhost similarity index 77% rename from cdist/conf/type/__package/explorer/pkgng_exists rename to docs/dev/sync-to-testhost index 6d69ba14..cc59eb8d 100755 --- a/cdist/conf/type/__package/explorer/pkgng_exists +++ b/docs/dev/sync-to-testhost @@ -1,6 +1,6 @@ #!/bin/sh # -# 2014 Jake Guffey (jake.guffey at eprotex.com) +# 2011 Nico Schottelius (nico-cdist at schottelius.org) # # This file is part of cdist. # @@ -18,10 +18,11 @@ # along with cdist. If not, see . # # -# Retrieve the status of a package - parsed dpkg output +# Sync repo to testhosts # -if [ "$("$__explorer/os")" = "freebsd" ]; then - command -v pkg -fi +dirs="cdist cdist-nutzung" +for dir in $dirs; do + rsync -av --delete /home/users/nico/p/$dir/ root@rnic01:$dir +done diff --git a/docs/dev/todo/3.0 b/docs/dev/todo/3.0 new file mode 100644 index 00000000..97699879 --- /dev/null +++ b/docs/dev/todo/3.0 @@ -0,0 +1 @@ +- remove __self and all references to it diff --git a/docs/dev/todo/TAKEME b/docs/dev/todo/TAKEME index 4d097091..87fc91c5 100644 --- a/docs/dev/todo/TAKEME +++ b/docs/dev/todo/TAKEME @@ -5,6 +5,10 @@ Feel free to pick one! CORE ---- +- support default parameter +- document and add paremeters for remote-copy and remote-exec! + - remove hack, make a feature of it + - remove var=foo calls on remote side. Use -o SendEnv (yeah, see ssh_config(5)) TESTS @@ -19,6 +23,9 @@ TESTS USER INTERFACE -------------- +- How to cleanly implement "restart service if config file changed" + -> document + - Cache - add example how to use - export variable $__cache @@ -38,6 +45,7 @@ TYPES - Add testing framework (proposed by Evax Software) - __user add option to include --create-home +- Merge __addifnosuchline and __removeline into __line + --state present|absent - __cron: Support --file to be used instead of user cron (probably direct support of /etc/cron.d) diff --git a/docs/dev/todo/niconext b/docs/dev/todo/niconext new file mode 100644 index 00000000..aa5f6001 --- /dev/null +++ b/docs/dev/todo/niconext @@ -0,0 +1,25 @@ +- introduce default parameters + - valid for optional parameters only + - stored in parameter/default/$name + + - when/where to save? in emulator? + - read vi fsproperty? + +- cleanup object_id handling + - have a look at singletons + +- update/create docs + - cdist-cache:: + How to get use information about the hosts we have been working on [advanced] + - cdist-scaling-tuning:: + How to scale out with cdist and which tunings to apply. [advanced] + - cdist-installation + How to use cdist to install hosts + - check speech publishing + - and speeches, which may be outdated as well + - Create new video for cdist 2.x + http://www.youtube.com/watch?v=PRMjzy48eTI + + - exec flag is not true for manifest anymore + - SSH HINTS - ssh agent + diff --git a/docs/dev/todo/performance-ideas b/docs/dev/todo/performance-ideas index 0320affa..bbbfe427 100644 --- a/docs/dev/todo/performance-ideas +++ b/docs/dev/todo/performance-ideas @@ -1,3 +1,6 @@ +- Migrate scripts from bin/* to functions in bin/cdist-deploy-to - Use one pipe-shell for type execution - Parallelise gencode and code-run of all objects - Diff against local cache only instead of real target +- Use only one ssh session? + - Can be indirectly improved via ssh config already! diff --git a/docs/dev/todo/steven b/docs/dev/todo/steven new file mode 100644 index 00000000..2aacaa42 --- /dev/null +++ b/docs/dev/todo/steven @@ -0,0 +1,118 @@ +autorequire: + - objects defined in type manifests should be automatically prerequisites of the current object + - __foo/some-id + __other other-id --state present + => require="__other/other-id" __foo/some-id + + +metaparameters: + - steal the metaparameters from puppet: + + # I have to be there before the other one + __directory /etc/ssh \ + --before __file/etc/ssh/sshd_config + + # the other one has to be there before me + __file /etc/ssh/sshd_config \ + --after __directory/etc/ssh + + # if I change, tell the other one about it + __file /etc/ssh/sshd_config \ + --notify __init_script/etc/rc.d/sshd + + # whenever the other one changes, I want to know + __init_script /etc/rc.d/sshd \ + --subscribe __file/etc/ssh/sshd_config + + - how does a type react to a received 'event'? + - maybe something like: + __some_type/ + manifest + ... + gencode-refresh + ... + - gencode-refresh -> code-refresh -> ssh $target sh -e code-refresh + + + + +logging: + - logging from type emulator without clobbering stdout + maybe implement logging server as described here [1] + [1] http://docs.python.org/py3k/howto/logging-cookbook.html#configuration-server-example + + - use different logger to limit output to current area of interest, + e.g. + explorer.$target_host: explorer related messages for the run for $target_host + manifest.$target_host: manifest related messages for the run for $target_host + ... + then one could filter e.g. on explorer.* + + - more granular debug output, + [2] http://blog.ooz.ie/2011/03/python-logging-extending-standard.html + + + +tests: + + __init__(): + - sets up env: __target_host + + run_initial_manifest(): + - parameter is actually used (from __init__) + - ensure changing the manifest actually runs a different manifest + -> give ConfigInstall Constructor different manifest + -> different manifest is executed. + - test all submitted (from core to type manifest) variables: + - ENVIRONMENT + - they are set + - they contain the correct values + + run_type_manifest(): + - test all submitted (from core to type manifest) variables: + - ENVIRONMENT + - they are set + - they contain the correct values + - same tests as for test_initial_manifest_*? + + run_manifest(): + - test all submitted variables: + - ENVIRONMENT + - including __debug, if debug + - they are set + - they contain the correct values + - does $require work? + - check that exception raised, if manifest is not existent + + object_run(): + - ensure no object is run twice + - ensure requirements are taken into account? + - and order of run is adjusted + - check (from extern?) that all needed variables are setup + - ensure no code-{local, remote} is created, + if gencode is not producing code + - ensure THAT code-{local, remote} contains what gencode created + - abort if gencode-* fails + - abort if code-* fails + - abort == raise(FooException) + - gencode-*: ensure ENVIRONMENT is setup correctly + + run_type_explorer() + - ensure ALL type explores have been run + - ensure output is saved to correct path + - ensure a type with {0,1,2} explorers works ? + - none, one, multiple + - ensure ENVIRONMENT is setup correctly + - fails if ANY of the given explorer fails + + run_global_explorers(): + - ensure ALL type explores have been run + - ensure output is saved to correct path + - ensure a type with {0,1,2} explorers works ? + - none, one, multiple + - ensure ENVIRONMENT is setup correctly + - fails if ANY of the given explorer fails + +Code fixes needed: + + - shutil, os.mkdir, etc. everywhere: catch/reraise exceptions correctly diff --git a/docs/dev/todo/tests b/docs/dev/todo/tests new file mode 100644 index 00000000..d2101980 --- /dev/null +++ b/docs/dev/todo/tests @@ -0,0 +1,27 @@ +Tests needed for config_install: + + cleanup() + - Fail if cache_dir from previous run cannot be deleted + - Fail if cache_dir cannot be created from current out_dir + + filter() + - ensure logformat is changed: target host is prefixed: + LOGLEVEL: target_host: MESSAGE + + link_emulator(): + - ensure that links to ALL types are created + - ensure that links points to correct executable + - i.e. readlink() works + - AND target of readlink is the correct executable + + remote_mkdir() + - is directory created + + remove_remote_path + - is path removed + + transfer_path + - is src to dst transferred? + +emulator: + may only be called with __ as prefix - fail otherwise! diff --git a/docs/legal/Benedikt_Koeppel.email b/docs/legal/Benedikt_Koeppel.email deleted file mode 100644 index 71fb39e9..00000000 --- a/docs/legal/Benedikt_Koeppel.email +++ /dev/null @@ -1,185 +0,0 @@ -From kaction Fri Jul 22 10:45:09 2016 -Return-path: -Envelope-to: KAction@gnu.org -Delivery-date: Fri, 22 Jul 2016 03:42:02 -0400 -Received: from fencepost.gnu.org [208.118.235.10] - by searing with POP3 (fetchmail-6.3.26) - for (single-drop); Fri, 22 Jul 2016 10:45:09 +0300 (MSK) -Received: from eggs.gnu.org ([2001:4830:134:3::10]:42146) - by fencepost.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) - (Exim 4.82) - (envelope-from ) - id 1bQV5t-0001Ct-WA - for KAction@gnu.org; Fri, 22 Jul 2016 03:42:02 -0400 -Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) - (envelope-from ) - id 1bQV5r-000365-7C - for KAction@gnu.org; Fri, 22 Jul 2016 03:42:00 -0400 -X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org -X-Spam-Level: -X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,HTML_MESSAGE, - T_DKIM_INVALID autolearn=disabled version=3.3.2 -Received: from mail-oi0-x22f.google.com ([2607:f8b0:4003:c06::22f]:32858) - by eggs.gnu.org with esmtp (Exim 4.71) - (envelope-from ) - id 1bQV5q-00035k-WC - for KAction@gnu.org; Fri, 22 Jul 2016 03:41:59 -0400 -Received: by mail-oi0-x22f.google.com with SMTP id j185so152015483oih.0 - for ; Fri, 22 Jul 2016 00:41:58 -0700 (PDT) -DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; - d=benediktkoeppel.ch; s=google; - h=mime-version:in-reply-to:references:from:date:message-id:subject:to; - bh=blJePxf1Q0zVh1kUkaKI6tKoOKbPV9CkRqLrYN8tz+4=; - b=VSpfcDF2tO+mgrTfZGlhHaqbtfYNe/QCbkSH5jWx8CVaItTuu88pTzdHuNZPtYrlQO - KZ6R/7xJrqGdWnKFCUibDAKI1Pd9OAx+ahQsYT5M7eKQt+nM9cMxaiyBjTTPfpF9UVa/ - /anpDGs/Bs6Z/p6c3ElNJOunfeEeS7kscr+Do= -X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; - d=1e100.net; s=20130820; - h=x-gm-message-state:mime-version:in-reply-to:references:from:date - :message-id:subject:to; - bh=blJePxf1Q0zVh1kUkaKI6tKoOKbPV9CkRqLrYN8tz+4=; - b=azAT/E+JYRP5bGvTI3t2BGCNsNfHxSWK+NKOtaWNYo1lyATKw9nJsSl1g6osLeanFr - JjpwlqHUN7v18z5ETqI+kvrmUShZjrgzGYE+yQuq++E4z/0C2YOUf+XZkGFVACguKRNt - HmOufiJNmkB2fYsIRMw3R21hLnM5QkIBlujmwbdxrtWyQSQ8Mfr4+sOnfp1ltHKaixIe - phfyJ6K6qP2h71VShDZmopg8Sg9rz6DSHbFDy8Ka9UTT3DXC+sLpdKFAfSebl0Tgd0eE - r0JND1fwL3pDQCxo4uK+GVM3q/usdTgzBwLnlg22clN1eca2oqrqdQdLQzgGuWYOmQg9 - +tTg== -X-Gm-Message-State: AEkoous0GycxMsszEEqNZrxNJGSADUJISKsdXl4E3+tACC8xUjLdUl3dFeAjSq6rGKkDeLMDrrfVceDa+nAo8A== -X-Received: by 10.157.19.98 with SMTP id q31mr1158747otq.125.1469173317562; - Fri, 22 Jul 2016 00:41:57 -0700 (PDT) -MIME-Version: 1.0 -Received: by 10.202.93.135 with HTTP; Fri, 22 Jul 2016 00:41:38 -0700 (PDT) -In-Reply-To: -References: -From: =?UTF-8?Q?Benedikt_K=C3=B6ppel?= -Date: Fri, 22 Jul 2016 09:41:38 +0200 -Message-ID: -Subject: Re: cdist contribution relicensing -To: Dmitry Bogatov -Content-Type: multipart/alternative; boundary=001a1135177ab4fbf60538349102 -X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] -X-Received-From: 2607:f8b0:4003:c06::22f -X-UIDL: S)T"!() wrote: - -> -> Hello, dear contributors of cdist project! -> -> Recently we discovered licensing issue with your contribution. Namely, -> while most of code is GPLv3+, including some of code written by you, -> manpages (man.txt, now man.rst) are GPLv3 only licensed. -> -> On behalf of cdist releasers (Darko and Nico), I (another cdist -> contributor and cdist Debian maintainer) ask you to permit relicense -> your contribution from GPLv3 to GPLv3+. Without your permission, we -> would be stuck the day when GPLv4 come (hope it will never come, but -> still), or have to reimplement your contribution. -> -> If you agree, please respond with something like -> -> I, #name# <#email#> permit to relicense all my contribution to -> cdist project, source code https://github.com/ungleich/cdist -> to GNU General Public license, version 3 or (at your option) -> any later version, as published by Free Software Foundation. -> -> #day# Jule 2016 year. -> -> If possible, GPG-sign such email. Do not include anything else -> valuable in this email that you do not want to be stored forever in -> public. -> -> Dear contributors, when replying to this email, please do not send -> copy to other contributors -- save their inbox storage. -> -> Thank you in advance for one more contribution. -> -> -- -> Accept: text/plain, text/x-diff -> Accept-Language: eo,en,ru -> X-Web-Site: sinsekvu.github.io -> - ---001a1135177ab4fbf60538349102 -Content-Type: text/html; charset=UTF-8 -Content-Transfer-Encoding: quoted-printable - -
=C2=A0 =C2=A0 =C2=A0 =C2= -=A0 I, Benedikt K=C3=B6ppel, code@benediktkoeppel.ch,=C2=A0permit to relicense all my= - contribution to
=C2=A0 =C2=A0 =C2=A0 =C2=A0 cdist project, source code=C2=A0https://github.com/ungleich/cdist
=C2=A0 = -=C2=A0 =C2=A0 =C2=A0 to GNU General Public license, version 3 or (at your o= -ption)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 any later version, as published by Free Softw= -are Foundation.

=C2=A0 =C2=A0 =C2=A0 =C2=A0 22 Ju= -ly 2016



On Wed, Jul 20, 2016 at 5:09 PM, = -Dmitry Bogatov <KAction@gnu.org> wrote:

-Hello, dear contributors of cdist project!
-
-Recently we discovered licensing issue with your contribution. Namely,
-while most of code is GPLv3+, including some of code written by you,
-manpages (man.txt, now man.rst) are GPLv3 only licensed.
-
-On behalf of cdist releasers (Darko and Nico), I (another cdist
-contributor and cdist Debian maintainer) ask you to permit relicense
-your contribution from GPLv3 to GPLv3+. Without your permission, we
-would be stuck the day when GPLv4 come (hope it will never come, but
-still), or have to reimplement your contribution.
-
-If you agree, please respond with something like
-
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 I, #name# <#email#> permit to relicense a= -ll my contribution to
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 cdist project, source code https://gith= -ub.com/ungleich/cdist
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 to GNU General Public license, version 3 or (at= - your option)
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 any later version, as published by Free Softwar= -e Foundation.
-
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 #day# Jule 2016 year.
-
-If possible, GPG-sign such email. Do not include anything else
-valuable in this email that you do not want to be stored forever in
-public.
-
-Dear contributors, when replying to this email, please do not send
-copy to other contributors -- save their inbox storage.
-
-Thank you in advance for one more contribution.
-
---
-Accept: text/plain, text/x-diff
-Accept-Language: eo,en,ru
-X-Web-Site: sinsekvu.github.io
-

- ---001a1135177ab4fbf60538349102-- - diff --git a/docs/legal/Chase_James.email b/docs/legal/Chase_James.email deleted file mode 100644 index c57c62fd..00000000 --- a/docs/legal/Chase_James.email +++ /dev/null @@ -1,185 +0,0 @@ -From kaction Wed Jul 20 21:30:05 2016 -Return-path: -Envelope-to: KAction@gnu.org -Delivery-date: Wed, 20 Jul 2016 14:25:53 -0400 -Received: from fencepost.gnu.org [208.118.235.10] - by searing with POP3 (fetchmail-6.3.26) - for (single-drop); Wed, 20 Jul 2016 21:30:05 +0300 (MSK) -Received: from eggs.gnu.org ([2001:4830:134:3::10]:48289) - by fencepost.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) - (Exim 4.82) - (envelope-from ) - id 1bPwBt-00025s-Lu - for KAction@gnu.org; Wed, 20 Jul 2016 14:25:53 -0400 -Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) - (envelope-from ) - id 1bPwBr-0007tM-Uq - for KAction@gnu.org; Wed, 20 Jul 2016 14:25:53 -0400 -X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org -X-Spam-Level: -X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,HTML_MESSAGE, - T_DKIM_INVALID autolearn=disabled version=3.3.2 -Received: from mail-io0-x236.google.com ([2607:f8b0:4001:c06::236]:32874) - by eggs.gnu.org with esmtp (Exim 4.71) - (envelope-from ) - id 1bPwBr-0007t9-NK - for KAction@gnu.org; Wed, 20 Jul 2016 14:25:51 -0400 -Received: by mail-io0-x236.google.com with SMTP id 38so55303707iol.0 - for ; Wed, 20 Jul 2016 11:25:50 -0700 (PDT) -DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; - d=nu-ex-com.20150623.gappssmtp.com; s=20150623; - h=mime-version:references:in-reply-to:from:date:message-id:subject:to; - bh=jeiFw5Oto9q90WQrIDawOh/M0DSQuTm6MsNWzCa2iqM=; - b=w2EjWx2jk9uB85wrWykVmNEy9QEg28aOHaekBeO8iyoODPF2j8MsXjtXhvUs+4ZxLF - 9fo3qkCLMV9NrPtteb8y4y5kTjbAHJsskIf7r2vdmG1VavbaHlkg8RNya2D90M46cJtz - uaQHQsup+ukaia6j5rQOSq96ioa+hB6mDifxDyvuHY8nbnKnZ3ZYcs+XWnMEBFYa+fPr - Uy/WEnszBVLXVBWh8DN4KNYNuIenzTo0UBSscrriq4vVs3+7uzqimK2jK2OGYAx6sNot - S/DRbSGlY4HRrELgfL654UZsdExXAgphu1X+ibAjCaFjPPK/Nn+rOBif9KFmjLI5c+pF - tLQw== -X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; - d=1e100.net; s=20130820; - h=x-gm-message-state:mime-version:references:in-reply-to:from:date - :message-id:subject:to; - bh=jeiFw5Oto9q90WQrIDawOh/M0DSQuTm6MsNWzCa2iqM=; - b=QzC2SV8Hl3lehpfi0nN2IboohDGuxFsjoqLSL38THT412ruqWgwQoVLbBQg4XRmAgg - rrT2sR8LCCTHJqUBjFlaTIOAFxxWj8ji9E9p9BNTHHvQ6Gqhl5U3SOPAXvtFtoEPEoLa - 9EyNGzjO7VqsZHoYcYgXf/Tpw8Nsro14Lnv7ShbPS5ZNitwwXlVO+7v1FvxxARQskM3a - NWmw5/8fXLqsd5bQATq6Lq3APmV2wZFmVdJ9QZam9BZHqq5X11hLf6t4r0OgEyhwZ4/o - MX1rJvYL7Qnc3Gy6iQJTw8IJeECYP1jJ+g87C15kgKiyE70x2Xg/dPTPi5wuO2OSBnNq - 0gAg== -X-Gm-Message-State: ALyK8tKkwgnTTOBYgFgESByuR5isjDNaKDDSP1OBDQYyhq6gPsDbGeLfq9zPZ7jm2ZciBSSvH2DS7EF+bA/qcw== -X-Received: by 10.107.130.170 with SMTP id m42mr43873568ioi.78.1469039149834; - Wed, 20 Jul 2016 11:25:49 -0700 (PDT) -MIME-Version: 1.0 -References: -In-Reply-To: -From: nx -Date: Wed, 20 Jul 2016 18:25:40 +0000 -Message-ID: -Subject: Re: cdist contribution relicensing -To: Dmitry Bogatov -Content-Type: multipart/alternative; boundary=001a113bd076affa64053815546c -X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] -X-Received-From: 2607:f8b0:4001:c06::236 -X-UIDL: ~j$"!G$!#!92;"!/;T"! - ---001a113bd076affa64053815546c -Content-Type: text/plain; charset=UTF-8 - -I, Chase James , permit to relicense all my -contribution to cdist project, source code https://github.com/ungleich/cdist - to GNU General Public license, version 3 or (at your option) any later -version, as published by Free Software Foundation. - -20 July 2016 - -On Wed, Jul 20, 2016 at 11:10 AM Dmitry Bogatov wrote: - -> -> Hello, dear contributors of cdist project! -> -> Recently we discovered licensing issue with your contribution. Namely, -> while most of code is GPLv3+, including some of code written by you, -> manpages (man.txt, now man.rst) are GPLv3 only licensed. -> -> On behalf of cdist releasers (Darko and Nico), I (another cdist -> contributor and cdist Debian maintainer) ask you to permit relicense -> your contribution from GPLv3 to GPLv3+. Without your permission, we -> would be stuck the day when GPLv4 come (hope it will never come, but -> still), or have to reimplement your contribution. -> -> If you agree, please respond with something like -> -> I, #name# <#email#> permit to relicense all my contribution to -> cdist project, source code https://github.com/ungleich/cdist -> to GNU General Public license, version 3 or (at your option) -> any later version, as published by Free Software Foundation. -> -> #day# Jule 2016 year. -> -> If possible, GPG-sign such email. Do not include anything else -> valuable in this email that you do not want to be stored forever in -> public. -> -> Dear contributors, when replying to this email, please do not send -> copy to other contributors -- save their inbox storage. -> -> Thank you in advance for one more contribution. -> -> -- -> Accept: text/plain, text/x-diff -> Accept-Language: eo,en,ru -> X-Web-Site: sinsekvu.github.io -> - ---001a113bd076affa64053815546c -Content-Type: text/html; charset=UTF-8 -Content-Transfer-Encoding: quoted-printable - -
I, Chase James <nx-cdist@nu-ex.com>, permit to relicense a= -ll my contribution to=C2=A0cdist project,= - source code=C2=A0= -https://github.com/ungleich/cdist=C2=A0to GNU General Public license, version 3 or (at your option)=C2= -=A0any later version, as published by Fre= -e Software Foundation.

20 July 2016
= -

On Wed, Jul 20, 2016 = -at 11:10 AM Dmitry Bogatov <KAction@g= -nu.org> wrote:

-Hello, dear contributors of cdist project!
-
-Recently we discovered licensing issue with your contribution. Namely,
-while most of code is GPLv3+, including some of code written by you,
-manpages (man.txt, now man.rst) are GPLv3 only licensed.
-
-On behalf of cdist releasers (Darko and Nico), I (another cdist
-contributor and cdist Debian maintainer) ask you to permit relicense
-your contribution from GPLv3 to GPLv3+. Without your permission, we
-would be stuck the day when GPLv4 come (hope it will never come, but
-still), or have to reimplement your contribution.
-
-If you agree, please respond with something like
-
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 I, #name# <#email#> permit to relicense a= -ll my contribution to
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 cdist project, source code https://gith= -ub.com/ungleich/cdist
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 to GNU General Public license, version 3 or (at= - your option)
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 any later version, as published by Free Softwar= -e Foundation.
-
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 #day# Jule 2016 year.
-
-If possible, GPG-sign such email. Do not include anything else
-valuable in this email that you do not want to be stored forever in
-public.
-
-Dear contributors, when replying to this email, please do not send
-copy to other contributors -- save their inbox storage.
-
-Thank you in advance for one more contribution.
-
---
-Accept: text/plain, text/x-diff
-Accept-Language: eo,en,ru
-X-Web-Site: sinsekvu.github.io
-
- ---001a113bd076affa64053815546c-- - diff --git a/docs/legal/Christian_Warden.email b/docs/legal/Christian_Warden.email deleted file mode 100644 index 798b3201..00000000 --- a/docs/legal/Christian_Warden.email +++ /dev/null @@ -1,122 +0,0 @@ -From kaction Wed Jul 20 18:25:04 2016 -Return-path: -Envelope-to: KAction@gnu.org -Delivery-date: Wed, 20 Jul 2016 11:20:15 -0400 -Received: from fencepost.gnu.org [208.118.235.10] - by searing with POP3 (fetchmail-6.3.26) - for (single-drop); Wed, 20 Jul 2016 18:25:04 +0300 (MSK) -Received: from eggs.gnu.org ([2001:4830:134:3::10]:34238) - by fencepost.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) - (Exim 4.82) - (envelope-from ) - id 1bPtIF-000809-Ob - for KAction@gnu.org; Wed, 20 Jul 2016 11:20:15 -0400 -Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) - (envelope-from ) - id 1bPtIB-0006jv-SP - for KAction@gnu.org; Wed, 20 Jul 2016 11:20:15 -0400 -X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org -X-Spam-Level: -X-Spam-Status: No, score=-0.5 required=5.0 tests=BAYES_50,RP_MATCHES_RCVD, - T_DKIM_INVALID autolearn=disabled version=3.3.2 -Received: from sage.xerus.org ([207.210.217.189]:21397) - by eggs.gnu.org with esmtp (Exim 4.71) - (envelope-from ) - id 1bPtIB-0006cm-9G - for KAction@gnu.org; Wed, 20 Jul 2016 11:20:11 -0400 -DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xerus.org; s=sage; - h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID:Subject:To:From:Date; bh=O5u4neMHAeGrtpVYFlmpULGNH1YPNhLUEaWPXxzf2xk=; - b=KjzaEXo/CKeUuLj2B1Hrf3krvsJgkMnjqvjJM2KfFJWsiiHU9qPlUtaETBG9jE9tD5MTjg/5/Wr/4u+CnA3xLeNBMIDrFaLaPW2vdlqFsRSVsjl3g/a4LqNrIZcU60/Lwlzb4ber5Y5i69MUX4Y/m1p57FjXTlqONbZZzOa82WQ=; -Received: from c-71-59-214-243.hsd1.or.comcast.net ([71.59.214.243] helo=speedy.xerus.org) - by sage.xerus.org (envelope-from ) - with esmtpsa (Exim 4.80 #2 (Debian)) - id 1bPtHk-0005To-3h - for ; Wed, 20 Jul 2016 08:19:44 -0700 -Received: from cwarden by speedy.xerus.org with local (Exim 4.80) - (envelope-from ) - id 1bPtHj-0007NB-6e - for KAction@gnu.org; Wed, 20 Jul 2016 08:19:43 -0700 -Date: Wed, 20 Jul 2016 08:19:43 -0700 -From: "Christian G. Warden" -To: Dmitry Bogatov -Subject: Re: cdist contribution relicensing -Message-ID: <20160720151943.GD8681@xerus.org> -References: -MIME-Version: 1.0 -Content-Type: multipart/signed; micalg=pgp-sha1; - protocol="application/pgp-signature"; boundary="eAbsdosE1cNLO4uF" -Content-Disposition: inline -In-Reply-To: -X-Face: jD^+@)>yf8|'#1~7ie$N]>2XN},k*wInk~T->gX/l"0?GDg#b;M[;(4'R94H`6,~p"&"(`$ - ?KVH_(2BuS[Zi(IFt,DWb'j77JZMQ~S0mN]o^>zAGQOaz6/uCSFu(O,jf*(e<*'Sa~yW1k1RC0xhd1 - ]'F2p]Wvt3bJ$i2E69!rDttE@/nw?1kS#-#Al(p=G\{Jj4GaRlN(V=R@+&dqD{`v7Y{!WE_?H!iD2D - Z$ -User-Agent: Mutt/1.6.0 (2016-04-01) -X-Sender-Verification: OK -X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] -X-Received-From: 207.210.217.189 -X-UIDL: Dh>"!+M_"!, waive all copyright and -related rights in my contribution to the cdist project. - -Christian - -On Wed, Jul 20, 2016 at 06:09:46PM +0300, Dmitry Bogatov wrote: ->=20 -> Hello, dear contributors of cdist project! ->=20 -> Recently we discovered licensing issue with your contribution. Namely, -> while most of code is GPLv3+, including some of code written by you, -> manpages (man.txt, now man.rst) are GPLv3 only licensed. ->=20 -> On behalf of cdist releasers (Darko and Nico), I (another cdist -> contributor and cdist Debian maintainer) ask you to permit relicense -> your contribution from GPLv3 to GPLv3+. Without your permission, we -> would be stuck the day when GPLv4 come (hope it will never come, but -> still), or have to reimplement your contribution. ->=20 -> If you agree, please respond with something like ->=20 -> I, #name# <#email#> permit to relicense all my contribution to -> cdist project, source code https://github.com/ungleich/cdist -> to GNU General Public license, version 3 or (at your option) -> any later version, as published by Free Software Foundation. ->=20 -> #day# Jule 2016 year. ->=20 -> If possible, GPG-sign such email. Do not include anything else -> valuable in this email that you do not want to be stored forever in -> public. ->=20 -> Dear contributors, when replying to this email, please do not send -> copy to other contributors -- save their inbox storage. ->=20 -> Thank you in advance for one more contribution. ->=20 -> -- -> Accept: text/plain, text/x-diff -> Accept-Language: eo,en,ru -> X-Web-Site: sinsekvu.github.io - - - ---eAbsdosE1cNLO4uF -Content-Type: application/pgp-signature; name="signature.asc" - ------BEGIN PGP SIGNATURE----- -Version: GnuPG v1 - -iEYEARECAAYFAlePlo8ACgkQXSJ4OU73l6Ap6wCgjNo7oLH8G6KUECBOTyCoGbMk -wgAAoJHq5Tx5EWNO9pg3YvBtff5m1iHx -=srJn ------END PGP SIGNATURE----- - ---eAbsdosE1cNLO4uF-- - diff --git a/docs/legal/Daniel_Heule.email b/docs/legal/Daniel_Heule.email deleted file mode 100644 index a66e468c..00000000 --- a/docs/legal/Daniel_Heule.email +++ /dev/null @@ -1,97 +0,0 @@ -From kaction Thu Jul 21 09:20:03 2016 -Return-path: -Envelope-to: KAction@gnu.org -Delivery-date: Thu, 21 Jul 2016 02:15:43 -0400 -Received: from fencepost.gnu.org [208.118.235.10] - by searing with POP3 (fetchmail-6.3.26) - for (single-drop); Thu, 21 Jul 2016 09:20:03 +0300 (MSK) -Received: from eggs.gnu.org ([2001:4830:134:3::10]:60463) - by fencepost.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) - (Exim 4.82) - (envelope-from ) - id 1bQ7Go-0005is-V4 - for KAction@gnu.org; Thu, 21 Jul 2016 02:15:43 -0400 -Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) - (envelope-from ) - id 1bQ7Gk-0006QB-Hy - for KAction@gnu.org; Thu, 21 Jul 2016 02:15:41 -0400 -X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org -X-Spam-Level: -X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,HTML_MESSAGE, - RCVD_IN_DNSWL_NONE autolearn=disabled version=3.3.2 -Received: from mail3.sfsservices.biz ([194.93.112.48]:32812) - by eggs.gnu.org with esmtp (Exim 4.71) - (envelope-from ) - id 1bQ7Gk-0006Pg-Ay - for KAction@gnu.org; Thu, 21 Jul 2016 02:15:38 -0400 -X-Received: from localhost (localhost [127.0.0.1]) - by mail3.sfsservices.biz (Postfix) with ESMTP id 4F7C37E219FD - for ; Thu, 21 Jul 2016 08:15:33 +0200 (CEST) -X-Virus-Scanned: amavisd-new at sfsservices.biz -X-Received: from mail3.sfsservices.biz ([127.0.0.1]) - by localhost (mail3.sfsservices.biz [127.0.0.1]) (amavisd-new, port 10023) - with ESMTP id 42FFY6pT6H_v for ; - Thu, 21 Jul 2016 08:15:33 +0200 (CEST) -X-Received: from chsfsd14.sfs-intra.net (chsfsln0001.sfs-intra.net [INTERNAL-IP]) - by mail3.sfsservices.biz (Postfix) with ESMTP - for ; Thu, 21 Jul 2016 08:15:33 +0200 (CEST) -In-Reply-To: -References: -To: Dmitry Bogatov -MIME-Version: 1.0 -Subject: Antwort: cdist contribution relicensing -X-KeepSent: 3BCE55E5:113E83E4-C1257FF7:002232C0; - type=4; name=$KeepSent -X-Mailer: IBM Notes Release 9.0.1FP3 January 13, 2015 -Message-ID: -From: Daniel Heule -Date: Thu, 21 Jul 2016 08:15:32 +0200 -X-MIMETrack: Serialize by Router on chsfsd14/SFS(Release 9.0.1FP6|April 20, 2016) at - 21.07.2016 08:15:32, - Serialize complete at 21.07.2016 08:15:32 -Content-Type: multipart/alternative; boundary="=_alternative 00226206C1257FF7_=" -X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] -X-Received-From: 194.93.112.48 -X-UIDL: LCD"!0Gb!!dH-"!0ma"! - -Dies ist eine mehrteilige Nachricht im MIME-Format. ---=_alternative 00226206C1257FF7_= -Content-Type: text/plain; charset="ISO-8859-1" -Content-Transfer-Encoding: quoted-printable - -I, Daniel Heule, hda@sfs.biz permit to relicense all my contribution to -cdist project, source code https://github.com/ungleich/cdist -to GNU General Public license, version 3 or (at your option) -any later version, as published by Free Software Foundation. - -21 Jule 2016. - - - -Mit freundlichen Gr=FCssen / Kind regards - -Daniel Heule - ---=_alternative 00226206C1257FF7_= -Content-Type: text/html; charset="ISO-8859-1" -Content-Transfer-Encoding: quoted-printable - -I, Daniel Heule, hda@sfs.biz permit to relicense all -my contribution to
-cdist project, source code
https://github.com/ungleich/cdist
-to GNU General Public license, version 3 or (at your option)
-any later version, as published by Free Software Foundation.
-
-21 Jule 2016.
-
-
-
-
Mit freundlichen Gr=FCssen / Kind re= -gards
-
-
Daniel Heule -
---=_alternative 00226206C1257FF7_=-- - diff --git a/docs/legal/Daniel_Maher.email b/docs/legal/Daniel_Maher.email deleted file mode 100644 index 3e7ab892..00000000 --- a/docs/legal/Daniel_Maher.email +++ /dev/null @@ -1,180 +0,0 @@ -From kaction Thu Jul 21 17:05:06 2016 -Return-path: -Envelope-to: KAction@gnu.org -Delivery-date: Thu, 21 Jul 2016 10:00:45 -0400 -Received: from fencepost.gnu.org [208.118.235.10] - by searing with POP3 (fetchmail-6.3.26) - for (single-drop); Thu, 21 Jul 2016 17:05:06 +0300 (MSK) -Received: from eggs.gnu.org ([2001:4830:134:3::10]:51771) - by fencepost.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) - (Exim 4.82) - (envelope-from ) - id 1bQEWr-0007dw-7V - for KAction@gnu.org; Thu, 21 Jul 2016 10:00:45 -0400 -Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) - (envelope-from ) - id 1bQEWm-0005MY-BL - for KAction@gnu.org; Thu, 21 Jul 2016 10:00:44 -0400 -X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org -X-Spam-Level: * -X-Spam-Status: No, score=1.8 required=5.0 tests=BAYES_50,FREEMAIL_FROM, - FREEMAIL_REPLY,HTML_MESSAGE,T_DKIM_INVALID autolearn=disabled version=3.3.2 -Received: from mail-lf0-x22f.google.com ([2a00:1450:4010:c07::22f]:33089) - by eggs.gnu.org with esmtp (Exim 4.71) - (envelope-from ) - id 1bQEWl-0005Lm-Ra - for KAction@gnu.org; Thu, 21 Jul 2016 10:00:40 -0400 -Received: by mail-lf0-x22f.google.com with SMTP id b199so62920486lfe.0 - for ; Thu, 21 Jul 2016 07:00:39 -0700 (PDT) -DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; - d=gmail.com; s=20120113; - h=mime-version:in-reply-to:references:from:date:message-id:subject:to; - bh=QxAnWA/6Ux99c9jwOxhyzuW7Mgg4vOlk5/YLw6lG7vI=; - b=GxRkrDAKMCBYgbFXFw//11UoxJ1DI3SANR2ZJTIGfJQWun/PdH/UIp9Y/yrUgReQ52 - aF+/xiGwZtwAtNrW5x5sH8t6eKTEDX98F44kqyTn8W0r4UKlFveIGyqGLKhwgiysUa7s - V7t4HeZHf6KuS1M2v7pGHfY8RWNKkcqbAfc1o5RvSf5w7Fma7vwYTfHhpOTHymjJ6Q0r - 9Ite/jxAuZkg1MD1AQftYpJX1MHpEvsZfSwNNl/rc06onY8uF5/WCbORoDJdDvnFnIle - UKDqPxvOO5b82FH1t4YZQy3qN6uJEZj5XHTHNVe0wmnl09hkKJgq2OF7ih1tKLPhxyo+ - MhJw== -X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; - d=1e100.net; s=20130820; - h=x-gm-message-state:mime-version:in-reply-to:references:from:date - :message-id:subject:to; - bh=QxAnWA/6Ux99c9jwOxhyzuW7Mgg4vOlk5/YLw6lG7vI=; - b=Um0d/lugkccoSfexFcSRQXYK9NPQW24ciOdTfq6HfF1io3u/LCeIg8Vevtk0aY2aJd - 88LeTX66bYD3s3fDRaAo3/GFnjD48IaXkkLNqXD9WHvLdC01RHVerPU0gG0drd28gFfS - BLr6EO7Eyx1VNNFw9eT9PSkzJdRBA73h6zv+/eJLLSI+xz2e9oMlixZ4UnVj7Zc2GDBD - QKftxgjr499rVbkRDXCvjBhEEUdYVJSPlr+gNCnmfy9Me6tqRvjWOwGbxwvnOj/DZ0Lc - s7F7oy6K3DnJMweLH48JsQLiOp4FDJjMydhrxavr2FZ1xdTtDXQzxQCPZfyJsilteQKd - VX1A== -X-Gm-Message-State: ALyK8tJIaYrPzw331bl+6pm5hf75dGrGWIlW3nvRHHCunoAIji4D3HIofy8DADE4ckYnaOxRSf6aYlYIrHPoYg== -X-Received: by 10.25.22.152 with SMTP id 24mr24682317lfw.180.1469109638281; - Thu, 21 Jul 2016 07:00:38 -0700 (PDT) -MIME-Version: 1.0 -Received: by 10.25.85.141 with HTTP; Thu, 21 Jul 2016 07:00:18 -0700 (PDT) -In-Reply-To: -References: -From: dan maher -Date: Thu, 21 Jul 2016 16:00:18 +0200 -Message-ID: -Subject: Re: cdist contribution relicensing -To: Dmitry Bogatov -Content-Type: multipart/alternative; boundary=001a11408306203f8e053825be9d -X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] -X-Received-From: 2a00:1450:4010:c07::22f -X-UIDL: PnS!!MF-!!Y1/!!@L permit to relicense all -my contribution to - cdist project, source code https://github.com/ungleich/cdist - to GNU General Public license, version 3 or (at your option) - any later version, as published by Free Software Foundation. - - 21 July 2016. - -On 20 July 2016 at 17:09, Dmitry Bogatov wrote: - -> -> Hello, dear contributors of cdist project! -> -> Recently we discovered licensing issue with your contribution. Namely, -> while most of code is GPLv3+, including some of code written by you, -> manpages (man.txt, now man.rst) are GPLv3 only licensed. -> -> On behalf of cdist releasers (Darko and Nico), I (another cdist -> contributor and cdist Debian maintainer) ask you to permit relicense -> your contribution from GPLv3 to GPLv3+. Without your permission, we -> would be stuck the day when GPLv4 come (hope it will never come, but -> still), or have to reimplement your contribution. -> -> If you agree, please respond with something like -> -> I, #name# <#email#> permit to relicense all my contribution to -> cdist project, source code https://github.com/ungleich/cdist -> to GNU General Public license, version 3 or (at your option) -> any later version, as published by Free Software Foundation. -> -> #day# Jule 2016 year. -> -> If possible, GPG-sign such email. Do not include anything else -> valuable in this email that you do not want to be stored forever in -> public. -> -> Dear contributors, when replying to this email, please do not send -> copy to other contributors -- save their inbox storage. -> -> Thank you in advance for one more contribution. -> -> -- -> Accept: text/plain, text/x-diff -> Accept-Language: eo,en,ru -> X-Web-Site: sinsekvu.github.io -> - ---001a11408306203f8e053825be9d -Content-Type: text/html; charset=UTF-8 -Content-Transfer-Encoding: quoted-printable - -
=C2=A0 =C2=A0 =C2=A0 =C2=A0 I, Daniel MAHER <phrawzty+cdist@gmail.com> permit= - to relicense all my contribution to
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 cdist project, source code https://gith= -ub.com/ungleich/cdist
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 to GNU General Public license, version 3 or (at= - your option)
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 any later version, as published by Free Softwar= -e Foundation.
-
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 21 July 2016.
<= -br>
On 20 July 2016 at 17:09, Dmitry Bogatov <KAct= -ion@gnu.org> wrote:

-Hello, dear contributors of cdist project!
-
-Recently we discovered licensing issue with your contribution. Namely,
-while most of code is GPLv3+, including some of code written by you,
-manpages (man.txt, now man.rst) are GPLv3 only licensed.
-
-On behalf of cdist releasers (Darko and Nico), I (another cdist
-contributor and cdist Debian maintainer) ask you to permit relicense
-your contribution from GPLv3 to GPLv3+. Without your permission, we
-would be stuck the day when GPLv4 come (hope it will never come, but
-still), or have to reimplement your contribution.
-
-If you agree, please respond with something like
-
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 I, #name# <#email#> permit to relicense a= -ll my contribution to
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 cdist project, source code https://gith= -ub.com/ungleich/cdist
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 to GNU General Public license, version 3 or (at= - your option)
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 any later version, as published by Free Softwar= -e Foundation.
-
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 #day# Jule 2016 year.
-
-If possible, GPG-sign such email. Do not include anything else
-valuable in this email that you do not want to be stored forever in
-public.
-
-Dear contributors, when replying to this email, please do not send
-copy to other contributors -- save their inbox storage.
-
-Thank you in advance for one more contribution.
-
---
-Accept: text/plain, text/x-diff
-Accept-Language: eo,en,ru
-X-Web-Site: sinsekvu.github.io
-

- ---001a11408306203f8e053825be9d-- - diff --git a/docs/legal/Giel_van_Schijndel.email b/docs/legal/Giel_van_Schijndel.email deleted file mode 100644 index 2f085653..00000000 --- a/docs/legal/Giel_van_Schijndel.email +++ /dev/null @@ -1,85 +0,0 @@ -From kaction Thu Jul 21 01:10:04 2016 -Return-path: -Envelope-to: KAction@gnu.org -Delivery-date: Wed, 20 Jul 2016 18:06:32 -0400 -Received: from fencepost.gnu.org [208.118.235.10] - by searing with POP3 (fetchmail-6.3.26) - for (single-drop); Thu, 21 Jul 2016 01:10:04 +0300 (MSK) -Received: from eggs.gnu.org ([2001:4830:134:3::10]:44575) - by fencepost.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) - (Exim 4.82) - (envelope-from ) - id 1bPzdP-0004KA-R1 - for KAction@gnu.org; Wed, 20 Jul 2016 18:06:31 -0400 -Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) - (envelope-from ) - id 1bPzdL-0005W4-Bl - for KAction@gnu.org; Wed, 20 Jul 2016 18:06:30 -0400 -X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org -X-Spam-Level: -X-Spam-Status: No, score=-0.5 required=5.0 tests=BAYES_50,RP_MATCHES_RCVD - autolearn=disabled version=3.3.2 -Received: from khitomer.mortis.eu ([185.27.175.75]:55475) - by eggs.gnu.org with esmtp (Exim 4.71) - (envelope-from ) - id 1bPzdL-0005VB-4y - for KAction@gnu.org; Wed, 20 Jul 2016 18:06:27 -0400 -Received: from salidar.dom.custoft.eu (unknown [IPv6:2001:981:4eab:1:7016:52bb:c51b:646d]) - (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) - (Client CN "Giel van Schijndel", Issuer "CAcert Class 3 Root" (not verified)) - by khitomer.mortis.eu (Postfix) with ESMTPS id 0634E1D8 - for ; Thu, 21 Jul 2016 00:06:24 +0200 (CEST) -Received: by salidar.dom.custoft.eu (Postfix, from userid 2079) - id BA3033216E; Thu, 21 Jul 2016 00:06:22 +0200 (CEST) -Date: Thu, 21 Jul 2016 00:06:22 +0200 -From: Giel van Schijndel -To: Dmitry Bogatov -Subject: Re: cdist contribution relicensing -Message-ID: <20160720220622.GC2228@salidar.dom.custoft.eu> -References: -MIME-Version: 1.0 -Content-Type: multipart/signed; micalg=pgp-sha1; - protocol="application/pgp-signature"; boundary="2qXFWqzzG3v1+95a" -Content-Disposition: inline -In-Reply-To: -OpenPGP: id=CEE5E742; url=http://gpg.mortis.eu/me.asc -User-Agent: Mutt/1.6.0 (2016-04-01) -X-detected-operating-system: by eggs.gnu.org: FreeBSD 9.x -X-Received-From: 185.27.175.75 -X-UIDL: Kgn!!Pf9!!I,+!!#DW"! - - ---2qXFWqzzG3v1+95a -Content-Type: text/plain; charset=us-ascii -Content-Disposition: inline -Content-Transfer-Encoding: quoted-printable - -I, Giel van Schijndel, hereby give permission to any recipients of my -contributions to the cdist project done up to this date, to redistribute -these or derivatives thereof 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. For clarity: -these contributions should be reachable through the Git commit -identifiable by SHA-1 160-bit hash 7e57575f9e1ad0909750d116e9eabc15c1c77e2c -to be considered "up to this date". - -Signed, July 21th, 2016. - ---=20 -Met vriendelijke groet, -With kind regards, -Giel van Schijndel - ---2qXFWqzzG3v1+95a -Content-Type: application/pgp-signature; name="signature.asc" - ------BEGIN PGP SIGNATURE----- -Version: GnuPG v1 - -iEYEARECAAYFAleP9dgACgkQZBYm/87l50LVfQCfXo/2XqCwreH0VEmsmYzE5nE/ -zlMAn0D8/9qif3bAwOwDtvFKJWtfabrg -=f6r/ ------END PGP SIGNATURE----- - ---2qXFWqzzG3v1+95a-- - diff --git a/docs/legal/Jacob_Guffey.email b/docs/legal/Jacob_Guffey.email deleted file mode 100644 index a9892deb..00000000 --- a/docs/legal/Jacob_Guffey.email +++ /dev/null @@ -1,64 +0,0 @@ -From kaction Sat Jul 23 01:20:04 2016 -Return-path: -Envelope-to: KAction@gnu.org -Delivery-date: Fri, 22 Jul 2016 18:19:30 -0400 -Received: from fencepost.gnu.org [208.118.235.10] - by searing with POP3 (fetchmail-6.3.26) - for (single-drop); Sat, 23 Jul 2016 01:20:04 +0300 (MSK) -Received: from eggs.gnu.org ([2001:4830:134:3::10]:57472) - by fencepost.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) - (Exim 4.82) - (envelope-from ) - id 1bQin4-0006js-EH - for KAction@gnu.org; Fri, 22 Jul 2016 18:19:30 -0400 -Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) - (envelope-from ) - id 1bQin0-00078i-0H - for KAction@gnu.org; Fri, 22 Jul 2016 18:19:29 -0400 -X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org -X-Spam-Level: -X-Spam-Status: No, score=-3.2 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD - autolearn=disabled version=3.3.2 -Received: from jhsmtdmz01x.jointheirstm.org ([69.28.94.113]:64009) - by eggs.gnu.org with esmtp (Exim 4.71) - (envelope-from ) - id 1bQimz-00078K-Rx - for KAction@gnu.org; Fri, 22 Jul 2016 18:19:25 -0400 -Received: from moshe.jointheirstm.org (c-98-253-78-203.hsd1.in.comcast.net [98.253.78.203]) - by JHSMTDMZ01X.jointheirstm.org (Postfix) with ESMTPSA id 922972AE606 - for ; Fri, 22 Jul 2016 18:19:23 -0400 (EDT) -Subject: Re: cdist contribution relicensing -To: Dmitry Bogatov -References: -From: Jake Guffey -Message-ID: <57929BB9.1080104@Jointheirstm.org> -Date: Fri, 22 Jul 2016 18:18:33 -0400 -User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 - Thunderbird/38.5.0 -MIME-Version: 1.0 -In-Reply-To: -Content-Type: text/plain; charset=windows-1252 -Content-Transfer-Encoding: 7bit -X-detected-operating-system: by eggs.gnu.org: FreeBSD 9.x -X-Received-From: 69.28.94.113 -X-UIDL: B!'#!_Z2!![?h"!'Ij"! - ------BEGIN PGP SIGNED MESSAGE----- -Hash: SHA256 - -I, Jacob Guffey , permit to relicense -all my contributions to the cdist project, source code -https://github.com/ungleich/cdist to GNU General Public license, -version 3 or (at the maintainer's option) any later version, as -published by Free Software Foundation. - -2016-07-22 - ------BEGIN PGP SIGNATURE----- -Version: GnuPG v2 - -iF4EAREIAAYFAleSm7YACgkQT+o/hrTzJc0NQwD/b2hjXG6UCJXnVUANmWnVy+/L -ae+7lZhFL8UklI5cb/0BAOC7jjH8FfKz1lL/Arqw4SM64yy3wiwvJjqJDtmuumWl -=VLlV ------END PGP SIGNATURE----- - diff --git a/docs/legal/README b/docs/legal/README deleted file mode 100644 index 91a2a0d3..00000000 --- a/docs/legal/README +++ /dev/null @@ -1,10 +0,0 @@ -Around 20 Jule 2016 year was discovered issue, that while all code is -GPLv3+ licensed, type documentation is GPLv3 only. As such -contributors was emailed to ask them permission to relicense to -GPLv3+. - -This directory contains emails, containing permission with all -headers. Not sure about legal significance, since email is so easy to -forge, but it is best option availiable. - - -- Dmitry Bogatov Wed, 20 Jul 2016 18:25:27 +0300 diff --git a/docs/legal/Ricardo_Catalinas.email b/docs/legal/Ricardo_Catalinas.email deleted file mode 100644 index 306ec073..00000000 --- a/docs/legal/Ricardo_Catalinas.email +++ /dev/null @@ -1,183 +0,0 @@ -From kaction Wed Jul 20 18:15:05 2016 -Return-path: -Envelope-to: KAction@gnu.org -Delivery-date: Wed, 20 Jul 2016 11:13:48 -0400 -Received: from fencepost.gnu.org [208.118.235.10] - by searing with POP3 (fetchmail-6.3.26) - for (single-drop); Wed, 20 Jul 2016 18:15:05 +0300 (MSK) -Received: from eggs.gnu.org ([2001:4830:134:3::10]:33032) - by fencepost.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) - (Exim 4.82) - (envelope-from ) - id 1bPtBz-0007Ty-T1 - for KAction@gnu.org; Wed, 20 Jul 2016 11:13:48 -0400 -Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) - (envelope-from ) - id 1bPtBx-0005MG-9h - for KAction@gnu.org; Wed, 20 Jul 2016 11:13:46 -0400 -X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org -X-Spam-Level: -X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,FREEMAIL_FROM, - HTML_MESSAGE,T_DKIM_INVALID autolearn=disabled version=3.3.2 -Received: from mail-wm0-x22f.google.com ([2a00:1450:400c:c09::22f]:36812) - by eggs.gnu.org with esmtp (Exim 4.71) - (envelope-from ) - id 1bPtBw-0005Lt-Ul - for KAction@gnu.org; Wed, 20 Jul 2016 11:13:45 -0400 -Received: by mail-wm0-x22f.google.com with SMTP id q128so60444546wma.1 - for ; Wed, 20 Jul 2016 08:13:44 -0700 (PDT) -DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; - d=gmail.com; s=20120113; - h=mime-version:in-reply-to:references:date:message-id:subject:from:to; - bh=YrPuTGXNLw9oFiHKKS+IheiScrs5DuAEvUTlakl0Mxg=; - b=WyUhnGVNalPpcJVnkHrFy1wNBjA/S7fZujrzehx9NGmJFOnawS4GJeatEZ4Pdj3hcq - sBzndUsU57BoYVn99QGM5eELbngARMKyU81V3sobYs5oeP6tFdKxnDpedgS6+yTKXLjP - ZH/tJiINIpXhjSxJkqw8q/dV5SKz6do840Roj1234XUKinRnUPX+zJt3Kjy2M+/dDfL8 - wp5u9xTIS1c9cA3xYN/rdrsIjbRkgo01Yh1wVaZBYpaWFybX09uOSo4fXFGZ6rKQl8iJ - 3M+S3+wQxaP2PZzj9z0eV/GVNM5+5lVcmUjI/PAqIq6nS6mOawolTB078FMFD9cvDRtS - KiNg== -X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; - d=1e100.net; s=20130820; - h=x-gm-message-state:mime-version:in-reply-to:references:date - :message-id:subject:from:to; - bh=YrPuTGXNLw9oFiHKKS+IheiScrs5DuAEvUTlakl0Mxg=; - b=EwpgAswQ/18QAMRKkz00dKKmXL7loG/R2ZX6KjvFCsBb0x8sV90eWI+17vBF+GVS1y - k6pXyyfLBFgeFBlgjN8oqaSqHhKNoOzWLNKHpOwAW+WnJ/SyprpxdU1BHz2ZOMDTOJuP - 9NTW8LoB4fU24ns1Yor6ykRMeBGQZDvTT3Zi4JsU48522W1WRXXH/Y4sJRm/hdlSaU18 - 1UN7ySE0Oey6Ufk+yG7M6EwJvY7ZI+zRlPsoknGwofg8H6VH7mKBcDvHc71Wk5tGOVMN - iJeKjmgmReG38Em5C+uGO0h9zjsIYZsYC8dUyRCkfNLD66pRdpFuRFIWhG/PU1aH9hIo - Wlng== -X-Gm-Message-State: ALyK8tLwjExHqmfFbrI69OlGTEDrsSCXwwBlBtD3gfpXU42hI/M5850STADANQROCfznBfKvk/zO9N4+82n/hA== -MIME-Version: 1.0 -X-Received: by 10.194.209.163 with SMTP id mn3mr1847437wjc.45.1469027623430; - Wed, 20 Jul 2016 08:13:43 -0700 (PDT) -Received: by 10.194.228.10 with HTTP; Wed, 20 Jul 2016 08:13:43 -0700 (PDT) -Received: by 10.194.228.10 with HTTP; Wed, 20 Jul 2016 08:13:43 -0700 (PDT) -In-Reply-To: -References: -Date: Wed, 20 Jul 2016 16:13:43 +0100 -Message-ID: -Subject: Re: cdist contribution relicensing -From: =?UTF-8?Q?Ricardo_Catalinas_Jim=C3=A9nez?= -To: Dmitry Bogatov -Content-Type: multipart/alternative; boundary=047d7b3a8d24a8fb78053812a524 -X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] -X-Received-From: 2a00:1450:400c:c09::22f -X-UIDL: H8X!!VF3!!(#b"!\C)!! - ---047d7b3a8d24a8fb78053812a524 -Content-Type: text/plain; charset=UTF-8 - - I, Ricardo Catalinas permit to relicense all my -contribution to - cdist project, source codehttps://github.com/ungleich/cdist - to GNU General Public license, version 3 or (at your option) - any later version, as published by Free Software Foundation. - - 20th Jule 2016 year - -/Ricardo - -On Jul 20, 2016 4:11 PM, "Dmitry Bogatov" wrote: - -> -> Hello, dear contributors of cdist project! -> -> Recently we discovered licensing issue with your contribution. Namely, -> while most of code is GPLv3+, including some of code written by you, -> manpages (man.txt, now man.rst) are GPLv3 only licensed. -> -> On behalf of cdist releasers (Darko and Nico), I (another cdist -> contributor and cdist Debian maintainer) ask you to permit relicense -> your contribution from GPLv3 to GPLv3+. Without your permission, we -> would be stuck the day when GPLv4 come (hope it will never come, but -> still), or have to reimplement your contribution. -> -> If you agree, please respond with something like -> -> I, #name# <#email#> permit to relicense all my contribution to -> cdist project, source code https://github.com/ungleich/cdist -> to GNU General Public license, version 3 or (at your option) -> any later version, as published by Free Software Foundation. -> -> #day# Jule 2016 year. -> -> If possible, GPG-sign such email. Do not include anything else -> valuable in this email that you do not want to be stored forever in -> public. -> -> Dear contributors, when replying to this email, please do not send -> copy to other contributors -- save their inbox storage. -> -> Thank you in advance for one more contribution. -> -> -- -> Accept: text/plain, text/x-diff -> Accept-Language: eo,en,ru -> X-Web-Site: sinsekvu.github.io -> - ---047d7b3a8d24a8fb78053812a524 -Content-Type: text/html; charset=UTF-8 -Content-Transfer-Encoding: quoted-printable - -

=C2=A0 I, Ricardo Catalinas <jimenezrick@gmail.com> permit to relicense all my contr= -ibution to
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 cdist project, source codehttps://github.com/ungleich/cdist
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 to GNU General Public license, version 3 or (at= - your option)
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 any later version, as published by Free Softwar= -e Foundation.

-

=C2=A0 =C2=A0 =C2=A0 =C2=A0 20th Jule 2016 year

-

/Ricardo

-

On Jul 20, 2016 4= -:11 PM, "Dmitry Bogatov" <K= -Action@gnu.org> wrote:

-Hello, dear contributors of cdist project!
-
-Recently we discovered licensing issue with your contribution. Namely,
-while most of code is GPLv3+, including some of code written by you,
-manpages (man.txt, now man.rst) are GPLv3 only licensed.
-
-On behalf of cdist releasers (Darko and Nico), I (another cdist
-contributor and cdist Debian maintainer) ask you to permit relicense
-your contribution from GPLv3 to GPLv3+. Without your permission, we
-would be stuck the day when GPLv4 come (hope it will never come, but
-still), or have to reimplement your contribution.
-
-If you agree, please respond with something like
-
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 I, #name# <#email#> permit to relicense a= -ll my contribution to
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 cdist project, source code https://gith= -ub.com/ungleich/cdist
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 to GNU General Public license, version 3 or (at= - your option)
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 any later version, as published by Free Softwar= -e Foundation.
-
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 #day# Jule 2016 year.
-
-If possible, GPG-sign such email. Do not include anything else
-valuable in this email that you do not want to be stored forever in
-public.
-
-Dear contributors, when replying to this email, please do not send
-copy to other contributors -- save their inbox storage.
-
-Thank you in advance for one more contribution.
-
---
-Accept: text/plain, text/x-diff
-Accept-Language: eo,en,ru
-X-Web-Site: sinsekvu.github.io
-
- ---047d7b3a8d24a8fb78053812a524-- - diff --git a/docs/legal/Steven_Armstrong.email b/docs/legal/Steven_Armstrong.email deleted file mode 100644 index 02951a32..00000000 --- a/docs/legal/Steven_Armstrong.email +++ /dev/null @@ -1,57 +0,0 @@ -From kaction Thu Jul 21 00:55:04 2016 -Return-path: -Envelope-to: KAction@gnu.org -Delivery-date: Wed, 20 Jul 2016 17:51:39 -0400 -Received: from fencepost.gnu.org [208.118.235.10] - by searing with POP3 (fetchmail-6.3.26) - for (single-drop); Thu, 21 Jul 2016 00:55:04 +0300 (MSK) -Received: from eggs.gnu.org ([2001:4830:134:3::10]:42614) - by fencepost.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) - (Exim 4.82) - (envelope-from ) - id 1bPzP1-0005f6-89 - for KAction@gnu.org; Wed, 20 Jul 2016 17:51:39 -0400 -Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) - (envelope-from ) - id 1bPzOx-00032C-RS - for KAction@gnu.org; Wed, 20 Jul 2016 17:51:38 -0400 -X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org -X-Spam-Level: -X-Spam-Status: No, score=-0.5 required=5.0 tests=BAYES_50,RP_MATCHES_RCVD - autolearn=disabled version=3.3.2 -Received: from wolke.armstrong.cc ([136.243.209.126]:37928) - by eggs.gnu.org with esmtp (Exim 4.71) - (envelope-from ) - id 1bPzOx-00031o-L9 - for KAction@gnu.org; Wed, 20 Jul 2016 17:51:35 -0400 -Sender: steven@armstrong.cc -Subject: Re: cdist contribution relicensing -To: Dmitry Bogatov -References: -From: Steven Armstrong -Message-ID: -Date: Wed, 20 Jul 2016 23:51:28 +0200 -MIME-Version: 1.0 -In-Reply-To: -Content-Type: text/plain; charset=windows-1252; format=flowed -Content-Transfer-Encoding: 7bit -X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] -X-Received-From: 136.243.209.126 -X-UIDL: b-6"!eP*"!*!D"!c+f!! - -Dmitry Bogatov wrote on 07/20/16 17:09: -> I, #name# <#email#> permit to relicense all my contribution to -> cdist project, source code https://github.com/ungleich/cdist -> to GNU General Public license, version 3 or (at your option) -> any later version, as published by Free Software Foundation. -> -> #day# Jule 2016 year. - -I, Steven Armstrong , permit to re-license -all my contribution to the cdist project source code -https://github.com/ungleich/cdist to GNU General Public license, version -3 or (at your option) any later version, as published by Free Software -Foundation. - -20 July 2016 - diff --git a/docs/legal/Thomas_Oettli.email b/docs/legal/Thomas_Oettli.email deleted file mode 100644 index eb515a59..00000000 --- a/docs/legal/Thomas_Oettli.email +++ /dev/null @@ -1,342 +0,0 @@ -From kaction Tue Aug 2 13:59:41 2016 -Return-path: -Envelope-to: KAction@gnu.org -Delivery-date: Tue, 02 Aug 2016 05:50:23 -0400 -Received: from fencepost.gnu.org [208.118.235.10] - by searing with POP3 (fetchmail-6.3.26) - for (single-drop); Tue, 02 Aug 2016 13:59:41 +0300 (MSK) -Received: from eggs.gnu.org ([2001:4830:134:3::10]:41424) - by fencepost.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) - (Exim 4.82) - (envelope-from ) - id 1bUWL9-0006S9-Ft - for KAction@gnu.org; Tue, 02 Aug 2016 05:50:23 -0400 -Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) - (envelope-from ) - id 1bUWL1-0007oE-Eo - for KAction@gnu.org; Tue, 02 Aug 2016 05:50:21 -0400 -X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org -X-Spam-Level: -X-Spam-Status: No, score=0.9 required=5.0 tests=BAYES_50,HTML_MESSAGE, - RCVD_IN_DNSWL_NONE,TVD_FW_GRAPHIC_NAME_MID autolearn=disabled version=3.3.2 -Received: from mail2.sfsservices.biz ([194.93.112.42]:43385) - by eggs.gnu.org with esmtp (Exim 4.71) - (envelope-from ) - id 1bUWKe-0007eL-5Z - for KAction@gnu.org; Tue, 02 Aug 2016 05:50:15 -0400 -X-Received: from localhost (localhost [127.0.0.1]) - by mail2.sfsservices.biz (Postfix) with ESMTP id B80B68BEA15B - for ; Tue, 2 Aug 2016 11:49:19 +0200 (CEST) -X-Virus-Scanned: amavisd-new at sfsservices.biz -X-Received: from mail2.sfsservices.biz ([127.0.0.1]) - by localhost (mail2.sfsservices.biz [127.0.0.1]) (amavisd-new, port 10023) - with ESMTP id Kq9SpRTVO-tm for ; - Tue, 2 Aug 2016 11:49:19 +0200 (CEST) -X-Received: from chsfsd15.sfs-intra.net (chsfsln0002.sfs-intra.net [INTERNAL-IP]) - by mail2.sfsservices.biz (Postfix) with ESMTP - for ; Tue, 2 Aug 2016 11:49:19 +0200 (CEST) -In-Reply-To: -References: -Subject: Antwort: cdist contribution relicensing -X-KeepSent: A672E59F:C63BD8B2-C1258003:0035E697; - type=4; name=$KeepSent -To: Dmitry Bogatov -X-Mailer: IBM Notes Release 9.0.1 October 14, 2013 -Message-ID: -From: Thomas Oettli -Date: Tue, 2 Aug 2016 11:49:18 +0200 -X-MIMETrack: Serialize by Router on chsfsd15/SFS(Release 9.0.1FP6|April 20, 2016) at - 02.08.2016 11:49:19 -MIME-Version: 1.0 -Content-type: multipart/related; - Boundary="0__=4EBB0A90DFA660078f9e8a93df938690918c4EBB0A90DFA66007" -X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] -X-Received-From: 194.93.112.42 -X-UIDL: Jb%#!^\~!!pT3"!DD="! - ---0__=4EBB0A90DFA660078f9e8a93df938690918c4EBB0A90DFA66007 -Content-type: multipart/alternative; - Boundary="1__=4EBB0A90DFA660078f9e8a93df938690918c4EBB0A90DFA66007" - ---1__=4EBB0A90DFA660078f9e8a93df938690918c4EBB0A90DFA66007 -Content-type: text/plain; charset=UTF-8 -Content-transfer-encoding: quoted-printable - - -I, Thomas Oettli permit to relicense all my contribution= - to -cdist project, source code https://github.com/ungleich/cdist -to GNU General Public license, version 3 or (at your option) -any later version, as published by Free Software Foundation. - - - -Thomas Oettli -Systemengineer SAP & Linux - -SFS services AG, Corporate IT -Rosenbergsaustrasse 8, CH-9435 Heerbrugg -T +41 71 72 75269 F +41 71 72 75237 -thomas.oettli@sfs.biz www.sfs.biz - - - -Denken Sie an die Umwelt bevor Sie drucken. - Please consider your -environment before printing. - - - - -Von: Dmitry Bogatov -An: Andi Br=C3=B6nnimann , Benedikt Koeppel - , Chase Allen James - , Christian G. Warden , - Daniel Heule , Daniel Maher , Dominique Roux , - Evax Software , Giel van Schijndel , Jake Guffey , J= -ake - Guffey , Nico Schottelius - , Ramon Salvad=C3=B3 - , Ricardo Catalinas Jim=C3=A9nez - , Steven Armstrong - , Thomas Oettli -Kopie: Darko Poljak , Nico Schottelius - -Datum: 20.07.2016 17:11 -Betreff: cdist contribution relicensing - - - - -Hello, dear contributors of cdist project! - -Recently we discovered licensing issue with your contribution. Namely, -while most of code is GPLv3+, including some of code written by you, -manpages (man.txt, now man.rst) are GPLv3 only licensed. - -On behalf of cdist releasers (Darko and Nico), I (another cdist -contributor and cdist Debian maintainer) ask you to permit relicense -your contribution from GPLv3 to GPLv3+. Without your permission, we -would be stuck the day when GPLv4 come (hope it will never come, but -still), or have to reimplement your contribution. - -If you agree, please respond with something like - - I, #name# <#email#> permit to relicense all my contribution to - cdist project, source code https://github.com/ungleich/cdist - to GNU General Public license, version 3 or (at your option) - any later version, as published by Free Software Foundation. - - #day# Jule 2016 year. - -If possible, GPG-sign such email. Do not include anything else -valuable in this email that you do not want to be stored forever in -public. - -Dear contributors, when replying to this email, please do not send -copy to other contributors -- save their inbox storage. - -Thank you in advance for one more contribution. - --- -Accept: text/plain, text/x-diff -Accept-Language: eo,en,ru -X-Web-Site: sinsekvu.github.io -[Anhang "attsga4c.dat" gel=C3=B6scht von Thomas Oettli/otho/SFS]= - ---1__=4EBB0A90DFA660078f9e8a93df938690918c4EBB0A90DFA66007 -Content-type: text/html; charset=UTF-8 -Content-Disposition: inline -Content-transfer-encoding: quoted-printable - - -

I, Thomas Oettli <otho@sfs.biz> permit to= - relicense all my contribution to
-cdist project, source code
https://github.com/ungleich/cdist
-to GNU General Public license, version 3 or (at your option)
-any later version, as published by Free Software Foundation.

-
-
-
-Thomas Oettli
-Systemengineer SAP & Linux

-
-SFS services AG, Corporate IT
-Rosenbergsaustrasse 8, CH-9435 Heerbrugg
-T +41 71 72 75269   F +41 71 72 75237  

-
thomas.oettli@sfs.biz      www.sfs.biz
-
-
-
-3D"Denken
-
-
-3D"InactiveDmitry Bogatov ---20.07.2016 17:11:48---Hello, dear contribu= -tors of cdist project! Recently we discovered licensing issue with your= - contribu
-
-Von: Dmitry Bogatov <KAction@gnu.org>= -
-An: Andi Br=C3=B6nnimann <andi-cdist@v-n= -et.ch>, Benedikt Koeppel <code@benediktkoeppel.ch>, Chase Alle= -n James <nx-cdist@nu-ex.com>, Christian G. Warden <cwarden@xer= -us.org>, Daniel Heule <hda@sfs.biz>, Daniel Maher <phrawzty= -+cdist@gmail.com>, Dominique Roux <dominique.roux4@gmail.com>,= - Evax Software <contact@evax.fr>, Giel van Schijndel <giel+cdi= -st@mortis.eu>, Jake Guffey <jake.guffey@eprotex.com>, Jake Guf= -fey <jake.guffey@jointheirstm.org>, Nico Schottelius <nico-cdi= -st@schottelius.org>, Ramon Salvad=C3=B3 <rsalvado@gnuine.com>,= - Ricardo Catalinas Jim=C3=A9nez <jimenezrick@gmail.com>, Steven A= -rmstrong <steven-cdist@armstrong.cc>, Thomas Oettli <otho@sfs.= -biz>
-Kopie: Darko Poljak <darko.poljak@gmail.= -com>, Nico Schottelius <nico.schottelius@ungleich.ch> -Datum: 20.07.2016 17:11
-Betreff: = -cdist contribution relicensing
-



-
-
-
-Hello, dear contributors of cdist project!
-
-Recently we discovered licensing issue with your contribution. Namely,<= -br> -while most of code is GPLv3+, including some of code written by you, -manpages (man.txt, now man.rst) are GPLv3 only licensed.
-
-On behalf of cdist releasers (Darko and Nico), I (another cdist
-contributor and cdist Debian maintainer) ask you to permit relicense -your contribution from GPLv3 to GPLv3+. Without your permission, we
= - -would be stuck the day when GPLv4 come (hope it will never come, but -still), or have to reimplement your contribution.
-
-If you agree, please respond with something like
-
- I, #name# <#email#> permit to relicense all my contribution to= -
- cdist project, source code
https://github.com/ungleich/cdist
- to GNU General Public license, version 3 or (at your option)
- any later version, as published by Free Software Foundation.
-
-        #day# Jule 2016 year.
-
-If possible, GPG-sign such email. Do not include anything else
-valuable in this email that you do not want to be stored forever in
= - -public.
-
-Dear contributors, when replying to this email, please do not send
-copy to other contributors -- save their inbox storage.
-
-Thank you in advance for one more contribution.
-
---
-Accept: text/plain, text/x-diff
-Accept-Language: eo,en,ru
-X-Web-Site: sinsekvu.github.io
-[Anhang "attsga4c.dat" gel=C3=B6scht von Thomas Oettli/otho/S= -FS]

-= - - ---1__=4EBB0A90DFA660078f9e8a93df938690918c4EBB0A90DFA66007-- - - ---0__=4EBB0A90DFA660078f9e8a93df938690918c4EBB0A90DFA66007 -Content-type: image/gif; - name="16993833.gif" -Content-Disposition: inline; filename="16993833.gif" -Content-ID: <1__=4EBB0A90DFA660078f9e8a93df@sfs-intra.net> -Content-transfer-encoding: base64 - -R0lGODlhVgAqAOUAAPA4IP////AwGPAoEPi4sPBIMPAwEPCAcPiYkPA4GPBwYPjAuPCQgPiooOgg -CPBYSOggAPBAKPAoCPBQOPCIePCIgPiYiPjQyPB4aPigkOgYAPBoWOgoCPBgSPBgUPBoUPCYiPjw -8PBYQPCYkPigmPjAsPjIwPjg2Pjo4Pjw6OgoEPAgCPBIOPjY0PjY2Pjg4PBQQPB4YPCAePCQiPio -mPiwqPjo6PAgAPBAMPBwWPCAaPiQiPiwoPjIyPjQ0Pj48CwAAAAAVgAqAEAI/wADCBTogwIMAAgT -KlwIIAKDgRApTChAsaLFixU9uIAIEYUFDxhDVpyQQWABhgAEbJjBoKXLly4RhIC4YADDBB1kHNjJ -s+fOGhBRpnzgsyhPCicGpoAgtClDBy8E1nRKFSGHgSiYVnUKwQYCm1udCjggFaxCAyU5qlWLgENY -sRTWyp1Lt67du3gHOhDwtq/fv2EFqBA4gS9ghQ7KHk6YWOADw4sRehAqoLLlywIMDJAgQ+0CFSgT -WDaQOTNpA6htDpxAGfVo05k5DNiRV+4ByAklKF5ooEHt3xAx4E54e3ECCCY4amAIoQXwDcP9aiAg -8EOCyNizbxVgQeAFrYcFKP8Y6DZyAYgn9i42QAFE9L8rfAeYuh6DQAbv/UogIZQF8IH0nUUDcBKg -NMF/LjiAnW4AmnUYgxesEFkCA6i1AQQDYKbhewnAsBtDG2poAAc/cBTCAxCQFmJl16H0gUAnZACC -BSOMQKMFCOCIwIwIYOBgQgZ8CCQJ/wUQQg0NJKnkkkrywMCPCEWgXUMNMoQWgVMOBEIHD3TpJZcP -dAAmmBuAEJVcFyjAQgEfUFdkABKJJJIIFFygFgEODKDnnnz26eefgAYq6KCE6nkDdSdNqeiiKZEl -kA04cJCfU6RB9N2kTiWggZ0ciaCeX6oZCd5iFQbQA2iRNSaQgthF8AKrrQr/CViQAaAAa2QsWIfS -iiJqEJesCfFq2QARDCRCiwuJJqxlEIwn1IFFBgikfLUVyNB5wCW6kEoMVODtt95SYEFya0mLkAA5 -kIDAuuy2m6ObAr1nAAYZuNtuA85xhN96A6RAE5R9qSRQcYdVOlAByAImwANVRrbCQFJGJoAHA7Xw -qcIVABswxQOZAAGmVAkwwp0MGMWTj7tqLEIMCrTs8sstzzBXCDQcADPMHxiAEra/QccQg+YCYACR -b+YVw3sBeJBiZafx+iywVwKHAYaoVW311fk9wFp2DnAadNS1RbzgBWIvBgEKAxEAJdh56YydBhsF -IECGCdRttwCi2a13Zg5MUOAvRwh8fK4D4/03gNtvieZABEkV7fjjRZtAwOSUV2755SVcrjnmmxOQ -eeecb77AQBcsx+jpkWmQQtmotx4wBsK5LvtbA8inA+uz555Q4QEBADs= - ---0__=4EBB0A90DFA660078f9e8a93df938690918c4EBB0A90DFA66007 -Content-type: image/gif; - name="16816884.gif" -Content-Disposition: inline; filename="16816884.gif" -Content-ID: <2__=4EBB0A90DFA660078f9e8a93df@sfs-intra.net> -Content-transfer-encoding: base64 - -R0lGODlhNgEiAOQAAP///wCAAACIAJiIAACImACguOj4+Pj40HDI6PjgmND4+Pj46ACIcLigALjw -+OjIcAC40NC4APjw0NDw+HCIAJigAJjg+LjI0LjI6NDIuOjIuOj40PjwuAAAAAAAAAAAACwAAAAA -NgEiAEAI/wABCBxIsKDBgwgTKlzIsKHDhxAjSpxIsaLFixgzClzQQIDHjx4LGFAYoGBJACdRCgxw -suXKlzBZwhyYkqDLmTNb3qS58mbKmipt9hyq8idPo0GBykx6tGlMpQd3QkWpM2fMq0GT7tQo8YFH -BFzDih1LtqzZs2gRDgDJtq0ABg4SJvBIwCTLpUxxYhWqd2revzyzStVb1KpgwkgT50X6d/Bex34h -G2YceXJgn5cDp93MubPnz6BDP5zL1oLo06hTq15d0avbryT5Hp6N+bFJvo4v57Y8WzZlzb+xKq3d -W/HtzL150xauHOjFtWAFSqjwunrbujbvMmYd1aBz7rJB+/9diFfs970R11r3CHchaQHYNfsuL/Mn -/fI0a94Fnp/y/p7byfcfgFv1x59yVAUXXIIH0kdVdv5tN+BRCurWWH6ATRQBBOB16OGHIKJ1gHoh -jUReeA2d55B+aano3XFcFeiiRSxKNCNCN6YmwQQAjAgSAQoAsGNCU2kHGV5GGobjUxMSqCRvSaKY -m0slVUkgcZNp95JksWnVpHHLQdjfUgGKSOJ6QIao5ppsonbmRwVs8OZ6P7Zp5514hjXnW3E15GOd -4Ul1n36DRkWoUYXmZCWATtGGZGbDIToYlYxuKSlRlRalE4uJ/jfgok1q2hSVmzJ1X1YD7VldmgiR -Fh9hGSb/hx6Mzb14IaqI3QqmfJYRB+aUuc66q22y+lbrYsjhCoCqIjnk2kev5mmetNQqG2Oo1War -7bbc/ckqt+CGK65BC1zgrQIZmEiklhHlSNKnZhXYHYoYyRgvvA+5S2uIHLXVbJfAPfookxTa+hh+ -mVb5XX2KOlfkgxArKLCDneqGaKANG2pqcRJfClq/1f07b7KSVYgYvmWSDKOv+wJbGKjIVbYcl3YN -HOCvyW7ZIK+dvQdSewDPGqa8N+MG67E7W9uXkpTCfJzMDutqMLJLEpshlk9uBrJ1HOLIroHH4qvs -1/Yt7PTYnoLtnYNMC2gzp4cGOnDNERpKJoT2NTi3vGRp1hAkQa5FN9ABGIxr+OHVBo744oyntta/ -W9P5WrSNV245Rup1rdCfaNLKN5v6Xj7y0ft2FvpBqrol+EHvRVsjzbA/nSWxPh1pLM4Q663z7nc/ -5XvEs1/Nsq67AW9877UL51zqr61eEAcUwFe6l0h+Wv2XKzNts8W9CxU72mlfNbzUWYZ/NffDl40f -7sZ9TxDzbIl8UAR0Tc9l98WnrzL5sRaHINK44x/7cna8mO0PV8jbn/5yl6r1yK9VgBLdiSR4mtNR -ZHk/65ND6HcdCnrwgyAMoQhDExAAOw== - ---0__=4EBB0A90DFA660078f9e8a93df938690918c4EBB0A90DFA66007 -Content-type: image/gif; - name="graycol.gif" -Content-Disposition: inline; filename="graycol.gif" -Content-ID: <3__=4EBB0A90DFA660078f9e8a93df@sfs-intra.net> -Content-transfer-encoding: base64 - -R0lGODlhEAAQAKECAMzMzAAAAP///wAAACH5BAEAAAIALAAAAAAQABAAAAIXlI+py+0PopwxUbpu -ZRfKZ2zgSJbmSRYAIf4fT3B0aW1pemVkIGJ5IFVsZWFkIFNtYXJ0U2F2ZXIhAAA7 - ---0__=4EBB0A90DFA660078f9e8a93df938690918c4EBB0A90DFA66007-- - - diff --git a/docs/man/cdist-reference.text.sh b/docs/man/cdist-reference.text.sh new file mode 100755 index 00000000..7081e762 --- /dev/null +++ b/docs/man/cdist-reference.text.sh @@ -0,0 +1,261 @@ +#!/bin/sh +# +# 2010-2014 Nico Schottelius (nico-cdist at schottelius.org) +# 2014 Daniel Heule (hda at sfs.biz) +# +# This file is part of cdist. +# +# cdist is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# cdist is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with cdist. If not, see . +# +# +# Generate manpage that lists available types +# + +__cdist_pwd="$(pwd -P)" +__cdist_mydir="${0%/*}"; +__cdist_abs_mydir="$(cd "$__cdist_mydir" && pwd -P)" +__cdist_myname=${0##*/}; +__cdist_abs_myname="$__cdist_abs_mydir/$__cdist_myname" + +filename="${__cdist_myname%.sh}" +dest="$__cdist_abs_mydir/man7/$filename" + +cd "$__cdist_abs_mydir" + +exec > "$dest" +cat << eof +cdist-reference(7) +================== +Nico Schottelius + +NAME +---- +cdist-reference - Variable, path and type reference for cdist + + +EXPLORERS +--------- +The following global explorers are available: + +eof +( + cd ../../cdist/conf/explorer + for explorer in *; do + echo "- $explorer" + done +) + +cat << eof + +PATHS +----- +\$HOME/.cdist:: + The standard cdist configuration directory relative to your home directory + This is usually the place you want to store your site specific configuration + +cdist/conf/:: + The distribution configuration directory + This contains types and explorers to be used + +confdir:: + Cdist will use all available configuration directories and create + a temporary confdir containing links to the real configuration directories. + This way it is possible to merge configuration directories. + By default it consists of everything in \$HOME/.cdist and cdist/conf/. + For more details see cdist(1) + +confdir/manifest/init:: + This is the central entry point. + It is an executable (+x bit set) shell script that can use + values from the explorers to decide which configuration to create + for the specified target host. + Its intent is to used to define mapping from configurations to hosts. + +confdir/manifest/*:: + All other files in this directory are not directly used by cdist, but you + can seperate configuration mappings, if you have a lot of code in the + conf/manifest/init file. This may also be helpful to have different admins + maintain different groups of hosts. + +confdir/explorer/:: + Contains explorers to be run on the target hosts, see cdist-explorer(7). + +confdir/type/:: + Contains all available types, which are used to provide + some kind of functionality. See cdist-type(7). + +confdir/type//:: + Home of the type . + This directory is referenced by the variable __type (see below). + +confdir/type//man.text:: + Manpage in Asciidoc format (required for inclusion into upstream) + +confdir/type//manifest:: + Used to generate additional objects from a type. + +confdir/type//gencode-local:: + Used to generate code to be executed on the source host + +confdir/type//gencode-remote:: + Used to generate code to be executed on the target host + +confdir/type//parameter/required:: + Parameters required by type, \n seperated list. + +confdir/type//parameter/optional:: + Parameters optionally accepted by type, \n seperated list. + +confdir/type//parameter/default/*:: + Default values for optional parameters. + Assuming an optional parameter name of 'foo', it's default value would + be read from the file confdir/type//parameter/default/foo. + +confdir/type//parameter/boolean:: + Boolean parameters accepted by type, \n seperated list. + +confdir/type//explorer:: + Location of the type specific explorers. + This directory is referenced by the variable __type_explorer (see below). + See cdist-explorer(7). + +confdir/type//files:: + This directory is reserved for user data and will not be used + by cdist at any time. It can be used for storing supplementary + files (like scripts to act as a template or configuration files). + +out/:: + This directory contains output of cdist and is usually located + in a temporary directory and thus will be removed after the run. + This directory is referenced by the variable __global (see below). + +out/explorer:: + Output of general explorers. + +out/object:: + Objects created for the host. + +out/object/:: + Contains all object specific information. + This directory is referenced by the variable __object (see below). + +out/object//explorers:: + Output of type specific explorers, per object. + +TYPES +----- +The following types are available: + +eof + +for type in man7/cdist-type__*.text; do + no_dir="${type#man7/}"; + no_type="${no_dir#cdist-type}"; + name="${no_type%.text}"; + name_no_underline="$(echo $name | sed 's/^__/\\__/g')" + man="${no_dir%.text}(7)" + + echo "- $name_no_underline" "($man)" +done + +cat << eof + + +OBJECTS +------- +For object to object communication and tests, the following paths are +usable within a object directory: + +files:: + This directory is reserved for user data and will not be used + by cdist at any time. It can be used freely by the type + (for instance to store template results). +changed:: + This empty file exists in an object directory, if the object has + code to be excuted (either remote or local) +stdin:: + This file exists and contains data, if data was provided on stdin + when the type was called. + + +ENVIRONMENT VARIABLES (FOR READING) +----------------------------------- +The following environment variables are exported by cdist: + +__explorer:: + Directory that contains all global explorers. + Available for: initial manifest, explorer, type explorer, shell +__manifest:: + Directory that contains the initial manifest. + Available for: initial manifest, type manifest, shell +__global:: + Directory that contains generic output like explorer. + Available for: initial manifest, type manifest, type gencode, shell +__messages_in:: + File to read messages from + Available for: initial manifest, type manifest, type gencode +__messages_out:: + File to write messages + Available for: initial manifest, type manifest, type gencode +__object:: + Directory that contains the current object. + Available for: type manifest, type explorer, type gencode and code scripts +__object_id:: + The type unique object id. + Available for: type manifest, type explorer, type gencode and code scripts + Note: The leading and the trailing "/" will always be stripped (caused by + the filesystem database and ensured by the core). + Note: Double slashes ("//") will not be fixed and result in an error. +__object_name:: + The full qualified name of the current object. + Available for: type manifest, type explorer, type gencode +__target_host:: + The host we are deploying to. + Available for: explorer, initial manifest, type explorer, type manifest, type gencode, shell +__type:: + Path to the current type. + Available for: type manifest, type gencode +__type_explorer:: + Directory that contains the type explorers. + Available for: type explorer + +ENVIRONMENT VARIABLES (FOR WRITING) +----------------------------------- +The following environment variables influence the behaviour of cdist: + +require:: + Setup dependencies between objects (see cdist-manifest(7)) + +CDIST_LOCAL_SHELL:: + Use this shell locally instead of /bin/sh to execute scripts + +CDIST_REMOTE_SHELL:: + Use this shell remotely instead of /bin/sh to execute scripts + +CDIST_OVERRIDE:: + Allow overwriting type parameters (see cdist-manifest(7)) + +CDIST_ORDER_DEPENDENCY:: + Create dependencies based on the execution order (see cdist-manifest(7)) + +SEE ALSO +-------- +- cdist(1) + + +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/man1/cdist.text b/docs/man/man1/cdist.text new file mode 100644 index 00000000..c09d8f41 --- /dev/null +++ b/docs/man/man1/cdist.text @@ -0,0 +1,161 @@ +cdist(1) +======== +Nico Schottelius + + +NAME +---- +cdist - Usable Configuration Management + + +SYNOPSIS +-------- +cdist [-h] [-d] [-v] [-V] {banner,config,shell} ... + +cdist banner [-h] [-d] [-v] + +cdist config [-h] [-d] [-V] [-c CONF_DIR] [-i MANIFEST] [-p] [-s] host [host ...] + +cdist shell [-h] [-d] [-v] [-s SHELL] + + +DESCRIPTION +----------- +cdist is the frontend executable to the cdist configuration management. +cdist supports different subcommands as explained below. + +GENERAL +------- +All commands accept the following options: + +-d, --debug:: + Set log level to debug + +-h, --help:: + Show the help screen + +-v, --verbose:: + Set log level to info, be more verbose + +-V, --version:: + Show version and exit + + +BANNER +------ +Displays the cdist banner. Useful for printing +cdist posters - a must have for every office. + + +CONFIG +------ +Configure one or more hosts + +-h, --help:: + Show the help screen + +-c CONF_DIR, --conf-dir CONF_DIR:: + Add a configuration directory. Can be specified multiple times. + If configuration directories contain conflicting types, explorers or + manifests, then the last one found is used. Additionally this can also + be configured by setting the CDIST_PATH environment variable to a colon + delimited list of config directories. Directories given with the + --conf-dir argument have higher precedence over those set through the + environment variable. + +-i MANIFEST, --initial-manifest MANIFEST:: + Path to a cdist manifest or - to read from stdin + +-p, --parallel:: + Operate on multiple hosts in parallel + +-s, --sequential:: + Operate on multiple hosts sequentially + +--remote-copy REMOTE_COPY:: + Command to use for remote copy (should behave like scp) + +--remote-exec REMOTE_EXEC:: + Command to use for remote execution (should behave like ssh) + +SHELL +----- +This command allows you to spawn a shell that enables access +to the types as commands. It can be thought as an +"interactive manifest" environment. See below for example +usage. Its primary use is for debugging type parameters. + +-s/--shell:: + Select shell to use, defaults to current shell + + +EXAMPLES +-------- + +-------------------------------------------------------------------------------- +# Configure ikq05.ethz.ch with debug enabled +% cdist config -d ikq05.ethz.ch + +# Configure hosts in parallel and use a different configuration directory +% cdist config -c ~/p/cdist-nutzung \ + -p ikq02.ethz.ch ikq03.ethz.ch ikq04.ethz.ch + +# Use custom remote exec / copy commands +% cdist config --remote-exec /path/to/my/remote/exec \ + --remote-copy /path/to/my/remote/copy \ + -p ikq02.ethz.ch ikq03.ethz.ch ikq04.ethz.ch + +# Display banner +cdist banner + +# Show help +% cdist --help + +# Show Version +% cdist --version + +# Enter a shell that has access to emulated types +% cdist shell +% __git +usage: __git --source SOURCE [--state STATE] [--branch BRANCH] + [--group GROUP] [--owner OWNER] [--mode MODE] object_id + + +-------------------------------------------------------------------------------- + + +ENVIRONMENT +----------- +TMPDIR, TEMP, TMP:: + Setup the base directory for the temporary directory. + See http://docs.python.org/py3k/library/tempfile.html for + more information. This is rather useful, if the standard + directory used does not allow executables. + +CDIST_LOCAL_SHELL:: + Selects shell for local script execution, defaults to /bin/sh + +CDIST_REMOTE_SHELL:: + Selects shell for remote scirpt execution, defaults to /bin/sh + + +EXIT STATUS +----------- +The following exit values shall be returned: + +0:: + Successful completion +1:: + One or more host configurations failed + + +SEE ALSO +-------- +- cdist(7) +- cdist-reference(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-best-practice.text b/docs/man/man7/cdist-best-practice.text new file mode 100644 index 00000000..a818be60 --- /dev/null +++ b/docs/man/man7/cdist-best-practice.text @@ -0,0 +1,247 @@ +cdist-best-practice(7) +====================== +Nico Schottelius + +NAME +---- +cdist-best-practice - Practices used in real environments + + +PASSWORDLESS CONNECTIONS +------------------------ +It is recommended to run cdist with public key authentication. +This requires a private/public key pair and the entry +"PermitRootLogin without-password" in the sshd server. +See sshd_config(5) and ssh-keygen(1). + + +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 +"sharing of multiple sessions over a single network connection" +(quote from ssh_config(5)). The following code is suitable for +inclusion into your ~/.ssh/config: + +-------------------------------------------------------------------------------- +Host * + ControlPath ~/.ssh/master-%l-%r@%h:%p + ControlMaster auto + ControlPersist 10 +-------------------------------------------------------------------------------- + +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: + +-------------------------------------------------------------------------------- +ln -sf /bin/dash /bin/sh +-------------------------------------------------------------------------------- + + +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 +control git. For instance if you plan to use the typical three +environments production, integration and development, you can +realise this with git branches: + +-------------------------------------------------------------------------------- +# Go to cdist checkout +cd /path/to/cdist + +# Create branches +git branch development +git branch integration +git branch production + +# Make use of a branch, for instance production +git checkout production +-------------------------------------------------------------------------------- + +Similar if you want to have cdist checked out at multiple machines, +you can clone it multiple times: + +-------------------------------------------------------------------------------- +machine-a % git clone git://your-git-server/cdist +machine-b % git clone git://your-git-server/cdist +-------------------------------------------------------------------------------- + +SEPERATING WORK BY GROUPS +------------------------- +If you are working with different groups on one cdist-configuration, +you can delegate to other manifests and have the groups edit only +their manifests. You can use the following snippet in +**conf/manifests/init**: + +-------------------------------------------------------------------------------- +# Include other groups +sh -e "$__manifest/systems" + +sh -e "$__manifest/cbrg" +-------------------------------------------------------------------------------- + + +MAINTAINING MULTIPLE CONFIGURATIONS +----------------------------------- +When you need to manage multiple sites with cdist, like company_a, company_b +and private for instance, you can easily use git for this purpose. +Including a possible common base that is reused accross the different sites: + +-------------------------------------------------------------------------------- +# create branches +git branch company_a company_b common private + +# make stuff for company a +git checkout company_a +# work, commit, etc. + +# make stuff for company b +git checkout company_b +# work, commit, etc. + +# make stuff relevant for all sites +git checkout common +# work, commit, etc. + +# change to private and include latest common stuff +git checkout private +git merge common +-------------------------------------------------------------------------------- + +The following **.git/config** is taken from a a real world scenario: +-------------------------------------------------------------------------------- +# Track upstream, merge from time to time +[remote "upstream"] + url = git://git.schottelius.org/cdist + fetch = +refs/heads/*:refs/remotes/upstream/* + +# Same as upstream, but works when being offline +[remote "local"] + fetch = +refs/heads/*:refs/remotes/local/* + url = /home/users/nico/p/cdist + +# Remote containing various ETH internal branches +[remote "eth"] + url = sans.ethz.ch:/home/services/sans/git/cdist-eth + fetch = +refs/heads/*:refs/remotes/eth/* + +# Public remote that contains my private changes to cdist upstream +[remote "nico"] + url = git.schottelius.org:/home/services/git/cdist-nico + fetch = +refs/heads/*:refs/remotes/nico/* + +# The "nico" branch will be synced with the remote nico, branch master +[branch "nico"] + remote = nico + merge = refs/heads/master + +# ETH stable contains rock solid configurations used in various places +[branch "eth-stable"] + remote = eth + merge = refs/heads/stable +-------------------------------------------------------------------------------- + +Have a look at git-remote(1) to adjust the remote configuration, which allows + + +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 +implement this scenario with a gateway host and sudo: + +- Create a dedicated user (for instance **cdist**) +- Setup the ssh-pubkey for this user that has the right to configure all hosts +- Create a wrapper to update the cdist configuration in ~cdist/cdist +- Allow every developer to execute this script via sudo as the user cdist +- Allow run of cdist as user cdist on specific hosts on a per user/group base + - f.i. nico ALL=(ALL) NOPASSWD: /home/cdist/bin/cdist config hostabc + +For more details consult sudoers(5) + +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 + +-------------------------------------------------------------------------------- +#!/bin/sh +# in the template, use cat << eof (here document) to output the text +# and use standard shell variables in the template +# output everything in the template script to stdout +cat << EOF +server { + listen 80; + server_name $SERVERNAME; + root $ROOT; + + access_log /var/log/nginx/$SERVERNAME_access.log + error_log /var/log/nginx/$SERVERNAME_error.log +} +EOF +-------------------------------------------------------------------------------- + +* in the manifest, export the relevant variables and add the following lines in your manifest: +-------------------------------------------------------------------------------- +# export variables needed for the template + export SERVERNAME='test" + export ROOT='/var/www/test' +# render the template + mkdir -p "$__object/files" + "$__type/files/basic.conf.sh" > "$__object/files/basic.conf" +# send the rendered template + __file /etc/nginx/sites-available/test.conf \ + --state present + --source "$__object/files/basic.conf" +-------------------------------------------------------------------------------- + + +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 +with - (stdin) as argument and feed object into stdin +of cdist: + +-------------------------------------------------------------------------------- +# Singleton type without parameter +echo __ungleich_munin_server | cdist --initial-manifest - munin.panter.ch + +# Singleton type with parameter +echo __ungleich_munin_node --allow 1.2.3.4 | \ + cdist --initial-manifest - rails-19.panter.ch + +# Normal type +echo __file /tmp/stdintest --mode 0644 | \ + cdist --initial-manifest - cdist-dev-01.ungleich.ch +-------------------------------------------------------------------------------- + + +OTHER CONTENT IN CDIST REPOSITORY +--------------------------------- +Usually the cdist repository contains all configuration +items. Sometimes you may have additional resources that +you would like to store in your central configuration +repositiory (like password files from KeepassX, +Libreoffice diagrams, etc.). + +It is recommended to use a subfolder named "non-cdist" +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) +- 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.text b/docs/man/man7/cdist-bootstrap.text new file mode 100644 index 00000000..5852bad0 --- /dev/null +++ b/docs/man/man7/cdist-bootstrap.text @@ -0,0 +1,148 @@ +cdist-bootstrap(7) +================== +Nico Schottelius + + +NAME +---- +cdist-bootstrap - setup cdist environment + + +INTRODUCTION +------------ +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. + + +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 +think about where to configure your hosts from, which may be a different +location. + +For starters, having cdist (which includes the configuration database) on +your notebook should be fine. +Additionally an external copy of the git repository the configuration +relies on is recommended, for use as backup as well as to allow easy collaboration +with others. + +For more sophisticated setups developing cdist configurations with multiple +people, have a look at cdist-best-practice(7). + + +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). +Entering the command "git branch" should show you "* master", which indicates +you are on the **master** branch. + +The master branch reflects the latest development of cdist. As this is the +development branch, it may or may not work. There are also version branches +available, which are kept in a stable state. Let's use **git branch -r** +to list all branches: + +-------------------------------------------------------------------------------- +cdist% git branch -r + origin/1.0 + origin/1.1 + origin/1.2 + origin/1.3 + origin/1.4 + origin/1.5 + origin/1.6 + origin/1.7 + origin/2.0 + origin/HEAD -> origin/master + origin/archive_shell_function_approach + origin/master +-------------------------------------------------------------------------------- + +So **2.0** is the latest version branch in this example. +All versions (2.0.x) within one version branch (2.0) are compatible to each +other and won't break your configuration when updating. + +It's up to you to decide which branch you want to base your own work on: +master contains more recent changes, newer types, but may also break. +The version branches are stable, but may lack the latest features. +Your decision can be changed later on, but may result in merge conflicts, +which you will need to solve. + +Let's assume you want latest stuff and select the master branch as base for +your own work. Now it's time to create your branch, which contains your +local changes. I usually name it by the company/area I am working for: +ethz-systems, localch, customerX, ... But this is pretty much up to you. + +In this tutorial I use the branch **mycompany**: + +-------------------------------------------------------------------------------- +cdist% git checkout -b mycompany origin/master +Branch mycompany set up to track remote branch master from origin. +Switched to a new branch 'mycompany' +cdist-user% git branch + master +* mycompany +-------------------------------------------------------------------------------- + +From now on, you can use git as usual to commit your changes in your own branch. + + +PUBLISHING THE CONFIGURATION +---------------------------- +Usually a development machine like a notebook should be considered +temporary only. For this reason and to enable shareability, the configuration +should be published to another device as early as possible. The following +example shows how to publish the configuration to another host that is +reachable via ssh and has git installed: + +-------------------------------------------------------------------------------- +# Create bare git repository on the host named "loch" +cdist% ssh loch "GIT_DIR=/home/nutzer/cdist git init" +Initialized empty Git repository in /home/nutzer/cdist/ + +# Add remote git repo to git config +cdist% git remote add loch loch:/home/nutzer/cdist + +# Configure the mycompany branch to push to loch +cdist% git config branch.mycompany.remote loch + +# Configure mycompany branch to push into remote master branch +cdist% git config branch.mycompany.merge refs/heads/master + +# Push mycompany branch to remote branch master initially +cdist% git push loch mycompany:refs/heads/master +-------------------------------------------------------------------------------- + +Now you have setup the git repository to synchronise the **mycompany** +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 +-------------------- +Whenever you want to update your cdist installation, you can use git to do so: + +-------------------------------------------------------------------------------- +# Update git repository with latest changes from origin +cdist% git fetch origin + +# Update current branch with master branch from origin +cdist% git merge origin/master + +# Alternative: Update current branch with 2.0 branch from origin +cdist% git merge origin/2.0 +-------------------------------------------------------------------------------- + + +SEE ALSO +-------- +- cdist(1) +- 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.text b/docs/man/man7/cdist-explorer.text new file mode 100644 index 00000000..2c25d845 --- /dev/null +++ b/docs/man/man7/cdist-explorer.text @@ -0,0 +1,68 @@ +cdist-explorer(7) +================= +Nico Schottelius + + +NAME +---- +cdist-explorer - Explore the target systems + + +DESCRIPTION +----------- +Explorer are small shell scripts, which will be executed on the target +host. The aim of the explorer is to give hints to types on how to act on the +target system. An explorer outputs the result to stdout, which is usually +a one liner, but may be empty or multi line especially in the case of +type explorers. + +There are general explorers, which are run in an early stage, and +type explorers. Both work almost exactly the same way, with the difference +that the values of the general explorers are stored in a general location and +the type specific below the object. + +Explorers can reuse other explorers on the target system by calling +$__explorer/ (general and type explorer) or +$__type_explorer/ (type explorer). + +In case of significant errors, the explorer may exit non-zero and return an +error message on stderr, which will cause cdist to abort. + +You can also use stderr for debugging purposes while developing a new +explorer. + +EXAMPLES +-------- +A very simple explorer may look like this: + +-------------------------------------------------------------------------------- +hostname +-------------------------------------------------------------------------------- + +Which is in practise the ***hostname*** explorer. + +A type explorer, which could check for the status of a package may look like this: + +-------------------------------------------------------------------------------- +if [ -f "$__object/parameter/name" ]; then + name="$(cat "$__object/parameter/name")" +else + name="$__object_id" +fi + +# Except dpkg failing, if package is not known / installed +dpkg -s "$name" 2>/dev/null || exit 0 +-------------------------------------------------------------------------------- + + +SEE ALSO +-------- +- cdist(1) +- cdist-reference(7) +- cdist-stages(7) + + +COPYING +------- +Copyright \(C) 2010-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-hacker.text b/docs/man/man7/cdist-hacker.text new file mode 100644 index 00000000..2cbf5a8b --- /dev/null +++ b/docs/man/man7/cdist-hacker.text @@ -0,0 +1,164 @@ +cdist-hacker(7) +=============== +Nico Schottelius + + +NAME +---- +cdist-hacker - How to get (stuff) into cdist + + +WELCOME +------- +Welcome dear hacker! I invite you to a tour of pointers to +get into the usable configuration mangament system, cdist. + +The first thing to know is probably that cdist is brought to +you by people who care about how code looks like and who think +twice before merging or implementing a feature: Less features +with good usability are far better than the opposite. + + +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) +------------------------------- +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. + +Indention is 4 spaces (welcome to the python world). + +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. + +There are though some requirements to ensure your changes don't break others +work nor kill the authors brain: + +- All files should contain the usual header (Author, Copying, etc.) +- Code submission must be done via git +- Do not add cdist/conf/manifest/init - This file should only be touched in your + private branch! +- Code to be included should be branched of the upstream "master" branch + - Exception: Bugfixes to a version branch +- On a merge request, always name the branch I should pull from +- Always ensure **all** manpages build. Use **./build man** to test. +- If you developed more than **one** feature, consider submitting them in + separate branches. This way one feature can already be included, even if + the other needs to be improved. + +As soon as your work meets these requirements, write a mail +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 +------------------------ +For detailled information about types, see cdist-type(7). + +Submitting a type works as described above, with the additional requirement +that a corresponding manpage named man.text in asciidoc format with +the manpage-name "cdist-type__NAME" is included in the type directory +AND asciidoc is able to compile it (i.e. do NOT have to many "=" in the second +line). + +Warning: Submitting "exec" or "run" types that simply echo their parameter in +gencode* will not be accepted, because they are of no use. Every type can output +code and thus such a type introduces redundant functionality that is given by +core cdist already. + + +EXAMPLE GIT WORKFLOW +--------------------- +The following workflow works fine for most developers: + +-------------------------------------------------------------------------------- +# get latest upstream master branch +git clone https://github.com/telmich/cdist.git + +# update if already existing +cd cdist; git fetch -v; git merge origin/master + +# create a new branch for your feature/bugfix +cd cdist # if you haven't done before +git checkout -b documentation_cleanup + +# *hack* +*hack* + +# clone the cdist repository on github if you haven't done so + +# configure your repo to know about your clone (only once) +git remote add github git@github.com:YOURUSERNAME/cdist.git + +# push the new branch to github +git push github documentation_cleanup + +# (or everything) +git push --mirror github + +# create a pull request at github (use a browser) +# *fixthingsbecausequalityassurancefoundissuesinourpatch* +*hack* + +# push code to github again +git push ... # like above + +# add comment that everything should be green now (use a browser) + +# go back to master branch +git checkout master + +# update master branch that includes your changes now +git fetch -v origin +git diff master..origin/master +git merge origin/master +-------------------------------------------------------------------------------- + +If at any point you want to go back to the original master branch, you can +use **git stash** to stash your changes away: + +-------------------------------------------------------------------------------- +# assume you are on documentation_cleanup +git stash + +# change to master and update to most recent upstream version +git checkout master +git fetch -v origin +git merge origin/master +-------------------------------------------------------------------------------- + +Similar when you want to develop another new feature, you go back +to the master branch and create another branch based on it: + +-------------------------------------------------------------------------------- +# change to master and update to most recent upstream version +git checkout master +git fetch -v origin +git merge origin/master + +git checkout -b another_feature +-------------------------------------------------------------------------------- + +(you can repeat the code above for as many features as you want to develop +in parallel) + + +SEE ALSO +-------- +- cdist(7) +- 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/man7/cdist-manifest.text b/docs/man/man7/cdist-manifest.text new file mode 100644 index 00000000..96346c08 --- /dev/null +++ b/docs/man/man7/cdist-manifest.text @@ -0,0 +1,262 @@ +cdist-manifest(7) +================= +Nico Schottelius + + +NAME +---- +cdist-manifest - (Re-)Use types + + +DESCRIPTION +----------- +Manifests are used to define which objects to create. +Objects are instances of **types**, like in object oriented programming languages. +An object is represented by the combination of +**type + slash + object name**: **\__file/etc/cdist-configured** is an +object of the type ***__file*** with the name ***etc/cdist-configured***. + +All available types can be found in the **cdist/conf/type/** directory, +use **ls cdist/conf/type** to get the list of available types. If you have +setup the MANPATH correctly, you can use **man cdist-reference** to access +the reference with pointers to the manpages. + + +Types in manifests are used like normal command line tools. Let's have a look +at an example: +-------------------------------------------------------------------------------- +# Create object of type __package with the parameter state = absent +__package apache2 --state absent + +# Same with the __directory type +__directory /tmp/cdist --state present +-------------------------------------------------------------------------------- + +These two lines create objects, which will later be used to realise the +configuration on the target host. + +Manifests are executed locally as a shell script using **/bin/sh -e**. +The resulting objects are stored in an internal database. + +The same object can be redefined in multiple different manifests as long as +the parameters are exactly the same. + +In general, manifests are used to define which types are used depending +on given conditions. + + +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). + + +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. +Cdist expects the initial manifest at **cdist/conf/manifest/init**. + +Within this initial manifest you define, which objects should be +created on which host. To distinguish between hosts, you can use the +environment variable **__target_host**. Let's have a look at a simple +example: + +-------------------------------------------------------------------------------- +__cdistmarker + +case "$__target_host" in + localhost) + __directory /home/services/kvm-vm --parents yes + ;; +esac +-------------------------------------------------------------------------------- + +This manifest says: Independent of the host, always use the type +***__cdistmarker***, which creates the file **/etc/cdist-configured**, +with the timestamp as content. +The directory ***/home/services/kvm-vm***, including all parent directories, +is only created on the host ***localhost***. + +As you can see, there is no magic involved, the manifest is simple shell code that +utilises cdist types. Every available type can be executed like a normal +command. + + +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 following example would include every file with a **.sh** suffix: + +-------------------------------------------------------------------------------- +# Include *.sh +for manifest in $__manifest/*.sh; do + # And source scripts into our shell environment + . "$manifest" +done +-------------------------------------------------------------------------------- + + +DEPENDENCIES +------------ +If you want to describe that something requires something else, just +setup the variable "require" to contain the requirements. Multiple +requirements can be added white space separated. + +-------------------------------------------------------------------------------- + 1 # No dependency + 2 __file /etc/cdist-configured + 3 + 4 # Require above object + 5 require="__file/etc/cdist-configured" __link /tmp/cdist-testfile \ + 6 --source /etc/cdist-configured --type symbolic + 7 + 8 # Require two objects + 9 require="__file/etc/cdist-configured __link/tmp/cdist-testfile" \ +10 __file /tmp/cdist-another-testfile + + +-------------------------------------------------------------------------------- + +Above the "require" variable is only set for the command that is +immediately following it. Dependencies should allways be declared that way. + +On line 4 you can see that the instantion of a type "__link" object needs +the object "__file/etc/cdist-configured" to be present, before it can proceed. + +This also means that the "__link" command must make sure, that either +"__file/etc/cdist-configured" allready is present, or, if it's not, it needs +to be created. The task of cdist is to make sure, that the dependency will be +resolved appropriately and thus "__file/etc/cdist-configured" be created +if necessary before "__link" proceeds (or to abort execution with an error). + +All objects that are created in a type manifest are automatically required +from the type that is calling them. This is called "autorequirement" in +cdist jargon. + +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). + +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. +When cdist sees that this variable is setup, the current created object +automatically depends on the previously created object. + +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 +--------- +In some special cases, you would like to create an already defined object +with different parameters. In normal situations this leads to an error in cdist. +If you whish, you can setup the environment variable CDIST_OVERRIDE +(any value or even empty is ok) to tell cdist, that this object override is +wanted and should be accepted. +ATTENTION: Only use this feature if you are 100% sure in which order +cdist encounters the affected objects, otherwhise this results +in an undefined situation. + +If CDIST_OVERRIDE and CDIST_ORDER_DEPENDENCY are set for an object, +CDIST_ORDER_DEPENDENCY will be ignored, because adding a dependency in case of +overrides would result in circular dependencies, which is an error. + + + + +EXAMPLES +-------- +The initial manifest may for instance contain the following code: + +-------------------------------------------------------------------------------- +# Always create this file, so other sysadmins know cdist is used. +__file /etc/cdist-configured + +case "$__target_host" in + my.server.name) + __directory /root/bin/ + __file /etc/issue.net --source "$__manifest/issue.net + ;; +esac +-------------------------------------------------------------------------------- + +The manifest of the type "nologin" may look like this: + +-------------------------------------------------------------------------------- +__file /etc/nologin --source "$__type/files/default.nologin" +-------------------------------------------------------------------------------- + +This example makes use of dependencies: + +-------------------------------------------------------------------------------- +# Ensure that lighttpd is installed +__package lighttpd --state present +# Ensure that munin makes use of lighttpd instead of the default webserver +# package as decided by the package manager +require="__package/lighttpd" __package munin --state present +-------------------------------------------------------------------------------- + +How to override objects: + +-------------------------------------------------------------------------------- +# for example in the inital manifest + +# create user account foobar with some hash for password +__user foobar --password 'some_fancy_hash' --home /home/foobarexample + +# ... many statements and includes in the manifest later ... +# somewhere in a conditionaly sourced manifest +# (e.g. for example only sourced if a special application is on the target host) + +# this leads to an error ... +__user foobar --password 'some_other_hash' + +# this tells cdist, that you know that this is an override and should be accepted +CDIST_OVERRIDE=yes __user foobar --password 'some_other_hash' +# it's only an override, means the parameter --home is not touched +# and stays at the original value of /home/foobarexample +-------------------------------------------------------------------------------- + +Dependencies defined by execution order work as following: + +-------------------------------------------------------------------------------- + +# Tells cdist to execute all types in the order in which they are created ... +export CDIST_ORDER_DEPENDENCY=on +__sample_type 1 +require="__some_type_somewhere/id" __sample_type 2 +__example_type 23 +# Now this types are executed in the creation order until the variable is unset +unset CDIST_ORDER_DEPENDENCY +# all now following types cdist makes the order .. +__not_in_order_type 42 + +# how it works : +# this lines above are translated to: +__sample_type 1 +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.text b/docs/man/man7/cdist-messaging.text new file mode 100644 index 00000000..0e53871e --- /dev/null +++ b/docs/man/man7/cdist-messaging.text @@ -0,0 +1,72 @@ +cdist-messaging(7) +================== +Nico Schottelius + +NAME +---- +cdist-messaging - How the initial manifest and types can communication + + +DESCRIPTION +----------- +cdist has a simple but powerful way of allowing communication between +the initial manifest and types as well as types and types. + +Whenever execution is passed from cdist to one of the +scripts described below, cdist generate 2 new temporary files +and exports the environment variables __messages_in and +__messages_out to point to them. + +Before handing over the control, the content of the global message +file is copied into the file referenced by $__messages_in. + +After cdist gained control back, the content of the file referenced +by $__messages_out is appended to the global message file. + +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 +can only react reliably on messages by objects that you depend on. + + +AVAILABILITY +------------ +Messaging is possible between all **local** scripts: + +- initial manifest +- type/manifest +- type/gencode-local +- type/gencode-remote + + +EXAMPLES +-------- +When you want to emit a message use: + +-------------------------------------------------------------------------------- +echo "something" >> "$__messages_out" +-------------------------------------------------------------------------------- + +When you want to react on a message use: + +-------------------------------------------------------------------------------- +if grep -q "^__your_type/object/id:something" "$__messages_in"; then + echo "I do something else" +fi +-------------------------------------------------------------------------------- + + +SEE ALSO +-------- +- cdist(1) +- 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/man7/cdist-quickstart.text b/docs/man/man7/cdist-quickstart.text new file mode 100644 index 00000000..8b754650 --- /dev/null +++ b/docs/man/man7/cdist-quickstart.text @@ -0,0 +1,105 @@ +cdist-quickstart(7) +=================== +Nico Schottelius + + +NAME +---- +cdist-quickstart - jump in and enjoy cdist + + +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. + +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** +of the target host to allow root logins: Edit +the file **/etc/ssh/sshd_config** and add one of the following +lines: + +-------------------------------------------------------------------------------- +# Allow login only via public key +PermitRootLogin without-password + +# Allow login via password and public key +PermitRootLogin yes +-------------------------------------------------------------------------------- + +As cdist uses ssh intensively, it is recommended to setup authentication +with public keys: + +-------------------------------------------------------------------------------- +# Generate pubkey pair as a normal user +ssh-keygen + +# Copy pubkey over to target host +ssh-copy-id root@localhost +-------------------------------------------------------------------------------- + +Have a look at ssh-agent(1) and ssh-add(1) on how to cache the password for +your public key. Usually it looks like this: + +-------------------------------------------------------------------------------- +# Start agent and export variables +eval `ssh-agent` + +# Add keys (requires password for every identity file) +ssh-add +-------------------------------------------------------------------------------- + +At this point you should be able to ***ssh root@localhost*** without +re-entering the password. If something failed until here, ensure that +all steps went successfully and you have read and understood the +documentation. + +As soon as you are able to login without password to localhost, +we can use cdist to configure it. You can copy and paste the following +code into your shell to get started and configure localhost: +-------------------------------------------------------------------------------- +# Get cdist +# Mirrors can be found on +# http://www.nico.schottelius.org/software/cdist/install/#index2h4 +git clone git://git.schottelius.org/cdist + +# Create manifest (maps configuration to host(s) +cd cdist +echo '__file /etc/cdist-configured' > cdist/conf/manifest/init + +# Configure localhost in verbose mode +./bin/cdist config -v localhost + +# Find out that cdist created /etc/cdist-configured +ls -l /etc/cdist-configured +-------------------------------------------------------------------------------- + +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) +- 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/src/cdist-remote-exec-copy.rst b/docs/man/man7/cdist-remote-exec-copy.text similarity index 52% rename from docs/src/cdist-remote-exec-copy.rst rename to docs/man/man7/cdist-remote-exec-copy.text index bb818310..298891d6 100644 --- a/docs/src/cdist-remote-exec-copy.rst +++ b/docs/man/man7/cdist-remote-exec-copy.text @@ -1,28 +1,46 @@ -Remote exec and copy commands -============================= +cdist-remote-exec-copy(7) +========================= +Nico Schottelius + +NAME +---- +cdist-remote-exec-copy - How to use remote exec and copy + + +INTRO +----- Cdist interacts with the target host in two ways: - - it executes code (__remote_exec) - and it copies files (__remote_copy) By default this is accomplished with ssh and scp respectively. -The default implementations used by cdist are:: - - __remote_exec: ssh -o User=root - __remote_copy: scp -o User=root +The default implementations used by cdist are: +__remote_exec: ssh -o User=root -q +__remote_copy: scp -o User=root -q The user can override these defaults by providing custom implementations and passing them to cdist with the --remote-exec and/or --remote-copy arguments. For __remote_exec, the custom implementation must behave as if it where ssh. For __remote_copy, it must behave like scp. -Please notice, custom implementations should work like ssh/scp so __remote_copy -must support IPv6 addresses enclosed in square brackets. For __remote_exec you -must take into account that for some options (like -L) IPv6 addresses can be -specified by enclosed in square brackets (see :strong:`ssh`\ (1) and -:strong:`scp`\ (1)). 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(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/src/cdist-stages.rst b/docs/man/man7/cdist-stages.text similarity index 73% rename from docs/src/cdist-stages.rst rename to docs/man/man7/cdist-stages.text index 751ba9c7..5f2d2e4c 100644 --- a/docs/src/cdist-stages.rst +++ b/docs/man/man7/cdist-stages.text @@ -1,12 +1,19 @@ -Execution stages -================ +cdist-stages(7) +=============== +Nico Schottelius -Description +NAME +---- +cdist-stages - Stages used during configuration deployment + + +DESCRIPTION ----------- -When cdist is started, it passes through different stages. +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 @@ -14,7 +21,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 @@ -23,7 +30,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 @@ -31,7 +38,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, @@ -45,7 +52,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 @@ -53,18 +60,30 @@ 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 errors, the configuration +If, and only if, all the stages complete without an errors, the configuration will be applied to the target. + + +SEE ALSO +-------- +- cdist(1) +- 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/man7/cdist-troubleshooting.text b/docs/man/man7/cdist-troubleshooting.text new file mode 100644 index 00000000..7c5e7612 --- /dev/null +++ b/docs/man/man7/cdist-troubleshooting.text @@ -0,0 +1,63 @@ +cdist-troubleshooting(7) +======================== +Nico Schottelius + + +NAME +---- +cdist-troubleshooting - common problems and their solutions + + +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. +An example script would be something like this: + +-------------------------------------------------------------------------------- +% cat ~/.cdist/manifest/init +"$__manifest/special" +% cat ~/.cdist/manifest/special +#!/bin/sh +echo "Here is an unclean exiting script" +somecommandthatdoesnotexist +echo "I continue here although previous command failed" +-------------------------------------------------------------------------------- + +We can clearly see that **somecommandthatdoesnotexist** +will fail in ~/.cdist/manifest/special. But as the custom +script is not called with the -e flag (exit on failure) of shell, +it does not lead to an error. And thus cdist sees the exit 0 +code of the last echo line instead of the failing command. + +All scripts executed by cdist carry the -e flag. +To prevent the above from happening, there are three solutions available, +two of which can be used in the calling script: +-------------------------------------------------------------------------------- +# Execute as before, but abort on failure +sh -e "$__manifest/special" + +# Source the script in our namespace, runs in a set -e environment: +. "$__manifest/special" +-------------------------------------------------------------------------------- + +The third solution is to include a shebang header in every script +you write to use the -e flag: + +-------------------------------------------------------------------------------- +% cat ~/.cdist/manifest/special +#!/bin/sh -e +... +-------------------------------------------------------------------------------- + + +SEE ALSO +-------- +- cdist(1) +- 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-tutorial.text b/docs/man/man7/cdist-tutorial.text new file mode 100644 index 00000000..85419025 --- /dev/null +++ b/docs/man/man7/cdist-tutorial.text @@ -0,0 +1,58 @@ +cdist-tutorial(7) +================= +Nico Schottelius + + +NAME +---- +cdist-tutorial - a guided introduction into cdist + + +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) +- 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/man/man7/cdist-type.text b/docs/man/man7/cdist-type.text new file mode 100644 index 00000000..323fc130 --- /dev/null +++ b/docs/man/man7/cdist-type.text @@ -0,0 +1,310 @@ +cdist-type(7) +============= +Nico Schottelius + + +NAME +---- +cdist-type - Functionality bundled + + +SYNOPSIS +-------- +__TYPE ID --parameter value [--parameter value ...] + +__TYPE --parameter value [--parameter value ...] (for singletons) + + +DESCRIPTION +----------- +Types are the main component of cdist and define functionality. If you +use cdist, you'll write a type for every functionality you would like +to use. + + +HOW TO USE A TYPE +----------------- +You can use types from the initial manifest or the type manifest like a +normal shell command: + +-------------------------------------------------------------------------------- +# Creates empty file /etc/cdist-configured +__file /etc/cdist-configured --type file + +# Ensure tree is installed +__package tree --state installed +-------------------------------------------------------------------------------- + +A list of supported types can be found in the cdist-reference(7) manpage. + + +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 +system. Singleton types do not take an object name as argument. + +Example: +-------------------------------------------------------------------------------- +# __issue type manages /etc/issue +__issue + +# Probably your own type - singletons may use parameters +__myfancysingleton --colour green +-------------------------------------------------------------------------------- + + +HOW TO WRITE A NEW TYPE +----------------------- +A type consists of + +- parameter (optional) +- manifest (optional) +- singleton (optional) +- explorer (optional) +- gencode (optional) + +Types are stored below cdist/conf/type/. Their name should always be prefixed with +two underscores (__) to prevent collisions with other executables in $PATH. + +To implement a new type, create the directory **cdist/conf/type/__NAME**. + + +DEFINING PARAMETERS +------------------- +Every type consists of required, optional and boolean parameters, which must +each be declared in a newline separated file in ***parameter/required***, +***parameter/required_multiple***, ***parameter/optional***, +***parameter/optional_multiple*** and ***parameter/boolean***. +Parameters which are allowed multiple times should be listed in +required_multiple or optional_multiple respectively. All other parameters +follow the standard unix behaviour "the last given wins". +If either is missing, the type will have no required, no optional, no boolean +or no parameters at all. + +Default values for optional parameters can be predefined in +***parameter/default/***. + +Example: +-------------------------------------------------------------------------------- +echo servername >> cdist/conf/type/__nginx_vhost/parameter/required +echo logdirectory >> cdist/conf/type/__nginx_vhost/parameter/optional +echo loglevel >> cdist/conf/type/__nginx_vhost/parameter/optional +mkdir cdist/conf/type/__nginx_vhost/parameter/default +echo warning > cdist/conf/type/__nginx_vhost/parameter/default/loglevel +echo server_alias >> cdist/conf/type/__nginx_vhost/parameter/optional_multiple +echo use_ssl >> cdist/conf/type/__nginx_vhost/parameter/boolean +-------------------------------------------------------------------------------- + + +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 +represented by file existence. File exists -> True, +file does not exist -> False + +Example: (e.g. in cdist/conf/type/__nginx_vhost/manifest) +-------------------------------------------------------------------------------- +# required parameter +servername="$(cat "$__object/parameter/servername")" + +# optional parameter +if [ -f "$__object/parameter/logdirectory" ]; then + logdirectory="$(cat "$__object/parameter/logdirectory")" +fi + +# optional parameter with predefined default +loglevel="$(cat "$__object/parameter/loglevel")" + +# boolean parameter +if [ -f "$__object/parameter/use_ssl" ]; then + # file exists -> True + # do some fancy ssl stuff +fi + +# parameter with multiple values +if [ -f "$__object/parameter/server_alias" ]; then + for alias in $(cat "$__object/parameter/server_alias"); do + echo $alias > /some/where/usefull + done +fi + +-------------------------------------------------------------------------------- + + +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. + +Example use of a type: (e.g. in cdist/conf/type/__archlinux_hostname) +-------------------------------------------------------------------------------- +__file /etc/rc.conf --source - << eof +... +HOSTNAME="$__target_host" +... +eof +-------------------------------------------------------------------------------- +If you have not seen this syntax (<< eof) before, it may help you to read +about "here documents". + +In the __file type, stdin is used as source for the file, if - is used for source: + +-------------------------------------------------------------------------------- + if [ -f "$__object/parameter/source" ]; then + source="$(cat "$__object/parameter/source")" + if [ "$source" = "-" ]; then + source="$__object/stdin" + fi + .... +-------------------------------------------------------------------------------- + + +WRITING THE MANIFEST +-------------------- +In the manifest of a type you can use other types, so your type extends +their functionality. A good example is the __package type, which in +a shortened version looks like this: + +-------------------------------------------------------------------------------- +os="$(cat "$__global/explorer/os")" +case "$os" in + archlinux) type="pacman" ;; + debian|ubuntu) type="apt" ;; + gentoo) type="emerge" ;; + *) + echo "Don't know how to manage packages on: $os" >&2 + exit 1 + ;; +esac + +__package_$type "$@" +-------------------------------------------------------------------------------- + +As you can see, the type can reference different environment variables, +which are documented in cdist-reference(7). + +Always ensure the manifest is executable, otherwise cdist will not be able +to execute it. For more information about manifests see cdist-manifest(7). + + +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 +directory: + +-------------------------------------------------------------------------------- +touch cdist/conf/type/__NAME/singleton +-------------------------------------------------------------------------------- + +This will also change the way your type must be called: + +-------------------------------------------------------------------------------- +__YOURTYPE --parameter value +-------------------------------------------------------------------------------- + +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 +------------------ +If a type needs to explore specific details, it can provide type specific +explorers, which will be executed on the target for every created object. + +The explorers are stored under the "explorer" directory below the type. +It could for instance contain code to check the md5sum of a file on the +client, like this (shortened version from the type __file): + +-------------------------------------------------------------------------------- +if [ -f "$__object/parameter/destination" ]; then + destination="$(cat "$__object/parameter/destination")" +else + destination="/$__object_id" +fi + +if [ -e "$destination" ]; then + md5sum < "$destination" +fi +-------------------------------------------------------------------------------- + + +WRITING THE GENCODE SCRIPT +-------------------------- +There are two gencode scripts: ***gencode-local*** and ***gencode-remote***. +The output of gencode-local is executed locally, whereas +the output of gencode-remote is executed on the target. +The gencode scripts can make use of the parameters, the global explorers +and the type specific explorers. + +If the gencode scripts encounters an error, it should print diagnostic +messages to stderr and exit non-zero. If you need to debug the gencode +script, you can write to stderr: + +-------------------------------------------------------------------------------- +# Debug output to stderr +echo "My fancy debug line" >&2 + +# Output to be saved by cdist for execution on the target +echo "touch /etc/cdist-configured" +-------------------------------------------------------------------------------- + + +VARIABLE ACCESS FROM THE GENERATED SCRIPTS +------------------------------------------ +In the generated scripts, you have access to the following cdist variables + +- __object +- __object_id + +but only for read operations, means there is no back copy of this +files after the script execution. + +So when you generate a script with the following content, it will work: + +-------------------------------------------------------------------------------- +if [ -f "$__object/parameter/name" ]; then + name="$(cat "$__object/parameter/name")" +else + name="$__object_id" +fi +-------------------------------------------------------------------------------- + + +HINTS FOR TYPEWRITERS +---------------------- +It must be assumed that the target is pretty dumb and thus does not have high +level tools like ruby installed. If a type requires specific tools to be present +on the target, there must be another type that provides this tool and the first +type should create an object of the specific type. + +If your type wants to save temporary data, that may be used by other types +later on (for instance __file), you can save them in the subdirectory +"files" below $__object (but you must create it yourself). +cdist will not touch this directory. + +If your type contains static files, it's also recommended to place them in +a folder named "files" within the type (again, because cdist guarantees to +never ever touch this folder). + + +HOW TO INCLUDE A TYPE INTO UPSTREAM CDIST +----------------------------------------- +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 +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/speeches/2014-05-08_linuxtag_berlin.odp b/docs/speeches/2014-05-08_linuxtag_berlin.odp index 38063332..0cf6374c 100644 Binary files a/docs/speeches/2014-05-08_linuxtag_berlin.odp and b/docs/speeches/2014-05-08_linuxtag_berlin.odp differ diff --git a/docs/speeches/2014-05-19_cdi.st-zkb_linux_erfa.odp b/docs/speeches/2014-05-19_cdi.st-zkb_linux_erfa.odp index a09db845..f722a9cc 100644 Binary files a/docs/speeches/2014-05-19_cdi.st-zkb_linux_erfa.odp and b/docs/speeches/2014-05-19_cdi.st-zkb_linux_erfa.odp differ diff --git a/docs/speeches/2014-06-10_openclouddays.odp b/docs/speeches/2014-06-10_openclouddays.odp deleted file mode 100644 index e85451c8..00000000 Binary files a/docs/speeches/2014-06-10_openclouddays.odp and /dev/null differ diff --git a/docs/speeches/2014-06-10_openclouddays_teaser.odp b/docs/speeches/2014-06-10_openclouddays_teaser.odp deleted file mode 100644 index 16ec8e95..00000000 Binary files a/docs/speeches/2014-06-10_openclouddays_teaser.odp and /dev/null differ diff --git a/docs/speeches/2014-06-10_openclouddays_teaser.pdf b/docs/speeches/2014-06-10_openclouddays_teaser.pdf deleted file mode 100644 index c5a052b8..00000000 Binary files a/docs/speeches/2014-06-10_openclouddays_teaser.pdf and /dev/null differ diff --git a/docs/speeches/2014-06-19_ucms14_cdi.st.odp b/docs/speeches/2014-06-19_ucms14_cdi.st.odp deleted file mode 100644 index 9338abe4..00000000 Binary files a/docs/speeches/2014-06-19_ucms14_cdi.st.odp and /dev/null differ diff --git a/docs/speeches/2014-06-19_ucms14_cdist_cinv_bof.odp b/docs/speeches/2014-06-19_ucms14_cdist_cinv_bof.odp deleted file mode 100644 index 21f59ee8..00000000 Binary files a/docs/speeches/2014-06-19_ucms14_cdist_cinv_bof.odp and /dev/null differ diff --git a/docs/speeches/2014-11-07_sfs_linux_erfa_cdist4.odp b/docs/speeches/2014-11-07_sfs_linux_erfa_cdist4.odp deleted file mode 100644 index 29ada1b0..00000000 Binary files a/docs/speeches/2014-11-07_sfs_linux_erfa_cdist4.odp and /dev/null differ diff --git a/docs/speeches/2014-11-07_sfs_linux_erfa_cdist4.pdf b/docs/speeches/2014-11-07_sfs_linux_erfa_cdist4.pdf deleted file mode 100644 index 718d3997..00000000 Binary files a/docs/speeches/2014-11-07_sfs_linux_erfa_cdist4.pdf and /dev/null differ diff --git a/docs/speeches/2014-11-07_sfs_linux_erfa_cdist_web_prototype.odp b/docs/speeches/2014-11-07_sfs_linux_erfa_cdist_web_prototype.odp deleted file mode 100644 index 47c858d4..00000000 Binary files a/docs/speeches/2014-11-07_sfs_linux_erfa_cdist_web_prototype.odp and /dev/null differ diff --git a/docs/speeches/2014-11-07_sfs_linux_erfa_cdist_web_prototype.pdf b/docs/speeches/2014-11-07_sfs_linux_erfa_cdist_web_prototype.pdf deleted file mode 100644 index ae0a3bef..00000000 Binary files a/docs/speeches/2014-11-07_sfs_linux_erfa_cdist_web_prototype.pdf and /dev/null differ diff --git a/docs/speeches/2015-10-21-opennebulaconf-cdist.odp b/docs/speeches/2015-10-21-opennebulaconf-cdist.odp deleted file mode 100644 index f76ba9c3..00000000 Binary files a/docs/speeches/2015-10-21-opennebulaconf-cdist.odp and /dev/null differ diff --git a/docs/src/Makefile b/docs/src/Makefile deleted file mode 100644 index 2ecf7a32..00000000 --- a/docs/src/Makefile +++ /dev/null @@ -1,237 +0,0 @@ -# Makefile for Sphinx documentation -# - -# You can set these variables from the command line. -SPHINXOPTS = -SPHINXBUILD = sphinx-build -PAPER = -BUILDDIR = ../dist -# for cache, etc. -_BUILDDIR = _build - -# User-friendly check for sphinx-build -ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1) - $(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don\'t have Sphinx installed, grab it from http://sphinx-doc.org/) -endif - -# Internal variables. -PAPEROPT_a4 = -D latex_paper_size=a4 -PAPEROPT_letter = -D latex_paper_size=letter -ALLSPHINXOPTS = -d $(_BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . -# the i18n builder cannot share the environment and doctrees with the others -I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . - -.PHONY: help -help: - @echo "Please use \`make ' where is one of" - @echo " html to make standalone HTML files" - @echo " dirhtml to make HTML files named index.html in directories" - @echo " singlehtml to make a single large HTML file" - @echo " pickle to make pickle files" - @echo " json to make JSON files" - @echo " htmlhelp to make HTML files and a HTML help project" - @echo " qthelp to make HTML files and a qthelp project" - @echo " applehelp to make an Apple Help Book" - @echo " devhelp to make HTML files and a Devhelp project" - @echo " epub to make an epub" - @echo " epub3 to make an epub3" - @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" - @echo " latexpdf to make LaTeX files and run them through pdflatex" - @echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx" - @echo " text to make text files" - @echo " man to make manual pages" - @echo " texinfo to make Texinfo files" - @echo " info to make Texinfo files and run them through makeinfo" - @echo " gettext to make PO message catalogs" - @echo " changes to make an overview of all changed/added/deprecated items" - @echo " xml to make Docutils-native XML files" - @echo " pseudoxml to make pseudoxml-XML files for display purposes" - @echo " linkcheck to check all external links for integrity" - @echo " doctest to run all doctests embedded in the documentation (if enabled)" - @echo " coverage to run coverage check of the documentation (if enabled)" - @echo " dummy to check syntax errors of document sources" - -.PHONY: clean -clean: - rm -rf $(BUILDDIR)/* - rm -rf $(_BUILDDIR)/* - -.PHONY: html -html: - $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html - @echo - @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." - -.PHONY: dirhtml -dirhtml: - $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml - @echo - @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." - -.PHONY: singlehtml -singlehtml: - $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml - @echo - @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." - -.PHONY: pickle -pickle: - $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle - @echo - @echo "Build finished; now you can process the pickle files." - -.PHONY: json -json: - $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json - @echo - @echo "Build finished; now you can process the JSON files." - -.PHONY: htmlhelp -htmlhelp: - $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp - @echo - @echo "Build finished; now you can run HTML Help Workshop with the" \ - ".hhp project file in $(BUILDDIR)/htmlhelp." - -.PHONY: qthelp -qthelp: - $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp - @echo - @echo "Build finished; now you can run "qcollectiongenerator" with the" \ - ".qhcp project file in $(BUILDDIR)/qthelp, like this:" - @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/cdist-docs.qhcp" - @echo "To view the help file:" - @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/cdist-docs.qhc" - -.PHONY: applehelp -applehelp: - $(SPHINXBUILD) -b applehelp $(ALLSPHINXOPTS) $(BUILDDIR)/applehelp - @echo - @echo "Build finished. The help book is in $(BUILDDIR)/applehelp." - @echo "N.B. You won't be able to view it unless you put it in" \ - "~/Library/Documentation/Help or install it in your application" \ - "bundle." - -.PHONY: devhelp -devhelp: - $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp - @echo - @echo "Build finished." - @echo "To view the help file:" - @echo "# mkdir -p $$HOME/.local/share/devhelp/cdist-docs" - @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/cdist-docs" - @echo "# devhelp" - -.PHONY: epub -epub: - $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub - @echo - @echo "Build finished. The epub file is in $(BUILDDIR)/epub." - -.PHONY: epub3 -epub3: - $(SPHINXBUILD) -b epub3 $(ALLSPHINXOPTS) $(BUILDDIR)/epub3 - @echo - @echo "Build finished. The epub3 file is in $(BUILDDIR)/epub3." - -.PHONY: latex -latex: - $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex - @echo - @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." - @echo "Run \`make' in that directory to run these through (pdf)latex" \ - "(use \`make latexpdf' here to do that automatically)." - -.PHONY: latexpdf -latexpdf: - $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex - @echo "Running LaTeX files through pdflatex..." - $(MAKE) -C $(BUILDDIR)/latex all-pdf - @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." - -.PHONY: latexpdfja -latexpdfja: - $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex - @echo "Running LaTeX files through platex and dvipdfmx..." - $(MAKE) -C $(BUILDDIR)/latex all-pdf-ja - @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." - -.PHONY: text -text: - $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text - @echo - @echo "Build finished. The text files are in $(BUILDDIR)/text." - -.PHONY: man -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." - -.PHONY: texinfo -texinfo: - $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo - @echo - @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo." - @echo "Run \`make' in that directory to run these through makeinfo" \ - "(use \`make info' here to do that automatically)." - -.PHONY: info -info: - $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo - @echo "Running Texinfo files through makeinfo..." - make -C $(BUILDDIR)/texinfo info - @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." - -.PHONY: gettext -gettext: - $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale - @echo - @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." - -.PHONY: changes -changes: - $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes - @echo - @echo "The overview file is in $(BUILDDIR)/changes." - -.PHONY: linkcheck -linkcheck: - $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck - @echo - @echo "Link check complete; look for any errors in the above output " \ - "or in $(BUILDDIR)/linkcheck/output.txt." - -.PHONY: doctest -doctest: - $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest - @echo "Testing of doctests in the sources finished, look at the " \ - "results in $(BUILDDIR)/doctest/output.txt." - -.PHONY: coverage -coverage: - $(SPHINXBUILD) -b coverage $(ALLSPHINXOPTS) $(BUILDDIR)/coverage - @echo "Testing of coverage in the sources finished, look at the " \ - "results in $(BUILDDIR)/coverage/python.txt." - -.PHONY: xml -xml: - $(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml - @echo - @echo "Build finished. The XML files are in $(BUILDDIR)/xml." - -.PHONY: pseudoxml -pseudoxml: - $(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml - @echo - @echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml." - -.PHONY: dummy -dummy: - $(SPHINXBUILD) -b dummy $(ALLSPHINXOPTS) $(BUILDDIR)/dummy - @echo - @echo "Build finished. Dummy builder generates no files." diff --git a/docs/src/_static/cdist-logo.jpeg b/docs/src/_static/cdist-logo.jpeg deleted file mode 100644 index 9bfa2529..00000000 Binary files a/docs/src/_static/cdist-logo.jpeg and /dev/null differ diff --git a/docs/src/_static/pgp-key-EFD2AE4EC36B6901.asc b/docs/src/_static/pgp-key-EFD2AE4EC36B6901.asc deleted file mode 100644 index 1762d7c1..00000000 --- a/docs/src/_static/pgp-key-EFD2AE4EC36B6901.asc +++ /dev/null @@ -1,52 +0,0 @@ ------BEGIN PGP PUBLIC KEY BLOCK----- -Version: GnuPG v2 - -mQINBFeCnRQBEACoybnhBEubglOHJrZQ8PKcdeQaGZRoTc3cDs84lr6a9HiLeoBO -f8x9fpN4LJbaJOyFJLcvVHHcljvooCLqL5t8/pj7Lyvq1AYuMAeS2Wy19amy3tE5 -aYYdN85idE/m81B+nD76URL4UjXm0T9ITNLbSE3cZTh/25fsFLub+CHauuP0zxJJ -4SlWnIvvcx1hg9n0la9M1DwcNSdI9A7bZLHIM3Ixuq8HTXcuuozXvJOxTgKZ6Yfs -UmTW7mMykbcxcNZx9bADj8kJOEf9FlJzalkW3XVGbBBYgwDrqoRGl+gtt5up71cE -N0NSL6+6mNJBW3ek9kI88z2qUlVe5UXZQxe5sgjrcnE2sPJkAjCiYUXhVzjV5Oo1 -CZ8m1egZLM4IWwAVg8lTizSozYWm9Rs5BcHRVSbQenXoJffTYJY//UE7sAkAfKCf -vsHCdc1H1yK2OwC418nj/T2Zu8Yt0CWiQT3Sogtqz6R7HgVCmSqEdQl3+VL2hQkk -4s0lSOCtBpe0R700phJ67QsnCB8cGMqfUbYZ9cEppJwPA3X3tZd5BJ2OYFU/qhrM -SJ9konAWxnFkViBz0MCKhVjMh6DsH40xdQQsrXsF2aSwEv3MFw/sj+xt1KIuRE5i -IDrZpbaWVjshoJVH6l4eK01DfxRHRJdj8AyH/xJTQQRal2J4CNWjtl+NzwARAQAB -tDB1bmdsZWljaCBHbWJIICh1bmdsZWljaCBGT1NTKSA8Zm9zc0B1bmdsZWljaC5j -aD6JAjcEEwEIACEFAleCnRQCGwMFCwkIBwIGFQgJCgsCBBYCAwECHgECF4AACgkQ -79KuTsNraQGQ6w//dLuEsGzhqQ4FdYwpTOOfcWB6+i42PGb2TgXzwbx5kgzKv6oi -nGuMlXKfamaqbCQuPRyHxR34VRgJslDcvhIXDhB7ELdi5ib8vpA2bX082Es9cKUB -TSGPtp8y7n9aN9ebu/HWLQu88YdAHEcB8BhSuMmcxGvRM1H2a59lW5WizQ7KUPLt -5a8UeELmf/Xz0k4YLP39ApXHxfis0kbGYBni6f7WsyVw2SBEqiG6Z9XktRcSo0e/ -RlZb8FlEQgkZtafmFh2qLS710sll8bcD4Xqktzy4ztUgp6ImtpUY8CwdO9H8VCZK -xCwEIX3W25qAXiV8aFSJ9T4M15dkZivq1vvAEmE0G1zEi8AwI3NGjMXDh61A1yH3 -auHdSOPzdlICqZDBDlX70tmzL3MBOBy32DkVMwe5JHlj9RBjrpp/B3wch1La2NND -4tFEzYMYlkDxCjJKpNqGDZO+ZqHA7dOx3sx6XPlGtSyWnFfFPu2bBvrDhyORmMbO -20pLotDXIzJ8qNCsZ6XAiJ1PDeHintxbRwJxERScv3EcvcE/lcxrlS/TX9LbBJPE -0y/JMpXLx+9WdG5KpDCxpuZHVyKkcXP0TAPq/IG+VPo9wTGg6cy///Se2PKBbuMm -X90VVM/C5PYmDjJ+IxZckBm6oXLJSZd0rETrf0G4HQCznnA8oiQbZu1ac/O5Ag0E -V4KdFAEQALoVDmDKujONT1yDT+AFUc2a/IBBU7V5Ut86+ZdiXltKVpQA3Dc17bdt -GS5YqMVnIaKZ7MqRhfo0XeVzyTBzjGLr+2EZdWb51I7JNto/HVZgUOvon9BiMoTK -KUOD8gFlhblCcKd/aVOJXPDzKYfu2jgBmgtcHecbyXRbjlha6l0/jsFJj0VJySQv -pj2AftKtb7mltz5Wfm/FkUfpEYGl2NSucW3bYNe0j6BmQXqRqLupeoSdmWrPT+oa -RXxKfM0Ug43WnNYgXsAwU383pdfmYIzxsV7RRIXZZswNKuMj4XyDp1hvF4++6Nqb -ySsCGWRWYG1TK0yCQyzRYvaaY15W9ZX8q91Qx9R6RksXs8bjDmHKo55z4V3Dy5KG -dwanyatmEwkbcKjFECK84V8zNJDspsLS1BGiUF69qWdU/wREMs4kp0gUC+3Fbguf -u/v4yc87SO9QvIIv2lWp3nRpQC5661+SK4dB2SVYL88Yd+LFoe883qI5GQIFLad+ -Q5Y/c305r44VOlACV/EsP01LoHHfSsTeneoBUW8ndoKyE3yJ5LKYUV9caROG4/Wh -hGWulkZTXSUXv8q6rUoCIkJiTPPnozwjtErlGyNGcnG1WR55sRV8SFr/SflnUDh9 -tAo+I1xegS+B9W+I89jv3ujkpDVNoST8nb44EZrAq/R0WST48zDHABEBAAGJAh8E -GAEIAAkFAleCnRQCGwwACgkQ79KuTsNraQH7Iw//YclkUN193xbaOho/y4Dj4vk1 -/Gl4bRgek5CkeMll2uxvsvaVEhL1fbBOR501kmYKzCynkESWft8FG7LNxLi7t3Y9 -XrnvvIqPVGAwD8x1+fj+LWCAOZAcFQ3nPSXRY+aZ545G5Mu24EHKsaBEFiyGlDSY -6+XLJchQEpUwVn3MIk9RKCyYi9pAdofgvHuDbB8fFz2YGyjmBn+WbZCmvTm62AIP -WzaNBx507l9LBObY2teBTFLFOnUmNW0QLNpV8lGlWv/rVGfzqD3VVavRNGcXLkI9 -spv4r5ci9tQWwW52Z8fAFMo4yWeeWnS0uk4vKtq3ANwFqFtxLuA8WBy9FYQ/5BR0 -RdbI0a/iVN2rJcZxGqUbz22U+4N7g89EmHA40LFsWmIl5duAtXZ3XIlMFzCuXwYf -u9fpLUs6uIdRuVVg/qVJva608hn/7/fEqetbwoHmmSBVUSOQYdMZZ5SyR8zDUbBh -acGOOPRSN7tJG8ycoPSQKQci4fXEpqkBfojalqNKGgJUj+5IWApZWvZV0Z6fFLO7 -Q2vd1jXYb4lKv04pfxqfOuOlSy9w6ElNewF4V7jSdGqfitw2lQNXlC1EaoajkiZJ -Evcb9b5HexuJPI3cxyJGZyUYyqk2FF0ztGigbhK986iyKILJB+OqiLbAs3KIgezD -vsomtv+pm41l0JK+Xps= -=/2wY ------END PGP PUBLIC KEY BLOCK----- diff --git a/docs/src/cdist-best-practice.rst b/docs/src/cdist-best-practice.rst deleted file mode 100644 index a91f2cc0..00000000 --- a/docs/src/cdist-best-practice.rst +++ /dev/null @@ -1,363 +0,0 @@ -Best practice -============= -Practices used in real environments - -Passwordless connections ------------------------- -It is recommended to run cdist with public key authentication. -This requires a private/public key pair and the entry -"PermitRootLogin without-password" in the sshd server. -See sshd_config(5) and ssh-keygen(1). - - -Speeding up ssh connections ---------------------------- -When connecting to a new host, the initial delay with ssh connections -is pretty big. As cdist makes many connections to each host successive -connections can be sped up by "sharing of multiple sessions over a single -network connection" (quote from ssh_config(5)). This is also called "connection -multiplexing". - -Cdist implements this since v4.0.0 by executing ssh with the appropriate -options (`-o ControlMaster=auto -o ControlPath=/tmp//s -o -ControlPersist=2h`). - -Note that the sshd_config on the server can configure the maximum number of -parallel multiplexed connections this with `MaxSessions N` (N defaults to 10 -for OpenSSH v7.4). - - -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:: - - ln -sf /bin/dash /bin/sh - - -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 -control git. For instance if you plan to use the typical three -environments production, integration and development, you can -realise this with git branches:: - - # Go to cdist checkout - cd /path/to/cdist - - # Create branches - git branch development - git branch integration - git branch production - - # Make use of a branch, for instance production - git checkout production - -Similar if you want to have cdist checked out at multiple machines, -you can clone it multiple times:: - - machine-a % git clone git://your-git-server/cdist - machine-b % git clone git://your-git-server/cdist - - -Separating work by groups -------------------------- -If you are working with different groups on one cdist-configuration, -you can delegate to other manifests and have the groups edit only -their manifests. You can use the following snippet in -**conf/manifests/init**:: - - # Include other groups - sh -e "$__manifest/systems" - - sh -e "$__manifest/cbrg" - - -Maintaining multiple configurations ------------------------------------ -When you need to manage multiple sites with cdist, like company_a, company_b -and private for instance, you can easily use git for this purpose. -Including a possible common base that is reused across the different sites:: - - # create branches - git branch company_a company_b common private - - # make stuff for company a - git checkout company_a - # work, commit, etc. - - # make stuff for company b - git checkout company_b - # work, commit, etc. - - # make stuff relevant for all sites - git checkout common - # work, commit, etc. - - # change to private and include latest common stuff - git checkout private - git merge common - - -The following **.git/config** is taken from a real world scenario:: - - # Track upstream, merge from time to time - [remote "upstream"] - url = git://git.schottelius.org/cdist - fetch = +refs/heads/*:refs/remotes/upstream/* - - # Same as upstream, but works when being offline - [remote "local"] - fetch = +refs/heads/*:refs/remotes/local/* - url = /home/users/nico/p/cdist - - # Remote containing various ETH internal branches - [remote "eth"] - url = sans.ethz.ch:/home/services/sans/git/cdist-eth - fetch = +refs/heads/*:refs/remotes/eth/* - - # Public remote that contains my private changes to cdist upstream - [remote "nico"] - url = git.schottelius.org:/home/services/git/cdist-nico - fetch = +refs/heads/*:refs/remotes/nico/* - - # The "nico" branch will be synced with the remote nico, branch master - [branch "nico"] - remote = nico - merge = refs/heads/master - - # ETH stable contains rock solid configurations used in various places - [branch "eth-stable"] - remote = eth - merge = refs/heads/stable - -Have a look at git-remote(1) to adjust the remote configuration, which allows - - -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 -implement this scenario with a gateway host and sudo: - -- Create a dedicated user (for instance **cdist**) -- Setup the ssh-pubkey for this user that has the right to configure all hosts -- Create a wrapper to update the cdist configuration in ~cdist/cdist -- Allow every developer to execute this script via sudo as the user cdist -- Allow run of cdist as user cdist on specific hosts on a per user/group basis. - - - f.i. nico ALL=(ALL) NOPASSWD: /home/cdist/bin/cdist config hostabc - -For more details consult sudoers(5) - - -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 - -.. code-block:: sh - - #!/bin/sh - # in the template, use cat << eof (here document) to output the text - # and use standard shell variables in the template - # output everything in the template script to stdout - cat << EOF - server { - listen 80; - server_name $SERVERNAME; - root $ROOT; - - access_log /var/log/nginx/$SERVERNAME_access.log - error_log /var/log/nginx/$SERVERNAME_error.log - } - EOF - -* in the manifest, export the relevant variables and add the following lines to your manifest: - -.. code-block:: console - - # export variables needed for the template - export SERVERNAME='test" - export ROOT='/var/www/test' - # render the template - mkdir -p "$__object/files" - "$__type/files/basic.conf.sh" > "$__object/files/basic.conf" - # send the rendered template - __file /etc/nginx/sites-available/test.conf \ - --state present - --source "$__object/files/basic.conf" - - -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 -with - (stdin) as argument and feed object into stdin -of cdist: - -.. code-block:: sh - - # Singleton type without parameter - echo __ungleich_munin_server | cdist --initial-manifest - munin.panter.ch - - # Singleton type with parameter - echo __ungleich_munin_node --allow 1.2.3.4 | \ - cdist --initial-manifest - rails-19.panter.ch - - # Normal type - echo __file /tmp/stdintest --mode 0644 | \ - cdist --initial-manifest - cdist-dev-01.ungleich.ch - - -Other content in cdist repository ---------------------------------- -Usually the cdist repository contains all configuration -items. Sometimes you may have additional resources that -you would like to store in your central configuration -repository (like password files from KeepassX, -Libreoffice diagrams, etc.). - -It is recommended to use a subfolder named "non-cdist" -in the repository for such content: It allows you to -easily distinguish what is used by cdist and what is not -and also to store all important files in one -repository. - - -Perils of CDIST_ORDER_DEPENDENCY --------------------------------- -With CDIST_ORDER_DEPENDENCY all types are executed in the order in which they -are created in the manifest. The current created object automatically depends -on the previously created object. - -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). - -This can be helpful, but it can also be the source of *evil*. - - -CDIST_ORDER_DEPENDENCY easily causes unobvious dependency cycles -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -Let's see an example. Suppose you have special init manifest where among other -things you are assuring that remote host has packages `sudo` and `curl` -installed. - -**init1** - -.. code-block:: sh - - CDIST_ORDER_DEPENDENCY=1 - export CDIST_ORDER_DEPENDENCY - - for p in sudo curl - do - __package "${p}" - done - -Then you have some other special init manifest where among other things you are -assuring `sudo` package is installed. - -**init2** - -.. code-block:: sh - - CDIST_ORDER_DEPENDENCY=1 - export CDIST_ORDER_DEPENDENCY - - __package sudo - -Then you have third init manifest where you combine those two init manifests, -by including them: - -**init** - -.. code-block:: sh - - sh -e "$__manifest/init1" - sh -e "$__manifest/init2" - -The resulting init manifest is then equal to: - -.. code-block:: sh - - CDIST_ORDER_DEPENDENCY=1 - export CDIST_ORDER_DEPENDENCY - - for p in sudo curl - do - __package "${p}" - done - - CDIST_ORDER_DEPENDENCY=1 - export CDIST_ORDER_DEPENDENCY - - __package sudo - -In the end you get the following dependencies: - -* `__package/curl` depends on `__package/sudo` -* `__package/sudo` depends on `__package/curl` - -And here you have a circular dependency! - -In the real world manifest can be quite complex, dependencies can become -complicated and circual dependencies are not so obvious. Resolving it can -become cumbersome. - -**Practical solution?** - -Instead of managing complex init manifests you can write custom types. -Each custom type can do one thing, it has well defined dependencies that will -not leak into init manifest. In custom type you can also add special explorers -and gencode. - -Then, in init manifest you combine your complex types. It is: - -* cleaner -* easier to follow -* easier to maintain -* easier to debug. - - -CDIST_ORDER_DEPENDENCY kills parallelization -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -Suppose you have defined CDIST_ORDER_DEPENDENCY and then, among other things, -you specify creation of three, by nature independent, files. - -**init** - -.. code-block:: sh - - CDIST_ORDER_DEPENDENCY=1 - export CDIST_ORDER_DEPENDENCY - - ... - __file /tmp/file1 - __file /tmp/file2 - __file /tmp/file3 - ... - -Due to defined CDIST_ORDER_DEPENDENCY cdist will execute them in specified order. -It is better to use CDIST_ORDER_DEPENDENCY in well defined blocks: - -**init** - -.. code-block:: sh - - CDIST_ORDER_DEPENDENCY=1 - export CDIST_ORDER_DEPENDENCY - ... - unset CDIST_ORDER_DEPENDENCY - - __file /tmp/file1 - __file /tmp/file2 - __file /tmp/file3 - - CDIST_ORDER_DEPENDENCY=1 - export CDIST_ORDER_DEPENDENCY - ... - unset CDIST_ORDER_DEPENDENCY diff --git a/docs/src/cdist-bootstrap.rst b/docs/src/cdist-bootstrap.rst deleted file mode 100644 index c9972a99..00000000 --- a/docs/src/cdist-bootstrap.rst +++ /dev/null @@ -1,118 +0,0 @@ -Bootstrap -========= -This document describes the usual steps recommended for a new -cdist setup. It is recommended that you have read and understood -`cdist quickstart `_ before digging into this. - - -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 -think about where to configure your hosts from, which may be a different -location. - -For starters, having cdist (which includes the configuration database) on -your notebook should be fine. -Additionally an external copy of the git repository the configuration -relies on is recommended, for use as backup as well as to allow easy collaboration -with others. - -For more sophisticated setups developing cdist configurations with multiple -people, have a look at `cdist best practice `_. - - -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 `_ if you don't). -Entering the command "git branch" should show you "* master", which indicates -you are on the **master** branch. - -The master branch reflects the latest development of cdist. As this is the -development branch, it may or may not work. There are also version branches -available, which are kept in a stable state. Let's use **git branch -r** -to list all branches:: - - cdist% git branch -r - origin/1.0 - origin/1.1 - origin/1.2 - origin/1.3 - origin/1.4 - origin/1.5 - origin/1.6 - origin/1.7 - origin/2.0 - origin/HEAD -> origin/master - origin/archive_shell_function_approach - origin/master - -So **2.0** is the latest version branch in this example. -All versions (2.0.x) within one version branch (2.0) are compatible to each -other and won't break your configuration when updating. - -It's up to you to decide which branch you want to base your own work on: -master contains more recent changes, newer types, but may also break. -The version branches are stable, but may lack the latest features. -Your decision can be changed later on, but may result in merge conflicts, -which you will need to solve. - -Let's assume you want latest stuff and select the master branch as base for -your own work. Now it's time to create your branch, which contains your -local changes. I usually name it by the company/area I am working for: -ethz-systems, localch, customerX, ... But this is pretty much up to you. - -In this tutorial I use the branch **mycompany**:: - - cdist% git checkout -b mycompany origin/master - Branch mycompany set up to track remote branch master from origin. - Switched to a new branch 'mycompany' - cdist-user% git branch - master - * mycompany - -From now on, you can use git as usual to commit your changes in your own branch. - - -Publishing the configuration ----------------------------- -Usually a development machine like a notebook should be considered -temporary only. For this reason and to enable shareability, the configuration -should be published to another device as early as possible. The following -example shows how to publish the configuration to another host that is -reachable via ssh and has git installed:: - - # Create bare git repository on the host named "loch" - cdist% ssh loch "GIT_DIR=/home/nutzer/cdist git init" - Initialized empty Git repository in /home/nutzer/cdist/ - - # Add remote git repo to git config - cdist% git remote add loch loch:/home/nutzer/cdist - - # Configure the mycompany branch to push to loch - cdist% git config branch.mycompany.remote loch - - # Configure mycompany branch to push into remote master branch - cdist% git config branch.mycompany.merge refs/heads/master - - # Push mycompany branch to remote branch master initially - cdist% git push loch mycompany:refs/heads/master - -Now you have setup the git repository to synchronise the **mycompany** -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 --------------------- -Whenever you want to update your cdist installation, you can use git to do so:: - - # Update git repository with latest changes from origin - cdist% git fetch origin - - # Update current branch with master branch from origin - cdist% git merge origin/master - - # Alternative: Update current branch with 2.0 branch from origin - cdist% git merge origin/2.0 diff --git a/docs/src/cdist-cache.rst b/docs/src/cdist-cache.rst deleted file mode 100644 index 0e5361ee..00000000 --- a/docs/src/cdist-cache.rst +++ /dev/null @@ -1,98 +0,0 @@ -Local cache overview -==================== - -Description ------------ -While executing, cdist stores data to local cache. Currently this feature is -one way only. That means that cdist does not use stored data for future runs. -Anyway, those data can be used for debugging cdist, debugging types and -debugging after host configuration fails. - -Local cache is saved under $HOME/.cdist/cache directory, one directory entry -for each host. Subdirectory path is specified by -:strong:`-C/--cache-path-pattern` option, :strong:`cache_path_pattern` -configuration option or by using :strong:`CDIST_CACHE_PATH_PATTERN` -environment variable. - -For more info on cache path pattern see :strong:`CACHE PATH PATTERN FORMAT` -section in cdist man page. - - -Cache overview --------------- -As noted above each configured host has got its subdirectory in local cache. -Entries in host's cache directory are as follows. - -bin - directory with cdist type emulators - -conf - dynamically determined cdist conf directory, union of all specified - conf directories - -explorer - directory containing global explorer named files containing explorer output - after running on target host - -messages - file containing messages - -object - directory containing subdirectory for each cdist object - -object_marker - object marker for this particular cdist run - -stderr - directory containing init manifest and remote stderr stream output - -stdout - directory containing init manifest and remote stdout stream output - -target_host - file containing target host of this cdist run, as specified when running - cdist - -typeorder - file containing types in order of execution. - - -Object cache overview -~~~~~~~~~~~~~~~~~~~~~ -Each object under :strong:`object` directory has its own structurue. - -code-local - code generated from gencode-local, present only if something is - generated - -code-remote - code generated from gencode-remote, present only if something is - generated - -explorer - directory containing type explorer named files containing explorer output - after running on target host - -files - directory with object files created during type execution - -parameter - directory containing type parameter named files containing parameter - values - -source - this type's source (init manifest) - -state - this type execution state ('done' when finished) - -stderr - directory containing type's manifest, gencode-* and code-* stderr stream - outputs - -stdin - this type stdin content - -stdout - directory containing type's manifest, gencode-* and code-* stdout stream - outputs. diff --git a/docs/src/cdist-configuration.rst b/docs/src/cdist-configuration.rst deleted file mode 100644 index 4c9b4d33..00000000 --- a/docs/src/cdist-configuration.rst +++ /dev/null @@ -1,103 +0,0 @@ -Configuration -============= - -Description ------------ -cdist obtains configuration data from the following sources in the following -order: - - #. command-line options - #. configuration file specified at command-line using -g command line option - #. configuration file specified in CDIST_CONFIG_FILE environment variable - #. environment variables - #. user's configuration file (first one found of ~/.cdist.cfg, $XDG_CONFIG_HOME/cdist/cdist.cfg, in specified order) - #. in-distribution configuration file (cdist/conf/cdist.cfg) - #. system-wide configuration file (/etc/cdist.cfg) - -if one exists. - -Configuration source with lower ordering number from above has a higher -precedence. Configuration option value read from source with higher -precedence will overwrite option value, if exists, read from source with -lower precedence. That means that command-line option wins them all. - -Users can decide on the local conifguration file location. It can be either -~/.cdist.cfg or $XDG_CONFIG_HOME/cdist/cdist.cfg. Note that, if both exist, -then ~/.cdist.cfg is used. - -For a per-project configuration, particular environment variables or better, -CDIST_CONFIG_FILE environment variable or -g CONFIG_FILE command line option, -can be used. - -Config file format ------------------- -cdist configuration file is in the INI file format. Currently it supports -only [GLOBAL] section. -The possible keywords and their meanings are as follows: - -:strong:`archiving` - Use specified archiving. Valid values include: - 'none', 'tar', 'tgz', 'tbz2' and 'txz'. - -:strong:`beta` - Enable beta functionality. It recognizes boolean values from - 'yes'/'no', 'on'/'off', 'true'/'false' and '1'/'0'. - -:strong:`cache_path_pattern` - Specify cache path pattern. - -:strong:`conf_dir` - List of configuration directories separated with the character conventionally - used by the operating system to separate search path components (as in PATH), - such as ':' for POSIX or ';' for Windows. - If also specified at command line then values from command line are - appended to this value. - -:strong:`init_manifest` - Specify default initial manifest. - -:strong:`inventory_dir` - Specify inventory directory. - -:strong:`jobs` - Specify number of jobs for parallel processing. If -1 then the default, - number of CPU's in the system is used. If 0 then parallel processing in - jobs is disabled. If set to positive number then specified maximum - number of processes will be used. - -:strong:`local_shell` - Shell command used for local execution. - -:strong:`out_path` - Directory to save cdist output in. - -:strong:`parallel` - Process hosts in parallel. If -1 then the default, number of CPU's in - the system is used. If 0 then parallel processing of hosts is disabled. - If set to positive number then specified maximum number of processes - will be used. - -:strong:`remote_copy` - Command to use for remote copy (should behave like scp). - -:strong:`remote_exec` - Command to use for remote execution (should behave like ssh). - -:strong:`remote_out_path` - Directory to save cdist output in on the target host. - -:strong:`remote_shell` - Shell command at remote host used for remote execution. - -:strong:`save_output_streams` - Enable/disable saving output streams (enabled by default). - It recognizes boolean values from 'yes'/'no', 'on'/'off', 'true'/'false' - and '1'/'0'. - -:strong:`timestamp` - Timestamp log messages with the current local date and time - in the format: YYYYMMDDHHMMSS.us. - -:strong:`verbosity` - Set verbosity level. Valid values are: - 'ERROR', 'WARNING', 'INFO', 'VERBOSE', 'DEBUG', 'TRACE' and 'OFF'. diff --git a/docs/src/cdist-explorer.rst b/docs/src/cdist-explorer.rst deleted file mode 100644 index a3c4f490..00000000 --- a/docs/src/cdist-explorer.rst +++ /dev/null @@ -1,54 +0,0 @@ -Explorer -======== - -Description ------------ -Explorers are small shell scripts, which will be executed on the target -host. The aim of each explorer is to give hints to types on how to act on the -target system. An explorer outputs the result to stdout, which is usually -a one liner, but may be empty or multi line especially in the case of -type explorers. - -There are general explorers, which are run in an early stage, and -type explorers. Both work almost exactly the same way, with the difference -that the values of the general explorers are stored in a general location and -the type specific below the object. - -Explorers can reuse other explorers on the target system by calling - -:: - - $__explorer/ (general and type explorer) - -or - -:: - - $__type_explorer/ (type explorer). - -In case of significant errors, the explorer may exit non-zero and return an -error message on stderr, which will cause cdist to abort. - -You can also use stderr for debugging purposes while developing a new -explorer. - -Examples --------- -A very simple explorer may look like this:: - - hostname - -Which is in practise the **hostname** explorer. - -A type explorer, which could check for the status of a package may look like this: - -.. code-block:: sh - - if [ -f "$__object/parameter/name" ]; then - name="$(cat "$__object/parameter/name")" - else - name="$__object_id" - fi - - # Expect dpkg failing, if package is not known / installed - dpkg -s "$name" 2>/dev/null || exit 0 diff --git a/docs/src/cdist-features.rst b/docs/src/cdist-features.rst deleted file mode 100644 index be56fa22..00000000 --- a/docs/src/cdist-features.rst +++ /dev/null @@ -1,48 +0,0 @@ -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 separated - + Sticks completely to the KISS (keep it simple and stupid) paradigm - + 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, familiar environment, documentation - Is available as manpages and HTML - -UNIX, simplicity, familiar environment - cdist is configured in POSIX shell - diff --git a/docs/src/cdist-hacker.rst b/docs/src/cdist-hacker.rst deleted file mode 100644 index e4252e19..00000000 --- a/docs/src/cdist-hacker.rst +++ /dev/null @@ -1,145 +0,0 @@ -Hacking -======= - -Welcome -------- -Welcome dear hacker! I invite you to a tour of pointers to -get into the usable configuration management system, cdist. - -The first thing to know is probably that cdist is brought to -you by people who care about how code looks like and who think -twice before merging or implementing a feature: Less features -with good usability are far better than the opposite. - - -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 code.ungleich.ch. - - -Coding conventions (everywhere) -------------------------------- -If something should be improved or needs to be fixed, add the word FIXME -nearby, so grepping for FIXME gives all positions that need to be fixed. - -Indentation is 4 spaces (welcome to the python world). - - -How to submit stuff for inclusion into upstream cdist ------------------------------------------------------ -If you did some cool changes to cdist, which you think might be of benefit to other -cdist users, you're welcome to propose inclusion into upstream. - -There are some requirements to ensure your changes don't break other peoples -work nor kill the authors brain: - -- All files should contain the usual header (Author, Copying, etc.) -- Code submission must be done via git -- Do not add cdist/conf/manifest/init - This file should only be touched in your - private branch! -- Code to be included should be branched of the upstream "master" branch - - - Exception: Bugfixes to a version branch - -- On a merge request, always name the branch I should pull from -- Always ensure **all** manpages build. Use **./build man** to test. -- If you developed more than **one** feature, consider submitting them in - separate branches. This way one feature can already be included, even if - the other needs to be improved. - -As soon as your work meets these requirements, write a mail -for inclusion to the mailinglist **cdist-configuration-management at googlegroups.com** -or open a merge request at https://code.ungleich.ch/ungleich-public/cdist. - - -How to submit a new type ------------------------- -For detailed information about types, see `cdist type `_. - -Submitting a type works as described above, with the additional requirement -that a corresponding manpage named man.rst in ReSTructured text format with -the manpage-name "cdist-type__NAME" is included in the type directory -AND the manpage builds (`make man`). - -Warning: Submitting "exec" or "run" types that simply echo their parameter in -**gencode** will not be accepted, because they are of no use. Every type can output -code and thus such a type introduces redundant functionality that is given by -core cdist already. - - -Example git workflow ---------------------- -The following workflow works fine for most developers - -.. code-block:: sh - - # get latest upstream master branch - git clone https://code.ungleich.ch/ungleich-public/cdist.git - - # update if already existing - cd cdist; git fetch -v; git merge origin/master - - # create a new branch for your feature/bugfix - cd cdist # if you haven't done before - git checkout -b documentation_cleanup - - # *hack* - *hack* - - # clone the cdist repository on code.ungleich.ch if you haven't done so - - # configure your repo to know about your clone (only once) - git remote add ungleich git@code.ungleich.ch:YOURUSERNAME/cdist.git - - # push the new branch to ungleich gitlab - git push ungleich documentation_cleanup - - # (or everything) - git push --mirror ungleich - - # create a merge request at ungleich gitlab (use a browser) - # *fixthingsbecausequalityassurancefoundissuesinourpatch* - *hack* - - # push code to ungleich gitlab again - git push ... # like above - - # add comment that everything should be green now (use a browser) - - # go back to master branch - git checkout master - - # update master branch that includes your changes now - git fetch -v origin - git diff master..origin/master - git merge origin/master - -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 - - # change to master and update to most recent upstream version - git checkout master - git fetch -v origin - git merge origin/master - -Similarly 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 - git merge origin/master - - git checkout -b another_feature - -(you can repeat the code above for as many features as you want to develop -in parallel) diff --git a/docs/src/cdist-install.rst b/docs/src/cdist-install.rst deleted file mode 100644 index a9b7d6b5..00000000 --- a/docs/src/cdist-install.rst +++ /dev/null @@ -1,159 +0,0 @@ -How to install cdist -==================== - -Requirements -------------- - -Source Host -~~~~~~~~~~~ - -This is the machine from which you will configure 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 man pages) - -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://code.ungleich.ch/ungleich-public/cdist.git - cd cdist - export PATH=$PATH:$(pwd -P)/bin - -From version 4.2.0 cdist tags and releases are signed. -You can get GPG public key used for signing `here <_static/pgp-key-EFD2AE4EC36B6901.asc>`_. - -You can also get cdist from `github mirror `_. - -To install cdist with distutils from cloned repository, first you have to -create version.py: - -.. code-block:: sh - - ./bin/build-helper version - -Then you install it with: - -.. code-block:: sh - - make install - -or with: - -.. code-block:: sh - - make install-user - -to install it into user *site-packages* directory. -Or directly with distutils: - -.. code-block:: sh - - python setup.py install - -Note that `bin/build-helper` script is intended for cdist maintainers. - - -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 - -Building and using documentation (man and html) -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -If you want to build and use the documentation, run: - -.. code-block:: sh - - make docs - -Documentation comes in two formats, man pages and full HTML -documentation. Documentation is built into distribution's -docs/dist directory. man pages are in docs/dist/man and -HTML documentation in docs/dist/html. - -If you want to use man pages, run: - -.. code-block:: sh - - export MANPATH=$MANPATH:$(pwd -P)/docs/dist/man - -Or you can move man pages from docs/dist/man directory to some -other directory and add it to MANPATH. - -Full HTML documentation can be accessed at docs/dist/html/index.html. - -You can also build only man pages or only html documentation, for -only man pages run: - -.. code-block:: sh - - make man - -for only html documentation run: - -.. code-block:: sh - - make html - -You can also build man pages for types in your ~/.cdist directory: - -.. code-block:: sh - - make dotman - -Built man pages are now in docs/dist/man directory. If you have -some other custom .cdist directory, e.g. /opt/cdist then use: - -.. code-block:: sh - - make DOT_CDIST_PATH=/opt/cdist dotman - -Note that `dotman`-target has to be built before a `make docs`-run, otherwise -the custom man-pages are not picked up. - -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/src/cdist-integration.rst b/docs/src/cdist-integration.rst deleted file mode 100644 index 13880cd3..00000000 --- a/docs/src/cdist-integration.rst +++ /dev/null @@ -1,47 +0,0 @@ -cdist integration / using cdist as library -========================================== - -Description ------------ - -cdist can be integrate with other applications by importing cdist and other -cdist modules and setting all by hand. There are also helper functions which -aim to ease this integration. Just import **cdist.integration** and use its -functions: - -* :strong:`cdist.integration.configure_hosts_simple` for configuration -* :strong:`cdist.integration.install_hosts_simple` for installation. - -Functions require `host` and `manifest` parameters. -`host` can be specified as a string representing host or as iterable -of hosts. `manifest` is a path to initial manifest. For other cdist -options default values will be used. `verbose` is a desired verbosity -level which defaults to VERBOSE_INFO. `cdist_path` parameter specifies -path to cdist executable, if it is `None` then functions will try to -find it first from local lib directory and then in PATH. - -In case of cdist error :strong:`cdist.Error` exception is raised. - -:strong:`WARNING`: cdist integration helper functions are not yet stable! - -Examples --------- - -.. code-block:: sh - - # configure host from python interactive shell - >>> import cdist.integration - >>> cdist.integration.configure_hosts_simple('185.203.114.185', - ... '~/.cdist/manifest/init') - - # configure host from python interactive shell, specifying verbosity level - >>> import cdist.integration - >>> cdist.integration.configure_hosts_simple( - ... '185.203.114.185', '~/.cdist/manifest/init', - ... verbose=cdist.argparse.VERBOSE_TRACE) - - # configure specified dns hosts from python interactive shell - >>> import cdist.integration - >>> hosts = ('dns1.ungleich.ch', 'dns2.ungleich.ch', 'dns3.ungleich.ch', ) - >>> cdist.integration.configure_hosts_simple(hosts, - ... '~/.cdist/manifest/init') diff --git a/docs/src/cdist-inventory.rst b/docs/src/cdist-inventory.rst deleted file mode 100644 index 106fcdb6..00000000 --- a/docs/src/cdist-inventory.rst +++ /dev/null @@ -1,211 +0,0 @@ -Inventory -========= - -Introduction ------------- - -cdist comes with simple built-in tag based inventory. It is a simple inventory -with list of hosts and a host has a list of tags. -Inventory functionality is still in **beta** so it can be used only if beta -command line flag is specified (-b, --beta) or setting CDIST_BETA env var. - -Description ------------ - -The idea is to have simple tagging inventory. There is a list of hosts and for -each host there are tags. Inventory database is a set of files under inventory -database base directory. Filename equals hostname. Each file contains tags for -hostname with each tag on its own line. - -Using inventory you can now configure hosts by selecting them by tags. - -Tags have no values, as tags are just tags. Tag name-value would in this -context mean that host has two tags and it is selected by specifying that both -tags are present. - -This inventory is **KISS** cdist built-in inventory database. You can maintain it -using cdist inventory interface or using standard UNIX tools. - -cdist inventory interface -------------------------- - -With cdist inventory interface you can list host(s) and tag(s), add host(s), -add tag(s), delete host(s) and delete tag(s). - -Configuring hosts using inventory ---------------------------------- - -config command now has new options, **-t**, **-a** and **-A**. - -**-A** means that all hosts in tag db is selected. - -**-a** means that selected hosts must contain ALL specified tags. - -**-t** means that host specifies tag - all hosts that have specified tags are -selected. - -Examples --------- - -.. code-block:: sh - - # List inventory content - $ cdist inventory list -b - - # List inventory for specified host localhost - $ cdist inventory list -b localhost - - # List inventory for specified tag loadbalancer - $ cdist inventory list -b -t loadbalancer - - # Add hosts to inventory - $ cdist inventory add-host -b web1 web2 web3 - - # Delete hosts from file old-hosts from inventory - $ cdist inventory del-host -b -f old-hosts - - # Add tags to specified hosts - $ cdist inventory add-tag -b -t europe,croatia,web,static web1 web2 - - # Add tag to all hosts in inventory - $ cdist inventory add-tag -b -t vm - - # Delete all tags from specified host - $ cdist inventory del-tag -b -a localhost - - # Delete tags read from stdin from hosts specified by file hosts - $ cdist inventory del-tag -b -T - -f hosts - - # Configure hosts from inventory with any of specified tags - $ cdist config -b -t web dynamic - - # Configure hosts from inventory with all specified tags - $ cdist config -b -t -a web dynamic - - # Configure all hosts from inventory db - $ cdist config -b -A - -Example of manipulating database --------------------------------- - -.. code-block:: sh - - $ python3 scripts/cdist inventory list -b - $ python3 scripts/cdist inventory add-host -b localhost - $ python3 scripts/cdist inventory add-host -b test.mycloud.net - $ python3 scripts/cdist inventory list -b - localhost - test.mycloud.net - $ python3 scripts/cdist inventory add-host -b web1.mycloud.net web2.mycloud.net shell1.mycloud.net shell2.mycloud.net - $ python3 scripts/cdist inventory list -b - localhost - test.mycloud.net - web1.mycloud.net - web2.mycloud.net - shell1.mycloud.net - shell2.mycloud.net - $ python3 scripts/cdist inventory add-tag -b -t web web1.mycloud.net web2.mycloud.net - $ python3 scripts/cdist inventory add-tag -b -t shell shell1.mycloud.net shell2.mycloud.net - $ python3 scripts/cdist inventory add-tag -b -t cloud - $ python3 scripts/cdist inventory list -b - localhost cloud - test.mycloud.net cloud - web1.mycloud.net cloud,web - web2.mycloud.net cloud,web - shell1.mycloud.net cloud,shell - shell2.mycloud.net cloud,shell - $ python3 scripts/cdist inventory add-tag -b -t test,web,shell test.mycloud.net - $ python3 scripts/cdist inventory list -b - localhost cloud - test.mycloud.net cloud,shell,test,web - web1.mycloud.net cloud,web - web2.mycloud.net cloud,web - shell1.mycloud.net cloud,shell - shell2.mycloud.net cloud,shell - $ python3 scripts/cdist inventory del-tag -b -t shell test.mycloud.net - $ python3 scripts/cdist inventory list -b - localhost cloud - test.mycloud.net cloud,test,web - web1.mycloud.net cloud,web - web2.mycloud.net cloud,web - shell1.mycloud.net cloud,shell - shell2.mycloud.net cloud,shell - $ python3 scripts/cdist inventory add-tag -b -t all - $ python3 scripts/cdist inventory add-tag -b -t mistake - $ python3 scripts/cdist inventory list -b - localhost all,cloud,mistake - test.mycloud.net all,cloud,mistake,test,web - web1.mycloud.net all,cloud,mistake,web - web2.mycloud.net all,cloud,mistake,web - shell1.mycloud.net all,cloud,mistake,shell - shell2.mycloud.net all,cloud,mistake,shell - $ python3 scripts/cdist inventory del-tag -b -t mistake - $ python3 scripts/cdist inventory list -b - localhost all,cloud - test.mycloud.net all,cloud,test,web - web1.mycloud.net all,cloud,web - web2.mycloud.net all,cloud,web - shell1.mycloud.net all,cloud,shell - shell2.mycloud.net all,cloud,shell - $ python3 scripts/cdist inventory del-host -b localhost - $ python3 scripts/cdist inventory list -b - test.mycloud.net all,cloud,test,web - web1.mycloud.net all,cloud,web - web2.mycloud.net all,cloud,web - shell1.mycloud.net all,cloud,shell - shell2.mycloud.net all,cloud,shell - $ python3 scripts/cdist inventory list -b -t web - test.mycloud.net all,cloud,test,web - web1.mycloud.net all,cloud,web - web2.mycloud.net all,cloud,web - $ python3 scripts/cdist inventory list -b -t -a web test - test.mycloud.net all,cloud,test,web - $ python3 scripts/cdist inventory list -b -t -a web all - test.mycloud.net all,cloud,test,web - web1.mycloud.net all,cloud,web - web2.mycloud.net all,cloud,web - $ python3 scripts/cdist inventory list -b -t web all - test.mycloud.net all,cloud,test,web - web1.mycloud.net all,cloud,web - web2.mycloud.net all,cloud,web - shell1.mycloud.net all,cloud,shell - shell2.mycloud.net all,cloud,shell - $ cd cdist/inventory - $ ls -1 - shell1.mycloud.net - shell2.mycloud.net - test.mycloud.net - web1.mycloud.net - web2.mycloud.net - $ ls -l - total 20 - -rw-r--r-- 1 darko darko 16 Jun 24 12:43 shell1.mycloud.net - -rw-r--r-- 1 darko darko 16 Jun 24 12:43 shell2.mycloud.net - -rw-r--r-- 1 darko darko 19 Jun 24 12:43 test.mycloud.net - -rw-r--r-- 1 darko darko 14 Jun 24 12:43 web1.mycloud.net - -rw-r--r-- 1 darko darko 14 Jun 24 12:43 web2.mycloud.net - $ cat test.mycloud.net - test - all - web - cloud - $ cat web2.mycloud.net - all - web - cloud - -For more info about inventory commands and options see `cdist `_\ (1). - -Using external inventory ------------------------- - -cdist can be used with any external inventory where external inventory is -some storage or database from which you can get a list of hosts to configure. -cdist can then be fed with this list of hosts through stdin or file using -**-f** option. For example, if your host list is stored in sqlite3 database -hosts.db and you want to select hosts which purpose is **django** then you -can use it with cdist like: - -.. code-block:: sh - - $ sqlite3 hosts.db "select hostname from hosts where purpose = 'django';" | cdist config diff --git a/docs/src/cdist-manifest.rst b/docs/src/cdist-manifest.rst deleted file mode 100644 index 4dd3e74b..00000000 --- a/docs/src/cdist-manifest.rst +++ /dev/null @@ -1,257 +0,0 @@ -Manifest -======== - -Description ------------ -Manifests are used to define which objects to create. -Objects are instances of **types**, like in object oriented programming languages. -An object is represented by the combination of -**type + slash + object name**: **\__file/etc/cdist-configured** is an -object of the type **__file** with the name **etc/cdist-configured**. - -All available types can be found in the **cdist/conf/type/** directory, -use **ls cdist/conf/type** to get the list of available types. If you have -setup the MANPATH correctly, you can use **man cdist-reference** to access -the reference with pointers to the manpages. - - -Types in manifests are used like normal command line tools. Let's have a look -at an example:: - - # Create object of type __package with the parameter state = absent - __package apache2 --state absent - - # Same with the __directory type - __directory /tmp/cdist --state present - -These two lines create objects, which will later be used to realise the -configuration on the target host. - -Manifests are executed locally as a shell script using **/bin/sh -e**. -The resulting objects are stored in an internal database. - -The same object can be redefined in multiple different manifests as long as -the parameters are exactly the same. - -In general, manifests are used to define which types are used depending -on given conditions. - - -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 `_. - - -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. -Cdist expects the initial manifest at **cdist/conf/manifest/init**. - -Within this initial manifest you define which objects should be -created on which host. To distinguish between hosts, you can use the -environment variable **__target_host** and/or **__target_hostname** and/or -**__target_fqdn**. Let's have a look at a simple example:: - - __cdistmarker - - case "$__target_host" in - localhost) - __directory /home/services/kvm-vm --parents yes - ;; - esac - -This manifest says: Independent of the host, always use the type -**__cdistmarker**, which creates the file **/etc/cdist-configured**, -with the timestamp as content. -The directory **/home/services/kvm-vm**, including all parent directories, -is only created on the host **localhost**. - -As you can see, there is no magic involved, the manifest is simple shell code that -utilises cdist types. Every available type can be executed like a normal -command. - - -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 `_). - -The following example would include every file with a **.sh** suffix:: - - # Include *.sh - for manifest in $__manifest/*.sh; do - # And source scripts into our shell environment - . "$manifest" - done - - -Dependencies ------------- -If you want to describe that something requires something else, just -setup the variable "require" to contain the requirements. Multiple -requirements can be added white space separated. - -:: - - 1 # No dependency - 2 __file /etc/cdist-configured - 3 - 4 # Require above object - 5 require="__file/etc/cdist-configured" __link /tmp/cdist-testfile \ - 6 --source /etc/cdist-configured --type symbolic - 7 - 8 # Require two objects - 9 require="__file/etc/cdist-configured __link/tmp/cdist-testfile" \ - 10 __file /tmp/cdist-another-testfile - - -Above the "require" variable is only set for the command that is -immediately following it. Dependencies should always be declared that way. - -On line 4 you can see that the instantiation of a type "\__link" object needs -the object "__file/etc/cdist-configured" to be present, before it can proceed. - -This also means that the "\__link" command must make sure, that either -"\__file/etc/cdist-configured" already is present, or, if it's not, it needs -to be created. The task of cdist is to make sure, that the dependency will be -resolved appropriately and thus "\__file/etc/cdist-configured" be created -if necessary before "__link" proceeds (or to abort execution with an error). - -If you really need to make all types depend on a common dependency, you can -export the "require" variable as well. But then, if you need to add extra -dependencies to a specific type, you have to make sure that you append these -to the globally already defined one. - -:: - - # First of all, update the package index - __package_update_index - # Upgrade all the installed packages afterwards - require="__package_update_index" __package_upgrade_all - # Create a common dependency for all the next types so that they get to - # be executed only after the package upgrade has finished - export require="__package_upgrade_all" - - # Ensure that lighttpd is installed after we have upgraded all the packages - __package lighttpd --state present - # Ensure that munin is installed after lighttpd is present and after all - # the packages are upgraded - require="$require __package/lighttpd" __package munin --state present - - -All objects that are created in a type manifest are automatically required -from the type that is calling them. This is called "autorequirement" in -cdist jargon. - -You can find a more in depth description of the flow execution of manifests -in `cdist execution stages `_ and of how types work in `cdist type `_. - - -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. -When cdist sees that this variable is setup, the current created object -automatically depends on the previously created object. - -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). - -Read also about `perils of CDIST_ORDER_DEPENDENCY `_. - - -Overrides ---------- -In some special cases, you would like to create an already defined object -with different parameters. In normal situations this leads to an error in cdist. -If you wish, you can setup the environment variable CDIST_OVERRIDE -(any value or even empty is ok) to tell cdist, that this object override is -wanted and should be accepted. -ATTENTION: Only use this feature if you are 100% sure in which order -cdist encounters the affected objects, otherwise this results -in an undefined situation. - -If CDIST_OVERRIDE and CDIST_ORDER_DEPENDENCY are set for an object, -CDIST_ORDER_DEPENDENCY will be ignored, because adding a dependency in case of -overrides would result in circular dependencies, which is an error. - - -Examples --------- -The initial manifest may for instance contain the following code: - -.. code-block:: sh - - # Always create this file, so other sysadmins know cdist is used. - __file /etc/cdist-configured - - case "$__target_host" in - my.server.name) - __directory /root/bin/ - __file /etc/issue.net --source "$__manifest/issue.net - ;; - esac - -The manifest of the type "nologin" may look like this: - -.. code-block:: sh - - __file /etc/nologin --source "$__type/files/default.nologin" - -This example makes use of dependencies: - -.. code-block:: sh - - # Ensure that lighttpd is installed - __package lighttpd --state present - # Ensure that munin makes use of lighttpd instead of the default webserver - # package as decided by the package manager - require="__package/lighttpd" __package munin --state present - -How to override objects: - -.. code-block:: sh - - # for example in the initial manifest - - # create user account foobar with some hash for password - __user foobar --password 'some_fancy_hash' --home /home/foobarexample - - # ... many statements and includes in the manifest later ... - # somewhere in a conditionally sourced manifest - # (e.g. for example only sourced if a special application is on the target host) - - # this leads to an error ... - __user foobar --password 'some_other_hash' - - # this tells cdist, that you know that this is an override and should be accepted - CDIST_OVERRIDE=yes __user foobar --password 'some_other_hash' - # it's only an override, means the parameter --home is not touched - # and stays at the original value of /home/foobarexample - -Dependencies defined by execution order work as following: - -.. code-block:: sh - - # Tells cdist to execute all types in the order in which they are created ... - export CDIST_ORDER_DEPENDENCY=on - __sample_type 1 - require="__some_type_somewhere/id" __sample_type 2 - __example_type 23 - # Now this types are executed in the creation order until the variable is unset - unset CDIST_ORDER_DEPENDENCY - # all now following types cdist makes the order .. - __not_in_order_type 42 - - # how it works : - # this lines above are translated to: - __sample_type 1 - require="__some_type_somewhere/id __sample_type/1" __sample_type 2 - require="__sample_type/2" __example_type 23 - __not_in_order_type 42 diff --git a/docs/src/cdist-messaging.rst b/docs/src/cdist-messaging.rst deleted file mode 100644 index ea35c404..00000000 --- a/docs/src/cdist-messaging.rst +++ /dev/null @@ -1,94 +0,0 @@ -Messaging -========= - -Description ------------ -cdist has a simple but powerful way of allowing communication between -the initial manifest and types as well as types and types. - -Whenever execution is passed from cdist to one of the -scripts described below, cdist generate 2 new temporary files -and exports the environment variables **__messages_in** and -**__messages_out** to point to them. - -Before handing over the control, the content of the global message -file is copied into the file referenced by **$__messages_in**. - -After cdist gained control back, the content of the file referenced -by **$__messages_out** is appended to the global message file. - -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 `_) and thus you -can only react reliably on messages by objects that you depend on. - - -Availability ------------- -Messaging is possible between all **local** scripts: - -- initial manifest -- type/manifest -- type/gencode-local -- type/gencode-remote - - -Examples --------- -When you want to emit a message use: - -.. code-block:: sh - - echo "something" >> "$__messages_out" - -When you want to react on a message use: - -.. code-block:: sh - - if grep -q "^__your_type/object/id:something" "$__messages_in"; then - echo "I do something else" - fi - -Some real life examples: - -.. code-block:: sh - - # Reacting on changes from block for keepalive - if grep -q "^__block/keepalive-vrrp" "$__messages_in"; then - echo /etc/init.d/keepalived restart - fi - - # Reacting on changes of configuration files - if grep -q "^__file/etc/one" $__messages_in; then - echo 'for init in /etc/init.d/opennebula*; do $init restart; done' - fi - -Restart sshd on changes - -.. code-block:: sh - - os="$(cat "$__global/explorer/os")" - - case "$os" in - centos|redhat|suse) - restart="/etc/init.d/sshd restart" - ;; - debian|ubuntu) - restart="/etc/init.d/ssh restart" - ;; - *) - cat << eof >&2 - Unsupported os $os. - If you would like to have this type running on $os, - you can either develop the changes and send a pull - request or ask for a quote at www.ungleich.ch - eof - exit 1 - ;; - esac - - if grep -q "^__key_value/PermitRootLogin" "$__messages_in"; then - echo $restart - fi diff --git a/docs/src/cdist-os.rst b/docs/src/cdist-os.rst deleted file mode 100644 index a8e31226..00000000 --- a/docs/src/cdist-os.rst +++ /dev/null @@ -1,19 +0,0 @@ -Supported operating systems -=========================== - -cdist was tested or is know to run on at least - -* `Alpine Linux `_ -* `Archlinux `_ -* `CentOS `_ -* `Debian `_ -* `Devuan `_ -* `Fedora `_ -* `FreeBSD `_ -* `Gentoo `_ -* `Mac OS X `_ -* `NetBSD `_ -* `OpenBSD `_ -* `Redhat `_ -* `Ubuntu `_ -* `XenServer `_ diff --git a/docs/src/cdist-parallelization.rst b/docs/src/cdist-parallelization.rst deleted file mode 100644 index d458a128..00000000 --- a/docs/src/cdist-parallelization.rst +++ /dev/null @@ -1,73 +0,0 @@ -Parallelization -=============== - -Description ------------ -cdist has two modes of parallel operation. - -One of them is to operate on each host in separate process. This is enabled -with :strong:`-p/--parallel` option. - -The other way is to operate in parallel within one host where you specify -the number of jobs. This is enabled with :strong:`-j/--jobs` option where you -can specify the number of parallel jobs. By default, -:strong:`multiprocessing.cpu_count()` is used. For this mode global explorers, -object preparation and object run are supported. - -You can, of course, use those two options together. This means that each host -will be processed by its own process. Within each process cdist will operate -using specified number of parallel jobs. - -For more info on those options see :strong:`cdist`\ (1). - - -Examples --------- - -.. code-block:: sh - - # Configure hosts read from file hosts.file in parallel - $ cdist config -p -f hosts.file - - # Configure hosts read from file hosts.file sequentially but using default - # number of parallel jobs - $ cdist config -j -f hosts.file - - # Configure hosts read from file hosts.file in parallel using 16 - # parallel jobs - $ cdist config -j 16 -p -f hosts.file - - -Caveats -------- -When operating in parallel, either by operating in parallel for each host -(-p/--parallel) or by parallel jobs within a host (-j/--jobs), and depending -on target SSH server and its configuration you may encounter connection drops. -This is controlled with sshd :strong:MaxStartups configuration options. -You may also encounter session open refusal. This happens with ssh multiplexing -when you reach maximum number of open sessions permitted per network -connection. In this case ssh will disable multiplexing. -This limit is controlled with sshd :strong:MaxSessions configuration -options. For more details refer to :strong:`sshd_config`\ (5). - -For example, if you reach :strong:`MaxSessions` sessions you may get the -following output: - -.. code-block:: sh - - $ cdist config -b -j 11 -v 78.47.116.244 - INFO: cdist: version 4.2.2-55-g640b7f9 - INFO: 78.47.116.244: Running global explorers - INFO: 78.47.116.244: Remote transfer in 11 parallel jobs - channel 22: open failed: administratively prohibited: open failed - mux_client_request_session: session request failed: Session open refused by peer - ControlSocket /tmp/tmpuah6fw_t/d886d4b7e4425a102a54bfaff4d2288b/ssh-control-path already exists, disabling multiplexing - INFO: 78.47.116.244: Running global explorers in 11 parallel jobs - channel 22: open failed: administratively prohibited: open failed - mux_client_request_session: session request failed: Session open refused by peer - ControlSocket /tmp/tmpuah6fw_t/d886d4b7e4425a102a54bfaff4d2288b/ssh-control-path already exists, disabling multiplexing - INFO: 78.47.116.244: Running initial manifest /tmp/tmpuah6fw_t/d886d4b7e4425a102a54bfaff4d2288b/data/conf/manifest/init - INFO: 78.47.116.244: Running manifest and explorers for __file/root/host.file - INFO: 78.47.116.244: Generating code for __file/root/host.file - INFO: 78.47.116.244: Finished successful run in 18.655028820037842 seconds - INFO: cdist: Total processing time for 1 host(s): 19.159148693084717 diff --git a/docs/src/cdist-quickstart.rst b/docs/src/cdist-quickstart.rst deleted file mode 100644 index 99af869f..00000000 --- a/docs/src/cdist-quickstart.rst +++ /dev/null @@ -1,77 +0,0 @@ -Quickstart -========== - -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. - -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** -of the target host to allow root logins: Edit -the file **/etc/ssh/sshd_config** and add one of the following -lines:: - - # Allow login only via public key - PermitRootLogin without-password - - # Allow login via password and public key - PermitRootLogin yes - -As cdist uses ssh intensively, it is recommended to setup authentication -with public keys:: - - # Generate pubkey pair as a normal user - ssh-keygen - - # Copy pubkey over to target host - ssh-copy-id root@localhost - -Have a look at ssh-agent(1) and ssh-add(1) on how to cache the password for -your public key. Usually it looks like this:: - - # Start agent and export variables - eval `ssh-agent` - - # Add keys (requires password for every identity file) - ssh-add - -At this point you should be able to **ssh root@localhost** without -re-entering the password. If something failed until here, ensure that -all steps went successfully and you have read and understood the -documentation. - -As soon as you are able to login without password to localhost, -we can use cdist to configure it. You can copy and paste the following -code into your shell to get started and configure localhost:: - - # Get cdist - git clone git@code.ungleich.ch:ungleich-public/cdist.git - - # Create manifest (maps configuration to host(s) - cd cdist - echo '__file /etc/cdist-configured' > cdist/conf/manifest/init - - # Configure localhost in verbose mode - ./bin/cdist config -v localhost - - # Find out that cdist created /etc/cdist-configured - ls -l /etc/cdist-configured - -Note: cdist/conf is configuration directory shipped with cdist distribution. -If exists, ~/.cdist, is also automatically used as cdist configuration -directory. So in the above example you could create ~/.cdist directory, -then ~/.cdist/manifest sub-directory and create init manifest -~/.cdist/manifest/init. - -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. diff --git a/docs/src/cdist-real-world.rst b/docs/src/cdist-real-world.rst deleted file mode 100644 index 8ccb0fc9..00000000 --- a/docs/src/cdist-real-world.rst +++ /dev/null @@ -1,573 +0,0 @@ -Dive into real world cdist -========================== - -Introduction ------------- - -This walkthrough shows real world cdist configuration example. - -Sample target host is named **test.ungleich.ch**. -Just replace **test.ungleich.ch** with your target hostname. - -Our goal is to configure python application hosting. For writing sample -application we will use `Bottle `_ WSGI micro web-framework. -It will use PostgreSQL database and it will list items from **items** table. -It will be served by uWSGI server. We will also use the Nginx web server -as a reverse proxy and we want HTTPS. -For HTTPS we will use Let's Encrypt certificate. - -For setting up hosting we want to use cdist so we will write a new type -for that. This type will: - -- install required packages -- create OS user, user home directory and application home directory -- create PostgreSQL database -- configure uWSGI -- configure Let's Encrypt certificate -- configure nginx. - -Our type will not create the actual python application. Its intention is only -to configure hosing for specified user and project. It is up to the user to -create his/her applications. - -So let's start. - -Creating type layout --------------------- - -We will create a new custom type. Let's call it **__sample_bottle_hosting**. - -Go to **~/.cdist/type** directory (create it if it does not exist) and create -new type layout:: - - cd ~/.cdist/type - mkdir __sample_bottle_hosting - cd __sample_bottle_hosting - touch manifest gencode-remote - mkdir parameter - touch parameter/required - -Creating __sample_bottle_hosting type parameters ------------------------------------------------- - -Our type will be configurable through the means of parameters. Let's define -the following parameters: - -projectname - name for the project, needed for uWSGI ini file - -user - user name - -domain - target host domain, needed for Let's Encrypt certificate. - -We define parameters to make our type reusable for different projects, user and domain. - -Define required parameters:: - - printf "projectname\n" >> parameter/required - printf "user\n" >> parameter/required - printf "domain\n" >> parameter/required - -For details on type parameters see `Defining parameters `_. - -Creating __sample_bottle_hosting type manifest ----------------------------------------------- - -Next step is to define manifest (~/.cdist/type/__sample_bottle_hosting/manifest). -We also want our type to currently support only Devuan. So we will start by -checking target host OS. We will use `os `_ -global explorer:: - - os=$(cat "$__global/explorer/os") - - case "$os" in - devuan) - : - ;; - *) - echo "OS $os currently not supported" >&2 - exit 1 - ;; - esac - -If target host OS is not Devuan then we print error message to stderr -and exit. For other OS-es support we should check and change package names -we should install, because packages differ in different OS-es and in different -OS distributions like GNU/Linux distributions. There can also be a different -configuration locations (e.g. nginx config directory could be in /usr/local tree). -If we detected unsupported OS we should error out. cdist will stop configuration -process and output error message. - -Creating user and user directories -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -Then we create user and his/her home directory and application home directory. -We will use existing cdist types `__user `_ and `__directory `_:: - - user="$(cat "$__object/parameter/user")" - home="/home/$user" - apphome="$home/app" - - # create user - __user "$user" --home "$home" --shell /bin/bash - # create user home dir - require="__user/$user" __directory "$home" \ - --owner "$user" --group "$user" --mode 0755 - # create app home dir - require="__user/$user __directory/$home" __directory "$apphome" \ - --state present --owner "$user" --group "$user" --mode 0755 - -First we define *user*, *home* and *apphome* variables. User is defined by type's -**user** parameter. Here we use **require** which is cdist's way to define dependencies. -User home directory should be created **after** user is created. And application -home directory is created **after** both user and user home directory are created. -For details on **require** see `Dependencies `_. - -Installing packages -~~~~~~~~~~~~~~~~~~~ - -Install required packages using existing `__package `_ type. -Before installing package we want to update apt package index using -`__apt_update_index `_:: - - # define packages that need to be installed - packages_to_install="nginx uwsgi-plugin-python3 python3-dev python3-pip postgresql postgresql-contrib libpq-dev python3-venv uwsgi python3-psycopg2" - - # update package index - __apt_update_index - # install packages - for package in $packages_to_install - do require="__apt_update_index" __package $package --state=present - done - -Here we use shell for loop. It executes **require="__apt_update_index" __package** -for each member in a list we define in **packages_to_install** variable. -This is much nicer then having as many **require="__apt_update_index" __package** -lines as there are packages we want to install. - -For python packages we use `__package_pip `_:: - - # install pip3 packages - for package in bottle bottle-pgsql; do - __package_pip --pip pip3 $package - done - -Creating PostgreSQL database -~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -Create PostgreSQL database using `__postgres_database `_ -and `__postgres_role `_ for creating database user:: - - #PostgreSQL db & user - postgres_server=postgresql - - # create PostgreSQL db user - require="__package/postgresql" __postgres_role $user --login --createdb - # create PostgreSQL db - require="__postgres_role/$user __package/postgresql" __postgres_database $user \ - --owner $user - -Configuring uWSGI -~~~~~~~~~~~~~~~~~ - -Configure uWSGI using `__file `_ type:: - - # configure uWSGI - projectname="$(cat "$__object/parameter/projectname")" - require="__package/uwsgi" __file /etc/uwsgi/apps-enabled/$user.ini \ - --owner root --group root --mode 0644 \ - --state present \ - --source - << EOF - [uwsgi] - socket = $apphome/uwsgi.sock - chdir = $apphome - wsgi-file = $projectname/wsgi.py - touch-reload = $projectname/wsgi.py - processes = 4 - threads = 2 - chmod-socket = 666 - daemonize=true - vacuum = true - uid = $user - gid = $user - EOF - -We require package uWSGI present in order to create **/etc/uwsgi/apps-enabled/$user.ini** file. -Installation of uWSGI also creates configuration layout: **/etc/uwsgi/apps-enabled**. -If this directory does not exist then **__file** type would error. -We also use stdin as file content source. For details see `Input from stdin `_. -For feading stdin we use here-document (**<<** operator). It allows redirection of subsequent -lines read by the shell to the input of a command until a line containing only the delimiter -and a newline, with no blank characters in between (EOF in our case). - -Configuring nginx for Let's Encrypt and HTTPS redirection -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -Next configure nginx for Let's Encrypt and for HTTP -> HTTPS redirection. For this -purpose we will create new type **__sample_nginx_http_letsencrypt_and_ssl_redirect** -and use it here:: - - domain="$(cat "$__object/parameter/domain")" - webroot="/var/www/html" - __sample_nginx_http_letsencrypt_and_ssl_redirect "$domain" --webroot "$webroot" - -Configuring certificate creation -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -After HTTP nginx configuration we will create Let's Encrypt certificate using -`__letsencrypt_cert `_ type. -For Let's Encrypt cert configuration ensure that there is a DNS entry for your -domain. We assure that cert creation is applied after nginx HTTP is configured -for Let's Encrypt to work:: - - # create SSL cert - require="__package/nginx __sample_nginx_http_letsencrypt_and_ssl_redirect/$domain" \ - __letsencrypt_cert --admin-email admin@test.ungleich.ch \ - --webroot "$webroot" \ - --automatic-renewal \ - --renew-hook "service nginx reload" \ - --domain "$domain" \ - "$domain" - -Configuring nginx HTTPS server with uWSGI upstream -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -Then we can configure nginx HTTPS server that will use created Let's Encrypt certificate:: - - # configure nginx - require="__package/nginx __letsencrypt_cert/$domain" \ - __file "/etc/nginx/sites-enabled/https-$domain" \ - --source - --mode 0644 << EOF - upstream _bottle { - server unix:$apphome/uwsgi.sock; - } - - server { - listen 443; - listen [::]:443; - - server_name $domain; - - access_log /var/log/nginx/access.log; - - ssl on; - ssl_certificate /etc/letsencrypt/live/$domain/fullchain.pem; - ssl_certificate_key /etc/letsencrypt/live/$domain/privkey.pem; - - client_max_body_size 256m; - - location / { - try_files \$uri @uwsgi; - } - - location @uwsgi { - include uwsgi_params; - uwsgi_pass _bottle; - } - } - EOF - -Now our manifest is finished. - -Complete __sample_bottle_hosting type manifest listing -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -Here is complete __sample_bottle_hosting type manifest listing, -located in ~/.cdist/type/__sample_bottle_hosting/manifest:: - - #!/bin/sh - - os=$(cat "$__global/explorer/os") - - case "$os" in - devuan) - : - ;; - *) - echo "OS $os currently not supported" >&2 - exit 1 - ;; - esac - - projectname="$(cat "$__object/parameter/projectname")" - user="$(cat "$__object/parameter/user")" - home="/home/$user" - apphome="$home/app" - domain="$(cat "$__object/parameter/domain")" - - # create user - __user "$user" --home "$home" --shell /bin/bash - # create user home dir - require="__user/$user" __directory "$home" \ - --owner "$user" --group "$user" --mode 0755 - # create app home dir - require="__user/$user __directory/$home" __directory "$apphome" \ - --state present --owner "$user" --group "$user" --mode 0755 - - # define packages that need to be installed - packages_to_install="nginx uwsgi-plugin-python3 python3-dev python3-pip postgresql postgresql-contrib libpq-dev python3-venv uwsgi python3-psycopg2" - - # update package index - __apt_update_index - # install packages - for package in $packages_to_install - do require="__apt_update_index" __package $package --state=present - done - # install pip3 packages - for package in bottle bottle-pgsql; do - __package_pip --pip pip3 $package - done - - #PostgreSQL db & user - postgres_server=postgresql - - # create PostgreSQL db user - require="__package/postgresql" __postgres_role $user --login --createdb - # create PostgreSQL db - require="__postgres_role/$user __package/postgresql" __postgres_database $user \ - --owner $user - # configure uWSGI - require="__package/uwsgi" __file /etc/uwsgi/apps-enabled/$user.ini \ - --owner root --group root --mode 0644 \ - --state present \ - --source - << EOF - [uwsgi] - socket = $apphome/uwsgi.sock - chdir = $apphome - wsgi-file = $projectname/wsgi.py - touch-reload = $projectname/wsgi.py - processes = 4 - threads = 2 - chmod-socket = 666 - daemonize=true - vacuum = true - uid = $user - gid = $user - EOF - - # setup nginx HTTP for Let's Encrypt and SSL redirect - domain="$(cat "$__object/parameter/domain")" - webroot="/var/www/html" - __sample_nginx_http_letsencrypt_and_ssl_redirect "$domain" --webroot "$webroot" - - # create SSL cert - require="__package/nginx __sample_nginx_http_letsencrypt_and_ssl_redirect/$domain" \ - __letsencrypt_cert --admin-email admin@test.ungleich.ch \ - --webroot "$webroot" \ - --automatic-renewal \ - --renew-hook "service nginx reload" \ - --domain "$domain" \ - "$domain" - - # configure nginx - require="__package/nginx __letsencrypt_cert/$domain" \ - __file "/etc/nginx/sites-enabled/https-$domain" \ - --source - --mode 0644 << EOF - upstream _bottle { - server unix:$apphome/uwsgi.sock; - } - - server { - listen 443; - listen [::]:443; - - server_name $domain; - - access_log /var/log/nginx/access.log; - - ssl on; - ssl_certificate /etc/letsencrypt/live/$domain/fullchain.pem; - ssl_certificate_key /etc/letsencrypt/live/$domain/privkey.pem; - - client_max_body_size 256m; - - location / { - try_files \$uri @uwsgi; - } - - location @uwsgi { - include uwsgi_params; - uwsgi_pass _bottle; - } - } - EOF - -Creating __sample_bottle_hosting type gencode-remote ----------------------------------------------------- - -Now define **gencode-remote** script: ~/.cdist/type/__sample_bottle_hosting/gencode-remote. -After manifest is applied it should restart uWSGI and nginx services so that our -configuration is active. Our gencode-remote looks like the following:: - - echo "service uwsgi restart" - echo "service nginx restart" - -Our **__sample_bottle_hosting** type is now finished. - -Creating __sample_nginx_http_letsencrypt_and_ssl_redirect type --------------------------------------------------------------- - -Let's now create **__sample_nginx_http_letsencrypt_and_ssl_redirect** type:: - - cd ~/.cdist/type - mkdir __sample_nginx_http_letsencrypt_and_ssl_redirect - cd __sample_nginx_http_letsencrypt_and_ssl_redirect - mkdir parameter - echo webroot > parameter/required - touch manifest - touch gencode-remote - -Edit manifest:: - - domain="$__object_id" - webroot="$(cat "$__object/parameter/webroot")" - # make sure we have nginx package - __package nginx - # setup Let's Encrypt HTTP acme challenge, redirect HTTP to HTTPS - require="__package/nginx" __file "/etc/nginx/sites-enabled/http-$domain" \ - --source - --mode 0644 << EOF - server { - listen *:80; - listen [::]:80; - - server_name $domain; - - # Let's Encrypt - location /.well-known/acme-challenge/ { - root $webroot; - } - - # Everything else -> SSL - location / { - return 301 https://\$host\$request_uri; - } - } - - EOF - -Edit gencode-remote:: - - echo "service nginx reload" - -Creating init manifest ----------------------- - -Next create init manifest:: - - cd ~/.cdist/manifest - printf "__sample_bottle_hosting --projectname sample --user app --domain \$__target_host sample\n" > sample - -Using this init manifest our target host will be configured using our **__sample_bottle_hosting** -type with projectname *sample*, user *app* and domain equal to **__target_host**. -Here the last positional argument *sample* is type's object id. For details on -**__target_host** and **__object_id** see -`Environment variables (for reading) `_ -reference. - -Configuring host ----------------- - -Finally configure test.ungleich.ch:: - - cdist config -v -i ~/.cdist/manifest/sample test.ungleich.ch - -After cdist configuration is successfully finished our host is ready. - -Creating python bottle application ----------------------------------- - -We now need to create Bottle application. As you remember from the beginning -of this walkthrough our type does not create the actual python application, -its intention is only to configure hosing for specified user and project. -It is up to the user to create his/her applications. - -Become app user:: - - su -l app - -Preparing database -~~~~~~~~~~~~~~~~~~ - -We need to prepare database for our application. Create table and -insert some items:: - - psql -c "create table items (item varchar(255));" - - psql -c "insert into items(item) values('spam');" - psql -c "insert into items(item) values('eggs');" - psql -c "insert into items(item) values('sausage');" - -Creating application -~~~~~~~~~~~~~~~~~~~~ - -Next create sample app:: - - cd /home/app/app - mkdir sample - cd sample - -Create app.py with the following content:: - - #!/usr/bin/env python3 - - import bottle - import bottle_pgsql - - app = application = bottle.Bottle() - plugin = bottle_pgsql.Plugin('dbname=app user=app password=') - app.install(plugin) - - @app.route('/') - def show_index(db): - db.execute('select * from items') - items = db.fetchall() or [] - rv = '

Items:

    ' - for item in items: - rv += '
  • ' + str(item['item']) + '
  • ' - rv += '
' - return rv - - if __name__ == '__main__': - bottle.run(app=app, host='0.0.0.0', port=8080) - -Create wsgi.py with the following content:: - - import os - - os.chdir(os.path.dirname(__file__)) - - import app - application = app.app - -We have configured uWSGI with **touch-reload = $projectname/wsgi.py** so after -we have changed our **wsgi.py** file uWSGI reloads the application. - -Our application selects and lists items from **items** table. - -Openning application -~~~~~~~~~~~~~~~~~~~~ - -Finally try the application:: - - http://test.ungleich.ch/ - -It should redirect to HTTPS and return: - -.. container:: highlight - - .. raw:: html - -

Items:

- -
    -
  • spam
  • -
  • eggs
  • -
  • sausage
  • -
- -What's next? ------------- - -Continue reading next sections ;) diff --git a/docs/src/cdist-reference.rst.sh b/docs/src/cdist-reference.rst.sh deleted file mode 100755 index f4a37816..00000000 --- a/docs/src/cdist-reference.rst.sh +++ /dev/null @@ -1,346 +0,0 @@ -#!/bin/sh -# -# 2010-2014 Nico Schottelius (nico-cdist at schottelius.org) -# 2014 Daniel Heule (hda at sfs.biz) -# -# This file is part of cdist. -# -# cdist is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# cdist is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with cdist. If not, see . -# -# -# Generate manpage that lists available types -# - -__cdist_pwd="$(pwd -P)" -__cdist_mydir="${0%/*}"; -__cdist_abs_mydir="$(cd "$__cdist_mydir" && pwd -P)" -__cdist_myname=${0##*/}; -__cdist_abs_myname="$__cdist_abs_mydir/$__cdist_myname" - -filename="${__cdist_myname%.sh}" -dest="$__cdist_abs_mydir/$filename" - -cd "$__cdist_abs_mydir" - -exec > "$dest" -cat << eof -Reference -========= -Variable, path and type reference for cdist - -Explorers ---------- -The following global explorers are available: - -eof -( - cd ../../cdist/conf/explorer - for explorer in $(ls * | LC_ALL=C sort); do - echo "- $explorer" - done -) - -cat << eof - -Paths ------ -\$HOME/.cdist - The standard cdist configuration directory relative to your home directory. - This is usually the place you want to store your site specific configuration. - -cdist/conf/ - The distribution configuration directory. - This contains types and explorers to be used. - -cdist/inventory/ - The distribution inventory directory. - This path is relative to cdist installation directory. - -confdir - Cdist will use all available configuration directories and create - a temporary confdir containing links to the real configuration directories. - This way it is possible to merge configuration directories. - By default it consists of everything in \$HOME/.cdist and cdist/conf/. - For more details see cdist(1). - -confdir/files/ - Cdist does not care about this directory besides providing access to it. - It is thought to be a general file storage area. - -confdir/manifest/init - This is the central entry point. - It is an executable (+x bit set) shell script that can use - values from the explorers to decide which configuration to create - for the specified target host. - Its intent is to used to define mapping from configurations to hosts. - -confdir/manifest/* - All other files in this directory are not directly used by cdist, but you - can separate configuration mappings, if you have a lot of code in the - conf/manifest/init file. This may also be helpful to have different admins - maintain different groups of hosts. - -confdir/explorer/ - 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 \`_. - -confdir/type// - Home of the type . - This directory is referenced by the variable __type (see below). - -confdir/type//man.rst - Manpage in reStructuredText format (required for inclusion into upstream). - -confdir/type//manifest - Used to generate additional objects from a type. - -confdir/type//gencode-local - Used to generate code to be executed on the source host. - -confdir/type//gencode-remote - Used to generate code to be executed on the target host. - -confdir/type//parameter/required - Parameters required by type, \n separated list. - -confdir/type//parameter/optional - Parameters optionally accepted by type, \n separated list. - -confdir/type//parameter/default/* - Default values for optional parameters. - Assuming an optional parameter name of 'foo', it's default value would - be read from the file confdir/type//parameter/default/foo. - -confdir/type//parameter/boolean - Boolean parameters accepted by type, \n separated list. - -confdir/type//explorer - Location of the type specific explorers. - This directory is referenced by the variable __type_explorer (see below). - See \`cdist explorer \`_. - -confdir/type//files - This directory is reserved for user data and will not be used - by cdist at any time. It can be used for storing supplementary - files (like scripts to act as a template or configuration files). - -out/ - This directory contains output of cdist and is usually located - in a temporary directory and thus will be removed after the run. - This directory is referenced by the variable __global (see below). - -out/explorer - Output of general explorers. - -out/object - Objects created for the host. - -out/object/ - Contains all object specific information. - This directory is referenced by the variable __object (see below). - -out/object//explorers - Output of type specific explorers, per object. - -Types ------ -The following types are available: - -eof - -# 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}"; - manref="${no_dir%.rst}" - man="${manref}(7)" - - echo "- $name" "(\`${man} \`_)" -done - -cat << eof - - -Objects -------- -For object to object communication and tests, the following paths are -usable within a object directory: - -files - This directory is reserved for user data and will not be used - by cdist at any time. It can be used freely by the type - (for instance to store template results). -changed - This empty file exists in an object directory, if the object has - code to be executed (either remote or local). -stdin - This file exists and contains data, if data was provided on stdin - when the type was called. - - -Environment variables (for reading) ------------------------------------ -The following environment variables are exported by cdist: - -__cdist_log_level, __cdist_log_level_name - cdist log level value and cdist log level name. One of: - - +----------------+-----------------+ - | Log level name | Log level value | - +================+=================+ - | OFF | 60 | - +----------------+-----------------+ - | ERROR | 40 | - +----------------+-----------------+ - | WARNING | 30 | - +----------------+-----------------+ - | INFO | 20 | - +----------------+-----------------+ - | VERBOSE | 15 | - +----------------+-----------------+ - | DEBUG | 10 | - +----------------+-----------------+ - | TRACE | 5 | - +----------------+-----------------+ - - Available for: initial manifest, explorer, type manifest, type explorer, - type gencode. -__cdist_dry_run - Is set only when doing dry run (``-n`` flag). - Available for: initial manifest, explorer, type manifest, type explorer, - type gencode. -__explorer - Directory that contains all global explorers. - Available for: initial manifest, explorer, type explorer, shell. -__files - Directory that contains content from the "files" subdirectories - from the configuration directories. - Available for: initial manifest, type manifest, type gencode, shell. -__manifest - Directory that contains the initial manifest. - Available for: initial manifest, type manifest, shell. -__global - Directory that contains generic output like explorer. - Available for: initial manifest, type manifest, type gencode, shell. -__messages_in - File to read messages from. - Available for: initial manifest, type manifest, type gencode. -__messages_out - File to write messages. - Available for: initial manifest, type manifest, type gencode. -__object - Directory that contains the current object. - Available for: type manifest, type explorer, type gencode and code scripts. -__object_id - The type unique object id. - Available for: type manifest, type explorer, type gencode and code scripts. - Note: The leading and the trailing "/" will always be stripped (caused by - the filesystem database and ensured by the core). - Note: Double slashes ("//") will not be fixed and result in an error. -__object_name - The full qualified name of the current object. - Available for: type manifest, type explorer, type gencode. -__target_host - The host we are deploying to. This is primary variable. It's content is - literally the one user passed in. - Available for: explorer, initial manifest, type explorer, type manifest, type gencode, shell. -__target_hostname - The hostname of host we are deploying to. This variable is derived from - **__target_host** (using **socket.getaddrinfo(__target_host)** and then - **socket.gethostbyaddr()**). - Available for: explorer, initial manifest, type explorer, type manifest, type gencode, shell. -__target_fqdn - The fully qualified domain name of the host we are deploying to. - This variable is derived from **__target_host** - (using **socket.getfqdn()**). - Available for: explorer, initial manifest, type explorer, type manifest, type gencode, shell. -__target_host_tags - Comma separated list of target host tags. - Available for: explorer, initial manifest, type explorer, type manifest, type gencode, shell. -__type - Path to the current type. - Available for: type manifest, type gencode. -__type_explorer - Directory that contains the type explorers. - Available for: type explorer. - -Environment variables (for writing) ------------------------------------ -The following environment variables influence the behaviour of cdist: - -require - Setup dependencies between objects (see \`cdist manifest \`_). - -__cdist_log_level - cdist log level value. One of: - - +----------------+-----------------+ - | Log level | Log level value | - +================+=================+ - | OFF | 60 | - +----------------+-----------------+ - | ERROR | 40 | - +----------------+-----------------+ - | WARNING | 30 | - +----------------+-----------------+ - | INFO | 20 | - +----------------+-----------------+ - | VERBOSE | 15 | - +----------------+-----------------+ - | DEBUG | 10 | - +----------------+-----------------+ - | TRACE | 5 | - +----------------+-----------------+ - - If set cdist will set this log level in - accordance with configuration rules. If cdist invokation is used - in types then nested cdist will honor this specified log level if - not specified otherwise while invoking it. - -CDIST_PATH - Colon delimited list of config directories. - -CDIST_LOCAL_SHELL - Use this shell locally instead of /bin/sh to execute scripts. - -CDIST_REMOTE_SHELL - Use this shell remotely instead of /bin/sh to execute scripts. - -CDIST_OVERRIDE - Allow overwriting type parameters (see \`cdist manifest \`_). - -CDIST_ORDER_DEPENDENCY - Create dependencies based on the execution order (see \`cdist manifest \`_). - Read also about \`perils of CDIST_ORDER_DEPENDENCY \`_. - -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). - -CDIST_INVENTORY_DIR - Use this directory as inventory directory. - -CDIST_BETA - Enable beta functionalities. - -CDIST_CACHE_PATH_PATTERN - Custom cache path pattern. -eof diff --git a/docs/src/cdist-saving-output-streams.rst b/docs/src/cdist-saving-output-streams.rst deleted file mode 100644 index da66f754..00000000 --- a/docs/src/cdist-saving-output-streams.rst +++ /dev/null @@ -1,88 +0,0 @@ -Saving output streams -===================== - -Description ------------ -Since version 4.8.0 cdist, by default, saves output streams to local cache. -Saving output streams is implemented because important information was lost -during a config run, hidden in all other output. -Now all created output is bound to the context where it was produced. - -Saving output streams include stdout and stderr of init manifest, remote -commands and for each object stdout and stderr of manifest, gencode-\* and code-\*. -Output stream files are created only if some output is produced. For more info -on these cache files see `Local cache overview `_. - -Also, in case of an error, cdist can now exit and show all information it has -about the error. - -For example: - -.. code-block:: sh - - $ ./bin/cdist config -v -i ~/.cdist/manifest/init-output-streams $(cat ~/ungleich/data/opennebula-debian9-test ) - INFO: 185.203.112.42: Starting configuration run - INFO: 185.203.112.42: Processing __myline/test - ERROR: 185.203.112.42: Command failed: '/bin/sh -e /tmp/tmpow6cwemh/75ee6a79e32da093da23fe4a13dd104b/data/object/__myline/test/.cdist-kisrqlpw/code-local' - return code: 1 - ---- BEGIN stdout ---- - ---- END stdout ---- - - Error processing object '__myline/test' - ======================================== - name: __myline/test - path: /tmp/tmpow6cwemh/75ee6a79e32da093da23fe4a13dd104b/data/object/__myline/test/.cdist-kisrqlpw - source: /home/darko/.cdist/manifest/init-output-streams - type: /tmp/tmpow6cwemh/75ee6a79e32da093da23fe4a13dd104b/data/conf/type/__myline - - ---- BEGIN manifest:stderr ---- - myline manifest stderr - - ---- END manifest:stderr ---- - - ---- BEGIN gencode-remote:stderr ---- - test gencode-remote error - - ---- END gencode-remote:stderr ---- - - ---- BEGIN code-local:stderr ---- - error - - ---- END code-local:stderr ---- - - ERROR: cdist: Failed to configure the following hosts: 185.203.112.42 - -Upon successful run execution state is saved to local cache and temporary -directory is removed. -In case of an error temporary directory is not removed and can be further -discovered. - -There is also an option :strong:`-S/--disable-saving-output-streams` for -disabling saving output streams. In this case error reporting can look -like this: - -.. code-block:: sh - - $ ./bin/cdist config -v -S -i ~/.cdist/manifest/init-output-streams $(cat ~/ungleich/data/opennebula-debian9-test ) - INFO: 185.203.112.42: Starting configuration run - test stdout output streams - test stderr output streams - myline manifest stdout - myline manifest stderr - test gencode-remote error - INFO: 185.203.112.42: Processing __myline/test - error - ERROR: 185.203.112.42: Command failed: '/bin/sh -e /tmp/tmpzomy0wis/75ee6a79e32da093da23fe4a13dd104b/data/object/__myline/test/.cdist-n566pqut/code-local' - return code: 1 - ---- BEGIN stdout ---- - ---- END stdout ---- - - Error processing object '__myline/test' - ======================================== - name: __myline/test - path: /tmp/tmpzomy0wis/75ee6a79e32da093da23fe4a13dd104b/data/object/__myline/test/.cdist-n566pqut - source: /home/darko/.cdist/manifest/init-output-streams - type: /tmp/tmpzomy0wis/75ee6a79e32da093da23fe4a13dd104b/data/conf/type/__myline - - - ERROR: cdist: Failed to configure the following hosts: 185.203.112.42 diff --git a/docs/src/cdist-support.rst b/docs/src/cdist-support.rst deleted file mode 100644 index 19afde2f..00000000 --- a/docs/src/cdist-support.rst +++ /dev/null @@ -1,26 +0,0 @@ -Support -------- - -Chat -~~~~ -Chat with us: `ungleich chat `_. - -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 -`ungleich `_. diff --git a/docs/src/cdist-troubleshooting.rst b/docs/src/cdist-troubleshooting.rst deleted file mode 100644 index e639aafd..00000000 --- a/docs/src/cdist-troubleshooting.rst +++ /dev/null @@ -1,64 +0,0 @@ -Troubleshooting -=============== - -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. -An example script would be something like this: - -.. code-block:: sh - - % cat ~/.cdist/manifest/init - "$__manifest/special" - % cat ~/.cdist/manifest/special - #!/bin/sh - echo "Here is an unclean exiting script" - somecommandthatdoesnotexist - echo "I continue here although previous command failed" - -We can clearly see that **somecommandthatdoesnotexist** -will fail in ~/.cdist/manifest/special. But as the custom -script is not called with the -e flag (exit on failure) of shell, -it does not lead to an error. And thus cdist sees the exit 0 -code of the last echo line instead of the failing command. - -All scripts executed by cdist carry the -e flag. -To prevent the above from happening, there are three solutions available, -two of which can be used in the calling script: - -.. code-block:: sh - - # Execute as before, but abort on failure - sh -e "$__manifest/special" - - # Source the script in our namespace, runs in a set -e environment: - . "$__manifest/special" - -The third solution is to include a shebang header in every script -you write to use the -e flag: - -.. code-block:: sh - - % cat ~/.cdist/manifest/special - #!/bin/sh -e - ... - -Using debug dump helper script ------------------------------- -Since cdist stores data to local cache that can be used for debugging there -is a helper script that dumps data from local cache, -`cdist-dump `_. - -For more info see: - -.. code-block:: sh - - cdist-dump -h - -Or from cdist git cloned directory: - -.. code-block:: sh - - ./scripts/cdist-dump -h - diff --git a/docs/src/cdist-type.rst b/docs/src/cdist-type.rst deleted file mode 100644 index 582c0938..00000000 --- a/docs/src/cdist-type.rst +++ /dev/null @@ -1,524 +0,0 @@ -cdist type -========== - -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 --------- - -.. 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: - -.. code-block:: sh - - # Creates empty file /etc/cdist-configured - __file /etc/cdist-configured --type file - - # Ensure tree is installed - __package tree --state installed - -A list of supported types can be found in the `cdist reference `_ manpage. - - -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 -system. Singleton types do not take an object name as argument. - - -Example: - -.. code-block:: sh - - # __issue type manages /etc/issue - __issue - - # Probably your own type - singletons may use parameters - __myfancysingleton --colour green - - -Config types ------------- -By default types are used with config command. These are types that are not -flagged by any known command flag. If a type is marked then it will be skipped -with config command. - - -Install types -------------- -If a type is flagged with 'install' flag then it is used only with install command. -With other commands, i.e. config, these types are skipped if used. - - -Nonparallel types ------------------ -If a type is flagged with 'nonparallel' flag then its objects cannot be run in parallel -when using -j option. Example of such a type is __package_dpkg type where dpkg itself -prevents to be run in more than one instance. - - -Deprecated types ------------------ -If a type is flagged with 'deprecated' marker then it is considered deprecated. -When it is used cdist writes warning line. If 'deprecated' marker has content -then this content is printed as a deprecation messages, e.g.: - -.. code-block:: sh - - $ ls -l deprecated - -rw-r--r-- 1 darko darko 71 May 20 18:30 deprecated - $ cat deprecated - This type is deprecated. It will be removed in the next minor release. - $ echo '__foo foo' | ./bin/cdist config -i - 185.203.112.26 - WARNING: 185.203.112.26: Type __foo is deprecated: This type is deprecated. It will be removed in the next minor release. - -If 'deprecated' marker has no content then general message is printed, e.g.: - -.. code-block:: sh - - $ ls -l deprecated - -rw-r--r-- 1 darko darko 0 May 20 18:36 deprecated - $ echo '__bar foo' | ./bin/cdist config -i - 185.203.112.26 - WARNING: 185.203.112.26: Type __bar is deprecated. - - -How to write a new type ------------------------ -A type consists of - -- parameter (optional) -- manifest (optional) -- singleton (optional) -- explorer (optional) -- gencode (optional) -- nonparallel (optional) - -Types are stored below cdist/conf/type/. Their name should always be prefixed with -two underscores (__) to prevent collisions with other executables in $PATH. - -To implement a new type, create the directory **cdist/conf/type/__NAME**. - -Type manifest and gencode can be written in any language. They just need to be -executable and have a proper shebang. If they are not executable then cdist assumes -they are written in shell so they are executed using '/bin/sh -e' or 'CDIST_LOCAL_SHELL'. - -For executable shell code it is suggested that shebang is '#!/bin/sh -e'. - -For creating type skeleton you can use helper script -`cdist-new-type `_. - - -Defining parameters -------------------- -Every type consists of required, optional and boolean parameters, which must -each be declared in a newline separated file in **parameter/required**, -**parameter/required_multiple**, **parameter/optional**, -**parameter/optional_multiple** and **parameter/boolean**. -Parameters which are allowed multiple times should be listed in -required_multiple or optional_multiple respectively. All other parameters -follow the standard unix behaviour "the last given wins". -If either is missing, the type will have no required, no optional, no boolean -or no parameters at all. - -Default values for optional parameters can be predefined in -**parameter/default/**. - -Example: - -.. code-block:: sh - - echo servername >> cdist/conf/type/__nginx_vhost/parameter/required - echo logdirectory >> cdist/conf/type/__nginx_vhost/parameter/optional - echo loglevel >> cdist/conf/type/__nginx_vhost/parameter/optional - mkdir cdist/conf/type/__nginx_vhost/parameter/default - echo warning > cdist/conf/type/__nginx_vhost/parameter/default/loglevel - echo server_alias >> cdist/conf/type/__nginx_vhost/parameter/optional_multiple - echo use_ssl >> cdist/conf/type/__nginx_vhost/parameter/boolean - - -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 -represented by file existence. File exists -> True, -file does not exist -> False - -Example: (e.g. in cdist/conf/type/__nginx_vhost/manifest) - -.. code-block:: sh - - # required parameter - servername="$(cat "$__object/parameter/servername")" - - # optional parameter - if [ -f "$__object/parameter/logdirectory" ]; then - logdirectory="$(cat "$__object/parameter/logdirectory")" - fi - - # optional parameter with predefined default - loglevel="$(cat "$__object/parameter/loglevel")" - - # boolean parameter - if [ -f "$__object/parameter/use_ssl" ]; then - # file exists -> True - # do some fancy ssl stuff - fi - - # parameter with multiple values - if [ -f "$__object/parameter/server_alias" ]; then - for alias in $(cat "$__object/parameter/server_alias"); do - echo $alias > /some/where/useful - done - fi - - -Deprecated parameters ---------------------- -To deprecate type parameters one can declare a file for each deprecated -parameter under **parameter/deprecated** directory. - -When such parameter is used cdist writes warning line with deprecation message. -If such file has content then this content is printed as deprecation message. -If there is no content then generic parameter deprecation message is printed. - -Example: - -.. code-block:: sh - - $ ls parameter/deprecated/ - eggs spam - $ cat parameter/deprecated/eggs - eggs parameter is deprecated, please use multiple egg parameter. - $ cat parameter/deprecated/spam - $ echo '__foo foo --foo foo --eggs eggs' | ./bin/cdist config -i - 185.203.112.26 - WARNING: 185.203.112.26: eggs parameter of type __foo is deprecated: eggs parameter is deprecated, please use multiple egg parameter. - $ echo '__foo foo --foo foo --eggs eggs --spam spam' | ./bin/cdist config -i - 185.203.112.26 - WARNING: 185.203.112.26: spam parameter of type __foo is deprecated. - WARNING: 185.203.112.26: eggs parameter of type __foo is deprecated: eggs parameter is deprecated, please use multiple egg parameter. - - -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. - -Example use of a type: (e.g. in cdist/conf/type/__archlinux_hostname) - -.. code-block:: sh - - __file /etc/rc.conf --source - << eof - ... - HOSTNAME="$__target_host" - ... - eof - -If you have not seen this syntax (<< eof) before, it may help you to read -about "here documents". - -In the __file type, stdin is used as source for the file, if - is used for source: - -.. code-block:: sh - - if [ -f "$__object/parameter/source" ]; then - source="$(cat "$__object/parameter/source")" - if [ "$source" = "-" ]; then - source="$__object/stdin" - fi - .... - - -Stdin inside a loop -~~~~~~~~~~~~~~~~~~~ -Since cdist saves type's stdin content in the object as **$__object/stdin**, -so it can be accessed in manifest and gencode-* scripts, this can lead to -unexpected behavior. For example, suppose you have some type with the following -in its manifest: - -.. code-block:: sh - - if [ -f "$__object/parameter/foo" ] - then - while read -r l - do - __file "$l" - echo "$l" >&2 - done < "$__object/parameter/foo" - fi - -and init manifest: - -.. code-block:: sh - - __foo foo --foo a --foo b --foo c - -You expect that manifest stderr content is: - -.. code-block:: sh - - a - b - c - -and that files *a*, *b* and *c* are created. But all you get in manifest stderr -is: - -.. code-block:: sh - - a - -and only *a* file is created. - -When redirecting parameter *foo* file content to while's stdin that means that all -commands in while body have this same stdin. So when *__file* type gets executed, -cdist saves its stdin which means it gets the remaining content of parameter *foo* -file, i.e.: - -.. code-block:: sh - - b - c - -The solution is to make sure that your types inside such loops get their stdin -from somewhere else, e.g. for the above problem *__file* type can get empty -stdin from */dev/null*: - -.. code-block:: sh - - if [ -f "$__object/parameter/foo" ] - then - while read -r l - do - __file "$l" < /dev/null - echo "$l" >&2 - done < "$__object/parameter/foo" - fi - - -Writing the manifest --------------------- -In the manifest of a type you can use other types, so your type extends -their functionality. A good example is the __package type, which in -a shortened version looks like this: - -.. code-block:: sh - - os="$(cat "$__global/explorer/os")" - case "$os" in - archlinux) type="pacman" ;; - debian|ubuntu) type="apt" ;; - gentoo) type="emerge" ;; - *) - echo "Don't know how to manage packages on: $os" >&2 - exit 1 - ;; - esac - - __package_$type "$@" - -As you can see, the type can reference different environment variables, -which are documented in `cdist reference `_. - -Always ensure the manifest is executable, otherwise cdist will not be able -to execute it. For more information about manifests see `cdist manifest `_. - - -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 -directory: - -.. code-block:: sh - - touch cdist/conf/type/__NAME/singleton - -This will also change the way your type must be called: - -.. code-block:: sh - - __YOURTYPE --parameter value - -As you can see, the object ID is omitted, because it does not make any sense, -if your type can be used only once. - - -Install - type with install command ------------------------------------ -If you want a type to be used with install command, you must mark it as -install: create the (empty) file "install" in your type directory: - -.. code-block:: sh - - touch cdist/conf/type/__install_NAME/install - -With other commands, i.e. config, it will be skipped if used. - - -Nonparallel - only one instance can be run at a time ----------------------------------------------------- -If objects of a type must not or cannot be run in parallel when using -j -option, you must mark it as nonparallel: create the (empty) file "nonparallel" -in your type directory: - -.. code-block:: sh - - touch cdist/conf/type/__NAME/nonparallel - -For example, package types are nonparallel types. - - -The type explorers ------------------- -If a type needs to explore specific details, it can provide type specific -explorers, which will be executed on the target for every created object. - -The explorers are stored under the "explorer" directory below the type. -It could for instance contain code to check the md5sum of a file on the -client, like this (shortened version from the type __file): - -.. code-block:: sh - - if [ -f "$__object/parameter/destination" ]; then - destination="$(cat "$__object/parameter/destination")" - else - destination="/$__object_id" - fi - - if [ -e "$destination" ]; then - md5sum < "$destination" - fi - - -Writing the gencode script --------------------------- -There are two gencode scripts: **gencode-local** and **gencode-remote**. -The output of gencode-local is executed locally, whereas -the output of gencode-remote is executed on the target. -The gencode scripts can make use of the parameters, the global explorers -and the type specific explorers. - -If the gencode scripts encounters an error, it should print diagnostic -messages to stderr and exit non-zero. If you need to debug the gencode -script, you can write to stderr: - -.. code-block:: sh - - # Debug output to stderr - echo "My fancy debug line" >&2 - - # Output to be saved by cdist for execution on the target - echo "touch /etc/cdist-configured" - -Notice: if you use __remote_copy or __remote_exec directly in your scripts -then for IPv6 address with __remote_copy execution you should enclose IPv6 -address in square brackets. The same applies to __remote_exec if it behaves -the same as ssh for some options where colon is a delimiter, as for -L ssh -option (see :strong:`ssh`\ (1) and :strong:`scp`\ (1)). - - -Variable access from the generated scripts ------------------------------------------- -In the generated scripts, you have access to the following cdist variables - -- __object -- __object_id - -but only for read operations, means there is no back copy of this -files after the script execution. - -So when you generate a script with the following content, it will work: - -.. code-block:: sh - - if [ -f "$__object/parameter/name" ]; then - name="$(cat "$__object/parameter/name")" - else - name="$__object_id" - fi - - -Environment variable usage idiom --------------------------------- -In type scripts you can support environment variables with default values if -environment variable is unset or null by using **${parameter:-[word]}** -parameter expansion. - -Example using mktemp in a portable way that supports TMPDIR environment variable. - -.. code-block:: sh - - tempfile=$(mktemp "${TMPDIR:-/tmp}/cdist.XXXXXXXXXX") - - -Log level in types ------------------- -cdist log level can be accessed from __cdist_log_level variable.One of: - - +----------------+-----------------+ - | Log level | Log level value | - +================+=================+ - | OFF | 60 | - +----------------+-----------------+ - | ERROR | 40 | - +----------------+-----------------+ - | WARNING | 30 | - +----------------+-----------------+ - | INFO | 20 | - +----------------+-----------------+ - | VERBOSE | 15 | - +----------------+-----------------+ - | DEBUG | 10 | - +----------------+-----------------+ - | TRACE | 5 | - +----------------+-----------------+ - - -It is available for initial manifest, explorer, type manifest, -type explorer, type gencode. - - -Detecting dry run ------------------ - -If ``$__cdist_dry_run`` environment variable is set, then it's dry run. - -It is available for initial manifest, explorer, type manifest, -type explorer, type gencode. - - -Hints for typewriters ----------------------- -It must be assumed that the target is pretty dumb and thus does not have high -level tools like ruby installed. If a type requires specific tools to be present -on the target, there must be another type that provides this tool and the first -type should create an object of the specific type. - -If your type wants to save temporary data, that may be used by other types -later on (for instance \__file), you can save them in the subdirectory -"files" below $__object (but you must create it yourself). -cdist will not touch this directory. - -If your type contains static files, it's also recommended to place them in -a folder named "files" within the type (again, because cdist guarantees to -never ever touch this folder). - - -How to include a type into upstream cdist ------------------------------------------ -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 hacking `_ on -how to submit it. diff --git a/docs/src/cdist-types.rst b/docs/src/cdist-types.rst deleted file mode 100644 index d5104667..00000000 --- a/docs/src/cdist-types.rst +++ /dev/null @@ -1,8 +0,0 @@ -cdist types -=========== - -.. toctree:: - :titlesonly: - :glob: - - man7/* diff --git a/docs/src/conf.py b/docs/src/conf.py deleted file mode 100644 index 78f9842c..00000000 --- a/docs/src/conf.py +++ /dev/null @@ -1,314 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- -# -# cdist-docs documentation build configuration file, created by -# sphinx-quickstart on Fri May 6 21:45:28 2016. -# -# This file is execfile()d with the current directory set to its -# containing dir. -# -# Note that not all possible configuration values are present in this -# autogenerated file. -# -# All configuration values have a default; values that are commented out -# serve to show the default. - -import sys -import os -import sphinx_rtd_theme - -# If extensions (or modules to document with autodoc) are in another directory, -# 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__)), "..", ".."))) - -# Import cdist after sys.path fixup above. - -import cdist.version # nopep8 - ignore error that import is not at top - -# -- General configuration ------------------------------------------------ - -# If your documentation needs a minimal Sphinx version, state it here. -# needs_sphinx = '1.0' - -# Add any Sphinx extension module names here, as strings. They can be -# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom -# ones. -extensions = [ - 'cdist.sphinxext.manpage', - 'sphinx.ext.extlinks', -] - -# Add any paths that contain templates here, relative to this directory. -templates_path = ['_templates'] - -# The suffix(es) of source filenames. -# You can specify multiple suffix as a list of string: -source_suffix = ['.rst'] - -# The encoding of source files. -# source_encoding = 'utf-8-sig' - -# The master toctree document. -master_doc = 'index' - -# General information about the project. -project = 'cdist' -copyright = 'ungleich GmbH 2019' -# author = 'Darko Poljak' - -# The version info for the project you're documenting, acts as replacement for -# |version| and |release|, also used in various other places throughout the -# built documents. -# -# The short X.Y version. -version = cdist.version.VERSION -# The full version, including alpha/beta/rc tags. -release = version - -# The language for content autogenerated by Sphinx. Refer to documentation -# for a list of supported languages. -# -# This is also used if you do content translation via gettext catalogs. -# Usually you set "language" from the command line for these cases. -language = None - -# There are two options for replacing |today|: either, you set today to some -# non-false value, then it is used: -# today = '' -# Else, today_fmt is used as the format for a strftime call. -# today_fmt = '%B %d, %Y' - -# List of patterns, relative to source directory, that match files and -# directories to ignore when looking for source files. -# This patterns also effect to html_static_path and html_extra_path -exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] - -# The reST default role (used for this markup: `text`) to use for all -# documents. -# default_role = None - -# If true, '()' will be appended to :func: etc. cross-reference text. -# add_function_parentheses = True - -# If true, the current module name will be prepended to all description -# unit titles (such as .. function::). -# add_module_names = True - -# If true, sectionauthor and moduleauthor directives will be shown in the -# output. They are ignored by default. -# show_authors = False - -# The name of the Pygments (syntax highlighting) style to use. -pygments_style = 'sphinx' - -# A list of ignored prefixes for module index sorting. -# modindex_common_prefix = [] - -# If true, keep warnings as "system message" paragraphs in the built documents. -# keep_warnings = False - -# If true, `todo` and `todoList` produce output, else they produce nothing. -todo_include_todos = False - - -# -- Options for HTML output ---------------------------------------------- - -# The theme to use for HTML and HTML Help pages. See the documentation for -# a list of builtin themes. -html_theme = 'sphinx_rtd_theme' -html_theme_path = [sphinx_rtd_theme.get_html_theme_path()] - -# Theme options are theme-specific and customize the look and feel of a theme -# further. For a list of options available for each theme, see the -# documentation. -# html_theme_options = {} - -# Add any paths that contain custom themes here, relative to this directory. -# html_theme_path = [] - -# The name for this set of Sphinx documents. -# " v documentation" by default. -# html_title = 'cdist-docs v0.0.1' - -# A shorter title for the navigation bar. Default is the same as html_title. -# html_short_title = None - -# The name of an image file (relative to this directory) to place at the top -# of the sidebar. -html_logo = '_static/cdist-logo.jpeg' - -# The name of an image file (relative to this directory) to use as a favicon of -# the docs. This file should be a Windows icon file (.ico) -# being 16x16 or 32x32 -# pixels large. -# html_favicon = None - -# 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 -# directly to the root of the documentation. -# html_extra_path = [] - -# If not None, a 'Last updated on:' timestamp is inserted at every page -# bottom, using the given strftime format. -# The empty string is equivalent to '%b %d, %Y'. -# html_last_updated_fmt = None - -# Custom sidebar templates, maps document names to template names. -# html_sidebars = {} - -# Additional templates that should be rendered to pages, maps page names to -# template names. -# html_additional_pages = {} - -# If false, no module index is generated. -# html_domain_indices = True - -# If false, no index is generated. -# html_use_index = True - -# If true, the index is split into individual pages for each letter. -# html_split_index = False - -# If true, links to the reST sources are added to the pages. -# html_show_sourcelink = True - -# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. -# html_show_sphinx = True - -# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. -# html_show_copyright = True - -# If true, an OpenSearch description file will be output, and all pages will -# contain a tag referring to it. The value of this option must be the -# base URL from which the finished HTML is served. -# html_use_opensearch = '' - -# This is the file name suffix for HTML files (e.g. ".xhtml"). -# html_file_suffix = None -# html_file_suffix = "" - -# Language to be used for generating the HTML full-text search index. -# Sphinx supports the following languages: -# 'da', 'de', 'en', 'es', 'fi', 'fr', 'h', 'it', 'ja' -# 'nl', 'no', 'pt', 'ro', 'r', 'sv', 'tr', 'zh' -# html_search_language = 'en' - -# A dictionary with options for the search language support, empty by default. -# 'ja' uses this config value. -# 'zh' user can custom change `jieba` dictionary path. -# html_search_options = {'type': 'default'} - -# The name of a javascript file (relative to the configuration directory) that -# implements a search results scorer. If empty, the default will be used. -# html_search_scorer = 'scorer.js' - -# Output file base name for HTML help builder. -htmlhelp_basename = 'cdistdoc' - -# -- Options for LaTeX output --------------------------------------------- - -# latex_elements = { -# The paper size ('letterpaper' or 'a4paper'). -# 'papersize': 'letterpaper', - -# The font size ('10pt', '11pt' or '12pt'). -# 'pointsize': '10pt', - -# Additional stuff for the LaTeX preamble. -# 'preamble': '', - -# Latex figure (float) alignment -# 'figure_align': 'htbp', -# } - -# Grouping the document tree into LaTeX files. List of tuples -# (source start file, target name, title, -# author, documentclass [howto, manual, or own class]). -latex_documents = [ - (master_doc, 'cdist.tex', 'cdist Documentation', - 'Darko Poljak', 'manual'), -] - -# The name of an image file (relative to this directory) to place at the top of -# the title page. -# latex_logo = None - -# For "manual" documents, if this is true, then toplevel headings are parts, -# not chapters. -# latex_use_parts = False - -# If true, show page references after internal links. -# latex_show_pagerefs = False - -# If true, show URL addresses after external links. -# latex_show_urls = False - -# Documents to append as an appendix to all manuals. -# latex_appendices = [] - -# If false, no module index is generated. -# latex_domain_indices = True - - -# -- Options for manual page output --------------------------------------- - -# One entry per manual page. List of tuples -# (source start file, name, description, authors, manual section). -root_mandir = os.path.dirname(os.path.realpath(__file__)) -mandirs = [] -for mansubdir in ('man1', 'man7'): - 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('man' + str(section), froot), - froot, '', [], section) - man_pages.append(man_page) - -# man_pages = [ -# ('cdist-type', 'cdist-type', 'cdist-type documentation', -# [author], 1), -# ('man7/cdist-type__file', 'cdist-type__file', -# '', [], 1), -# ('cdist-type__directory', 'cdist-type__directory', -# 'cdist-type__directory documentation', [author], 1), -# ] - -# If true, show URL addresses after external links. -# man_show_urls = False - - -# -- Options for Texinfo output ------------------------------------------- - -# Grouping the document tree into Texinfo files. List of tuples -# (source start file, target name, title, author, -# dir menu entry, description, category) -texinfo_documents = [ - (master_doc, 'cdist', 'cdist Documentation', - '', 'cdist', 'Configuration management system.', - 'Miscellaneous'), -] - -# Documents to append as an appendix to all manuals. -# texinfo_appendices = [] - -# If false, no module index is generated. -# texinfo_domain_indices = True - -# How to display URL addresses: 'footnote', 'no', or 'inline'. -# texinfo_show_urls = 'footnote' - -# If true, do not generate a @detailmenu in the "Top" node's menu. -# texinfo_no_detailmenu = False diff --git a/docs/src/docutils.conf b/docs/src/docutils.conf deleted file mode 100644 index 168f9e2b..00000000 --- a/docs/src/docutils.conf +++ /dev/null @@ -1,2 +0,0 @@ -[parsers] -smart_quotes: false diff --git a/docs/src/index.rst b/docs/src/index.rst deleted file mode 100644 index 6cbd938a..00000000 --- a/docs/src/index.rst +++ /dev/null @@ -1,43 +0,0 @@ -cdist - usable configuration management -======================================= - -cdist is a usable configuration management system. -It adheres to the KISS principle and -is being used in small up to enterprise grade environments. - - -.. toctree:: - :maxdepth: 3 - :glob: - :numbered: - :hidden: - - cdist-why - cdist-features - cdist-os - cdist-install - cdist-upgrade - cdist-support - cdist-quickstart - cdist-real-world - man1/cdist - man1/cdist-dump - man1/cdist-new-type - cdist-bootstrap - cdist-configuration - cdist-manifest - cdist-type - cdist-types - cdist-explorer - cdist-messaging - cdist-parallelization - cdist-inventory - cdist-integration - cdist-reference - cdist-best-practice - cdist-stages - cdist-cache - cdist-saving-output-streams - cdist-remote-exec-copy - cdist-hacker - cdist-troubleshooting diff --git a/docs/src/man1/cdist-dump.rst b/docs/src/man1/cdist-dump.rst deleted file mode 100644 index 907cd192..00000000 --- a/docs/src/man1/cdist-dump.rst +++ /dev/null @@ -1,110 +0,0 @@ -cdist-dump(1) -============= - -NAME ----- -cdist-dump - Dump data from local cdist cache - - -SYNOPSIS --------- - -:: - - cdist-dump [options] [host...] - - - -DESCRIPTION ------------ -cdist-dump is a helper script that dumps data from local cdist cache for -specified hosts. If host is not specified then all data from cache directory -is dumped. Default cache directory is '~/.cdist/cache'. - -cdist-dump can be used for debugging existing types, host configuration and -new types. - - -OPTIONS -------- -**-a** - dump all - -**-C CACHE-DIR** - use specified CACHE-DIR (default: ~/.cdist/cache) - -**-c** - dump code-* - -**-d DELIMITER** - delimiter used for filename and line number prefix (default: ':') - -**-E** - dump global explorers - -**-e** - dump type explorers - -**-F** - disable filename prefix (enabled by default) - -**-f** - enable filename prefix (default) - -**-g** - dump gencode-* - -**-h** - show this help screen and exit - -**-L** - disable line number prefix (default) - -**-l** - enable line number prefix (disabled by default) - -**-m** - dump messages - -**-o** - dump executions' stdout - -**-p** - dump parameters - -**-r** - dump executions' stderr - -**-V** - show version and exit - -**-v** - increase verbosity - - -EXAMPLES --------- - -.. code-block:: sh - - # Dump all - % cdist-dump -a - - # Dump only code-* output - % cdist-dump -c - - -SEE ALSO --------- -:strong:`cdist`\ (1) - - -AUTHORS -------- -Darko Poljak - - -COPYING -------- -Copyright \(C) 2019 Darko Poljak. Free use of this software is -granted under the terms of the GNU General Public License v3 or later (GPLv3+). diff --git a/docs/src/man1/cdist-new-type.rst b/docs/src/man1/cdist-new-type.rst deleted file mode 100644 index f1a8b992..00000000 --- a/docs/src/man1/cdist-new-type.rst +++ /dev/null @@ -1,74 +0,0 @@ -cdist-new-type(1) -================= - -NAME ----- -cdist-new-type - Create new type skeleton - - -SYNOPSIS --------- - -:: - - cdist-new-type TYPE-NAME AUTHOR-NAME AUTHOR-EMAIL [TYPE-BASE-PATH] - - - -DESCRIPTION ------------ -cdist-new-type is a helper script that creates new type skeleton. -It is then up to the type author to finish the type. - -It creates skeletons for the following files: - -* man.rst -* manifest -* gencode-remote. - -Upon creation it prints the path to the newly created type directory. - - -ARGUMENTS ---------- -**TYPE-NAME** - Name of the new type. - -**AUTHOR-NAME** - Type author's full name. - -**AUTHOR-NAME** - Type author's email. - -**TYPE-BASE-PATH** - Path to the base directory of the type. If not set it defaults - to '$PWD/type'. - - -EXAMPLES --------- - -.. code-block:: sh - - # Create new type __foo in ~/.cdist directory. - $ cd ~/.cdist - $ cdist-new-type '__foo' 'Foo Bar' 'foo.bar at foobar.org' - /home/foo/.cdist/type/__foo - - -SEE ALSO --------- -:strong:`cdist`\ (1) - - -AUTHORS -------- - -| Steven Armstrong -| Darko Poljak - - -COPYING -------- -Copyright \(C) 2019 Steven Armstrong, Darko Poljak. Free use of this software is -granted under the terms of the GNU General Public License v3 or later (GPLv3+). diff --git a/docs/src/man1/cdist.rst b/docs/src/man1/cdist.rst deleted file mode 100644 index 30832f2f..00000000 --- a/docs/src/man1/cdist.rst +++ /dev/null @@ -1,740 +0,0 @@ -cdist(1) -======== - -NAME ----- -cdist - Usable Configuration Management - - -SYNOPSIS --------- - -:: - - cdist [-h] [-V] {banner,config,install,inventory,shell} ... - - cdist banner [-h] [-l LOGLEVEL] [-q] [-v] - - cdist config [-h] [-l LOGLEVEL] [-q] [-v] [-b] [-g CONFIG_FILE] [-4] - [-6] [-C CACHE_PATH_PATTERN] [-c CONF_DIR] [-i MANIFEST] - [-j [JOBS]] [-n] [-o OUT_PATH] [-P] - [-R [{tar,tgz,tbz2,txz}]] [-r REMOTE_OUT_PATH] - [--remote-copy REMOTE_COPY] [--remote-exec REMOTE_EXEC] - [-S] [-I INVENTORY_DIR] [-A] [-a] [-f HOSTFILE] - [-p [HOST_MAX]] [-s] [-t] - [host [host ...]] - - cdist install [-h] [-l LOGLEVEL] [-q] [-v] [-b] [-g CONFIG_FILE] [-4] - [-6] [-C CACHE_PATH_PATTERN] [-c CONF_DIR] [-i MANIFEST] - [-j [JOBS]] [-n] [-o OUT_PATH] [-P] - [-R [{tar,tgz,tbz2,txz}]] [-r REMOTE_OUT_PATH] - [--remote-copy REMOTE_COPY] [--remote-exec REMOTE_EXEC] - [-S] [-I INVENTORY_DIR] [-A] [-a] [-f HOSTFILE] - [-p [HOST_MAX]] [-s] [-t] - [host [host ...]] - - cdist inventory [-h] {add-host,add-tag,del-host,del-tag,list} ... - - cdist inventory add-host [-h] [-l LOGLEVEL] [-q] [-v] [-b] - [-g CONFIG_FILE] [-I INVENTORY_DIR] - [-f HOSTFILE] - [host [host ...]] - - cdist inventory add-tag [-h] [-l LOGLEVEL] [-q] [-v] [-b] - [-g CONFIG_FILE] [-I INVENTORY_DIR] - [-f HOSTFILE] [-T TAGFILE] [-t TAGLIST] - [host [host ...]] - - cdist inventory del-host [-h] [-l LOGLEVEL] [-q] [-v] [-b] - [-g CONFIG_FILE] [-I INVENTORY_DIR] [-a] - [-f HOSTFILE] - [host [host ...]] - - cdist inventory del-tag [-h] [-l LOGLEVEL] [-q] [-v] [-b] - [-g CONFIG_FILE] [-I INVENTORY_DIR] [-a] - [-f HOSTFILE] [-T TAGFILE] [-t TAGLIST] - [host [host ...]] - - cdist inventory list [-h] [-l LOGLEVEL] [-q] [-v] [-b] [-g CONFIG_FILE] - [-I INVENTORY_DIR] [-a] [-f HOSTFILE] [-H] [-t] - [host [host ...]] - - cdist shell [-h] [-l LOGLEVEL] [-q] [-v] [-s SHELL] - - -DESCRIPTION ------------ -cdist is the frontend executable to the cdist configuration management. -It supports different subcommands as explained below. - -It is written in Python so it requires :strong:`python`\ (1) to be installed. -It requires a minimal Python version 3.2. - -GENERAL -------- -All commands accept the following options: - -**-h, --help** - Show the help screen. - -**-l LOGLEVEL, --log-level LOGLEVEL** - Set the specified verbosity level. The levels, in - order from the lowest to the highest, are: ERROR (-1), - WARNING (0), INFO (1), VERBOSE (2), DEBUG (3) TRACE (4 - or higher). If used along with -v then -v increases - last set value and -l overwrites last set value. - -**-q, --quiet** - Quiet mode: disables logging, including WARNING and ERROR. - -**-v, --verbose** - Increase the verbosity level. Every instance of -v - increments the verbosity level by one. Its default - value is 0 which includes ERROR and WARNING levels. - The levels, in order from the lowest to the highest, - are: ERROR (-1), WARNING (0), INFO (1), VERBOSE (2), - DEBUG (3) TRACE (4 or higher). If used along with -l - then -l overwrites last set value and -v increases - last set value. - -**-V, --version** - Show version and exit. - - -BANNER ------- -Displays the cdist banner. Useful for printing -cdist posters - a must have for every office. - - -CONFIG/INSTALL --------------- -Configure/install one or more hosts. -Install command is currently in beta. - -**-4, --force-ipv4** - Force to use IPv4 addresses only. No influence for - custom remote commands. - -**-6, --force-ipv6** - Force to use IPv6 addresses only. No influence for - custom remote commands. - -**-A, --all-tagged** - Use all hosts present in tags db. Currently in beta. - -**-a, --all** - List hosts that have all specified tags, if -t/--tag - is specified. - -**-b, --beta** - Enable beta functionality. - -**-C CACHE_PATH_PATTERN, --cache-path-pattern CACHE_PATH_PATTERN** - Specify custom cache path pattern. If it is not set then - default hostdir is used. For more info on format see - :strong:`CACHE PATH PATTERN FORMAT` below. - -**-c CONF_DIR, --conf-dir CONF_DIR** - Add a configuration directory. Can be specified multiple times. - If configuration directories contain conflicting types, explorers or - manifests, then the last one found is used. - -**-f HOSTFILE, --file HOSTFILE** - Read specified file for a list of additional hosts to operate on - or if '-' is given, read stdin (one host per line). - If no host or host file is specified then, by default, - read hosts from stdin. For the file format see - :strong:`HOSTFILE FORMAT` below. - -**-g CONFIG_FILE, --config-file CONFIG_FILE** - Use specified custom configuration file. - -**-I INVENTORY_DIR, --inventory INVENTORY_DIR** - Use specified custom inventory directory. Inventory - directory is set up by the following rules: if cdist - configuration resolves this value then specified - directory is used, if HOME env var is set then - ~/.cdit/inventory is used, otherwise distribution - inventory directory is used. - -**-i MANIFEST, --initial-manifest MANIFEST** - Path to a cdist manifest or - to read from stdin. - -**-j [JOBS], --jobs [JOBS]** - Operate in parallel in specified maximum number of - jobs. Global explorers, object prepare and object run - are supported. Without argument CPU count is used by - default. - -**-n, --dry-run** - Do not execute code. - -**-o OUT_PATH, --out-dir OUT_PATH** - Directory to save cdist output in. - -**-P, --timestamp** - Timestamp log messages with the current local date and time - in the format: YYYYMMDDHHMMSS.us. - -**-p [HOST_MAX], --parallel [HOST_MAX]** - Operate on multiple hosts in parallel for specified - maximum hosts at a time. Without argument CPU count is - used by default. - -**-R [{tar,tgz,tbz2,txz}], --use-archiving [{tar,tgz,tbz2,txz}]** - Operate by using archiving with compression where - appropriate. Supported values are: tar - tar archive, - tgz - gzip tar archive (the default), tbz2 - bzip2 tar - archive and txz - lzma tar archive. Currently in beta. - -**-r REMOTE_OUT_PATH, --remote-out-dir REMOTE_OUT_PATH** - Directory to save cdist output in on the target host. - -**-S, --disable-saving-output-streams** - Disable saving output streams. - -**-s, --sequential** - Operate on multiple hosts sequentially (default). - -**--remote-copy REMOTE_COPY** - Command to use for remote copy (should behave like scp). - -**--remote-exec REMOTE_EXEC** - Command to use for remote execution (should behave like ssh). - -**-t, --tag** - Host is specified by tag, not hostname/address; list - all hosts that contain any of specified tags. - Currently in beta. - -HOSTFILE FORMAT -~~~~~~~~~~~~~~~ -The HOSTFILE contains one host per line. -A comment is started with '#' and continues to the end of the line. -Any leading and trailing whitespace on a line is ignored. -Empty lines are ignored/skipped. - - -The Hostfile lines are processed as follows. First, all comments are -removed. Then all leading and trailing whitespace characters are stripped. -If such a line results in empty line it is ignored/skipped. Otherwise, -host string is used. - -CACHE PATH PATTERN FORMAT -~~~~~~~~~~~~~~~~~~~~~~~~~ -Cache path pattern specifies path for a cache directory subdirectory. -In the path, '%N' will be substituted by the target host, '%h' will -be substituted by the calculated host directory, '%P' will be substituted -by the current process id. All format codes that -:strong:`python` :strong:`datetime.strftime()` function supports, except -'%h', are supported. These date/time directives format cdist config/install -start time. - -If empty pattern is specified then default calculated host directory -is used. - -Calculated host directory is a hash of a host cdist operates on. - -Resulting path is used to specify cache path subdirectory under which -current host cache data are saved. - - -INVENTORY ---------- -Manage inventory database. -Currently in beta with all sub-commands. - - -INVENTORY ADD-HOST ------------------- -Add host(s) to inventory database. - -**host** - Host(s) to add. - -**-b, --beta** - Enable beta functionality. - -**-f HOSTFILE, --file HOSTFILE** - Read additional hosts to add from specified file or - from stdin if '-' (each host on separate line). If no - host or host file is specified then, by default, read - from stdin. Hostfile format is the same as config hostfile format. - -**-g CONFIG_FILE, --config-file CONFIG_FILE** - Use specified custom configuration file. - -**-I INVENTORY_DIR, --inventory INVENTORY_DIR** - Use specified custom inventory directory. Inventory - directory is set up by the following rules: if cdist - configuration resolves this value then specified - directory is used, if HOME env var is set then - ~/.cdit/inventory is used, otherwise distribution - inventory directory is used. - - -INVENTORY ADD-TAG ------------------ -Add tag(s) to inventory database. - -**host** - List of host(s) for which tags are added. - -**-b, --beta** - Enable beta functionality. - -**-f HOSTFILE, --file HOSTFILE** - Read additional hosts to add tags from specified file - or from stdin if '-' (each host on separate line). If - no host or host file is specified then, by default, - read from stdin. If no tags/tagfile nor hosts/hostfile - are specified then tags are read from stdin and are - added to all hosts. Hostfile format is the same as config hostfile format. - -**-g CONFIG_FILE, --config-file CONFIG_FILE** - Use specified custom configuration file. - -**-I INVENTORY_DIR, --inventory INVENTORY_DIR** - Use specified custom inventory directory. Inventory - directory is set up by the following rules: if cdist - configuration resolves this value then specified - directory is used, if HOME env var is set then - ~/.cdit/inventory is used, otherwise distribution - inventory directory is used. - -**-T TAGFILE, --tag-file TAGFILE** - Read additional tags to add from specified file or - from stdin if '-' (each tag on separate line). If no - tag or tag file is specified then, by default, read - from stdin. If no tags/tagfile nor hosts/hostfile are - specified then tags are read from stdin and are added - to all hosts. Tagfile format is the same as config hostfile format. - -**-t TAGLIST, --taglist TAGLIST** - Tag list to be added for specified host(s), comma - separated values. - - -INVENTORY DEL-HOST ------------------- -Delete host(s) from inventory database. - -**host** - Host(s) to delete. - -**-a, --all** - Delete all hosts. - -**-b, --beta** - Enable beta functionality. - -**-f HOSTFILE, --file HOSTFILE** - Read additional hosts to delete from specified file or - from stdin if '-' (each host on separate line). If no - host or host file is specified then, by default, read - from stdin. Hostfile format is the same as config hostfile format. - -**-g CONFIG_FILE, --config-file CONFIG_FILE** - Use specified custom configuration file. - -**-I INVENTORY_DIR, --inventory INVENTORY_DIR** - Use specified custom inventory directory. Inventory - directory is set up by the following rules: if cdist - configuration resolves this value then specified - directory is used, if HOME env var is set then - ~/.cdit/inventory is used, otherwise distribution - inventory directory is used. - - -INVENTORY DEL-TAG ------------------ -Delete tag(s) from inventory database. - -**host** - List of host(s) for which tags are deleted. - -**-a, --all** - Delete all tags for specified host(s). - -**-b, --beta** - Enable beta functionality. - -**-f HOSTFILE, --file HOSTFILE** - Read additional hosts to delete tags for from - specified file or from stdin if '-' (each host on - separate line). If no host or host file is specified - then, by default, read from stdin. If no tags/tagfile - nor hosts/hostfile are specified then tags are read - from stdin and are deleted from all hosts. Hostfile - format is the same as config hostfile format. - -**-g CONFIG_FILE, --config-file CONFIG_FILE** - Use specified custom configuration file. - -**-I INVENTORY_DIR, --inventory INVENTORY_DIR** - Use specified custom inventory directory. Inventory - directory is set up by the following rules: if cdist - configuration resolves this value then specified - directory is used, if HOME env var is set then - ~/.cdit/inventory is used, otherwise distribution - inventory directory is used. - -**-T TAGFILE, --tag-file TAGFILE** - Read additional tags from specified file or from stdin - if '-' (each tag on separate line). If no tag or tag - file is specified then, by default, read from stdin. - If no tags/tagfile nor hosts/hostfile are specified - then tags are read from stdin and are added to all - hosts. Tagfile format is the same as config hostfile format. - -**-t TAGLIST, --taglist TAGLIST** - Tag list to be deleted for specified host(s), comma - separated values. - - -INVENTORY LIST --------------- -List inventory database. - -**host** - Host(s) to list. - -**-a, --all** - List hosts that have all specified tags, if -t/--tag - is specified. - -**-b, --beta** - Enable beta functionality. - -**-f HOSTFILE, --file HOSTFILE** - Read additional hosts to list from specified file or - from stdin if '-' (each host on separate line). If no - host or host file is specified then, by default, list - all. Hostfile format is the same as config hostfile format. - -**-g CONFIG_FILE, --config-file CONFIG_FILE** - Use specified custom configuration file. - -**-H, --host-only** - Suppress tags listing. - -**-I INVENTORY_DIR, --inventory INVENTORY_DIR** - Use specified custom inventory directory. Inventory - directory is set up by the following rules: if cdist - configuration resolves this value then specified - directory is used, if HOME env var is set then - ~/.cdit/inventory is used, otherwise distribution - inventory directory is used. - -**-t, --tag** - Host is specified by tag, not hostname/address; list - all hosts that contain any of specified tags. - - -SHELL ------ -This command allows you to spawn a shell that enables access -to the types as commands. It can be thought as an -"interactive manifest" environment. See below for example -usage. Its primary use is for debugging type parameters. - -**-s SHELL, --shell SHELL** - Select shell to use, defaults to current shell. Used shell should - be POSIX compatible shell. - - -CONFIGURATION -------------- -cdist obtains configuration data from the following sources in the following -order (from higher to lower precedence): - - #. command-line options - #. configuration file specified at command-line - #. configuration file specified in CDIST_CONFIG_FILE environment variable - #. environment variables - #. user's configuration file (first one found of ~/.cdist.cfg, $XDG_CONFIG_HOME/cdist/cdist.cfg, in specified order) - #. system-wide configuration file (/etc/cdist.cfg). - -CONFIGURATION FILE FORMAT -~~~~~~~~~~~~~~~~~~~~~~~~~ -cdist configuration file is in the INI file format. Currently it supports -only [GLOBAL] section. -The possible keywords and their meanings are as follows: - -:strong:`archiving` - Use specified archiving. Valid values include: - 'none', 'tar', 'tgz', 'tbz2' and 'txz'. - -:strong:`beta` - Enable beta functionality. It recognizes boolean values from - 'yes'/'no', 'on'/'off', 'true'/'false' and '1'/'0'. - -:strong:`cache_path_pattern` - Specify cache path pattern. - -:strong:`conf_dir` - List of configuration directories separated with the character conventionally - used by the operating system to separate search path components (as in PATH), - such as ':' for POSIX or ';' for Windows. - If also specified at command line then values from command line are - appended to this value. - -:strong:`init_manifest` - Specify default initial manifest. - -:strong:`inventory_dir` - Specify inventory directory. - -:strong:`jobs` - Specify number of jobs for parallel processing. If -1 then the default, - number of CPU's in the system is used. If 0 then parallel processing in - jobs is disabled. If set to positive number then specified maximum - number of processes will be used. - -:strong:`local_shell` - Shell command used for local execution. - -:strong:`out_path` - Directory to save cdist output in. - -:strong:`parallel` - Process hosts in parallel. If -1 then the default, number of CPU's in - the system is used. If 0 then parallel processing of hosts is disabled. - If set to positive number then specified maximum number of processes - will be used. - -:strong:`remote_copy` - Command to use for remote copy (should behave like scp). - -:strong:`remote_exec` - Command to use for remote execution (should behave like ssh). - -:strong:`remote_out_path` - Directory to save cdist output in on the target host. - -:strong:`remote_shell` - Shell command at remote host used for remote execution. - -:strong:`save_output_streams` - Enable/disable saving output streams (enabled by default). - It recognizes boolean values from 'yes'/'no', 'on'/'off', 'true'/'false' - and '1'/'0'. - -:strong:`timestamp` - Timestamp log messages with the current local date and time - in the format: YYYYMMDDHHMMSS.us. - -:strong:`verbosity` - Set verbosity level. Valid values are: - 'ERROR', 'WARNING', 'INFO', 'VERBOSE', 'DEBUG', 'TRACE' and 'OFF'. - - -FILES ------ -~/.cdist - Your personal cdist config directory. If exists it will be - automatically used. -~/.cdist/cache - Local cache directory. -~/.cdist/inventory - The home inventory directory. If ~/.cdist exists it will be used as - default inventory directory. -cdist/conf - The distribution configuration directory. It contains official types and - explorers. This path is relative to cdist installation directory. -cdist/inventory - The distribution inventory directory. - This path is relative to cdist installation directory. -/etc/cdist.cfg - Global cdist configuration file, if exists. -~/.cdist.cfg or $XDG_CONFIG_HOME/cdist/cdist.cfg - Local cdist configuration file, if exists. - -NOTES ------ -cdist detects if host is specified by IPv6 address. If so then remote_copy -command is executed with host address enclosed in square brackets -(see :strong:`scp`\ (1)). - -EXAMPLES --------- - -.. code-block:: sh - - # Configure ikq05.ethz.ch with debug enabled - % cdist config -vvv ikq05.ethz.ch - - # Configure hosts in parallel and use a different configuration directory - % cdist config -c ~/p/cdist-nutzung \ - -p ikq02.ethz.ch ikq03.ethz.ch ikq04.ethz.ch - - # Use custom remote exec / copy commands - % cdist config --remote-exec /path/to/my/remote/exec \ - --remote-copy /path/to/my/remote/copy \ - -p ikq02.ethz.ch ikq03.ethz.ch ikq04.ethz.ch - - # Configure hosts read from file loadbalancers - % cdist config -f loadbalancers - - # Configure hosts read from file web.hosts using 16 parallel jobs - # (beta functionality) - % cdist config -b -j 16 -f web.hosts - - # Display banner - cdist banner - - # Show help - % cdist --help - - # Show Version - % cdist --version - - # Enter a shell that has access to emulated types - % cdist shell - % __git - usage: __git --source SOURCE [--state STATE] [--branch BRANCH] - [--group GROUP] [--owner OWNER] [--mode MODE] object_id - - # Install ikq05.ethz.ch with debug enabled - % cdist install -vvv ikq05.ethz.ch - - # List inventory content - % cdist inventory list -b - - # List inventory for specified host localhost - % cdist inventory list -b localhost - - # List inventory for specified tag loadbalancer - % cdist inventory list -b -t loadbalancer - - # Add hosts to inventory - % cdist inventory add-host -b web1 web2 web3 - - # Delete hosts from file old-hosts from inventory - % cdist inventory del-host -b -f old-hosts - - # Add tags to specified hosts - % cdist inventory add-tag -b -t europe,croatia,web,static web1 web2 - - # Add tag to all hosts in inventory - % cdist inventory add-tag -b -t vm - - # Delete all tags from specified host - % cdist inventory del-tag -b -a localhost - - # Delete tags read from stdin from hosts specified by file hosts - % cdist inventory del-tag -b -T - -f hosts - - # Configure hosts from inventory with any of specified tags - % cdist config -b -t web dynamic - - # Configure hosts from inventory with all specified tags - % cdist config -b -t -a web dynamic - - # Configure all hosts from inventory db - $ cdist config -b -A - - -ENVIRONMENT ------------ -TMPDIR, TEMP, TMP - Setup the base directory for the temporary directory. - See http://docs.python.org/py3k/library/tempfile.html for - more information. This is rather useful, if the standard - directory used does not allow executables. - -CDIST_PATH - Colon delimited list of config directories. - -CDIST_LOCAL_SHELL - Selects shell for local script execution, defaults to /bin/sh. - -CDIST_REMOTE_SHELL - Selects shell for remote script execution, defaults to /bin/sh. - -CDIST_OVERRIDE - Allow overwriting type parameters. - -CDIST_ORDER_DEPENDENCY - Create dependencies based on the execution order. - -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). - -CDIST_INVENTORY_DIR - Use this directory as inventory directory. - -CDIST_BETA - Enable beta functionality. - -CDIST_CACHE_PATH_PATTERN - Custom cache path pattern. - -CDIST_CONFIG_FILE - Custom configuration file. - - -EXIT STATUS ------------ -The following exit values shall be returned: - -0 Successful completion. - -1 One or more host configurations failed. - - -AUTHORS -------- -Originally written by Nico Schottelius -and Steven Armstrong . - - -CAVEATS -------- -When operating in parallel, either by operating in parallel for each host -(-p/--parallel) or by parallel jobs within a host (-j/--jobs), and depending -on target SSH server and its configuration you may encounter connection drops. -This is controlled with sshd :strong:`MaxStartups` configuration options. -You may also encounter session open refusal. This happens with ssh multiplexing -when you reach maximum number of open sessions permitted per network -connection. In this case ssh will disable multiplexing. -This limit is controlled with sshd :strong:`MaxSessions` configuration -options. For more details refer to :strong:`sshd_config`\ (5). - -When requirements for the same object are defined in different manifests (see -example below), for example, in init manifest and in some other type manifest -and those requirements differ then dependency resolver cannot detect -dependencies correctly. This happens because cdist cannot prepare all objects first -and run all objects afterwards. Some object can depend on the result of type -explorer(s) and explorers are executed during object run. cdist will detect -such case and display a warning message. An example of such a case: - -.. code-block:: sh - - init manifest: - __a a - require="__e/e" __b b - require="__f/f" __c c - __e e - __f f - require="__c/c" __d d - __g g - __h h - - type __g manifest: - require="__c/c __d/d" __a a - - Warning message: - WARNING: cdisttesthost: Object __a/a already exists with requirements: - /usr/home/darko/ungleich/cdist/cdist/test/config/fixtures/manifest/init-deps-resolver /tmp/tmp.cdist.test.ozagkg54/local/759547ff4356de6e3d9e08522b0d0807/data/conf/type/__g/manifest: set() - /tmp/tmp.cdist.test.ozagkg54/local/759547ff4356de6e3d9e08522b0d0807/data/conf/type/__g/manifest: {'__c/c', '__d/d'} - Dependency resolver could not handle dependencies as expected. - -COPYING -------- -Copyright \(C) 2011-2017 Nico Schottelius. Free use of this software is -granted under the terms of the GNU General Public License v3 or later (GPLv3+). diff --git a/docs/src/man7/.gitignore b/docs/src/man7/.gitignore deleted file mode 100644 index e69de29b..00000000 diff --git a/docs/web/cdist.mdwn b/docs/web/cdist.mdwn new file mode 100644 index 00000000..74457fc8 --- /dev/null +++ b/docs/web/cdist.mdwn @@ -0,0 +1,21 @@ +[[!meta title="cdist - usable configuration management"]] + +![cdist-logo](cdist-logo.png "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](http://trac.mcs.anl.gov/projects/bcfg2), +[chef](http://wiki.opscode.com/display/chef/), +[cfengine](http://www.cfengine.org/) +and [puppet](http://www.puppetlabs.com/). + + * [[Why should I use cdist?|why]] + * [[Documentation|documentation]] + * [[Supported Operating Systems|os]] + * [[Installation|install]] + * [[Update|update]] + * [[Support|support]] + +[[!tag cdist unix]] diff --git a/docs/src/_static/cdist-logo.png b/docs/web/cdist/cdist-logo.png similarity index 100% rename from docs/src/_static/cdist-logo.png rename to docs/web/cdist/cdist-logo.png diff --git a/docs/web/cdist/documentation.mdwn b/docs/web/cdist/documentation.mdwn new file mode 100644 index 00000000..db25b566 --- /dev/null +++ b/docs/web/cdist/documentation.mdwn @@ -0,0 +1,9 @@ +[[!meta title="Documentation"]] + +You can browse the latest +[latest version of the manpages](/software/cdist/man/latest) or +have a look at [all versions](/software/cdist/man). + +You can also view [speeches about cdist](/software/cdist/speeches). + +[[!tag cdist unix]] diff --git a/docs/web/cdist/features.mdwn b/docs/web/cdist/features.mdwn new file mode 100644 index 00000000..a97f2013 --- /dev/null +++ b/docs/web/cdist/features.mdwn @@ -0,0 +1,26 @@ +But cdist ticks differently, here is the feature set that makes it unique: + +[[!table data=""" +Keywords | Description +Simplicity | There is only one type to extend cdist called ***type*** +Design | Type and core cleanly seperated +Design | Sticks completly to the KISS (keep it simple and stupid) paradigma +Design | Meaningful error messages - do not lose time debugging error messages +Design | Consistency in behaviour, naming and documentation +Design | No surprise factor: Only do what is obviously clear, no magic +Design | Define target state, do not focus on methods or scripts +Design | 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 +Fast development | 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](http://www.openssh.com/) as transport protocol +Requirements, Simplicity | Requires only shell and SSH server on the target +UNIX | Reuse of existing tools like cat, find, mv, ... +UNIX, familar environment, documentation | Is available as manpages and HTML +UNIX, simplicity, familar environment | cdist is configured in POSIX shell +"""]] + +[[!tag cdist unix]] diff --git a/docs/web/cdist/install.mdwn b/docs/web/cdist/install.mdwn new file mode 100644 index 00000000..c81354f0 --- /dev/null +++ b/docs/web/cdist/install.mdwn @@ -0,0 +1,183 @@ +[[!meta title="How to install cdist"]] +[[!toc levels=3]] + +## 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 + * Asciidoc and xsltproc (for building the manpages) + +### Target Hosts + + * /bin/sh: A posix like shell (for instance bash, dash, zsh) + * SSH server + +## Requirement Installation: Python >= 3.2 + +Ensure you have at least Python 3.2 or newer installed on +the **source host**. +You can check this by running **python -V**: + + % python -V + Python 3.3.0 + +### Archlinux + +Archlinux includes a recent python in the extra repository. +You can install it using + + pacman -S python + +### CentOS + +See the "From source" section + +### Debian + +For Debian **wheezy** or newer: + + aptitude install python3 + +On **squeeze** you can add following line in **/etc/apt/sources.list** + + deb http://ftp.debian.org/debian wheezy main + +And add pinning entry in **/etc/apt/preferences.d/wheezy**: + + Package: * + Pin: release n=wheezy + Pin-Priority: 1 + +Please be aware that both **openssh-server** and **openssh-client** might be +removed on **python3.2** installation. You surely want to reinstall them: + + apt-get install -t wheezy openssh-server openssh-client + +For older Debian versions, installing python 3.2 from source is required. + +If you want to build the cdist manpages: + + aptitude install --without-recommends asciidoc xsltproc + +### Fedora + +Fedora 15 and newer includes a recent python. +You can install it using + + yum install python3 + +### FreeBSD + +For the port: + + cd /usr/ports/lang/python32/ && make install clean + +For the package: + + pkg_add -r python32 + +You can also use any newer version, but at least python 3.2 is required. + +### Gentoo + +Gentoo only provides python 3.2 in testing packages (http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?part=3&chap=3). +If you want to ensure nothing breaks you must set back the python version to what was default before. + + emerge -av =python-3.2.2 --autounmask-write + emerge -av =python-3.2.2 + eselect python list + eselect python list set python3.2 + +### Max OS X + +You can choose between Homebrew and Macports, either way works: + +[Homebrew](http://mxcl.github.com/homebrew/) variant: + + brew install python3 + +[Macports](http://www.macports.org/install.php) variant: + + port install python32 + ln -s /opt/local/bin/python3.2 /opt/local/bin/python3 + +### Redhat + +See the "From source" section + +### From Source + +For those operating systems not yet supporting Python 3.2: + + pyversion=3.2.3 + wget http://www.python.org/ftp/python/$pyversion/Python-${pyversion}.tar.bz2 + tar xvfj Python-${pyversion}.tar.bz2 + cd Python-${pyversion} + ./configure + make + sudo make install + +This installs python 3.2 to /usr/local/bin. +Ensure this directory is in your PATH environment variable. + +## 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: + + git clone git://git.schottelius.org/cdist + cd cdist + export PATH=$PATH:$(pwd -P)/bin + +If you want to build and use the manpages, run: + + make man + export MANPATH=$MANPATH:$(pwd -P)/doc/man + +#### Available versions in git + + * The active development takes place in the **master** branch + * The current stable version can be found in the **2.0** branch + * The upcoming stable version can be found in the **2.1** branch + +Other branches may be available for features or bugfixes, but they +may vanish at any point. To select a specific branch use + + # Generic code + git checkout -b origin/ + +So for instance if you want to use and stay with version 2.0, you can use + + git checkout -b 2.0 origin/2.0 + +#### 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](https://github.com/telmich/cdist)) + * git://git.code.sf.net/p/cdist/code ([sourceforge](https://sourceforge.net/p/cdist/code)) + +### Python Package + +Cdist is available as a python package at +[PyPi](http://pypi.python.org/pypi/cdist/). You can install it using + + pip install cdist + +## Use cdist + +[[Dig into the documentation|documentation]] to get started with cdist! + +[[!tag cdist unix]] diff --git a/docs/web/cdist/os.mdwn b/docs/web/cdist/os.mdwn new file mode 100644 index 00000000..24992439 --- /dev/null +++ b/docs/web/cdist/os.mdwn @@ -0,0 +1,17 @@ +[[!meta title="Supported Operating Systems"]] + +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/) + * [Fedora](http://fedoraproject.org/) + * [FreeBSD](http://www.freebsd.org) + * [Gentoo](http://www.gentoo.org/) + * [Mac OS X](http://www.apple.com/macosx/) + * [OpenBSD](http://www.openbsd.org) + * [Redhat](http://www.redhat.com/) + * [Ubuntu](http://www.ubuntu.com/) + * [XenServer](http://www.citrix.com/xenserver/) + +[[!tag cdist unix]] diff --git a/docs/web/cdist/support.mdwn b/docs/web/cdist/support.mdwn new file mode 100644 index 00000000..39388c5a --- /dev/null +++ b/docs/web/cdist/support.mdwn @@ -0,0 +1,25 @@ +## Support + +### IRC + +You can join the development ***IRC channel*** +[#cstar on irc.freenode.net](irc://irc.freenode.org/#cstar). + +### Mailing list + +Bug reports, questions, patches, etc. should be send to the +[cdist mailing list](http://l.schottelius.org/mailman/listinfo/cdist). + +### Linkedin + +If you have an account +at [Linked in](http://www.linkedin.com/), +you can join the +[cdist group](http://www.linkedin.com/groups/cdist-configuration-management-3952797). + +### Commercial support + +You can request commercial support for cdist from +[my company](http://www.ungleich.ch/english/). + +[[!tag cdist unix]] diff --git a/docs/src/cdist-upgrade.rst b/docs/web/cdist/update.mdwn similarity index 78% rename from docs/src/cdist-upgrade.rst rename to docs/web/cdist/update.mdwn index e57ed63c..28f41da7 100644 --- a/docs/src/cdist-upgrade.rst +++ b/docs/web/cdist/update.mdwn @@ -1,13 +1,9 @@ -How to upgrade cdist -==================== +[[!meta title="How to update cdist"]] -Update the git installation ---------------------------- +## Update The Git Installation To upgrade cdist in the current branch use -.. code-block:: sh - git pull # Also update the manpages @@ -18,14 +14,11 @@ 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 -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +### 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 @@ -43,8 +36,6 @@ 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 ... @@ -53,67 +44,50 @@ the migration/update, you can do so as follows: After that, you can go back and continue the upgrade: -.. code-block:: sh - # git checkout upgrade_cdist -Update the python package -------------------------- +## Update The Python Package To upgrade to the lastet version do -.. code-block:: sh - pip install --upgrade cdist -General update instructions ---------------------------- +## General Update Instructions -Updating from 3.0 to 3.1 -~~~~~~~~~~~~~~~~~~~~~~~~ +### 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 -~~~~~~~~~~~~~~~~~~~~~~~~ +### Updating from 2.3 to 3.0 The **changed** attribute of objects has been removed. -Use `messaging `_ instead. +Use [messaging](/software/cdist/man/3.0.0/man7/cdist-messaging.html) instead. -Updating from 2.2 to 2.3 -~~~~~~~~~~~~~~~~~~~~~~~~ +### Updating from 2.2 to 2.3 -No incompatibilities. +No incompatiblities. -Updating from 2.1 to 2.2 -~~~~~~~~~~~~~~~~~~~~~~~~ +### 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 -~~~~~~~~~~~~~~~~~~~~~~~~ - +### 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**. @@ -137,8 +111,7 @@ Have a look at the update guide for [[2.0 to 2.1|2.0-to-2.1]]. * Type **\_\_ssh_authorized_key** has been replaced by more flexible type **\_\_ssh_authorized_keys** -Updating from 1.7 to 2.0 -~~~~~~~~~~~~~~~~~~~~~~~~ +### 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" @@ -146,14 +119,12 @@ Updating from 1.7 to 2.0 * Use "cdist banner" for fun * Use **\_\_object_name** instead of **\_\_self** in manifests -Updating from 1.6 to 1.7 -~~~~~~~~~~~~~~~~~~~~~~~~ +### 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 -~~~~~~~~~~~~~~~~~~~~~~~~ +### Updating from 1.5 to 1.6 * If you used **\_\_package_apt --preseed**, you need to use the new type **\_\_debconf_set_selections** instead. @@ -161,23 +132,19 @@ Updating from 1.5 to 1.6 --state uninstaaled. Starting with 1.6, it was made consistently to --state removed. -Updating from 1.3 to 1.5 -~~~~~~~~~~~~~~~~~~~~~~~~ +### Updating from 1.3 to 1.5 -No incompatibilities. +No incompatiblities. -Updating from 1.2 to 1.3 -~~~~~~~~~~~~~~~~~~~~~~~~ +### Updating from 1.2 to 1.3 Rename **gencode** of every type to **gencode-remote**. -Updating from 1.1 to 1.2 -~~~~~~~~~~~~~~~~~~~~~~~~ +### Updating from 1.1 to 1.2 -No incompatibilities. +No incompatiblities. -Updating from 1.0 to 1.1 -~~~~~~~~~~~~~~~~~~~~~~~~ +### 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 @@ -186,3 +153,6 @@ 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 + + +[[!tag cdist unix]] diff --git a/docs/web/cdist/update/2.0-to-2.1.mdwn b/docs/web/cdist/update/2.0-to-2.1.mdwn new file mode 100644 index 00000000..1d0037ab --- /dev/null +++ b/docs/web/cdist/update/2.0-to-2.1.mdwn @@ -0,0 +1,118 @@ +[[!meta title="Update Guide for 2.0 to 2.1"]] + +## Introduction + +When changing your installation from 2.0 to 2.1, there are +a lot of changes coming up. 2.1 is mainly a cleanup release, +which removes long time deprecated behaviour, but also makes +a lot of things more consistent and allows you to split off your types, +explorers and manifest to custom directories. + +This document will guide you to a successful update. + +## Preperation + +As for every software and system you use in production, you should first of +all make a backup of your data. To prevent any breakage, it is +recommended to create a new git branch to do the update on: + + % git checkout -b update_to_2.1 + +This also ensure that whenever you need to do a change in your +2.0 based tree, you can simply go back to that branch, apply the change +and configure your systems - independently of your update progress! + +Next fetch the latest upstream changes, I assume that +origin refers to one of the upstream mirrors (change origin if you use +another remote name for upstream cdist): + + % git fetch -v origin + +## Merge the changes + +Now try to merge upstream into the new branch. + + % git merge origin/2.1 + +Fix any conflicts that may have been occurred due to local changes +and then **git add** and *git commit** those changes. This should seldomly +occur and if, it's mostly for people hacking on the cdist core. + +## Move "conf" directory + +One of the biggest changes in cdist 2.1 is that you can have multiple +**conf** directories: Indeed, the new default behaviour of cdist is to +search for conf directories + + * below the python module (cdist/conf in the source tree or in the installed location) + * at ~/.cdist/ (on conf suffix there) + +So you can now choose, where to store your types. + +### Integrate your conf/ back into the tree + +If you choose to store your types together with the upstream types, +you can just move all your stuff below **cdist/conf**: + + % git mv conf/type/* cdist/conf/type + % git mv conf/manifest/* cdist/conf/manifest + % git mv conf/explorer/* cdist/conf/explorer + % git commit -m "Re-Integrate my conf directory into cdist 2.1 tree" + +### Move your conf/ directory to ~/.cdist + +If you want to store your site specific +configuration outside of the cdist tree, you +can move your conf/ directory to your homedirectory ($HOME) under ~/.cdist: + + % mv conf ~/.cdist + % git rm -r conf + % git commit -m "Move my conf directory to ~/.cdist" + +It it still recommended to use a version control system like git in it: + + % cd ~/.cdist + % git init + % git add . + % git commit -m "Create new git repository containing my cdist configuration" + +## Test the migration + +Some of the types shipped with upstream were changed, so you may want to test +the result by running cdist on one of your staging target hosts: + + % ./bin/cdist config -v staging-host + +All incompatibilities are listed on the [[cdist update page|software/cdist/update]], +so you can browse through the list and update your configuration. + +## Final Cleanups + +When everything is tested, there are some cleanups to be done to finalise the update. + +### When continuing to keep conf/ in the tree + +You can then merge back your changes into the master tree and continue to work +as normal. + +### When using ~/.cdist + +If you decided to move your site specific code to ~/.cdist, you can now switch your +**master** branch or version branch to upstream directly. Assumnig you are in the +cdist directory, having your previous branch checked out, you can create a clean +state using the following commands: + + % upstream_branch=2.1 + % current_branch=$(git rev-parse --abbrev-ref HEAD) + % git checkout -b archive_my_own_tree + % git branch -D "$current_branch" + % git checkout -b "$current_branch" "origin/$upstream_branch" + +Afther these commands, your previous main branch is accessible at +**archive_my_own_tree** and your branch is now tracking upstream. + +## Questions? Critics? Hints? + +If you think this manual helped or misses some information, do not +hesitate to contact us on any of the usual ways (irc, mailinglist, +github issue tracker, ...). diff --git a/docs/src/cdist-why.rst b/docs/web/cdist/why.mdwn similarity index 67% rename from docs/src/cdist-why.rst rename to docs/web/cdist/why.mdwn index 1123a1de..f571555c 100644 --- a/docs/src/cdist-why.rst +++ b/docs/web/cdist/why.mdwn @@ -1,21 +1,20 @@ -Why should I use cdist? -======================= +[[!meta title="Why should I use cdist?"]] + +[[!toc]] There are several motivations to use cdist, these are probably the most popular ones. -Known language --------------- +## Known language Cdist is being configured in -`shell script `_. +[shell script](https://en.wikipedia.org/wiki/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 `_ +[DSL](https://en.wikipedia.org/wiki/Domain-specific_language) or programming language. -Powerful 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 @@ -27,46 +26,44 @@ which make daily work easy: * Loop support (**for, while**) * Support for dependencies between cdist types -More than shell scripting -------------------------- +## 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 +the results are +[idempotent](https://en.wikipedia.org/wiki/Idempotence). +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 ----------------------------------------- +## Zero dependency configuration management -Cdist requires very little on a target system. Even better, +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 high level programming +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 ------------------------ +## Push based distribution Cdist uses the push based model for configuration. In this -scenario, one (or more) computers connect to the target hosts +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 +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 ---------------- +## 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. + +[[!tag cdist unix]] diff --git a/hacking/.gitignore b/hacking/.gitignore deleted file mode 100644 index 375edb27..00000000 --- a/hacking/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -iso/ -*.iso -preos/ diff --git a/hacking/README b/hacking/README deleted file mode 100644 index 937564d5..00000000 --- a/hacking/README +++ /dev/null @@ -1,33 +0,0 @@ -- next step - - rootfs fix - - get working to login - - have sshd enabled - - kernel -> initramfs? - http://jootamam.net/howto-initramfs-image.htm - - busybox!! - -- everything into initramfs? - -- permission problem on various files below /etc - -- Target: - - get working iso - - have it configured and gathered by cdist? - - -- boot process via ...? - - systemd? - -- packaging via ... - - packages? - - binlist - - bootstrap of os - -> root permissions! - -- boot device - -- uefi support - [9:15] wurzel:hacking% pacman -Ql syslinux | grep ldlin - syslinux /usr/lib/syslinux/bios/ldlinux.c32 - syslinux /usr/lib/syslinux/efi32/ldlinux.e32 - syslinux /usr/lib/syslinux/efi64/ldlinux.e64 diff --git a/hacking/v1-debootstrap-pacstrap/arch_bootstrap.sh b/hacking/v1-debootstrap-pacstrap/arch_bootstrap.sh deleted file mode 100644 index 0472bf3c..00000000 --- a/hacking/v1-debootstrap-pacstrap/arch_bootstrap.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh - -fakeroot pacman -r $(pwd -P)/preos -Syu --noconfirm --cachedir $(pwd -P)/preos/var/cache/pacman base - diff --git a/hacking/v1-debootstrap-pacstrap/debian_bootstrap.sh b/hacking/v1-debootstrap-pacstrap/debian_bootstrap.sh deleted file mode 100644 index 75628116..00000000 --- a/hacking/v1-debootstrap-pacstrap/debian_bootstrap.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -fakeroot debootstrap jessie ./preos-debootstrap/ diff --git a/hacking/v2-initramfs-from-os/add_kernel_isolinux.sh b/hacking/v2-initramfs-from-os/add_kernel_isolinux.sh deleted file mode 100755 index ec7b610c..00000000 --- a/hacking/v2-initramfs-from-os/add_kernel_isolinux.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/sh - -# FIXME: Write cdist type / explorer that finds -# package for a file, distro independent - -if [ "$#" -ne 1 ]; then - echo "$0 dir-out" - exit 1 -fi - -dir=$1; shift -boot=$dir/boot - -mkdir -p "$boot" -cp /boot/vmlinuz-linux \ - /boot/initramfs-linux-fallback.img \ - /usr/lib/syslinux/bios/isolinux.bin \ - "$boot" - -cp /usr/lib/syslinux/bios/ldlinux.c32 \ - "$dir" - -cat > "$dir/isolinux.cfg" << eof -default preos -label preos -title cdist PreOS -linux /boot/vmlinuz-linux -initrd /boot/initramfs-linux-fallback.img -eof diff --git a/hacking/v2-initramfs-from-os/all.sh b/hacking/v2-initramfs-from-os/all.sh deleted file mode 100755 index fe3d6d11..00000000 --- a/hacking/v2-initramfs-from-os/all.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/sh - -set -e - -dir=./iso -iso=preos.iso - -./filelist_from_package.sh | ./filelist_to_dir.sh "$dir" -echo "MISSING: copy libraries" >&2 -./add_kernel_isolinux.sh "$dir" -./create_iso.sh "$dir" "$iso" diff --git a/hacking/v2-initramfs-from-os/bin_to_pkg.sh b/hacking/v2-initramfs-from-os/bin_to_pkg.sh deleted file mode 100755 index 111b1fa9..00000000 --- a/hacking/v2-initramfs-from-os/bin_to_pkg.sh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/sh - -abspath=$(command -v "$1") -pacman -Qoq "$abspath" diff --git a/hacking/v2-initramfs-from-os/copy_files_for_iso.sh b/hacking/v2-initramfs-from-os/copy_files_for_iso.sh deleted file mode 100755 index 0318c072..00000000 --- a/hacking/v2-initramfs-from-os/copy_files_for_iso.sh +++ /dev/null @@ -1,23 +0,0 @@ -#!/bin/sh - -set -ex - -testdir=./iso-root-dir - -# Create base -rm -rf "$testdir" -mkdir "$testdir" - -# Copy binaries - -# Copy kernel -mkdir -p "$testdir/boot" -cp /boot/vmlinuz-linux "$testdir/boot/kernel" -cp /boot/initramfs-linux-fallback.img "$testdir/boot/initramfs" - -# Create iso -genisoimage -v -V "cdist preos v0.1" \ - -cache-inodes -J -l \ - -r -no-emul-boot \ - -boot-load-size 4 -b isolinux.bin -c boot.cat -o cdist-preos.iso iso - diff --git a/hacking/v2-initramfs-from-os/file_list_of_packages.sh b/hacking/v2-initramfs-from-os/file_list_of_packages.sh deleted file mode 100644 index 608fdfbc..00000000 --- a/hacking/v2-initramfs-from-os/file_list_of_packages.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -pacman -Qlq "$@" diff --git a/hacking/v2-initramfs-from-os/filelist_from_package.sh b/hacking/v2-initramfs-from-os/filelist_from_package.sh deleted file mode 100755 index 5652ba66..00000000 --- a/hacking/v2-initramfs-from-os/filelist_from_package.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/sh - -# Generate filelist excluding stuff that takes only space -( - for pkg in systemd openssh \ - bash bzip2 coreutils cryptsetup device-mapper dhcpcd \ - diffutils e2fsprogs file filesystem findutils gawk \ - gettext glibc grep gzip inetutils iproute2 \ - iputils jfsutils less licenses linux logrotate lvm2 \ - man-db man-pages mdadm nano pacman pciutils \ - pcmciautils procps-ng psmisc reiserfsprogs \ - s-nail sed shadow sysfsutils systemd-sysvcompat tar \ - usbutils util-linux vi which xfsprogs \ - ; do - pacman -Qlq $pkg | grep -v \ - -e /usr/share/man/ \ - -e /usr/share/doc/ \ - -e /usr/include - - done -) | sort | uniq diff --git a/hacking/v2-initramfs-from-os/filelist_to_dir.sh b/hacking/v2-initramfs-from-os/filelist_to_dir.sh deleted file mode 100755 index 3ce19b9f..00000000 --- a/hacking/v2-initramfs-from-os/filelist_to_dir.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/sh - -if [ "$#" -ne 1 ]; then - echo "$0 outdir" - exit 1 -fi - -outdir=$1; shift - -mkdir -p "$outdir" - -while read file; do - if [ -d "$file" ]; then - mkdir -p "$outdir$file" - else - cp --preserve=mode,links "$file" "$outdir$file" - fi -done diff --git a/hacking/v2-initramfs-from-os/packages_arch b/hacking/v2-initramfs-from-os/packages_arch deleted file mode 100644 index ed879512..00000000 --- a/hacking/v2-initramfs-from-os/packages_arch +++ /dev/null @@ -1,29 +0,0 @@ -base syslinux - -[10:06] wurzel:hacking% sudo !! -sudo pacman -S base -[sudo] password for nico: -:: linux is in IgnorePkg/IgnoreGroup. Install anyway? [Y/n] y -:: There are 50 members in group base: -:: Repository core - 1) bash 2) bzip2 3) coreutils 4) cryptsetup 5) device-mapper 6) dhcpcd 7) diffutils 8) e2fsprogs 9) file - 10) filesystem 11) findutils 12) gawk 13) gcc-libs 14) gettext 15) glibc 16) grep 17) gzip 18) inetutils - 19) iproute2 20) iputils 21) jfsutils 22) less 23) licenses 24) linux 25) logrotate 26) lvm2 27) man-db - 28) man-pages 29) mdadm 30) nano 31) netctl 32) pacman 33) pciutils 34) pcmciautils 35) perl 36) procps-ng - 37) psmisc 38) reiserfsprogs 39) s-nail 40) sed 41) shadow 42) sysfsutils 43) systemd-sysvcompat 44) tar - 45) texinfo 46) usbutils 47) util-linux 48) vi 49) which 50) xfsprogs - -Enter a selection (default=all): - -:18,23s/ [0-9]*)//g - - bash bzip2 coreutils cryptsetup device-mapper dhcpcd diffutils e2fsprogs file - filesystem findutils gawk gcc-libs gettext glibc grep gzip inetutils - iproute2 iputils jfsutils less licenses linux logrotate lvm2 man-db - man-pages mdadm nano netctl pacman pciutils pcmciautils perl procps-ng - psmisc reiserfsprogs s-nail sed shadow sysfsutils systemd-sysvcompat tar - texinfo usbutils util-linux vi which xfsprogs - -6J - -bash bzip2 coreutils cryptsetup device-mapper dhcpcd diffutils e2fsprogs file filesystem findutils gawk gcc-libs gettext glibc grep gzip inetutils iproute2 iputils jfsutils less licenses linux logrotate lvm2 man-db man-pages mdadm nano netctl pacman pciutils pcmciautils perl procps-ng psmisc reiserfsprogs s-nail sed shadow sysfsutils systemd-sysvcompat tar texinfo usbutils util-linux vi which xfsprogs diff --git a/hacking/v3-busybox/add_kernel_isolinux.sh b/hacking/v3-busybox/add_kernel_isolinux.sh deleted file mode 100755 index ac5d495b..00000000 --- a/hacking/v3-busybox/add_kernel_isolinux.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/sh - -# FIXME: distro specific kernel location - -if [ "$#" -ne 1 ]; then - echo "$0 dir-out" - exit 1 -fi - -dir=$1; shift -boot=$dir/boot - -mkdir -p "$boot" -cp /boot/vmlinuz-linux "$boot/linux" -cp /usr/lib/syslinux/bios/isolinux.bin "$boot" -cp /usr/lib/syslinux/bios/ldlinux.c32 "$dir" - -cat > "$dir/isolinux.cfg" << eof -default preos -label preos -title cdist PreOS -linux /boot/linux -initrd /boot/initramfs -eof diff --git a/hacking/v3-busybox/all.sh b/hacking/v3-busybox/all.sh deleted file mode 100755 index 65a3706b..00000000 --- a/hacking/v3-busybox/all.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh - -rm -rf preos -mkdir -p preos/boot - -./create_initramfs.sh > preos/boot/initramfs -./add_kernel_isolinux.sh preos -./copy_bin_with_libs.sh preos -./create_iso.sh preos preos.iso diff --git a/hacking/v3-busybox/copy_bin_with_libs.sh b/hacking/v3-busybox/copy_bin_with_libs.sh deleted file mode 100755 index ee2b532e..00000000 --- a/hacking/v3-busybox/copy_bin_with_libs.sh +++ /dev/null @@ -1,60 +0,0 @@ -#!/bin/sh -# Nico Schottelius -# Fri May 1 17:31:50 CEST 2015 - - -PATH=/bin:/sbin:/usr/bin:/usr/sbin - -if [ "$#" -ne 1 ]; then - echo "$0 dir-out" - exit 1 -fi - - -out_dir=$1 - -#bin_list="udevadm bash fdisk mount syslinux umount rm mv" -bin_list="udevadm fdisk" - -libs=$(mktemp /tmp/cdist-preos-libs.XXXXXXXXXXXXX) - -mkdir -p "$out_dir/bin" "$out_dir/lib" - -( - for bin in $bin_list; do - src=$(which "$bin") - cp "$src" "$out_dir/bin" - - ldd "$src" | sed -e 's/=>//' -e 's/(.*//' | awk '{ if(NF == 2) { print $2 } else { print $1 } }' - done -) | sort | uniq > "$libs" - - -while read lib; do - if echo $lib | grep '^/'; then - # echo "Copying fqdn lib $lib ..." - cp "$lib" "$out_dir/lib" - else - echo "How to copy $lib ?" - fi -done < "$libs" - - -rm -f "$libs" - -exit 0 - - -bin=$1 - -# Not used alternatives -# new_list=$(objdump -p /usr/bin/ls | awk '$1 ~ /NEEDED/ { print $2 }') -# ldconfig -p | grep 'libBrokenLocale.so.1$' | sed 's/.* => //' - - -for new_item in $new_list; do - - -done - -ldconfig -p | diff --git a/hacking/v3-busybox/create_initramfs.sh b/hacking/v3-busybox/create_initramfs.sh deleted file mode 100755 index f87a7ef6..00000000 --- a/hacking/v3-busybox/create_initramfs.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/sh -set -ex - - -initramfs_dir=$(mktemp -d /tmp/cdist-preos.XXXXXXX) -# initramfs_dir=$1 - -for dir in bin sbin etc proc sys newroot usr/bin usr/sbin; do - mkdir -p ${initramfs_dir}/$dir -done -touch ${initramfs_dir}/etc/mdev.conf - -cp init "${initramfs_dir}/init" -cp $(which busybox) "${initramfs_dir}/bin" - -for link in sh mount; do - ln -fs busybox "${initramfs_dir}/bin/$link" -done - -cd "${initramfs_dir}" -find . | cpio -H newc -o | gzip - -rm -rf "${initramfs_dir}" - -exit 0 - -# TODO: -# - Kernel modules -# - ssh -# - various mkfs -# - libs - diff --git a/hacking/v3-busybox/create_iso.sh b/hacking/v3-busybox/create_iso.sh deleted file mode 100755 index c6b39be6..00000000 --- a/hacking/v3-busybox/create_iso.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/sh - -# FIXME: include os explorer to name preos - -if [ "$#" -ne 2 ]; then - echo "$0 dir-in iso-out" - exit 1 -fi - -indir=$1; shift -iso=$1; shift - -version=0.4 - -out=preos-${version}.iso - - # -cache-inodes \ -genisoimage -r -J -l \ - -V "cdist PreOS $version" \ - -b boot/isolinux.bin -no-emul-boot -c boot.cat -boot-load-size 4 -boot-info-table \ - -o "$iso" "$indir" diff --git a/hacking/v3-busybox/init b/hacking/v3-busybox/init deleted file mode 100755 index a961526f..00000000 --- a/hacking/v3-busybox/init +++ /dev/null @@ -1,61 +0,0 @@ -#!/bin/sh - -#Create all the symlinks to /bin/busybox -/bin/busybox --install -s - -#Mount things needed by this script -mount -t proc proc /proc -mount -t sysfs sysfs /sys - -#Disable kernel messages from popping onto the screen -echo 0 > /proc/sys/kernel/printk - - -#Create device nodes -mknod /dev/null c 1 3 -mknod /dev/tty c 5 0 -mdev -s - -#Function for parsing command line options with "=" in them -# get_opt("init=/sbin/init") will return "/sbin/init" -get_opt() { - echo "$@" | cut -d "=" -f 2 -} - -#Defaults -init="/sbin/init" -root="/dev/hda1" - -#Process command line options -for i in $(cat /proc/cmdline); do - case $i in - root\=*) - root=$(get_opt $i) - ;; - init\=*) - init=$(get_opt $i) - ;; - esac -done - - -exec sh - -# Skipping the rest - -#Mount the root device -mount "${root}" /newroot - -#Check if $init exists and is executable -if [[ -x "/newroot/${init}" ]] ; then - #Unmount all other mounts so that the ram used by - #the initramfs can be cleared after switch_root - umount /sys /proc - - #Switch to the new root and execute init - exec switch_root /newroot "${init}" -fi - -#This will only be run if the exec above failed -echo "Failed to switch_root, dropping to a shell" -exec sh diff --git a/hacking/v3-busybox/qemu-test.sh b/hacking/v3-busybox/qemu-test.sh deleted file mode 100755 index 02afc2e6..00000000 --- a/hacking/v3-busybox/qemu-test.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/sh - -if [ "$#" -ne 1 ]; then - echo "$0 iso" - exit 1 -fi - -iso=$1; shift - -qemu-system-x86_64 -m 512 -boot order=cd \ - -drive file=$iso,media=cdrom - diff --git a/other/archived_types/.README.unmaintained b/other/archived_types/.README.unmaintained index 513f3b78..e9795911 100644 --- a/other/archived_types/.README.unmaintained +++ b/other/archived_types/.README.unmaintained @@ -1 +1 @@ -This type is not maintained anymore and has thus been removed from cdist. +This type is not maintained by anymore and has thus been removed from cdist. diff --git a/other/archived_types/__autofs/man.rst b/other/archived_types/__autofs/man.text similarity index 65% rename from other/archived_types/__autofs/man.rst rename to other/archived_types/__autofs/man.text index 4f02720e..9b343309 100644 --- a/other/archived_types/__autofs/man.rst +++ b/other/archived_types/__autofs/man.text @@ -1,10 +1,13 @@ cdist-type__autofs(7) ===================== -Install and start autofs - Steven Armstrong +NAME +---- +cdist-type__autofs - install and start autofs + + DESCRIPTION ----------- This space intentionally left blank. @@ -23,14 +26,14 @@ None. EXAMPLES -------- -.. code-block:: sh - - __autofs +-------------------------------------------------------------------------------- +__autofs +-------------------------------------------------------------------------------- SEE ALSO -------- -- `cdist-type(7) `_ +- cdist-type(7) COPYING diff --git a/other/archived_types/__autofs/manifest b/other/archived_types/__autofs/manifest index ed6e87ee..4a726c0a 100755 --- a/other/archived_types/__autofs/manifest +++ b/other/archived_types/__autofs/manifest @@ -23,7 +23,7 @@ os=$(cat "$__global/explorer/os") case "$os" in - ubuntu|debian|archlinux|devuan) + ubuntu|debian|archlinux) __package autofs --state present __start_on_boot autofs --state present ;; diff --git a/other/archived_types/__autofs_map/man.rst b/other/archived_types/__autofs_map/man.text similarity index 62% rename from other/archived_types/__autofs_map/man.rst rename to other/archived_types/__autofs_map/man.text index dfb79a27..50ce2fa8 100644 --- a/other/archived_types/__autofs_map/man.rst +++ b/other/archived_types/__autofs_map/man.text @@ -1,10 +1,13 @@ cdist-type__autofs_map(7) ========================= -Manage autofs maps - Steven Armstrong +NAME +---- +cdist-type__autofs_map - Manage autofs maps + + DESCRIPTION ----------- This cdist type allows you to define maps for autofs. @@ -17,50 +20,48 @@ The object_id is used as the mount-point as described in auto.master(5). REQUIRED PARAMETERS ------------------- -map +map:: Name of the map to use. See auto.master(5). OPTIONAL PARAMETERS ------------------- -type +type:: Type of map used for this mount point. Defaults to 'file'. See map-type in auto.master(5) for possible values. - -options +options:: See auto.master(5). - -comment +comment:: A comment describing this map. Is added to the generated entry in auto.master. BOOLEAN PARAMETERS ------------------ -noreload +noreload:: don't reload autofs after the entry has been changed EXAMPLES -------- -.. code-block:: sh +-------------------------------------------------------------------------------- +# Add auto mounter at /net and reload +__autofs_map /net --map /etc/auto.net --type program - # Add auto mounter at /net and reload - __autofs_map /net --map /etc/auto.net --type program - - # Add auto mounter at /pub and don't reload - __autofs_map /pub \ - --map /etc/auto.pub \ - --type file \ - --options "nosuid,rw,bg,hard,intr --ghost" \ - --noreload +# Add auto mounter at /pub and don't reload +__autofs_map /pub \ + --map /etc/auto.pub \ + --type file \ + --options "nosuid,rw,bg,hard,intr --ghost" \ + --noreload +-------------------------------------------------------------------------------- SEE ALSO -------- -- `cdist-type(7) `_ -- `cdist-type__autofs_reload(7) `_ +- cdist-type(7) +- cdist-type__autofs_reload(7) COPYING diff --git a/other/archived_types/__autofs_reload/gencode-remote b/other/archived_types/__autofs_reload/gencode-remote index 913d3f24..883602e2 100755 --- a/other/archived_types/__autofs_reload/gencode-remote +++ b/other/archived_types/__autofs_reload/gencode-remote @@ -28,7 +28,7 @@ not_supported() { } case "$os" in - ubuntu|debian|archlinux|devuan) + ubuntu|debian|archlinux) echo "pkill -HUP automount" ;; *) diff --git a/other/archived_types/__autofs_reload/man.rst b/other/archived_types/__autofs_reload/man.text similarity index 63% rename from other/archived_types/__autofs_reload/man.rst rename to other/archived_types/__autofs_reload/man.text index 101e9965..d2085a98 100644 --- a/other/archived_types/__autofs_reload/man.rst +++ b/other/archived_types/__autofs_reload/man.text @@ -1,10 +1,13 @@ cdist-type__autofs_reload(7) ============================ -Tell automounter to reload config file - Steven Armstrong +NAME +---- +cdist-type__autofs_reload - tell automounter to reload config file + + DESCRIPTION ----------- This space intentionally left blank. @@ -23,14 +26,14 @@ None. EXAMPLES -------- -.. code-block:: sh - - __autofs_reload +-------------------------------------------------------------------------------- +__autofs_reload +-------------------------------------------------------------------------------- SEE ALSO -------- -- `cdist-type(7) `_ +- cdist-type(7) COPYING diff --git a/other/types_submitted_for_inclusion/__init_script/man.rst b/other/types_submitted_for_inclusion/__init_script/man.text similarity index 63% rename from other/types_submitted_for_inclusion/__init_script/man.rst rename to other/types_submitted_for_inclusion/__init_script/man.text index 9d9220d4..c33ff7b7 100644 --- a/other/types_submitted_for_inclusion/__init_script/man.rst +++ b/other/types_submitted_for_inclusion/__init_script/man.text @@ -1,10 +1,13 @@ cdist-type__init_script(7) ========================== -Use the init scripts - Daniel Roth +NAME +---- +cdist-type__init_script - Use the init scripts + + DESCRIPTION ----------- This type can be used to control your init scripts. @@ -12,35 +15,34 @@ This type can be used to control your init scripts. REQUIRED PARAMETERS ------------------- -mode +mode:: Specifies what shall be done with the init script (usually one of 'start'|'stop'|'restart'|'reload' or 'force-reload') OPTIONAL PARAMETERS ------------------- -script +script:: If supplied, use this as the init-script. Otherwise the object_id is used. -base_dir +base_dir:: If supplied, this type uses this directory instead of '/etc/init.d'. The parameter will not need an ending slash. - EXAMPLES -------- -.. code-block:: sh +-------------------------------------------------------------------------------- +# Reloads the configuration for lighttpd +__init_script lighttpd --mode force-reload - # Reloads the configuration for lighttpd - __init_script lighttpd --mode force-reload - - # Reloads the configuration for lighttpd - __init_script lighty --script lighttpd --mode force-reload +# Reloads the configuration for lighttpd +__init_script lighty --script lighttpd --mode force-reload +-------------------------------------------------------------------------------- SEE ALSO -------- -- `cdist-type(7) `_ +- cdist-type(7) COPYING diff --git a/other/types_submitted_for_inclusion/__mysql_server/man.rst b/other/types_submitted_for_inclusion/__mysql_server/man.text similarity index 58% rename from other/types_submitted_for_inclusion/__mysql_server/man.rst rename to other/types_submitted_for_inclusion/__mysql_server/man.text index c561117c..f8573051 100644 --- a/other/types_submitted_for_inclusion/__mysql_server/man.rst +++ b/other/types_submitted_for_inclusion/__mysql_server/man.text @@ -1,10 +1,13 @@ cdist-type__mysql_server(7) =========================== -Manage a MySQL server - Benedikt Koeppel +NAME +---- +cdist-type__mysql_server - Manage a MySQL server + + DESCRIPTION ----------- This cdist type allows you to install a MySQL database server. The @@ -15,13 +18,13 @@ with MySQL. REQUIRED PARAMETERS ------------------- -password +password:: The root password to set. OPTIONAL PARAMETERS ------------------- -no_my_cnf +no_my_cnf:: The /root/.my.cnf file is used to temporary store the root password when doing the mysql_secure_installation. If you want to have your own .my.cnf file, then specify --no_my_cnf "true". @@ -31,24 +34,24 @@ no_my_cnf EXAMPLES -------- -.. code-block:: sh +-------------------------------------------------------------------------------- +# to install a MySQL server +__mysql_server - # to install a MySQL server - __mysql_server +# to install a MySQL server, remove remote access, remove test databases +# similar to mysql_secure_installation, specify the root password +__mysql_server --password "Uu9jooKe" +# this will also write a /root/.my.cnf file - # to install a MySQL server, remove remote access, remove test databases - # similar to mysql_secure_installation, specify the root password - __mysql_server --password "Uu9jooKe" - # this will also write a /root/.my.cnf file - - # if you don't want cdist to write a /root/.my.cnf file permanently, specify - # the --no_my_cnf option - __mysql_server --password "Uu9jooKe" --no_my_cnf +# if you don't want cdist to write a /root/.my.cnf file permanently, specify +# the --no_my_cnf option +__mysql_server --password "Uu9jooKe" --no_my_cnf +-------------------------------------------------------------------------------- SEE ALSO -------- -- `cdist-type(7) `_ +- cdist-type(7) COPYING diff --git a/other/types_submitted_for_inclusion/__nfs_client/man.rst b/other/types_submitted_for_inclusion/__nfs_client/man.text similarity index 67% rename from other/types_submitted_for_inclusion/__nfs_client/man.rst rename to other/types_submitted_for_inclusion/__nfs_client/man.text index 3c582958..3f0808a7 100644 --- a/other/types_submitted_for_inclusion/__nfs_client/man.rst +++ b/other/types_submitted_for_inclusion/__nfs_client/man.text @@ -1,10 +1,13 @@ cdist-type__nfs_client(7) ========================= -nfs client - Steven Armstrong +NAME +---- +cdist-type__nfs_client - nfs client + + DESCRIPTION ----------- Install, start, do whatever is necessary to have a working nfs client. @@ -23,14 +26,14 @@ None. EXAMPLES -------- -.. code-block:: sh - - __nfs_client +-------------------------------------------------------------------------------- +__nfs_client +-------------------------------------------------------------------------------- SEE ALSO -------- -- `cdist-type(7) `_ +- cdist-type(7) COPYING diff --git a/other/types_submitted_for_inclusion/__nfs_export/man.rst b/other/types_submitted_for_inclusion/__nfs_export/man.text similarity index 67% rename from other/types_submitted_for_inclusion/__nfs_export/man.rst rename to other/types_submitted_for_inclusion/__nfs_export/man.text index 4dd164ec..41ff64e8 100644 --- a/other/types_submitted_for_inclusion/__nfs_export/man.rst +++ b/other/types_submitted_for_inclusion/__nfs_export/man.text @@ -1,10 +1,13 @@ cdist-type__nfs_export(7) ========================= -Manage nfs exports - Steven Armstrong +NAME +---- +cdist-type__nfs_export - manage nfs exports + + DESCRIPTION ----------- This cdist type allows you to manage entries in /etc/exports.d. @@ -14,35 +17,35 @@ For older distributions (currently ubuntu lucid) that don't support REQUIRED PARAMETERS ------------------- -client +client:: space delimited list of client ip/networks for use in /etc/exports. See exports(5) OPTIONAL PARAMETERS ------------------- -options +options:: export options for use in /etc/exports. See exports(5) -export +export:: the directory to export. Defaults to object_id -state +state:: Either present or absent. Defaults to present. EXAMPLES -------- -.. code-block:: sh - - __nfs_export /local/chroot/lucid-amd64 \ - --client "192.168.0.1/24 10.0.0.1/16" \ - --options "ro,async,no_all_squash,no_root_squash,subtree_check" +-------------------------------------------------------------------------------- +__nfs_export /local/chroot/lucid-amd64 \ + --client "192.168.0.1/24 10.0.0.1/16" \ + --options "ro,async,no_all_squash,no_root_squash,subtree_check" +-------------------------------------------------------------------------------- SEE ALSO -------- -- `cdist-type(7) `_ +- cdist-type(7) - exports(5) diff --git a/other/types_submitted_for_inclusion/__nfs_server/man.rst b/other/types_submitted_for_inclusion/__nfs_server/man.text similarity index 67% rename from other/types_submitted_for_inclusion/__nfs_server/man.rst rename to other/types_submitted_for_inclusion/__nfs_server/man.text index 1f9aad76..41fc1d75 100644 --- a/other/types_submitted_for_inclusion/__nfs_server/man.rst +++ b/other/types_submitted_for_inclusion/__nfs_server/man.text @@ -1,10 +1,13 @@ cdist-type__nfs_server(7) ========================= -nfs server - Steven Armstrong +NAME +---- +cdist-type__nfs_server - nfs server + + DESCRIPTION ----------- Install, start, do whatever is necessary to have a working nfs server. @@ -23,14 +26,14 @@ None. EXAMPLES -------- -.. code-block:: sh - - __nfs_server +-------------------------------------------------------------------------------- +__nfs_server +-------------------------------------------------------------------------------- SEE ALSO -------- -- `cdist-type(7) `_ +- cdist-type(7) COPYING diff --git a/other/types_submitted_for_inclusion/__rsyncer/man.rst b/other/types_submitted_for_inclusion/__rsyncer/man.text similarity index 72% rename from other/types_submitted_for_inclusion/__rsyncer/man.rst rename to other/types_submitted_for_inclusion/__rsyncer/man.text index a09bfea5..6fab9fd3 100644 --- a/other/types_submitted_for_inclusion/__rsyncer/man.rst +++ b/other/types_submitted_for_inclusion/__rsyncer/man.text @@ -1,10 +1,13 @@ cdist-type__rsyncer(7) ====================== -Use rsync to copy files. - Daniel Maher +NAME +---- +cdist-type__rsyncer - Use rsync to copy files. + + DESCRIPTION ----------- This type is used to trigger rsync to copy files from the machine running cdist @@ -16,41 +19,41 @@ from the destination which are not present on the source. REQUIRED PARAMETERS ------------------- -source +source:: The full path of the source from which to copy. This is passed directly to rsync. OPTIONAL PARAMETERS ------------------- -destination +destination:: The full path of the destination. This is passed directly to rsync. Default: object_id -delete +delete:: If true, remove files from destination which are not in source. This is effectively the --delete argument of rsync. Default: false -rsyncbin +rsyncbin:: Specify the full path to the rsync binary. Default: `which rsync` EXAMPLES -------- -.. code-block:: sh +-------------------------------------------------------------------------------- +# Basic example +__rsyncer '/home/foo' --source '/opt/dist/foo' - # Basic example - __rsyncer '/home/foo' --source '/opt/dist/foo' - - # Fancier example - __rsyncer FOO --source '/opt/dist/foo' --destination '/home/foo/' --delete true +# Fancier example +__rsyncer FOO --source '/opt/dist/foo' --destination '/home/foo/' --delete true +-------------------------------------------------------------------------------- SEE ALSO -------- -- `cdist-type(7) `_ +- cdist-type(7) COPYING diff --git a/other/types_submitted_for_inclusion/__run_command/man.rst b/other/types_submitted_for_inclusion/__run_command/man.rst deleted file mode 100644 index f4426043..00000000 --- a/other/types_submitted_for_inclusion/__run_command/man.rst +++ /dev/null @@ -1,66 +0,0 @@ -cdist-type__run_command(7) -========================== -Run a command - -Benedikt Koeppel - - -DESCRIPTION ------------ -This cdist type allows you to run a specific command once at installation time. - - -REQUIRED PARAMETERS -------------------- - - -OPTIONAL PARAMETERS -------------------- -command - Command (with arguments) to run. - - If no command is give, then the object_id is executed. - - - -EXAMPLES --------- - -.. code-block:: sh - - # Run a command - __run_command "/etc/init.d/mysql restart" - # runs `/etc/init.d/mysql restart` (the "object_id") - - # Run the same command: - __run_command restart-mysql --command "/etc/init.d/mysql restart" - # runs `/etc/init.d/mysql restart` (the --command argument) - # additionally, it can easily be referenced (for example in a require="..." - #as __run_command/restart-mysql - - # Run a script: - __run_command install-pear --command "$(cat <<-EOF - /usr/bin/pear install --force Auth - /usr/bin/pear install --force HTML_Template_IT-1.2.1 - /usr/bin/pear install --force MDB2 - /usr/bin/pear install --force MDB2#mysql - /usr/bin/pear config-set preferred_state beta; - /usr/bin/pear install --force --alldeps Spreadsheet_Excel_Writer; - /usr/bin/pear config-set preferred_state stable - /usr/bin/pear install --force HTTP_Request - /usr/bin/pear install --force Mail - /usr/bin/pear install --force Auth_HTTP - /usr/bin/pear install --force XML_RPC - EOF - )" - - -SEE ALSO --------- -- `cdist-type(7) `_ - - -COPYING -------- -Copyright \(C) 2012 Benedikt Koeppel. Free use of this software is -granted under the terms of the GNU General Public License version 3 (GPLv3). diff --git a/other/types_submitted_for_inclusion/__run_command/man.text b/other/types_submitted_for_inclusion/__run_command/man.text new file mode 100644 index 00000000..5ea553c3 --- /dev/null +++ b/other/types_submitted_for_inclusion/__run_command/man.text @@ -0,0 +1,70 @@ +cdist-type__run_command(7) +========================== +Benedikt Koeppel + + +NAME +---- +cdist-type__run_command - Run a command + + +DESCRIPTION +----------- +This cdist type allows you to run a specific command once at installation time. + + +REQUIRED PARAMETERS +------------------- + + +OPTIONAL PARAMETERS +------------------- +command:: + Command (with arguments) to run. + + If no command is give, then the object_id is executed. + + + +EXAMPLES +-------- + +-------------------------------------------------------------------------------- +# Run a command +__run_command "/etc/init.d/mysql restart" +# runs `/etc/init.d/mysql restart` (the "object_id") + +# Run the same command: +__run_command restart-mysql --command "/etc/init.d/mysql restart" +# runs `/etc/init.d/mysql restart` (the --command argument) +# additionally, it can easily be referenced (for example in a require="..." +#as __run_command/restart-mysql + +# Run a script: +__run_command install-pear --command "$(cat <<-EOF + /usr/bin/pear install --force Auth + /usr/bin/pear install --force HTML_Template_IT-1.2.1 + /usr/bin/pear install --force MDB2 + /usr/bin/pear install --force MDB2#mysql + /usr/bin/pear config-set preferred_state beta; + /usr/bin/pear install --force --alldeps Spreadsheet_Excel_Writer; + /usr/bin/pear config-set preferred_state stable + /usr/bin/pear install --force HTTP_Request + /usr/bin/pear install --force Mail + /usr/bin/pear install --force Auth_HTTP + /usr/bin/pear install --force XML_RPC +EOF +)" + +-------------------------------------------------------------------------------- + + +SEE ALSO +-------- +- cdist-type(7) + + +COPYING +------- +Copyright \(C) 2012 Benedikt Koeppel. Free use of this software is +granted under the terms of the GNU General Public License version 3 (GPLv3). diff --git a/scripts/cdist b/scripts/cdist index 3110e657..39449666 100755 --- a/scripts/cdist +++ b/scripts/cdist @@ -1,8 +1,7 @@ #!/usr/bin/env python3 # -*- coding: utf-8 -*- # -# 2010-2016 Nico Schottelius (nico-cdist at schottelius.org) -# 2016 Darko Poljak (darko.poljak at gmail.com) +# 2010-2013 Nico Schottelius (nico-cdist at schottelius.org) # # This file is part of cdist. # @@ -21,22 +20,90 @@ # # -import logging -import sys -import cdist -import cdist.argparse -import cdist.banner -import cdist.config -import cdist.install -import cdist.shell -import cdist.inventory - - def commandline(): """Parse command line""" + import argparse - parser, cfg = cdist.argparse.parse_and_configure(sys.argv[1:]) - args = cfg.get_args() + import cdist.banner + import cdist.config + import cdist.shell + + # Construct parser others can reuse + parser = {} + # Options _all_ parsers have in common + parser['loglevel'] = argparse.ArgumentParser(add_help=False) + parser['loglevel'].add_argument('-d', '--debug', + help='Set log level to debug', action='store_true', + default=False) + parser['loglevel'].add_argument('-v', '--verbose', + help='Set log level to info, be more verbose', + action='store_true', default=False) + + # Main subcommand parser + parser['main'] = argparse.ArgumentParser(description='cdist ' + cdist.VERSION, + parents=[parser['loglevel']]) + parser['main'].add_argument('-V', '--version', + help='Show version', action='version', + version='%(prog)s ' + cdist.VERSION) + parser['sub'] = parser['main'].add_subparsers(title="Commands") + + # Banner + parser['banner'] = parser['sub'].add_parser('banner', + parents=[parser['loglevel']]) + parser['banner'].set_defaults(func=cdist.banner.banner) + + # Config + parser['config'] = parser['sub'].add_parser('config', + parents=[parser['loglevel']]) + parser['config'].add_argument('host', nargs='+', + help='one or more hosts to operate on') + parser['config'].add_argument('-c', '--conf-dir', + help='Add configuration directory (can be repeated, last one wins)', + action='append') + parser['config'].add_argument('-i', '--initial-manifest', + help='Path to a cdist manifest or \'-\' to read from stdin.', + dest='manifest', required=False) + parser['config'].add_argument('-n', '--dry-run', + help='Do not execute code', action='store_true') + parser['config'].add_argument('-o', '--out-dir', + help='Directory to save cdist output in', dest="out_path") + parser['config'].add_argument('-p', '--parallel', + help='Operate on multiple hosts in parallel', + action='store_true', dest='parallel') + parser['config'].add_argument('-s', '--sequential', + help='Operate on multiple hosts sequentially (default)', + action='store_false', dest='parallel') + parser['config'].add_argument('--remote-copy', + help='Command to use for remote copy (should behave like scp)', + action='store', dest='remote_copy', + default=cdist.REMOTE_COPY) + parser['config'].add_argument('--remote-exec', + help='Command to use for remote execution (should behave like ssh)', + action='store', dest='remote_exec', + default=cdist.REMOTE_EXEC) + parser['config'].set_defaults(func=cdist.config.Config.commandline) + + # Shell + parser['shell'] = parser['sub'].add_parser('shell', + parents=[parser['loglevel']]) + parser['shell'].add_argument('-s', '--shell', + help='Select shell to use, defaults to current shell') + parser['shell'].set_defaults(func=cdist.shell.Shell.commandline) + + + for p in parser: + parser[p].epilog = "Get cdist at http://www.nico.schottelius.org/software/cdist/" + + args = parser['main'].parse_args(sys.argv[1:]) + + # Loglevels are handled globally in here and debug wins over verbose + if args.verbose: + logging.root.setLevel(logging.INFO) + if args.debug: + logging.root.setLevel(logging.DEBUG) + + log.debug(args) + log.info("version %s" % cdist.VERSION) # Work around python 3.3 bug: # http://bugs.python.org/issue16308 @@ -55,19 +122,29 @@ def commandline(): args.func(args) - if __name__ == "__main__": + # Sys is needed for sys.exit() + import sys + cdistpythonversion = '3.2' if sys.version < cdistpythonversion: - print('Python >= {} is required on the source host.'.format( - cdistpythonversion), file=sys.stderr) + print('Python >= ' + cdistpythonversion + + ' is required on the source host.', file=sys.stderr) sys.exit(1) + exit_code = 0 try: - import re + import logging import os + import re + import cdist + import cdist.log + + logging.setLoggerClass(cdist.log.Log) + logging.basicConfig(format='%(levelname)s: %(message)s') + log = logging.getLogger("cdist") if re.match("__", os.path.basename(sys.argv[0])): import cdist.emulator @@ -80,7 +157,6 @@ if __name__ == "__main__": exit_code = 2 except cdist.Error as e: - log = logging.getLogger("cdist") log.error(e) exit_code = 1 diff --git a/scripts/cdist-dump b/scripts/cdist-dump deleted file mode 100755 index 83b09eb8..00000000 --- a/scripts/cdist-dump +++ /dev/null @@ -1,325 +0,0 @@ -#!/bin/sh - -VERSION="0.0.1" -RELEASE="" - -set -u -# set -x - -hosts= -cache_dir=~/.cdist/cache - -do_all=1 -do_global_explorer= -do_type_explorer= -do_script_stdout= -do_script_stderr= -do_gencode= -do_code= -do_messages= -do_parameter= -delimiter=':' -ln= -filename_prefix=1 -verbose=0 - -myname=${0##*/} - -print_version() -{ - printf "%s %s %s\n" "${myname}" "${VERSION}" "${RELEASE}" -} - -usage() -{ - cat << eof -${myname}: [options] [host...] -eof - - print_version - - cat << eof - -Dump data from cache directories. - -host - Dump data for specified hosts. If not specified then all data - from cache directory is dumped. - -Options - -a dump all - -C CACHE-DIR use specified CACHE-DIR (default: ~/.cdist/cache) - -c dump code-* - -d DELIMITER delimiter used for filename and line number prefix (default: ':') - -E dump global explorers - -e dump type explorers - -F disable filename prefix (enabled by default) - -f enable filename prefix (default) - -g dump gencode-* - -h show this help screen and exit - -L disable line number prefix (default) - -l enable line number prefix (disabled by default) - -m dump messages - -o dump executions' stdout - -p dump parameters - -r dump executions' stderr - -V show version and exit - -v increase verbosity -eof -} - -exit_err() -{ - printf "%s\n" "$1" - exit 1 -} - -# parse options -while [ "$#" -ge 1 ] -do - case "$1" in - -a) - do_all=1 - ;; - -C) - if [ "$#" -ge 2 ] - then - case "$2" in - -*) - exit_err "Missing cache directory" - ;; - *) - cache_dir="$2" - shift - ;; - esac - else - exit_err "Missing cache directory" - fi - ;; - -c) - do_code=1 - do_all= - ;; - -d) - if [ "$#" -ge 2 ] - then - case "$2" in - -*) - exit_err "Missing delimiter" - ;; - *) - delimiter="$2" - shift - ;; - esac - else - exit_err "Missing delimiter" - fi - ;; - -E) - do_global_explorer=1 - do_all= - ;; - -e) - do_type_explorer=1 - do_all= - ;; - -F) - filename_prefix= - ;; - -f) - filename_prefix=1 - ;; - -g) - do_gencode=1 - do_all= - ;; - -h) - usage - exit 0 - ;; - -L) - ln= - ;; - -l) - ln=1 - ;; - -m) - do_messages=1 - do_all= - ;; - -o) - do_script_stdout=1 - do_all= - ;; - -p) - do_parameter=1 - do_all= - ;; - -r) - do_script_stderr=1 - do_all= - ;; - -V) - print_version - exit 0 - ;; - -v) - verbose=$((verbose + 1)) - ;; - *) - hosts="${hosts} $1" - break - ;; - esac - shift -done - -if [ "${ln}" = "1" ] -then - ln="NR \"${delimiter}\"" -fi - -if [ "${filename_prefix}" = "1" ] -then - filename_prefix="{}${delimiter}" -fi - -if [ "${do_all}" = "1" ] -then - do_global_explorer=1 - do_type_explorer=1 - do_script_stdout=1 - do_script_stderr=1 - do_gencode=1 - do_code=1 - do_messages=1 - do_parameter=1 -fi - -set -- -size +0 -set -- "$@" \( -or= - -print_verbose() -{ - if [ "${verbose}" -ge "$1" ] - then - printf "%s\n" "$2" - fi -} - -hor_line() -{ - if [ $# -gt 0 ] - then - c="$1" - else - c='=' - fi - printf "%78s\n" "" | tr ' ' "${c}" -} - -if [ "${do_global_explorer}" ] -then - print_verbose 2 "Dumping global explorers" - set -- "$@" ${or} \( \ - -path "*/explorer/*" -a \ - ! -path "*/conf/*" -a \ - ! -path "*/object/*/explorer/*" \ - \) - or="-o" -fi - -if [ "${do_type_explorer}" ] -then - print_verbose 2 "Dumping type explorers" - set -- "$@" ${or} -path "*/object/*/explorer/*" - or="-o" -fi - -if [ "${do_script_stdout}" ] -then - print_verbose 2 "Dumping execution's stdout" - set -- "$@" ${or} -path "*/stdout/*" - or="-o" -fi - -if [ "${do_script_stderr}" ] -then - print_verbose 2 "Dumping execution's stderr" - set -- "$@" ${or} -path "*/stderr/*" - or="-o" -fi - -if [ "${do_gencode}" ] -then - print_verbose 2 "Dumping gencode-*" - set -- "$@" ${or} \( -name "gencode-*" -a ! -path "*/stdout/*" -a ! -path "*/stderr/*" \) - or="-o" -fi - -if [ "${do_code}" ] -then - print_verbose 2 "Dumping code-*" - set -- "$@" ${or} \( -name "code-*" -a ! -path "*/stdout/*" -a ! -path "*/stderr/*" \) - or="-o" -fi - -if [ "${do_messages}" ] -then - print_verbose 2 "Dumping messages" - set -- "$@" ${or} -name "messages" - or="-o" -fi - -if [ "${do_parameter}" ] -then - print_verbose 2 "Dumping parameters" - set -- "$@" ${or} -path "*/parameter/*" - or="-o" -fi - -set -- "$@" \) -set -- '.' "$@" -exec awk -v prefix="${filename_prefix}" "{print prefix ${ln} \$0}" {} \; - -# printf "+ %s\n" "$*" - -print_verbose 2 "Using cache dir: ${cache_dir}" - -OLD_PWD=$(pwd) -cd "${cache_dir}" || exit - -# If no host is specified then search all. -[ -z "${hosts}" ] && hosts="-" - -for host in ${hosts} -do - [ "${host}" = "-" ] && host= - # find host cache directory - host_dir=$(find . -name target_host -exec grep -l "${host}" {} +) - print_verbose 3 "found host directory files:" - print_verbose 3 "${host_dir}" - - OLD_IFS="${IFS}" - IFS=" - " - - for d in ${host_dir} - do - dir=$(dirname "${d}") - - print_verbose 0 "target host: $(cat "${dir}/target_host"), host directory: ${dir}" - hor_line '=' - - PREV_PWD=$(pwd) - cd "${dir}" || exit - # set -x - find "$@" - # set +x - cd "${PREV_PWD}" || exit - done - IFS="${OLD_IFS}" -done -cd "${OLD_PWD}" || exit diff --git a/scripts/cdist-new-type b/scripts/cdist-new-type deleted file mode 100755 index 79dcfd90..00000000 --- a/scripts/cdist-new-type +++ /dev/null @@ -1,159 +0,0 @@ -#!/bin/sh - -basename="${0##*/}" - -if [ $# -lt 3 ] -then - printf "usage: %s TYPE-NAME AUTHOR-NAME AUTHOR-EMAIL [TYPE-BASE-PATH] - TYPE-NAME Name of the type. - AUTHOR-NAME Type author's full name. - AUTHOR-EMAIL Type author's email. - TYPE-BASE-PATH Path to the base directory of the type. If not set it defaults - to '\$PWD/type'.\n" "${basename}" - exit 1 -fi - -type_name="$1" -shift -author_name="$1" -shift -author_email="$1" -shift - -if [ $# -ge 1 ] -then - type_base_path="$1" - shift -else - #type_base_path=~/.cdist/type - type_base_path="$PWD/type" -fi - -error() { - printf "%s\n" "$*" >&2 -} - -die() { - error "$@" - exit 1 -} - -cd "$type_base_path" || die "Could not change to type directory: $type_base_path. -You have to specify type base path or run me from within a cdist conf directory, -e.g. ~/.cdist." - -year=$(date +%Y) -copyright="# $year $author_name ($author_email)" - -license="# 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 . -# -" - -set -e - -mkdir "$type_name" -cd "$type_name" - -### man page -header="cdist-type${type_name}(7)" -header_length="${#header}" -cat >> man.rst << DONE -$header -$(while [ "${header_length}" -gt 0 ]; do printf "="; header_length=$((header_length - 1)); done; printf "\n";) - -NAME ----- -cdist-type${type_name} - TODO - - -DESCRIPTION ------------ -This space intentionally left blank. - - -REQUIRED PARAMETERS -------------------- -None. - - -OPTIONAL PARAMETERS -------------------- -None. - - -BOOLEAN PARAMETERS ------------------- -None. - - -EXAMPLES --------- - -.. code-block:: sh - - # TODO - ${type_name} - - -SEE ALSO --------- -:strong:\`TODO\`\\ (7) - - -AUTHORS -------- -$author_name <$author_email> - - -COPYING -------- -Copyright \(C) $year $author_name. 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. -DONE - -### manifest -cat >> manifest << DONE -#!/bin/sh -e -# -${copyright} -# -${license} - -os=\$(cat "\$__global/explorer/os") - -case "\$os" in - *) - printf "Your operating system (%s) is currently not supported by this type (%s)\n" "\$os" "\${__type##*/}" >&2 - printf "Please contribute an implementation for it if you can.\n" >&2 - exit 1 - ;; -esac -DONE -chmod +x manifest - -# gencode-remote -cat >> gencode-remote << DONE -#!/bin/sh -e -# -${copyright} -# -${license} -DONE -chmod +x gencode-remote - -printf "%s/%s\n" "$type_base_path" "$type_name" diff --git a/setup.py b/setup.py index ae651125..c484a269 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,6 @@ import cdist import os import re - def data_finder(data_dir): entries = [] for name in os.listdir(data_dir): @@ -25,24 +24,22 @@ def data_finder(data_dir): return entries - cur = os.getcwd() os.chdir("cdist") package_data = data_finder("conf") os.chdir(cur) - setup( - name="cdist", - packages=["cdist", "cdist.core", "cdist.exec", "cdist.util", ], + name = "cdist", + packages = ["cdist", "cdist.core", "cdist.exec", "cdist.util" ], package_data={'cdist': package_data}, - scripts=["scripts/cdist", "scripts/cdist-dump", "scripts/cdist-new-type"], - version=cdist.version.VERSION, - description="A Usable Configuration Management System", - author="Nico Schottelius", - author_email="nico-cdist-pypi@schottelius.org", - url="https://www.cdi.st/", - classifiers=[ + scripts = ["scripts/cdist"], + version = cdist.version.VERSION, + description = "A Usable Configuration Management System", + author = "Nico Schottelius", + author_email = "nico-cdist-pypi@schottelius.org", + url = "http://www.nico.schottelius.org/software/cdist/", + classifiers = [ "Development Status :: 6 - Mature", "Environment :: Console", "Intended Audience :: System Administrators", @@ -60,11 +57,10 @@ setup( "Topic :: System :: Software Distribution", "Topic :: Utilities" ], - long_description=''' + long_description = ''' 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 + 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 cfengine, bcfg2, chef and puppet. ''' )