Merge remote-tracking branch 'ungleich/master'

This commit is contained in:
Steven Armstrong 2016-10-05 23:22:44 +02:00
commit 4c1c1e990d
272 changed files with 7932 additions and 2286 deletions

21
.gitignore vendored
View file

@ -2,26 +2,29 @@
.*.swp .*.swp
# Ignore generated manpages # Ignore generated manpages
docs/man/.marker docs/src/.marker
docs/man/man1/*.1 docs/src/man1/*.1
docs/man/man7/*.7 docs/src/man7/*.7
docs/man/man*/*.html docs/src/man7/cdist-type__*.rst
docs/man/man*/*.xml docs/src/cdist-reference.rst
docs/man/man*/docbook-xsl.css
docs/man/man7/cdist-type__*.rst
docs/man/man7/cdist-reference.rst
# Ignore cdist cache for version control # Ignore cdist cache for version control
/cache/ /cache/
# Python: cache, distutils, distribution in general # Python: cache, distutils, distribution in general
__pycache__/ __pycache__/
*.pyc
MANIFEST MANIFEST
dist/ dist/
cdist/version.py cdist/version.py
#sphinx build dir # sphinx build dirs, cache
_build/ _build/
docs/dist
# Ignore temp files used for signing
cdist-*.tar.gz
cdist-*.tar.gz.asc
# Packaging: Archlinux # Packaging: Archlinux
/PKGBUILD /PKGBUILD

View file

@ -20,7 +20,7 @@
helper=./bin/build-helper helper=./bin/build-helper
MANDIR=docs/man DOCS_SRC_DIR=docs/src
SPEECHDIR=docs/speeches SPEECHDIR=docs/speeches
TYPEDIR=cdist/conf/type TYPEDIR=cdist/conf/type
@ -36,17 +36,19 @@ CHANGELOG_FILE=docs/changelog
PYTHON_VERSION=cdist/version.py PYTHON_VERSION=cdist/version.py
SPHINXM=make -C $(MANDIR) man SPHINXM=make -C $(DOCS_SRC_DIR) man
SPHINXH=make -C $(MANDIR) html SPHINXH=make -C $(DOCS_SRC_DIR) html
SPHINXC=make -C $(DOCS_SRC_DIR) clean
################################################################################ ################################################################################
# Manpages # Manpages
# #
MAN1DSTDIR=$(MANDIR)/man1 MAN1DSTDIR=$(DOCS_SRC_DIR)/man1
MAN7DSTDIR=$(MANDIR)/man7 MAN7DSTDIR=$(DOCS_SRC_DIR)/man7
# Manpages #1: Types # Manpages #1: Types
# Use shell / ls to get complete list - $(TYPEDIR)/*/man.rst does not work # Use shell / ls to get complete list - $(TYPEDIR)/*/man.rst does not work
MANTYPESRC=$(shell ls $(TYPEDIR)/*/man.rst) # Using ls does not work if no file with given pattern exist, so use wildcard
MANTYPESRC=$(wildcard $(TYPEDIR)/*/man.rst)
MANTYPEPREFIX=$(subst $(TYPEDIR)/,$(MAN7DSTDIR)/cdist-type,$(MANTYPESRC)) MANTYPEPREFIX=$(subst $(TYPEDIR)/,$(MAN7DSTDIR)/cdist-type,$(MANTYPESRC))
MANTYPES=$(subst /man.rst,.rst,$(MANTYPEPREFIX)) MANTYPES=$(subst /man.rst,.rst,$(MANTYPEPREFIX))
@ -55,32 +57,35 @@ $(MAN7DSTDIR)/cdist-type%.rst: $(TYPEDIR)/%/man.rst
ln -sf "../../../$^" $@ ln -sf "../../../$^" $@
# Manpages #2: reference # Manpages #2: reference
MANREF=$(MAN7DSTDIR)/cdist-reference.rst DOCSREF=$(MAN7DSTDIR)/cdist-reference.rst
MANREFSH=$(MANDIR)/cdist-reference.rst.sh DOCSREFSH=$(DOCS_SRC_DIR)/cdist-reference.rst.sh
$(MANREF): $(MANREFSH) $(DOCSREF): $(DOCSREFSH)
$(MANREFSH) $(DOCSREFSH)
# Manpages #3: generic part # Manpages #3: generic part
mansphinxman: $(MANTYPES) $(MANREF) man: $(MANTYPES) $(DOCSREF) $(PYTHON_VERSION)
$(SPHINXM) $(SPHINXM)
mansphinxhtml: $(MANTYPES) $(MANREF) html: $(MANTYPES) $(DOCSREF) $(PYTHON_VERSION)
$(SPHINXH) $(SPHINXH)
man: mansphinxman mansphinxhtml docs: man html
docs-clean:
$(SPHINXC)
# Manpages #5: release part # Manpages #5: release part
MANWEBDIR=$(WEBBASE)/man/$(CHANGELOG_VERSION) MANWEBDIR=$(WEBBASE)/man/$(CHANGELOG_VERSION)
MANBUILDDIR=$(MANDIR)/_build/html HTMLBUILDDIR=docs/dist/html
man-dist: man docs-dist: html
rm -rf "${MANWEBDIR}" rm -rf "${MANWEBDIR}"
mkdir -p "${MANWEBDIR}" mkdir -p "${MANWEBDIR}"
# mkdir -p "${MANWEBDIR}/man1" "${MANWEBDIR}/man7" # mkdir -p "${MANWEBDIR}/man1" "${MANWEBDIR}/man7"
# cp ${MAN1DSTDIR}/*.html ${MAN1DSTDIR}/*.css ${MANWEBDIR}/man1 # cp ${MAN1DSTDIR}/*.html ${MAN1DSTDIR}/*.css ${MANWEBDIR}/man1
# cp ${MAN7DSTDIR}/*.html ${MAN7DSTDIR}/*.css ${MANWEBDIR}/man7 # cp ${MAN7DSTDIR}/*.html ${MAN7DSTDIR}/*.css ${MANWEBDIR}/man7
cp -R ${MANBUILDDIR}/* ${MANWEBDIR} cp -R ${HTMLBUILDDIR}/* ${MANWEBDIR}
cd ${MANWEBDIR} && git add . && git commit -m "cdist manpages update: $(CHANGELOG_VERSION)" || true cd ${MANWEBDIR} && git add . && git commit -m "cdist manpages update: $(CHANGELOG_VERSION)" || true
man-latest-link: web-pub man-latest-link: web-pub
@ -88,6 +93,22 @@ man-latest-link: web-pub
ssh staticweb.ungleich.ch \ ssh staticweb.ungleich.ch \
"cd /home/services/www/nico/nico.schottelius.org/www/software/cdist/man/ && rm -f latest && ln -sf "$(CHANGELOG_VERSION)" latest" "cd /home/services/www/nico/nico.schottelius.org/www/software/cdist/man/ && rm -f latest && ln -sf "$(CHANGELOG_VERSION)" latest"
# Manpages: .cdist Types
DOT_CDIST_PATH=${HOME}/.cdist
DOTMAN7DSTDIR=$(MAN7DSTDIR)
DOTTYPEDIR=$(DOT_CDIST_PATH)/type
DOTMANTYPESRC=$(wildcard $(DOTTYPEDIR)/*/man.rst)
DOTMANTYPEPREFIX=$(subst $(DOTTYPEDIR)/,$(DOTMAN7DSTDIR)/cdist-type,$(DOTMANTYPESRC))
DOTMANTYPES=$(subst /man.rst,.rst,$(DOTMANTYPEPREFIX))
# Link manpage: do not create man.html but correct named file
$(DOTMAN7DSTDIR)/cdist-type%.rst: $(DOTTYPEDIR)/%/man.rst
ln -sf "$^" $@
# Manpages #3: generic part
dotman: $(DOTMANTYPES)
$(SPHINXM)
################################################################################ ################################################################################
# Speeches # Speeches
# #
@ -127,7 +148,7 @@ web-doc:
web-dist: web-blog web-doc web-dist: web-blog web-doc
web-pub: web-dist man-dist speeches-dist web-pub: web-dist docs-dist speeches-dist
cd "${WEBDIR}" && make pub cd "${WEBDIR}" && make pub
web-release-all: man-latest-link web-release-all: man-latest-link
@ -192,12 +213,12 @@ release:
# #
clean: clean:
rm -f $(MAN7DSTDIR)/cdist-reference.rst rm -f $(DOCS_SRC_DIR)/cdist-reference.rst
find "$(MANDIR)" -mindepth 2 -type l \ find "$(DOCS_SRC_DIR)" -mindepth 2 -type l \
| xargs rm -f | xargs rm -f
make -C $(MANDIR) clean make -C $(DOCS_SRC_DIR) clean
find * -name __pycache__ | xargs rm -rf find * -name __pycache__ | xargs rm -rf
@ -208,6 +229,10 @@ clean:
rm -f MANIFEST PKGBUILD rm -f MANIFEST PKGBUILD
rm -rf dist/ rm -rf dist/
# Signed release
rm -f cdist-*.tar.gz
rm -f cdist-*.tar.gz.asc
distclean: clean distclean: clean
rm -f cdist/version.py rm -f cdist/version.py
@ -221,3 +246,6 @@ pub:
test: test:
$(helper) $@ $(helper) $@
pep8:
$(helper) $@

View file

@ -153,7 +153,90 @@ eof
fi fi
printf "Enter tag description for ${target_version}: " printf "Enter tag description for ${target_version}: "
read tagmessage read tagmessage
git tag "$target_version" -m "$$tagmessage"
# setup for signed tags:
# gpg --fulL-gen-key
# gpg --list-secret-keys --keyid-format LONG
# git config --local user.signingkey <id>
# for exporting pub key:
# gpg --armor --export <id> > pubkey.asc
# gpg --output pubkey.gpg --export <id>
# show tag with signature
# git show <tag>
# verify tag signature
# git tag -v <tag>
#
# gpg verify signature
# gpg --verify <asc-file> <file>
# gpg --no-default-keyring --keyring <pubkey.gpg> --verify <asc-file> <file>
# Ensure gpg-agent is running.
export GPG_TTY=$(tty)
gpg-agent
git tag -s "$target_version" -m "$tagmessage"
git push --tags
;;
sign-git-release)
if [ $# -lt 2 ]
then
printf "usage: $0 sign-git-release TAG TOKEN [ARCHIVE]\n"
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 \"${tag}\" not found.\n"
exit 1
fi
token="$2"
if [ $# -gt 2 ]
then
archivename="$3"
else
archivename="cdist-${tag}.tar.gz"
git archive --prefix="cdist-${tag}/" -o "${archivename}" "${tag}" \
|| exit 1
fi
gpg --armor --detach-sign "${archivename}" || exit 1
# make github release
curl -H "Authorization: token ${token}" \
--request POST \
--data "{ \"tag_name\":\"${tag}\", \
\"target_commitish\":\"master\", \
\"name\": \"${tag}\", \
\"body\":\"${tag}\", \
\"draft\":false, \
\"prerelease\": false}" \
"https://api.github.com/repos/ungleich/cdist/releases" || exit 1
# get release ID
repoid=$(curl "https://api.github.com/repos/ungleich/cdist/releases/tags/${tag}" \
| python3 -c 'import json; import sys; print(json.loads(sys.stdin.read())["id"])') \
|| exit 1
# upload archive and then signature
curl -H "Authorization: token ${token}" \
-H "Accept: application/vnd.github.manifold-preview" \
-H "Content-Type: application/x-gtar" \
--data-binary @${archivename} \
"https://uploads.github.com/repos/ungleich/cdist/releases/${repoid}/assets?name=${archivename}" \
|| exit 1
curl -H "Authorization: token ${token}" \
-H "Accept: application/vnd.github.manifold-preview" \
-H "Content-Type: application/pgp-signature" \
--data-binary @${archivename}.asc \
"https://uploads.github.com/repos/ungleich/cdist/releases/${repoid}/assets?name=${archivename}.asc" \
|| exit 1
# remove generated files (archive and asc)
if [ $# -eq 2]
then
rm -f "${archivename}"
fi
rm -f "${archivename}.asc"
;; ;;
release) release)
@ -166,9 +249,10 @@ eof
# First check everything is sane # First check everything is sane
"$0" check-date "$0" check-date
"$0" check-unittest "$0" check-unittest
"$0" check-pep8
# Generate version file to be included in packaging # Generate version file to be included in packaging
"$0" version "$0" target-version
# Ensure the git status is clean, else abort # Ensure the git status is clean, else abort
if ! git diff-index --name-only --exit-code HEAD ; then if ! git diff-index --name-only --exit-code HEAD ; then
@ -206,8 +290,10 @@ eof
"$0" check-date "$0" check-date
"$0" check-unittest "$0" check-unittest
# Generate man pages (indirect check if they build) # Generate documentation (man and html)
make man # First, clean old generated docs
make docs-clean
make docs
# Generate speeches (indirect check if they build) # Generate speeches (indirect check if they build)
make speeches make speeches
@ -218,6 +304,11 @@ eof
# Tag the current commit # Tag the current commit
"$0" release-git-tag "$0" release-git-tag
# sign git tag
printf "Enter github authentication token: "
read token
"$0" sign-git-release "${target_version}" "${token}"
# Also merge back the version branch # Also merge back the version branch
if [ "$masterbranch" = yes ]; then if [ "$masterbranch" = yes ]; then
git checkout master git checkout master
@ -268,6 +359,32 @@ eof
fi fi
;; ;;
pep8)
pep8 "${basedir}" "${basedir}/scripts/cdist" | less
;;
check-pep8)
"$0" pep8
echo "Please review pep8 report."
while true
do
echo "Continue (yes/no)?"
any=
read any
case "$any" in
yes)
break
;;
no)
exit 1
;;
*)
echo "Please answer with 'yes' or 'no' explicitly."
;;
esac
done
;;
version-branch) version-branch)
"$0" changelog-version | cut -d. -f '1,2' "$0" changelog-version | cut -d. -f '1,2'
;; ;;
@ -276,6 +393,11 @@ eof
echo "VERSION = \"$(git describe)\"" > cdist/version.py echo "VERSION = \"$(git describe)\"" > cdist/version.py
;; ;;
target-version)
target_version=$($0 changelog-version)
echo "VERSION = \"${target_version}\"" > cdist/version.py
;;
*) *)
echo "Unknown helper target $@ - aborting" echo "Unknown helper target $@ - aborting"
exit 1 exit 1

468
bin/build-helper.freebsd Executable file
View file

@ -0,0 +1,468 @@
#!/bin/sh
#
# 2011-2013 Nico Schottelius (nico-cdist at schottelius.org)
# 2016 Darko Poljak (darko.poljak at gmail.com)
#
# This file is part of cdist.
#
# cdist is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# cdist is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
#
#
# This file contains the heavy lifting found usually in the Makefile
#
# vars for make
helper=$0
basedir=${0%/*}/../
# run_as is used to check how the script is called (by $0 value)
# currently supported sufixes for $0 are:
# .freebsd - run as freebsd
basename=${0##*/}
run_as=${basename#*.}
case "$run_as" in
freebsd)
to_a=cdist-configuration-management
to_d=googlegroups.com
from_a=darko.poljak
from_d=gmail.com
ml_name="Darko Poljak"
ml_sig_name="Darko"
# vars for make
WEBDIR=../vcs/www.nico.schottelius.org
;;
*)
to_a=cdist
to_d=l.schottelius.org
from_a=nico-cdist
from_d=schottelius.org
ml_name="Nico -telmich- Schottelius"
ml_sig_name="Nico"
# vars for make
WEBDIR=$$HOME/vcs/www.nico.schottelius.org
;;
esac
# Change to checkout directory
cd "$basedir"
version=$(git describe)
option=$1; shift
case "$option" in
print-make-vars)
printf "helper: ${helper}\n"
printf "WEBDIR: ${WEBDIR}\n"
;;
print-runas)
printf "run_as: $run_as\n"
;;
changelog-changes)
if [ "$#" -eq 1 ]; then
start=$1
else
start="[[:digit:]]"
fi
end="[[:digit:]]"
awk -F: "BEGIN { start=0 }
{
if(start == 0) {
if (\$0 ~ /^$start/) {
start = 1
}
} else {
if (\$0 ~ /^$end/) {
exit
} else {
print \$0
}
}
}" "$basedir/docs/changelog"
;;
changelog-version)
# get version from changelog
grep '^[[:digit:]]' "$basedir/docs/changelog" | head -n1 | sed 's/:.*//'
;;
check-date)
# verify date in changelog is today
date_today="$(date +%Y-%m-%d)"
date_changelog=$(grep '^[[:digit:]]' "$basedir/docs/changelog" | head -n1 | sed 's/.*: //')
if [ "$date_today" != "$date_changelog" ]; then
echo "Date in changelog is not today"
echo "Changelog: $date_changelog"
exit 1
fi
;;
check-unittest)
"$0" test
;;
blog)
version=$1; shift
blogfile=$1; shift
dir=${blogfile%/*}
file=${blogfile##*/}
cat << eof > "$blogfile"
[[!meta title="Cdist $version released"]]
Here's a short overview about the changes found in version ${version}:
eof
$0 changelog-changes "$version" >> "$blogfile"
cat << eof >> "$blogfile"
For more information visit the [[cdist homepage|software/cdist]].
[[!tag cdist config unix]]
eof
cd "$dir"
git add "$file"
# Allow git commit to fail if there are no changes
git commit -m "cdist blog update: $version" "$blogfile" || true
;;
ml-release)
if [ $# -ne 1 ]; then
echo "$0 ml-release version" >&2
exit 1
fi
version=$1; shift
to=${to_a}@${to_d}
from=${from_a}@${from_d}
(
cat << eof
From: ${ml_name} <$from>
To: cdist mailing list <$to>
Subject: cdist $version released
Hello .*,
cdist $version has been released with the following changes:
eof
"$0" changelog-changes "$version"
cat << eof
Cheers,
${ml_sig_name}
--
Automatisation at its best level. With cdist.
eof
) | /usr/sbin/sendmail -f "$from" "$to"
;;
release-git-tag)
target_version=$($0 changelog-version)
if git rev-parse --verify refs/tags/$target_version 2>/dev/null; then
echo "Tag for $target_version exists, aborting"
exit 1
fi
printf "Enter tag description for ${target_version}: "
read tagmessage
# setup for signed tags:
# gpg --fulL-gen-key
# gpg --list-secret-keys --keyid-format LONG
# git config --local user.signingkey <id>
# for exporting pub key:
# gpg --armor --export <id> > pubkey.asc
# gpg --output pubkey.gpg --export <id>
# show tag with signature
# git show <tag>
# verify tag signature
# git tag -v <tag>
#
# gpg verify signature
# gpg --verify <asc-file> <file>
# gpg --no-default-keyring --keyring <pubkey.gpg> --verify <asc-file> <file>
# Ensure gpg-agent is running.
export GPG_TTY=$(tty)
gpg-agent
git tag -s "$target_version" -m "$tagmessage"
git push --tags
;;
sign-git-release)
if [ $# -lt 2 ]
then
printf "usage: $0 sign-git-release TAG TOKEN [ARCHIVE]\n"
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 \"${tag}\" not found.\n"
exit 1
fi
token="$2"
if [ $# -gt 2 ]
then
archivename="$3"
else
archivename="cdist-${tag}.tar.gz"
git archive --prefix="cdist-${tag}/" -o "${archivename}" "${tag}" \
|| exit 1
fi
gpg --armor --detach-sign "${archivename}" || exit 1
# make github release
curl -H "Authorization: token ${token}" \
--request POST \
--data "{ \"tag_name\":\"${tag}\", \
\"target_commitish\":\"master\", \
\"name\": \"${tag}\", \
\"body\":\"${tag}\", \
\"draft\":false, \
\"prerelease\": false}" \
"https://api.github.com/repos/ungleich/cdist/releases" || exit 1
# get release ID
repoid=$(curl "https://api.github.com/repos/ungleich/cdist/releases/tags/${tag}" \
| python3 -c 'import json; import sys; print(json.loads(sys.stdin.read())["id"])') \
|| exit 1
# upload archive and then signature
curl -H "Authorization: token ${token}" \
-H "Accept: application/vnd.github.manifold-preview" \
-H "Content-Type: application/x-gtar" \
--data-binary @${archivename} \
"https://uploads.github.com/repos/ungleich/cdist/releases/${repoid}/assets?name=${archivename}" \
|| exit 1
curl -H "Authorization: token ${token}" \
-H "Accept: application/vnd.github.manifold-preview" \
-H "Content-Type: application/pgp-signature" \
--data-binary @${archivename}.asc \
"https://uploads.github.com/repos/ungleich/cdist/releases/${repoid}/assets?name=${archivename}.asc" \
|| exit 1
# remove generated files (archive and asc)
if [ $# -eq 2]
then
rm -f "${archivename}"
fi
rm -f "${archivename}.asc"
;;
release)
set -e
target_version=$($0 changelog-version)
target_branch=$($0 version-branch)
echo "Beginning release process for $target_version"
# First check everything is sane
"$0" check-date
"$0" check-unittest
"$0" check-pep8
# Generate version file to be included in packaging
"$0" target-version
# Ensure the git status is clean, else abort
if ! git diff-index --name-only --exit-code HEAD ; then
echo "Unclean tree, see files above, aborting"
exit 1
fi
# Ensure we are on the master branch
masterbranch=yes
if [ "$(git rev-parse --abbrev-ref HEAD)" != "master" ]; then
echo "Releases are happening from the master branch, aborting"
echo "Enter the magic word to release anyway"
read magicword
if [ "$magicword" = "iknowwhatido" ]; then
masterbranch=no
else
exit 1
fi
fi
if [ "$masterbranch" = yes ]; then
# Ensure version branch exists
if ! git rev-parse --verify refs/heads/$target_branch 2>/dev/null; then
git branch "$target_branch"
fi
# Merge master branch into version branch
git checkout "$target_branch"
git merge master
fi
# Verify that after the merge everything works
"$0" check-date
"$0" check-unittest
# Generate documentation (man and html)
# First, clean old generated docs
make helper=${helper} WEBDIR=${WEBDIR} docs-clean
make helper=${helper} WEBDIR=${WEBDIR} docs
# Generate speeches (indirect check if they build)
make helper=${helper} WEBDIR=${WEBDIR} speeches
#############################################################
# Everything green, let's do the release
# Tag the current commit
"$0" release-git-tag
# sign git tag
printf "Enter github authentication token: "
read token
"$0" sign-git-release "${target_version}" "${token}"
# Also merge back the version branch
if [ "$masterbranch" = yes ]; then
git checkout master
git merge "$target_branch"
fi
# Publish git changes
case "$run_as" in
freebsd)
# if we are not Nico :) then just push, no mirror
git push
# push also new branch and set up tracking
git push -u origin "${target_branch}"
;;
*)
make helper=${helper} WEBDIR=${WEBDIR} pub
;;
esac
# publish man, speeches, website
if [ "$masterbranch" = yes ]; then
make helper=${helper} WEBDIR=${WEBDIR} web-release-all
else
make helper=${helper} WEBDIR=${WEBDIR} web-release-all-no-latest
fi
# Ensure that pypi release has the right version
"$0" version
# Create and publish package for pypi
make helper=${helper} WEBDIR=${WEBDIR} pypi-release
case "$run_as" in
freebsd)
;;
*)
# Archlinux release is based on pypi
make archlinux-release
;;
esac
# Announce change on ML
make helper=${helper} WEBDIR=${WEBDIR} ml-release
cat << eof
Manual steps post release:
- linkedin
- hackernews
- reddit
- twitter
eof
case "$run_as" in
freebsd)
cat <<eof
Additional steps post release:
- archlinux release
eof
;;
*)
;;
esac
;;
test)
export PYTHONPATH="$(pwd -P)"
if [ $# -lt 1 ]; then
python3 -m cdist.test
else
python3 -m unittest "$@"
fi
;;
pep8)
pep8 "${basedir}" "${basedir}/scripts/cdist" | less
;;
check-pep8)
"$0" pep8
echo "Please review pep8 report."
while true
do
echo "Continue (yes/no)?"
any=
read any
case "$any" in
yes)
break
;;
no)
exit 1
;;
*)
echo "Please answer with 'yes' or 'no' explicitly."
;;
esac
done
;;
version-branch)
"$0" changelog-version | cut -d. -f '1,2'
;;
version)
echo "VERSION = \"$(git describe)\"" > cdist/version.py
;;
target-version)
target_version=$($0 changelog-version)
echo "VERSION = \"${target_version}\"" > cdist/version.py
;;
*)
echo "Unknown helper target $@ - aborting"
exit 1
;;
esac

View file

@ -21,6 +21,7 @@
import os import os
import subprocess import subprocess
import hashlib
import cdist.version import cdist.version
@ -41,17 +42,35 @@ BANNER = """
"P' "" "" "P' "" ""
""" """
REMOTE_COPY = "scp -o User=root -q" REMOTE_COPY = "scp -o User=root"
REMOTE_EXEC = "ssh -o User=root -q" REMOTE_EXEC = "ssh -o User=root"
class Error(Exception): class Error(Exception):
"""Base exception class for this project""" """Base exception class for this project"""
pass pass
class UnresolvableRequirementsError(cdist.Error): class UnresolvableRequirementsError(cdist.Error):
"""Resolving requirements failed""" """Resolving requirements failed"""
pass pass
class CdistBetaRequired(cdist.Error):
"""Beta functionality is used but beta is not enabled"""
def __init__(self, command, arg):
self.command = command
self.arg = arg
def __str__(self):
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/--enable-beta command "
"line flag.")
return err_msg.format(self.arg, self.command)
class CdistObjectError(Error): class CdistObjectError(Error):
"""Something went wrong with an object""" """Something went wrong with an object"""
@ -60,9 +79,11 @@ class CdistObjectError(Error):
self.source = " ".join(cdist_object.source) self.source = " ".join(cdist_object.source)
self.message = message self.message = message
def __str__(self): def __str__(self):
return '%s: %s (defined at %s)' % (self.name, self.message, self.source) return '%s: %s (defined at %s)' % (self.name,
self.message,
self.source)
def file_to_list(filename): def file_to_list(filename):
"""Return list from \n seperated file""" """Return list from \n seperated file"""
@ -77,3 +98,11 @@ def file_to_list(filename):
lines = [] lines = []
return 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")

View file

@ -22,6 +22,17 @@
# FIXME: other system types (not linux ...) # 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 if [ -r /proc/cpuinfo ]; then
# this should only exist on virtual guest machines, # this should only exist on virtual guest machines,
# tested on vmware, xen, kvm # tested on vmware, xen, kvm
@ -37,11 +48,12 @@ if [ -r /proc/cpuinfo ]; then
if grep -q -i 'vmware' /sys/class/dmi/id/product_name; then if grep -q -i 'vmware' /sys/class/dmi/id/product_name; then
echo "virtual_by_vmware" echo "virtual_by_vmware"
exit exit
else elif grep -q -i 'bochs' /sys/class/dmi/id/product_name; then
if grep -q -i 'bochs' /sys/class/dmi/id/product_name; then echo "virtual_by_kvm"
echo "virtual_by_kvm" exit
exit elif grep -q -i 'virtualbox' /sys/class/dmi/id/product_name; then
fi echo "virtual_by_virtualbox"
exit
fi fi
fi fi
fi fi

View file

@ -39,6 +39,11 @@ if [ -f /etc/cdist-preos ]; then
exit 0 exit 0
fi fi
if [ -d /gnu/store ]; then
echo guixsd
exit 0
fi
### Debian and derivatives ### Debian and derivatives
if grep -q ^DISTRIB_ID=Ubuntu /etc/lsb-release 2>/dev/null; then if grep -q ^DISTRIB_ID=Ubuntu /etc/lsb-release 2>/dev/null; then
echo ubuntu echo ubuntu
@ -72,6 +77,11 @@ if [ -f /etc/owl-release ]; then
fi fi
### Redhat and derivatives ### 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 if grep -q ^CentOS /etc/redhat-release 2>/dev/null; then
echo centos echo centos
exit 0 exit 0

View file

@ -54,7 +54,7 @@ case "$($__explorer/os)" in
owl) owl)
cat /etc/owl-release cat /etc/owl-release
;; ;;
redhat|centos|mitel) redhat|centos|mitel|scientific)
cat /etc/redhat-release cat /etc/redhat-release
;; ;;
slackware) slackware)

View file

@ -1,8 +1,9 @@
cdist-type__apt_key(7) cdist-type__apt_key(7)
====================== ======================
Manage the list of keys used by apt
Steven Armstrong <steven-cdist--@--armstrong.cc> NAME
----
cdist-type__apt_key - Manage the list of keys used by apt
DESCRIPTION DESCRIPTION
@ -24,8 +25,8 @@ keyid
the id of the key to add. Defaults to __object_id the id of the key to add. Defaults to __object_id
keyserver keyserver
the keyserver from which to fetch the key. If omitted the default set in the keyserver from which to fetch the key. If omitted the default set
./parameter/default/keyserver is used. in ./parameter/default/keyserver is used.
EXAMPLES EXAMPLES
@ -47,12 +48,14 @@ EXAMPLES
__apt_key UbuntuArchiveKey --keyid 437D05B5 --keyserver keyserver.ubuntu.com __apt_key UbuntuArchiveKey --keyid 437D05B5 --keyserver keyserver.ubuntu.com
SEE ALSO AUTHORS
-------- -------
- `cdist-type(7) <cdist-type.html>`_ Steven Armstrong <steven-cdist--@--armstrong.cc>
COPYING COPYING
------- -------
Copyright \(C) 2011-2014 Steven Armstrong. Free use of this software is Copyright \(C) 2011-2014 Steven Armstrong. You can redistribute it
granted under the terms of the GNU General Public License version 3 (GPLv3). and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.

View file

@ -1,8 +1,9 @@
cdist-type__apt_key_uri(7) cdist-type__apt_key_uri(7)
========================== ==========================
Add apt key from uri
Steven Armstrong <steven-cdist--@--armstrong.cc> NAME
----
cdist-type__apt_key_uri - Add apt key from uri
DESCRIPTION DESCRIPTION
@ -37,12 +38,14 @@ EXAMPLES
--state present --state present
SEE ALSO AUTHORS
-------- -------
- `cdist-type(7) <cdist-type.html>`_ Steven Armstrong <steven-cdist--@--armstrong.cc>
COPYING COPYING
------- -------
Copyright \(C) 2011-2014 Steven Armstrong. Free use of this software is Copyright \(C) 2011-2014 Steven Armstrong. You can redistribute it
granted under the terms of the GNU General Public License version 3 (GPLv3). and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.

View file

@ -1,8 +1,9 @@
cdist-type__apt_norecommends(7) cdist-type__apt_norecommends(7)
=============================== ===============================
Configure apt to not install recommended packages
Steven Armstrong <steven-cdist--@--armstrong.cc> NAME
----
cdist-type__apt_norecommends - Configure apt to not install recommended packages
DESCRIPTION DESCRIPTION
@ -28,12 +29,14 @@ EXAMPLES
__apt_norecommends __apt_norecommends
SEE ALSO AUTHORS
-------- -------
- `cdist-type(7) <cdist-type.html>`_ Steven Armstrong <steven-cdist--@--armstrong.cc>
COPYING COPYING
------- -------
Copyright \(C) 2014 Steven Armstrong. Free use of this software is Copyright \(C) 2014 Steven Armstrong. You can redistribute it
granted under the terms of the GNU General Public License version 3 (GPLv3). and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.

View file

@ -1,8 +1,9 @@
cdist-type__apt_ppa(7) cdist-type__apt_ppa(7)
====================== ======================
Manage ppa repositories
Steven Armstrong <steven-cdist--@--armstrong.cc> NAME
----
cdist-type__apt_ppa - Manage ppa repositories
DESCRIPTION DESCRIPTION
@ -36,12 +37,14 @@ EXAMPLES
__apt_ppa ppa:sans-intern/missing-bits --state absent __apt_ppa ppa:sans-intern/missing-bits --state absent
SEE ALSO AUTHORS
-------- -------
- `cdist-type(7) <cdist-type.html>`_ Steven Armstrong <steven-cdist--@--armstrong.cc>
COPYING COPYING
------- -------
Copyright \(C) 2011-2014 Steven Armstrong. Free use of this software is Copyright \(C) 2011-2014 Steven Armstrong. You can redistribute it
granted under the terms of the GNU General Public License version 3 (GPLv3). and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.

View file

@ -1,8 +1,9 @@
cdist-type__apt_source(7) cdist-type__apt_source(7)
========================= =========================
Manage apt sources
Steven Armstrong <steven-cdist--@--armstrong.cc> NAME
----
cdist-type__apt_source - Manage apt sources
DESCRIPTION DESCRIPTION
@ -55,12 +56,14 @@ EXAMPLES
--component partner --state present --component partner --state present
SEE ALSO AUTHORS
-------- -------
- `cdist-type(7) <cdist-type.html>`_ Steven Armstrong <steven-cdist--@--armstrong.cc>
COPYING COPYING
------- -------
Copyright \(C) 2011-2014 Steven Armstrong. Free use of this software is Copyright \(C) 2011-2014 Steven Armstrong. You can redistribute it
granted under the terms of the GNU General Public License version 3 (GPLv3). and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.

View file

@ -1,8 +1,9 @@
cdist-type__apt_update_index(7) cdist-type__apt_update_index(7)
=============================== ===============================
Update apt's package index
Steven Armstrong <steven-cdist--@--armstrong.cc> NAME
----
cdist-type__apt_update_index - Update apt's package index
DESCRIPTION DESCRIPTION
@ -27,12 +28,14 @@ EXAMPLES
__apt_update_index __apt_update_index
SEE ALSO AUTHORS
-------- -------
- `cdist-type(7) <cdist-type.html>`_ Steven Armstrong <steven-cdist--@--armstrong.cc>
COPYING COPYING
------- -------
Copyright \(C) 2011 Steven Armstrong. Free use of this software is Copyright \(C) 2011 Steven Armstrong. You can redistribute it
granted under the terms of the GNU General Public License version 3 (GPLv3). and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.

View file

@ -1,8 +1,9 @@
cdist-type__block(7) cdist-type__block(7)
==================== ====================
Manage blocks of text in files
Steven Armstrong <steven-cdist--@--armstrong.cc> NAME
----
cdist-type__block - Manage blocks of text in files
DESCRIPTION DESCRIPTION
@ -68,12 +69,14 @@ EXAMPLES
DONE DONE
SEE ALSO AUTHORS
-------- -------
- `cdist-type(7) <cdist-type.html>`_ Steven Armstrong <steven-cdist--@--armstrong.cc>
COPYING COPYING
------- -------
Copyright \(C) 2013 Steven Armstrong. Free use of this software is Copyright \(C) 2013 Steven Armstrong. You can redistribute it
granted under the terms of the GNU General Public License version 3 (GPLv3). and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.

View file

@ -1,8 +1,9 @@
cdist-type__ccollect_source(7) cdist-type__ccollect_source(7)
============================== ==============================
Manage ccollect sources
Nico Schottelius <nico-cdist--@--schottelius.org> NAME
----
cdist-type__ccollect_source - Manage ccollect sources
DESCRIPTION DESCRIPTION
@ -52,12 +53,17 @@ EXAMPLES
SEE ALSO SEE ALSO
-------- --------
- `cdist-type(7) <cdist-type.html>`_ :strong:`ccollect`\ (1)
- ccollect(1)
- http://www.nico.schottelius.org/software/ccollect/
AUTHORS
-------
Nico Schottelius <nico-cdist--@--schottelius.org>
COPYING COPYING
------- -------
Copyright \(C) 2014 Nico Schottelius. Free use of this software is Copyright \(C) 2014 Nico Schottelius. You can redistribute it
granted under the terms of the GNU General Public License version 3 (GPLv3). and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.

View file

@ -40,7 +40,9 @@ echo "$source" | __file "$source_file" --source - --state "$state"
################################################################################ ################################################################################
# Booleans # Booleans
if [ -f "$__object/parameter/verbose" ]; then if [ "${state}" = "absent" ]; then
verbosestate="absent"
elif [ -f "$__object/parameter/verbose" ]; then
verbosestate="present" verbosestate="present"
else else
verbosestate="absent" verbosestate="absent"

View file

@ -1,8 +1,9 @@
cdist-type__cdist(7) cdist-type__cdist(7)
==================== ====================
Manage cdist installations
Nico Schottelius <nico-cdist--@--schottelius.org> NAME
----
cdist-type__cdist - Manage cdist installations
DESCRIPTION DESCRIPTION
@ -49,12 +50,14 @@ EXAMPLES
__cdist --source "git://git.schottelius.org/cdist" /home/cdist/cdist __cdist --source "git://git.schottelius.org/cdist" /home/cdist/cdist
SEE ALSO AUTHORS
-------- -------
- `cdist-type(7) <cdist-type.html>`_ Nico Schottelius <nico-cdist--@--schottelius.org>
COPYING COPYING
------- -------
Copyright \(C) 2013 Nico Schottelius. Free use of this software is Copyright \(C) 2013 Nico Schottelius. You can redistribute it
granted under the terms of the GNU General Public License version 3 (GPLv3). and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.

View file

@ -1,8 +1,9 @@
cdist-type__cdistmarker(7) cdist-type__cdistmarker(7)
========================== ==========================
Add a timestamped cdist marker.
Daniel Maher <phrawzty+cdist--@--gmail.com> NAME
----
cdist-type__cdistmarker - Add a timestamped cdist marker.
DESCRIPTION DESCRIPTION
@ -41,12 +42,14 @@ EXAMPLES
__cdistmarker --destination /tmp/cdist_marker --format '+%s' __cdistmarker --destination /tmp/cdist_marker --format '+%s'
SEE ALSO AUTHORS
-------- -------
- `cdist-type(7) <cdisty-type.html>`_ Daniel Maher <phrawzty+cdist--@--gmail.com>
COPYING COPYING
------- -------
Copyright \(C) 2011 Daniel Maher. Free use of this software is granted under Copyright \(C) 2011 Daniel Maher. You can redistribute it
the terms of the GNU General Public License version 3 (GPLv3). and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.

View file

@ -1,8 +1,9 @@
cdist-type__config_file(7) cdist-type__config_file(7)
========================== ==========================
Manages config files
Steven Armstrong <steven-cdist--@--armstrong.cc> NAME
----
cdist-type__config_file - _Manages config files
DESCRIPTION DESCRIPTION
@ -47,11 +48,17 @@ EXAMPLES
SEE ALSO SEE ALSO
-------- --------
- `cdist-type(7) <cdist-type.html>`_ :strong:`cdist-type__file`\ (7)
- `cdist-type__file(7) <cdist-type__file.html>`_
AUTHORS
-------
Steven Armstrong <steven-cdist--@--armstrong.cc>
COPYING COPYING
------- -------
Copyright \(C) 2015 Steven Armstrong. Free use of this software is Copyright \(C) 2015 Steven Armstrong. You can redistribute it
granted under the terms of the GNU General Public License version 3 (GPLv3). and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.

View file

@ -1,8 +1,9 @@
cdist-type__consul(7) cdist-type__consul(7)
===================== =====================
Install consul
Steven Armstrong <steven-cdist--@--armstrong.cc> NAME
----
cdist-type__consul - Install consul
DESCRIPTION DESCRIPTION
@ -40,12 +41,14 @@ EXAMPLES
--version 0.4.1 --version 0.4.1
SEE ALSO AUTHORS
-------- -------
- `cdist-type(7) <cdist-type.html>`_ Steven Armstrong <steven-cdist--@--armstrong.cc>
COPYING COPYING
------- -------
Copyright \(C) 2015 Steven Armstrong. Free use of this software is Copyright \(C) 2015 Steven Armstrong. You can redistribute it
granted under the terms of the GNU General Public License version 3 (GPLv3). and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.

View file

@ -23,7 +23,7 @@
os=$(cat "$__global/explorer/os") os=$(cat "$__global/explorer/os")
case "$os" in case "$os" in
centos|redhat|ubuntu|debian|archlinux|gentoo) scientific|centos|redhat|ubuntu|debian|archlinux|gentoo)
# any linux should work # any linux should work
: :
;; ;;

View file

@ -1,8 +1,9 @@
cdist-type__consul_agent(7) cdist-type__consul_agent(7)
=========================== ===========================
Manage the consul agent
Steven Armstrong <steven-cdist--@--armstrong.cc> NAME
----
cdist-type__consul_agent - Manage the consul agent
DESCRIPTION DESCRIPTION
@ -110,7 +111,7 @@ enable-syslog
enables logging to syslog enables logging to syslog
verify-incoming verify-incoming
enforce the use of TLS and verify a client's authenticity on incomming connections enforce the use of TLS and verify a client's authenticity on incoming connections
verify-outgoing verify-outgoing
enforce the use of TLS and verify the peers authenticity on outgoing connections enforce the use of TLS and verify the peers authenticity on outgoing connections
@ -164,11 +165,17 @@ EXAMPLES
SEE ALSO SEE ALSO
-------- --------
- `cdist-type(7) <cdist-type.html>`_ consul documentation at: <http://www.consul.io/docs/agent/options.html>.
- http://www.consul.io/docs/agent/options.html
AUTHORS
-------
Steven Armstrong <steven-cdist--@--armstrong.cc>
COPYING COPYING
------- -------
Copyright \(C) 2015 Steven Armstrong. Free use of this software is Copyright \(C) 2015 Steven Armstrong. You can redistribute it
granted under the terms of the GNU General Public License version 3 (GPLv3). and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.

View file

@ -23,7 +23,7 @@
os=$(cat "$__global/explorer/os") os=$(cat "$__global/explorer/os")
case "$os" in case "$os" in
centos|debian|redhat|ubuntu) scientific|centos|debian|redhat|ubuntu)
# whitelist safeguard # whitelist safeguard
: :
;; ;;

View file

@ -1,8 +1,9 @@
cdist-type__consul_check(7) cdist-type__consul_check(7)
============================= =============================
Manages consul checks
Steven Armstrong <steven-cdist--@--armstrong.cc> NAME
----
cdist-type__consul_check - Manages consul checks
DESCRIPTION DESCRIPTION
@ -10,7 +11,7 @@ DESCRIPTION
Generate and deploy check definitions for a consul agent. Generate and deploy check definitions for a consul agent.
See http://www.consul.io/docs/agent/checks.html for parameter documentation. See http://www.consul.io/docs/agent/checks.html for parameter documentation.
Use either script toghether with interval, or use ttl. Use either script together with interval, or use ttl.
REQUIRED PARAMETERS REQUIRED PARAMETERS
@ -85,11 +86,17 @@ EXAMPLES
SEE ALSO SEE ALSO
-------- --------
- `cdist-type(7) <cdist-type.html>`_ :strong:`cdist-type__consul_agent`\ (7)
- `cdist-type__consul_agent(7) <cdist-type__consul_agent.html>`_
AUTHORS
-------
Steven Armstrong <steven-cdist--@--armstrong.cc>
COPYING COPYING
------- -------
Copyright \(C) 2015-2016 Steven Armstrong. Free use of this software is Copyright \(C) 2015-2016 Steven Armstrong. You can redistribute it
granted under the terms of the GNU General Public License version 3 (GPLv3). and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.

View file

@ -1,8 +1,9 @@
cdist-type__consul_reload(7) cdist-type__consul_reload(7)
============================ ============================
Reload consul
Steven Armstrong <steven-cdist--@--armstrong.cc> NAME
----
cdist-type__consul_reload - Reload consul
DESCRIPTION DESCRIPTION
@ -28,12 +29,14 @@ EXAMPLES
__consul_reload __consul_reload
SEE ALSO AUTHORS
-------- -------
- `cdist-type(7) <cdist-type.html>`_ Steven Armstrong <steven-cdist--@--armstrong.cc>
COPYING COPYING
------- -------
Copyright \(C) 2015 Steven Armstrong. Free use of this software is Copyright \(C) 2015 Steven Armstrong. You can redistribute it
granted under the terms of the GNU General Public License version 3 (GPLv3). and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.

View file

@ -1,8 +1,9 @@
cdist-type__consul_service(7) cdist-type__consul_service(7)
============================= =============================
Manages consul services
Steven Armstrong <steven-cdist--@--armstrong.cc> NAME
----
cdist-type__consul_service - Manages consul services
DESCRIPTION DESCRIPTION
@ -65,11 +66,17 @@ EXAMPLES
SEE ALSO SEE ALSO
-------- --------
- `cdist-type(7) <cdist-type.html>`_ :strong:`cdist-type__consul_agent`\ (7)
- `cdist-type__consul_agent(7) <cdist-type__consul_agent.html>`_
AUTHORS
-------
Steven Armstrong <steven-cdist--@--armstrong.cc>
COPYING COPYING
------- -------
Copyright \(C) 2015 Steven Armstrong. Free use of this software is Copyright \(C) 2015 Steven Armstrong. You can redistribute it
granted under the terms of the GNU General Public License version 3 (GPLv3). and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.

View file

@ -1,8 +1,9 @@
cdist-type__consul_template(7) cdist-type__consul_template(7)
============================== ==============================
Manage the consul-template service
Steven Armstrong <steven-cdist--@--armstrong.cc> NAME
----
cdist-type__consul_template - Manage the consul-template service
DESCRIPTION DESCRIPTION
@ -124,11 +125,17 @@ EXAMPLES
SEE ALSO SEE ALSO
-------- --------
- `cdist-type(7) <cdist-type.html>`_ consul documentation at: <https://github.com/hashicorp/consul-template>.
- https://github.com/hashicorp/consul-template
AUTHORS
-------
Steven Armstrong <steven-cdist--@--armstrong.cc>
COPYING COPYING
------- -------
Copyright \(C) 2015 Steven Armstrong. Free use of this software is Copyright \(C) 2015 Steven Armstrong. You can redistribute it
granted under the terms of the GNU General Public License version 3 (GPLv3). and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.

View file

@ -22,7 +22,7 @@
os=$(cat "$__global/explorer/os") os=$(cat "$__global/explorer/os")
case "$os" in case "$os" in
centos|redhat) scientific|centos|redhat)
# whitelist safeguard # whitelist safeguard
service_onchange='service consul-template status >/dev/null && service consul-template reload || true' \ service_onchange='service consul-template status >/dev/null && service consul-template reload || true' \
;; ;;

View file

@ -1,8 +1,9 @@
cdist-type__consul_template_template(7) cdist-type__consul_template_template(7)
======================================= =======================================
Manage consul-template templates
Steven Armstrong <steven-cdist--@--armstrong.cc> NAME
----
cdist-type__consul_template_template - Manage consul-template templates
DESCRIPTION DESCRIPTION
@ -67,12 +68,17 @@ EXAMPLES
SEE ALSO SEE ALSO
-------- --------
- `cdist-type(7) <cdist-type.html>`_ :strong:`cdist-type__consul_template`\ (7), :strong:`cdist-type__consul_template_config`\ (7)
- `cdist-type__consul_template(7) <cdist-type__consul_template.html>`_
- `cdist-type__consul_template_config(7) <cdist-type__consul_template_config.html>`_
AUTHORS
-------
Steven Armstrong <steven-cdist--@--armstrong.cc>
COPYING COPYING
------- -------
Copyright \(C) 2015-2016 Steven Armstrong. Free use of this software is Copyright \(C) 2015-2016 Steven Armstrong. You can redistribute it
granted under the terms of the GNU General Public License version 3 (GPLv3). and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.

View file

@ -1,8 +1,9 @@
cdist-type__consul_watch_checks(7) cdist-type__consul_watch_checks(7)
================================== ==================================
Manages consul checks watches
Steven Armstrong <steven-cdist--@--armstrong.cc> NAME
----
cdist-type__consul_watch_checks - Manages consul checks watches
DESCRIPTION DESCRIPTION
@ -54,12 +55,19 @@ EXAMPLES
SEE ALSO SEE ALSO
-------- --------
- `cdist-type(7) <cdist-type.html>`_ :strong:`cdist-type__consul_agent`\ (7)
- `cdist-type__consul_agent(7) <cdist-type__consul_agent.html>`_
- http://www.consul.io/docs/agent/watches.html consul documentation at: <http://www.consul.io/docs/agent/watches.html>.
AUTHORS
-------
Steven Armstrong <steven-cdist--@--armstrong.cc>
COPYING COPYING
------- -------
Copyright \(C) 2015 Steven Armstrong. Free use of this software is Copyright \(C) 2015 Steven Armstrong. You can redistribute it
granted under the terms of the GNU General Public License version 3 (GPLv3). and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.

View file

@ -1,8 +1,9 @@
cdist-type__consul_watch_event(7) cdist-type__consul_watch_event(7)
================================= =================================
Manages consul event watches
Steven Armstrong <steven-cdist--@--armstrong.cc> NAME
----
cdist-type__consul_watch_event - Manages consul event watches
DESCRIPTION DESCRIPTION
@ -47,12 +48,19 @@ EXAMPLES
SEE ALSO SEE ALSO
-------- --------
- `cdist-type(7) <cdist-type.html>`_ :strong:`cdist-type__consul_agent`\ (7)
- `cdist-type__consul_agent(7) <cdist-type__consul_agent.html>`_
- http://www.consul.io/docs/agent/watches.html consul documentation at: <http://www.consul.io/docs/agent/watches.html>.
AUTHORS
-------
Steven Armstrong <steven-cdist--@--armstrong.cc>
COPYING COPYING
------- -------
Copyright \(C) 2015 Steven Armstrong. Free use of this software is Copyright \(C) 2015 Steven Armstrong. You can redistribute it
granted under the terms of the GNU General Public License version 3 (GPLv3). and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.

View file

@ -1,8 +1,9 @@
cdist-type__consul_watch_key(7) cdist-type__consul_watch_key(7)
=============================== ===============================
Manages consul key watches
Steven Armstrong <steven-cdist--@--armstrong.cc> NAME
----
cdist-type__consul_watch_key - Manages consul key watches
DESCRIPTION DESCRIPTION
@ -44,12 +45,19 @@ EXAMPLES
SEE ALSO SEE ALSO
-------- --------
- `cdist-type(7) <cdist-type.html>`_ :strong:`cdist-type__consul_agent`\ (7)
- `cdist-type__consul_agent(7) <cdist-type__consul_agent.html>`_
- http://www.consul.io/docs/agent/watches.html consul documentation at: <http://www.consul.io/docs/agent/watches.html>.
AUTHORS
-------
Steven Armstrong <steven-cdist--@--armstrong.cc>
COPYING COPYING
------- -------
Copyright \(C) 2015 Steven Armstrong. Free use of this software is Copyright \(C) 2015 Steven Armstrong. You can redistribute it
granted under the terms of the GNU General Public License version 3 (GPLv3). and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.

View file

@ -1,8 +1,9 @@
cdist-type__consul_watch_keyprefix(7) cdist-type__consul_watch_keyprefix(7)
===================================== =====================================
Manages consul keyprefix watches
Steven Armstrong <steven-cdist--@--armstrong.cc> NAME
----
cdist-type__consul_watch_keyprefix - Manages consul keyprefix watches
DESCRIPTION DESCRIPTION
@ -44,12 +45,19 @@ EXAMPLES
SEE ALSO SEE ALSO
-------- --------
- `cdist-type(7) <cdist-type.html>`_ :strong:`cdist-type__consul_agent`\ (7)
- `cdist-type__consul_agent(7) <cdist-type__consul_agent.html>`_
- http://www.consul.io/docs/agent/watches.html consul documentation at: <http://www.consul.io/docs/agent/watches.html>.
AUTHORS
-------
Steven Armstrong <steven-cdist--@--armstrong.cc>
COPYING COPYING
------- -------
Copyright \(C) 2015 Steven Armstrong. Free use of this software is Copyright \(C) 2015 Steven Armstrong. You can redistribute it
granted under the terms of the GNU General Public License version 3 (GPLv3). and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.

View file

@ -1,8 +1,9 @@
cdist-type__consul_watch_nodes(7) cdist-type__consul_watch_nodes(7)
================================= =================================
Manages consul nodes watches
Steven Armstrong <steven-cdist--@--armstrong.cc> NAME
----
cdist-type__consul_watch_nodes - Manages consul nodes watches
DESCRIPTION DESCRIPTION
@ -40,12 +41,19 @@ EXAMPLES
SEE ALSO SEE ALSO
-------- --------
- `cdist-type(7) <cdist-type.html>`_ :strong:`cdist-type__consul_agent`\ (7)
- `cdist-type__consul_agent(7) <cdist-type__consul_agent.html>`_
- http://www.consul.io/docs/agent/watches.html consul documentation at: <http://www.consul.io/docs/agent/watches.html>.
AUTHORS
-------
Steven Armstrong <steven-cdist--@--armstrong.cc>
COPYING COPYING
------- -------
Copyright \(C) 2015 Steven Armstrong. Free use of this software is Copyright \(C) 2015 Steven Armstrong. You can redistribute it
granted under the terms of the GNU General Public License version 3 (GPLv3). and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.

View file

@ -1,8 +1,9 @@
cdist-type__consul_watch_service(7) cdist-type__consul_watch_service(7)
=================================== ===================================
Manages consul service watches
Steven Armstrong <steven-cdist--@--armstrong.cc> NAME
----
cdist-type__consul_watch_service - Manages consul service watches
DESCRIPTION DESCRIPTION
@ -64,12 +65,19 @@ EXAMPLES
SEE ALSO SEE ALSO
-------- --------
- `cdist-type(7) <cdist-type.html>`_ :strong:`cdist-type__consul_agent`\ (7)
- `cdist-type__consul_agent(7) <cdist-type__consul_agent.html>`_
- http://www.consul.io/docs/agent/watches.html consul documentation at: <http://www.consul.io/docs/agent/watches.html>.
AUTHORS
-------
Steven Armstrong <steven-cdist--@--armstrong.cc>
COPYING COPYING
------- -------
Copyright \(C) 2015 Steven Armstrong. Free use of this software is Copyright \(C) 2015 Steven Armstrong. You can redistribute it
granted under the terms of the GNU General Public License version 3 (GPLv3). and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.

View file

@ -1,8 +1,9 @@
cdist-type__consul_watch_services(7) cdist-type__consul_watch_services(7)
==================================== ====================================
Manages consul services watches
Steven Armstrong <steven-cdist--@--armstrong.cc> NAME
----
cdist-type__consul_watch_services - Manages consul services watches
DESCRIPTION DESCRIPTION
@ -40,12 +41,19 @@ EXAMPLES
SEE ALSO SEE ALSO
-------- --------
- `cdist-type(7) <cdist-type.html>`_ :strong:`cdist-type__consul_agent`\ (7)
- `cdist-type__consul_agent(7) <cdist-type__consul_agent.html>`_
- http://www.consul.io/docs/agent/watches.html consul documentation at: <http://www.consul.io/docs/agent/watches.html>.
AUTHORS
-------
Steven Armstrong <steven-cdist--@--armstrong.cc>
COPYING COPYING
------- -------
Copyright \(C) 2015 Steven Armstrong. Free use of this software is Copyright \(C) 2015 Steven Armstrong. You can redistribute it
granted under the terms of the GNU General Public License version 3 (GPLv3). and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.

View file

@ -1,8 +1,9 @@
cdist-type__cron(7) cdist-type__cron(7)
=================== ===================
Installs and manages cron jobs
Steven Armstrong <steven-cdist--@--armstrong.cc> NAME
----
cdist-type__cron - Installs and manages cron jobs
DESCRIPTION DESCRIPTION
@ -67,11 +68,17 @@ EXAMPLES
SEE ALSO SEE ALSO
-------- --------
- `cdist-type(7) <cdist-type.html>`_ :strong:`crontab`\ (5)
- crontab(5)
AUTHORS
-------
Steven Armstrong <steven-cdist--@--armstrong.cc>
COPYING COPYING
------- -------
Copyright \(C) 2011-2013 Steven Armstrong. Free use of this software is Copyright \(C) 2011-2013 Steven Armstrong. You can redistribute it
granted under the terms of the GNU General Public License version 3 (GPLv3). and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.

View file

@ -1,8 +1,9 @@
cdist-type__debconf_set_selections(7) cdist-type__debconf_set_selections(7)
===================================== =====================================
Setup debconf selections
Nico Schottelius <nico-cdist--@--schottelius.org> NAME
----
cdist-type__debconf_set_selections - Setup debconf selections
DESCRIPTION DESCRIPTION
@ -36,12 +37,17 @@ EXAMPLES
SEE ALSO SEE ALSO
-------- --------
- `cdist-type(7) <cdist-type.html>`_ :strong:`debconf-set-selections`\ (1), :strong:`cdist-type__update_alternatives`\ (7)
- `cdist-type__update_alternatives(7) <cdist-type__update_alternatives.html>`_
- debconf-set-selections(1)
AUTHORS
-------
Nico Schottelius <nico-cdist--@--schottelius.org>
COPYING COPYING
------- -------
Copyright \(C) 2011-2014 Nico Schottelius. Free use of this software is Copyright \(C) 2011-2014 Nico Schottelius. You can redistribute it
granted under the terms of the GNU General Public License version 3 (GPLv3). and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.

View file

@ -1,8 +1,9 @@
cdist-type__directory(7) cdist-type__directory(7)
======================== ========================
Manage a directory
Nico Schottelius <nico-cdist--@--schottelius.org> NAME
----
cdist-type__directory - Manage a directory
DESCRIPTION DESCRIPTION
@ -87,12 +88,14 @@ EXAMPLES
--owner root --group root --mode 0755 --state present --owner root --group root --mode 0755 --state present
SEE ALSO AUTHORS
-------- -------
- `cdist-type(7) <cdist-type.html>`_ Nico Schottelius <nico-cdist--@--schottelius.org>
COPYING COPYING
------- -------
Copyright \(C) 2011 Nico Schottelius. Free use of this software is Copyright \(C) 2011 Nico Schottelius. You can redistribute it
granted under the terms of the GNU General Public License version 3 (GPLv3). and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.

View file

@ -1,8 +1,9 @@
cdist-type__dog_vdi(7) cdist-type__dog_vdi(7)
====================== ======================
Manage Sheepdog VM images
Nico Schottelius <nico-cdist--@--schottelius.org> NAME
----
cdist-type__dog_vdi - Manage Sheepdog VM images
DESCRIPTION DESCRIPTION
@ -42,12 +43,17 @@ EXAMPLES
SEE ALSO SEE ALSO
-------- --------
- `cdist-type(7) <cdist-type.html>`_ :strong:`qemu`\ (1), :strong:`dog`\ (8)
- dog(8)
- qemu(1)
AUTHORS
-------
Nico Schottelius <nico-cdist--@--schottelius.org>
COPYING COPYING
------- -------
Copyright \(C) 2014 Nico Schottelius. Free use of this software is Copyright \(C) 2014 Nico Schottelius. You can redistribute it
granted under the terms of the GNU General Public License version 3 (GPLv3). and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.

View file

@ -1,8 +1,9 @@
cdist-type__file(7) cdist-type__file(7)
=================== ===================
Manage files.
Nico Schottelius <nico-cdist--@--schottelius.org> NAME
----
cdist-type__file - Manage files.
DESCRIPTION DESCRIPTION
@ -98,12 +99,14 @@ EXAMPLES
DONE DONE
SEE ALSO AUTHORS
-------- -------
* `cdist-type(7) <cdist-type.html>`_ Nico Schottelius <nico-cdist--@--schottelius.org>
COPYING COPYING
------- -------
Copyright \(C) 2011-2013 Nico Schottelius. Free use of this software is Copyright \(C) 2011-2013 Nico Schottelius. You can redistribute it
granted under the terms of the GNU General Public License version 3 (GPLv3). and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.

View file

@ -0,0 +1,43 @@
#!/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 <http://www.gnu.org/licenses/>.
#
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

View file

@ -0,0 +1,102 @@
#!/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 <http://www.gnu.org/licenses/>.
#
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"

View file

@ -0,0 +1,81 @@
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 <fstype> on <device> \: <discoverd device> created
Filesystem was created on <discoverd device>
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 <hda--@--sfs.biz>
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+).

View file

@ -0,0 +1 @@
force

View file

@ -0,0 +1,3 @@
device
label
mkfsoptions

View file

@ -0,0 +1 @@
fstype

View file

@ -1,8 +1,9 @@
cdist-type__firewalld_rule(7) cdist-type__firewalld_rule(7)
============================= =============================
Configure firewalld rules
Nico Schottelius <nico-cdist--@--schottelius.org> NAME
----
cdist-type__firewalld_rule - Configure firewalld rules
DESCRIPTION DESCRIPTION
@ -64,12 +65,17 @@ EXAMPLES
SEE ALSO SEE ALSO
-------- --------
- `cdist-type(7) <cdist-type.html>`_ :strong:`cdist-type__iptables_rule`\ (7), :strong:`firewalld`\ (8)
- `cdist-type__iptables_rule(7) <cdist-type__iptables_rule.html>`_
- firewalld(8)
AUTHORS
-------
Nico Schottelius <nico-cdist--@--schottelius.org>
COPYING COPYING
------- -------
Copyright \(C) 2015 Nico Schottelius. Free use of this software is Copyright \(C) 2015 Nico Schottelius. You can redistribute it
granted under the terms of the GNU General Public License version 3 (GPLv3). and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.

View file

@ -0,0 +1,84 @@
#!/bin/sh
#
# 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 <http://www.gnu.org/licenses/>.
#
#
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

View file

@ -0,0 +1,53 @@
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 <darko.poljak--@--ungleich.ch>
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.

View file

@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
# #
# 2011 Nico Schottelius (nico-cdist at schottelius.org) # 2016 Darko Poljak (darko.poljak at ungleich.ch)
# #
# This file is part of cdist. # This file is part of cdist.
# #
@ -16,13 +16,8 @@
# #
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with cdist. If not, see <http://www.gnu.org/licenses/>. # along with cdist. If not, see <http://www.gnu.org/licenses/>.
#
#
# Sync repo to testhosts
#
dirs="cdist cdist-nutzung" bootstate="$(cat "$__object/parameter/bootstate")"
for dir in $dirs; do __package firewalld
rsync -av --delete /home/users/nico/p/$dir/ root@rnic01:$dir require="__package/firewalld" __start_on_boot firewalld --state "${bootstate}"
done

View file

@ -0,0 +1 @@
present

View file

@ -0,0 +1 @@
present

View file

@ -0,0 +1,2 @@
bootstate
startstate

View file

@ -1,8 +1,9 @@
cdist-type__git(7) cdist-type__git(7)
================== ==================
Get and or keep git repositories up-to-date
Nico Schottelius <nico-cdist--@--schottelius.org> NAME
----
cdist-type__git - Get and or keep git repositories up-to-date
DESCRIPTION DESCRIPTION
@ -46,12 +47,14 @@ EXAMPLES
__git /home/nico/cdist --source git://github.com/telmich/cdist.git --branch 2.1 __git /home/nico/cdist --source git://github.com/telmich/cdist.git --branch 2.1
SEE ALSO AUTHORS
-------- -------
- `cdist-type(7) <cdist-type.html>`_ Nico Schottelius <nico-cdist--@--schottelius.org>
COPYING COPYING
------- -------
Copyright \(C) 2012 Nico Schottelius. Free use of this software is Copyright \(C) 2012 Nico Schottelius. You can redistribute it
granted under the terms of the GNU General Public License version 3 (GPLv3). and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.

View file

@ -1,8 +1,9 @@
cdist-type__group(7) cdist-type__group(7)
==================== ====================
Manage groups
Steven Armstrong <steven-cdist--@--armstrong.cc> NAME
----
cdist-type__group - Manage groups
DESCRIPTION DESCRIPTION
@ -66,12 +67,14 @@ EXAMPLES
__group foobar --gid 1234 --password 'crypted-password-string' __group foobar --gid 1234 --password 'crypted-password-string'
SEE ALSO AUTHORS
-------- -------
- `cdist-type(7) <cdist-type.html>`_ Steven Armstrong <steven-cdist--@--armstrong.cc>
COPYING COPYING
------- -------
Copyright \(C) 2011-2015 Steven Armstrong. Free use of this software is Copyright \(C) 2011-2015 Steven Armstrong. You can redistribute it
granted under the terms of the GNU General Public License version 3 (GPLv3). and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.

View file

@ -40,7 +40,7 @@ case "$os" in
exit 0 exit 0
fi fi
;; ;;
centos) scientific|centos|openbsd)
if [ "$name_sysconfig" = "$name_should" -a "$name_running" = "$name_should" ]; then if [ "$name_sysconfig" = "$name_should" -a "$name_running" = "$name_should" ]; then
exit 0 exit 0
fi fi
@ -64,7 +64,7 @@ else
echo "hostname '$name_should'" echo "hostname '$name_should'"
echo "printf '%s\n' '$name_should' > /etc/hostname" echo "printf '%s\n' '$name_should' > /etc/hostname"
;; ;;
centos) centos|openbsd)
echo "hostname '$name_should'" echo "hostname '$name_should'"
;; ;;
suse) suse)

View file

@ -1,8 +1,9 @@
cdist-type__hostname(7) cdist-type__hostname(7)
======================= =======================
Set the hostname
Steven Armstrong <steven-cdist--@--armstrong.cc> NAME
----
cdist-type__hostname - Set the hostname
DESCRIPTION DESCRIPTION
@ -38,12 +39,14 @@ EXAMPLES
__hostname --name some-static-hostname __hostname --name some-static-hostname
SEE ALSO AUTHORS
-------- -------
- `cdist-type(7) <cdist-type.html>`_ Steven Armstrong <steven-cdist--@--armstrong.cc>
COPYING COPYING
------- -------
Copyright \(C) 2012 Steven Armstrong. Free use of this software is Copyright \(C) 2012 Steven Armstrong. You can redistribute it
granted under the terms of the GNU General Public License version 3 (GPLv3). and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.

View file

@ -23,7 +23,14 @@ os=$(cat "$__global/explorer/os")
if [ -f "$__object/parameter/name" ]; then if [ -f "$__object/parameter/name" ]; then
name_should="$(cat "$__object/parameter/name")" name_should="$(cat "$__object/parameter/name")"
else else
name_should="$(echo "${__target_host%%.*}")" case "$os" in
openbsd)
name_should="$(echo "${__target_host}")"
;;
*)
name_should="$(echo "${__target_host%%.*}")"
;;
esac
fi fi
@ -38,13 +45,16 @@ case "$os" in
# handled in gencode-remote # handled in gencode-remote
: :
;; ;;
centos) scientific|centos)
__key_value sysconfig-hostname \ __key_value sysconfig-hostname \
--file /etc/sysconfig/network \ --file /etc/sysconfig/network \
--delimiter '=' \ --delimiter '=' \
--key HOSTNAME \ --key HOSTNAME \
--value "$name_should" --exact_delimiter --value "$name_should" --exact_delimiter
;; ;;
openbsd)
echo "$name_should" | __file /etc/myname --source -
;;
*) *)
not_supported not_supported
;; ;;

View file

@ -1,8 +1,9 @@
cdist-type__iptables_apply(7) cdist-type__iptables_apply(7)
============================= =============================
Apply the rules
Nico Schottelius <nico-cdist--@--schottelius.org> NAME
----
cdist-type__iptables_apply - Apply the rules
DESCRIPTION DESCRIPTION
@ -28,12 +29,17 @@ None (__iptables_apply is used by __iptables_rule)
SEE ALSO SEE ALSO
-------- --------
- `cdist-type(7) <cdist-type.html>`_ :strong:`cdist-type__iptables_rule`\ (7), :strong:`iptables`\ (8)
- `cdist-type__iptables_rule(7) <cdist-type__iptables_rule.html>`_
- iptables(8)
AUTHORS
-------
Nico Schottelius <nico-cdist--@--schottelius.org>
COPYING COPYING
------- -------
Copyright \(C) 2013 Nico Schottelius. Free use of this software is Copyright \(C) 2013 Nico Schottelius. You can redistribute it
granted under the terms of the GNU General Public License version 3 (GPLv3). and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.

View file

@ -1,8 +1,9 @@
cdist-type__iptables_rule(7) cdist-type__iptables_rule(7)
============================ ============================
Deploy iptable rulesets
Nico Schottelius <nico-cdist--@--schottelius.org> NAME
----
cdist-type__iptables_rule - Deploy iptable rulesets
DESCRIPTION DESCRIPTION
@ -49,12 +50,17 @@ EXAMPLES
SEE ALSO SEE ALSO
-------- --------
- `cdist-type(7) <cdist-type.html>`_ :strong:`cdist-type__iptables_apply`\ (7), :strong:`iptables`\ (8)
- `cdist-type__iptables_apply(7) <cdist-type__iptables_apply.html>`_
- iptables(8)
AUTHORS
-------
Nico Schottelius <nico-cdist--@--schottelius.org>
COPYING COPYING
------- -------
Copyright \(C) 2013 Nico Schottelius. Free use of this software is Copyright \(C) 2013 Nico Schottelius. You can redistribute it
granted under the terms of the GNU General Public License version 3 (GPLv3). and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.

View file

@ -1,8 +1,9 @@
cdist-type__issue(7) cdist-type__issue(7)
==================== ====================
Manage issue
Nico Schottelius <nico-cdist--@--schottelius.org> NAME
----
cdist-type__issue - Manage issue
DESCRIPTION DESCRIPTION
@ -33,12 +34,14 @@ EXAMPLES
__issue --source "$__type/files/myfancyissue" __issue --source "$__type/files/myfancyissue"
SEE ALSO AUTHORS
-------- -------
- `cdist-type(7) <cdist-type.html>`_ Nico Schottelius <nico-cdist--@--schottelius.org>
COPYING COPYING
------- -------
Copyright \(C) 2011 Nico Schottelius. Free use of this software is Copyright \(C) 2011 Nico Schottelius. You can redistribute it
granted under the terms of the GNU General Public License version 3 (GPLv3). and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.

View file

@ -1,13 +1,14 @@
cdist-type__jail(7) cdist-type__jail(7)
=================== ===================
Manage FreeBSD jails
Jake Guffey <jake.guffey--@--eprotex.com> NAME
----
cdist-type__jail - Manage FreeBSD jails
DESCRIPTION DESCRIPTION
----------- -----------
This type is used on FreeBSD to manage jails. This type is used on FreeBSD to manage jails by calling the appropriate per-version subtype.
REQUIRED PARAMETERS REQUIRED PARAMETERS
@ -107,10 +108,17 @@ EXAMPLES
SEE ALSO SEE ALSO
-------- --------
- `cdist-type(7) <cdist-type.html>`_ :strong:`jail`\ (8)
AUTHORS
-------
Jake Guffey <jake.guffey--@--jointheirstm.org>
COPYING COPYING
------- -------
Copyright \(C) 2012 Jake Guffey. Free use of this software is Copyright \(C) 2012,2016 Jake Guffey. You can redistribute it
granted under the terms of the GNU General Public License version 3 (GPLv3). and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.

View file

@ -37,6 +37,19 @@ jaildir="$(cat "$__object/parameter/jaildir")"
__directory ${jaildir} --parents __directory ${jaildir} --parents
set -- "$@" "$__object_id" "--state" "$state"
cd "$__object/parameter"
for property in $(ls .); do
set -- "$@" "--$property" "$(cat "$property")"
done
ver="$(cat "$__global/explorer/os_version")"
if [ -n "$(echo "$ver" | grep '^10\.' )" ]; then # Version is 10.x
__jail_freebsd10 "$@"
else
__jail_freebsd9 "$@"
fi
# Debug # Debug
#set +x #set +x

View file

@ -0,0 +1,52 @@
#!/bin/sh
#
# 2012 Jake Guffey (jake.guffey at eprotex.com)
#
# This file is part of cdist.
#
# cdist is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# cdist is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
#
#
# The __jail type creates, configures, and deletes FreeBSD jails for use as
# virtual machines.
#
# Debug
#exec >&2
#set -x
jaildir="$(cat "$__object/parameter/jaildir")"
jailbase="$(cat "$__object/parameter/jailbase")"
state="$(cat "$__object/parameter/state")"
if [ "$state" = "present" ] && [ -z "$jailbase" ]; then
exec >&2
echo "jailbase is a REQUIRED parameter when state=present!"
exit 1
fi
remotebase="${jaildir}/jailbase.tgz"
basepresent="$(cat "$__object/explorer/basepresent")"
if [ "$state" = "present" ]; then
if [ "$basepresent" = "NONE" ]; then
echo "$__remote_copy" "${jailbase}" "$__target_host:${remotebase}"
fi # basepresent=NONE
fi # state=present
# Debug
#set +x

View file

@ -0,0 +1,362 @@
#!/bin/sh
#
# 2012,2014,2016 Jake Guffey (jake.guffey at jointheirstm.org)
#
# This file is part of cdist.
#
# cdist is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# cdist is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
#
#
# The __jail_freebsd10 type creates, configures, and deletes FreeBSD
# jails for use as virtual machines on FreeBSD 10.x.
#
# Debug
#exec >&2
#set -x
if [ -f "$__object/parameter/name" ]; then
name="$(cat "$__object/parameter/name")"
else
name="$__object_id"
fi
state="$(cat "$__object/parameter/state")"
started="true"
# If the user wants the jail gone, it implies it shouldn't be started.
[ -f "$__object/parameter/stopped" -o "$state" = "absent" ] && started="false"
if [ -f "$__object/parameter/ip" ]; then
ip="$(cat "$__object/parameter/ip")"
else
# IP is an optional param when $state=absent, but
# when $state=present, it's required. Enforce this.
if [ "$state" = "present" ]; then
exec >&2
echo "If --state is 'present,' --ip must be given\!"
exit 1
fi
fi
if [ -f "$__object/parameter/hostname" ]; then
hostname="$(cat "$__object/parameter/hostname")"
else
hostname="$name"
fi
if [ -f "$__object/parameter/devfs-disable" ]; then
devfsenable="false"
else
devfsenable="true"
fi
devfsruleset="$(cat "$__object/parameter/devfs-ruleset")"
# devfs_ruleset being defined without devfs_enable being true
# is pointless. Treat this as an error.
if [ -n "$devfsruleset" -a "$devfsenable" = "false" ]; then
exec >&2
echo "Can't have --devfs-ruleset defined with --devfs-disable"
exit 1
fi
if [ -f "$__object/parameter/onboot" ]; then
onboot="true"
fi
jaildir="$(cat "$__object/parameter/jaildir")"
present="$(cat "$__object/explorer/present")"
#present="$(cat "$__type/explorer/present")"
status="$(cat "$__object/explorer/status")"
# Handle ip="addr, addr" format
if [ $(expr "${ip}" : ".*, .*") -gt "0" ]; then
SAVE_IFS="$IFS"
IFS=", "
for cur_ip in ${ip}; do
# Just get the last IP address for SSH to listen on
mgmt_ip=$(echo "${ip}" | cut '-d ' -f1) # In case using "ip netmask" format rather than CIDR
done
IFS="$SAVE_IFS"
else
mgmt_ip=$(echo "${ip}" | cut '-d ' -f1) # In case using "ip netmask" format rather than CIDR
fi
stopJail() {
# Check $status before issuing command
if [ "$status" = "STARTED" ]; then
echo "/etc/rc.d/jail stop ${name}"
echo "stop" >> "$__messages_out"
fi
}
startJail() {
# Check $status before issuing command
if [ "$status" = "NOTSTART" ]; then
echo "/etc/rc.d/jail start ${name}"
echo "start" >> "$__messages_out"
fi
}
deleteJail() {
# Unmount the jail's mountpoints if necessary
cat <<EOF
output="\$(mount | grep "\/${name}\/dev")" || true
if [ -n "\${output}" ]; then # /dev is still mounted...jail still running?
/etc/rc.d/jail stop "${name}"
fi
output="\$(mount | grep "\/rw\/${name}\/")" || true
if [ -n "\${output}" ]; then # >=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 <<EOF
sed -i .bak -E -e "/^${name} {\$/,/^}\\\$/d" /etc/jail.conf
if [ -f "/etc/jail.conf.bak" ]; then
rm -f "/etc/jail.conf.bak"
fi
EOF
# Remove " $name " from jail_list if it's there
cat <<EOF
eval \$(grep '^jail_list=' /etc/rc.conf)
for JAIL in \${jail_list}; do
if [ ! "\${JAIL}" = "${name}" ]; then
new_list="\${new_list} \${JAIL}"
fi
done
jail_list="\${new_list}"
sed -i '.bak' "s/^jail_list=\".*\"/jail_list=\"\${jail_list}\"/" /etc/rc.conf
unset jail_list
if [ -f "/etc/rc.conf.bak" ]; then
rm -f /etc/rc.conf.bak
fi
EOF
echo "delete" >> "$__messages_out"
}
createJail() {
# Create the jail directory
cat <<EOF
umask 022
mkdir -p ${jaildir}/${name}
if [ ! -d "${jaildir}/base" ]; then
mkdir "${jaildir}/base"
tar -xzf "${jaildir}/jailbase.tgz" -C "${jaildir}/base"
if [ ! -d "${jaildir}/base/usr/local" ]; then
mkdir -p "${jaildir}/base/usr/local"
fi
if [ ! -d "${jaildir}/base/usr/home" ]; then
mkdir -p "${jaildir}/base/usr/home"
fi
if [ ! -d "${jaildir}/base/home" ]; then
if [ ! -L "${jaildir}/base/home" ]; then
SAVE=\$PWD; cd ${jaildir}/base
ln -s usr/home home
cd \$SAVE; unset SAVE
fi
fi
fi
if [ ! -d "${jaildir}/rw" ]; then
mkdir "${jaildir}/rw"
fi
mkdir -p "${jaildir}/rw/${name}/etc"
cp -r ${jaildir}/base/etc/* "${jaildir}/rw/${name}/etc/"
if [ ! -f "${jaildir}/rw/${name}/etc/resolv.conf" ]; then
cp /etc/resolv.conf "${jaildir}/rw/${name}/etc/"
fi
mkdir "${jaildir}/rw/${name}/local"
mkdir "${jaildir}/rw/${name}/var"
if [ -n "\$(ls ${jaildir}/base/var)" ]; then
cp -r ${jaildir}/base/var/* "${jaildir}/rw/${name}/var/"
fi
chmod 755 "${jaildir}/rw/${name}/var"
chmod 755 "${jaildir}/base/var"
if [ ! -d "${jaildir}/base/var/db" ]; then
mkdir -p "${jaildir}/base/var/db"
fi
if [ -n "\$(ls ${jaildir}/base/var/db)" ]; then
chmod 755 "${jaildir}/rw/${name}/var/db"
chmod 755 "${jaildir}/base/var/db"
fi
mkdir "${jaildir}/rw/${name}/home"
if [ -n "\$(ls ${jaildir}/base/usr/home)" ]; then
cp -r ${jaildir}/base/usr/home/* "${jaildir}/rw/${name}/home/"
fi
mkdir "${jaildir}/rw/${name}/root"
if [ -n "\$(ls -A ${jaildir}/base/root)" ]; then
cp -r ${jaildir}/base/root/ "${jaildir}/rw/${name}/root/"
fi
EOF
echo "create" >> "$__messages_out"
# Create the ro+rw mountpoint entries in fstab
cat <<EOF
cat >/etc/fstab.${name} <<END
${jaildir}/base ${jaildir}/${name} nullfs ro 0 0
${jaildir}/rw/${name}/etc ${jaildir}/${name}/etc nullfs rw 0 0
${jaildir}/rw/${name}/local ${jaildir}/${name}/usr/local nullfs rw 0 0
${jaildir}/rw/${name}/var ${jaildir}/${name}/var nullfs rw 0 0
${jaildir}/rw/${name}/home ${jaildir}/${name}/usr/home nullfs rw 0 0
${jaildir}/rw/${name}/root ${jaildir}/${name}/root nullfs rw 0 0
END
EOF
# Add the jail configuration to jail.conf
cat <<EOF
# first check to see whether jail_enable="YES" exists in rc.conf or not and add it
# if necessary
jail_enable="\$(grep '^jail_enable=' /etc/rc.conf | cut -d= -f2)"
if [ -z "\$jail_enable" ]; then # no jail_enable line in rc.conf at all
echo "jail_enable=\"YES\"" >>/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 <<END
[jailrules=\${num}]
add include \\\$devfsrules_hide_all
add include \\\$devfsrules_unhide_basic
add include \\\$devfsrules_unhide_login
END
fi
devfsruleset_num=\$(grep "\[${devfsruleset}=" /etc/devfs.rules | sed -n 's/\[.*=\([0-9]*\)\]/\1/pg')
if [ -n "\$devfsruleset_num" ]; then
jaildata="\$jaildata
devfs_ruleset=\"\${devfsruleset_num}\";"
fi
fi
EOF
echo "printf \"%s\\n%s\n%s\n\" \"\$jailheader\" \"\$jaildata\" \"\$jailtrailer\" >>\"\$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 <<EOF
eval "\$(grep '^jail_list=' /etc/rc.conf)"
if [ -z "\$jail_list" ]; then # no jail_list line in rc.conf at all
echo "jail_list=\"${name}\"" >>/etc/rc.conf
else
jail_list="\${jail_list} ${name}"
sed -i '.bak' "s/^jail_list=\".*\"/jail_list=\"\${jail_list}\"/" /etc/rc.conf
rm -f /etc/rc.conf.bak
fi
unset jail_list
EOF
echo "onboot" >> "$__messages_out"
fi
# Add the normal entries into the jail's rc.conf
cat <<EOF
echo hostname=\"${hostname}\" >"${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 <<EOF
mgmt_ip="$(echo "$mgmt_ip" | sed -E -e 's#/[0-9]*$##g')"
sed -E -i '.bak' -e "s/#?ListenAddress 0.0.0.0/ListenAddress \${mgmt_ip}/" "${jaildir}/rw/${name}/etc/ssh/sshd_config"
EOF
}
if [ "$present" = "EXISTS" ]; then # The jail currently exists
if [ "$state" = "present" ]; then # The jail is supposed to exist
if [ "$started" = "true" ]; then # The jail is supposed to be started
startJail
else # The jail is not supposed to be started
stopJail
fi
exit 0
else # The jail is not supposed to exist
stopJail
deleteJail
exit 0
fi
else # The jail does not currently exist
if [ "$state" = "absent" ]; then # The jail is not supposed to be present
exit 0
else # The jail is supposed to exist
createJail
[ "$started" = "true" ] && startJail
exit 0
fi
fi

View file

@ -0,0 +1,123 @@
cdist-type__jail_freebsd10(7)
=============================
NAME
----
cdist-type__jail_freeebsd10 - Manage FreeBSD jails
DESCRIPTION
-----------
This type is used on FreeBSD >= 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 <jake.guffey--@--jointheirstm.org>
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.

View file

@ -0,0 +1,3 @@
onboot
stopped
devfs-disable

View file

@ -0,0 +1 @@
jailrules

View file

@ -0,0 +1 @@

View file

@ -0,0 +1 @@
/usr/jail

View file

@ -0,0 +1 @@
present

View file

@ -0,0 +1,8 @@
name
ip
hostname
interface
devfs-ruleset
jaildir
jailbase
state

View file

@ -0,0 +1,54 @@
#!/bin/sh
#
# 2012 Jake Guffey (jake.guffey at eprotex.com)
#
# This file is part of cdist.
#
# cdist is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# cdist is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
#
#
# 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

View file

@ -0,0 +1,43 @@
#!/bin/sh
#
# 2012 Jake Guffey (jake.guffey at eprotex.com)
#
# This file is part of cdist.
#
# cdist is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# cdist is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
#
#
# 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

View file

@ -0,0 +1,52 @@
#!/bin/sh
#
# 2012 Jake Guffey (jake.guffey at eprotex.com)
#
# This file is part of cdist.
#
# cdist is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# cdist is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
#
#
# 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

View file

@ -1,6 +1,6 @@
#!/bin/sh #!/bin/sh
# #
# 2012,2014 Jake Guffey (jake.guffey at eprotex.com) # 2012,2014,2016 Jake Guffey (jake.guffey at jointheirstm.org)
# #
# This file is part of cdist. # This file is part of cdist.
# #
@ -18,8 +18,8 @@
# along with cdist. If not, see <http://www.gnu.org/licenses/>. # along with cdist. If not, see <http://www.gnu.org/licenses/>.
# #
# #
# The __jail type creates, configures, and deletes FreeBSD jails for use as # The __jail_freebsd9 type creates, configures, and deletes FreeBSD jails
# virtual machines. # for use as virtual machines on FreeBSD 9.x and before.
# #
# Debug # Debug
@ -354,3 +354,4 @@ else # The jail does not currently exist
exit 0 exit 0
fi fi
fi fi

View file

@ -0,0 +1,124 @@
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_<name>_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 <jake.guffey--@--eprotex.com>
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.

View file

@ -0,0 +1,3 @@
onboot
stopped
devfs-disable

View file

@ -0,0 +1 @@
jailrules

View file

@ -0,0 +1 @@

View file

@ -0,0 +1 @@
/usr/jail

View file

@ -0,0 +1 @@
present

View file

@ -0,0 +1,8 @@
name
ip
hostname
interface
devfs-ruleset
jaildir
jailbase
state

View file

@ -1,8 +1,9 @@
cdist-type__key_value(7) cdist-type__key_value(7)
======================== ========================
Change property values in files
Steven Armstrong <steven-cdist--@--armstrong.cc> NAME
----
cdist-type__key_value - Change property values in files
DESCRIPTION DESCRIPTION
@ -77,15 +78,17 @@ EXAMPLES
MORE INFORMATION MORE INFORMATION
---------------- ----------------
This type try to handle as many values as possible, so it doesn't use regexes. This type try to handle as many values as possible, so it doesn't use regexes.
So you need to exactly specify the key and delimiter. Delimiter can be of any lenght. So you need to exactly specify the key and delimiter. Delimiter can be of any length.
SEE ALSO AUTHORS
-------- -------
- `cdist-type(7) <cdist-type.html>`_ Steven Armstrong <steven-cdist--@--armstrong.cc>
COPYING COPYING
------- -------
Copyright \(C) 2011 Steven Armstrong. Free use of this software is Copyright \(C) 2011 Steven Armstrong. You can redistribute it
granted under the terms of the GNU General Public License version 3 (GPLv3). and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.

View file

@ -0,0 +1,37 @@
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 <carlos.ortigoza--@--ungleich.ch>
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+).

View file

@ -0,0 +1,50 @@
#!/bin/sh
#
# 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 <http://www.gnu.org/licenses/>.
#
#
# 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

View file

@ -0,0 +1 @@
type

View file

View file

@ -1,8 +1,9 @@
cdist-type__line(7) cdist-type__line(7)
=================== ===================
Manage lines in files
Nico Schottelius <nico-cdist--@--schottelius.org> NAME
----
cdist-type__line - Manage lines in files
DESCRIPTION DESCRIPTION
@ -60,11 +61,17 @@ EXAMPLES
SEE ALSO SEE ALSO
-------- --------
- `cdist-type(7) <cdist-type.html>`_ :strong:`grep`\ (1)
- grep(1)
AUTHORS
-------
Nico Schottelius <nico-cdist--@--schottelius.org>
COPYING COPYING
------- -------
Copyright \(C) 2012-2013 Nico Schottelius. Free use of this software is Copyright \(C) 2012-2013 Nico Schottelius. You can redistribute it
granted under the terms of the GNU General Public License version 3 (GPLv3). and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.

View file

@ -1,8 +1,9 @@
cdist-type__link(7) cdist-type__link(7)
=================== ===================
Manage links (hard and symbolic)
Nico Schottelius <nico-cdist--@--schottelius.org> NAME
----
cdist-type__link - Manage links (hard and symbolic)
DESCRIPTION DESCRIPTION
@ -46,12 +47,14 @@ EXAMPLES
__link /opt/plone --state absent __link /opt/plone --state absent
SEE ALSO AUTHORS
-------- -------
- `cdist-type(7) <cdist-type.html>`_ Nico Schottelius <nico-cdist--@--schottelius.org>
COPYING COPYING
------- -------
Copyright \(C) 2011-2012 Nico Schottelius. Free use of this software is Copyright \(C) 2011-2012 Nico Schottelius. You can redistribute it
granted under the terms of the GNU General Public License version 3 (GPLv3). and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.

View file

@ -1,8 +1,9 @@
cdist-type__locale(7) cdist-type__locale(7)
===================== =====================
Configure locales
Nico Schottelius <nico-cdist--@--schottelius.org> NAME
----
cdist-type__locale - Configure locales
DESCRIPTION DESCRIPTION
@ -33,12 +34,16 @@ EXAMPLES
SEE ALSO SEE ALSO
-------- --------
- locale(1) :strong:`locale`\ (1), :strong:`localedef`\ (1), :strong:`cdist-type__locale_system`\ (7)
- localedef(1)
- `cdist-type(7) <cdist-type.html>`_
AUTHORS
-------
Nico Schottelius <nico-cdist--@--schottelius.org>
COPYING COPYING
------- -------
Copyright \(C) 2013-2014 Nico Schottelius. Free use of this software is Copyright \(C) 2013-2016 Nico Schottelius. Free use of this software is
granted under the terms of the GNU General Public License version 3 (GPLv3). granted under the terms of the GNU General Public License version 3 or
later (GPLv3+).

Some files were not shown because too many files have changed in this diff Show more