diff --git a/.gitignore b/.gitignore
index baf9b6f2..2a193c2a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -8,8 +8,8 @@ docs/man/man7/*.7
docs/man/man*/*.html
docs/man/man*/*.xml
docs/man/man*/docbook-xsl.css
-docs/man/man7/cdist-type__*.text
-docs/man/man7/cdist-reference.text
+docs/man/man7/cdist-type__*.rst
+docs/man/man7/cdist-reference.rst
# Ignore cdist cache for version control
/cache/
@@ -20,6 +20,9 @@ MANIFEST
dist/
cdist/version.py
+#sphinx build dir
+_build/
+
# Packaging: Archlinux
/PKGBUILD
/cdist-*.pkg.tar.xz
diff --git a/.version b/.version
deleted file mode 100644
index 71f08595..00000000
--- a/.version
+++ /dev/null
@@ -1 +0,0 @@
-2.1.0-pre1
diff --git a/Makefile b/Makefile
index 9502c989..e584fc63 100644
--- a/Makefile
+++ b/Makefile
@@ -18,8 +18,6 @@
#
#
-A2XM=a2x -f manpage --no-xmllint -a encoding=UTF-8
-A2XH=a2x -f xhtml --no-xmllint -a encoding=UTF-8
helper=./bin/build-helper
MANDIR=docs/man
@@ -28,7 +26,7 @@ TYPEDIR=cdist/conf/type
WEBSRCDIR=docs/web
-WEBDIR=$$HOME/www.nico.schottelius.org
+WEBDIR=$$HOME/vcs/www.nico.schottelius.org
WEBBLOG=$(WEBDIR)/blog
WEBBASE=$(WEBDIR)/software/cdist
WEBPAGE=$(WEBBASE).mdwn
@@ -38,6 +36,8 @@ CHANGELOG_FILE=docs/changelog
PYTHON_VERSION=cdist/version.py
+SPHINXM=make -C $(MANDIR) man
+SPHINXH=make -C $(MANDIR) html
################################################################################
# Manpages
#
@@ -45,64 +45,48 @@ MAN1DSTDIR=$(MANDIR)/man1
MAN7DSTDIR=$(MANDIR)/man7
# Manpages #1: Types
-# Use shell / ls to get complete list - $(TYPEDIR)/*/man.text does not work
-MANTYPESRC=$(shell ls $(TYPEDIR)/*/man.text)
-
-# replace first path component
+# Use shell / ls to get complete list - $(TYPEDIR)/*/man.rst does not work
+MANTYPESRC=$(shell ls $(TYPEDIR)/*/man.rst)
MANTYPEPREFIX=$(subst $(TYPEDIR)/,$(MAN7DSTDIR)/cdist-type,$(MANTYPESRC))
+MANTYPES=$(subst /man.rst,.rst,$(MANTYPEPREFIX))
-# replace man.text with .7 or .html
-MANTYPEMAN=$(subst /man.text,.7,$(MANTYPEPREFIX))
-MANTYPEHTML=$(subst /man.text,.html,$(MANTYPEPREFIX))
-MANTYPEALL=$(MANTYPEMAN) $(MANTYPEHTML)
-
-# Link manpage so A2XH does not create man.html but correct named file
-$(MAN7DSTDIR)/cdist-type%.text: $(TYPEDIR)/%/man.text
+# Link manpage: do not create man.html but correct named file
+$(MAN7DSTDIR)/cdist-type%.rst: $(TYPEDIR)/%/man.rst
ln -sf "../../../$^" $@
# Manpages #2: reference
-MANREF=$(MAN7DSTDIR)/cdist-reference.text
-MANREFSH=$(MANDIR)/cdist-reference.text.sh
-MANREFMAN=$(MANREF:.text=.7)
-MANREFHTML=$(MANREF:.text=.html)
-MANREFALL=$(MANREFMAN) $(MANREFHTML)
+MANREF=$(MAN7DSTDIR)/cdist-reference.rst
+MANREFSH=$(MANDIR)/cdist-reference.rst.sh
$(MANREF): $(MANREFSH)
$(MANREFSH)
-# Manpages #3: static pages
-MAN1STATIC=$(shell ls $(MAN1DSTDIR)/*.text)
-MAN7STATIC=$(shell ls $(MAN7DSTDIR)/*.text)
-MANSTATICMAN=$(MAN1STATIC:.text=.1) $(MAN7STATIC:.text=.7)
-MANSTATICHTML=$(MAN1STATIC:.text=.html) $(MAN7STATIC:.text=.html)
-MANSTATICALL=$(MANSTATICMAN) $(MANSTATICHTML)
+# Manpages #3: generic part
+mansphinxman: $(MANTYPES) $(MANREF)
+ $(SPHINXM)
-# Manpages #4: generic part
+mansphinxhtml: $(MANTYPES) $(MANREF)
+ $(SPHINXH)
-# Creating the type manpage
-%.1 %.7: %.text
- $(A2XM) $^
-
-# Creating the type html page
-%.html: %.text
- $(A2XH) $^
-
-man: $(MANTYPEALL) $(MANREFALL) $(MANSTATICALL)
+man: mansphinxman mansphinxhtml
# Manpages #5: release part
MANWEBDIR=$(WEBBASE)/man/$(CHANGELOG_VERSION)
+MANBUILDDIR=$(MANDIR)/_build/html
-man-dist: man check-date
+man-dist: man
rm -rf "${MANWEBDIR}"
- mkdir -p "${MANWEBDIR}/man1" "${MANWEBDIR}/man7"
- cp ${MAN1DSTDIR}/*.html ${MAN1DSTDIR}/*.css ${MANWEBDIR}/man1
- cp ${MAN7DSTDIR}/*.html ${MAN7DSTDIR}/*.css ${MANWEBDIR}/man7
+ mkdir -p "${MANWEBDIR}"
+ # mkdir -p "${MANWEBDIR}/man1" "${MANWEBDIR}/man7"
+ # cp ${MAN1DSTDIR}/*.html ${MAN1DSTDIR}/*.css ${MANWEBDIR}/man1
+ # cp ${MAN7DSTDIR}/*.html ${MAN7DSTDIR}/*.css ${MANWEBDIR}/man7
+ cp -R ${MANBUILDDIR}/* ${MANWEBDIR}
cd ${MANWEBDIR} && git add . && git commit -m "cdist manpages update: $(CHANGELOG_VERSION)" || true
man-latest-link: web-pub
# Fix ikiwiki, which does not like symlinks for pseudo security
- ssh tee.schottelius.org \
- "cd /home/services/www/nico/www.nico.schottelius.org/www/software/cdist/man && rm -f latest && ln -sf "$(CHANGELOG_VERSION)" latest"
+ ssh staticweb.ungleich.ch \
+ "cd /home/services/www/nico/nico.schottelius.org/www/software/cdist/man/ && rm -f latest && ln -sf "$(CHANGELOG_VERSION)" latest"
################################################################################
# Speeches
@@ -162,17 +146,6 @@ $(ML_FILE): $(CHANGELOG_FILE)
ml-release: $(ML_FILE)
-################################################################################
-# Release: Freecode
-#
-FREECODE_FILE=.lock-freecode
-
-$(FREECODE_FILE): $(CHANGELOG_FILE)
- $(helper) freecode-release $(CHANGELOG_VERSION)
- touch $@
-
-freecode-release: $(FREECODE_FILE)
-
################################################################################
# pypi
#
@@ -189,7 +162,7 @@ ARCHLINUX_FILE=.lock-archlinux
ARCHLINUXTAR=cdist-$(CHANGELOG_VERSION)-1.src.tar.gz
$(ARCHLINUXTAR): PKGBUILD
- makepkg -c --source
+ umask 022; mkaurball
PKGBUILD: PKGBUILD.in $(PYTHON_VERSION)
./PKGBUILD.in $(CHANGELOG_VERSION)
@@ -219,15 +192,13 @@ release:
#
clean:
- rm -f $(MAN7DSTDIR)/cdist-reference.text
+ rm -f $(MAN7DSTDIR)/cdist-reference.rst
find "$(MANDIR)" -mindepth 2 -type l \
- -o -name "*.1" \
- -o -name "*.7" \
- -o -name "*.html" \
- -o -name "*.xml" \
| xargs rm -f
+ make -C $(MANDIR) clean
+
find * -name __pycache__ | xargs rm -rf
# Archlinux
@@ -246,10 +217,7 @@ distclean: clean
# The pub is Nico's "push to all git remotes" way ("make pub")
pub:
- for remote in "" github sf; do \
- echo "Pushing to $$remote"; \
- git push --mirror $$remote; \
- done
+ git push --mirror
test:
$(helper) $@
diff --git a/PKGBUILD.in b/PKGBUILD.in
index e3ae4619..c967249d 100755
--- a/PKGBUILD.in
+++ b/PKGBUILD.in
@@ -17,7 +17,13 @@ source=("http://pypi.python.org/packages/source/c/cdist/cdist-\${pkgver}.tar.gz"
package() {
cd cdist-\${pkgver}
python3 setup.py build install --root="\${pkgdir}"
+ find "\$pkgdir" -type d -exec chmod 0755 {} \;
+ find "\$pkgdir" -type f -exec chmod a+r {} \;
}
eof
makepkg -g >> "${outfile}"
+
+# Fix this issue:
+# error: failed to upload cdist-3.1.6-1.src.tar.gz: Error - all files must have permissions of 644 or 755.
+chmod a+r "${outfile}"
diff --git a/bin/build-helper b/bin/build-helper
index 93401d3b..31789a2e 100755
--- a/bin/build-helper
+++ b/bin/build-helper
@@ -104,6 +104,11 @@ eof
;;
ml-release)
+ if [ $# -ne 1 ]; then
+ echo "$0 ml-release version" >&2
+ exit 1
+ fi
+
version=$1; shift
to_a=cdist
@@ -140,39 +145,6 @@ eof
;;
- freecode-release)
- version=$1; shift
- api_token=$(awk '/machine freecode login/ { print $8 }' ~/.netrc)
-
- printf "Enter tag list for freecode release %s> " "$version"
- read taglist
-
- printf "Enter changelog for freecode release %s> " "$version"
- read changelog
-
- echo "Submit preview"
- cat << eof
-tag_list = $taglist
-changelog = $changelog
-version = $version
-eof
- printf "Press enter to submit to freecode> "
- read dummy
-
- cat << eof | cfreecode-api release-add cdist
- {
- "auth_code": "$api_token",
- "release": {
- "tag_list": "$taglist",
- "version": "$version",
- "changelog": "$changelog",
- "hidden_from_frontpage": false
- }
- }
-eof
-
- ;;
-
release-git-tag)
target_version=$($0 changelog-version)
if git rev-parse --verify refs/tags/$target_version 2>/dev/null; then
@@ -271,9 +243,6 @@ eof
# Archlinux release is based on pypi
make archlinux-release
- # Announce change on Freecode
- make freecode-release
-
# Announce change on ML
make ml-release
diff --git a/cdist/__init__.py b/cdist/__init__.py
index 20c76b31..4454a3ac 100644
--- a/cdist/__init__.py
+++ b/cdist/__init__.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
#
-# 2010-2012 Nico Schottelius (nico-cdist at schottelius.org)
+# 2010-2015 Nico Schottelius (nico-cdist at schottelius.org)
#
# This file is part of cdist.
#
@@ -41,8 +41,6 @@ BANNER = """
"P' "" ""
"""
-DOT_CDIST = ".cdist"
-
REMOTE_COPY = "scp -o User=root -q"
REMOTE_EXEC = "ssh -o User=root -q"
diff --git a/cdist/conf/explorer/cpu_cores b/cdist/conf/explorer/cpu_cores
index efabc848..7f7a955e 100755
--- a/cdist/conf/explorer/cpu_cores
+++ b/cdist/conf/explorer/cpu_cores
@@ -22,10 +22,19 @@
# FIXME: other system types (not linux ...)
-if [ -r /proc/cpuinfo ]; then
- cores="$(cat /proc/cpuinfo | grep "core id" | sort | uniq | wc -l)"
- if [ ${cores} -eq 0 ]; then
- cores="1"
- fi
- echo "${cores}"
-fi
+os=$("$__explorer/os")
+case "$os" in
+ "macosx")
+ echo "$(sysctl -n hw.physicalcpu)"
+ ;;
+
+ *)
+ if [ -r /proc/cpuinfo ]; then
+ cores="$(grep "core id" /proc/cpuinfo | sort | uniq | wc -l)"
+ if [ ${cores} -eq 0 ]; then
+ cores="1"
+ fi
+ echo "$cores"
+ fi
+ ;;
+esac
diff --git a/cdist/conf/explorer/cpu_sockets b/cdist/conf/explorer/cpu_sockets
index 98836cec..8a8194df 100755
--- a/cdist/conf/explorer/cpu_sockets
+++ b/cdist/conf/explorer/cpu_sockets
@@ -22,10 +22,19 @@
# FIXME: other system types (not linux ...)
-if [ -r /proc/cpuinfo ]; then
- sockets="$(cat /proc/cpuinfo | grep "physical id" | sort | uniq | wc -l)"
- if [ ${sockets} -eq 0 ]; then
- sockets="$(cat /proc/cpuinfo | grep "processor" | wc -l)"
+os=$("$__explorer/os")
+case "$os" in
+ "macosx")
+ echo "$(system_profiler SPHardwareDataType | grep "Number of Processors" | awk -F': ' '{print $2}')"
+ ;;
+
+ *)
+ if [ -r /proc/cpuinfo ]; then
+ sockets="$(grep "physical id" /proc/cpuinfo | sort | uniq | wc -l)"
+ if [ ${sockets} -eq 0 ]; then
+ sockets="$(cat /proc/cpuinfo | grep "processor" | wc -l)"
+ fi
+ echo "${sockets}"
fi
- echo "${sockets}"
-fi
+ ;;
+esac
diff --git a/cdist/conf/explorer/init b/cdist/conf/explorer/init
new file mode 100755
index 00000000..2693a0d3
--- /dev/null
+++ b/cdist/conf/explorer/init
@@ -0,0 +1,35 @@
+#!/bin/sh
+#
+# 2016 Daniel Heule (hda at sfs.biz)
+#
+# This file is part of cdist.
+#
+# cdist is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# cdist is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with cdist. If not, see .
+#
+#
+# Returns the process name of pid 1 ( normaly the init system )
+# for example at linux this value is "init" or "systemd" in most cases
+#
+
+uname_s="$(uname -s)"
+
+case "$uname_s" in
+ Linux|FreeBSD)
+ ps -o comm= -p 1 || true
+ ;;
+ *)
+ # return a empty string as unknown value
+ echo ""
+ ;;
+esac
diff --git a/cdist/conf/explorer/interfaces b/cdist/conf/explorer/interfaces
index 6804f2db..c1f2a57a 100755
--- a/cdist/conf/explorer/interfaces
+++ b/cdist/conf/explorer/interfaces
@@ -24,12 +24,12 @@
#
# Use ip, if available
-if command -v ip; then
+if command -v ip >/dev/null; then
ip -o link show | sed -n 's/^[0-9]\+: \(.\+\): <.*/\1/p'
exit 0
fi
-if ! command -v ifconfig; then
+if ! command -v ifconfig >/dev/null; then
# no ifconfig, nothing we could do
exit 0
fi
diff --git a/cdist/conf/explorer/memory b/cdist/conf/explorer/memory
index 982b5dfa..05db865f 100755
--- a/cdist/conf/explorer/memory
+++ b/cdist/conf/explorer/memory
@@ -22,6 +22,15 @@
# FIXME: other system types (not linux ...)
-if [ -r /proc/meminfo ]; then
- echo "$(cat /proc/meminfo | grep "MemTotal:" | awk '{print $2}')"
-fi
+os=$("$__explorer/os")
+case "$os" in
+ "macosx")
+ echo "$(sysctl -n hw.memsize)/1024" | bc
+ ;;
+
+ *)
+ if [ -r /proc/meminfo ]; then
+ grep "MemTotal:" /proc/meminfo | awk '{print $2}'
+ fi
+ ;;
+esac
diff --git a/cdist/conf/explorer/os b/cdist/conf/explorer/os
index 053177eb..de1d29c3 100755
--- a/cdist/conf/explorer/os
+++ b/cdist/conf/explorer/os
@@ -49,6 +49,11 @@ if [ -f /etc/debian_version ]; then
echo debian
exit 0
fi
+
+if [ -f /etc/devuan_version ]; then
+ echo devuan
+ exit 0
+fi
###
if [ -f /etc/gentoo-release ]; then
@@ -77,6 +82,11 @@ if grep -q ^Fedora /etc/redhat-release 2>/dev/null; then
exit 0
fi
+if grep -q ^Mitel /etc/redhat-release 2>/dev/null; then
+ echo mitel
+ exit 0
+fi
+
if [ -f /etc/redhat-release ]; then
echo redhat
exit 0
diff --git a/cdist/conf/explorer/os_version b/cdist/conf/explorer/os_version
index 50889429..6c7becdc 100755
--- a/cdist/conf/explorer/os_version
+++ b/cdist/conf/explorer/os_version
@@ -33,6 +33,9 @@ case "$($__explorer/os)" in
debian)
cat /etc/debian_version
;;
+ devuan)
+ cat /etc/devuan_version
+ ;;
fedora)
cat /etc/fedora-release
;;
@@ -51,7 +54,7 @@ case "$($__explorer/os)" in
owl)
cat /etc/owl-release
;;
- redhat|centos)
+ redhat|centos|mitel)
cat /etc/redhat-release
;;
slackware)
diff --git a/cdist/conf/type/__apt_key/man.text b/cdist/conf/type/__apt_key/man.rst
similarity index 52%
rename from cdist/conf/type/__apt_key/man.text
rename to cdist/conf/type/__apt_key/man.rst
index 1a33e732..43dc89b1 100644
--- a/cdist/conf/type/__apt_key/man.text
+++ b/cdist/conf/type/__apt_key/man.rst
@@ -1,13 +1,10 @@
cdist-type__apt_key(7)
======================
+Manage the list of keys used by apt
+
Steven Armstrong
-NAME
-----
-cdist-type__apt_key - manage the list of keys used by apt
-
-
DESCRIPTION
-----------
Manages the list of keys used by apt to authenticate packages.
@@ -20,13 +17,13 @@ None.
OPTIONAL PARAMETERS
-------------------
-state::
+state
'present' or 'absent'. Defaults to 'present'
-keyid::
+keyid
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
./parameter/default/keyserver is used.
@@ -34,25 +31,25 @@ keyserver::
EXAMPLES
--------
---------------------------------------------------------------------------------
-# Add Ubuntu Archive Automatic Signing Key
-__apt_key 437D05B5
-# Same thing
-__apt_key 437D05B5 --state present
-# Get rid of it
-__apt_key 437D05B5 --state absent
+.. code-block:: sh
-# same thing with human readable name and explicit keyid
-__apt_key UbuntuArchiveKey --keyid 437D05B5
+ # Add Ubuntu Archive Automatic Signing Key
+ __apt_key 437D05B5
+ # Same thing
+ __apt_key 437D05B5 --state present
+ # Get rid of it
+ __apt_key 437D05B5 --state absent
-# same thing with other keyserver
-__apt_key UbuntuArchiveKey --keyid 437D05B5 --keyserver keyserver.ubuntu.com
---------------------------------------------------------------------------------
+ # same thing with human readable name and explicit keyid
+ __apt_key UbuntuArchiveKey --keyid 437D05B5
+
+ # same thing with other keyserver
+ __apt_key UbuntuArchiveKey --keyid 437D05B5 --keyserver keyserver.ubuntu.com
SEE ALSO
--------
-- cdist-type(7)
+- `cdist-type(7) `_
COPYING
diff --git a/cdist/conf/type/__apt_key/parameter/default/keyserver b/cdist/conf/type/__apt_key/parameter/default/keyserver
index f851282c..0d189916 100644
--- a/cdist/conf/type/__apt_key/parameter/default/keyserver
+++ b/cdist/conf/type/__apt_key/parameter/default/keyserver
@@ -1 +1 @@
-subkeys.pgp.net
+pool.sks-keyservers.net
diff --git a/cdist/conf/type/__apt_key_uri/man.text b/cdist/conf/type/__apt_key_uri/man.rst
similarity index 61%
rename from cdist/conf/type/__apt_key_uri/man.text
rename to cdist/conf/type/__apt_key_uri/man.rst
index fe9c3a25..a235e13a 100644
--- a/cdist/conf/type/__apt_key_uri/man.text
+++ b/cdist/conf/type/__apt_key_uri/man.rst
@@ -1,13 +1,10 @@
cdist-type__apt_key_uri(7)
==========================
+Add apt key from uri
+
Steven Armstrong
-NAME
-----
-cdist-type__apt_key_uri - add apt key from uri
-
-
DESCRIPTION
-----------
Download a key from an uri and add it to the apt keyring.
@@ -15,16 +12,16 @@ Download a key from an uri and add it to the apt keyring.
REQUIRED PARAMETERS
-------------------
-uri::
+uri
the uri from which to download the key
OPTIONAL PARAMETERS
-------------------
-state::
+state
'present' or 'absent', defaults to 'present'
-name::
+name
a name for this key, used when testing if it is already installed.
Defaults to __object_id
@@ -32,17 +29,17 @@ name::
EXAMPLES
--------
---------------------------------------------------------------------------------
-__apt_key_uri rabbitmq \
- --name 'RabbitMQ Release Signing Key ' \
- --uri http://www.rabbitmq.com/rabbitmq-signing-key-public.asc \
- --state present
---------------------------------------------------------------------------------
+.. code-block:: sh
+
+ __apt_key_uri rabbitmq \
+ --name 'RabbitMQ Release Signing Key ' \
+ --uri http://www.rabbitmq.com/rabbitmq-signing-key-public.asc \
+ --state present
SEE ALSO
--------
-- cdist-type(7)
+- `cdist-type(7) `_
COPYING
diff --git a/cdist/conf/type/__apt_norecommends/man.text b/cdist/conf/type/__apt_norecommends/man.rst
similarity index 63%
rename from cdist/conf/type/__apt_norecommends/man.text
rename to cdist/conf/type/__apt_norecommends/man.rst
index 3b65e72f..232bb166 100644
--- a/cdist/conf/type/__apt_norecommends/man.text
+++ b/cdist/conf/type/__apt_norecommends/man.rst
@@ -1,13 +1,10 @@
cdist-type__apt_norecommends(7)
===============================
+Configure apt to not install recommended packages
+
Steven Armstrong
-NAME
-----
-cdist-type__apt_norecommends - configure apt to not install recommended packages
-
-
DESCRIPTION
-----------
Configure apt to not install any recommended or suggested packages.
@@ -26,14 +23,14 @@ None.
EXAMPLES
--------
---------------------------------------------------------------------------------
-__apt_norecommends
---------------------------------------------------------------------------------
+.. code-block:: sh
+
+ __apt_norecommends
SEE ALSO
--------
-- cdist-type(7)
+- `cdist-type(7) `_
COPYING
diff --git a/cdist/conf/type/__apt_norecommends/manifest b/cdist/conf/type/__apt_norecommends/manifest
index 881c2427..9e633308 100755
--- a/cdist/conf/type/__apt_norecommends/manifest
+++ b/cdist/conf/type/__apt_norecommends/manifest
@@ -22,7 +22,7 @@
os=$(cat "$__global/explorer/os")
case "$os" in
- ubuntu|debian)
+ ubuntu|debian|devuan)
# No stinking recommends thank you very much.
# If I want something installed I will do so myself.
__file /etc/apt/apt.conf.d/99-no-recommends \
@@ -30,6 +30,8 @@ case "$os" in
--source - << DONE
APT::Install-Recommends "0";
APT::Install-Suggests "0";
+APT::AutoRemove::RecommendsImportant "0";
+APT::AutoRemove::SuggestsImportant "0";
DONE
;;
*)
diff --git a/cdist/conf/type/__apt_ppa/man.text b/cdist/conf/type/__apt_ppa/man.rst
similarity index 55%
rename from cdist/conf/type/__apt_ppa/man.text
rename to cdist/conf/type/__apt_ppa/man.rst
index da18e9f0..e39bd6b2 100644
--- a/cdist/conf/type/__apt_ppa/man.text
+++ b/cdist/conf/type/__apt_ppa/man.rst
@@ -1,13 +1,10 @@
cdist-type__apt_ppa(7)
======================
+Manage ppa repositories
+
Steven Armstrong
-NAME
-----
-cdist-type__apt_ppa - Manage ppa repositories
-
-
DESCRIPTION
-----------
This cdist type allows manage ubuntu ppa repositories.
@@ -15,7 +12,7 @@ This cdist type allows manage ubuntu ppa repositories.
REQUIRED PARAMETERS
-------------------
-state::
+state
The state the ppa should be in, either 'present' or 'absent'.
Defaults to 'present'
@@ -28,20 +25,20 @@ None.
EXAMPLES
--------
---------------------------------------------------------------------------------
-# Enable a ppa repository
-__apt_ppa ppa:sans-intern/missing-bits
-# same as
-__apt_ppa ppa:sans-intern/missing-bits --state present
+.. code-block:: sh
-# Disable a ppa repository
-__apt_ppa ppa:sans-intern/missing-bits --state absent
---------------------------------------------------------------------------------
+ # Enable a ppa repository
+ __apt_ppa ppa:sans-intern/missing-bits
+ # same as
+ __apt_ppa ppa:sans-intern/missing-bits --state present
+
+ # Disable a ppa repository
+ __apt_ppa ppa:sans-intern/missing-bits --state absent
SEE ALSO
--------
-- cdist-type(7)
+- `cdist-type(7) `_
COPYING
diff --git a/cdist/conf/type/__apt_ppa/manifest b/cdist/conf/type/__apt_ppa/manifest
index 1d90e9c4..a67c7613 100755
--- a/cdist/conf/type/__apt_ppa/manifest
+++ b/cdist/conf/type/__apt_ppa/manifest
@@ -1,6 +1,6 @@
#!/bin/sh
#
-# 2011-2014 Steven Armstrong (steven-cdist at armstrong.cc)
+# 2011-2016 Steven Armstrong (steven-cdist at armstrong.cc)
#
# This file is part of cdist.
#
@@ -21,9 +21,8 @@
name="$__object_id"
__package software-properties-common
-__package python-software-properties
-require="__package/software-properties-common __package/python-software-properties" \
+require="__package/software-properties-common" \
__file /usr/local/bin/remove-apt-repository \
--source "$__type/files/remove-apt-repository" \
--mode 0755
diff --git a/cdist/conf/type/__apt_source/man.text b/cdist/conf/type/__apt_source/man.rst
similarity index 60%
rename from cdist/conf/type/__apt_source/man.text
rename to cdist/conf/type/__apt_source/man.rst
index 03b2b311..70649c4b 100644
--- a/cdist/conf/type/__apt_source/man.text
+++ b/cdist/conf/type/__apt_source/man.rst
@@ -1,13 +1,10 @@
cdist-type__apt_source(7)
=========================
+Manage apt sources
+
Steven Armstrong
-NAME
-----
-cdist-type__apt_source - manage apt sources
-
-
DESCRIPTION
-----------
This cdist type allows you to manage apt sources.
@@ -15,52 +12,52 @@ This cdist type allows you to manage apt sources.
REQUIRED PARAMETERS
-------------------
-uri::
+uri
the uri to the apt repository
OPTIONAL PARAMETERS
-------------------
-arch::
+arch
set this if you need to force and specific arch (ubuntu specific)
-state::
+state
'present' or 'absent', defaults to 'present'
-distribution::
+distribution
the distribution codename to use. Defaults to DISTRIB_CODENAME from
the targets /etc/lsb-release
-component::
+component
space delimited list of components to enable. Defaults to an empty string.
BOOLEAN PARAMETERS
------------------
-include-src::
+include-src
include deb-src entries
EXAMPLES
--------
---------------------------------------------------------------------------------
-__apt_source rabbitmq \
- --uri http://www.rabbitmq.com/debian/ \
- --distribution testing \
- --component main \
- --include-src \
- --state present
+.. code-block:: sh
-__apt_source canonical_partner \
- --uri http://archive.canonical.com/ \
- --component partner --state present
---------------------------------------------------------------------------------
+ __apt_source rabbitmq \
+ --uri http://www.rabbitmq.com/debian/ \
+ --distribution testing \
+ --component main \
+ --include-src \
+ --state present
+
+ __apt_source canonical_partner \
+ --uri http://archive.canonical.com/ \
+ --component partner --state present
SEE ALSO
--------
-- cdist-type(7)
+- `cdist-type(7) `_
COPYING
diff --git a/cdist/conf/type/__apt_source/manifest b/cdist/conf/type/__apt_source/manifest
index 0e782716..59c7c567 100755
--- a/cdist/conf/type/__apt_source/manifest
+++ b/cdist/conf/type/__apt_source/manifest
@@ -27,11 +27,9 @@ if [ -f "$__object/parameter/distribution" ]; then
else
distribution="$(cat "$__global/explorer/lsb_codename")"
fi
-if [ -f "$__object/parameter/component" ]; then
- component="$(cat "$__object/parameter/component")"
-else
- component=""
-fi
+
+component="$(cat "$__object/parameter/component")"
+
if [ -f "$__object/parameter/arch" ]; then
forcedarch="[arch=$(cat "$__object/parameter/arch")]"
else
diff --git a/cdist/test/cdist_object/fixtures/object/__first/.keep b/cdist/conf/type/__apt_source/parameter/default/component
similarity index 100%
rename from cdist/test/cdist_object/fixtures/object/__first/.keep
rename to cdist/conf/type/__apt_source/parameter/default/component
diff --git a/cdist/conf/type/__apt_update_index/man.text b/cdist/conf/type/__apt_update_index/man.rst
similarity index 65%
rename from cdist/conf/type/__apt_update_index/man.text
rename to cdist/conf/type/__apt_update_index/man.rst
index 778af508..2fc66c65 100644
--- a/cdist/conf/type/__apt_update_index/man.text
+++ b/cdist/conf/type/__apt_update_index/man.rst
@@ -1,13 +1,10 @@
cdist-type__apt_update_index(7)
===============================
+Update apt's package index
+
Steven Armstrong
-NAME
-----
-cdist-type__apt_update_index - update apt's package index
-
-
DESCRIPTION
-----------
This cdist type runs apt-get update whenever any apt sources have changed.
@@ -25,14 +22,14 @@ None.
EXAMPLES
--------
---------------------------------------------------------------------------------
-__apt_update_index
---------------------------------------------------------------------------------
+.. code-block:: sh
+
+ __apt_update_index
SEE ALSO
--------
-- cdist-type(7)
+- `cdist-type(7) `_
COPYING
diff --git a/cdist/conf/type/__block/explorer/block b/cdist/conf/type/__block/explorer/block
index 6c35bc46..e1ca3441 100755
--- a/cdist/conf/type/__block/explorer/block
+++ b/cdist/conf/type/__block/explorer/block
@@ -1,5 +1,24 @@
#!/bin/sh
-# 2013 Steven Armstrong (steven-cdist at armstrong.cc)
+#
+# 2013 Steven Armstrong (steven-cdist armstrong.cc)
+# 2014 Nico Schottelius (nico-cdist at schottelius.org)
+#
+# This file is part of cdist.
+#
+# cdist is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# cdist is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with cdist. If not, see .
+#
+
file="$(cat "$__object/parameter/file" 2>/dev/null || echo "/$__object_id")"
@@ -8,12 +27,12 @@ file="$(cat "$__object/parameter/file" 2>/dev/null || echo "/$__object_id")"
prefix=$(cat "$__object/parameter/prefix" 2>/dev/null || echo "#cdist:__block/$__object_id")
suffix=$(cat "$__object/parameter/suffix" 2>/dev/null || echo "#/cdist:__block/$__object_id")
-awk -v prefix="$prefix" -v suffix="$suffix" '{
- if (index($0,prefix)) {
+awk -v prefix="^$prefix\$" -v suffix="^$suffix\$" '{
+ if (match($0,prefix)) {
triggered=1
}
if (triggered) {
- if (index($0,suffix)) {
+ if (match($0,suffix)) {
triggered=0
}
print
diff --git a/cdist/conf/type/__block/gencode-remote b/cdist/conf/type/__block/gencode-remote
index 0a5eea18..2e2147e5 100755
--- a/cdist/conf/type/__block/gencode-remote
+++ b/cdist/conf/type/__block/gencode-remote
@@ -46,13 +46,13 @@ tmpfile=\$(mktemp ${file}.cdist.XXXXXXXXXX)
if [ -f "$file" ]; then
cp -p "$file" "\$tmpfile"
fi
-awk -v prefix="$prefix" -v suffix="$suffix" '
+awk -v prefix="^$prefix\$" -v suffix="^$suffix\$" '
{
- if (index(\$0,prefix)) {
+ if (match(\$0,prefix)) {
triggered=1
}
if (triggered) {
- if (index(\$0,suffix)) {
+ if (match(\$0,suffix)) {
triggered=0
}
} else {
diff --git a/cdist/conf/type/__block/man.text b/cdist/conf/type/__block/man.rst
similarity index 64%
rename from cdist/conf/type/__block/man.text
rename to cdist/conf/type/__block/man.rst
index 2312d293..4b7d61dc 100644
--- a/cdist/conf/type/__block/man.text
+++ b/cdist/conf/type/__block/man.rst
@@ -1,13 +1,10 @@
cdist-type__block(7)
====================
+Manage blocks of text in files
+
Steven Armstrong
-NAME
-----
-cdist-type__block - Manage blocks of text in files
-
-
DESCRIPTION
-----------
Manage a block of text in an existing file.
@@ -18,62 +15,62 @@ of text.
REQUIRED PARAMETERS
-------------------
-text::
+text
the text to manage.
If text is '-' (dash), take what was written to stdin as the text.
OPTIONAL PARAMETERS
-------------------
-file::
+file
the file in which to manage the text block.
Defaults to object_id.
-prefix::
+prefix
the prefix to add before the text.
Defaults to #cdist:__block/$__object_id
-suffix::
- the prefix to add after the text.
+suffix
+ the suffix to add after the text.
Defaults to #/cdist:__block/$__object_id
-state::
+state
'present' or 'absent', defaults to 'present'
MESSAGES
--------
-add::
+add
block was added
-update::
+update
block was updated/changed
-remove::
+remove
block was removed
EXAMPLES
--------
---------------------------------------------------------------------------------
-# text from argument
-__block /path/to/file \
- --prefix '#start' \
- --suffix '#end' \
- --text 'some\nblock of\ntext'
+.. code-block:: sh
-# text from stdin
-__block some-id \
- --file /path/to/file \
- --text - << DONE
-here some block
-of text
-DONE
---------------------------------------------------------------------------------
+ # text from argument
+ __block /path/to/file \
+ --prefix '#start' \
+ --suffix '#end' \
+ --text 'some\nblock of\ntext'
+
+ # text from stdin
+ __block some-id \
+ --file /path/to/file \
+ --text - << DONE
+ here some block
+ of text
+ DONE
SEE ALSO
--------
-- cdist-type(7)
+- `cdist-type(7) `_
COPYING
diff --git a/cdist/conf/type/__block/manifest b/cdist/conf/type/__block/manifest
index 1fc9ec79..bf96181c 100755
--- a/cdist/conf/type/__block/manifest
+++ b/cdist/conf/type/__block/manifest
@@ -31,6 +31,6 @@ echo "$prefix" > "$block"
if [ "$text" = "-" ]; then
cat "$__object/stdin" >> "$block"
else
- cat "$text" >> "$block"
+ echo "$text" >> "$block"
fi
echo "$suffix" >> "$block"
diff --git a/cdist/conf/type/__ccollect_source/explorer/stat b/cdist/conf/type/__ccollect_source/explorer/stat
index 298221b7..9b5ad75b 100755
--- a/cdist/conf/type/__ccollect_source/explorer/stat
+++ b/cdist/conf/type/__ccollect_source/explorer/stat
@@ -25,7 +25,7 @@ destination="/$__object_id"
os=$("$__explorer/os")
case "$os" in
- "freebsd")
+ "freebsd"|"netbsd"|"openbsd")
# FIXME: should be something like this based on man page, but can not test
stat -f "type: %ST
owner: %Du %Su
@@ -35,6 +35,15 @@ size: %Dz
links: %Dl
" "$destination"
;;
+ "macosx")
+ stat -f "type: %HT
+ owner: %Du %Su
+ group: %Dg %Sg
+ mode: %Lp %Sp
+ size: %Dz
+ links: %Dl
+ " "$destination"
+ ;;
*)
stat --printf="type: %F
owner: %u %U
diff --git a/cdist/conf/type/__ccollect_source/man.text b/cdist/conf/type/__ccollect_source/man.rst
similarity index 65%
rename from cdist/conf/type/__ccollect_source/man.text
rename to cdist/conf/type/__ccollect_source/man.rst
index 32a7467e..12fb8f42 100644
--- a/cdist/conf/type/__ccollect_source/man.text
+++ b/cdist/conf/type/__ccollect_source/man.rst
@@ -1,59 +1,58 @@
cdist-type__ccollect_source(7)
==============================
+Manage ccollect sources
+
Nico Schottelius
-NAME
-----
-cdist-type__ccollect_source - Manage ccollect sources
-
-
DESCRIPTION
-----------
This cdist type allows you to create or delete ccollect sources.
+
REQUIRED PARAMETERS
-------------------
-source::
+source
The source from which to backup
-destination::
+destination
The destination directory
OPTIONAL PARAMETERS
-------------------
-state::
+state
'present' or 'absent', defaults to 'present'
-ccollectconf::
+ccollectconf
The CCOLLECT_CONF directory. Defaults to /etc/ccollect.
OPTIONAL MULTIPLE PARAMETERS
----------------------------
-exclude::
+exclude
Paths to exclude of backup
+
BOOLEAN PARAMETERS
------------------
-verbose::
+verbose
Whether to report backup verbosely
+
EXAMPLES
--------
---------------------------------------------------------------------------------
-__ccollect_source doc.ungleich.ch \
- --source doc.ungleich.ch:/ \
- --destination /backup/doc.ungleich.ch \
- --exclude '/proc/*' --exclude '/sys/*' \
- --verbose
+.. code-block:: sh
---------------------------------------------------------------------------------
+ __ccollect_source doc.ungleich.ch \
+ --source doc.ungleich.ch:/ \
+ --destination /backup/doc.ungleich.ch \
+ --exclude '/proc/*' --exclude '/sys/*' \
+ --verbose
SEE ALSO
--------
-- cdist-type(7)
+- `cdist-type(7) `_
- ccollect(1)
- http://www.nico.schottelius.org/software/ccollect/
diff --git a/cdist/conf/type/__cdist/man.text b/cdist/conf/type/__cdist/man.rst
similarity index 67%
rename from cdist/conf/type/__cdist/man.text
rename to cdist/conf/type/__cdist/man.rst
index 0805598e..f15d3b73 100644
--- a/cdist/conf/type/__cdist/man.text
+++ b/cdist/conf/type/__cdist/man.rst
@@ -1,13 +1,10 @@
cdist-type__cdist(7)
====================
+Manage cdist installations
+
Nico Schottelius
-NAME
-----
-cdist-type__cdist - Manage cdist installations
-
-
DESCRIPTION
-----------
This cdist type allows you to easily setup cdist
@@ -26,16 +23,16 @@ REQUIRED PARAMETERS
OPTIONAL PARAMETERS
-------------------
-username::
+username
Select the user to create for the cdist installation.
Defaults to "cdist".
-source::
+source
Select the source from which to clone cdist from.
Defaults to "git://github.com/telmich/cdist.git".
-branch::
+branch
Select the branch to checkout from.
Defaults to "master".
@@ -43,18 +40,18 @@ branch::
EXAMPLES
--------
---------------------------------------------------------------------------------
-# Install cdist for user cdist in her home as subfolder cdist
-__cdist /home/cdist/cdist
+.. code-block:: sh
-# Use alternative source
-__cdist --source "git://git.schottelius.org/cdist" /home/cdist/cdist
---------------------------------------------------------------------------------
+ # Install cdist for user cdist in her home as subfolder cdist
+ __cdist /home/cdist/cdist
+
+ # Use alternative source
+ __cdist --source "git://git.schottelius.org/cdist" /home/cdist/cdist
SEE ALSO
--------
-- cdist-type(7)
+- `cdist-type(7) `_
COPYING
diff --git a/cdist/conf/type/__cdistmarker/gencode-remote b/cdist/conf/type/__cdistmarker/gencode-remote
index e332df38..92ea582b 100755
--- a/cdist/conf/type/__cdistmarker/gencode-remote
+++ b/cdist/conf/type/__cdistmarker/gencode-remote
@@ -19,19 +19,11 @@
#
# The marker file is established in the docs, but it isn't obligatory.
-if [ -f "$__object/parameter/destination" ]; then
- destination="$(cat "$__object/parameter/destination")"
-else
- destination='/etc/cdist-configured'
-fi
+destination="$(cat "$__object/parameter/destination")"
# The basic output of date is usually good enough, but variety is the
# spice of life...
-if [ -f "$__object/parameter/format" ]; then
- format="$(cat "$__object/parameter/format")"
-else
- format='-u'
-fi
+format="$(cat "$__object/parameter/format")"
# Dump the timestamp in UTC to the marker
echo "date $format > $destination"
diff --git a/cdist/conf/type/__cdistmarker/man.text b/cdist/conf/type/__cdistmarker/man.rst
similarity index 67%
rename from cdist/conf/type/__cdistmarker/man.text
rename to cdist/conf/type/__cdistmarker/man.rst
index ca5611a7..22e711b6 100644
--- a/cdist/conf/type/__cdistmarker/man.text
+++ b/cdist/conf/type/__cdistmarker/man.rst
@@ -1,13 +1,10 @@
cdist-type__cdistmarker(7)
==========================
+Add a timestamped cdist marker.
+
Daniel Maher
-NAME
-----
-cdist-type__cdistmarker - Add a timestamped cdist marker.
-
-
DESCRIPTION
-----------
This type is used to add a common marker file which indicates that a given
@@ -23,11 +20,11 @@ None.
OPTIONAL PARAMETERS
-------------------
-destination::
+destination
The path and filename of the marker.
Default: /etc/cdist-configured
-format::
+format
The format of the timestamp. This is passed directly to system 'date'.
Default: -u
@@ -35,18 +32,18 @@ format::
EXAMPLES
--------
---------------------------------------------------------------------------------
-# Creates the marker as normal.
-__cdistmarker
+.. code-block:: sh
-# Creates the marker differently.
-__cdistmarker --file /tmp/cdist_marker --format '+%s'
---------------------------------------------------------------------------------
+ # Creates the marker as normal.
+ __cdistmarker
+
+ # Creates the marker differently.
+ __cdistmarker --destination /tmp/cdist_marker --format '+%s'
SEE ALSO
--------
-- cdist-type(7)
+- `cdist-type(7) `_
COPYING
diff --git a/cdist/conf/type/__cdistmarker/parameter/default/destination b/cdist/conf/type/__cdistmarker/parameter/default/destination
new file mode 100644
index 00000000..bd3a112f
--- /dev/null
+++ b/cdist/conf/type/__cdistmarker/parameter/default/destination
@@ -0,0 +1 @@
+/etc/cdist-configured
diff --git a/cdist/conf/type/__cdistmarker/parameter/default/format b/cdist/conf/type/__cdistmarker/parameter/default/format
new file mode 100644
index 00000000..5dc9e6ec
--- /dev/null
+++ b/cdist/conf/type/__cdistmarker/parameter/default/format
@@ -0,0 +1 @@
+-u
diff --git a/cdist/conf/type/__config_file/gencode-remote b/cdist/conf/type/__config_file/gencode-remote
new file mode 100755
index 00000000..e9b38c35
--- /dev/null
+++ b/cdist/conf/type/__config_file/gencode-remote
@@ -0,0 +1,34 @@
+#!/bin/sh
+#
+# 2015 Steven Armstrong (steven-cdist at armstrong.cc)
+#
+# This file is part of cdist.
+#
+# cdist is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# cdist is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with cdist. If not, see .
+#
+
+destination="$__object_id"
+state="$(cat "$__object/parameter/state")"
+
+if [ "$state" = "absent" ]; then
+ # nothing to do
+ exit 0
+fi
+
+if [ -f "$__object/parameter/onchange" ]; then
+ if grep -q "^__file/${destination}" "$__messages_in"; then
+ cat "$__object/parameter/onchange"
+ fi
+fi
+
diff --git a/cdist/conf/type/__config_file/man.rst b/cdist/conf/type/__config_file/man.rst
new file mode 100644
index 00000000..49b63984
--- /dev/null
+++ b/cdist/conf/type/__config_file/man.rst
@@ -0,0 +1,57 @@
+cdist-type__config_file(7)
+==========================
+Manages config files
+
+Steven Armstrong
+
+
+DESCRIPTION
+-----------
+Deploy config files using the file type.
+Run the given code if the files changes.
+
+
+REQUIRED PARAMETERS
+-------------------
+None.
+
+
+OPTIONAL PARAMETERS
+-------------------
+group
+ see cdist-type__file
+mode
+ see cdist-type__file
+onchange
+ the code to run if the file changes
+owner
+ see cdist-type__file
+source
+ Path to the config file.
+ If source is '-' (dash), take what was written to stdin as the config file content.
+state
+ see cdist-type__file
+
+
+EXAMPLES
+--------
+
+.. code-block:: sh
+
+ __config_file /etc/consul/conf.d/watch_foo.json \
+ --owner root --group consul --mode 640 \
+ --source "$__type/files/watch_foo.json" \
+ --state present \
+ --onchange 'service consul status >/dev/null && service consul reload || true'
+
+
+SEE ALSO
+--------
+- `cdist-type(7) `_
+- `cdist-type__file(7) `_
+
+
+COPYING
+-------
+Copyright \(C) 2015 Steven Armstrong. Free use of this software is
+granted under the terms of the GNU General Public License version 3 (GPLv3).
diff --git a/cdist/conf/type/__config_file/manifest b/cdist/conf/type/__config_file/manifest
new file mode 100755
index 00000000..29add8b7
--- /dev/null
+++ b/cdist/conf/type/__config_file/manifest
@@ -0,0 +1,41 @@
+#!/bin/sh
+#
+# 2015 Steven Armstrong (steven-cdist at armstrong.cc)
+#
+# This file is part of cdist.
+#
+# cdist is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# cdist is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with cdist. If not, see .
+#
+
+set -- "/${__object_id}"
+for param in $(ls "$__object/parameter/"); do
+ case "$param" in
+ source)
+ source="$(cat "$__object/parameter/source")"
+ if [ "$source" = "-" ]; then
+ source="$__object/stdin"
+ fi
+ set -- "$@" --source "$source"
+ ;;
+ owner|group|mode|state)
+ set -- "$@" "--${param}" "$(cat "$__object/parameter/$param")"
+ ;;
+ *)
+ # ignore unknown parameters
+ :
+ ;;
+ esac
+done
+
+__file "$@"
diff --git a/cdist/conf/type/__config_file/parameter/default/state b/cdist/conf/type/__config_file/parameter/default/state
new file mode 100644
index 00000000..e7f6134f
--- /dev/null
+++ b/cdist/conf/type/__config_file/parameter/default/state
@@ -0,0 +1 @@
+present
diff --git a/cdist/conf/type/__config_file/parameter/optional b/cdist/conf/type/__config_file/parameter/optional
new file mode 100644
index 00000000..085c7725
--- /dev/null
+++ b/cdist/conf/type/__config_file/parameter/optional
@@ -0,0 +1,6 @@
+group
+mode
+onchange
+owner
+source
+state
diff --git a/cdist/conf/type/__consul/files/versions/0.4.1/cksum b/cdist/conf/type/__consul/files/versions/0.4.1/cksum
new file mode 100644
index 00000000..edba1a68
--- /dev/null
+++ b/cdist/conf/type/__consul/files/versions/0.4.1/cksum
@@ -0,0 +1 @@
+428915666 15738724 consul
diff --git a/cdist/conf/type/__consul/files/versions/0.4.1/source b/cdist/conf/type/__consul/files/versions/0.4.1/source
new file mode 100644
index 00000000..b1e9908d
--- /dev/null
+++ b/cdist/conf/type/__consul/files/versions/0.4.1/source
@@ -0,0 +1 @@
+https://dl.bintray.com/mitchellh/consul/0.4.1_linux_amd64.zip
diff --git a/cdist/conf/type/__consul/files/versions/0.5.0/cksum b/cdist/conf/type/__consul/files/versions/0.5.0/cksum
new file mode 100644
index 00000000..fe9888ae
--- /dev/null
+++ b/cdist/conf/type/__consul/files/versions/0.5.0/cksum
@@ -0,0 +1 @@
+131560372 17734417 consul
diff --git a/cdist/conf/type/__consul/files/versions/0.5.0/source b/cdist/conf/type/__consul/files/versions/0.5.0/source
new file mode 100644
index 00000000..00a209a5
--- /dev/null
+++ b/cdist/conf/type/__consul/files/versions/0.5.0/source
@@ -0,0 +1 @@
+https://dl.bintray.com/mitchellh/consul/0.5.0_linux_amd64.zip
diff --git a/cdist/conf/type/__consul/files/versions/0.5.1/cksum b/cdist/conf/type/__consul/files/versions/0.5.1/cksum
new file mode 100644
index 00000000..a176ed43
--- /dev/null
+++ b/cdist/conf/type/__consul/files/versions/0.5.1/cksum
@@ -0,0 +1 @@
+2564582176 18232733 consul
diff --git a/cdist/conf/type/__consul/files/versions/0.5.1/source b/cdist/conf/type/__consul/files/versions/0.5.1/source
new file mode 100644
index 00000000..f02a1103
--- /dev/null
+++ b/cdist/conf/type/__consul/files/versions/0.5.1/source
@@ -0,0 +1 @@
+https://dl.bintray.com/mitchellh/consul/0.5.1_linux_amd64.zip
diff --git a/cdist/conf/type/__consul/files/versions/0.5.2/cksum b/cdist/conf/type/__consul/files/versions/0.5.2/cksum
new file mode 100644
index 00000000..1c077266
--- /dev/null
+++ b/cdist/conf/type/__consul/files/versions/0.5.2/cksum
@@ -0,0 +1 @@
+2207534901 18245010 consul
diff --git a/cdist/conf/type/__consul/files/versions/0.5.2/source b/cdist/conf/type/__consul/files/versions/0.5.2/source
new file mode 100644
index 00000000..43b43d55
--- /dev/null
+++ b/cdist/conf/type/__consul/files/versions/0.5.2/source
@@ -0,0 +1 @@
+https://releases.hashicorp.com/consul/0.5.2/consul_0.5.2_linux_amd64.zip
diff --git a/cdist/conf/type/__consul/files/versions/0.6.0/cksum b/cdist/conf/type/__consul/files/versions/0.6.0/cksum
new file mode 100644
index 00000000..bf41a9b8
--- /dev/null
+++ b/cdist/conf/type/__consul/files/versions/0.6.0/cksum
@@ -0,0 +1 @@
+688442448 19798264 consul
diff --git a/cdist/conf/type/__consul/files/versions/0.6.0/source b/cdist/conf/type/__consul/files/versions/0.6.0/source
new file mode 100644
index 00000000..691f2a87
--- /dev/null
+++ b/cdist/conf/type/__consul/files/versions/0.6.0/source
@@ -0,0 +1 @@
+https://releases.hashicorp.com/consul/0.6.0/consul_0.6.0_linux_amd64.zip
diff --git a/cdist/conf/type/__consul/files/versions/0.6.1/cksum b/cdist/conf/type/__consul/files/versions/0.6.1/cksum
new file mode 100644
index 00000000..aa354351
--- /dev/null
+++ b/cdist/conf/type/__consul/files/versions/0.6.1/cksum
@@ -0,0 +1 @@
+3100584780 20416856 consul
diff --git a/cdist/conf/type/__consul/files/versions/0.6.1/source b/cdist/conf/type/__consul/files/versions/0.6.1/source
new file mode 100644
index 00000000..3b20388f
--- /dev/null
+++ b/cdist/conf/type/__consul/files/versions/0.6.1/source
@@ -0,0 +1 @@
+https://releases.hashicorp.com/consul/0.6.1/consul_0.6.1_linux_amd64.zip
diff --git a/cdist/conf/type/__consul/files/versions/0.6.2/cksum b/cdist/conf/type/__consul/files/versions/0.6.2/cksum
new file mode 100644
index 00000000..9c0b35c5
--- /dev/null
+++ b/cdist/conf/type/__consul/files/versions/0.6.2/cksum
@@ -0,0 +1 @@
+2124180907 20416920 consul
diff --git a/cdist/conf/type/__consul/files/versions/0.6.2/source b/cdist/conf/type/__consul/files/versions/0.6.2/source
new file mode 100644
index 00000000..b0c6eeed
--- /dev/null
+++ b/cdist/conf/type/__consul/files/versions/0.6.2/source
@@ -0,0 +1 @@
+https://releases.hashicorp.com/consul/0.6.2/consul_0.6.2_linux_amd64.zip
diff --git a/cdist/conf/type/__consul/files/versions/0.6.3/cksum b/cdist/conf/type/__consul/files/versions/0.6.3/cksum
new file mode 100644
index 00000000..886d01bb
--- /dev/null
+++ b/cdist/conf/type/__consul/files/versions/0.6.3/cksum
@@ -0,0 +1 @@
+1832669072 20417720 consul
diff --git a/cdist/conf/type/__consul/files/versions/0.6.3/source b/cdist/conf/type/__consul/files/versions/0.6.3/source
new file mode 100644
index 00000000..fef668be
--- /dev/null
+++ b/cdist/conf/type/__consul/files/versions/0.6.3/source
@@ -0,0 +1 @@
+https://releases.hashicorp.com/consul/0.6.3/consul_0.6.3_linux_amd64.zip
diff --git a/cdist/conf/type/__consul/files/versions/0.6.4/cksum b/cdist/conf/type/__consul/files/versions/0.6.4/cksum
new file mode 100644
index 00000000..1124b7aa
--- /dev/null
+++ b/cdist/conf/type/__consul/files/versions/0.6.4/cksum
@@ -0,0 +1 @@
+3832641574 23002736 consul
diff --git a/cdist/conf/type/__consul/files/versions/0.6.4/source b/cdist/conf/type/__consul/files/versions/0.6.4/source
new file mode 100644
index 00000000..96879b8d
--- /dev/null
+++ b/cdist/conf/type/__consul/files/versions/0.6.4/source
@@ -0,0 +1 @@
+https://releases.hashicorp.com/consul/0.6.4/consul_0.6.4_linux_amd64.zip
diff --git a/cdist/conf/type/__consul/man.rst b/cdist/conf/type/__consul/man.rst
new file mode 100644
index 00000000..77fae852
--- /dev/null
+++ b/cdist/conf/type/__consul/man.rst
@@ -0,0 +1,51 @@
+cdist-type__consul(7)
+=====================
+Install consul
+
+Steven Armstrong
+
+
+DESCRIPTION
+-----------
+Downloads and installs the consul binary from https://dl.bintray.com/mitchellh/consul.
+Note that the consul binary is downloaded on the server (the machine running
+cdist) and then deployed to the target host using the __file type.
+
+
+REQUIRED PARAMETERS
+-------------------
+None.
+
+
+OPTIONAL PARAMETERS
+-------------------
+state
+ either 'present' or 'absent'. Defaults to 'present'
+
+version
+ which version of consul to install. See ./files/versions for a list of
+ supported versions. Defaults to the latest known version.
+
+
+EXAMPLES
+--------
+
+.. code-block:: sh
+
+ # just install using defaults
+ __consul
+
+ # specific version
+ __consul \
+ --version 0.4.1
+
+
+SEE ALSO
+--------
+- `cdist-type(7) `_
+
+
+COPYING
+-------
+Copyright \(C) 2015 Steven Armstrong. Free use of this software is
+granted under the terms of the GNU General Public License version 3 (GPLv3).
diff --git a/cdist/conf/type/__consul/manifest b/cdist/conf/type/__consul/manifest
new file mode 100755
index 00000000..0187d959
--- /dev/null
+++ b/cdist/conf/type/__consul/manifest
@@ -0,0 +1,55 @@
+#!/bin/sh
+#
+# 2015 Steven Armstrong (steven-cdist at armstrong.cc)
+# 2016 Nico Schottelius (nico-cdist at schottelius.org)
+#
+# This file is part of cdist.
+#
+# cdist is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# cdist is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with cdist. If not, see .
+#
+
+
+os=$(cat "$__global/explorer/os")
+
+case "$os" in
+ centos|redhat|ubuntu|debian|archlinux|gentoo)
+ # any linux should work
+ :
+ ;;
+ *)
+ echo "Your operating system ($os) is currently not supported by this type (${__type##*/})." >&2
+ echo "Please contribute an implementation for it if you can." >&2
+ exit 1
+ ;;
+esac
+
+versions_dir="$__type/files/versions"
+version="$(cat "$__object/parameter/version")"
+version_dir="$versions_dir/$version"
+
+if [ ! -d "$version_dir" ]; then
+ echo "Unknown consul version '$version'. Expected one of:" >&2
+ ls "$versions_dir" >&2
+ exit 1
+fi
+
+__staged_file /usr/local/bin/consul \
+ --source "$(cat "$version_dir/source")" \
+ --cksum "$(cat "$version_dir/cksum")" \
+ --fetch-command 'curl -s -L "%s"' \
+ --prepare-command 'unzip -p "%s"' \
+ --state "$(cat "$__object/parameter/state")" \
+ --group root \
+ --owner root \
+ --mode 755
diff --git a/cdist/conf/type/__consul/parameter/default/state b/cdist/conf/type/__consul/parameter/default/state
new file mode 100644
index 00000000..e7f6134f
--- /dev/null
+++ b/cdist/conf/type/__consul/parameter/default/state
@@ -0,0 +1 @@
+present
diff --git a/cdist/conf/type/__consul/parameter/default/version b/cdist/conf/type/__consul/parameter/default/version
new file mode 100644
index 00000000..d2b13eb6
--- /dev/null
+++ b/cdist/conf/type/__consul/parameter/default/version
@@ -0,0 +1 @@
+0.6.4
diff --git a/cdist/conf/type/__consul/parameter/optional b/cdist/conf/type/__consul/parameter/optional
new file mode 100644
index 00000000..4d595ed7
--- /dev/null
+++ b/cdist/conf/type/__consul/parameter/optional
@@ -0,0 +1,2 @@
+state
+version
diff --git a/cdist/test/cdist_object/fixtures/object/__first/child/.cdist/.keep b/cdist/conf/type/__consul/singleton
similarity index 100%
rename from cdist/test/cdist_object/fixtures/object/__first/child/.cdist/.keep
rename to cdist/conf/type/__consul/singleton
diff --git a/cdist/conf/type/__consul_agent/files/consul-prepare.upstart b/cdist/conf/type/__consul_agent/files/consul-prepare.upstart
new file mode 100644
index 00000000..569220d1
--- /dev/null
+++ b/cdist/conf/type/__consul_agent/files/consul-prepare.upstart
@@ -0,0 +1,9 @@
+start on starting consul
+
+task
+
+script
+ mkdir -p /var/run/consul
+ chown consul:consul /var/run/consul
+ chmod 2770 /var/run/consul
+end script
diff --git a/cdist/conf/type/__consul_agent/files/consul.systemd b/cdist/conf/type/__consul_agent/files/consul.systemd
new file mode 100644
index 00000000..8d5fd323
--- /dev/null
+++ b/cdist/conf/type/__consul_agent/files/consul.systemd
@@ -0,0 +1,22 @@
+[Unit]
+Description=Consul Agent
+Wants=basic.target
+After=basic.target network.target
+
+[Service]
+User=consul
+Group=consul
+Environment="GOMAXPROCS=2"
+# Run ExecStartPre with root-permissions
+PermissionsStartOnly=true
+ExecStartPre=/usr/bin/mkdir -p /var/run/consul
+ExecStartPre=/usr/bin/chown consul:consul /var/run/consul
+ExecStartPre=/usr/bin/chmod 2770 /var/run/consul
+ExecStart=/usr/local/bin/consul agent -config-dir /etc/consul/conf.d
+ExecReload=/bin/kill -HUP $MAINPID
+KillMode=process
+Restart=on-failure
+RestartSec=42s
+
+[Install]
+WantedBy=multi-user.target
diff --git a/cdist/conf/type/__consul_agent/files/consul.sysv-debian b/cdist/conf/type/__consul_agent/files/consul.sysv-debian
new file mode 100644
index 00000000..a75c555d
--- /dev/null
+++ b/cdist/conf/type/__consul_agent/files/consul.sysv-debian
@@ -0,0 +1,81 @@
+#!/bin/sh
+#
+# 2015 Nico Schottelius (nico-cdist at schottelius.org)
+# 2015 Steven Armstrong (steven-cdist at armstrong.cc)
+#
+# This file is part of cdist.
+#
+# cdist is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# cdist is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with cdist. If not, see .
+#
+
+if [ -f "/etc/default/consul" ]; then
+ . /etc/default/consul
+fi
+
+. /lib/lsb/init-functions
+
+NAME=consul
+CONSUL=/usr/local/bin/consul
+CONFIG=/etc/$NAME/conf.d
+PID_FILE=/var/run/$NAME/pidfile
+
+mkdir -p /var/run/$NAME
+chown consul:consul /var/run/$NAME
+chmod 2770 /var/run/$NAME
+
+export PATH="${PATH:+$PATH:}/usr/sbin:/sbin"
+
+case "$1" in
+ start)
+ log_daemon_msg "Starting consul agent" "consul" || true
+ if start-stop-daemon --start --quiet --oknodo \
+ --pidfile "$PID_FILE" --background \
+ --exec $CONSUL -- agent -pid-file="$PID_FILE" -config-dir "$CONFIG"; then
+ log_end_msg 0 || true
+ else
+ log_end_msg 1 || true
+ fi
+ ;;
+
+ stop)
+ log_daemon_msg "Stopping consul agent" "consul" || true
+ if start-stop-daemon --stop --quiet --oknodo --pidfile $PID_FILE; then
+ log_end_msg 0 || true
+ else
+ log_end_msg 1 || true
+ fi
+ ;;
+
+ reload)
+ log_daemon_msg "Reloading consul agent" "consul" || true
+ if start-stop-daemon --stop --signal HUP --quiet --oknodo --pidfile $PID_FILE --exec $CONSUL; then
+ log_end_msg 0 || true
+ else
+ log_end_msg 1 || true
+ fi
+ ;;
+
+ restart)
+ $0 stop && $0 start
+ ;;
+
+ status)
+ status_of_proc -p $PID_FILE $CONSUL consul && exit 0 || exit $?
+ ;;
+
+ *)
+ log_action_msg "Usage: /etc/init.d/consul {start|stop|reload|restart|status}"
+ exit 1
+ ;;
+esac
diff --git a/cdist/conf/type/__consul_agent/files/consul.sysv-redhat b/cdist/conf/type/__consul_agent/files/consul.sysv-redhat
new file mode 100644
index 00000000..13dafd2e
--- /dev/null
+++ b/cdist/conf/type/__consul_agent/files/consul.sysv-redhat
@@ -0,0 +1,95 @@
+#!/bin/bash
+#
+# /etc/rc.d/init.d/consul
+#
+# Daemonize the consul agent.
+#
+# chkconfig: 2345 95 95
+# description: Service discovery and configuration made easy. \
+# Distributed, highly available, and datacenter-aware.
+# processname: consul
+# pidfile: /var/run/consul/pidfile
+
+# Source function library.
+. /etc/init.d/functions
+NAME=consul
+CONSUL=/usr/local/bin/consul
+CONFIG=/etc/$NAME/conf.d
+PID_FILE=/var/run/$NAME/pidfile
+LOG_FILE=/var/log/$NAME
+
+[ -e /etc/sysconfig/$NAME ] && . /etc/sysconfig/$NAME
+export GOMAXPROCS=${GOMAXPROCS:-2}
+
+mkdir -p /var/run/$NAME
+chown consul:consul /var/run/$NAME
+chmod 2770 /var/run/$NAME
+
+
+start() {
+ echo -n "Starting $NAME: "
+ daemon --user=consul \
+ --pidfile="$PID_FILE" \
+ "$CONSUL" agent -pid-file="$PID_FILE" -config-dir "$CONFIG" >> "$LOG_FILE" &
+ retcode=$?
+ touch /var/lock/subsys/$NAME
+ return $retcode
+}
+
+stop() {
+ echo -n "Shutting down $NAME: "
+ killproc -p "$PID_FILE" $NAME
+ retcode=$?
+ rm -f /var/lock/subsys/$NAME
+ return $retcode
+}
+
+case "$1" in
+ start)
+ if $(status -p "$PID_FILE" $NAME >/dev/null); then
+ echo "$NAME already running"
+ else
+ start
+ fi
+ ;;
+ stop)
+ if $(status -p "$PID_FILE" $NAME >/dev/null); then
+ stop
+ else
+ echo "$NAME not running"
+ fi
+ ;;
+ info)
+ "$CONSUL" info
+ ;;
+ status)
+ status -p "$PID_FILE" $NAME
+ exit $?
+ ;;
+ restart)
+ if $(status -p "$PID_FILE" $NAME >/dev/null); then
+ stop
+ fi
+ start
+ ;;
+ reload)
+ if $(status -p "$PID_FILE" $NAME >/dev/null); then
+ kill -HUP `cat $PID_FILE`
+ else
+ echo "$NAME not running"
+ fi
+ ;;
+ condrestart)
+ if [ -f /var/lock/subsys/$NAME ]; then
+ if $(status -p "$PID_FILE" $NAME >/dev/null); then
+ stop
+ fi
+ start
+ fi
+ ;;
+ *)
+ echo "Usage: $NAME {start|stop|status|reload|restart|condrestart|info}"
+ exit 1
+ ;;
+esac
+exit $?
diff --git a/cdist/conf/type/__consul_agent/files/consul.upstart b/cdist/conf/type/__consul_agent/files/consul.upstart
new file mode 100644
index 00000000..ed0c7b8e
--- /dev/null
+++ b/cdist/conf/type/__consul_agent/files/consul.upstart
@@ -0,0 +1,13 @@
+description "Consul Agent"
+start on (local-filesystems and net-device-up IFACE!=lo)
+stop on runlevel [06]
+
+setuid consul
+setgid consul
+
+respawn
+respawn limit 10 10
+kill timeout 10
+
+exec /usr/local/bin/consul agent -config-dir /etc/consul/conf.d
+
diff --git a/cdist/conf/type/__consul_agent/gencode-remote b/cdist/conf/type/__consul_agent/gencode-remote
new file mode 100755
index 00000000..04662967
--- /dev/null
+++ b/cdist/conf/type/__consul_agent/gencode-remote
@@ -0,0 +1,31 @@
+#!/bin/sh
+#
+# 2015 Steven Armstrong (steven-cdist at armstrong.cc)
+#
+# This file is part of cdist.
+#
+# cdist is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# cdist is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with cdist. If not, see .
+#
+
+service="consul"
+state="$(cat "$__object/parameter/state")"
+
+case "$state" in
+ present)
+ :
+ ;;
+ absent)
+ echo "service $service stop || true"
+ ;;
+esac
diff --git a/cdist/conf/type/__consul_agent/man.rst b/cdist/conf/type/__consul_agent/man.rst
new file mode 100644
index 00000000..8285cb25
--- /dev/null
+++ b/cdist/conf/type/__consul_agent/man.rst
@@ -0,0 +1,174 @@
+cdist-type__consul_agent(7)
+===========================
+Manage the consul agent
+
+Steven Armstrong
+
+
+DESCRIPTION
+-----------
+Configure and manage the consul agent.
+
+
+REQUIRED PARAMETERS
+-------------------
+None.
+
+
+OPTIONAL PARAMETERS
+-------------------
+acl-datacenter
+ only used by servers. This designates the datacenter which is authoritative
+ for ACL information.
+
+acl-default-policy
+ either "allow" or "deny"; defaults to "allow". The default policy controls the
+ behavior of a token when there is no matching rule.
+
+acl-down-policy
+ either "allow", "deny" or "extend-cache"; "extend-cache" is the default.
+
+acl-master-token
+ only used for servers in the acl_datacenter. This token will be created with
+ management-level permissions if it does not exist. It allows operators to
+ bootstrap the ACL system with a token ID that is well-known.
+
+acl-token
+ when provided, the agent will use this token when making requests to the
+ Consul servers.
+
+acl-ttl
+ used to control Time-To-Live caching of ACLs.
+
+bind-addr
+ sets the bind address for cluster communication
+
+bootstrap-expect
+ sets server to expect bootstrap mode
+
+ca-file-source
+ path to a PEM encoded certificate authority file which will be uploaded and
+ configure using the ca_file config option.
+
+cert-file-source
+ path to a PEM encoded certificate file which will be uploaded and
+ configure using the cert_file config option.
+
+client-addr
+ sets the address to bind for client access
+
+datacenter
+ datacenter of the agent
+
+encrypt
+ provides the gossip encryption key
+
+group
+ the primary group for the agent
+
+json-config
+ path to a partial json config file without leading { and trailing }.
+ If json-config is '-' (dash), take what was written to stdin as the file content.
+
+key-file-source
+ path to a PEM encoded private key file which will be uploaded and
+ configure using the key_file config option.
+
+node-name
+ name of this node. Must be unique in the cluster
+
+retry-join
+ address to attempt joining every retry_interval until at least one join works.
+ Can be specified multiple times.
+
+user
+ the user to run the agent as
+
+state
+ if the agent is 'present' or 'absent'. Defaults to 'present'.
+ Currently state=absent is not working due to some dependency issues.
+
+
+BOOLEAN PARAMETERS
+------------------
+disable-remote-exec
+ disables support for remote execution. When set to true, the agent will ignore any incoming remote exec requests.
+
+disable-update-check
+ disables automatic checking for security bulletins and new version releases
+
+leave-on-terminate
+ gracefully leave cluster on SIGTERM
+
+rejoin-after-leave
+ rejoin the cluster using the previous state after leaving
+
+server
+ used to control if an agent is in server or client mode
+
+syslog
+ enables logging to syslog
+
+verify-incoming
+ enforce the use of TLS and verify a client's authenticity on incomming connections
+
+verify-outgoing
+ enforce the use of TLS and verify the peers authenticity on outgoing connections
+
+
+EXAMPLES
+--------
+
+.. code-block:: sh
+
+ # configure as server, bootstrap and rejoin
+ hostname="$(cat "$__global/explorer/hostname")"
+ __consul_agent \
+ --datacenter dc1 \
+ --node-name "${hostname%%.*}" \
+ --disable-update-check \
+ --server \
+ --rejoin-after-leave \
+ --bootstrap-expect 3 \
+ --retry-join consul-01 \
+ --retry-join consul-02 \
+ --retry-join consul-03
+
+ # configure as server, bootstrap and rejoin with ssl support
+ hostname="$(cat "$__global/explorer/hostname")"
+ __consul_agent \
+ --datacenter dc1 \
+ --node-name "${hostname%%.*}" \
+ --disable-update-check \
+ --server \
+ --rejoin-after-leave \
+ --bootstrap-expect 3 \
+ --retry-join consul-01 \
+ --retry-join consul-02 \
+ --retry-join consul-03 \
+ --ca-file-source /path/to/ca.pem \
+ --cert-file-source /path/to/cert.pem \
+ --key-file-source /path/to/key.pem \
+ --verify-incoming \
+ --verify-outgoing
+
+ # configure as client and try joining existing cluster
+ __consul_agent \
+ --datacenter dc1 \
+ --node-name "${hostname%%.*}" \
+ --disable-update-check \
+ --retry-join consul-01 \
+ --retry-join consul-02 \
+ --retry-join consul-03
+
+
+SEE ALSO
+--------
+- `cdist-type(7) `_
+- http://www.consul.io/docs/agent/options.html
+
+
+COPYING
+-------
+Copyright \(C) 2015 Steven Armstrong. Free use of this software is
+granted under the terms of the GNU General Public License version 3 (GPLv3).
diff --git a/cdist/conf/type/__consul_agent/manifest b/cdist/conf/type/__consul_agent/manifest
new file mode 100755
index 00000000..b4d1d75c
--- /dev/null
+++ b/cdist/conf/type/__consul_agent/manifest
@@ -0,0 +1,221 @@
+#!/bin/sh
+#
+# 2015 Steven Armstrong (steven-cdist at armstrong.cc)
+# 2015 Nico Schottelius (nico-cdist at schottelius.org)
+#
+# This file is part of cdist.
+#
+# cdist is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# cdist is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with cdist. If not, see .
+#
+
+
+os=$(cat "$__global/explorer/os")
+
+case "$os" in
+ centos|debian|redhat|ubuntu)
+ # whitelist safeguard
+ :
+ ;;
+ *)
+ echo "Your operating system ($os) is currently not supported by this type (${__type##*/})." >&2
+ echo "Please contribute an implementation for it if you can." >&2
+ exit 1
+ ;;
+esac
+
+state="$(cat "$__object/parameter/state")"
+user="$(cat "$__object/parameter/user")"
+group="$(cat "$__object/parameter/group")"
+data_dir="/var/lib/consul"
+conf_dir="/etc/consul/conf.d"
+conf_file="config.json"
+
+# FIXME: there has got to be a better way to handle the dependencies in this case
+case "$state" in
+ present)
+ __group "$group" --system --state "$state"
+ require="__group/$group" \
+ __user "$user" --system --gid "$group" \
+ --home "$data_dir" --state "$state"
+ export require="__user/consul"
+ ;;
+ absent)
+ echo "Sorry, state=absent currently not supported :-(" >&2
+ exit 1
+ require="$__object_name" \
+ __user "$user" --system --gid "$group" --state "$state"
+ require="__user/$user" \
+ __group "$group" --system --state "$state"
+ ;;
+esac
+
+__directory /etc/consul \
+ --owner root --group "$group" --mode 750 --state "$state"
+require="__directory/etc/consul" \
+ __directory "$conf_dir" \
+ --owner root --group "$group" --mode 750 --state "$state"
+
+if [ -f "$__object/parameter/ca-file-source" -o -f "$__object/parameter/cert-file-source" -o -f "$__object/parameter/key-file-source" ]; then
+ # create directory for ssl certs
+ require="__directory/etc/consul" \
+ __directory /etc/consul/ssl \
+ --owner root --group "$group" --mode 750 --state "$state"
+fi
+
+__directory "$data_dir" \
+ --owner "$user" --group "$group" --mode 770 --state "$state"
+
+
+# Generate json config file
+(
+echo "{"
+
+# parameters we define ourself
+printf ' "data_dir": "%s"\n' "$data_dir"
+
+for param in $(ls "$__object/parameter/"); do
+ case "$param" in
+ state|user|group|json-config) continue ;;
+ ca-file-source|cert-file-source|key-file-source)
+ source="$(cat "$__object/parameter/$param")"
+ destination="/etc/consul/ssl/${source##*/}"
+ require="__directory/etc/consul/ssl" \
+ __file "$destination" \
+ --owner root --group consul --mode 640 \
+ --source "$source" \
+ --state "$state"
+ key="$(echo "${param%-*}" | tr '-' '_')"
+ printf ' ,"%s": "%s"\n' "$key" "$destination"
+ ;;
+ disable-remote-exec|disable-update-check|leave-on-terminate|rejoin-after-leave|server|syslog|verify-incoming|verify-outgoing)
+ # handle boolean parameters
+ key="$(echo "$param" | tr '-' '_')"
+ printf ' ,"%s": true\n' "$key"
+ ;;
+ retry-join)
+ # join multiple parameters into json array
+ retry_join="$(awk '{printf "\""$1"\","}' "$__object/parameter/retry-join")"
+ # remove trailing ,
+ printf ' ,"retry_join": [%s]\n' "${retry_join%*,}"
+ ;;
+ retry-join-wan)
+ # join multiple parameters into json array over wan
+ retry_join_wan="$(awk '{printf "\""$1"\","}' "$__object/parameter/retry-join-wan")"
+ # remove trailing ,
+ printf ' ,"retry_join_wan": [%s]\n' "${retry_join_wan%*,}"
+ ;;
+ bootstrap-expect)
+ # integer key=value parameters
+ key="$(echo "$param" | tr '-' '_')"
+ printf ' ,"%s": %s\n' "$key" "$(cat "$__object/parameter/$param")"
+ ;;
+ *)
+ # string key=value parameters
+ key="$(echo "$param" | tr '-' '_')"
+ printf ' ,"%s": "%s"\n' "$key" "$(cat "$__object/parameter/$param")"
+ ;;
+ esac
+done
+if [ -f "$__object/parameter/json-config" ]; then
+ json_config="$(cat "$__object/parameter/json-config")"
+ if [ "$json_config" = "-" ]; then
+ json_config="$__object/stdin"
+ fi
+ # remove leading and trailing whitespace and commas from first and last line
+ # indent each line with 3 spaces for consistency
+ json=$(sed -e 's/^[ \t]*/ /' -e '1s/^[ \t,]*//' -e '$s/[ \t,]*$//' "$json_config")
+ printf ' ,%s\n' "$json"
+fi
+echo "}"
+) | \
+require="__directory${conf_dir}" \
+ __config_file "${conf_dir}/${conf_file}" \
+ --owner root --group "$group" --mode 640 \
+ --state "$state" \
+ --onchange 'service consul status >/dev/null && service consul reload || true' \
+ --source -
+
+init_sysvinit()
+{
+ __file /etc/init.d/consul \
+ --owner root --group root --mode 0755 \
+ --state "$state" \
+ --source "$__type/files/consul.sysv-$1"
+ require="__file/etc/init.d/consul" __start_on_boot consul
+}
+
+init_systemd()
+{
+ __file /lib/systemd/system/consul.service \
+ --owner root --group root --mode 0644 \
+ --state "$state" \
+ --source "$__type/files/consul.systemd"
+ require="__file/lib/systemd/system/consul.service" __start_on_boot consul
+}
+
+init_upstart()
+{
+ __file /etc/init/consul-prepare.conf \
+ --owner root --group root --mode 0644 \
+ --state "$state" \
+ --source "$__type/files/consul-prepare.upstart"
+ require="__file/etc/init/consul-prepare.conf" \
+ __file /etc/init/consul.conf \
+ --owner root --group root --mode 0644 \
+ --state "$state" \
+ --source "$__type/files/consul.upstart"
+ require="__file/etc/init/consul.conf" __start_on_boot consul
+}
+
+# Install init script to start on boot
+case "$os" in
+ centos|redhat)
+ os_version="$(sed 's/[^0-9.]//g' "$__global/explorer/os_version")"
+ major_version="${os_version%%.*}"
+ case "$major_version" in
+ [456])
+ init_sysvinit redhat
+ ;;
+ 7)
+ init_systemd
+ ;;
+ *)
+ echo "Unsupported CentOS/Redhat version: $os_version" >&2
+ exit 1
+ ;;
+ esac
+ ;;
+
+ debian)
+ os_version=$(cat "$__global/explorer/os_version")
+ major_version="${os_version%%.*}"
+
+ case "$major_version" in
+ [567])
+ init_sysvinit debian
+ ;;
+ 8)
+ init_systemd
+ ;;
+ *)
+ echo "Unsupported Debian version $os_version" >&2
+ exit 1
+ ;;
+ esac
+ ;;
+
+ ubuntu)
+ init_upstart
+ ;;
+esac
diff --git a/cdist/conf/type/__consul_agent/parameter/boolean b/cdist/conf/type/__consul_agent/parameter/boolean
new file mode 100644
index 00000000..9efecf49
--- /dev/null
+++ b/cdist/conf/type/__consul_agent/parameter/boolean
@@ -0,0 +1,8 @@
+disable-remote-exec
+disable-update-check
+leave-on-terminate
+rejoin-after-leave
+server
+syslog
+verify-incoming
+verify-outgoing
diff --git a/cdist/conf/type/__consul_agent/parameter/default/group b/cdist/conf/type/__consul_agent/parameter/default/group
new file mode 100644
index 00000000..7d22c92b
--- /dev/null
+++ b/cdist/conf/type/__consul_agent/parameter/default/group
@@ -0,0 +1 @@
+consul
diff --git a/cdist/conf/type/__consul_agent/parameter/default/state b/cdist/conf/type/__consul_agent/parameter/default/state
new file mode 100644
index 00000000..e7f6134f
--- /dev/null
+++ b/cdist/conf/type/__consul_agent/parameter/default/state
@@ -0,0 +1 @@
+present
diff --git a/cdist/conf/type/__consul_agent/parameter/default/user b/cdist/conf/type/__consul_agent/parameter/default/user
new file mode 100644
index 00000000..7d22c92b
--- /dev/null
+++ b/cdist/conf/type/__consul_agent/parameter/default/user
@@ -0,0 +1 @@
+consul
diff --git a/cdist/conf/type/__consul_agent/parameter/optional b/cdist/conf/type/__consul_agent/parameter/optional
new file mode 100644
index 00000000..37aad8c1
--- /dev/null
+++ b/cdist/conf/type/__consul_agent/parameter/optional
@@ -0,0 +1,20 @@
+acl-datacenter
+acl-default-policy
+acl-down-policy
+acl-master-token
+acl-token
+acl-ttl
+bind-addr
+bootstrap-expect
+ca-file-source
+cert-file-source
+client-addr
+datacenter
+encrypt
+group
+json-config
+key-file-source
+node-name
+user
+state
+advertise-wan
diff --git a/cdist/conf/type/__consul_agent/parameter/optional_multiple b/cdist/conf/type/__consul_agent/parameter/optional_multiple
new file mode 100644
index 00000000..740e4d7f
--- /dev/null
+++ b/cdist/conf/type/__consul_agent/parameter/optional_multiple
@@ -0,0 +1,2 @@
+retry-join
+retry-join-wan
diff --git a/cdist/test/cdist_object/fixtures/object/__first/dog/.cdist/.keep b/cdist/conf/type/__consul_agent/singleton
similarity index 100%
rename from cdist/test/cdist_object/fixtures/object/__first/dog/.cdist/.keep
rename to cdist/conf/type/__consul_agent/singleton
diff --git a/cdist/conf/type/__consul_check/man.rst b/cdist/conf/type/__consul_check/man.rst
new file mode 100644
index 00000000..1de65358
--- /dev/null
+++ b/cdist/conf/type/__consul_check/man.rst
@@ -0,0 +1,71 @@
+cdist-type__consul_check(7)
+=============================
+Manages consul checks
+
+Steven Armstrong
+
+
+DESCRIPTION
+-----------
+Generate and deploy check definitions for a consul agent.
+See http://www.consul.io/docs/agent/checks.html for parameter documentation.
+
+Use either script toghether with interval, or use ttl.
+
+
+REQUIRED PARAMETERS
+-------------------
+None.
+
+
+OPTIONAL PARAMETERS
+-------------------
+interval
+ the interval in which the script given with --script should be run
+
+script
+ the shell command to run every --interval
+
+ttl
+ how long a check is considered healthy without being updated through the
+ HTTP interfave
+
+id
+ Defaults to --name
+
+name
+ The name of this check. Defaults to __object_id
+
+notes
+ human readable description
+
+state
+ if this check is 'present' or 'absent'. Defaults to 'present'.
+
+
+EXAMPLES
+--------
+
+.. code-block:: sh
+
+ __consul_check redis \
+ --script /usr/local/bin/check_redis.py \
+ --interval 10s
+
+ __consul_check some-object-id \
+ --id web-app \
+ --name "Web App Status" \
+ --notes "Web app does a curl internally every 10 seconds" \
+ --ttl 30s
+
+
+SEE ALSO
+--------
+- `cdist-type(7) `_
+- `cdist-type__consul_agent(7) `_
+
+
+COPYING
+-------
+Copyright \(C) 2015 Steven Armstrong. Free use of this software is
+granted under the terms of the GNU General Public License version 3 (GPLv3).
diff --git a/cdist/conf/type/__consul_check/manifest b/cdist/conf/type/__consul_check/manifest
new file mode 100755
index 00000000..3004f319
--- /dev/null
+++ b/cdist/conf/type/__consul_check/manifest
@@ -0,0 +1,64 @@
+#!/bin/sh
+#
+# 2015 Steven Armstrong (steven-cdist at armstrong.cc)
+#
+# This file is part of cdist.
+#
+# cdist is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# cdist is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with cdist. If not, see .
+#
+
+name="$(cat "$__object/parameter/name" 2>/dev/null || echo "$__object_id")"
+conf_dir="/etc/consul/conf.d"
+conf_file="check_${name}.json"
+state="$(cat "$__object/parameter/state")"
+
+# Sanity checks
+if [ -f "$__object/parameter/script" -a -f "$__object/parameter/ttl" ]; then
+ echo "Use either --script together with --interval OR --ttl, but not both" >&2
+ exit 1
+fi
+if [ -f "$__object/parameter/script" -a ! -f "$__object/parameter/interval" ]; then
+ echo "When using --script you must also define --interval" >&2
+ exit 1
+fi
+
+# Generate json config file
+(
+echo "{"
+printf ' "check": {\n'
+printf ' "name": "%s"\n' "$name"
+for param in $(ls "$__object/parameter/"); do
+ case "$param" in
+ state|name|interval) continue ;;
+ script)
+ printf ' ,"script": "%s"\n' "$(cat "$__object/parameter/script")"
+ printf ' ,"interval": "%s"\n' "$(cat "$__object/parameter/interval")"
+ ;;
+ *)
+ key="$(echo "$param" | tr '-' '_')"
+ printf ' ,"%s": "%s"\n' "$key" "$(cat "$__object/parameter/$param")"
+ ;;
+ esac
+done
+# end check
+echo " }"
+# end json file
+echo "}"
+) | \
+require="__directory${conf_dir}" \
+ __config_file "${conf_dir}/${conf_file}" \
+ --owner root --group consul --mode 640 \
+ --state "$state" \
+ --onchange 'service consul status >/dev/null && service consul reload || true' \
+ --source -
diff --git a/cdist/conf/type/__consul_check/parameter/default/state b/cdist/conf/type/__consul_check/parameter/default/state
new file mode 100644
index 00000000..e7f6134f
--- /dev/null
+++ b/cdist/conf/type/__consul_check/parameter/default/state
@@ -0,0 +1 @@
+present
diff --git a/cdist/conf/type/__consul_check/parameter/optional b/cdist/conf/type/__consul_check/parameter/optional
new file mode 100644
index 00000000..f6c3a6e4
--- /dev/null
+++ b/cdist/conf/type/__consul_check/parameter/optional
@@ -0,0 +1,7 @@
+id
+interval
+name
+notes
+script
+state
+ttl
diff --git a/cdist/conf/type/__consul_reload/gencode-remote b/cdist/conf/type/__consul_reload/gencode-remote
new file mode 100755
index 00000000..9369db73
--- /dev/null
+++ b/cdist/conf/type/__consul_reload/gencode-remote
@@ -0,0 +1,24 @@
+#!/bin/sh
+#
+# 2015 Steven Armstrong (steven-cdist at armstrong.cc)
+#
+# This file is part of cdist.
+#
+# cdist is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# cdist is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with cdist. If not, see .
+#
+
+service="consul"
+if grep -q "^__file/etc/consul/conf.d/" "$__messages_in"; then
+ echo "service $service status && service $service reload || true"
+fi
diff --git a/cdist/conf/type/__consul_reload/man.rst b/cdist/conf/type/__consul_reload/man.rst
new file mode 100644
index 00000000..f66bb545
--- /dev/null
+++ b/cdist/conf/type/__consul_reload/man.rst
@@ -0,0 +1,39 @@
+cdist-type__consul_reload(7)
+============================
+Reload consul
+
+Steven Armstrong
+
+
+DESCRIPTION
+-----------
+Reload consul after configuration changes.
+
+
+REQUIRED PARAMETERS
+-------------------
+None.
+
+
+OPTIONAL PARAMETERS
+-------------------
+None.
+
+
+EXAMPLES
+--------
+
+.. code-block:: sh
+
+ __consul_reload
+
+
+SEE ALSO
+--------
+- `cdist-type(7) `_
+
+
+COPYING
+-------
+Copyright \(C) 2015 Steven Armstrong. Free use of this software is
+granted under the terms of the GNU General Public License version 3 (GPLv3).
diff --git a/cdist/test/cdist_object/fixtures/object/__first/man/.cdist/.keep b/cdist/conf/type/__consul_reload/singleton
similarity index 100%
rename from cdist/test/cdist_object/fixtures/object/__first/man/.cdist/.keep
rename to cdist/conf/type/__consul_reload/singleton
diff --git a/cdist/conf/type/__consul_service/man.rst b/cdist/conf/type/__consul_service/man.rst
new file mode 100644
index 00000000..9a8efaab
--- /dev/null
+++ b/cdist/conf/type/__consul_service/man.rst
@@ -0,0 +1,75 @@
+cdist-type__consul_service(7)
+=============================
+Manages consul services
+
+Steven Armstrong
+
+
+DESCRIPTION
+-----------
+Generate and deploy service definitions for a consul agent.
+See http://www.consul.io/docs/agent/services.html for parameter documentation.
+
+Use either script together with interval, or use ttl.
+
+
+REQUIRED PARAMETERS
+-------------------
+None.
+
+
+OPTIONAL PARAMETERS
+-------------------
+check-interval
+ the interval in which the script given with --check-script should be run
+
+check-script
+ the shell command to run every --check-interval
+
+check-ttl
+ how long a service is considered healthy without being updated through the
+ HTTP interfave
+
+id
+ Defaults to --name
+
+name
+ The name of this service. Defaults to __object_id
+
+port
+ the port at which this service can be reached
+
+state
+ if this service is 'present' or 'absent'. Defaults to 'present'.
+
+tag
+ a tag to add to this service. Can be specified multiple times.
+
+
+EXAMPLES
+--------
+
+.. code-block:: sh
+
+ __consul_service redis \
+ --tag master \
+ --tag production \
+ --port 8000 \
+ --check-script /usr/local/bin/check_redis.py \
+ --check-interval 10s
+
+ __consul_service webapp \
+ --port 80 \
+ --check-ttl 10s
+
+
+SEE ALSO
+--------
+- `cdist-type(7) `_
+- `cdist-type__consul_agent(7) `_
+
+
+COPYING
+-------
+Copyright \(C) 2015 Steven Armstrong. Free use of this software is
+granted under the terms of the GNU General Public License version 3 (GPLv3).
diff --git a/cdist/conf/type/__consul_service/manifest b/cdist/conf/type/__consul_service/manifest
new file mode 100755
index 00000000..9ba64141
--- /dev/null
+++ b/cdist/conf/type/__consul_service/manifest
@@ -0,0 +1,83 @@
+#!/bin/sh
+#
+# 2015 Steven Armstrong (steven-cdist at armstrong.cc)
+#
+# This file is part of cdist.
+#
+# cdist is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# cdist is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with cdist. If not, see .
+#
+
+name="$(cat "$__object/parameter/name" 2>/dev/null || echo "$__object_id")"
+conf_dir="/etc/consul/conf.d"
+conf_file="service_${name}.json"
+state="$(cat "$__object/parameter/state")"
+
+# Sanity checks
+if [ -f "$__object/parameter/check-script" -a -f "$__object/parameter/check-ttl" ]; then
+ echo "Use either --check-script together with --check-interval OR --check-ttl, but not both" >&2
+ exit 1
+fi
+if [ -f "$__object/parameter/check-script" -a ! -f "$__object/parameter/check-interval" ]; then
+ echo "When using --check-script you must also define --check-interval" >&2
+ exit 1
+fi
+
+# Generate json config file
+(
+echo "{"
+printf ' "service": {\n'
+printf ' "name": "%s"\n' "$name"
+for param in $(ls "$__object/parameter/"); do
+ case "$param" in
+ state|name|check-interval) continue ;;
+ check-script)
+ printf ' ,"check": {\n'
+ printf ' "script": "%s"\n' "$(cat "$__object/parameter/check-script")"
+ printf ' ,"interval": "%s"\n' "$(cat "$__object/parameter/check-interval")"
+ printf ' }\n'
+ ;;
+ check-ttl)
+ printf ' ,"check": {\n'
+ printf ' "ttl": "%s"\n' "$(cat "$__object/parameter/check-ttl")"
+ printf ' }\n'
+ ;;
+ tag)
+ # create json array from newline delimited file
+ tags="$(awk '{printf "\""$1"\","}' "$__object/parameter/tag")"
+ # remove trailing ,
+ printf ' ,"tags": [%s]\n' "${tags%*,}"
+ ;;
+ port)
+ # integer key=value parameters
+ key="$(echo "$param" | tr '-' '_')"
+ printf ' ,"%s": %s\n' "$key" "$(cat "$__object/parameter/$param")"
+ ;;
+ *)
+ # string key=value parameters
+ key="$(echo "$param" | tr '-' '_')"
+ printf ' ,"%s": "%s"\n' "$key" "$(cat "$__object/parameter/$param")"
+ ;;
+ esac
+done
+# end service
+echo " }"
+# end json file
+echo "}"
+) | \
+require="__directory${conf_dir}" \
+ __config_file "${conf_dir}/${conf_file}" \
+ --owner root --group consul --mode 640 \
+ --state "$state" \
+ --onchange 'service consul status >/dev/null && service consul reload || true' \
+ --source -
diff --git a/cdist/conf/type/__consul_service/parameter/default/state b/cdist/conf/type/__consul_service/parameter/default/state
new file mode 100644
index 00000000..e7f6134f
--- /dev/null
+++ b/cdist/conf/type/__consul_service/parameter/default/state
@@ -0,0 +1 @@
+present
diff --git a/cdist/conf/type/__consul_service/parameter/optional b/cdist/conf/type/__consul_service/parameter/optional
new file mode 100644
index 00000000..496e31a3
--- /dev/null
+++ b/cdist/conf/type/__consul_service/parameter/optional
@@ -0,0 +1,7 @@
+check-interval
+check-script
+check-ttl
+id
+name
+port
+state
diff --git a/cdist/conf/type/__consul_service/parameter/optional_multiple b/cdist/conf/type/__consul_service/parameter/optional_multiple
new file mode 100644
index 00000000..42c7c82c
--- /dev/null
+++ b/cdist/conf/type/__consul_service/parameter/optional_multiple
@@ -0,0 +1 @@
+tag
diff --git a/cdist/conf/type/__consul_template/files/consul-template.systemd b/cdist/conf/type/__consul_template/files/consul-template.systemd
new file mode 100644
index 00000000..c67eaab5
--- /dev/null
+++ b/cdist/conf/type/__consul_template/files/consul-template.systemd
@@ -0,0 +1,19 @@
+[Unit]
+Description=Consul-Template Daemon
+Wants=basic.target
+After=basic.target network.target
+
+[Service]
+User=root
+Group=root
+Environment="CONSUL_TEMPLATE_LOG=info"
+Environment="GOMAXPROCS=2"
+ExecStart=/usr/local/bin/consul-template -config /etc/consul-template/conf.d
+ExecReload=/bin/kill -HUP $MAINPID
+KillMode=process
+Restart=on-failure
+RestartSec=10s
+LimitNOFILE=4096
+
+[Install]
+WantedBy=multi-user.target
diff --git a/cdist/conf/type/__consul_template/files/consul-template.sysv b/cdist/conf/type/__consul_template/files/consul-template.sysv
new file mode 100644
index 00000000..0a463020
--- /dev/null
+++ b/cdist/conf/type/__consul_template/files/consul-template.sysv
@@ -0,0 +1,89 @@
+#!/bin/bash
+#
+# /etc/rc.d/init.d/consul-template
+#
+# Daemonize the consul-template agent.
+#
+# chkconfig: 2345 95 95
+# description: Generic template rendering and notifications with Consul
+# processname: consul-template
+# pidfile: /var/run/consul-template/pidfile
+
+# Source function library.
+. /etc/init.d/functions
+NAME=consul-template
+CONSUL_TEMPLATE=/usr/local/bin/consul-template
+CONFIG=/etc/$NAME/conf.d
+PID_FILE=/var/run/$NAME/pidfile
+LOG_FILE=/var/log/$NAME
+
+[ -e /etc/sysconfig/$NAME ] && . /etc/sysconfig/$NAME
+export CONSUL_TEMPLATE_LOG=${CONSUL_TEMPLATE_LOG:-info}
+export GOMAXPROCS=${GOMAXPROCS:-2}
+
+mkdir -p /var/run/$NAME
+
+start() {
+ echo -n "Starting $NAME: "
+ daemon --pidfile="$PID_FILE" \
+ "$CONSUL_TEMPLATE" -config "$CONFIG" >> "$LOG_FILE" 2>&1 &
+ echo $! > "$PID_FILE"
+ retcode=$?
+ touch /var/lock/subsys/$NAME
+ return $retcode
+}
+
+stop() {
+ echo -n "Shutting down $NAME: "
+ killproc -p $PID_FILE $CONSUL_TEMPLATE
+ retcode=$?
+ rm -f /var/lock/subsys/$NAME
+ return $retcode
+}
+
+case "$1" in
+ start)
+ if $(status -p "$PID_FILE" $NAME >/dev/null); then
+ echo "$NAME already running"
+ else
+ start
+ fi
+ ;;
+ stop)
+ if $(status -p "$PID_FILE" $NAME >/dev/null); then
+ stop
+ else
+ echo "$NAME not running"
+ fi
+ ;;
+ status)
+ status -p "$PID_FILE" $NAME
+ exit $?
+ ;;
+ restart)
+ if $(status -p "$PID_FILE" $NAME >/dev/null); then
+ stop
+ fi
+ start
+ ;;
+ reload)
+ if $(status -p "$PID_FILE" $NAME >/dev/null); then
+ kill -HUP `cat $PID_FILE`
+ else
+ echo "$NAME not running"
+ fi
+ ;;
+ condrestart)
+ if [ -f /var/lock/subsys/$NAME ]; then
+ if $(status -p "$PID_FILE" $NAME >/dev/null); then
+ stop
+ fi
+ start
+ fi
+ ;;
+ *)
+ echo "Usage: $NAME {start|stop|status|reload|restart}"
+ exit 1
+ ;;
+esac
+exit $?
diff --git a/cdist/conf/type/__consul_template/files/consul-template.upstart b/cdist/conf/type/__consul_template/files/consul-template.upstart
new file mode 100644
index 00000000..b81a2818
--- /dev/null
+++ b/cdist/conf/type/__consul_template/files/consul-template.upstart
@@ -0,0 +1,12 @@
+description "Consul-Template Daemon"
+start on (local-filesystems and net-device-up IFACE!=lo)
+stop on runlevel [06]
+
+env CONSUL_TEMPLATE_LOG=info
+env GOMAXPROCS=${GOMAXPROCS}
+
+exec /usr/local/bin/consul-template -config /etc/consul-template/conf.d >> /var/log/consul-template 2>&1
+
+respawn
+respawn limit 10 10
+kill timeout 10
diff --git a/cdist/conf/type/__consul_template/files/versions/0.10.0/cksum b/cdist/conf/type/__consul_template/files/versions/0.10.0/cksum
new file mode 100644
index 00000000..bbf394db
--- /dev/null
+++ b/cdist/conf/type/__consul_template/files/versions/0.10.0/cksum
@@ -0,0 +1 @@
+3401777891 9273880 consul-template
diff --git a/cdist/conf/type/__consul_template/files/versions/0.10.0/source b/cdist/conf/type/__consul_template/files/versions/0.10.0/source
new file mode 100644
index 00000000..7fa074b5
--- /dev/null
+++ b/cdist/conf/type/__consul_template/files/versions/0.10.0/source
@@ -0,0 +1 @@
+https://github.com/hashicorp/consul-template/releases/download/v0.10.0/consul-template_0.10.0_linux_amd64.tar.gz
diff --git a/cdist/conf/type/__consul_template/man.rst b/cdist/conf/type/__consul_template/man.rst
new file mode 100644
index 00000000..bcdb94e3
--- /dev/null
+++ b/cdist/conf/type/__consul_template/man.rst
@@ -0,0 +1,134 @@
+cdist-type__consul_template(7)
+==============================
+Manage the consul-template service
+
+Steven Armstrong
+
+
+DESCRIPTION
+-----------
+Downloads and installs the consul-template binary from
+https://github.com/hashicorp/consul-template/releases/download/.
+Generates a global config file and creates directory for per template config files.
+Note that the consul-template binary is downloaded on the server (the machine running
+cdist) and then deployed to the target host using the __file type.
+
+
+REQUIRED PARAMETERS
+-------------------
+None.
+
+
+OPTIONAL PARAMETERS
+-------------------
+auth-username
+ specify a username for basic authentication.
+
+auth-password
+ specify a password for basic authentication.
+
+batch-size
+ the size of the batch when polling multiple dependencies.
+
+consul
+ the location of the Consul instance to query (may be an IP address or FQDN) with port.
+ Defaults to 'localhost:8500'.
+
+log-level
+ The log level for output. This applies to the stdout/stderr logging as well
+ as syslog logging (if enabled). Valid values are "debug", "info", "warn",
+ and "err". The default value is "warn".
+
+max-stale
+ the maximum staleness of a query. If specified, Consul will distribute work among all
+ servers instead of just the leader.
+
+retry
+ the amount of time to wait if Consul returns an error when communicating
+ with the API.
+
+state
+ either 'present' or 'absent'. Defaults to 'present'
+
+ssl-cert
+ Path to an SSL client certificate to use to authenticate to the consul server.
+ Useful if the consul server "verify_incoming" option is set.
+
+ssl-ca-cert
+ Path to a CA certificate file, containing one or more CA certificates to
+ use to validate the certificate sent by the consul server to us. This is a
+ handy alternative to setting --ssl-no-verify if you are using your own CA.
+
+syslog-facility
+ The facility to use when sending to syslog. This requires the use of --syslog.
+ The default value is LOCAL0.
+
+token
+ the Consul API token.
+
+vault-address
+ the location of the Vault instance to query (may be an IP address or FQDN) with port.
+
+vault-token
+ the Vault API token.
+
+vault-ssl-cert
+ Path to an SSL client certificate to use to authenticate to the vault server.
+
+vault-ssl-ca-cert
+ Path to a CA certificate file, containing one or more CA certificates to
+ use to validate the certificate sent by the vault server to us.
+
+version
+ which version of consul-template to install. See ./files/versions for a list of
+ supported versions. Defaults to the latest known version.
+
+wait
+ the minimum(:maximum) to wait before rendering a new template to disk and
+ triggering a command, separated by a colon (:). If the optional maximum
+ value is omitted, it is assumed to be 4x the required minimum value.
+
+
+BOOLEAN PARAMETERS
+------------------
+ssl
+ use HTTPS while talking to Consul. Requires the Consul server to be configured to serve secure connections.
+
+ssl-no-verify
+ ignore certificate warnings. Only used if ssl is enabled.
+
+syslog
+ Send log output to syslog (in addition to stdout and stderr).
+
+vault-ssl
+ use HTTPS while talking to Vault. Requires the Vault server to be configured to serve secure connections.
+
+vault-ssl-no-verify
+ ignore certificate warnings. Only used if vault is enabled.
+
+
+EXAMPLES
+--------
+
+.. code-block:: sh
+
+ __consul_template \
+ --consul consul.service.consul:8500 \
+ --retry 30s
+
+ # specific version
+ __consul_template \
+ --version 0.6.5 \
+ --retry 30s
+
+
+SEE ALSO
+--------
+- `cdist-type(7) `_
+- https://github.com/hashicorp/consul-template
+
+
+COPYING
+-------
+Copyright \(C) 2015 Steven Armstrong. Free use of this software is
+granted under the terms of the GNU General Public License version 3 (GPLv3).
diff --git a/cdist/conf/type/__consul_template/manifest b/cdist/conf/type/__consul_template/manifest
new file mode 100755
index 00000000..cedcb413
--- /dev/null
+++ b/cdist/conf/type/__consul_template/manifest
@@ -0,0 +1,190 @@
+#!/bin/sh
+#
+# 2015 Steven Armstrong (steven-cdist at armstrong.cc)
+#
+# This file is part of cdist.
+#
+# cdist is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# cdist is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with cdist. If not, see .
+#
+
+
+os=$(cat "$__global/explorer/os")
+
+case "$os" in
+ centos|redhat)
+ # whitelist safeguard
+ service_onchange='service consul-template status >/dev/null && service consul-template reload || true' \
+ ;;
+ archlinux)
+ service_onchange="systemctl status consul-template >/dev/null && systemctl reload consul-template || true"
+ ;;
+ *)
+ echo "Your operating system ($os) is currently not supported by this type (${__type##*/})." >&2
+ echo "Please contribute an implementation for it if you can." >&2
+ exit 1
+ ;;
+esac
+
+versions_dir="$__type/files/versions"
+version="$(cat "$__object/parameter/version")"
+version_dir="$versions_dir/$version"
+
+if [ ! -d "$version_dir" ]; then
+ echo "Unknown consul-template version '$version'. Expected one of:" >&2
+ ls "$versions_dir" >&2
+ exit 1
+fi
+
+state="$(cat "$__object/parameter/state")"
+
+__staged_file /usr/local/bin/consul-template \
+ --source "$(cat "$version_dir/source")" \
+ --cksum "$(cat "$version_dir/cksum")" \
+ --fetch-command 'curl -s -L "%s"' \
+ --prepare-command 'tar -xzf "%s"; cat consul-template_*/consul-template' \
+ --state "$state" \
+ --group root \
+ --owner root \
+ --mode 755
+
+
+conf_dir="/etc/consul-template/conf.d"
+conf_file="config.hcl"
+template_dir="/etc/consul-template/template"
+
+__directory /etc/consul-template \
+ --owner root --group root --mode 750
+require="__directory/etc/consul-template" \
+ __directory "$conf_dir" \
+ --owner root --group root --mode 750
+require="__directory/etc/consul-template" \
+ __directory "$template_dir" \
+ --owner root --group root --mode 750
+
+
+# Generate hcl config file
+(
+for param in $(ls "$__object/parameter/"); do
+ case "$param" in
+ auth-password|state|ssl-*|syslog-*|version|vault-token|vault-ssl*) continue ;;
+ auth-username)
+ printf 'auth {\n'
+ printf ' enabled = true\n'
+ printf ' username = "%s"\n' "$(cat "$__object/parameter/auth-username")"
+ if [ -f "$__object/parameter/auth-password" ]; then
+ printf ' password = %s\n' "$(cat "$__object/parameter/auth-password")"
+ fi
+ printf '}\n'
+ ;;
+ ssl)
+ printf 'ssl {\n'
+ printf ' enabled = true\n'
+ if [ -f "$__object/parameter/ssl-no-verify" ]; then
+ printf ' verify = false\n'
+ fi
+ if [ -f "$__object/parameter/ssl-cert" ]; then
+ printf ' cert = "%s"\n' "$(cat "$__object/parameter/ssl-cert")"
+ fi
+ if [ -f "$__object/parameter/ssl-ca-cert" ]; then
+ printf ' ca_cert = "%s"\n' "$(cat "$__object/parameter/ssl-ca-cert")"
+ fi
+ printf '}\n'
+ ;;
+ syslog)
+ printf 'syslog {\n'
+ printf ' enabled = true\n'
+ if [ -f "$__object/parameter/syslog-facility" ]; then
+ printf ' facility = "%s"\n' "$(cat "$__object/parameter/syslog-facility")"
+ fi
+ printf '}\n'
+ ;;
+ vault-address)
+ printf 'vault {\n'
+ printf ' address = "%s"\n' "$(cat "$__object/parameter/vault-address")"
+ if [ -f "$__object/parameter/vault-token" ]; then
+ printf ' token = "%s"\n' "$(cat "$__object/parameter/vault-token")"
+ fi
+ if [ -f "$__object/parameter/vault-ssl" ]; then
+ printf ' ssl {\n'
+ printf ' enabled = true\n'
+ if [ -f "$__object/parameter/vault-ssl-no-verify" ]; then
+ printf ' verify = false\n'
+ fi
+ if [ -f "$__object/parameter/vault-ssl-cert" ]; then
+ printf ' cert = "%s"\n' "$(cat "$__object/parameter/vault-ssl-cert")"
+ fi
+ if [ -f "$__object/parameter/vault-ssl-ca-cert" ]; then
+ printf ' ca_cert = "%s"\n' "$(cat "$__object/parameter/vault-ssl-ca-cert")"
+ fi
+ printf ' }\n'
+ fi
+ printf '}\n'
+ ;;
+ *)
+ # string key=value parameters
+ key="$(echo "$param" | tr '-' '_')"
+ printf '%s = "%s"\n' "$key" "$(cat "$__object/parameter/$param")"
+ ;;
+ esac
+done
+) | \
+require="__directory${conf_dir}" \
+ __config_file "${conf_dir}/${conf_file}" \
+ --owner root --group root --mode 640 \
+ --state "$state" \
+ --onchange "$service_onchange" \
+ --source -
+
+
+# Install init script to start on boot
+service="consul-template"
+case "$os" in
+ centos|redhat)
+ os_version="$(sed 's/[^0-9.]//g' "$__global/explorer/os_version")"
+ major_version="${os_version%%.*}"
+ case "$major_version" in
+ 7)
+ __file "/lib/systemd/system/${service}.service" \
+ --owner root --group root --mode 0555 \
+ --state "$state" \
+ --source "$__type/files/${service}.systemd"
+ export require="__file/lib/systemd/system/${service}.service"
+ ;;
+ *)
+ __file "/etc/init.d/${service}" \
+ --owner root --group root --mode 0555 \
+ --state "$state" \
+ --source "$__type/files/${service}.sysv"
+ export require="__file/etc/init.d/${service}"
+ ;;
+ esac
+ __start_on_boot "$service" --state "$state"
+ ;;
+ ubuntu)
+ __file "/etc/init/${service}.conf" \
+ --owner root --group root --mode 0644 \
+ --state "$state" \
+ --source "$__type/files/${service}.upstart"
+ export require="__file/etc/init/${service}.conf"
+ __start_on_boot "$service" --state "$state"
+ ;;
+ archlinux)
+ __file "/lib/systemd/system/${service}.service" \
+ --owner root --group root --mode 0555 \
+ --state "$state" \
+ --source "$__type/files/${service}.systemd"
+ export require="__file/lib/systemd/system/${service}.service"
+ __start_on_boot "$service" --state "$state"
+ ;;
+esac
diff --git a/cdist/conf/type/__consul_template/notes b/cdist/conf/type/__consul_template/notes
new file mode 100644
index 00000000..fc7cca11
--- /dev/null
+++ b/cdist/conf/type/__consul_template/notes
@@ -0,0 +1,93 @@
+# < 0.7.0
+ssl = true
+ssl_no_verify = true
+
+# >= 0.7.0
+ssl {
+ enabled = true
+ verify = false
+}
+
+# >= 0.9.0
+ssl-cert
+ssl-ca-cert
+
+
+
+--------------------------------------------------------------------------------
+### from docs
+
+
+ssl {
+ enabled = true
+ verify = false
+ cert = "/path/to/client/cert.pem"
+ ca_cert = "/path/to/ca/cert.pem"
+}
+
+
+ssl
+ Use HTTPS while talking to Consul. Requires the Consul server to be configured to serve secure connections. The default value is false.
+
+ssl-verify
+ Verify certificates when connecting via SSL. This requires the use of -ssl. The default value is true.
+
+ssl-cert
+ Path to an SSL client certificate to use to authenticate to the consul server. Useful if the consul server "verify_incoming" option is set.
+
+ssl-ca-cert
+ Path to a CA certificate file, containing one or more CA certificates to use to validate the certificate sent by the consul server to us. This is a handy alternative to setting --ssl-verify=false if you are using your own CA.
+
+--------------------------------------------------------------------------------
+
+### example config file from docs
+
+consul = "127.0.0.1:8500"
+token = "abcd1234" // May also be specified via the envvar CONSUL_TOKEN
+retry = "10s"
+max_stale = "10m"
+log_level = "warn"
+pid_file = "/path/to/pid"
+
+vault {
+ address = "https://vault.service.consul:8200"
+ token = "abcd1234" // May also be specified via the envvar VAULT_TOKEN
+ ssl {
+ enabled = true
+ verify = true
+ cert = "/path/to/client/cert.pem"
+ ca_cert = "/path/to/ca/cert.pem"
+ }
+}
+
+
+--auth-username
+--auth-password
+# if any are given enabled = true
+auth {
+ enabled = true
+ username = "test"
+ password = "test"
+}
+
+ssl {
+ enabled = true
+ verify = false
+ cert = "/path/to/client/cert.pem"
+ ca_cert = "/path/to/ca/cert.pem"
+}
+
+syslog {
+ enabled = true
+ facility = "LOCAL5"
+}
+
+template {
+ source = "/path/on/disk/to/template"
+ destination = "/path/on/disk/where/template/will/render"
+ command = "optional command to run when the template is updated"
+}
+
+template {
+ // Multiple template definitions are supported
+}
diff --git a/cdist/conf/type/__consul_template/parameter/boolean b/cdist/conf/type/__consul_template/parameter/boolean
new file mode 100644
index 00000000..10057e46
--- /dev/null
+++ b/cdist/conf/type/__consul_template/parameter/boolean
@@ -0,0 +1,5 @@
+ssl
+ssl-no-verify
+syslog
+vault-ssl
+vault-ssl-no-verify
diff --git a/cdist/conf/type/__consul_template/parameter/default/consul b/cdist/conf/type/__consul_template/parameter/default/consul
new file mode 100644
index 00000000..42dfa616
--- /dev/null
+++ b/cdist/conf/type/__consul_template/parameter/default/consul
@@ -0,0 +1 @@
+localhost:8500
diff --git a/cdist/conf/type/__consul_template/parameter/default/log-level b/cdist/conf/type/__consul_template/parameter/default/log-level
new file mode 100644
index 00000000..1ef71804
--- /dev/null
+++ b/cdist/conf/type/__consul_template/parameter/default/log-level
@@ -0,0 +1 @@
+warn
diff --git a/cdist/conf/type/__consul_template/parameter/default/state b/cdist/conf/type/__consul_template/parameter/default/state
new file mode 100644
index 00000000..e7f6134f
--- /dev/null
+++ b/cdist/conf/type/__consul_template/parameter/default/state
@@ -0,0 +1 @@
+present
diff --git a/cdist/conf/type/__consul_template/parameter/default/syslog-facility b/cdist/conf/type/__consul_template/parameter/default/syslog-facility
new file mode 100644
index 00000000..f32df182
--- /dev/null
+++ b/cdist/conf/type/__consul_template/parameter/default/syslog-facility
@@ -0,0 +1 @@
+LOCAL0
diff --git a/cdist/conf/type/__consul_template/parameter/default/version b/cdist/conf/type/__consul_template/parameter/default/version
new file mode 100644
index 00000000..78bc1abd
--- /dev/null
+++ b/cdist/conf/type/__consul_template/parameter/default/version
@@ -0,0 +1 @@
+0.10.0
diff --git a/cdist/conf/type/__consul_template/parameter/optional b/cdist/conf/type/__consul_template/parameter/optional
new file mode 100644
index 00000000..8bc528ac
--- /dev/null
+++ b/cdist/conf/type/__consul_template/parameter/optional
@@ -0,0 +1,18 @@
+auth-username
+auth-password
+batch-size
+consul
+log-level
+max-stale
+retry
+state
+ssl-cert
+ssl-ca-cert
+syslog-facility
+token
+vault-address
+vault-token
+vault-ssl-cert
+vault-ssl-ca-cert
+version
+wait
diff --git a/cdist/test/cdist_object/fixtures/object/__first/woman/.cdist/.keep b/cdist/conf/type/__consul_template/singleton
similarity index 100%
rename from cdist/test/cdist_object/fixtures/object/__first/woman/.cdist/.keep
rename to cdist/conf/type/__consul_template/singleton
diff --git a/cdist/conf/type/__consul_template_template/man.rst b/cdist/conf/type/__consul_template_template/man.rst
new file mode 100644
index 00000000..20d0a619
--- /dev/null
+++ b/cdist/conf/type/__consul_template_template/man.rst
@@ -0,0 +1,69 @@
+cdist-type__consul_template_template(7)
+=======================================
+Manage consul-template templates
+
+Steven Armstrong
+
+
+DESCRIPTION
+-----------
+Generate and deploy template definitions for a consul-template.
+See https://github.com/hashicorp/consul-template#examples for documentation.
+Templates are written in the Go template format.
+Either the --source or the --source-file parameter must be given.
+
+
+REQUIRED PARAMETERS
+-------------------
+destination
+ the destination where the generated file should go.
+
+
+OPTIONAL PARAMETERS
+-------------------
+command
+ an optional command to run after rendering the template to its destination.
+
+source
+ path to the template source. Conflicts --source-file.
+
+source-file
+ path to a local file which is uploaded using the __file type and configured
+ as the source.
+ If source is '-' (dash), take what was written to stdin as the file content.
+ Conflicts --source.
+
+state
+ if this template is 'present' or 'absent'. Defaults to 'present'.
+
+
+EXAMPLES
+--------
+
+.. code-block:: sh
+
+ # configure template on the target
+ __consul_template_template nginx \
+ --source /etc/my-consul-templates/nginx.ctmpl \
+ --destination /etc/nginx/nginx.conf \
+ --command 'service nginx restart'
+
+
+ # upload a local file to the target and configure it
+ __consul_template_template nginx \
+ --source-file "$__manifest/files/nginx.ctmpl" \
+ --destination /etc/nginx/nginx.conf \
+ --command 'service nginx restart'
+
+
+SEE ALSO
+--------
+- `cdist-type(7) `_
+- `cdist-type__consul_template(7) `_
+- `cdist-type__consul_template_config(7) `_
+
+
+COPYING
+-------
+Copyright \(C) 2015 Steven Armstrong. Free use of this software is
+granted under the terms of the GNU General Public License version 3 (GPLv3).
diff --git a/cdist/conf/type/__consul_template_template/manifest b/cdist/conf/type/__consul_template_template/manifest
new file mode 100755
index 00000000..c997a2c8
--- /dev/null
+++ b/cdist/conf/type/__consul_template_template/manifest
@@ -0,0 +1,74 @@
+#!/bin/sh
+#
+# 2015 Steven Armstrong (steven-cdist at armstrong.cc)
+#
+# This file is part of cdist.
+#
+# cdist is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# cdist is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with cdist. If not, see .
+#
+
+name="$(cat "$__object/parameter/name" 2>/dev/null || echo "$__object_id")"
+state="$(cat "$__object/parameter/state")"
+conf_dir="/etc/consul-template/conf.d"
+conf_file="template_${name}.hcl"
+template_dir="/etc/consul-template/template"
+require=""
+
+# Sanity checks
+if [ -f "$__object/parameter/source" -a -f "$__object/parameter/source-file" ]; then
+ echo "Use either --source OR --source-file, but not both." >&2
+ exit 1
+fi
+if [ ! -f "$__object/parameter/source" -a ! -f "$__object/parameter/source-file" ]; then
+ echo "Either --source OR --source-file must be given." >&2
+ exit 1
+fi
+
+# Generate hcl config file
+(
+printf 'template {\n'
+for param in $(ls "$__object/parameter/"); do
+ case "$param" in
+ source-file)
+ source="$(cat "$__object/parameter/$param")"
+ if [ "$source" = "-" ]; then
+ source="$__object/stdin"
+ fi
+ destination="${template_dir}/${name}"
+ require="__directory${template_dir}" \
+ __file "$destination" \
+ --owner root --group root --mode 640 \
+ --source "$source" \
+ --state "$state"
+ export require="__file${destination}"
+ printf ' source = "%s"\n' "$destination"
+
+ ;;
+ source|destination|command)
+ printf ' %s = "%s"\n' "$param" "$(cat "$__object/parameter/$param")"
+ ;;
+ *)
+ # ignore unknown parameters
+ :
+ ;;
+ esac
+done
+printf '}\n'
+) | \
+require="$require __directory${conf_dir}" \
+ __config_file "${conf_dir}/${conf_file}" \
+ --owner root --group root --mode 640 \
+ --state "$state" \
+ --onchange 'service consul-template status >/dev/null && service consul-template reload || true' \
+ --source -
diff --git a/cdist/conf/type/__consul_template_template/parameter/default/state b/cdist/conf/type/__consul_template_template/parameter/default/state
new file mode 100644
index 00000000..e7f6134f
--- /dev/null
+++ b/cdist/conf/type/__consul_template_template/parameter/default/state
@@ -0,0 +1 @@
+present
diff --git a/cdist/conf/type/__consul_template_template/parameter/optional b/cdist/conf/type/__consul_template_template/parameter/optional
new file mode 100644
index 00000000..229f6c89
--- /dev/null
+++ b/cdist/conf/type/__consul_template_template/parameter/optional
@@ -0,0 +1,4 @@
+command
+source
+source-file
+state
diff --git a/cdist/conf/type/__consul_template_template/parameter/required b/cdist/conf/type/__consul_template_template/parameter/required
new file mode 100644
index 00000000..ac459b09
--- /dev/null
+++ b/cdist/conf/type/__consul_template_template/parameter/required
@@ -0,0 +1 @@
+destination
diff --git a/cdist/conf/type/__consul_watch_checks/man.rst b/cdist/conf/type/__consul_watch_checks/man.rst
new file mode 100644
index 00000000..c1e8c0a7
--- /dev/null
+++ b/cdist/conf/type/__consul_watch_checks/man.rst
@@ -0,0 +1,65 @@
+cdist-type__consul_watch_checks(7)
+==================================
+Manages consul checks watches
+
+Steven Armstrong
+
+
+DESCRIPTION
+-----------
+Generate and deploy watch definitions of type 'checks' for a consul agent.
+See http://www.consul.io/docs/agent/watches.html for parameter documentation.
+
+
+REQUIRED PARAMETERS
+-------------------
+handler
+ the handler to invoke when the data view updates
+
+
+OPTIONAL PARAMETERS
+-------------------
+datacenter
+ can be provided to override the agent's default datacenter
+
+filter-service
+ filter to a specific service. Conflicts with --filter-state.
+
+filter-state
+ filter to a specific state. Conflicts with --filter-service.
+
+state
+ if this watch is 'present' or 'absent'. Defaults to 'present'.
+
+token
+ can be provided to override the agent's default ACL token
+
+
+EXAMPLES
+--------
+
+.. code-block:: sh
+
+ __consul_watch_checks some-id \
+ --handler /usr/bin/my-handler.sh
+
+ __consul_watch_checks some-id \
+ --filter-service consul \
+ --handler /usr/bin/my-handler.sh
+
+ __consul_watch_checks some-id \
+ --filter-state passing \
+ --handler /usr/bin/my-handler.sh
+
+
+SEE ALSO
+--------
+- `cdist-type(7) `_
+- `cdist-type__consul_agent(7) `_
+- http://www.consul.io/docs/agent/watches.html
+
+
+COPYING
+-------
+Copyright \(C) 2015 Steven Armstrong. Free use of this software is
+granted under the terms of the GNU General Public License version 3 (GPLv3).
diff --git a/cdist/conf/type/__consul_watch_checks/manifest b/cdist/conf/type/__consul_watch_checks/manifest
new file mode 100755
index 00000000..c05ae9eb
--- /dev/null
+++ b/cdist/conf/type/__consul_watch_checks/manifest
@@ -0,0 +1,61 @@
+#!/bin/sh
+#
+# 2015 Steven Armstrong (steven-cdist at armstrong.cc)
+#
+# This file is part of cdist.
+#
+# cdist is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# cdist is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with cdist. If not, see .
+#
+
+cdist_type="${__type##*/}"
+watch_type="${cdist_type##*_}"
+conf_dir="/etc/consul/conf.d"
+conf_file="watch_${watch_type}_${__object_id}.json"
+state="$(cat "$__object/parameter/state")"
+
+# Sanity checks
+if [ -f "$__object/parameter/filter-service" -a -f "$__object/parameter/filter-state" ]; then
+ echo "Use either --filter-service or --filter-state but not both." >&2
+ exit 1
+fi
+
+# Generate json config file
+(
+echo "{"
+printf ' "watches": [{\n'
+printf ' "type": "%s"\n' "$watch_type"
+for param in $(ls "$__object/parameter/"); do
+ case "$param" in
+ state) continue ;;
+ filter-*)
+ key="${param##*-}"
+ printf ' ,"%s": "%s"\n' "$key" "$(cat "$__object/parameter/$param")"
+ ;;
+ *)
+ key="$(echo "$param" | tr '-' '_')"
+ printf ' ,"%s": "%s"\n' "$key" "$(cat "$__object/parameter/$param")"
+ ;;
+ esac
+done
+# end watches
+echo " }]"
+# end json file
+echo "}"
+) | \
+require="__directory${conf_dir}" \
+ __config_file "${conf_dir}/${conf_file}" \
+ --owner root --group consul --mode 640 \
+ --state "$state" \
+ --onchange 'service consul status >/dev/null && service consul reload || true' \
+ --source -
diff --git a/cdist/conf/type/__consul_watch_checks/parameter/default/state b/cdist/conf/type/__consul_watch_checks/parameter/default/state
new file mode 100644
index 00000000..e7f6134f
--- /dev/null
+++ b/cdist/conf/type/__consul_watch_checks/parameter/default/state
@@ -0,0 +1 @@
+present
diff --git a/cdist/conf/type/__consul_watch_checks/parameter/optional b/cdist/conf/type/__consul_watch_checks/parameter/optional
new file mode 100644
index 00000000..d37fd557
--- /dev/null
+++ b/cdist/conf/type/__consul_watch_checks/parameter/optional
@@ -0,0 +1,5 @@
+datacenter
+filter-service
+filter-state
+state
+token
diff --git a/cdist/conf/type/__consul_watch_checks/parameter/required b/cdist/conf/type/__consul_watch_checks/parameter/required
new file mode 100644
index 00000000..64b916c1
--- /dev/null
+++ b/cdist/conf/type/__consul_watch_checks/parameter/required
@@ -0,0 +1 @@
+handler
diff --git a/cdist/conf/type/__consul_watch_event/man.rst b/cdist/conf/type/__consul_watch_event/man.rst
new file mode 100644
index 00000000..ea9bc61a
--- /dev/null
+++ b/cdist/conf/type/__consul_watch_event/man.rst
@@ -0,0 +1,58 @@
+cdist-type__consul_watch_event(7)
+=================================
+Manages consul event watches
+
+Steven Armstrong
+
+
+DESCRIPTION
+-----------
+Generate and deploy watch definitions of type 'event' for a consul agent.
+See http://www.consul.io/docs/agent/watches.html for parameter documentation.
+
+
+REQUIRED PARAMETERS
+-------------------
+handler
+ the handler to invoke when the data view updates
+
+
+OPTIONAL PARAMETERS
+-------------------
+datacenter
+ can be provided to override the agent's default datacenter
+
+name
+ restrict the watch to only events with the given name
+
+state
+ if this watch is 'present' or 'absent'. Defaults to 'present'.
+
+token
+ can be provided to override the agent's default ACL token
+
+
+EXAMPLES
+--------
+
+.. code-block:: sh
+
+ __consul_watch_event some-id \
+ --handler /usr/bin/my-handler.sh
+
+ __consul_watch_event some-id \
+ --name web-deploy \
+ --handler /usr/bin/my-handler.sh
+
+
+SEE ALSO
+--------
+- `cdist-type(7) `_
+- `cdist-type__consul_agent(7) `_
+- http://www.consul.io/docs/agent/watches.html
+
+
+COPYING
+-------
+Copyright \(C) 2015 Steven Armstrong. Free use of this software is
+granted under the terms of the GNU General Public License version 3 (GPLv3).
diff --git a/cdist/conf/type/__consul_watch_event/manifest b/cdist/conf/type/__consul_watch_event/manifest
new file mode 100755
index 00000000..4e36a10d
--- /dev/null
+++ b/cdist/conf/type/__consul_watch_event/manifest
@@ -0,0 +1,51 @@
+#!/bin/sh
+#
+# 2015 Steven Armstrong (steven-cdist at armstrong.cc)
+#
+# This file is part of cdist.
+#
+# cdist is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# cdist is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with cdist. If not, see .
+#
+
+cdist_type="${__type##*/}"
+watch_type="${cdist_type##*_}"
+conf_dir="/etc/consul/conf.d"
+conf_file="watch_${watch_type}_${__object_id}.json"
+state="$(cat "$__object/parameter/state")"
+
+# Generate json config file
+(
+echo "{"
+printf ' "watches": [{\n'
+printf ' "type": "%s"\n' "$watch_type"
+for param in $(ls "$__object/parameter/"); do
+ case "$param" in
+ state) continue ;;
+ *)
+ key="$(echo "$param" | tr '-' '_')"
+ printf ' ,"%s": "%s"\n' "$key" "$(cat "$__object/parameter/$param")"
+ ;;
+ esac
+done
+# end watches
+echo " }]"
+# end json file
+echo "}"
+) | \
+require="__directory${conf_dir}" \
+ __config_file "${conf_dir}/${conf_file}" \
+ --owner root --group consul --mode 640 \
+ --state "$state" \
+ --onchange 'service consul status >/dev/null && service consul reload || true' \
+ --source -
diff --git a/cdist/conf/type/__consul_watch_event/parameter/default/state b/cdist/conf/type/__consul_watch_event/parameter/default/state
new file mode 100644
index 00000000..e7f6134f
--- /dev/null
+++ b/cdist/conf/type/__consul_watch_event/parameter/default/state
@@ -0,0 +1 @@
+present
diff --git a/cdist/conf/type/__consul_watch_event/parameter/optional b/cdist/conf/type/__consul_watch_event/parameter/optional
new file mode 100644
index 00000000..ac808c47
--- /dev/null
+++ b/cdist/conf/type/__consul_watch_event/parameter/optional
@@ -0,0 +1,4 @@
+datacenter
+name
+state
+token
diff --git a/cdist/conf/type/__consul_watch_event/parameter/required b/cdist/conf/type/__consul_watch_event/parameter/required
new file mode 100644
index 00000000..64b916c1
--- /dev/null
+++ b/cdist/conf/type/__consul_watch_event/parameter/required
@@ -0,0 +1 @@
+handler
diff --git a/cdist/conf/type/__consul_watch_key/man.rst b/cdist/conf/type/__consul_watch_key/man.rst
new file mode 100644
index 00000000..90e952b8
--- /dev/null
+++ b/cdist/conf/type/__consul_watch_key/man.rst
@@ -0,0 +1,55 @@
+cdist-type__consul_watch_key(7)
+===============================
+Manages consul key watches
+
+Steven Armstrong
+
+
+DESCRIPTION
+-----------
+Generate and deploy watch definitions of type 'key' for a consul agent.
+See http://www.consul.io/docs/agent/watches.html for parameter documentation.
+
+
+REQUIRED PARAMETERS
+-------------------
+handler
+ the handler to invoke when the data view updates
+
+key
+ the key to watch for changes
+
+
+OPTIONAL PARAMETERS
+-------------------
+datacenter
+ can be provided to override the agent's default datacenter
+
+state
+ if this watch is 'present' or 'absent'. Defaults to 'present'.
+
+token
+ can be provided to override the agent's default ACL token
+
+
+EXAMPLES
+--------
+
+.. code-block:: sh
+
+ __consul_watch_key some-id \
+ --key foo/bar/baz \
+ --handler /usr/bin/my-key-handler.sh
+
+
+SEE ALSO
+--------
+- `cdist-type(7) `_
+- `cdist-type__consul_agent(7) `_
+- http://www.consul.io/docs/agent/watches.html
+
+
+COPYING
+-------
+Copyright \(C) 2015 Steven Armstrong. Free use of this software is
+granted under the terms of the GNU General Public License version 3 (GPLv3).
diff --git a/cdist/conf/type/__consul_watch_key/manifest b/cdist/conf/type/__consul_watch_key/manifest
new file mode 100755
index 00000000..4e36a10d
--- /dev/null
+++ b/cdist/conf/type/__consul_watch_key/manifest
@@ -0,0 +1,51 @@
+#!/bin/sh
+#
+# 2015 Steven Armstrong (steven-cdist at armstrong.cc)
+#
+# This file is part of cdist.
+#
+# cdist is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# cdist is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with cdist. If not, see .
+#
+
+cdist_type="${__type##*/}"
+watch_type="${cdist_type##*_}"
+conf_dir="/etc/consul/conf.d"
+conf_file="watch_${watch_type}_${__object_id}.json"
+state="$(cat "$__object/parameter/state")"
+
+# Generate json config file
+(
+echo "{"
+printf ' "watches": [{\n'
+printf ' "type": "%s"\n' "$watch_type"
+for param in $(ls "$__object/parameter/"); do
+ case "$param" in
+ state) continue ;;
+ *)
+ key="$(echo "$param" | tr '-' '_')"
+ printf ' ,"%s": "%s"\n' "$key" "$(cat "$__object/parameter/$param")"
+ ;;
+ esac
+done
+# end watches
+echo " }]"
+# end json file
+echo "}"
+) | \
+require="__directory${conf_dir}" \
+ __config_file "${conf_dir}/${conf_file}" \
+ --owner root --group consul --mode 640 \
+ --state "$state" \
+ --onchange 'service consul status >/dev/null && service consul reload || true' \
+ --source -
diff --git a/cdist/conf/type/__consul_watch_key/parameter/default/state b/cdist/conf/type/__consul_watch_key/parameter/default/state
new file mode 100644
index 00000000..e7f6134f
--- /dev/null
+++ b/cdist/conf/type/__consul_watch_key/parameter/default/state
@@ -0,0 +1 @@
+present
diff --git a/cdist/conf/type/__consul_watch_key/parameter/optional b/cdist/conf/type/__consul_watch_key/parameter/optional
new file mode 100644
index 00000000..bfce8305
--- /dev/null
+++ b/cdist/conf/type/__consul_watch_key/parameter/optional
@@ -0,0 +1,3 @@
+datacenter
+state
+token
diff --git a/cdist/conf/type/__consul_watch_key/parameter/required b/cdist/conf/type/__consul_watch_key/parameter/required
new file mode 100644
index 00000000..a7ae5b65
--- /dev/null
+++ b/cdist/conf/type/__consul_watch_key/parameter/required
@@ -0,0 +1,2 @@
+handler
+key
diff --git a/cdist/conf/type/__consul_watch_keyprefix/man.rst b/cdist/conf/type/__consul_watch_keyprefix/man.rst
new file mode 100644
index 00000000..8ee5822d
--- /dev/null
+++ b/cdist/conf/type/__consul_watch_keyprefix/man.rst
@@ -0,0 +1,55 @@
+cdist-type__consul_watch_keyprefix(7)
+=====================================
+Manages consul keyprefix watches
+
+Steven Armstrong
+
+
+DESCRIPTION
+-----------
+Generate and deploy watch definitions of type 'keyprefix' for a consul agent.
+See http://www.consul.io/docs/agent/watches.html for parameter documentation.
+
+
+REQUIRED PARAMETERS
+-------------------
+handler
+ the handler to invoke when the data view updates
+
+prefix
+ the prefix of keys to watch for changes
+
+
+OPTIONAL PARAMETERS
+-------------------
+datacenter
+ can be provided to override the agent's default datacenter
+
+state
+ if this watch is 'present' or 'absent'. Defaults to 'present'.
+
+token
+ can be provided to override the agent's default ACL token
+
+
+EXAMPLES
+--------
+
+.. code-block:: sh
+
+ __consul_watch_keyprefix some-id \
+ --prefix foo/ \
+ --handler /usr/bin/my-prefix-handler.sh
+
+
+SEE ALSO
+--------
+- `cdist-type(7) `_
+- `cdist-type__consul_agent(7) `_
+- http://www.consul.io/docs/agent/watches.html
+
+
+COPYING
+-------
+Copyright \(C) 2015 Steven Armstrong. Free use of this software is
+granted under the terms of the GNU General Public License version 3 (GPLv3).
diff --git a/cdist/conf/type/__consul_watch_keyprefix/manifest b/cdist/conf/type/__consul_watch_keyprefix/manifest
new file mode 100755
index 00000000..4e36a10d
--- /dev/null
+++ b/cdist/conf/type/__consul_watch_keyprefix/manifest
@@ -0,0 +1,51 @@
+#!/bin/sh
+#
+# 2015 Steven Armstrong (steven-cdist at armstrong.cc)
+#
+# This file is part of cdist.
+#
+# cdist is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# cdist is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with cdist. If not, see .
+#
+
+cdist_type="${__type##*/}"
+watch_type="${cdist_type##*_}"
+conf_dir="/etc/consul/conf.d"
+conf_file="watch_${watch_type}_${__object_id}.json"
+state="$(cat "$__object/parameter/state")"
+
+# Generate json config file
+(
+echo "{"
+printf ' "watches": [{\n'
+printf ' "type": "%s"\n' "$watch_type"
+for param in $(ls "$__object/parameter/"); do
+ case "$param" in
+ state) continue ;;
+ *)
+ key="$(echo "$param" | tr '-' '_')"
+ printf ' ,"%s": "%s"\n' "$key" "$(cat "$__object/parameter/$param")"
+ ;;
+ esac
+done
+# end watches
+echo " }]"
+# end json file
+echo "}"
+) | \
+require="__directory${conf_dir}" \
+ __config_file "${conf_dir}/${conf_file}" \
+ --owner root --group consul --mode 640 \
+ --state "$state" \
+ --onchange 'service consul status >/dev/null && service consul reload || true' \
+ --source -
diff --git a/cdist/conf/type/__consul_watch_keyprefix/parameter/default/state b/cdist/conf/type/__consul_watch_keyprefix/parameter/default/state
new file mode 100644
index 00000000..e7f6134f
--- /dev/null
+++ b/cdist/conf/type/__consul_watch_keyprefix/parameter/default/state
@@ -0,0 +1 @@
+present
diff --git a/cdist/conf/type/__consul_watch_keyprefix/parameter/optional b/cdist/conf/type/__consul_watch_keyprefix/parameter/optional
new file mode 100644
index 00000000..bfce8305
--- /dev/null
+++ b/cdist/conf/type/__consul_watch_keyprefix/parameter/optional
@@ -0,0 +1,3 @@
+datacenter
+state
+token
diff --git a/cdist/conf/type/__consul_watch_keyprefix/parameter/required b/cdist/conf/type/__consul_watch_keyprefix/parameter/required
new file mode 100644
index 00000000..6223b4de
--- /dev/null
+++ b/cdist/conf/type/__consul_watch_keyprefix/parameter/required
@@ -0,0 +1,2 @@
+handler
+keyprefix
diff --git a/cdist/conf/type/__consul_watch_nodes/man.rst b/cdist/conf/type/__consul_watch_nodes/man.rst
new file mode 100644
index 00000000..b5f0a5ce
--- /dev/null
+++ b/cdist/conf/type/__consul_watch_nodes/man.rst
@@ -0,0 +1,51 @@
+cdist-type__consul_watch_nodes(7)
+=================================
+Manages consul nodes watches
+
+Steven Armstrong
+
+
+DESCRIPTION
+-----------
+Generate and deploy watch definitions of type 'nodes' for a consul agent.
+See http://www.consul.io/docs/agent/watches.html for parameter documentation.
+
+
+REQUIRED PARAMETERS
+-------------------
+handler
+ the handler to invoke when the data view updates
+
+
+OPTIONAL PARAMETERS
+-------------------
+datacenter
+ can be provided to override the agent's default datacenter
+
+state
+ if this watch is 'present' or 'absent'. Defaults to 'present'.
+
+token
+ can be provided to override the agent's default ACL token
+
+
+EXAMPLES
+--------
+
+.. code-block:: sh
+
+ __consul_watch_nodes some-id \
+ --handler /usr/bin/my-key-handler.sh
+
+
+SEE ALSO
+--------
+- `cdist-type(7) `_
+- `cdist-type__consul_agent(7) `_
+- http://www.consul.io/docs/agent/watches.html
+
+
+COPYING
+-------
+Copyright \(C) 2015 Steven Armstrong. Free use of this software is
+granted under the terms of the GNU General Public License version 3 (GPLv3).
diff --git a/cdist/conf/type/__consul_watch_nodes/manifest b/cdist/conf/type/__consul_watch_nodes/manifest
new file mode 100755
index 00000000..4e36a10d
--- /dev/null
+++ b/cdist/conf/type/__consul_watch_nodes/manifest
@@ -0,0 +1,51 @@
+#!/bin/sh
+#
+# 2015 Steven Armstrong (steven-cdist at armstrong.cc)
+#
+# This file is part of cdist.
+#
+# cdist is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# cdist is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with cdist. If not, see .
+#
+
+cdist_type="${__type##*/}"
+watch_type="${cdist_type##*_}"
+conf_dir="/etc/consul/conf.d"
+conf_file="watch_${watch_type}_${__object_id}.json"
+state="$(cat "$__object/parameter/state")"
+
+# Generate json config file
+(
+echo "{"
+printf ' "watches": [{\n'
+printf ' "type": "%s"\n' "$watch_type"
+for param in $(ls "$__object/parameter/"); do
+ case "$param" in
+ state) continue ;;
+ *)
+ key="$(echo "$param" | tr '-' '_')"
+ printf ' ,"%s": "%s"\n' "$key" "$(cat "$__object/parameter/$param")"
+ ;;
+ esac
+done
+# end watches
+echo " }]"
+# end json file
+echo "}"
+) | \
+require="__directory${conf_dir}" \
+ __config_file "${conf_dir}/${conf_file}" \
+ --owner root --group consul --mode 640 \
+ --state "$state" \
+ --onchange 'service consul status >/dev/null && service consul reload || true' \
+ --source -
diff --git a/cdist/conf/type/__consul_watch_nodes/parameter/default/state b/cdist/conf/type/__consul_watch_nodes/parameter/default/state
new file mode 100644
index 00000000..e7f6134f
--- /dev/null
+++ b/cdist/conf/type/__consul_watch_nodes/parameter/default/state
@@ -0,0 +1 @@
+present
diff --git a/cdist/conf/type/__consul_watch_nodes/parameter/optional b/cdist/conf/type/__consul_watch_nodes/parameter/optional
new file mode 100644
index 00000000..bfce8305
--- /dev/null
+++ b/cdist/conf/type/__consul_watch_nodes/parameter/optional
@@ -0,0 +1,3 @@
+datacenter
+state
+token
diff --git a/cdist/conf/type/__consul_watch_nodes/parameter/required b/cdist/conf/type/__consul_watch_nodes/parameter/required
new file mode 100644
index 00000000..64b916c1
--- /dev/null
+++ b/cdist/conf/type/__consul_watch_nodes/parameter/required
@@ -0,0 +1 @@
+handler
diff --git a/cdist/conf/type/__consul_watch_service/man.rst b/cdist/conf/type/__consul_watch_service/man.rst
new file mode 100644
index 00000000..1cc2c00d
--- /dev/null
+++ b/cdist/conf/type/__consul_watch_service/man.rst
@@ -0,0 +1,75 @@
+cdist-type__consul_watch_service(7)
+===================================
+Manages consul service watches
+
+Steven Armstrong
+
+
+DESCRIPTION
+-----------
+Generate and deploy watch definitions of type 'service' for a consul agent.
+See http://www.consul.io/docs/agent/watches.html for parameter documentation.
+
+
+REQUIRED PARAMETERS
+-------------------
+handler
+ the handler to invoke when the data view updates
+
+service
+ the service to watch for changes
+
+
+OPTIONAL PARAMETERS
+-------------------
+datacenter
+ can be provided to override the agent's default datacenter
+
+state
+ if this watch is 'present' or 'absent'. Defaults to 'present'.
+
+token
+ can be provided to override the agent's default ACL token
+
+tag
+ filter by tag
+
+
+BOOLEAN PARAMETERS
+------------------
+passingonly
+ specifies if only hosts passing all checks are displayed
+
+
+EXAMPLES
+--------
+
+.. code-block:: sh
+
+ __consul_watch_service some-id \
+ --service consul \
+ --handler /usr/bin/my-handler.sh
+
+ __consul_watch_service some-id \
+ --service redis \
+ --tag production \
+ --handler /usr/bin/my-handler.sh
+
+ __consul_watch_service some-id \
+ --service redis \
+ --tag production \
+ --passingonly \
+ --handler /usr/bin/my-handler.sh
+
+
+SEE ALSO
+--------
+- `cdist-type(7) `_
+- `cdist-type__consul_agent(7) `_
+- http://www.consul.io/docs/agent/watches.html
+
+
+COPYING
+-------
+Copyright \(C) 2015 Steven Armstrong. Free use of this software is
+granted under the terms of the GNU General Public License version 3 (GPLv3).
diff --git a/cdist/conf/type/__consul_watch_service/manifest b/cdist/conf/type/__consul_watch_service/manifest
new file mode 100755
index 00000000..6011e288
--- /dev/null
+++ b/cdist/conf/type/__consul_watch_service/manifest
@@ -0,0 +1,54 @@
+#!/bin/sh
+#
+# 2015 Steven Armstrong (steven-cdist at armstrong.cc)
+#
+# This file is part of cdist.
+#
+# cdist is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# cdist is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with cdist. If not, see .
+#
+
+cdist_type="${__type##*/}"
+watch_type="${cdist_type##*_}"
+conf_dir="/etc/consul/conf.d"
+conf_file="watch_${watch_type}_${__object_id}.json"
+state="$(cat "$__object/parameter/state")"
+
+# Generate json config file
+(
+echo "{"
+printf ' "watches": [{\n'
+printf ' "type": "%s"\n' "$watch_type"
+for param in $(ls "$__object/parameter/"); do
+ case "$param" in
+ state) continue ;;
+ passingonly)
+ printf ' ,"passingonly": true\n'
+ ;;
+ *)
+ key="$(echo "$param" | tr '-' '_')"
+ printf ' ,"%s": "%s"\n' "$key" "$(cat "$__object/parameter/$param")"
+ ;;
+ esac
+done
+# end watches
+echo " }]"
+# end json file
+echo "}"
+) | \
+require="__directory${conf_dir}" \
+ __config_file "${conf_dir}/${conf_file}" \
+ --owner root --group consul --mode 640 \
+ --state "$state" \
+ --onchange 'service consul status >/dev/null && service consul reload || true' \
+ --source -
diff --git a/cdist/conf/type/__consul_watch_service/parameter/boolean b/cdist/conf/type/__consul_watch_service/parameter/boolean
new file mode 100644
index 00000000..4c1e4b3f
--- /dev/null
+++ b/cdist/conf/type/__consul_watch_service/parameter/boolean
@@ -0,0 +1 @@
+passingonly
diff --git a/cdist/conf/type/__consul_watch_service/parameter/default/state b/cdist/conf/type/__consul_watch_service/parameter/default/state
new file mode 100644
index 00000000..e7f6134f
--- /dev/null
+++ b/cdist/conf/type/__consul_watch_service/parameter/default/state
@@ -0,0 +1 @@
+present
diff --git a/cdist/conf/type/__consul_watch_service/parameter/optional b/cdist/conf/type/__consul_watch_service/parameter/optional
new file mode 100644
index 00000000..a81860ac
--- /dev/null
+++ b/cdist/conf/type/__consul_watch_service/parameter/optional
@@ -0,0 +1,4 @@
+datacenter
+state
+tag
+token
diff --git a/cdist/conf/type/__consul_watch_service/parameter/required b/cdist/conf/type/__consul_watch_service/parameter/required
new file mode 100644
index 00000000..e1ffa4d6
--- /dev/null
+++ b/cdist/conf/type/__consul_watch_service/parameter/required
@@ -0,0 +1,2 @@
+handler
+service
diff --git a/cdist/conf/type/__consul_watch_services/man.rst b/cdist/conf/type/__consul_watch_services/man.rst
new file mode 100644
index 00000000..bf766222
--- /dev/null
+++ b/cdist/conf/type/__consul_watch_services/man.rst
@@ -0,0 +1,51 @@
+cdist-type__consul_watch_services(7)
+====================================
+Manages consul services watches
+
+Steven Armstrong
+
+
+DESCRIPTION
+-----------
+Generate and deploy watch definitions of type 'services' for a consul agent.
+See http://www.consul.io/docs/agent/watches.html for parameter documentation.
+
+
+REQUIRED PARAMETERS
+-------------------
+handler
+ the handler to invoke when the data view updates
+
+
+OPTIONAL PARAMETERS
+-------------------
+datacenter
+ can be provided to override the agent's default datacenter
+
+state
+ if this watch is 'present' or 'absent'. Defaults to 'present'.
+
+token
+ can be provided to override the agent's default ACL token
+
+
+EXAMPLES
+--------
+
+.. code-block:: sh
+
+ __consul_watch_services some-id \
+ --handler /usr/bin/my-key-handler.sh
+
+
+SEE ALSO
+--------
+- `cdist-type(7) `_
+- `cdist-type__consul_agent(7) `_
+- http://www.consul.io/docs/agent/watches.html
+
+
+COPYING
+-------
+Copyright \(C) 2015 Steven Armstrong. Free use of this software is
+granted under the terms of the GNU General Public License version 3 (GPLv3).
diff --git a/cdist/conf/type/__consul_watch_services/manifest b/cdist/conf/type/__consul_watch_services/manifest
new file mode 100755
index 00000000..4e36a10d
--- /dev/null
+++ b/cdist/conf/type/__consul_watch_services/manifest
@@ -0,0 +1,51 @@
+#!/bin/sh
+#
+# 2015 Steven Armstrong (steven-cdist at armstrong.cc)
+#
+# This file is part of cdist.
+#
+# cdist is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# cdist is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with cdist. If not, see .
+#
+
+cdist_type="${__type##*/}"
+watch_type="${cdist_type##*_}"
+conf_dir="/etc/consul/conf.d"
+conf_file="watch_${watch_type}_${__object_id}.json"
+state="$(cat "$__object/parameter/state")"
+
+# Generate json config file
+(
+echo "{"
+printf ' "watches": [{\n'
+printf ' "type": "%s"\n' "$watch_type"
+for param in $(ls "$__object/parameter/"); do
+ case "$param" in
+ state) continue ;;
+ *)
+ key="$(echo "$param" | tr '-' '_')"
+ printf ' ,"%s": "%s"\n' "$key" "$(cat "$__object/parameter/$param")"
+ ;;
+ esac
+done
+# end watches
+echo " }]"
+# end json file
+echo "}"
+) | \
+require="__directory${conf_dir}" \
+ __config_file "${conf_dir}/${conf_file}" \
+ --owner root --group consul --mode 640 \
+ --state "$state" \
+ --onchange 'service consul status >/dev/null && service consul reload || true' \
+ --source -
diff --git a/cdist/conf/type/__consul_watch_services/parameter/default/state b/cdist/conf/type/__consul_watch_services/parameter/default/state
new file mode 100644
index 00000000..e7f6134f
--- /dev/null
+++ b/cdist/conf/type/__consul_watch_services/parameter/default/state
@@ -0,0 +1 @@
+present
diff --git a/cdist/conf/type/__consul_watch_services/parameter/optional b/cdist/conf/type/__consul_watch_services/parameter/optional
new file mode 100644
index 00000000..bfce8305
--- /dev/null
+++ b/cdist/conf/type/__consul_watch_services/parameter/optional
@@ -0,0 +1,3 @@
+datacenter
+state
+token
diff --git a/cdist/conf/type/__consul_watch_services/parameter/required b/cdist/conf/type/__consul_watch_services/parameter/required
new file mode 100644
index 00000000..64b916c1
--- /dev/null
+++ b/cdist/conf/type/__consul_watch_services/parameter/required
@@ -0,0 +1 @@
+handler
diff --git a/cdist/conf/type/__cron/man.text b/cdist/conf/type/__cron/man.rst
similarity index 58%
rename from cdist/conf/type/__cron/man.text
rename to cdist/conf/type/__cron/man.rst
index f4e80a08..353f6bae 100644
--- a/cdist/conf/type/__cron/man.text
+++ b/cdist/conf/type/__cron/man.rst
@@ -1,13 +1,10 @@
cdist-type__cron(7)
===================
+Installs and manages cron jobs
+
Steven Armstrong
-NAME
-----
-cdist-type__cron - installs and manages cron jobs
-
-
DESCRIPTION
-----------
This cdist type allows you to manage entries in a users crontab.
@@ -15,34 +12,34 @@ This cdist type allows you to manage entries in a users crontab.
REQUIRED PARAMETERS
-------------------
-user::
+user
The user who's crontab is edited
-command::
+command
The command to run.
OPTIONAL PARAMETERS
-------------------
-state::
+state
Either present or absent. Defaults to present.
-minute::
+minute
See crontab(5). Defaults to *
-hour::
+hour
See crontab(5). Defaults to *
-day_of_month::
+day_of_month
See crontab(5). Defaults to *
-month::
+month
See crontab(5). Defaults to *
-day_of_week::
+day_of_week
See crontab(5). Defaults to *
-raw::
+raw
Take whatever the user has given instead of time and date fields.
If given, all other time and date fields are ignored.
Can for example be used to specify cron EXTENSIONS like reboot, yearly etc.
See crontab(5) for the extensions if any that your cron implementation
implements.
-raw_command::
- Take whatever the user has given in the commmand and ignore everything else.
+raw_command
+ Take whatever the user has given in the command and ignore everything else.
If given, the command will be added to crontab.
Can for example be used to define variables like SHELL or MAILTO.
@@ -50,27 +47,27 @@ raw_command::
EXAMPLES
--------
---------------------------------------------------------------------------------
-# run Monday to Saturday at 23:15
-__cron some-id --user root --command "/path/to/script" \
- --hour 23 --minute 15 --day_of_week 1-6
+.. code-block:: sh
-# run on reboot
-__cron some-id --user root --command "/path/to/script" \
- --raw @reboot
+ # run Monday to Saturday at 23:15
+ __cron some-id --user root --command "/path/to/script" \
+ --hour 23 --minute 15 --day_of_week 1-6
-# remove cronjob
-__cron some-id --user root --command "/path/to/script" --state absent
+ # run on reboot
+ __cron some-id --user root --command "/path/to/script" \
+ --raw @reboot
-# define default shell
-__cron some-id --user root --raw_command --command "SHELL=/bin/bash" \
- --state present
---------------------------------------------------------------------------------
+ # remove cronjob
+ __cron some-id --user root --command "/path/to/script" --state absent
+
+ # define default shell
+ __cron some-id --user root --raw_command --command "SHELL=/bin/bash" \
+ --state present
SEE ALSO
--------
-- cdist-type(7)
+- `cdist-type(7) `_
- crontab(5)
diff --git a/cdist/conf/type/__debconf_set_selections/man.text b/cdist/conf/type/__debconf_set_selections/man.rst
similarity index 52%
rename from cdist/conf/type/__debconf_set_selections/man.text
rename to cdist/conf/type/__debconf_set_selections/man.rst
index e36ebaa3..37aa65b9 100644
--- a/cdist/conf/type/__debconf_set_selections/man.text
+++ b/cdist/conf/type/__debconf_set_selections/man.rst
@@ -1,13 +1,10 @@
cdist-type__debconf_set_selections(7)
=====================================
+Setup debconf selections
+
Nico Schottelius
-NAME
-----
-cdist-type__debconf_set_selections - Setup debconf selections
-
-
DESCRIPTION
-----------
On Debian and alike systems debconf-set-selections(1) can be used
@@ -16,7 +13,7 @@ to setup configuration parameters.
REQUIRED PARAMETERS
-------------------
-file::
+file
Use the given filename as input for debconf-set-selections(1)
If filename is "-", read from stdin.
@@ -24,23 +21,23 @@ file::
EXAMPLES
--------
---------------------------------------------------------------------------------
-# Setup configuration for nslcd
-__debconf_set_selections nslcd --file /path/to/file
+.. code-block:: sh
-# Setup configuration for nslcd from another type
-__debconf_set_selections nslcd --file "$__type/files/preseed/nslcd"
+ # Setup configuration for nslcd
+ __debconf_set_selections nslcd --file /path/to/file
-__debconf_set_selections nslcd --file - << eof
-gitolite gitolite/gituser string git
-eof
---------------------------------------------------------------------------------
+ # Setup configuration for nslcd from another type
+ __debconf_set_selections nslcd --file "$__type/files/preseed/nslcd"
+
+ __debconf_set_selections nslcd --file - << eof
+ gitolite gitolite/gituser string git
+ eof
SEE ALSO
--------
-- cdist-type(7)
-- cdist-type__update_alternatives(7)
+- `cdist-type(7) `_
+- `cdist-type__update_alternatives(7) `_
- debconf-set-selections(1)
diff --git a/cdist/conf/type/__directory/explorer/stat b/cdist/conf/type/__directory/explorer/stat
index d8cdbb9e..41bc8b04 100755
--- a/cdist/conf/type/__directory/explorer/stat
+++ b/cdist/conf/type/__directory/explorer/stat
@@ -25,7 +25,7 @@ destination="/$__object_id"
os=$("$__explorer/os")
case "$os" in
- "freebsd")
+ "freebsd"|"netbsd"|"openbsd")
# FIXME: should be something like this based on man page, but can not test
stat -f "type: %ST
owner: %Du %Su
@@ -33,6 +33,13 @@ group: %Dg %Sg
mode: %Op %Sp
" "$destination"
;;
+ "macosx")
+ stat -f "type: %HT
+ owner: %Du %Su
+ group: %Dg %Sg
+ mode: %Lp %Sp
+ " "$destination"
+ ;;
*)
stat --printf="type: %F
owner: %u %U
diff --git a/cdist/conf/type/__directory/man.text b/cdist/conf/type/__directory/man.rst
similarity index 53%
rename from cdist/conf/type/__directory/man.text
rename to cdist/conf/type/__directory/man.rst
index a0bf8062..279763a1 100644
--- a/cdist/conf/type/__directory/man.text
+++ b/cdist/conf/type/__directory/man.rst
@@ -1,13 +1,10 @@
cdist-type__directory(7)
========================
+Manage a directory
+
Nico Schottelius
-NAME
-----
-cdist-type__directory - Manage a directory
-
-
DESCRIPTION
-----------
This cdist type allows you to create or remove directories on the target.
@@ -20,80 +17,79 @@ None.
OPTIONAL PARAMETERS
-------------------
-state::
+state
'present' or 'absent', defaults to 'present'
-group::
+group
Group to chgrp to.
-mode::
+mode
Unix permissions, suitable for chmod.
-owner::
+owner
User to chown to.
BOOLEAN PARAMETERS
------------------
-parents::
+parents
Whether to create parents as well (mkdir -p behaviour).
Warning: all intermediate directory permissions default
to whatever mkdir -p does.
Usually this means root:root, 0700.
-recursive::
+recursive
If supplied the chgrp and chown call will run recursively.
This does *not* influence the behaviour of chmod.
MESSAGES
--------
-chgrp ::
+chgrp
Changed group membership
-chown ::
+chown
Changed owner
-chmod ::
+chmod
Changed mode
-create::
+create
Empty directory was created
-remove::
+remove
Directory exists, but state is absent, directory will be removed by generated code.
-remove non directory::
- Someting other than a directory with the same name exists and was removed prior to create.
+remove non directory
+ Something other than a directory with the same name exists and was removed prior to create.
EXAMPLES
--------
---------------------------------------------------------------------------------
-# A silly example
-__directory /tmp/foobar
+.. code-block:: sh
-# Remove a directory
-__directory /tmp/foobar --state absent
+ # A silly example
+ __directory /tmp/foobar
-# Ensure /etc exists correctly
-__directory /etc --owner root --group root --mode 0755
+ # Remove a directory
+ __directory /tmp/foobar --state absent
-# Create nfs service directory, including parents
-__directory /home/services/nfs --parents
+ # Ensure /etc exists correctly
+ __directory /etc --owner root --group root --mode 0755
-# Change permissions recursively
-__directory /home/services --recursive --owner root --group root
+ # Create nfs service directory, including parents
+ __directory /home/services/nfs --parents
-# Setup a temp directory
-__directory /local --mode 1777
+ # Change permissions recursively
+ __directory /home/services --recursive --owner root --group root
-# Take it all
-__directory /home/services/kvm --recursive --parents \
- --owner root --group root --mode 0755 --state present
+ # Setup a temp directory
+ __directory /local --mode 1777
---------------------------------------------------------------------------------
+ # Take it all
+ __directory /home/services/kvm --recursive --parents \
+ --owner root --group root --mode 0755 --state present
SEE ALSO
--------
-- cdist-type(7)
+- `cdist-type(7) `_
COPYING
diff --git a/cdist/conf/type/__dog_vdi/man.text b/cdist/conf/type/__dog_vdi/man.rst
similarity index 50%
rename from cdist/conf/type/__dog_vdi/man.text
rename to cdist/conf/type/__dog_vdi/man.rst
index e3453ba7..3e6155a6 100644
--- a/cdist/conf/type/__dog_vdi/man.text
+++ b/cdist/conf/type/__dog_vdi/man.rst
@@ -1,13 +1,10 @@
cdist-type__dog_vdi(7)
======================
+Manage Sheepdog VM images
+
Nico Schottelius
-NAME
-----
-cdist-type__dog_vdi - Manage Sheepdog VM images
-
-
DESCRIPTION
-----------
The dog program is used to create images for sheepdog
@@ -16,9 +13,9 @@ to be used in qemu.
OPTIONAL PARAMETERS
-------------------
-state::
+state
Either "present" or "absent", defaults to "present"
-size::
+size
Size of the image in "dog vdi" compatible units.
Required if state is "present".
@@ -28,24 +25,24 @@ size::
EXAMPLES
--------
---------------------------------------------------------------------------------
-# Create a 50G size image
-__dog_vdi nico-privat.sky.ungleich.ch --size 50G
+.. code-block:: sh
-# Create a 50G size image (more explicit)
-__dog_vdi nico-privat.sky.ungleich.ch --size 50G --state present
+ # Create a 50G size image
+ __dog_vdi nico-privat.sky.ungleich.ch --size 50G
-# Remove image
-__dog_vdi nico-privat.sky.ungleich.ch --state absent
+ # Create a 50G size image (more explicit)
+ __dog_vdi nico-privat.sky.ungleich.ch --size 50G --state present
-# Remove image - keeping --size is ok
-__dog_vdi nico-privat.sky.ungleich.ch --size 50G --state absent
---------------------------------------------------------------------------------
+ # Remove image
+ __dog_vdi nico-privat.sky.ungleich.ch --state absent
+
+ # Remove image - keeping --size is ok
+ __dog_vdi nico-privat.sky.ungleich.ch --size 50G --state absent
SEE ALSO
--------
-- cdist-type(7)
+- `cdist-type(7) `_
- dog(8)
- qemu(1)
diff --git a/cdist/conf/type/__file/explorer/stat b/cdist/conf/type/__file/explorer/stat
index 52570379..8a917556 100755
--- a/cdist/conf/type/__file/explorer/stat
+++ b/cdist/conf/type/__file/explorer/stat
@@ -25,7 +25,7 @@ destination="/$__object_id"
os=$("$__explorer/os")
case "$os" in
- "freebsd"|"openbsd")
+ "freebsd"|"netbsd"|"openbsd")
# FIXME: should be something like this based on man page, but can not test
stat -f "type: %ST
owner: %Du %Su
@@ -33,6 +33,15 @@ group: %Dg %Sg
mode: %Op %Sp
size: %Dz
links: %Dl
+" "$destination"
+ ;;
+ "macosx")
+ stat -f "type: %HT
+owner: %Du %Su
+group: %Dg %Sg
+mode: %Lp %Sp
+size: %Dz
+links: %Dl
" "$destination"
;;
*)
diff --git a/cdist/conf/type/__file/gencode-local b/cdist/conf/type/__file/gencode-local
index 601705c8..ed7482cb 100755
--- a/cdist/conf/type/__file/gencode-local
+++ b/cdist/conf/type/__file/gencode-local
@@ -67,7 +67,7 @@ DONE
if [ "$upload_file" ]; then
echo upload >> "$__messages_out"
cat << DONE
-$__remote_copy $source ${__target_host}:\$destination_upload
+$__remote_copy "$source" "${__target_host}:\$destination_upload"
DONE
fi
# move uploaded file into place
diff --git a/cdist/conf/type/__file/man.rst b/cdist/conf/type/__file/man.rst
new file mode 100644
index 00000000..73336581
--- /dev/null
+++ b/cdist/conf/type/__file/man.rst
@@ -0,0 +1,109 @@
+cdist-type__file(7)
+===================
+Manage files.
+
+Nico Schottelius
+
+
+DESCRIPTION
+-----------
+This cdist type allows you to create files, remove files and set file
+attributes on the target.
+
+If the file already exists on the target, then if it is a:
+
+regular file, and state is:
+ present
+ replace it with the source file if they are not equal
+ exists
+ do nothing
+symlink
+ replace it with the source file
+directory
+ replace it with the source file
+
+In any case, make sure that the file attributes are as specified.
+
+
+REQUIRED PARAMETERS
+-------------------
+None.
+
+OPTIONAL PARAMETERS
+-------------------
+state
+ 'present', 'absent' or 'exists', defaults to 'present' where:
+
+ present
+ the file is exactly the one from source
+ absent
+ the file does not exist
+ exists
+ the file from source but only if it doesn't already exist
+
+group
+ Group to chgrp to.
+
+mode
+ Unix permissions, suitable for chmod.
+
+owner
+ User to chown to.
+
+source
+ If supplied, copy this file from the host running cdist to the target.
+ If not supplied, an empty file or directory will be created.
+ If source is '-' (dash), take what was written to stdin as the file content.
+
+MESSAGES
+--------
+chgrp
+ Changed group membership
+chown
+ Changed owner
+chmod
+ Changed mode
+create
+ Empty file was created (no --source specified)
+remove
+ File exists, but state is absent, file will be removed by generated code.
+upload
+ File was uploaded
+
+
+EXAMPLES
+--------
+
+.. code-block:: sh
+
+ # Create /etc/cdist-configured as an empty file
+ __file /etc/cdist-configured
+ # The same thing
+ __file /etc/cdist-configured --state present
+ # Use __file from another type
+ __file /etc/issue --source "$__type/files/archlinux" --state present
+ # Delete existing file
+ __file /etc/cdist-configured --state absent
+ # Supply some more settings
+ __file /etc/shadow --source "$__type/files/shadow" \
+ --owner root --group shadow --mode 0640 \
+ --state present
+ # Provide a default file, but let the user change it
+ __file /home/frodo/.bashrc --source "/etc/skel/.bashrc" \
+ --state exists \
+ --owner frodo --mode 0600
+ # Take file content from stdin
+ __file /tmp/whatever --owner root --group root --mode 644 --source - << DONE
+ Here goes the content for /tmp/whatever
+ DONE
+
+
+SEE ALSO
+--------
+* `cdist-type(7) `_
+
+
+COPYING
+-------
+Copyright \(C) 2011-2013 Nico Schottelius. Free use of this software is
+granted under the terms of the GNU General Public License version 3 (GPLv3).
diff --git a/cdist/conf/type/__file/man.text b/cdist/conf/type/__file/man.text
deleted file mode 100644
index a582b27b..00000000
--- a/cdist/conf/type/__file/man.text
+++ /dev/null
@@ -1,109 +0,0 @@
-cdist-type__file(7)
-===================
-Nico Schottelius
-
-
-NAME
-----
-cdist-type__file - Manage files
-
-
-DESCRIPTION
------------
-This cdist type allows you to create files, remove files and set file
-attributes on the target.
-
-If the file already exists on the target, then if it is a:
-- regular file, and state is:
- present: replace it with the source file if they are not equal
- exists: do nothing
-- symlink: replace it with the source file
-- directory: replace it with the source file
-
-In any case, make sure that the file attributes are as specified.
-
-
-REQUIRED PARAMETERS
--------------------
-None.
-
-OPTIONAL PARAMETERS
--------------------
-state::
- 'present', 'absent' or 'exists', defaults to 'present'
- where:
- present: the file is exactly the one from source
- absent: the file does not exist
- exists: the file from source but only if it doesn't already exist
-
-group::
- Group to chgrp to.
-
-mode::
- Unix permissions, suitable for chmod.
-
-owner::
- User to chown to.
-
-source::
- If supplied, copy this file from the host running cdist to the target.
- If not supplied, an empty file or directory will be created.
- If source is '-' (dash), take what was written to stdin as the file content.
-
-MESSAGES
---------
-chgrp ::
- Changed group membership
-chown ::
- Changed owner
-chmod ::
- Changed mode
-create::
- Empty file was created (no --source specified)
-remove::
- File exists, but state is absent, file will be removed by generated code.
-upload::
- File was uploaded
-
-
-EXAMPLES
---------
-
---------------------------------------------------------------------------------
-# Create /etc/cdist-configured as an empty file
-__file /etc/cdist-configured
-# The same thing
-__file /etc/cdist-configured --state present
-# Delete existing file
-__file /etc/cdist-configured --state absent
-
-# Use __file from another type
-__file /etc/issue --source "$__type/files/archlinux" --state present
-
-# Supply some more settings
-__file /etc/shadow --source "$__type/files/shadow" \
- --owner root --group shadow --mode 0640 \
- --state present
-
-# Provide a default file, but let the user change it
-__file /home/frodo/.bashrc --source "/etc/skel/.bashrc" \
- --state exists \
- --owner frodo --mode 0600
-
-# Take file content from stdin
-__file /tmp/whatever --owner root --group root --mode 644 --source - << DONE
-Here goes the content for /tmp/whatever
-DONE
-
---------------------------------------------------------------------------------
-
-
-SEE ALSO
---------
-- cdist-type(7)
-
-
-COPYING
--------
-Copyright \(C) 2011-2013 Nico Schottelius. Free use of this software is
-granted under the terms of the GNU General Public License version 3 (GPLv3).
diff --git a/cdist/conf/type/__firewalld_rule/explorer/rule b/cdist/conf/type/__firewalld_rule/explorer/rule
new file mode 100644
index 00000000..5a0e0265
--- /dev/null
+++ b/cdist/conf/type/__firewalld_rule/explorer/rule
@@ -0,0 +1,32 @@
+#!/bin/sh
+#
+# 2015 Nico Schottelius (nico-cdist at schottelius.org)
+#
+# This file is part of cdist.
+#
+# cdist is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# cdist is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with cdist. If not, see .
+#
+#
+
+protocol="$(cat "$__object/parameter/protocol")"
+table="$(cat "$__object/parameter/table")"
+chain="$(cat "$__object/parameter/chain")"
+priority="$(cat "$__object/parameter/priority")"
+rule="$(cat "$__object/parameter/rule")"
+
+if firewall-cmd --permanent --direct --query-rule "$protocol" "$table" "$chain" "$priority" $rule >/dev/null; then
+ echo present
+else
+ echo absent
+fi
diff --git a/cdist/conf/type/__firewalld_rule/gencode-remote b/cdist/conf/type/__firewalld_rule/gencode-remote
new file mode 100644
index 00000000..8f1ba28a
--- /dev/null
+++ b/cdist/conf/type/__firewalld_rule/gencode-remote
@@ -0,0 +1,48 @@
+#!/bin/sh
+#
+# 2015 Nico Schottelius (nico-cdist at schottelius.org)
+#
+# This file is part of cdist.
+#
+# cdist is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# cdist is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with cdist. If not, see .
+#
+#
+
+name="$__object_id"
+state_should="$(cat "$__object/parameter/state")"
+state_is="$(cat "$__object/explorer/rule")"
+
+[ "$state_is" = "$state_should" ] && exit 0
+
+protocol="$(cat "$__object/parameter/protocol")"
+table="$(cat "$__object/parameter/table")"
+chain="$(cat "$__object/parameter/chain")"
+priority="$(cat "$__object/parameter/priority")"
+rule="$(cat "$__object/parameter/rule")"
+
+case "$state_should" in
+ present)
+ echo firewall-cmd --quiet --permanent --direct --add-rule \"$protocol\" \"$table\" \"$chain\" \"$priority\" $rule
+ echo firewall-cmd --quiet --direct --add-rule \"$protocol\" \"$table\" \"$chain\" \"$priority\" $rule
+ ;;
+
+ absent)
+ echo firewall-cmd --quiet --permanent --direct --remove-rule \"$protocol\" \"$table\" \"$chain\" \"$priority\" $rule
+ echo firewall-cmd --quiet --direct --remove-rule \"$protocol\" \"$table\" \"$chain\" \"$priority\" $rule
+ ;;
+ *)
+ echo "Unknown state $state_should" >&2
+ exit 1
+ ;;
+esac
diff --git a/cdist/conf/type/__firewalld_rule/man.rst b/cdist/conf/type/__firewalld_rule/man.rst
new file mode 100644
index 00000000..d953b3d2
--- /dev/null
+++ b/cdist/conf/type/__firewalld_rule/man.rst
@@ -0,0 +1,75 @@
+cdist-type__firewalld_rule(7)
+=============================
+Configure firewalld rules
+
+Nico Schottelius
+
+
+DESCRIPTION
+-----------
+This cdist type allows you to manage rules in firewalld
+using the *direct* way (i.e. no zone support).
+
+
+REQUIRED PARAMETERS
+-------------------
+rule
+ The rule to apply. Essentially an firewalld command
+ line without firewalld in front of it.
+protocol
+ Either ipv4, ipv4 or eb. See firewall-cmd(1)
+table
+ The table to use (like filter or nat). See firewall-cmd(1).
+chain
+ The chain to use (like INPUT_direct or FORWARD_direct). See firewall-cmd(1).
+priority
+ The priority to use (0 is topmost). See firewall-cmd(1).
+
+
+OPTIONAL PARAMETERS
+-------------------
+state
+ 'present' or 'absent', defaults to 'present'
+
+
+EXAMPLES
+--------
+
+.. code-block:: sh
+
+ # Allow acces from entrance.place4.ungleich.ch
+ __firewalld_rule entrance \
+ --protocol ipv4 \
+ --table filter \
+ --chain INPUT_direct \
+ --priority 0 \
+ --rule '-s entrance.place4.ungleich.ch -j ACCEPT'
+
+ # Allow forwarding of traffic from br0
+ __firewalld_rule vm-forward --protocol ipv4 \
+ --table filter \
+ --chain FORWARD_direct \
+ --priority 0 \
+ --rule '-i br0 -j ACCEPT'
+
+ # Ensure old rule is absent - warning, the rule part must stay the same!
+ __firewalld_rule vm-forward
+ --protocol ipv4 \
+ --table filter \
+ --chain FORWARD_direct \
+ --priority 0 \
+ --rule '-i br0 -j ACCEPT' \
+ --state absent
+
+
+SEE ALSO
+--------
+- `cdist-type(7) `_
+- `cdist-type__iptables_rule(7) `_
+- firewalld(8)
+
+
+COPYING
+-------
+Copyright \(C) 2015 Nico Schottelius. Free use of this software is
+granted under the terms of the GNU General Public License version 3 (GPLv3).
diff --git a/cdist/conf/type/__firewalld_rule/manifest b/cdist/conf/type/__firewalld_rule/manifest
new file mode 100644
index 00000000..5baf6da3
--- /dev/null
+++ b/cdist/conf/type/__firewalld_rule/manifest
@@ -0,0 +1,23 @@
+#!/bin/sh
+#
+# 2015 David Hürlimann (david at ungleich.ch)
+#
+# This file is part of cdist.
+#
+# cdist is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# cdist is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with cdist. If not, see .
+#
+#
+# This type allows to configure the desired localtime timezone.
+
+__package firewalld
diff --git a/cdist/conf/type/__firewalld_rule/parameter/default/state b/cdist/conf/type/__firewalld_rule/parameter/default/state
new file mode 100644
index 00000000..e7f6134f
--- /dev/null
+++ b/cdist/conf/type/__firewalld_rule/parameter/default/state
@@ -0,0 +1 @@
+present
diff --git a/cdist/conf/type/__firewalld_rule/parameter/optional b/cdist/conf/type/__firewalld_rule/parameter/optional
new file mode 100644
index 00000000..ff72b5c7
--- /dev/null
+++ b/cdist/conf/type/__firewalld_rule/parameter/optional
@@ -0,0 +1 @@
+state
diff --git a/cdist/conf/type/__firewalld_rule/parameter/required b/cdist/conf/type/__firewalld_rule/parameter/required
new file mode 100644
index 00000000..58def7e4
--- /dev/null
+++ b/cdist/conf/type/__firewalld_rule/parameter/required
@@ -0,0 +1,5 @@
+chain
+priority
+protocol
+rule
+table
diff --git a/cdist/conf/type/__git/man.text b/cdist/conf/type/__git/man.rst
similarity index 60%
rename from cdist/conf/type/__git/man.text
rename to cdist/conf/type/__git/man.rst
index 5f74108b..75f6e48b 100644
--- a/cdist/conf/type/__git/man.text
+++ b/cdist/conf/type/__git/man.rst
@@ -1,13 +1,10 @@
cdist-type__git(7)
==================
+Get and or keep git repositories up-to-date
+
Nico Schottelius
-NAME
-----
-cdist-type__git - Get and or keep git repositories up-to-date
-
-
DESCRIPTION
-----------
This cdist type allows you to clone git repositories
@@ -15,43 +12,43 @@ This cdist type allows you to clone git repositories
REQUIRED PARAMETERS
-------------------
-source::
+source
Specifies the git remote to clone from
OPTIONAL PARAMETERS
-------------------
-state::
+state
Either "present" or "absent", defaults to "present"
-branch::
+branch
Create this branch by checking out the remote branch of this name
Default branch is "master"
-group::
+group
Group to chgrp to.
-mode::
+mode
Unix permissions, suitable for chmod.
-owner::
+owner
User to chown to.
EXAMPLES
--------
---------------------------------------------------------------------------------
-__git /home/services/dokuwiki --source git://github.com/splitbrain/dokuwiki.git
+.. code-block:: sh
-# Checkout cdist, stay on branch 2.1
-__git /home/nico/cdist --source git://github.com/telmich/cdist.git --branch 2.1
---------------------------------------------------------------------------------
+ __git /home/services/dokuwiki --source git://github.com/splitbrain/dokuwiki.git
+
+ # Checkout cdist, stay on branch 2.1
+ __git /home/nico/cdist --source git://github.com/telmich/cdist.git --branch 2.1
SEE ALSO
--------
-- cdist-type(7)
+- `cdist-type(7) `_
COPYING
diff --git a/cdist/conf/type/__group/TODO b/cdist/conf/type/__group/TODO
deleted file mode 100644
index c20a5d21..00000000
--- a/cdist/conf/type/__group/TODO
+++ /dev/null
@@ -1,2 +0,0 @@
-- delete groups
-
diff --git a/cdist/conf/type/__group/explorer/group b/cdist/conf/type/__group/explorer/group
index 4c1e6ac0..07f73a91 100755
--- a/cdist/conf/type/__group/explorer/group
+++ b/cdist/conf/type/__group/explorer/group
@@ -1,6 +1,6 @@
#!/bin/sh
#
-# 2011 Steven Armstrong (steven-cdist at armstrong.cc)
+# 2011-2015 Steven Armstrong (steven-cdist at armstrong.cc)
#
# This file is part of cdist.
#
diff --git a/cdist/conf/type/__group/explorer/gshadow b/cdist/conf/type/__group/explorer/gshadow
index 5ab4ed80..2e2ab29d 100755
--- a/cdist/conf/type/__group/explorer/gshadow
+++ b/cdist/conf/type/__group/explorer/gshadow
@@ -1,6 +1,6 @@
#!/bin/sh
#
-# 2011 Steven Armstrong (steven-cdist at armstrong.cc)
+# 2011-2015 Steven Armstrong (steven-cdist at armstrong.cc)
#
# This file is part of cdist.
#
@@ -22,21 +22,13 @@
#
name=$__object_id
-os_version="$($__explorer/os_version)"
os="$($__explorer/os)"
-if [ "$os" = "freebsd" ]; then
- echo "FreeBSD does not have getent gshadow"
- exit 0
-fi
-
-case "$os_version" in
- "Red Hat Enterprise Linux Server release "[45]*|"CentOS release "[45]*)
- # TODO: find a way to get this information
- echo "$os_version does not have getent gshadow"
- ;;
- *)
- getent gshadow "$name" || true
- ;;
+case "$os" in
+ "freebsd"|"netbsd")
+ echo "$os does not have getent gshadow"
+ exit 0
+ ;;
esac
+getent gshadow "$name" || true
diff --git a/cdist/conf/type/__group/gencode-remote b/cdist/conf/type/__group/gencode-remote
index 1cffa8d4..2aaa83f3 100755
--- a/cdist/conf/type/__group/gencode-remote
+++ b/cdist/conf/type/__group/gencode-remote
@@ -1,6 +1,6 @@
#!/bin/sh
#
-# 2011 Steven Armstrong (steven-cdist at armstrong.cc)
+# 2011-2015 Steven Armstrong (steven-cdist at armstrong.cc)
# 2011 Nico Schottelius (nico-cdist at schottelius.org)
#
# This file is part of cdist.
@@ -23,91 +23,86 @@
#
name="$__object_id"
-os_version="$(cat "$__global/explorer/os_version")"
os="$(cat "$__global/explorer/os")"
+state="$(cat "$__object/parameter/state")"
-cd "$__object/parameter"
-if grep -q "^${name}:" "$__object/explorer/group"; then
- for property in $(ls .); do
- new_value="$(cat "$property")"
- # argument to pass the groupmod command for this property (exceptions
- # are made in the case statement below)
- proparg="--$property"
- case "$property" in
- password)
- if [ "$os" = "freebsd" ]; then
- echo "group/$name: FreeBSD doesn't support password modification" >&2
- exit 1
- fi
- case "$os_version" in
- "Red Hat Enterprise Linux Server release "[45]*|"CentOS release "[45]*)
- # TODO: Use gpasswd? Need to fix gshadow explorer first.
- echo "group/$name: '$os_version' groupmod does not support password modification" >&2
- exit 1
+# Use short option names for portability
+shorten_property() {
+ case "$1" in
+ gid) echo "-g";;
+ password) echo "-p";;
+ system) echo "-r";;
+ esac
+}
+
+
+if [ "$state" = "present" ]; then
+ case "$os" in
+ freebsd)
+ supported_add_properties="gid"
+ supported_change_properties="gid"
+ ;;
+ *)
+ supported_add_properties="gid password system"
+ supported_change_properties="gid password"
+ ;;
+ esac
+ if grep -q "^${name}:" "$__object/explorer/group"; then
+ # change existing
+ for property in $supported_change_properties; do
+ if [ -f "$__object/parameter/$property" ]; then
+ new_value="$(cat "$__object/parameter/$property")"
+ unset current_value
+ case "$property" in
+ password)
+ current_value="$(awk -F: '{ print $2 }' "$__object/explorer/gshadow")"
+ ;;
+ gid)
+ current_value="$(awk -F: '{ print $3 }' "$__object/explorer/group")"
;;
esac
- current_value="$(awk -F: '{ print $2 }' < "$__object/explorer/gshadow")"
- ;;
- gid)
- # set to -g to support older redhat/centos
- proparg="-g"
- current_value="$(awk -F: '{ print $3 }' < "$__object/explorer/group")"
- ;;
- esac
-
- if [ "$new_value" != "$current_value" ]; then
- set -- "$@" "$proparg" \"$new_value\"
- echo change $property $new_value $current_value >> "$__messages_out"
- fi
- done
-
- if [ $# -gt 0 ]; then
- echo mod >> "$__messages_out"
- case $os in
- freebsd)
- echo pw group mod "$@" "$name"
- ;;
- *)
+ if [ "$new_value" != "$current_value" ]; then
+ set -- "$@" "$(shorten_property $property)" \'$new_value\'
+ echo change $property $new_value $current_value >> "$__messages_out"
+ fi
+ fi
+ done
+ if [ $# -gt 0 ]; then
+ if [ "$os" = "freebsd" ]; then
+ echo pw groupmod "$@" "$name"
+ else
echo groupmod "$@" "$name"
- ;;
- esac
+ fi
+ echo mod >> "$__messages_out"
+ fi
+ else
+ # create new
+ for property in $supported_change_properties; do
+ if [ -f "$__object/parameter/$property" ]; then
+ new_value="$(cat "$__object/parameter/$property")"
+ if [ -z "$new_value" ]; then
+ # Boolean parameters have no value
+ set -- "$@" "$(shorten_property $property)"
+ else
+ set -- "$@" "$(shorten_property $property)" \'$new_value\'
+ fi
+ fi
+ done
+ if [ "$os" = "freebsd" ]; then
+ echo pw groupadd "$@" "$name"
+ else
+ echo groupadd "$@" "$name"
+ fi
fi
else
- echo add >> "$__messages_out"
- for property in $(ls .); do
- new_value="$(cat "$property")"
+ # delete existing
+ if grep -q "^${name}:" "$__object/explorer/group"; then
if [ "$os" = "freebsd" ]; then
- case $property in
- gid)
- proparg="-g"
- ;;
- password)
- echo "group/$name: FreeBSD doesn't support password setting" >&2
- exit 1
- ;;
- *)
- # The type has been updated to support more properties than it knows how to handle for FreeBSD
- # tell the user about this.
- echo "Currently unknown property: $property" >&2
- exit 1
- ;;
- esac
+ echo pw groupdel "$name"
else
- proparg="--$property"
+ echo groupdel "$name"
fi
-
- set -- "$@" "$proparg" \"$new_value\"
- echo set $property $new_value >> "$__messages_out"
- done
-
- case $os in
- freebsd)
- echo pw group add "$@" "$name"
- ;;
- *)
- echo groupadd "$@" "$name"
- ;;
- esac
+ echo remove >> "$__messages_out"
+ fi
fi
-
diff --git a/cdist/conf/type/__group/man.rst b/cdist/conf/type/__group/man.rst
new file mode 100644
index 00000000..912dd226
--- /dev/null
+++ b/cdist/conf/type/__group/man.rst
@@ -0,0 +1,77 @@
+cdist-type__group(7)
+====================
+Manage groups
+
+Steven Armstrong
+
+
+DESCRIPTION
+-----------
+This cdist type allows you to create or modify groups on the target.
+
+
+REQUIRED PARAMETERS
+-------------------
+None.
+
+
+OPTIONAL PARAMETERS
+-------------------
+state
+ absent or present, defaults to present
+gid
+ see groupmod(8)
+password
+ see above
+
+
+BOOLEAN PARAMETERS
+------------------
+system
+ see groupadd(8), apply only on group creation
+
+
+MESSAGES
+--------
+mod
+ group is modified
+add
+ New group added
+remove
+ group is removed
+change
+ Changed group property from current_value to new_value
+set
+ set property to new value, property was not set before
+
+
+EXAMPLES
+--------
+
+.. code-block:: sh
+
+ # Create a group 'foobar' with operating system default settings
+ __group foobar
+
+ # Remove the 'foobar' group
+ __group foobar --state absent
+
+ # Create a system group 'myservice' with operating system default settings
+ __group myservice --system
+
+ # Same but with a specific gid
+ __group foobar --gid 1234
+
+ # Same but with a gid and password
+ __group foobar --gid 1234 --password 'crypted-password-string'
+
+
+SEE ALSO
+--------
+- `cdist-type(7) `_
+
+
+COPYING
+-------
+Copyright \(C) 2011-2015 Steven Armstrong. Free use of this software is
+granted under the terms of the GNU General Public License version 3 (GPLv3).
diff --git a/cdist/conf/type/__group/man.text b/cdist/conf/type/__group/man.text
deleted file mode 100644
index def0232f..00000000
--- a/cdist/conf/type/__group/man.text
+++ /dev/null
@@ -1,64 +0,0 @@
-cdist-type__group(7)
-====================
-Steven Armstrong
-
-
-NAME
-----
-cdist-type__group - Manage groups
-
-
-DESCRIPTION
------------
-This cdist type allows you to create or modify groups on the target.
-
-
-REQUIRED PARAMETERS
--------------------
-None.
-
-
-OPTIONAL PARAMETERS
--------------------
-gid::
- see groupmod(8)
-password::
- see above
-
-
-MESSAGES
---------
-mod::
- group is modified
-add::
- New group added
-change ::
- Changed group property from current_value to new_value
-set ::
- set property to new value, property was not set bevore
-
-
-EXAMPLES
---------
-
---------------------------------------------------------------------------------
-# Create a group 'foobar' with operating system default settings
-__group foobar
-
-# Same but with a specific gid
-__group foobar --gid 1234
-
-# Same but with a gid and password
-__group foobar --gid 1234 --password 'crypted-password-string'
---------------------------------------------------------------------------------
-
-
-SEE ALSO
---------
-- cdist-type(7)
-
-
-COPYING
--------
-Copyright \(C) 2011 Steven Armstrong. Free use of this software is
-granted under the terms of the GNU General Public License version 3 (GPLv3).
diff --git a/cdist/conf/type/__group/parameter/boolean b/cdist/conf/type/__group/parameter/boolean
new file mode 100644
index 00000000..bec3a35e
--- /dev/null
+++ b/cdist/conf/type/__group/parameter/boolean
@@ -0,0 +1 @@
+system
diff --git a/cdist/conf/type/__group/parameter/default/state b/cdist/conf/type/__group/parameter/default/state
new file mode 100644
index 00000000..e7f6134f
--- /dev/null
+++ b/cdist/conf/type/__group/parameter/default/state
@@ -0,0 +1 @@
+present
diff --git a/cdist/conf/type/__group/parameter/optional b/cdist/conf/type/__group/parameter/optional
index 4c661c8f..dd51c173 100644
--- a/cdist/conf/type/__group/parameter/optional
+++ b/cdist/conf/type/__group/parameter/optional
@@ -1,2 +1,3 @@
gid
password
+state
diff --git a/cdist/conf/type/__hostname/explorer/hostname_file b/cdist/conf/type/__hostname/explorer/hostname_file
index ed28c8a8..6a00aa9f 100755
--- a/cdist/conf/type/__hostname/explorer/hostname_file
+++ b/cdist/conf/type/__hostname/explorer/hostname_file
@@ -21,6 +21,10 @@
# Retrieve the contents of /etc/hostname
#
+# Almost any distribution
if [ -f /etc/hostname ]; then
cat /etc/hostname
+# SuSE
+elif [ -f /etc/HOSTNAME ]; then
+ cat /etc/HOSTNAME
fi
diff --git a/cdist/conf/type/__hostname/explorer/hostname_sysconfig b/cdist/conf/type/__hostname/explorer/hostname_sysconfig
new file mode 100755
index 00000000..d0d7b4e7
--- /dev/null
+++ b/cdist/conf/type/__hostname/explorer/hostname_sysconfig
@@ -0,0 +1,26 @@
+#!/bin/sh
+#
+# 2014 Nico Schottelius (nico-cdist at schottelius.org)
+#
+# This file is part of cdist.
+#
+# cdist is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# cdist is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with cdist. If not, see .
+#
+#
+# Retrieve the contents of /etc/hostname
+#
+
+if [ -f /etc/sysconfig/network ]; then
+ awk -F= '/^HOSTNAME=/ { print $2 }' /etc/sysconfig/network
+fi
diff --git a/cdist/conf/type/__hostname/gencode-remote b/cdist/conf/type/__hostname/gencode-remote
index 3d208cbe..9fac7bf4 100755
--- a/cdist/conf/type/__hostname/gencode-remote
+++ b/cdist/conf/type/__hostname/gencode-remote
@@ -28,14 +28,28 @@ fi
os=$(cat "$__global/explorer/os")
name_running=$(cat "$__global/explorer/hostname")
name_config=$(cat "$__object/explorer/hostname_file")
+name_sysconfig=$(cat "$__object/explorer/hostname_sysconfig")
has_hostnamectl=$(cat "$__object/explorer/has_hostnamectl")
################################################################################
# If everything is ok -> exit
#
-if [ "$name_config" = "$name_should" -a "$name_running" = "$name_should" ]; then
- exit 0
-fi
+case "$os" in
+ archlinux|debian|suse|ubuntu|devuan)
+ if [ "$name_config" = "$name_should" -a "$name_running" = "$name_should" ]; then
+ exit 0
+ fi
+ ;;
+ centos)
+ if [ "$name_sysconfig" = "$name_should" -a "$name_running" = "$name_should" ]; then
+ exit 0
+ fi
+ ;;
+ *)
+ echo "Unsupported os: $os" >&2
+ exit 1
+ ;;
+esac
################################################################################
# Setup hostname
@@ -45,6 +59,17 @@ echo changed >> "$__messages_out"
if [ "$has_hostnamectl" ]; then
echo "hostnamectl set-hostname '$name_should'"
else
- echo "hostname '$name_should'"
- echo "printf '%s\n' '$name_should' > /etc/hostname"
+ case "$os" in
+ archlinux|debian|ubuntu|devuan)
+ echo "hostname '$name_should'"
+ echo "printf '%s\n' '$name_should' > /etc/hostname"
+ ;;
+ centos)
+ echo "hostname '$name_should'"
+ ;;
+ suse)
+ echo "hostname '$name_should'"
+ echo "printf '%s\n' '$name_should' > /etc/HOSTNAME"
+ ;;
+ esac
fi
diff --git a/cdist/conf/type/__hostname/man.text b/cdist/conf/type/__hostname/man.rst
similarity index 63%
rename from cdist/conf/type/__hostname/man.text
rename to cdist/conf/type/__hostname/man.rst
index ac44d426..32d452f7 100644
--- a/cdist/conf/type/__hostname/man.text
+++ b/cdist/conf/type/__hostname/man.rst
@@ -1,13 +1,10 @@
cdist-type__hostname(7)
=======================
+Set the hostname
+
Steven Armstrong
-NAME
-----
-cdist-type__hostname - set the hostname
-
-
DESCRIPTION
-----------
Set's the hostname on various operating systems.
@@ -19,31 +16,31 @@ None.
OPTIONAL PARAMETERS
-------------------
-name::
+name
The hostname to set. Defaults to the first segment of __target_host
(${__target_host%%.*})
MESSAGES
--------
-changed::
+changed
Changed the hostname
EXAMPLES
--------
---------------------------------------------------------------------------------
-# take hostname from __target_host
-__hostname
+.. code-block:: sh
-# set hostname explicitly
-__hostname --name some-static-hostname
---------------------------------------------------------------------------------
+ # take hostname from __target_host
+ __hostname
+
+ # set hostname explicitly
+ __hostname --name some-static-hostname
SEE ALSO
--------
-- cdist-type(7)
+- `cdist-type(7) `_
COPYING
diff --git a/cdist/conf/type/__hostname/manifest b/cdist/conf/type/__hostname/manifest
index 0544a6f9..76f962e0 100755
--- a/cdist/conf/type/__hostname/manifest
+++ b/cdist/conf/type/__hostname/manifest
@@ -20,6 +20,12 @@
#
os=$(cat "$__global/explorer/os")
+if [ -f "$__object/parameter/name" ]; then
+ name_should="$(cat "$__object/parameter/name")"
+else
+ name_should="$(echo "${__target_host%%.*}")"
+fi
+
not_supported() {
echo "Your operating system ($os) is currently not supported by this type (${__type##*/})." >&2
@@ -28,11 +34,18 @@ not_supported() {
}
case "$os" in
- archlinux|debian|ubuntu)
- # handled in gencode-remote
- :
- ;;
- *)
- not_supported
- ;;
+ archlinux|debian|suse|ubuntu|devuan)
+ # handled in gencode-remote
+ :
+ ;;
+ centos)
+ __key_value sysconfig-hostname \
+ --file /etc/sysconfig/network \
+ --delimiter '=' \
+ --key HOSTNAME \
+ --value "$name_should" --exact_delimiter
+ ;;
+ *)
+ not_supported
+ ;;
esac
diff --git a/cdist/conf/type/__iptables_apply/files/init-script b/cdist/conf/type/__iptables_apply/files/init-script
index 2dc952e9..2247dcf5 100644
--- a/cdist/conf/type/__iptables_apply/files/init-script
+++ b/cdist/conf/type/__iptables_apply/files/init-script
@@ -45,4 +45,14 @@ case $1 in
restart)
"$0" stop && "$0" start
;;
+ reset)
+ for table in INPUT FORWARD OUTPUT; do
+ iptables -P "$table" ACCEPT
+ iptables -F "$table"
+ done
+ for table in PREROUTING POSTROUTING OUTPUT; do
+ iptables -t nat -P "$table" ACCEPT
+ iptables -t nat -F "$table"
+ done
+ ;;
esac
diff --git a/cdist/conf/type/__iptables_apply/gencode-remote b/cdist/conf/type/__iptables_apply/gencode-remote
index 9cdf28cf..c15d4d7f 100644
--- a/cdist/conf/type/__iptables_apply/gencode-remote
+++ b/cdist/conf/type/__iptables_apply/gencode-remote
@@ -1,3 +1,5 @@
+#!/bin/sh
+
if grep -q "^__file/etc/iptables.d/" "$__messages_in"; then
echo /etc/init.d/iptables restart
fi
diff --git a/cdist/conf/type/__iptables_apply/man.text b/cdist/conf/type/__iptables_apply/man.rst
similarity index 83%
rename from cdist/conf/type/__iptables_apply/man.text
rename to cdist/conf/type/__iptables_apply/man.rst
index 87f4b4ee..40605351 100644
--- a/cdist/conf/type/__iptables_apply/man.text
+++ b/cdist/conf/type/__iptables_apply/man.rst
@@ -1,13 +1,10 @@
cdist-type__iptables_apply(7)
=============================
+Apply the rules
+
Nico Schottelius
-NAME
-----
-cdist-type__iptables_apply - Apply the rules
-
-
DESCRIPTION
-----------
This cdist type deploys an init script that triggers
@@ -31,8 +28,8 @@ None (__iptables_apply is used by __iptables_rule)
SEE ALSO
--------
-- cdist-type(7)
-- cdist-type__iptables_rule(7)
+- `cdist-type(7) `_
+- `cdist-type__iptables_rule(7) `_
- iptables(8)
diff --git a/cdist/conf/type/__iptables_apply/manifest b/cdist/conf/type/__iptables_apply/manifest
index a22901ba..3bb2d976 100644
--- a/cdist/conf/type/__iptables_apply/manifest
+++ b/cdist/conf/type/__iptables_apply/manifest
@@ -1,3 +1,4 @@
+#!/bin/sh
#
# 2013 Nico Schottelius (nico-cdist at schottelius.org)
#
diff --git a/cdist/conf/type/__iptables_rule/man.rst b/cdist/conf/type/__iptables_rule/man.rst
new file mode 100644
index 00000000..5ee02f9c
--- /dev/null
+++ b/cdist/conf/type/__iptables_rule/man.rst
@@ -0,0 +1,60 @@
+cdist-type__iptables_rule(7)
+============================
+Deploy iptable rulesets
+
+Nico Schottelius
+
+
+DESCRIPTION
+-----------
+This cdist type allows you to manage iptable rules
+in a distribution independent manner.
+
+
+REQUIRED PARAMETERS
+-------------------
+rule
+ The rule to apply. Essentially an iptables command
+ line without iptables in front of it.
+
+
+OPTIONAL PARAMETERS
+-------------------
+state
+ 'present' or 'absent', defaults to 'present'
+
+
+EXAMPLES
+--------
+
+.. code-block:: sh
+
+ # Deploy some policies
+ __iptables_rule policy-in --rule "-P INPUT DROP"
+ __iptables_rule policy-out --rule "-P OUTPUT ACCEPT"
+ __iptables_rule policy-fwd --rule "-P FORWARD DROP"
+
+ # The usual established rule
+ __iptables_rule established --rule "-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT"
+
+ # Some service rules
+ __iptables_rule http --rule "-A INPUT -p tcp --dport 80 -j ACCEPT"
+ __iptables_rule ssh --rule "-A INPUT -p tcp --dport 22 -j ACCEPT"
+ __iptables_rule https --rule "-A INPUT -p tcp --dport 443 -j ACCEPT"
+
+ # Ensure some rules are not present anymore
+ __iptables_rule munin --rule "-A INPUT -p tcp --dport 4949 -j ACCEPT" \
+ --state absent
+
+
+SEE ALSO
+--------
+- `cdist-type(7) `_
+- `cdist-type__iptables_apply(7) `_
+- iptables(8)
+
+
+COPYING
+-------
+Copyright \(C) 2013 Nico Schottelius. Free use of this software is
+granted under the terms of the GNU General Public License version 3 (GPLv3).
diff --git a/cdist/conf/type/__iptables_rule/man.text b/cdist/conf/type/__iptables_rule/man.text
deleted file mode 100644
index 2f5b9785..00000000
--- a/cdist/conf/type/__iptables_rule/man.text
+++ /dev/null
@@ -1,64 +0,0 @@
-cdist-type__iptables_rule(7)
-============================
-Nico Schottelius
-
-
-NAME
-----
-cdist-type__iptables_rule - Deploy iptable rulesets
-
-
-DESCRIPTION
------------
-This cdist type allows you to manage iptable rules
-in a distribution independent manner.
-
-
-REQUIRED PARAMETERS
--------------------
-rule::
- The rule to apply. Essentially an iptables command
- line without iptables in front of it.
-
-
-OPTIONAL PARAMETERS
--------------------
-state::
- 'present' or 'absent', defaults to 'present'
-
-
-EXAMPLES
---------
-
---------------------------------------------------------------------------------
-# Deploy some policies
-__iptables_rule policy-in --rule "-P INPUT DROP"
-__iptables_rule policy-out --rule "-P OUTPUT ACCEPT"
-__iptables_rule policy-fwd --rule "-P FORWARD DROP"
-
-# The usual established rule
-__iptables_rule established --rule "-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT"
-
-# Some service rules
-__iptables_rule http --rule "-A INPUT -p tcp --dport 80 -j ACCEPT"
-__iptables_rule ssh --rule "-A INPUT -p tcp --dport 22 -j ACCEPT"
-__iptables_rule https --rule "-A INPUT -p tcp --dport 443 -j ACCEPT"
-
-# Ensure some rules are not present anymore
-__iptables_rule munin --rule "-A INPUT -p tcp --dport 4949 -j ACCEPT" \
- --state absent
-
---------------------------------------------------------------------------------
-
-
-SEE ALSO
---------
-- cdist-type(7)
-- cdist-type__iptables_apply(7)
-- iptables(8)
-
-
-COPYING
--------
-Copyright \(C) 2013 Nico Schottelius. Free use of this software is
-granted under the terms of the GNU General Public License version 3 (GPLv3).
diff --git a/cdist/conf/type/__iptables_rule/manifest b/cdist/conf/type/__iptables_rule/manifest
index f02ab18b..13cec523 100644
--- a/cdist/conf/type/__iptables_rule/manifest
+++ b/cdist/conf/type/__iptables_rule/manifest
@@ -1,3 +1,4 @@
+#!/bin/sh
#
# 2013 Nico Schottelius (nico-cdist at schottelius.org)
#
diff --git a/cdist/conf/type/__issue/man.text b/cdist/conf/type/__issue/man.rst
similarity index 62%
rename from cdist/conf/type/__issue/man.text
rename to cdist/conf/type/__issue/man.rst
index 40ed920e..4a6c1f8d 100644
--- a/cdist/conf/type/__issue/man.text
+++ b/cdist/conf/type/__issue/man.rst
@@ -1,13 +1,10 @@
cdist-type__issue(7)
====================
+Manage issue
+
Nico Schottelius
-NAME
-----
-cdist-type__issue - Manage issue
-
-
DESCRIPTION
-----------
This cdist type allows you to easily setup /etc/issue.
@@ -20,7 +17,7 @@ None.
OPTIONAL PARAMETERS
-------------------
-source::
+source
If supplied, use this file as /etc/issue instead of default.
@@ -28,17 +25,17 @@ source::
EXAMPLES
--------
---------------------------------------------------------------------------------
-__issue
+.. code-block:: sh
-# When called from another type
-__issue --source "$__type/files/myfancyissue"
---------------------------------------------------------------------------------
+ __issue
+
+ # When called from another type
+ __issue --source "$__type/files/myfancyissue"
SEE ALSO
--------
-- cdist-type(7)
+- `cdist-type(7) `_
COPYING
diff --git a/cdist/conf/type/__jail/explorer/status b/cdist/conf/type/__jail/explorer/status
index 06f7d063..1ceba212 100755
--- a/cdist/conf/type/__jail/explorer/status
+++ b/cdist/conf/type/__jail/explorer/status
@@ -39,7 +39,7 @@ fi
# backslash-escaped $jaildir
sjaildir="$(echo ${jaildir} | sed 's#/#\\/#g')"
-jls_output="$(jls | grep "[ ^I]${sjaildir}\/${name}\$")" || true
+jls_output="$(jls | grep "[ ]${sjaildir}\/${name}\$")" || true
if [ -n "${jls_output}" ]; then
echo "STARTED"
diff --git a/cdist/conf/type/__jail/gencode-remote b/cdist/conf/type/__jail/gencode-remote
index 141c8150..c88f3361 100755
--- a/cdist/conf/type/__jail/gencode-remote
+++ b/cdist/conf/type/__jail/gencode-remote
@@ -1,6 +1,6 @@
#!/bin/sh
#
-# 2012 Jake Guffey (jake.guffey at eprotex.com)
+# 2012,2014 Jake Guffey (jake.guffey at eprotex.com)
#
# This file is part of cdist.
#
@@ -104,6 +104,7 @@ stopJail() {
# Check $status before issuing command
if [ "$status" = "STARTED" ]; then
echo "/etc/rc.d/jail stop ${name}"
+ echo "stop" >> "$__messages_out"
fi
}
@@ -111,6 +112,7 @@ startJail() {
# Check $status before issuing command
if [ "$status" = "NOTSTART" ]; then
echo "/etc/rc.d/jail start ${name}"
+ echo "start" >> "$__messages_out"
fi
}
@@ -162,6 +164,7 @@ EOF
rm -f /etc/rc.conf.bak
fi
EOF
+ echo "delete" >> "$__messages_out"
}
createJail() {
@@ -215,6 +218,7 @@ cat <> "$__messages_out"
# Create the ro+rw mountpoint entries in fstab
cat <> "$__messages_out"
fi
# Add the normal entries into the jail's rc.conf
diff --git a/cdist/conf/type/__jail/man.text b/cdist/conf/type/__jail/man.rst
similarity index 61%
rename from cdist/conf/type/__jail/man.text
rename to cdist/conf/type/__jail/man.rst
index 9c968d84..38ec4f96 100644
--- a/cdist/conf/type/__jail/man.text
+++ b/cdist/conf/type/__jail/man.rst
@@ -1,13 +1,10 @@
cdist-type__jail(7)
===================
+Manage FreeBSD jails
+
Jake Guffey
-NAME
-----
-cdist-type__jail - Manage FreeBSD jails
-
-
DESCRIPTION
-----------
This type is used on FreeBSD to manage jails.
@@ -15,47 +12,47 @@ This type is used on FreeBSD to manage jails.
REQUIRED PARAMETERS
-------------------
-state::
+state
Either "present" or "absent", defaults to "present".
-jailbase::
+jailbase
The location of the .tgz archive containing the base fs for your jails.
OPTIONAL PARAMETERS
-------------------
-name::
+name
The name of the jail. Default is to use the object_id as the jail name.
-ip::
+ip
The ifconfig style IP/netmask combination to use for the jail guest. If
the state parameter is "present," this parameter is required.
-hostname::
+hostname
The FQDN to use for the jail guest. Defaults to the name parameter.
-interface::
+interface
The name of the physical interface on the jail server to bind the jail to.
Defaults to the first interface found in the output of ifconfig -l.
-devfs-ruleset::
+devfs-ruleset
The name of the devfs ruleset to associate with the jail. Defaults to
"jailrules." This ruleset must be copied to the server via another type.
To use this option, devfs-enable must be "true."
-jaildir::
+jaildir
The location on the remote server to use for hosting jail filesystems.
Defaults to /usr/jail.
BOOLEAN PARAMETERS
------------------
-stopped::
+stopped
Do not start the jail
-devfs-disable::
+devfs-disable
Whether to disallow devfs mounting within the jail
-onboot::
+onboot
Whether to add the jail to rc.conf's jail_list variable.
@@ -67,37 +64,50 @@ be removed then re-added with the correct IP address/netmask or the appropriate
line (jail__ip="...") modified within rc.conf through some alternate
means.
+MESSAGES
+--------
+start
+ The jail was started
+stop
+ The jail was stopped
+create:
+ The jail was created
+delete
+ The jail was deleted
+onboot
+ The jail was configured to start on boot
+
EXAMPLES
--------
---------------------------------------------------------------------------------
-# Create a jail called www
-__jail www --state present --ip "192.168.1.2" --jailbase /my/jail/base.tgz
+.. code-block:: sh
-# Remove the jail called www
-__jail www --state absent --jailbase /my/jail/base.tgz
+ # Create a jail called www
+ __jail www --state present --ip "192.168.1.2" --jailbase /my/jail/base.tgz
-# The jail www should not be started
-__jail www --state present --stopped \
- --ip "192.168.1.2 netmask 255.255.255.0" \
- --jailbase /my/jail/base.tgz
+ # Remove the jail called www
+ __jail www --state absent --jailbase /my/jail/base.tgz
-# Use the name variable explicitly
-__jail thisjail --state present --name www \
- --ip "192.168.1.2" \
- --jailbase /my/jail/base.tgz
+ # The jail www should not be started
+ __jail www --state present --stopped \
+ --ip "192.168.1.2 netmask 255.255.255.0" \
+ --jailbase /my/jail/base.tgz
-# Go nuts
-__jail lotsofoptions --state present --name testjail \
- --ip "192.168.1.100 netmask 255.255.255.0" \
- --hostname "testjail.example.com" --interface "em0" \
- --onboot --jailbase /my/jail/base.tgz --jaildir /jails
---------------------------------------------------------------------------------
+ # Use the name variable explicitly
+ __jail thisjail --state present --name www \
+ --ip "192.168.1.2" \
+ --jailbase /my/jail/base.tgz
+
+ # Go nuts
+ __jail lotsofoptions --state present --name testjail \
+ --ip "192.168.1.100 netmask 255.255.255.0" \
+ --hostname "testjail.example.com" --interface "em0" \
+ --onboot --jailbase /my/jail/base.tgz --jaildir /jails
SEE ALSO
--------
-- cdist-type(7)
+- `cdist-type(7) `_
COPYING
diff --git a/cdist/conf/type/__jail/manifest b/cdist/conf/type/__jail/manifest
index 6a953241..2d29e263 100755
--- a/cdist/conf/type/__jail/manifest
+++ b/cdist/conf/type/__jail/manifest
@@ -29,8 +29,8 @@
# Can only be used on FreeBSD
os="$(cat "$__global/explorer/os")"
if [ ! "$os" = "freebsd" ]; then
- echo "__jail can only be used on FreeBSD targets!" >&2
- exit 1
+ echo "__jail can only be used on FreeBSD targets!" >&2
+ exit 1
fi
jaildir="$(cat "$__object/parameter/jaildir")"
diff --git a/cdist/conf/type/__key_value/files/remote_script.sh b/cdist/conf/type/__key_value/files/remote_script.sh
index 282ba531..52b3f2de 100644
--- a/cdist/conf/type/__key_value/files/remote_script.sh
+++ b/cdist/conf/type/__key_value/files/remote_script.sh
@@ -1,3 +1,5 @@
+#!/bin/sh
+
export key="$(cat "$__object/parameter/key" 2>/dev/null \
|| echo "$__object_id")"
export state="$(cat "$__object/parameter/state")"
diff --git a/cdist/conf/type/__key_value/man.text b/cdist/conf/type/__key_value/man.rst
similarity index 62%
rename from cdist/conf/type/__key_value/man.text
rename to cdist/conf/type/__key_value/man.rst
index d4c8e2cc..4b259c75 100644
--- a/cdist/conf/type/__key_value/man.text
+++ b/cdist/conf/type/__key_value/man.rst
@@ -1,13 +1,10 @@
cdist-type__key_value(7)
========================
+Change property values in files
+
Steven Armstrong
-NAME
-----
-cdist-type__key_value - Change property values in files
-
-
DESCRIPTION
-----------
This cdist type allows you to change values in a key value based config
@@ -16,22 +13,22 @@ file.
REQUIRED PARAMETERS
-------------------
-file::
+file
The file to operate on.
-delimiter::
- The delimiter which seperates the key from the value.
+delimiter
+ The delimiter which separates the key from the value.
OPTIONAL PARAMETERS
-------------------
-state::
+state
present or absent, defaults to present. If present, sets the key to value,
if absent, removes the key from the file.
-key::
+key
The key to change. Defaults to object_id.
-value::
+value
The value for the key. Optional if state=absent, required otherwise.
-comment::
+comment
If supplied, the value will be inserted before the line with the key,
but only if the key or value must be changed.
You need to ensure yourself that the line is prefixed with the correct
@@ -40,41 +37,41 @@ comment::
BOOLEAN PARAMETERS
------------------
-exact_delimiter::
+exact_delimiter
If supplied, treat additional whitespaces between key, delimiter and value
as wrong value.
MESSAGES
--------
-remove::
+remove
Removed existing key and value
-insert::
+insert
Added key and value
-change::
+change
Changed value of existing key
-create::
+create
A new line was inserted in a new file
EXAMPLES
--------
---------------------------------------------------------------------------------
-# Set the maximum system user id
-__key_value SYS_UID_MAX --file /etc/login.defs --value 666 --delimiter ' '
+.. code-block:: sh
-# Same with fancy id
-__key_value my-fancy-id --file /etc/login.defs --key SYS_UID_MAX --value 666 \
- --delimiter ' '
+ # Set the maximum system user id
+ __key_value SYS_UID_MAX --file /etc/login.defs --value 666 --delimiter ' '
-# Enable packet forwarding
-__key_value net.ipv4.ip_forward --file /etc/sysctl.conf --value 1 \
- --delimiter ' = ' --comment '# my linux kernel should act as a router'
+ # Same with fancy id
+ __key_value my-fancy-id --file /etc/login.defs --key SYS_UID_MAX --value 666 \
+ --delimiter ' '
-# Remove existing key/value
-__key_value LEGACY_KEY --file /etc/somefile --state absent --delimiter '='
---------------------------------------------------------------------------------
+ # Enable packet forwarding
+ __key_value net.ipv4.ip_forward --file /etc/sysctl.conf --value 1 \
+ --delimiter ' = ' --comment '# my linux kernel should act as a router'
+
+ # Remove existing key/value
+ __key_value LEGACY_KEY --file /etc/somefile --state absent --delimiter '='
MORE INFORMATION
@@ -85,7 +82,7 @@ So you need to exactly specify the key and delimiter. Delimiter can be of any le
SEE ALSO
--------
-- cdist-type(7)
+- `cdist-type(7) `_
COPYING
diff --git a/cdist/conf/type/__line/man.text b/cdist/conf/type/__line/man.rst
similarity index 59%
rename from cdist/conf/type/__line/man.text
rename to cdist/conf/type/__line/man.rst
index f39ee929..f6d71a5a 100644
--- a/cdist/conf/type/__line/man.text
+++ b/cdist/conf/type/__line/man.rst
@@ -1,13 +1,10 @@
cdist-type__line(7)
===================
+Manage lines in files
+
Nico Schottelius
-NAME
-----
-cdist-type__line - Manage lines in files
-
-
DESCRIPTION
-----------
This cdist type allows you to add lines and remove lines from files.
@@ -18,16 +15,16 @@ REQUIRED PARAMETERS
OPTIONAL PARAMETERS
-------------------
-state::
+state
'present' or 'absent', defaults to 'present'
-line::
+line
Specifies the line which should be absent or present
Must be present, if state is present.
Must not be combined with regex, if state is absent.
-regex::
+regex
If state is present, search for this pattern and add
given line, if the given regular expression does not match.
@@ -38,7 +35,7 @@ regex::
Must not be combined with line, if state is absent.
-file::
+file
If supplied, use this as the destination file.
Otherwise the object_id is used.
@@ -46,24 +43,24 @@ file::
EXAMPLES
--------
---------------------------------------------------------------------------------
-# Manage the DAEMONS line in rc.conf
-__line daemons --file /etc/rc.conf --line 'DAEMONS=(hwclock !network sshd crond postfix)'
+.. code-block:: sh
-# Ensure the home mount is present in /etc/fstab - explicitly make it present
-__line home-fstab \
- --file /etc/fstab \
- --line 'filer.fs:/vol/home /home nfs defaults 0 0' \
- --state present
+ # Manage the DAEMONS line in rc.conf
+ __line daemons --file /etc/rc.conf --line 'DAEMONS=(hwclock !network sshd crond postfix)'
-# Removes the line specifiend in "include_www" from the file "lighttpd.conf"
-__line legacy_timezone --file /etc/rc.conf --regex 'TIMEZONE=.*' --state absent
---------------------------------------------------------------------------------
+ # Ensure the home mount is present in /etc/fstab - explicitly make it present
+ __line home-fstab \
+ --file /etc/fstab \
+ --line 'filer.fs:/vol/home /home nfs defaults 0 0' \
+ --state present
+
+ # Removes the line specifiend in "include_www" from the file "lighttpd.conf"
+ __line legacy_timezone --file /etc/rc.conf --regex 'TIMEZONE=.*' --state absent
SEE ALSO
--------
-- cdist-type(7)
+- `cdist-type(7) `_
- grep(1)
diff --git a/cdist/conf/type/__link/man.text b/cdist/conf/type/__link/man.rst
similarity index 51%
rename from cdist/conf/type/__link/man.text
rename to cdist/conf/type/__link/man.rst
index 663087db..654b097b 100644
--- a/cdist/conf/type/__link/man.text
+++ b/cdist/conf/type/__link/man.rst
@@ -1,13 +1,10 @@
cdist-type__link(7)
===================
+Manage links (hard and symbolic)
+
Nico Schottelius
-NAME
-----
-cdist-type__link - Manage links (hard and symbolic)
-
-
DESCRIPTION
-----------
This cdist type allows you to manage hard and symbolic links.
@@ -16,42 +13,42 @@ The given object id is the destination for the link.
REQUIRED PARAMETERS
-------------------
-source::
+source
Specifies the link source.
-type::
+type
Specifies the link type: Either hard or symoblic.
OPTIONAL PARAMETERS
-------------------
-state::
+state
'present' or 'absent', defaults to 'present'
EXAMPLES
--------
---------------------------------------------------------------------------------
-# Create hard link of /etc/shadow
-__link /root/shadow --source /etc/shadow --type hard
+.. code-block:: sh
-# Relative symbolic link
-__link /etc/apache2/sites-enabled/www.test.ch \
- --source ../sites-available/www.test.ch \
- --type symbolic
+ # Create hard link of /etc/shadow
+ __link /root/shadow --source /etc/shadow --type hard
-# Absolute symbolic link
-__link /opt/plone --source /home/services/plone --type symbolic
+ # Relative symbolic link
+ __link /etc/apache2/sites-enabled/www.test.ch \
+ --source ../sites-available/www.test.ch \
+ --type symbolic
-# Remove link
-__link /opt/plone --state absent
---------------------------------------------------------------------------------
+ # Absolute symbolic link
+ __link /opt/plone --source /home/services/plone --type symbolic
+
+ # Remove link
+ __link /opt/plone --state absent
SEE ALSO
--------
-- cdist-type(7)
+- `cdist-type(7) `_
COPYING
diff --git a/cdist/conf/type/__locale/man.text b/cdist/conf/type/__locale/man.rst
similarity index 53%
rename from cdist/conf/type/__locale/man.text
rename to cdist/conf/type/__locale/man.rst
index 5ccd3eab..df337739 100644
--- a/cdist/conf/type/__locale/man.text
+++ b/cdist/conf/type/__locale/man.rst
@@ -1,13 +1,10 @@
cdist-type__locale(7)
=====================
+Configure locales
+
Nico Schottelius
-NAME
-----
-cdist-type__locale - Configure locales
-
-
DESCRIPTION
-----------
This cdist type allows you to setup locales.
@@ -15,30 +12,30 @@ This cdist type allows you to setup locales.
OPTIONAL PARAMETERS
-------------------
-state::
+state
'present' or 'absent', defaults to present
EXAMPLES
--------
---------------------------------------------------------------------------------
-# Add locale de_CH.UTF-8
-__locale de_CH.UTF-8
+.. code-block:: sh
-# Same as above, but more explicit
-__locale de_CH.UTF-8 --state present
+ # Add locale de_CH.UTF-8
+ __locale de_CH.UTF-8
-# Remove colourful British English
-__locale en_GB.UTF-8 --state absent
---------------------------------------------------------------------------------
+ # Same as above, but more explicit
+ __locale de_CH.UTF-8 --state present
+
+ # Remove colourful British English
+ __locale en_GB.UTF-8 --state absent
SEE ALSO
--------
- locale(1)
- localedef(1)
-- cdist-type(7)
+- `cdist-type(7) `_
COPYING
diff --git a/cdist/conf/type/__locale/manifest b/cdist/conf/type/__locale/manifest
index f3d75d59..c1837ae3 100644
--- a/cdist/conf/type/__locale/manifest
+++ b/cdist/conf/type/__locale/manifest
@@ -1,6 +1,7 @@
#!/bin/sh
#
-# 2013-2014 Nico Schottelius (nico-cdist at schottelius.org)
+# 2013-2015 Nico Schottelius (nico-cdist at schottelius.org)
+# 2015 David Hürlimann (david at ungleich.ch)
#
# This file is part of cdist.
#
@@ -25,10 +26,13 @@ os=$(cat "$__global/explorer/os")
case "$os" in
- debian)
+ debian|devuan)
# Debian needs a seperate package
__package locales --state present
;;
+ archlinux|suse|ubuntu|centos)
+ :
+ ;;
*)
echo "Sorry, do not know how to handle os: $os" >&2
echo "Please edit the type ${__type##*/} to fix this." >&2
diff --git a/cdist/conf/type/__motd/gencode-remote b/cdist/conf/type/__motd/gencode-remote
index 2aa84902..41fe3482 100755
--- a/cdist/conf/type/__motd/gencode-remote
+++ b/cdist/conf/type/__motd/gencode-remote
@@ -1,3 +1,5 @@
+#!/bin/sh
+#
# 2013 Nico Schottelius (nico-cdist at schottelius.org)
#
# This file is part of cdist.
@@ -20,8 +22,8 @@
os=$(cat "$__global/explorer/os")
case "$os" in
- debian|ubuntu)
-
+ debian|ubuntu|devuan)
+
# Debian and Ubuntu need to be updated,
# as seen in /etc/init.d/bootlogs
echo "uname -snrvm > /var/run/motd"
diff --git a/cdist/conf/type/__motd/man.text b/cdist/conf/type/__motd/man.rst
similarity index 63%
rename from cdist/conf/type/__motd/man.text
rename to cdist/conf/type/__motd/man.rst
index a4ca80b5..988e2d02 100644
--- a/cdist/conf/type/__motd/man.text
+++ b/cdist/conf/type/__motd/man.rst
@@ -1,13 +1,10 @@
cdist-type__motd(7)
===================
+Manage message of the day
+
Nico Schottelius
-NAME
-----
-cdist-type__motd - Manage message of the day
-
-
DESCRIPTION
-----------
This cdist type allows you to easily setup /etc/motd.
@@ -20,7 +17,7 @@ None.
OPTIONAL PARAMETERS
-------------------
-source::
+source
If supplied, copy this file from the host running cdist to the target.
If not supplied, a default message will be placed onto the target.
@@ -28,18 +25,18 @@ source::
EXAMPLES
--------
---------------------------------------------------------------------------------
-# Use cdist defaults
-__motd
+.. code-block:: sh
-# Supply source file from a different type
-__motd --source "$__type/files/my-motd"
---------------------------------------------------------------------------------
+ # Use cdist defaults
+ __motd
+
+ # Supply source file from a different type
+ __motd --source "$__type/files/my-motd"
SEE ALSO
--------
-- cdist-type(7)
+- `cdist-type(7) `_
COPYING
diff --git a/cdist/conf/type/__motd/manifest b/cdist/conf/type/__motd/manifest
index 286d1ff3..4848a4c3 100755
--- a/cdist/conf/type/__motd/manifest
+++ b/cdist/conf/type/__motd/manifest
@@ -30,7 +30,7 @@ os=$(cat "$__global/explorer/os")
case "$os" in
- debian|ubuntu)
+ debian|ubuntu|devuan)
destination=/etc/motd.tail
;;
*)
diff --git a/cdist/conf/type/__mount/man.text b/cdist/conf/type/__mount/man.rst
similarity index 66%
rename from cdist/conf/type/__mount/man.text
rename to cdist/conf/type/__mount/man.rst
index 7299bdf3..696dfbd4 100644
--- a/cdist/conf/type/__mount/man.text
+++ b/cdist/conf/type/__mount/man.rst
@@ -1,13 +1,10 @@
cdist-type__mount(7)
====================
+Manage filesystem mounts
+
Steven Armstrong
-NAME
-----
-cdist-type__mount - manage filesystem mounts
-
-
DESCRIPTION
-----------
Manage filesystem mounts either via /etc/fstab or manually.
@@ -20,62 +17,62 @@ None.
OPTIONAL PARAMETERS
-------------------
-device::
+device
device to mount at path, defaults to 'none'. see mount(8)
-dump::
+dump
value for the dump field in fstab. see fstab(5)
defaults to 0.
This parameter is ignored, if the nofstab parameter is given.
-options::
+options
comma separated string of options, see mount(8)
-pass::
+pass
value for the pass field in fstab. see fstab(5)
defaults to 0.
This parameter is ignored, if the nofstab parameter is given.
-path::
+path
mount point where to mount the device, see mount(8).
Defaults to __object_id
-state::
+state
either present or absent. Defaults to present.
-type::
+type
vfstype, see mount(8)
BOOLEAN PARAMETERS
------------------
-nofstab::
+nofstab
do not manage an entry in /etc/fstab
EXAMPLES
--------
---------------------------------------------------------------------------------
-__mount /some/dir \
- --device /dev/sdc3 \
- --type xfs \
- --options "defaults,ro"
- --dump 0 \
- --pass 1
+.. code-block:: sh
-__mount /var/lib/one \
- --device mfsmount \
- --type fuse \
- --options "mfsmaster=mfsmaster.domain.tld,mfssubfolder=/one,nonempty,_netdev"
---------------------------------------------------------------------------------
+ __mount /some/dir \
+ --device /dev/sdc3 \
+ --type xfs \
+ --options "defaults,ro"
+ --dump 0 \
+ --pass 1
+
+ __mount /var/lib/one \
+ --device mfsmount \
+ --type fuse \
+ --options "mfsmaster=mfsmaster.domain.tld,mfssubfolder=/one,nonempty,_netdev"
SEE ALSO
--------
-- cdist-type(7)
+- `cdist-type(7) `_
COPYING
diff --git a/cdist/conf/type/__mount/manifest b/cdist/conf/type/__mount/manifest
index 8a1fa234..472b6e2e 100755
--- a/cdist/conf/type/__mount/manifest
+++ b/cdist/conf/type/__mount/manifest
@@ -26,9 +26,9 @@ if [ ! -f "$__object/parameter/nofstab" ]; then
(
printf "%s" "$(cat "$__object/parameter/device")"
printf " %s" "$path"
-type="$(cat "$__object/parameter/type" 2>/dev/null || echo "auto")"
+type="$(cat "$__object/parameter/type")"
printf " %s" "$type"
-options="$(cat "$__object/parameter/options" 2>/dev/null || echo "defaults")"
+options="$(cat "$__object/parameter/options")"
printf " %s" "$options"
printf " %s" "$(cat "$__object/parameter/dump")"
printf " %s\n" "$(cat "$__object/parameter/pass")"
diff --git a/cdist/conf/type/__mount/parameter/default/options b/cdist/conf/type/__mount/parameter/default/options
new file mode 100644
index 00000000..e94f8140
--- /dev/null
+++ b/cdist/conf/type/__mount/parameter/default/options
@@ -0,0 +1 @@
+defaults
diff --git a/cdist/conf/type/__mount/parameter/default/type b/cdist/conf/type/__mount/parameter/default/type
new file mode 100644
index 00000000..865faf10
--- /dev/null
+++ b/cdist/conf/type/__mount/parameter/default/type
@@ -0,0 +1 @@
+auto
diff --git a/cdist/conf/type/__mysql_database/gencode-remote b/cdist/conf/type/__mysql_database/gencode-remote
index 7cd32242..b1c2e6a1 100755
--- a/cdist/conf/type/__mysql_database/gencode-remote
+++ b/cdist/conf/type/__mysql_database/gencode-remote
@@ -45,7 +45,6 @@ if [ -f "$__object/parameter/user" ]; then
EOF
EOFF
else
- password=""
cat <<-EOFF
mysql -u root <<-EOF
GRANT ALL PRIVILEGES ON $database.* to '$user'@'localhost';
diff --git a/cdist/conf/type/__mysql_database/man.text b/cdist/conf/type/__mysql_database/man.rst
similarity index 65%
rename from cdist/conf/type/__mysql_database/man.text
rename to cdist/conf/type/__mysql_database/man.rst
index f184a30e..88f1eecd 100644
--- a/cdist/conf/type/__mysql_database/man.text
+++ b/cdist/conf/type/__mysql_database/man.rst
@@ -1,13 +1,10 @@
cdist-type__mysql_database(7)
=============================
+Manage a MySQL database
+
Benedikt Koeppel
-NAME
-----
-cdist-type__mysql_database - Manage a MySQL database
-
-
DESCRIPTION
-----------
This cdist type allows you to install a MySQL database.
@@ -19,28 +16,28 @@ None.
OPTIONAL PARAMETERS
-------------------
-name::
+name
The name of the database to install
defaults to the object id
-user::
+user
A user that should have access to the database
-password::
+password
The password for the user who manages the database
EXAMPLES
--------
---------------------------------------------------------------------------------
-__mysql_database "cdist" --name "cdist" --user "myuser" --password "mypwd"
---------------------------------------------------------------------------------
+.. code-block:: sh
+
+ __mysql_database "cdist" --name "cdist" --user "myuser" --password "mypwd"
SEE ALSO
--------
-- cdist-type(7)
+- `cdist-type(7) `_
COPYING
diff --git a/cdist/conf/type/__package/explorer/pkgng_exists b/cdist/conf/type/__package/explorer/pkgng_exists
new file mode 100755
index 00000000..355c5d65
--- /dev/null
+++ b/cdist/conf/type/__package/explorer/pkgng_exists
@@ -0,0 +1,27 @@
+#!/bin/sh
+#
+# 2014 Jake Guffey (jake.guffey at eprotex.com)
+#
+# This file is part of cdist.
+#
+# cdist is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# cdist is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with cdist. If not, see .
+#
+#
+# Retrieve the status of a package - parsed dpkg output
+#
+
+if [ "$($__explorer/os)" = "freebsd" ]; then
+ command -v pkg
+fi
+
diff --git a/cdist/conf/type/__package/man.text b/cdist/conf/type/__package/man.rst
similarity index 54%
rename from cdist/conf/type/__package/man.text
rename to cdist/conf/type/__package/man.rst
index b656c890..1ada06a7 100644
--- a/cdist/conf/type/__package/man.text
+++ b/cdist/conf/type/__package/man.rst
@@ -1,17 +1,14 @@
cdist-type__package(7)
======================
+Manage packages
+
Steven Armstrong
-NAME
-----
-cdist-type__package - Manage packages
-
-
DESCRIPTION
-----------
This cdist type allows you to install or uninstall packages on the target.
-It dispatches the actual work to the package system dependant types.
+It dispatches the actual work to the package system dependent types.
REQUIRED PARAMETERS
@@ -21,40 +18,41 @@ None
OPTIONAL PARAMETERS
-------------------
-name::
+name
The name of the package to install. Default is to use the object_id as the
package name.
-version::
+version
The version of the package to install. Default is to install the version
- choosen by the local package manager.
-type::
+ chosen by the local package manager.
+type
The package type to use. Default is determined based on the $os explorer
variable.
- e.g. __package_apt for Debian
- __package_emerge for Gentoo
+ e.g.
+ * __package_apt for Debian
+ * __package_emerge for Gentoo
-state::
+state
Either "present" or "absent", defaults to "present"
EXAMPLES
--------
---------------------------------------------------------------------------------
-# Install the package vim on the target
-__package vim --state present
+.. code-block:: sh
-# Same but install specific version
-__package vim --state present --version 7.3.50
+ # Install the package vim on the target
+ __package vim --state present
-# Force use of a specific package type
-__package vim --state present --type __package_apt
---------------------------------------------------------------------------------
+ # Same but install specific version
+ __package vim --state present --version 7.3.50
+
+ # Force use of a specific package type
+ __package vim --state present --type __package_apt
SEE ALSO
--------
-- cdist-type(7)
+- `cdist-type(7) `_
COPYING
diff --git a/cdist/conf/type/__package/manifest b/cdist/conf/type/__package/manifest
index 0ebf0099..6b0daa98 100755
--- a/cdist/conf/type/__package/manifest
+++ b/cdist/conf/type/__package/manifest
@@ -19,7 +19,7 @@
#
#
# __package is an abstract type which dispatches to the lower level
-# __package_$name types which do the actual interaction with the packaging
+# __package_$type types which do the actual interaction with the packaging
# system.
#
@@ -32,8 +32,14 @@ else
case "$os" in
amazon|centos|fedora|redhat) type="yum" ;;
archlinux) type="pacman" ;;
- debian|ubuntu) type="apt" ;;
- freebsd) type="pkg_freebsd" ;;
+ debian|ubuntu|devuan) type="apt" ;;
+ freebsd)
+ if [ -n "$(cat "$__object/explorer/pkgng_exists")" ]; then
+ type="pkgng_freebsd"
+ else
+ type="pkg_freebsd"
+ fi
+ ;;
gentoo) type="emerge" ;;
suse) type="zypper" ;;
openwrt) type="opkg" ;;
diff --git a/cdist/conf/type/__package_apt/gencode-remote b/cdist/conf/type/__package_apt/gencode-remote
index 57339db3..ef313070 100755
--- a/cdist/conf/type/__package_apt/gencode-remote
+++ b/cdist/conf/type/__package_apt/gencode-remote
@@ -27,12 +27,16 @@ else
name="$__object_id"
fi
-if [ -f "$__object/parameter/state" ]; then
- state_should="$(cat "$__object/parameter/state")"
+state_should="$(cat "$__object/parameter/state")"
+
+if [ -f "$__object/parameter/target-release" ]; then
+ target_release="--target-release $(cat "$__object/parameter/target-release")"
else
- state_should="present"
+ target_release=""
fi
+
+
# FIXME: use grep directly, state is a list, not a line!
state_is="$(cat "$__object/explorer/state")"
case "$state_is" in
@@ -44,13 +48,13 @@ esac
# Hint if we need to avoid questions at some point:
# DEBIAN_PRIORITY=critical can reduce the number of questions
-aptget="DEBIAN_FRONTEND=noninteractive apt-get --quiet --yes --no-install-recommends -o DPkg::Options::=\"--force-confold\""
+aptget="DEBIAN_FRONTEND=noninteractive apt-get --quiet --yes --no-install-recommends -o Dpkg::Options::=\"--force-confdef\" -o Dpkg::Options::=\"--force-confold\""
[ "$state_is" = "$state_should" ] && exit 0
case "$state_should" in
present)
- echo $aptget install \"$name\"
+ echo $aptget install $target_release \"$name\"
;;
absent)
echo $aptget remove \"$name\"
diff --git a/cdist/conf/type/__package_apt/man.text b/cdist/conf/type/__package_apt/man.rst
similarity index 53%
rename from cdist/conf/type/__package_apt/man.text
rename to cdist/conf/type/__package_apt/man.rst
index 5d4656c1..ec28c0cc 100644
--- a/cdist/conf/type/__package_apt/man.text
+++ b/cdist/conf/type/__package_apt/man.rst
@@ -1,13 +1,10 @@
cdist-type__package_apt(7)
==========================
+Manage packages with apt-get
+
Nico Schottelius
-NAME
-----
-cdist-type__package_apt - Manage packages with apt-get
-
-
DESCRIPTION
-----------
apt-get is usually used on Debian and variants (like Ubuntu) to
@@ -21,32 +18,35 @@ None
OPTIONAL PARAMETERS
-------------------
-name::
+name
If supplied, use the name and not the object id as the package name.
-state::
+state
Either "present" or "absent", defaults to "present"
+target-release
+ Passed on to apt-get install, see apt-get(8).
+ Essentially allows you to retrieve packages from a different release
EXAMPLES
--------
---------------------------------------------------------------------------------
-# Ensure zsh in installed
-__package_apt zsh --state present
+.. code-block:: sh
-# In case you only want *a* webserver, but don't care which one
-__package_apt webserver --state present --name nginx
+ # Ensure zsh in installed
+ __package_apt zsh --state present
-# Remove obsolete package
-__package_apt puppet --state absent
---------------------------------------------------------------------------------
+ # In case you only want *a* webserver, but don't care which one
+ __package_apt webserver --state present --name nginx
+
+ # Remove obsolete package
+ __package_apt puppet --state absent
SEE ALSO
--------
-- cdist-type(7)
-- cdist-type__package(7)
+- `cdist-type(7) `_
+- `cdist-type__package(7) `_
COPYING
diff --git a/cdist/conf/type/__package_apt/parameter/default/state b/cdist/conf/type/__package_apt/parameter/default/state
new file mode 100644
index 00000000..e7f6134f
--- /dev/null
+++ b/cdist/conf/type/__package_apt/parameter/default/state
@@ -0,0 +1 @@
+present
diff --git a/cdist/conf/type/__package_apt/parameter/optional b/cdist/conf/type/__package_apt/parameter/optional
index 41b8e6cf..d6674f95 100644
--- a/cdist/conf/type/__package_apt/parameter/optional
+++ b/cdist/conf/type/__package_apt/parameter/optional
@@ -1,3 +1,4 @@
name
version
state
+target-release
diff --git a/cdist/conf/type/__package_emerge/gencode-remote b/cdist/conf/type/__package_emerge/gencode-remote
index d4cee37e..1199fc72 100644
--- a/cdist/conf/type/__package_emerge/gencode-remote
+++ b/cdist/conf/type/__package_emerge/gencode-remote
@@ -27,37 +27,40 @@ else
name="$__object_id"
fi
-if [ -f "$__object/parameter/state" ]; then
- state_should="$(cat "$__object/parameter/state")"
-else
- state_should="present"
+state_should="$(cat "$__object/parameter/state")"
+
+version="$(cat "$__object/parameter/version")"
+
+if [ -n "$version" ]; then
+ name="=$name-$version"
fi
pkg_version="$(cat "$__object/explorer/pkg_version")"
if [ -z "$pkg_version" ]; then
state_is="absent"
-elif [ $(echo "$pkg_version" | wc -l) -gt 1 ]; then
+elif [ -z "$version" -a $(echo "$pkg_version" | wc -l) -gt 1 ]; then
+ echo "Package name is not unique! The following packages are installed:"
+ echo "$pkg_version"
+ exit 1
+elif [ -n "$version" -a $(echo "$pkg_version" | cut -d " " -f 1 | sort | uniq | wc -l) -gt 1 ]; then
echo "Package name is not unique! The following packages are installed:"
echo "$pkg_version"
exit 1
else
state_is="present"
- installed_version="$(echo "$pkg_version" | cut -d " " -f 2)"
+ if [ -n "$version" ] && echo "$pkg_version" | cut -d " " -f 2 | grep -q -x "$version"; then
+ installed_version="$(echo "$pkg_version" | cut -d " " -f 2 | grep -x "$version")"
+ else
+ installed_version="$(echo "$pkg_version" | cut -d " " -f 2 | tail -n 1)"
+ fi
fi
-if [ -f "$__object/parameter/version" ]; then
- version="$(cat "$__object/parameter/version")"
- if [ ! -z "$version" ]; then
- name="=$name-$version"
- fi
-else
- version=""
-fi
# Exit if nothing is needed to be done
[ "$state_is" = "$state_should" ] && ( [ -z "$version" ] || [ "$installed_version" = "$version" ] ) && exit 0
[ "$state_should" = "absent" ] && [ ! -z "$version" ] && [ "$installed_version" != "$version" ] && exit 0
+
case "$state_should" in
present)
echo "emerge \"$name\" &>/dev/null || exit 1"
diff --git a/cdist/conf/type/__package_emerge/man.text b/cdist/conf/type/__package_emerge/man.rst
similarity index 58%
rename from cdist/conf/type/__package_emerge/man.text
rename to cdist/conf/type/__package_emerge/man.rst
index 983b49a8..fe06031e 100644
--- a/cdist/conf/type/__package_emerge/man.text
+++ b/cdist/conf/type/__package_emerge/man.rst
@@ -1,13 +1,10 @@
cdist-type__package_emerge(7)
=============================
+Manage packages with portage
+
Thomas Oettli
-NAME
-----
-cdist-type__package_emerge - Manage packages with portage
-
-
DESCRIPTION
-----------
Portage is usually used on the gentoo distribution to manage packages.
@@ -23,35 +20,35 @@ None
OPTIONAL PARAMETERS
-------------------
-name::
+name
If supplied, use the name and not the object id as the package name.
-state::
+state
Either "present" or "absent", defaults to "present".
-version::
+version
If supplied, use to install or uninstall a specific version of the package named.
EXAMPLES
--------
---------------------------------------------------------------------------------
-# Ensure sys-devel/gcc is installed
-__package_emerge sys-devel/gcc --state present
+.. code-block:: sh
-# If you want a specific version of a package
-__package_emerge app-portage/gentoolkit --state present --version 0.3.0.8-r2
+ # Ensure sys-devel/gcc is installed
+ __package_emerge sys-devel/gcc --state present
-# Remove package
-__package_emerge sys-devel/gcc --state absent
---------------------------------------------------------------------------------
+ # If you want a specific version of a package
+ __package_emerge app-portage/gentoolkit --state present --version 0.3.0.8-r2
+
+ # Remove package
+ __package_emerge sys-devel/gcc --state absent
SEE ALSO
--------
-- cdist-type(7)
-- cdist-type__package(7)
-- cdist-type__package_emerge_dependencies(7)
+- `cdist-type(7) `_
+- `cdist-type__package(7) `_
+- `cdist-type__package_emerge_dependencies(7) `_
COPYING
diff --git a/cdist/conf/type/__package_emerge/parameter/default/state b/cdist/conf/type/__package_emerge/parameter/default/state
new file mode 100644
index 00000000..e7f6134f
--- /dev/null
+++ b/cdist/conf/type/__package_emerge/parameter/default/state
@@ -0,0 +1 @@
+present
diff --git a/cdist/test/cdist_object/fixtures/object/__second/.keep b/cdist/conf/type/__package_emerge/parameter/default/version
similarity index 100%
rename from cdist/test/cdist_object/fixtures/object/__second/.keep
rename to cdist/conf/type/__package_emerge/parameter/default/version
diff --git a/cdist/conf/type/__package_emerge_dependencies/man.text b/cdist/conf/type/__package_emerge_dependencies/man.rst
similarity index 55%
rename from cdist/conf/type/__package_emerge_dependencies/man.text
rename to cdist/conf/type/__package_emerge_dependencies/man.rst
index 0862256b..21af86e3 100644
--- a/cdist/conf/type/__package_emerge_dependencies/man.text
+++ b/cdist/conf/type/__package_emerge_dependencies/man.rst
@@ -1,19 +1,17 @@
cdist-type__package_emerge_dependencies(7)
==========================================
+Install dependencies for __package_emerge
+
Thomas Oettli
-NAME
-----
-cdist-type__package_emerge_dependencies - Install dependencies for __package_emerge
-
-
DESCRIPTION
-----------
Portage is usually used on the gentoo distribution to manage packages.
This type installs the following tools which are required by __package_emerge to work:
-app-portage/flaggie
-app-portage/gentoolkit
+
+* app-portage/flaggie
+* app-portage/gentoolkit
REQUIRED PARAMETERS
@@ -29,17 +27,17 @@ None
EXAMPLES
--------
---------------------------------------------------------------------------------
-# Ensure app-portage/flaggie and app-portage/gentoolkit are installed
-__package_emerge_dependencies
---------------------------------------------------------------------------------
+.. code-block:: sh
+
+ # Ensure app-portage/flaggie and app-portage/gentoolkit are installed
+ __package_emerge_dependencies
SEE ALSO
--------
-- cdist-type(7)
-- cdist-type__package(7)
-- cdist-type__package_emerge(7)
+- `cdist-type(7) `_
+- `cdist-type__package(7) `_
+- `cdist-type__package_emerge(7) `_
COPYING
diff --git a/cdist/conf/type/__package_luarocks/gencode-remote b/cdist/conf/type/__package_luarocks/gencode-remote
index 7a5a5b04..1046a936 100755
--- a/cdist/conf/type/__package_luarocks/gencode-remote
+++ b/cdist/conf/type/__package_luarocks/gencode-remote
@@ -29,11 +29,7 @@ else
name="$__object_id"
fi
-if [ -f "$__object/parameter/state" ]; then
- state_should="$(cat "$__object/parameter/state")"
-else
- state_should="present"
-fi
+state_should="$(cat "$__object/parameter/state")"
if grep -q "(installed)" "$__object/explorer/pkg_status"; then
state_is="present"
diff --git a/cdist/conf/type/__package_luarocks/man.text b/cdist/conf/type/__package_luarocks/man.rst
similarity index 59%
rename from cdist/conf/type/__package_luarocks/man.text
rename to cdist/conf/type/__package_luarocks/man.rst
index 657f68e5..ff7fea83 100644
--- a/cdist/conf/type/__package_luarocks/man.text
+++ b/cdist/conf/type/__package_luarocks/man.rst
@@ -1,13 +1,10 @@
cdist-type__package_luarocks(7)
===============================
+Manage luarocks packages
+
Christian G. Warden
-NAME
-----
-cdist-type__package_luarocks - Manage luarocks packages
-
-
DESCRIPTION
-----------
LuaRocks is a deployment and management system for Lua modules.
@@ -20,29 +17,29 @@ None
OPTIONAL PARAMETERS
-------------------
-name::
+name
If supplied, use the name and not the object id as the package name.
-state::
+state
Either "present" or "absent", defaults to "present"
EXAMPLES
--------
---------------------------------------------------------------------------------
-# Ensure luasocket is installed
-__package_luarocks luasocket --state present
+.. code-block:: sh
-# Remove package
-__package_luarocks luasocket --state absent
---------------------------------------------------------------------------------
+ # Ensure luasocket is installed
+ __package_luarocks luasocket --state present
+
+ # Remove package
+ __package_luarocks luasocket --state absent
SEE ALSO
--------
-- cdist-type(7)
-- cdist-type__package(7)
+- `cdist-type(7) `_
+- `cdist-type__package(7) `_
COPYING
diff --git a/cdist/conf/type/__package_luarocks/parameter/default/state b/cdist/conf/type/__package_luarocks/parameter/default/state
new file mode 100644
index 00000000..e7f6134f
--- /dev/null
+++ b/cdist/conf/type/__package_luarocks/parameter/default/state
@@ -0,0 +1 @@
+present
diff --git a/cdist/conf/type/__package_opkg/gencode-remote b/cdist/conf/type/__package_opkg/gencode-remote
index 1fb78fbe..2df31202 100755
--- a/cdist/conf/type/__package_opkg/gencode-remote
+++ b/cdist/conf/type/__package_opkg/gencode-remote
@@ -28,11 +28,7 @@ else
name="$__object_id"
fi
-if [ -f "$__object/parameter/state" ]; then
- state_should="$(cat "$__object/parameter/state")"
-else
- state_should="present"
-fi
+state_should="$(cat "$__object/parameter/state")"
state_is="$(cat "$__object/explorer/pkg_status")"
case "$state_is" in
diff --git a/cdist/conf/type/__package_opkg/man.text b/cdist/conf/type/__package_opkg/man.rst
similarity index 57%
rename from cdist/conf/type/__package_opkg/man.text
rename to cdist/conf/type/__package_opkg/man.rst
index aeb0a1c5..9af17988 100644
--- a/cdist/conf/type/__package_opkg/man.text
+++ b/cdist/conf/type/__package_opkg/man.rst
@@ -1,13 +1,10 @@
cdist-type__package_opkg(7)
-==========================
+===========================
+Manage packages with opkg
+
Giel van Schijndel
-NAME
-----
-cdist-type__package_opkg - Manage packages with opkg
-
-
DESCRIPTION
-----------
opkg is usually used on OpenWRT to manage packages.
@@ -20,29 +17,29 @@ None
OPTIONAL PARAMETERS
-------------------
-name::
+name
If supplied, use the name and not the object id as the package name.
-state::
+state
Either "present" or "absent", defaults to "present"
EXAMPLES
--------
---------------------------------------------------------------------------------
-# Ensure lsof is installed
-__package_opkg lsof --state present
+.. code-block:: sh
-# Remove obsolete package
-__package_opkg dnsmasq --state absent
---------------------------------------------------------------------------------
+ # Ensure lsof is installed
+ __package_opkg lsof --state present
+
+ # Remove obsolete package
+ __package_opkg dnsmasq --state absent
SEE ALSO
--------
-- cdist-type(7)
-- cdist-type__package(7)
+- `cdist-type(7) `_
+- `cdist-type__package(7) `_
COPYING
diff --git a/cdist/conf/type/__package_opkg/parameter/default/state b/cdist/conf/type/__package_opkg/parameter/default/state
new file mode 100644
index 00000000..e7f6134f
--- /dev/null
+++ b/cdist/conf/type/__package_opkg/parameter/default/state
@@ -0,0 +1 @@
+present
diff --git a/cdist/conf/type/__package_pacman/gencode-remote b/cdist/conf/type/__package_pacman/gencode-remote
index 02744fa8..da1ac7c2 100755
--- a/cdist/conf/type/__package_pacman/gencode-remote
+++ b/cdist/conf/type/__package_pacman/gencode-remote
@@ -31,11 +31,7 @@ else
name="$__object_id"
fi
-if [ -f "$__object/parameter/state" ]; then
- state_should="$(cat "$__object/parameter/state")"
-else
- state_should="present"
-fi
+state_should="$(cat "$__object/parameter/state")"
pkg_version="$(cat "$__object/explorer/pkg_version")"
if [ -z "$pkg_version" ]; then
diff --git a/cdist/conf/type/__package_pacman/man.text b/cdist/conf/type/__package_pacman/man.rst
similarity index 54%
rename from cdist/conf/type/__package_pacman/man.text
rename to cdist/conf/type/__package_pacman/man.rst
index 2e24ecd9..3d8845a5 100644
--- a/cdist/conf/type/__package_pacman/man.text
+++ b/cdist/conf/type/__package_pacman/man.rst
@@ -1,13 +1,10 @@
cdist-type__package_pacman(7)
=============================
+Manage packages with pacman
+
Nico Schottelius
-NAME
-----
-cdist-type__package_pacman - Manage packages with pacman
-
-
DESCRIPTION
-----------
Pacman is usually used on the Archlinux distribution to manage packages.
@@ -20,32 +17,32 @@ None
OPTIONAL PARAMETERS
-------------------
-name::
+name
If supplied, use the name and not the object id as the package name.
-state::
+state
Either "present" or "absent", defaults to "present"
EXAMPLES
--------
---------------------------------------------------------------------------------
-# Ensure zsh in installed
-__package_pacman zsh --state present
+.. code-block:: sh
-# If you don't want to follow pythonX packages, but always use python
-__package_pacman python --state present --name python2
+ # Ensure zsh in installed
+ __package_pacman zsh --state present
-# Remove obsolete package
-__package_pacman puppet --state absent
---------------------------------------------------------------------------------
+ # If you don't want to follow pythonX packages, but always use python
+ __package_pacman python --state present --name python2
+
+ # Remove obsolete package
+ __package_pacman puppet --state absent
SEE ALSO
--------
-- cdist-type(7)
-- cdist-type__package(7)
+- `cdist-type(7) `_
+- `cdist-type__package(7) `_
COPYING
diff --git a/cdist/conf/type/__package_pacman/parameter/default/state b/cdist/conf/type/__package_pacman/parameter/default/state
new file mode 100644
index 00000000..e7f6134f
--- /dev/null
+++ b/cdist/conf/type/__package_pacman/parameter/default/state
@@ -0,0 +1 @@
+present
diff --git a/cdist/conf/type/__package_pip/gencode-remote b/cdist/conf/type/__package_pip/gencode-remote
index ec1c89f8..ccfdb92b 100644
--- a/cdist/conf/type/__package_pip/gencode-remote
+++ b/cdist/conf/type/__package_pip/gencode-remote
@@ -1,6 +1,7 @@
#!/bin/sh
#
# 2012 Nico Schottelius (nico-cdist at schottelius.org)
+# 2016 Darko Poljak (darko.poljak at gmail.com)
#
# This file is part of cdist.
#
@@ -22,11 +23,7 @@
#
state_is=$(cat "$__object/explorer/state")
-if [ -f "$__object/parameter/state" ]; then
- state_should="$(cat "$__object/parameter/state")"
-else
- state_should="present"
-fi
+state_should="$(cat "$__object/parameter/state")"
[ "$state_is" = "$state_should" ] && exit 0
@@ -44,12 +41,30 @@ else
pip="pip"
fi
+runasparam="$__object/parameter/runas"
+if [ -f "$runasparam" ]
+then
+ runas=$(cat "$runasparam")
+else
+ runas=""
+fi
+
case "$state_should" in
present)
- echo $pip install -q "$name"
+ if [ "$runas" ]
+ then
+ echo "su -c \"$pip install -q $name\" $runas"
+ else
+ echo $pip install -q "$name"
+ fi
;;
absent)
- echo $pip uninstall -q -y "$name"
+ if [ "$runas" ]
+ then
+ echo "su -c \"$pip uninstall -q -y $name\" $runas"
+ else
+ echo $pip uninstall -q -y "$name"
+ fi
;;
*)
echo "Unknown state: $state_should" >&2
diff --git a/cdist/conf/type/__package_pip/man.text b/cdist/conf/type/__package_pip/man.rst
similarity index 55%
rename from cdist/conf/type/__package_pip/man.text
rename to cdist/conf/type/__package_pip/man.rst
index 5f619871..b312fff5 100644
--- a/cdist/conf/type/__package_pip/man.text
+++ b/cdist/conf/type/__package_pip/man.rst
@@ -1,13 +1,10 @@
cdist-type__package_pip(7)
==========================
+Manage packages with pip
+
Nico Schottelius
-NAME
-----
-cdist-type__package_pip - Manage packages with pip
-
-
DESCRIPTION
-----------
Pip is used in Python environments to install packages.
@@ -21,32 +18,38 @@ None
OPTIONAL PARAMETERS
-------------------
-name::
+name
If supplied, use the name and not the object id as the package name.
-pip::
+pip
Instead of using pip from PATH, use the specific pip path.
-state::
+state
Either "present" or "absent", defaults to "present"
+runas
+ Run pip as specified user. By default it runs as root.
+
EXAMPLES
--------
---------------------------------------------------------------------------------
-# Install a package
-__package_pip pyro --state present
+.. code-block:: sh
-# Use pip in a virtualenv located at /root/shinken_virtualenv
-__package_pip pyro --state present --pip /root/shinken_virtualenv/bin/pip
---------------------------------------------------------------------------------
+ # Install a package
+ __package_pip pyro --state present
+
+ # Use pip in a virtualenv located at /root/shinken_virtualenv
+ __package_pip pyro --state present --pip /root/shinken_virtualenv/bin/pip
+
+ # Use pip in a virtualenv located at /foo/shinken_virtualenv as user foo
+ __package_pip pyro --state present --pip /foo/shinken_virtualenv/bin/pip --runas foo
SEE ALSO
--------
-- cdist-type(7)
-- cdist-type__package(7)
+- `cdist-type(7) `_
+- `cdist-type__package(7) `_
COPYING
diff --git a/cdist/conf/type/__package_pip/parameter/default/state b/cdist/conf/type/__package_pip/parameter/default/state
new file mode 100644
index 00000000..e7f6134f
--- /dev/null
+++ b/cdist/conf/type/__package_pip/parameter/default/state
@@ -0,0 +1 @@
+present
diff --git a/cdist/conf/type/__package_pip/parameter/optional b/cdist/conf/type/__package_pip/parameter/optional
index f32876f7..d909e790 100644
--- a/cdist/conf/type/__package_pip/parameter/optional
+++ b/cdist/conf/type/__package_pip/parameter/optional
@@ -1,2 +1,4 @@
+name
pip
state
+runas
diff --git a/cdist/conf/type/__package_pkg_freebsd/gencode-remote b/cdist/conf/type/__package_pkg_freebsd/gencode-remote
index 3f5ebde7..5866a0a8 100755
--- a/cdist/conf/type/__package_pkg_freebsd/gencode-remote
+++ b/cdist/conf/type/__package_pkg_freebsd/gencode-remote
@@ -51,23 +51,10 @@ else
name="$__object_id"
fi
-if [ -f "$__object/parameter/flavor" ]; then
- flavor="$(cat "$__object/parameter/flavor")"
-fi
-
-if [ -f "$__object/parameter/version" ]; then
- version="$(cat "$__object/parameter/version")"
-fi
-
-if [ -f "$__object/parameter/pkgsite" ]; then
- pkgsite="$(cat "$__object/parameter/pkgsite")"
-fi
-
-if [ -f "$__object/parameter/state" ]; then
- state="$(cat "$__object/parameter/state")"
-else
- state="present"
-fi
+flavor="$(cat "$__object/parameter/flavor")"
+version="$(cat "$__object/parameter/version")"
+pkgsite="$(cat "$__object/parameter/pkgsite")"
+state="$(cat "$__object/parameter/state")"
curr_version="$(cat "$__object/explorer/pkg_version")"
add_cmd="pkg_add"
rm_cmd="pkg_delete"
diff --git a/cdist/conf/type/__package_pkg_freebsd/man.text b/cdist/conf/type/__package_pkg_freebsd/man.rst
similarity index 53%
rename from cdist/conf/type/__package_pkg_freebsd/man.text
rename to cdist/conf/type/__package_pkg_freebsd/man.rst
index 71387148..c728cc9a 100644
--- a/cdist/conf/type/__package_pkg_freebsd/man.text
+++ b/cdist/conf/type/__package_pkg_freebsd/man.rst
@@ -1,13 +1,10 @@
cdist-type__package_pkg_freebsd(7)
==================================
+Manage FreeBSD packages
+
Jake Guffey
-NAME
-----
-cdist-type__package_pkg_freebsd - Manage FreeBSD packages
-
-
DESCRIPTION
-----------
This type is usually used on FreeBSD to manage packages.
@@ -20,44 +17,44 @@ None
OPTIONAL PARAMETERS
-------------------
-name::
+name
If supplied, use the name and not the object id as the package name.
-flavor::
+flavor
If supplied, use to avoid ambiguity.
-version::
+version
If supplied, use to install a specific version of the package named.
-pkgsite::
+pkgsite
If supplied, use to install from a specific package repository.
-state::
+state
Either "present" or "absent", defaults to "present"
EXAMPLES
--------
---------------------------------------------------------------------------------
-# Ensure zsh is installed
-__package_pkg_freebsd zsh --state present
+.. code-block:: sh
-# Ensure vim is installed, use flavor no_x11
-__package_pkg_freebsd vim --state present --flavor no_x11
+ # Ensure zsh is installed
+ __package_pkg_freebsd zsh --state present
-# If you don't want to follow pythonX packages, but always use python
-__package_pkg_freebsd python --state present --name python2
+ # Ensure vim is installed, use flavor no_x11
+ __package_pkg_freebsd vim --state present --flavor no_x11
-# Remove obsolete package
-__package_pkg_freebsd puppet --state absent
---------------------------------------------------------------------------------
+ # If you don't want to follow pythonX packages, but always use python
+ __package_pkg_freebsd python --state present --name python2
+
+ # Remove obsolete package
+ __package_pkg_freebsd puppet --state absent
SEE ALSO
--------
-- cdist-type(7)
-- cdist-type__package(7)
+- `cdist-type(7) `_
+- `cdist-type__package(7) `_
COPYING
diff --git a/cdist/test/cdist_object/fixtures/object/__second/on-the/.cdist/.keep b/cdist/conf/type/__package_pkg_freebsd/parameter/default/flavor
similarity index 100%
rename from cdist/test/cdist_object/fixtures/object/__second/on-the/.cdist/.keep
rename to cdist/conf/type/__package_pkg_freebsd/parameter/default/flavor
diff --git a/cdist/test/cdist_object/fixtures/object/__second/under-the/.cdist/.keep b/cdist/conf/type/__package_pkg_freebsd/parameter/default/pkgsite
similarity index 100%
rename from cdist/test/cdist_object/fixtures/object/__second/under-the/.cdist/.keep
rename to cdist/conf/type/__package_pkg_freebsd/parameter/default/pkgsite
diff --git a/cdist/conf/type/__package_pkg_freebsd/parameter/default/state b/cdist/conf/type/__package_pkg_freebsd/parameter/default/state
new file mode 100644
index 00000000..e7f6134f
--- /dev/null
+++ b/cdist/conf/type/__package_pkg_freebsd/parameter/default/state
@@ -0,0 +1 @@
+present
diff --git a/cdist/test/cdist_object/fixtures/object/__third/.keep b/cdist/conf/type/__package_pkg_freebsd/parameter/default/version
similarity index 100%
rename from cdist/test/cdist_object/fixtures/object/__third/.keep
rename to cdist/conf/type/__package_pkg_freebsd/parameter/default/version
diff --git a/cdist/conf/type/__package_pkg_openbsd/gencode-remote b/cdist/conf/type/__package_pkg_openbsd/gencode-remote
index 08e15e89..dea7f711 100755
--- a/cdist/conf/type/__package_pkg_openbsd/gencode-remote
+++ b/cdist/conf/type/__package_pkg_openbsd/gencode-remote
@@ -42,11 +42,7 @@ else
name="$__object_id"
fi
-if [ -f "$__object/parameter/state" ]; then
- state_should="$(cat "$__object/parameter/state")"
-else
- state_should="present"
-fi
+state_should="$(cat "$__object/parameter/state")"
pkg_version="$(cat "$__object/explorer/pkg_version")"
diff --git a/cdist/conf/type/__package_pkg_openbsd/man.rst b/cdist/conf/type/__package_pkg_openbsd/man.rst
new file mode 100644
index 00000000..f9a746b9
--- /dev/null
+++ b/cdist/conf/type/__package_pkg_openbsd/man.rst
@@ -0,0 +1,63 @@
+cdist-type__package_pkg(7)
+==========================
+Manage OpenBSD packages
+
+Andi Brönnimann
+
+
+DESCRIPTION
+-----------
+This type is usually used on OpenBSD to manage packages.
+
+
+REQUIRED PARAMETERS
+-------------------
+None
+
+
+OPTIONAL PARAMETERS
+-------------------
+name
+ If supplied, use the name and not the object id as the package name.
+
+flavor
+ If supplied, use to avoid ambiguity.
+
+state
+ Either "present" or "absent", defaults to "present"
+
+pkg_path
+ Manually specify a PKG_PATH to add packages from.
+
+EXAMPLES
+--------
+
+.. code-block:: sh
+
+ # Ensure zsh is installed
+ __package_pkg_openbsd zsh --state present
+
+ # Ensure vim is installed, use flavor no_x11
+ __package_pkg_openbsd vim --state present --flavor no_x11
+
+ # If you don't want to follow pythonX packages, but always use python
+ __package_pkg_openbsd python --state present --name python2
+
+ # Remove obsolete package
+ __package_pkg_openbsd puppet --state absent
+
+ # Add a package using a particular mirror
+ __package_pkg_openbsd bash \
+ --pkg_path http://openbsd.mirrorcatalogs.com/snapshots/packages/amd64
+
+
+SEE ALSO
+--------
+- `cdist-type(7) `_
+- `cdist-type__package(7) `_
+
+
+COPYING
+-------
+Copyright \(C) 2011 Andi Brönnimann. Free use of this software is
+granted under the terms of the GNU General Public License version 3 (GPLv3).
diff --git a/cdist/conf/type/__package_pkg_openbsd/man.text b/cdist/conf/type/__package_pkg_openbsd/man.text
deleted file mode 100644
index c7de2652..00000000
--- a/cdist/conf/type/__package_pkg_openbsd/man.text
+++ /dev/null
@@ -1,66 +0,0 @@
-cdist-type__package_pkg(7)
-==========================
-Andi Brönnimann
-
-
-NAME
-----
-cdist-type__package_pkg_openbsd - Manage OpenBSD packages
-
-
-DESCRIPTION
------------
-This type is usually used on OpenBSD to manage packages.
-
-
-REQUIRED PARAMETERS
--------------------
-None
-
-
-OPTIONAL PARAMETERS
--------------------
-name::
- If supplied, use the name and not the object id as the package name.
-
-flavor::
- If supplied, use to avoid ambiguity.
-
-state::
- Either "present" or "absent", defaults to "present"
-
-pkg_path::
- Manually specify a PKG_PATH to add packages from.
-
-EXAMPLES
---------
-
---------------------------------------------------------------------------------
-# Ensure zsh is installed
-__package_pkg_openbsd zsh --state present
-
-# Ensure vim is installed, use flavor no_x11
-__package_pkg_openbsd vim --state present --flavor no_x11
-
-# If you don't want to follow pythonX packages, but always use python
-__package_pkg_openbsd python --state present --name python2
-
-# Remove obsolete package
-__package_pkg_openbsd puppet --state absent
-
-# Add a package using a particular mirror
-__package_pkg_openbsd bash \
- --pkg_path http://openbsd.mirrorcatalogs.com/snapshots/packages/amd64
---------------------------------------------------------------------------------
-
-
-SEE ALSO
---------
-- cdist-type(7)
-- cdist-type__package(7)
-
-
-COPYING
--------
-Copyright \(C) 2011 Andi Brönnimann. Free use of this software is
-granted under the terms of the GNU General Public License version 3 (GPLv3).
diff --git a/cdist/conf/type/__package_pkg_openbsd/parameter/default/state b/cdist/conf/type/__package_pkg_openbsd/parameter/default/state
new file mode 100644
index 00000000..e7f6134f
--- /dev/null
+++ b/cdist/conf/type/__package_pkg_openbsd/parameter/default/state
@@ -0,0 +1 @@
+present
diff --git a/cdist/conf/type/__package_pkgng_freebsd/explorer/pkg_version b/cdist/conf/type/__package_pkgng_freebsd/explorer/pkg_version
new file mode 100755
index 00000000..947857b9
--- /dev/null
+++ b/cdist/conf/type/__package_pkgng_freebsd/explorer/pkg_version
@@ -0,0 +1,37 @@
+#!/bin/sh
+#
+# 2014 Jake Guffey (jake.guffey at eprotex.com)
+#
+# This file is part of cdist.
+#
+# cdist is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# cdist is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with cdist. If not, see .
+#
+#
+# Retrieve the status of a package - parsed dpkg output
+#
+
+if [ -f "$__object/parameter/name" ]; then
+ name="$(cat "$__object/parameter/name")"
+else
+ name="$__object_id"
+fi
+
+# Don't produce "no pkgs installed" output -- breaks things
+PKG_OUTPUT=$(pkg info 2>&1)
+echo -n "$(echo "$PKG_OUTPUT" \
+ | awk '{print $1}' \
+ | sed 's/^\(.*\)-\([^-]*\)$/name:\1 ver:\2/g' \
+ | grep "name:$name ver:" \
+ | sed 's/^.*ver:\(.*\)/\1/g')"
+
diff --git a/cdist/conf/type/__package_pkgng_freebsd/gencode-remote b/cdist/conf/type/__package_pkgng_freebsd/gencode-remote
new file mode 100755
index 00000000..3c3e41e9
--- /dev/null
+++ b/cdist/conf/type/__package_pkgng_freebsd/gencode-remote
@@ -0,0 +1,127 @@
+#!/bin/sh
+#
+# 2014 Jake Guffey (jake.guffey at eprotex.com)
+#
+# This file is part of cdist.
+#
+# cdist is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# cdist is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with cdist. If not, see .
+#
+#
+# Manage packages with pkg on FreeBSD
+#
+
+# Debug
+#exec >&2
+#set -x
+
+if [ -f "$__object/parameter/name" ]; then
+ name="$(cat "$__object/parameter/name")"
+else
+ name="$__object_id"
+fi
+
+flavor="$(cat "$__object/parameter/flavor")"
+version="$(cat "$__object/parameter/version")"
+
+if [ -f "$__object/parameter/upgrade" ]; then
+ upgrade="true"
+else
+ upgrade="false"
+fi
+
+repo="$(cat "$__object/parameter/repo")"
+state="$(cat "$__object/parameter/state")"
+curr_version="$(cat "$__object/explorer/pkg_version")"
+add_cmd="pkg install -y"
+rm_cmd="pkg delete -y"
+upg_cmd="pkg upgrade -y"
+cmd=""
+
+# Print the command to be executed
+# Parms: $1 -- mode, "rm", "add", or "upg"
+# $2 -- the command to be echoed
+execcmd(){
+ local _cmd=""
+
+ case "$1" in
+ add)
+ _cmd="${add_cmd} $2"
+ ;;
+ rm)
+ _cmd="${rm_cmd} $2"
+ ;;
+ upg)
+ _cmd="${upg_cmd} $2"
+ ;;
+ *)
+ printf "Error. Don't understand command: %s" "$1" >&2
+ exit 1
+ ;;
+ esac
+
+ echo "$_cmd 2>&- >&-" # Silence the output of the command
+ echo "status=\$?"
+ echo "if [ \"\$status\" -ne \"0\" ]; then"
+ echo " echo \"Error: ${_cmd} exited nonzero with \$status\"'!' >&2"
+ echo " exit 1"
+ echo "fi"
+}
+
+if [ -n "$curr_version" ]; then # PKG *is* installed
+ if [ -n "$repo" ]; then
+ cmd="-r ${repo} ${name}"
+ else
+ cmd="${name}"
+ fi
+ if [ -n "$flavor" ]; then
+ cmd="${cmd}-${flavor}"
+ fi
+ # PKG is supposed to be removed
+ if [ "$state" = "absent" ]; then
+ execcmd "rm" "${cmd}"
+ # PKG is supposed to be installed to a particular version
+ elif [ -n "$version" ] && [ "$version" != "$curr_version" ]; then
+ if [ "$upgrade" = "true" ]; then
+ execcmd "upg" "${cmd}"
+ else
+ printf "Version %s is already installed and pkg-ng can't upgrade directly to version %s.\nTo upgrade to the latest version, use the --upgrade flag.\n" "$curr_version" "$version" >&2
+ exit 1
+ fi
+ # PKG is supposed to be installed to the latest version
+ else
+ : # Do nothing.
+ fi
+else # PKG *isn't* installed
+ if [ "$state" = "absent" ]; then # Shouldn't be installed
+ exit 0
+ else # Should be installed
+ if [ -n "$repo" ]; then
+ cmd="-r ${repo} ${name}"
+ else
+ cmd="${name}"
+ fi
+ if [ -n "$flavor" ]; then
+ cmd="${cmd}-${flavor}"
+ fi
+ if [ -n "$version" ]; then
+ cmd="${cmd}-${version}"
+ fi
+
+ execcmd "add" "$cmd"
+ exit 0
+ fi
+fi
+
+# Debug
+#set +x
diff --git a/cdist/conf/type/__package_pkgng_freebsd/man.rst b/cdist/conf/type/__package_pkgng_freebsd/man.rst
new file mode 100644
index 00000000..36f1a7d8
--- /dev/null
+++ b/cdist/conf/type/__package_pkgng_freebsd/man.rst
@@ -0,0 +1,94 @@
+cdist-type__package_pkgng_freebsd(7)
+====================================
+Manage FreeBSD packages with pkg-ng
+
+Jake Guffey
+
+
+DESCRIPTION
+-----------
+This type is usually used on FreeBSD to manage packages.
+
+
+REQUIRED PARAMETERS
+-------------------
+None
+
+
+OPTIONAL PARAMETERS
+-------------------
+name
+ If supplied, use the name and not the object id as the package name.
+
+flavor
+ If supplied, use to avoid ambiguity.
+
+version
+ If supplied, use to install a specific version of the package named.
+
+repo
+ If supplied, use to install the package named from a particular repo.
+
+state
+ Either "present" or "absent", defaults to "present"
+
+
+BOOLEAN PARAMETERS
+------------------
+upgrade
+ If supplied, allow upgrading to the latest version of a package.
+
+
+CAVEATS
+-------
+This type requires that repository definitions already exist in /etc/pkg/\*.conf.
+Ensure that they exist prior to use of this type with __file.
+
+pkg-ng can't upgrade a package to a specific version. If this type needs to
+upgrade a package, it can only ugprade to the latest available version. If the
+"upgrade" parameter is not given and an upgrade needs to occur, an error will result.
+
+
+MESSAGES
+--------
+install
+ The package was installed
+remove
+ The package was removed
+upgrade
+ The package was upgraded
+exist
+ The package was already present and thus not installed
+
+
+EXAMPLES
+--------
+
+.. code-block:: sh
+
+ # Ensure zsh is installed
+ __package_pkgng_freebsd zsh --state present
+
+ # Ensure vim is installed, use flavor no_x11
+ __package_pkgng_freebsd vim --state present --flavor no_x11
+
+ # If you don't want to follow pythonX packages, but always use python
+ __package_pkgng_freebsd python --state present --name python2
+
+ # Install a package from a particular repository when multiples exist
+ __package_pkgng_freebsd bash --state present --repo myrepo
+
+ # Remove obsolete package
+ __package_pkgng_freebsd puppet --state absent
+
+
+SEE ALSO
+--------
+- `cdist-type(7) `_
+- `cdist-type__package(7) `_
+
+
+COPYING
+-------
+Copyright \(C) 2014 Jake Guffey. Free use of this software is
+granted under the terms of the GNU General Public License version 3 (GPLv3).
diff --git a/cdist/conf/type/__package_pkgng_freebsd/parameter/boolean b/cdist/conf/type/__package_pkgng_freebsd/parameter/boolean
new file mode 100644
index 00000000..007ead00
--- /dev/null
+++ b/cdist/conf/type/__package_pkgng_freebsd/parameter/boolean
@@ -0,0 +1 @@
+upgrade
\ No newline at end of file
diff --git a/cdist/test/cdist_object/fixtures/object/__third/moon/.cdist/.keep b/cdist/conf/type/__package_pkgng_freebsd/parameter/default/flavor
similarity index 100%
rename from cdist/test/cdist_object/fixtures/object/__third/moon/.cdist/.keep
rename to cdist/conf/type/__package_pkgng_freebsd/parameter/default/flavor
diff --git a/cdist/conf/type/__package_pkgng_freebsd/parameter/default/repo b/cdist/conf/type/__package_pkgng_freebsd/parameter/default/repo
new file mode 100644
index 00000000..e69de29b
diff --git a/cdist/conf/type/__package_pkgng_freebsd/parameter/default/state b/cdist/conf/type/__package_pkgng_freebsd/parameter/default/state
new file mode 100644
index 00000000..e7f6134f
--- /dev/null
+++ b/cdist/conf/type/__package_pkgng_freebsd/parameter/default/state
@@ -0,0 +1 @@
+present
diff --git a/cdist/conf/type/__package_pkgng_freebsd/parameter/default/version b/cdist/conf/type/__package_pkgng_freebsd/parameter/default/version
new file mode 100644
index 00000000..e69de29b
diff --git a/cdist/conf/type/__package_pkgng_freebsd/parameter/optional b/cdist/conf/type/__package_pkgng_freebsd/parameter/optional
new file mode 100644
index 00000000..6e67f838
--- /dev/null
+++ b/cdist/conf/type/__package_pkgng_freebsd/parameter/optional
@@ -0,0 +1,5 @@
+name
+flavor
+version
+repo
+state
diff --git a/cdist/conf/type/__package_rubygem/gencode-remote b/cdist/conf/type/__package_rubygem/gencode-remote
index 6256e308..dc755ad3 100755
--- a/cdist/conf/type/__package_rubygem/gencode-remote
+++ b/cdist/conf/type/__package_rubygem/gencode-remote
@@ -27,11 +27,7 @@ else
name="$__object_id"
fi
-if [ -f "$__object/parameter/state" ]; then
- state_should="$(cat "$__object/parameter/state")"
-else
- state_should="present"
-fi
+state_should="$(cat "$__object/parameter/state")"
if grep -q true "$__object/explorer/pkg_status"; then
state_is="present"
diff --git a/cdist/conf/type/__package_rubygem/man.text b/cdist/conf/type/__package_rubygem/man.rst
similarity index 60%
rename from cdist/conf/type/__package_rubygem/man.text
rename to cdist/conf/type/__package_rubygem/man.rst
index a808c2aa..4cb9af04 100644
--- a/cdist/conf/type/__package_rubygem/man.text
+++ b/cdist/conf/type/__package_rubygem/man.rst
@@ -1,13 +1,10 @@
cdist-type__package_rubygem(7)
==============================
+Manage rubygem packages
+
Chase Allen James
-NAME
-----
-cdist-type__package_rubygem - Manage rubygem packages
-
-
DESCRIPTION
-----------
Rubygems is the default package management system for the Ruby programming language.
@@ -20,29 +17,29 @@ None
OPTIONAL PARAMETERS
-------------------
-name::
+name
If supplied, use the name and not the object id as the package name.
-state::
+state
Either "present" or "absent", defaults to "present"
EXAMPLES
--------
---------------------------------------------------------------------------------
-# Ensure sinatra is installed
-__package_rubygem sinatra --state present
+.. code-block:: sh
-# Remove package
-__package_rubygem rails --state absent
---------------------------------------------------------------------------------
+ # Ensure sinatra is installed
+ __package_rubygem sinatra --state present
+
+ # Remove package
+ __package_rubygem rails --state absent
SEE ALSO
--------
-- cdist-type(7)
-- cdist-type__package(7)
+- `cdist-type(7) `_
+- `cdist-type__package(7) `_
COPYING
diff --git a/cdist/conf/type/__package_rubygem/parameter/default/state b/cdist/conf/type/__package_rubygem/parameter/default/state
new file mode 100644
index 00000000..e7f6134f
--- /dev/null
+++ b/cdist/conf/type/__package_rubygem/parameter/default/state
@@ -0,0 +1 @@
+present
diff --git a/cdist/conf/type/__package_update_index/gencode-remote b/cdist/conf/type/__package_update_index/gencode-remote
new file mode 100755
index 00000000..589e7202
--- /dev/null
+++ b/cdist/conf/type/__package_update_index/gencode-remote
@@ -0,0 +1,50 @@
+#!/bin/sh
+#
+# 2014 Ricardo Catalinas Jiménez (jimenezrick at gmail.com)
+#
+# This file is part of cdist.
+#
+# cdist is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# cdist is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with cdist. If not, see .
+#
+#
+# Update the package index with the appropriate package manager
+#
+
+type="$__object/parameter/type"
+
+if [ -f "$type" ]; then
+ type="$(cat "$type")"
+else
+ # By default determine package manager based on operating system
+ os="$(cat "$__global/explorer/os")"
+ case "$os" in
+ amazon|centos|fedora|redhat) type="yum" ;;
+ debian|ubuntu|devuan) type="apt" ;;
+ archlinux) type="pacman" ;;
+ *)
+ echo "Don't know how to manage packages on: $os" >&2
+ exit 1
+ ;;
+ esac
+fi
+
+case "$type" in
+ yum) ;;
+ apt) echo "apt-get --quiet update" ;;
+ pacman) echo "pacman --noprogressbar --sync --refresh" ;;
+ *)
+ echo "Don't know how to manage packages on: $os" >&2
+ exit 1
+ ;;
+esac
diff --git a/cdist/conf/type/__package_update_index/man.rst b/cdist/conf/type/__package_update_index/man.rst
new file mode 100644
index 00000000..a16d29ce
--- /dev/null
+++ b/cdist/conf/type/__package_update_index/man.rst
@@ -0,0 +1,50 @@
+cdist-type__package_update_index(7)
+===================================
+Update the package index
+
+Ricardo Catalinas Jiménez
+
+
+DESCRIPTION
+-----------
+This cdist type allows you to update the package index on the target.
+It will automatically use the appropriate package manager.
+
+
+REQUIRED PARAMETERS
+-------------------
+None
+
+
+OPTIONAL PARAMETERS
+-------------------
+type
+ The package manager to use. Default is determined based on the $os
+ explorer variable.
+ e.g.
+ * apt for Debian
+ * yum for Red Hat
+ * pacman for Arch Linux
+
+
+EXAMPLES
+--------
+
+.. code-block:: sh
+
+ # Update the package index on the target
+ __package_update_index
+
+ # Force use of a specific package manager
+ __package_update_index --type apt
+
+
+SEE ALSO
+--------
+- `cdist-type(7) `_
+
+
+COPYING
+-------
+Copyright \(C) 2014 Ricardo Catalinas Jiménez. Free use of this software is
+granted under the terms of the GNU General Public License version 3 (GPLv3).
diff --git a/cdist/conf/type/__package_update_index/parameter/optional b/cdist/conf/type/__package_update_index/parameter/optional
new file mode 100644
index 00000000..aa80e646
--- /dev/null
+++ b/cdist/conf/type/__package_update_index/parameter/optional
@@ -0,0 +1 @@
+type
diff --git a/cdist/conf/type/__package_update_index/singleton b/cdist/conf/type/__package_update_index/singleton
new file mode 100644
index 00000000..e69de29b
diff --git a/cdist/conf/type/__package_upgrade_all/gencode-remote b/cdist/conf/type/__package_upgrade_all/gencode-remote
new file mode 100755
index 00000000..4d034816
--- /dev/null
+++ b/cdist/conf/type/__package_upgrade_all/gencode-remote
@@ -0,0 +1,62 @@
+#!/bin/sh
+#
+# 2014 Ricardo Catalinas Jiménez (jimenezrick at gmail.com)
+#
+# This file is part of cdist.
+#
+# cdist is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# cdist is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with cdist. If not, see .
+#
+#
+# Upgrade all the already installed packages with the appropriate package
+# manager
+#
+
+type="$__object/parameter/type"
+
+if [ -f "$type" ]; then
+ type="$(cat "$type")"
+else
+ # By default determine package manager based on operating system
+ os="$(cat "$__global/explorer/os")"
+ case "$os" in
+ amazon|centos|fedora|redhat) type="yum" ;;
+ debian|ubuntu|devuan) type="apt" ;;
+ archlinux) type="pacman" ;;
+ *)
+ echo "Don't know how to manage packages on: $os" >&2
+ exit 1
+ ;;
+ esac
+fi
+
+aptget="DEBIAN_FRONTEND=noninteractive apt-get --quiet --yes --no-install-recommends -o Dpkg::Options::=\"--force-confdef\" -o Dpkg::Options::=\"--force-confold\""
+
+case "$type" in
+ yum)
+ echo "yum --quiet --assumeyes update"
+ echo "yum --quiet clean all"
+ ;;
+ apt)
+ echo $aptget dist-upgrade
+ echo "apt-get --quiet autoclean"
+ ;;
+ pacman)
+ echo "pacman --noprogressbar --noconfirm --sync --sysupgrade"
+ echo "pacman --noprogressbar --noconfirm --sync --clean"
+ ;;
+ *)
+ echo "Don't know how to manage packages on: $os" >&2
+ exit 1
+ ;;
+esac
diff --git a/cdist/conf/type/__package_upgrade_all/man.rst b/cdist/conf/type/__package_upgrade_all/man.rst
new file mode 100644
index 00000000..146a8259
--- /dev/null
+++ b/cdist/conf/type/__package_upgrade_all/man.rst
@@ -0,0 +1,50 @@
+cdist-type__package_upgrade_all(7)
+==================================
+Upgrade all the installed packages
+
+Ricardo Catalinas Jiménez
+
+
+DESCRIPTION
+-----------
+This cdist type allows you to upgrade all the installed packages on the
+target. It will automatically use the appropriate package manager.
+
+
+REQUIRED PARAMETERS
+-------------------
+None
+
+
+OPTIONAL PARAMETERS
+-------------------
+type
+ The package manager to use. Default is determined based on the $os
+ explorer variable.
+ e.g.
+ * apt for Debian
+ * yum for Red Hat
+ * pacman for Arch Linux
+
+
+EXAMPLES
+--------
+
+.. code-block:: sh
+
+ # Upgrade all the installed packages on the target
+ __package_upgrade_all
+
+ # Force use of a specific package manager
+ __package_upgrade_all --type apt
+
+
+SEE ALSO
+--------
+- `cdist-type(7) `_
+
+
+COPYING
+-------
+Copyright \(C) 2014 Ricardo Catalinas Jiménez. Free use of this software is
+granted under the terms of the GNU General Public License version 3 (GPLv3).
diff --git a/cdist/conf/type/__package_upgrade_all/parameter/optional b/cdist/conf/type/__package_upgrade_all/parameter/optional
new file mode 100644
index 00000000..aa80e646
--- /dev/null
+++ b/cdist/conf/type/__package_upgrade_all/parameter/optional
@@ -0,0 +1 @@
+type
diff --git a/cdist/conf/type/__package_upgrade_all/singleton b/cdist/conf/type/__package_upgrade_all/singleton
new file mode 100644
index 00000000..e69de29b
diff --git a/cdist/conf/type/__package_yum/gencode-remote b/cdist/conf/type/__package_yum/gencode-remote
index 5f0e8ac8..32a794a0 100755
--- a/cdist/conf/type/__package_yum/gencode-remote
+++ b/cdist/conf/type/__package_yum/gencode-remote
@@ -1,6 +1,6 @@
#!/bin/sh
#
-# 2011 Nico Schottelius (nico-cdist at schottelius.org)
+# 2011-2014 Nico Schottelius (nico-cdist at schottelius.org)
#
# This file is part of cdist.
#
@@ -27,6 +27,14 @@ else
name="$__object_id"
fi
+# Support installing from an URL
+if [ -f "$__object/parameter/url" ]; then
+ install_name="$(cat "$__object/parameter/url")"
+else
+ install_name="$name"
+fi
+
+
state_should="$(cat "$__object/parameter/state")"
if grep -q -E "(centos|redhat|amazon)" "$__global/explorer/os"; then
@@ -47,7 +55,7 @@ fi
case "$state_should" in
present)
- echo yum $opts install \"$name\"
+ echo yum $opts install \"$install_name\"
;;
absent)
echo yum $opts remove \"$name\"
diff --git a/cdist/conf/type/__package_yum/man.text b/cdist/conf/type/__package_yum/man.rst
similarity index 56%
rename from cdist/conf/type/__package_yum/man.text
rename to cdist/conf/type/__package_yum/man.rst
index d958dd1e..65e56c7a 100644
--- a/cdist/conf/type/__package_yum/man.text
+++ b/cdist/conf/type/__package_yum/man.rst
@@ -1,13 +1,10 @@
cdist-type__package_yum(7)
==========================
+Manage packages with yum
+
Nico Schottelius
-NAME
-----
-cdist-type__package_yum - Manage packages with yum
-
-
DESCRIPTION
-----------
Yum is usually used on the Fedora distribution to manage packages.
@@ -22,32 +19,37 @@ None
OPTIONAL PARAMETERS
-------------------
-name::
+name
If supplied, use the name and not the object id as the package name.
-state::
+state
Either "present" or "absent", defaults to "present"
+url
+ URL to use for the package
EXAMPLES
--------
---------------------------------------------------------------------------------
-# Ensure zsh in installed
-__package_yum zsh --state present
+.. code-block:: sh
-# If you don't want to follow pythonX packages, but always use python
-__package_yum python --state present --name python2
+ # Ensure zsh in installed
+ __package_yum zsh --state present
-# Remove obsolete package
-__package_yum puppet --state absent
---------------------------------------------------------------------------------
+ # If you don't want to follow pythonX packages, but always use python
+ __package_yum python --state present --name python2
+
+ # Remove obsolete package
+ __package_yum puppet --state absent
+
+ __package epel-release-6-8 \
+ --url http://mirror.switch.ch/ftp/mirror/epel/6/i386/epel-release-6-8.noarch.rpm
SEE ALSO
--------
-- cdist-type(7)
-- cdist-type__package(7)
+- `cdist-type(7) `_
+- `cdist-type__package(7) `_
COPYING
diff --git a/cdist/conf/type/__package_yum/parameter/optional b/cdist/conf/type/__package_yum/parameter/optional
index 1b423dc4..9293119d 100644
--- a/cdist/conf/type/__package_yum/parameter/optional
+++ b/cdist/conf/type/__package_yum/parameter/optional
@@ -1,2 +1,3 @@
name
state
+url
diff --git a/cdist/conf/type/__package_zypper/explorer/pkg_version b/cdist/conf/type/__package_zypper/explorer/pkg_version
index 7f203067..83bf6dab 100644
--- a/cdist/conf/type/__package_zypper/explorer/pkg_version
+++ b/cdist/conf/type/__package_zypper/explorer/pkg_version
@@ -42,7 +42,7 @@ case "$ptype" in
zypper search --match-exact --installed-only --type "$ptype" "$name" | grep -E '^i' | cut -d " " -f 3 || true
;;
*)
- echo "unknown ptype in __package_zypper explorer" &>2
+ echo "unknown ptype in __package_zypper explorer" >&2
exit 1
;;
esac
diff --git a/cdist/conf/type/__package_zypper/man.text b/cdist/conf/type/__package_zypper/man.rst
similarity index 51%
rename from cdist/conf/type/__package_zypper/man.text
rename to cdist/conf/type/__package_zypper/man.rst
index 104d3a7a..2df22e72 100644
--- a/cdist/conf/type/__package_zypper/man.text
+++ b/cdist/conf/type/__package_zypper/man.rst
@@ -1,13 +1,10 @@
cdist-type__package_zypper(7)
=============================
+Manage packages with zypper
+
Daniel Heule
-NAME
-----
-cdist-type__package_zypper - Manage packages with zypper
-
-
DESCRIPTION
-----------
Zypper is usually used on the SuSE distribution to manage packages.
@@ -20,46 +17,46 @@ None
OPTIONAL PARAMETERS
-------------------
-name::
+name
If supplied, use the name and not the object id as the package name.
-state::
+state
Either "present" or "absent", defaults to "present"
-version::
+version
The version of the package to install. Default is to install the version
- choosen by the local package manager. For a list of available versions,
+ chosen by the local package manager. For a list of available versions,
have a look at the output of "zypper se -s packagename"
-ptype::
+ptype
Either "package", "patch", "pattern", "product" or "srcpackage", defaults to "package". For a description see man zypper.
EXAMPLES
--------
---------------------------------------------------------------------------------
-# Ensure zsh is installed
-__package_zypper zsh --state present
+.. code-block:: sh
-# If you don't want to follow pythonX packages, but always use python
-__package_zypper python --state present --name python2
+ # Ensure zsh is installed
+ __package_zypper zsh --state present
-# Ensure binutils is installed and the version is forced to be 2.23.1-0.19.2
-__package_zypper binutils --state present --version 2.23.1-0.19.2
+ # If you don't want to follow pythonX packages, but always use python
+ __package_zypper python --state present --name python2
-# Remove package
-__package_zypper cfengine --state absent
+ # Ensure binutils is installed and the version is forced to be 2.23.1-0.19.2
+ __package_zypper binutils --state present --version 2.23.1-0.19.2
-# install all packages which belongs to pattern x11
-__package_zypper x11 --ptype pattern --state present
---------------------------------------------------------------------------------
+ # Remove package
+ __package_zypper cfengine --state absent
+
+ # install all packages which belongs to pattern x11
+ __package_zypper x11 --ptype pattern --state present
SEE ALSO
--------
-- cdist-type(7)
-- cdist-type__package(7)
+- `cdist-type(7) `_
+- `cdist-type__package(7) `_
COPYING
diff --git a/cdist/conf/type/__pacman_conf/man.rst b/cdist/conf/type/__pacman_conf/man.rst
new file mode 100644
index 00000000..930035fa
--- /dev/null
+++ b/cdist/conf/type/__pacman_conf/man.rst
@@ -0,0 +1,68 @@
+cdist-type__pacman_conf(7)
+==========================
+Manage pacman configuration
+
+Dominique Roux
+
+
+DESCRIPTION
+-----------
+The type allows you to configure options section, add or delete repositories and manage mirrorlists
+
+
+REQUIRED PARAMETERS
+-------------------
+section
+ 'options' for configure options section
+
+ Otherwise it specifies a repository or a plain file
+
+key
+ Specifies the key which will be set
+
+ If section = 'options' or file is not set the key will
+ be checked against available keys from pacman.conf
+
+value
+ Specifies the value which will be set against the key
+
+
+OPTIONAL PARAMETERS
+-------------------
+state
+ 'present' or 'absent', defaults to 'present'
+
+file
+ Specifies the filename.
+
+ The managed file will be named like 'plain_file_filename'
+
+ If supplied the key will not be checked.
+
+
+EXAMPLES
+--------
+
+.. code-block:: sh
+
+ # Manage options section in pacman.conf
+ __pacman_conf options_Architecture --section options --key Architecture --value auto
+
+ # Add new repository
+ __pacman_conf localrepo_Server --section localrepo --key Server --value "file:///var/cache/pacman/pkg"
+
+ # Add mirror to a mirrorlist
+ __pacman_conf customlist_Server --file customlist --section customlist --key Server\
+ --value "file:///var/cache/pacman/pkg"
+
+
+SEE ALSO
+--------
+- `cdist-type(7) `_
+- grep(1)
+
+
+COPYING
+-------
+Copyright \(C) 2015 Dominique Roux. Free use of this software is
+granted under the terms of the GNU General Public License version 3 (GPLv3).
diff --git a/cdist/conf/type/__pacman_conf/manifest b/cdist/conf/type/__pacman_conf/manifest
new file mode 100644
index 00000000..b9679577
--- /dev/null
+++ b/cdist/conf/type/__pacman_conf/manifest
@@ -0,0 +1,133 @@
+#!/bin/sh
+#
+# 2015 Dominique Roux (dominique.roux4 at gmail.com)
+#
+# This file is part of cdist.
+#
+# cdist is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# cdist is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with cdist. If not, see .
+#
+
+#get params
+section=$(cat "$__object/parameter/section")
+key=$(cat "$__object/parameter/key")
+value=$(cat "$__object/parameter/value")
+file=$(cat "$__object/parameter/file" 2>/dev/null)
+state=$(cat "$__object/parameter/state" 2>/dev/null)
+
+#path variable default /etc/pacman.d
+sec_path="/etc/pacman.d"
+
+#allowed keys (from man pacman.conf)
+allowed_option_keys="RootDir DBPath CacheDir GPGDir LogFile HoldPkg IgnorePkg IgnoreGroup Include Architecture XferCommand NoUpgrade NoExtract CleanMethod SigLevel LocalFileSigLevel RemoteFileSigLevel"
+boolean_option_keys="UseSyslog Color UseDelta TotalDownload CheckSpace VerbosePkgLists"
+allowed_repo_keys="Include Server SigLevel Usage"
+
+#set global variables
+MATCH=0
+
+#function for check if array contain string
+contains_element() {
+
+ MATCH=0
+
+ target=$1
+ shift
+
+ for key in "$@"; do
+ if [ "${key}" = "${target}" ]; then
+ MATCH=1
+ return 0
+ fi
+ done
+ MATCH=0
+}
+
+if [ "${file}" ]; then
+ __file "${sec_path}/plain_file_${file}"\
+ --state exists --mode 666
+
+ if [ "${state}" = "present" ]; then
+
+ require="__file/${sec_path}/plain_file_${file}" __key_value ${file}_${key}\
+ --file ${sec_path}/plain_file_${file} --key ${key} --value ${value} --delimiter ' = '
+
+ exit 0
+
+ elif [ "${state}" = "absent" ]; then
+ require="__file/${sec_path}/plain_file_${file}" __key_value ${file}_${key}\
+ --state absent
+ exit 0
+
+ else
+ echo "ERROR: Unknown state: ${state}" >&2
+ exit 0
+ fi
+fi
+
+if [ "${section}" = "options" ]; then
+
+ __file "${sec_path}/${section}"\
+ --state exists --mode 666 --source - << eof
+[${section}]
+eof
+ #check if key is valid
+ #check for boolean value
+ contains_element "${key}" "${boolean_option_keys}"
+
+ if [ "${MATCH}" -eq 1 ]; then
+ if [ "${value}" = "on" ]; then
+ require="__file/${sec_path}/${section}" __line ${key}_${value}\
+ --file ${sec_path}/${section} --line ${key}
+ elif [ "${value}" = "off" ]; then
+ require="__file/${sec_path}/${section}" __line ${key}_${value}\
+ --file ${sec_path}/${section} --line ${key} --state absent
+ fi
+
+ else
+ contains_element "${key}" "${allowed_option_keys}"
+
+ if [ "${MATCH}" -eq 1 ]; then
+ require="__file/${sec_path}/${section}" __key_value ${section}_${key}\
+ --file ${sec_path}/${section} --key ${key} --value ${value} --delimiter ' = '
+ else
+ echo "Key: ${key} is not valid. Have a look at man pacman.conf" >&2
+ fi
+ fi
+
+else
+ __file "${sec_path}/repo_${section}"\
+ --state exists --mode 666 --source - << eof
+[${section}]
+eof
+ if [ "${state}" = "present" ]; then
+
+ #check if key is valid
+ contains_element "${key}" "${allowed_repo_keys}"
+ if [ ${MATCH} -eq 0 ]; then
+ exit
+ fi
+
+ require="__file/${sec_path}/repo_${section}" __key_value ${section}_${key}\
+ --file ${sec_path}/repo_${section} --key ${key} --value ${value} --delimiter ' = '
+
+ elif [ "${state}" = "absent" ]; then
+
+ require="__file/${sec_path}/repo_${section}" __key_value ${section}_${key}\
+ --state absent
+
+ else
+ echo "ERROR: Unknown state: ${state}" >&2
+ fi
+
+fi
diff --git a/cdist/conf/type/__pacman_conf/parameter/default/file b/cdist/conf/type/__pacman_conf/parameter/default/file
new file mode 100644
index 00000000..139597f9
--- /dev/null
+++ b/cdist/conf/type/__pacman_conf/parameter/default/file
@@ -0,0 +1,2 @@
+
+
diff --git a/cdist/conf/type/__pacman_conf/parameter/default/state b/cdist/conf/type/__pacman_conf/parameter/default/state
new file mode 100644
index 00000000..e7f6134f
--- /dev/null
+++ b/cdist/conf/type/__pacman_conf/parameter/default/state
@@ -0,0 +1 @@
+present
diff --git a/cdist/conf/type/__pacman_conf/parameter/optional b/cdist/conf/type/__pacman_conf/parameter/optional
new file mode 100644
index 00000000..5d52aa2e
--- /dev/null
+++ b/cdist/conf/type/__pacman_conf/parameter/optional
@@ -0,0 +1,2 @@
+file
+state
diff --git a/cdist/conf/type/__pacman_conf/parameter/required b/cdist/conf/type/__pacman_conf/parameter/required
new file mode 100644
index 00000000..2f9d59e0
--- /dev/null
+++ b/cdist/conf/type/__pacman_conf/parameter/required
@@ -0,0 +1,3 @@
+section
+key
+value
diff --git a/cdist/conf/type/__pacman_conf_integrate/files/mirrorlist b/cdist/conf/type/__pacman_conf_integrate/files/mirrorlist
new file mode 100644
index 00000000..a378fb50
--- /dev/null
+++ b/cdist/conf/type/__pacman_conf_integrate/files/mirrorlist
@@ -0,0 +1,344 @@
+##
+## Arch Linux repository mirrorlist
+## Generated on 2015-03-15
+##
+
+## Worldwide
+#Server = http://mirror.rackspace.com/archlinux/$repo/os/$arch
+
+## Australia
+#Server = http://mirror.aarnet.edu.au/pub/archlinux/$repo/os/$arch
+#Server = http://archlinux.mirror.digitalpacific.com.au/$repo/os/$arch
+#Server = http://ftp.iinet.net.au/pub/archlinux/$repo/os/$arch
+#Server = http://mirror.internode.on.net/pub/archlinux/$repo/os/$arch
+#Server = http://mirror.rackcentral.com.au/archlinux/$repo/os/$arch
+#Server = http://ftp.swin.edu.au/archlinux/$repo/os/$arch
+#Server = http://archlinux.mirror.uber.com.au/$repo/os/$arch
+
+## Austria
+#Server = http://mirror.easyname.at/archlinux/$repo/os/$arch
+#Server = http://mirror1.htu.tugraz.at/archlinux/$repo/os/$arch
+
+## Bangladesh
+#Server = http://mirrors.ispros.com.bd/archlinux/$repo/os/$arch
+
+## Belarus
+#Server = http://ftp.byfly.by/pub/archlinux/$repo/os/$arch
+#Server = http://mirror.datacenter.by/pub/archlinux/$repo/os/$arch
+
+## Belgium
+#Server = http://archlinux.cu.be/$repo/os/$arch
+#Server = http://archlinux.mirror.kangaroot.net/$repo/os/$arch
+
+## Brazil
+#Server = http://archlinux.c3sl.ufpr.br/$repo/os/$arch
+#Server = http://www.las.ic.unicamp.br/pub/archlinux/$repo/os/$arch
+#Server = http://pet.inf.ufsc.br/mirrors/archlinux/$repo/os/$arch
+
+## Bulgaria
+#Server = http://mirror.telepoint.bg/archlinux/$repo/os/$arch
+
+## Canada
+#Server = http://archlinux.dropswitch.net/archlinux/$repo/os/$arch
+#Server = http://mirror.clibre.uqam.ca/archlinux/$repo/os/$arch
+#Server = http://mirror.csclub.uwaterloo.ca/archlinux/$repo/os/$arch
+#Server = http://mirror.its.dal.ca/archlinux/$repo/os/$arch
+#Server = http://archlinux.mirror.rafal.ca/$repo/os/$arch
+#Server = http://archlinux.mirror.vexxhost.com/$repo/os/$arch
+
+## Chile
+#Server = http://mirror.archlinux.cl/$repo/os/$arch
+
+## China
+#Server = http://mirrors.163.com/archlinux/$repo/os/$arch
+#Server = http://mirror.bjtu.edu.cn/archlinux/$repo/os/$arch
+#Server = http://mirrors.cqu.edu.cn/archlinux/$repo/os/$arch
+#Server = http://mirrors.hust.edu.cn/archlinux/$repo/os/$arch
+#Server = http://mirrors.hustunique.com/archlinux/$repo/os/$arch
+#Server = http://mirrors.neusoft.edu.cn/archlinux/$repo/os/$arch
+#Server = http://run.hit.edu.cn/archlinux/$repo/os/$arch
+#Server = http://mirrors.tuna.tsinghua.edu.cn/archlinux/$repo/os/$arch
+#Server = http://mirrors.ustc.edu.cn/archlinux/$repo/os/$arch
+#Server = https://mirrors.ustc.edu.cn/archlinux/$repo/os/$arch
+#Server = http://mirrors.zju.edu.cn/archlinux/$repo/os/$arch
+
+## Colombia
+#Server = http://mirror.edatel.net.co/archlinux/$repo/os/$arch
+#Server = http://www.laqee.unal.edu.co/archlinux/$repo/os/$arch
+
+## Croatia
+#Server = http://archlinux.iskon.hr/$repo/os/$arch
+
+## Czech Republic
+#Server = http://archlinux.mirror.dkm.cz/pub/archlinux/$repo/os/$arch
+#Server = http://gluttony.sin.cvut.cz/arch/$repo/os/$arch
+#Server = http://mirror.oss.maxcdn.com/archlinux/$repo/os/$arch
+#Server = http://mirrors.nic.cz/archlinux/$repo/os/$arch
+#Server = http://mirror.vpsfree.cz/archlinux/$repo/os/$arch
+
+## Denmark
+#Server = http://mirrors.dotsrc.org/archlinux/$repo/os/$arch
+#Server = http://mirror.one.com/archlinux/$repo/os/$arch
+
+## Ecuador
+#Server = http://mirror.cedia.org.ec/archlinux/$repo/os/$arch
+#Server = http://mirror.espoch.edu.ec/archlinux/$repo/os/$arch
+#Server = http://mirror.uta.edu.ec/archlinux/$repo/os/$arch
+
+## Estonia
+#Server = http://ftp.eenet.ee/pub/archlinux/$repo/os/$arch
+
+## France
+#Server = http://archlinux.aubrac-medical.fr/$repo/os/$arch
+#Server = http://mirror.archlinux.ikoula.com/archlinux/$repo/os/$arch
+#Server = http://archlinux.vi-di.fr/$repo/os/$arch
+#Server = http://mir.art-software.fr/arch/$repo/os/$arch
+#Server = http://fooo.biz/archlinux/$repo/os/$arch
+#Server = https://fooo.biz/archlinux/$repo/os/$arch
+#Server = http://mirror.lastmikoi.net/archlinux/$repo/os/$arch
+#Server = http://mirror.lightcone.eu/archlinux/$repo/os/$arch
+#Server = http://archlinux.mailtunnel.eu/$repo/os/$arch
+#Server = https://www.mailtunnel.eu/archlinux/$repo/os/$arch
+#Server = http://mir.archlinux.fr/$repo/os/$arch
+#Server = http://arch.nimukaito.net/$repo/os/$arch
+#Server = http://archlinux.mirrors.ovh.net/archlinux/$repo/os/$arch
+#Server = http://archlinux.mirror.pkern.at/$repo/os/$arch
+#Server = https://archlinux.mirror.pkern.at/$repo/os/$arch
+#Server = http://archlinux.polymorf.fr/$repo/os/$arch
+#Server = http://arch.static.lu/$repo/os/$arch
+#Server = https://arch.static.lu/$repo/os/$arch
+#Server = http://arch.tamcore.eu/$repo/os/$arch
+#Server = http://mirror.tyborek.pl/arch/$repo/os/$arch
+#Server = http://ftp.u-strasbg.fr/linux/distributions/archlinux/$repo/os/$arch
+#Server = http://arch.yourlabs.org/$repo/os/$arch
+
+## Germany
+#Server = http://mirror.23media.de/archlinux/$repo/os/$arch
+#Server = http://archlinux.limun.org/$repo/os/$arch
+#Server = https://archlinux.limun.org/$repo/os/$arch
+#Server = http://artfiles.org/archlinux.org/$repo/os/$arch
+#Server = http://ftp.fau.de/archlinux/$repo/os/$arch
+#Server = https://ftp.fau.de/archlinux/$repo/os/$arch
+#Server = http://mirror.flipez.de/archlinux/$repo/os/$arch
+#Server = http://mirror.fluxent.de/archlinux/$repo/os/$arch
+#Server = http://mirror.gnomus.de/$repo/os/$arch
+#Server = http://arch.packages.gnp-tec.net/$repo/os/$arch
+#Server = http://ftp5.gwdg.de/pub/linux/archlinux/$repo/os/$arch
+#Server = http://mirror.hactar.bz/$repo/os/$arch
+#Server = http://ftp.hawo.stw.uni-erlangen.de/archlinux/$repo/os/$arch
+#Server = http://ftp.hosteurope.de/mirror/ftp.archlinux.org/$repo/os/$arch
+#Server = http://ftp-stud.hs-esslingen.de/pub/Mirrors/archlinux/$repo/os/$arch
+#Server = http://mirror.js-webcoding.de/pub/archlinux/$repo/os/$arch
+#Server = http://mirror.k42.ch/archlinux/$repo/os/$arch
+#Server = http://mirror.de.leaseweb.net/archlinux/$repo/os/$arch
+#Server = http://mirror.metalgamer.eu/archlinux/$repo/os/$arch
+#Server = http://mirror.michael-eckert.net/archlinux/$repo/os/$arch
+#Server = http://archlinux.my-universe.com/$repo/os/$arch
+#Server = https://archlinux.my-universe.com/$repo/os/$arch
+#Server = http://mirrors.n-ix.net/archlinux/$repo/os/$arch
+#Server = http://mirror.netcologne.de/archlinux/$repo/os/$arch
+#Server = http://mirrors.niyawe.de/archlinux/$repo/os/$arch
+#Server = http://ftp.halifax.rwth-aachen.de/archlinux/$repo/os/$arch
+#Server = http://linux.rz.rub.de/archlinux/$repo/os/$arch
+#Server = http://mirror.selfnet.de/archlinux/$repo/os/$arch
+#Server = http://ftp.spline.inf.fu-berlin.de/mirrors/archlinux/$repo/os/$arch
+#Server = http://ftp.tu-chemnitz.de/pub/linux/archlinux/$repo/os/$arch
+#Server = http://ftp.tuxdroid.org/archlinux/$repo/os/$arch
+#Server = http://ftp.uni-bayreuth.de/linux/archlinux/$repo/os/$arch
+#Server = http://ftp.uni-hannover.de/archlinux/$repo/os/$arch
+#Server = http://ftp.uni-kl.de/pub/linux/archlinux/$repo/os/$arch
+#Server = http://mirror.united-gameserver.de/archlinux/$repo/os/$arch
+
+## Greece
+#Server = http://ftp.cc.uoc.gr/mirrors/linux/archlinux/$repo/os/$arch
+#Server = http://foss.aueb.gr/mirrors/linux/archlinux/$repo/os/$arch
+#Server = https://foss.aueb.gr/mirrors/linux/archlinux/$repo/os/$arch
+#Server = http://mirrors.myaegean.gr/linux/archlinux/$repo/os/$arch
+#Server = http://ftp.ntua.gr/pub/linux/archlinux/$repo/os/$arch
+#Server = http://ftp.otenet.gr/linux/archlinux/$repo/os/$arch
+
+## Hungary
+#Server = http://ftp.mfa.kfki.hu/pub/mirrors/ftp.archlinux.org/$repo/os/$arch
+
+## Iceland
+#Server = http://mirror.system.is/arch/$repo/os/$arch
+#Server = https://mirror.system.is/arch/$repo/os/$arch
+
+## India
+#Server = http://mirror.cse.iitk.ac.in/archlinux/$repo/os/$arch
+#Server = http://ftp.iitm.ac.in/archlinux/$repo/os/$arch
+
+## Indonesia
+#Server = http://mirror.kavalinux.com/archlinux/$repo/os/$arch
+#Server = http://mirror.poliwangi.ac.id/archlinux/$repo/os/$arch
+#Server = http://suro.ubaya.ac.id/archlinux/$repo/os/$arch
+
+## Iran
+#Server = http://mirror.yazd.ac.ir/arch/$repo/os/$arch
+
+## Ireland
+#Server = http://ftp.heanet.ie/mirrors/ftp.archlinux.org/$repo/os/$arch
+
+## Israel
+#Server = http://mirror.isoc.org.il/pub/archlinux/$repo/os/$arch
+
+## Italy
+#Server = http://archlinux.openlabto.org/archlinux/$repo/os/$arch
+#Server = http://archlinux.beccacervello.it/archlinux/$repo/os/$arch
+#Server = http://mirrors.prometeus.net/archlinux/$repo/os/$arch
+
+## Japan
+#Server = http://ftp.tsukuba.wide.ad.jp/Linux/archlinux/$repo/os/$arch
+#Server = http://ftp.jaist.ac.jp/pub/Linux/ArchLinux/$repo/os/$arch
+
+## Kazakhstan
+#Server = http://mirror.neolabs.kz/archlinux/$repo/os/$arch
+
+## Latvia
+#Server = http://archlinux.koyanet.lv/archlinux/$repo/os/$arch
+
+## Lithuania
+#Server = http://archlinux.akmc.lt/$repo/os/$arch
+#Server = http://atviras.lt/veidrodziai/archlinux/$repo/os/$arch
+
+## Luxembourg
+#Server = http://archlinux.mirror.root.lu/$repo/os/$arch
+
+## Macedonia
+#Server = http://arch.softver.org.mk/archlinux/$repo/os/$arch
+#Server = http://mirror.t-home.mk/archlinux/$repo/os/$arch
+
+## Netherlands
+#Server = http://arch.apt-get.eu/$repo/os/$arch
+#Server = http://mirror.i3d.net/pub/archlinux/$repo/os/$arch
+#Server = https://mirror.i3d.net/pub/archlinux/$repo/os/$arch
+#Server = http://mirror.nl.leaseweb.net/archlinux/$repo/os/$arch
+#Server = http://ftp.nluug.nl/os/Linux/distr/archlinux/$repo/os/$arch
+#Server = http://ftp.snt.utwente.nl/pub/os/linux/archlinux/$repo/os/$arch
+
+## New Caledonia
+#Server = http://mirror.lagoon.nc/pub/archlinux/$repo/os/$arch
+#Server = http://archlinux.nautile.nc/archlinux/$repo/os/$arch
+
+## New Zealand
+#Server = http://mirror.xnet.co.nz/pub/archlinux/$repo/os/$arch
+
+## Norway
+#Server = http://mirror.archlinux.no/$repo/os/$arch
+#Server = http://archlinux.uib.no/$repo/os/$arch
+#Server = http://archlinux.neuf.no/$repo/os/$arch
+
+## Philippines
+#Server = http://mirror.pregi.net/pub/Linux/archlinux/$repo/os/$arch
+
+## Poland
+#Server = http://mirror.chmuri.net/archmirror/$repo/os/$arch
+#Server = http://arch.midov.pl/arch/$repo/os/$arch
+#Server = http://piotrkosoft.net/pub/mirrors/ftp.archlinux.org/$repo/os/$arch
+#Server = http://ftp.vectranet.pl/archlinux/$repo/os/$arch
+
+## Portugal
+#Server = http://archlinux.dcc.fc.up.pt/$repo/os/$arch
+#Server = http://ftp.rnl.tecnico.ulisboa.pt/pub/archlinux/$repo/os/$arch
+
+## Romania
+#Server = http://mirror.archlinux.ro/archlinux/$repo/os/$arch
+#Server = http://archlinux.mirrors.linux.ro/$repo/os/$arch
+
+## Russia
+#Server = http://mirror.rol.ru/archlinux/$repo/os/$arch
+#Server = http://mirror.yandex.ru/archlinux/$repo/os/$arch
+
+## Serbia
+#Server = http://mirror.pmf.kg.ac.rs/archlinux/$repo/os/$arch
+
+## Singapore
+#Server = http://download.nus.edu.sg/mirror/arch/$repo/os/$arch
+#Server = http://mirror.nus.edu.sg/archlinux/$repo/os/$arch
+
+## Slovakia
+#Server = http://mirror.lnx.sk/pub/linux/archlinux/$repo/os/$arch
+#Server = http://tux.rainside.sk/archlinux/$repo/os/$arch
+
+## South Africa
+#Server = http://ftp.wa.co.za/pub/archlinux/$repo/os/$arch
+
+## South Korea
+#Server = http://ftp.kaist.ac.kr/ArchLinux/$repo/os/$arch
+#Server = http://mirror.premi.st/archlinux/$repo/os/$arch
+
+## Spain
+#Server = http://osl.ugr.es/archlinux/$repo/os/$arch
+#Server = http://sunsite.rediris.es/mirror/archlinux/$repo/os/$arch
+
+## Sweden
+#Server = http://ftp.df.lth.se/pub/archlinux/$repo/os/$arch
+#Server = http://ftp.lysator.liu.se/pub/archlinux/$repo/os/$arch
+#Server = https://ftp.lysator.liu.se/pub/archlinux/$repo/os/$arch
+#Server = http://ftp.myrveln.se/pub/linux/archlinux/$repo/os/$arch
+#Server = http://ftp.portlane.com/pub/os/linux/archlinux/$repo/os/$arch
+
+## Switzerland
+#Server = http://archlinux.puzzle.ch/$repo/os/$arch
+
+## Taiwan
+#Server = http://archlinux.cs.nctu.edu.tw/$repo/os/$arch
+#Server = http://shadow.ind.ntou.edu.tw/archlinux/$repo/os/$arch
+#Server = http://ftp.tku.edu.tw/Linux/ArchLinux/$repo/os/$arch
+#Server = http://ftp.yzu.edu.tw/Linux/archlinux/$repo/os/$arch
+
+## Turkey
+#Server = http://ftp.linux.org.tr/archlinux/$repo/os/$arch
+
+## Ukraine
+#Server = http://mirrors.nix.org.ua/linux/archlinux/$repo/os/$arch
+
+## United Kingdom
+#Server = http://mirror.bytemark.co.uk/archlinux/$repo/os/$arch
+#Server = http://mirror.cinosure.com/archlinux/$repo/os/$arch
+#Server = http://mirrors.manchester.m247.com/arch-linux/$repo/os/$arch
+#Server = http://www.mirrorservice.org/sites/ftp.archlinux.org/$repo/os/$arch
+#Server = http://arch.serverspace.co.uk/arch/$repo/os/$arch
+#Server = http://archlinux.mirrors.uk2.net/$repo/os/$arch
+
+## United States
+#Server = http://mirrors.abscission.net/archlinux/$repo/os/$arch
+#Server = http://mirrors.acm.wpi.edu/archlinux/$repo/os/$arch
+#Server = http://mirrors.advancedhosters.com/archlinux/$repo/os/$arch
+#Server = http://mirrors.aggregate.org/archlinux/$repo/os/$arch
+#Server = http://archlinux.surlyjake.com/archlinux/$repo/os/$arch
+#Server = http://mirrors.cat.pdx.edu/archlinux/$repo/os/$arch
+#Server = http://mirror.cc.columbia.edu/pub/linux/archlinux/$repo/os/$arch
+#Server = http://mirrors.cdndepo.com/archlinux/$repo/os/$arch
+#Server = https://mirrors.cdndepo.com/archlinux/$repo/os/$arch
+#Server = http://mirrors.cecsresearch.org/archlinux/$repo/os/$arch
+#Server = http://cosmos.cites.illinois.edu/pub/archlinux/$repo/os/$arch
+#Server = http://mirror.cs.pitt.edu/archlinux/$repo/os/$arch
+#Server = http://mirror.es.its.nyu.edu/archlinux/$repo/os/$arch
+#Server = http://mirrors.gigenet.com/archlinux/$repo/os/$arch
+#Server = http://mirror.grig.io/archlinux/$repo/os/$arch
+#Server = http://www.gtlib.gatech.edu/pub/archlinux/$repo/os/$arch
+#Server = http://mirror.ancl.hawaii.edu/linux/archlinux/$repo/os/$arch
+#Server = http://mirror.jmu.edu/pub/archlinux/$repo/os/$arch
+#Server = http://mirrors.kernel.org/archlinux/$repo/os/$arch
+#Server = https://mirrors.kernel.org/archlinux/$repo/os/$arch
+#Server = http://mirror.us.leaseweb.net/archlinux/$repo/os/$arch
+#Server = http://mirrors.liquidweb.com/archlinux/$repo/os/$arch
+#Server = http://arch.localmsp.org/arch/$repo/os/$arch
+#Server = https://arch.localmsp.org/arch/$repo/os/$arch
+#Server = http://lug.mtu.edu/archlinux/$repo/os/$arch
+#Server = http://mirror.metrocast.net/archlinux/$repo/os/$arch
+#Server = http://mirror.nexcess.net/archlinux/$repo/os/$arch
+#Server = http://ftp.osuosl.org/pub/archlinux/$repo/os/$arch
+#Server = http://archlinux.pallissard.net/archlinux/$repo/os/$arch
+#Server = http://mirror.rit.edu/archlinux/$repo/os/$arch
+#Server = http://mirrors.rutgers.edu/archlinux/$repo/os/$arch
+#Server = http://mirror.umd.edu/archlinux/$repo/os/$arch
+#Server = http://mirror.vtti.vt.edu/archlinux/$repo/os/$arch
+#Server = http://mirrors.xmission.com/archlinux/$repo/os/$arch
+#Server = http://mirror.yellowfiber.net/archlinux/$repo/os/$arch
+
+## Vietnam
+#Server = http://f.archlinuxvn.org/archlinux/$repo/os/$arch
+#Server = http://mirror-fpt-telecom.fpt.net/archlinux/$repo/os/$arch
+
diff --git a/cdist/conf/type/__pacman_conf_integrate/files/options b/cdist/conf/type/__pacman_conf_integrate/files/options
new file mode 100644
index 00000000..68273e49
--- /dev/null
+++ b/cdist/conf/type/__pacman_conf_integrate/files/options
@@ -0,0 +1,6 @@
+[options]
+HoldPkg = pacman glibc
+Architecture = auto
+CheckSpace
+SigLevel = Required DatabaseOptional
+LocalFileSigLevel = Optional
diff --git a/cdist/conf/type/__pacman_conf_integrate/files/pacman.conf.cdist b/cdist/conf/type/__pacman_conf_integrate/files/pacman.conf.cdist
new file mode 100644
index 00000000..88e6e623
--- /dev/null
+++ b/cdist/conf/type/__pacman_conf_integrate/files/pacman.conf.cdist
@@ -0,0 +1,6 @@
+#
+# cdist managed - do not change
+#
+Include = /etc/pacman.d/options
+Include = /etc/pacman.d/repo_*
+Include = /etc/pacman.d/plain_file_*
diff --git a/cdist/conf/type/__pacman_conf_integrate/files/pacman.conf.pacman b/cdist/conf/type/__pacman_conf_integrate/files/pacman.conf.pacman
new file mode 100644
index 00000000..f43fe397
--- /dev/null
+++ b/cdist/conf/type/__pacman_conf_integrate/files/pacman.conf.pacman
@@ -0,0 +1,99 @@
+#
+# /etc/pacman.conf
+#
+# See the pacman.conf(5) manpage for option and repository directives
+
+#
+# GENERAL OPTIONS
+#
+[options]
+# The following paths are commented out with their default values listed.
+# If you wish to use different paths, uncomment and update the paths.
+#RootDir = /
+#DBPath = /var/lib/pacman/
+#CacheDir = /var/cache/pacman/pkg/
+#LogFile = /var/log/pacman.log
+#GPGDir = /etc/pacman.d/gnupg/
+HoldPkg = pacman glibc
+#XferCommand = /usr/bin/curl -C - -f %u > %o
+#XferCommand = /usr/bin/wget --passive-ftp -c -O %o %u
+#CleanMethod = KeepInstalled
+#UseDelta = 0.7
+Architecture = auto
+
+# Pacman won't upgrade packages listed in IgnorePkg and members of IgnoreGroup
+#IgnorePkg =
+#IgnoreGroup =
+
+#NoUpgrade =
+#NoExtract =
+
+# Misc options
+#UseSyslog
+#Color
+#TotalDownload
+CheckSpace
+#VerbosePkgLists
+
+# By default, pacman accepts packages signed by keys that its local keyring
+# trusts (see pacman-key and its man page), as well as unsigned packages.
+SigLevel = Required DatabaseOptional
+LocalFileSigLevel = Optional
+#RemoteFileSigLevel = Required
+
+# NOTE: You must run `pacman-key --init` before first using pacman; the local
+# keyring can then be populated with the keys of all official Arch Linux
+# packagers with `pacman-key --populate archlinux`.
+
+#
+# REPOSITORIES
+# - can be defined here or included from another file
+# - pacman will search repositories in the order defined here
+# - local/custom mirrors can be added here or in separate files
+# - repositories listed first will take precedence when packages
+# have identical names, regardless of version number
+# - URLs will have $repo replaced by the name of the current repo
+# - URLs will have $arch replaced by the name of the architecture
+#
+# Repository entries are of the format:
+# [repo-name]
+# Server = ServerName
+# Include = IncludePath
+#
+# The header [repo-name] is crucial - it must be present and
+# uncommented to enable the repo.
+#
+
+# The testing repositories are disabled by default. To enable, uncomment the
+# repo name header and Include lines. You can add preferred servers immediately
+# after the header, and they will be used before the default mirrors.
+
+#[testing]
+#Include = /etc/pacman.d/mirrorlist
+
+[core]
+Include = /etc/pacman.d/mirrorlist
+
+[extra]
+Include = /etc/pacman.d/mirrorlist
+
+#[community-testing]
+#Include = /etc/pacman.d/mirrorlist
+
+[community]
+Include = /etc/pacman.d/mirrorlist
+
+# If you want to run 32 bit applications on your x86_64 system,
+# enable the multilib repositories as required here.
+
+#[multilib-testing]
+#Include = /etc/pacman.d/mirrorlist
+
+#[multilib]
+#Include = /etc/pacman.d/mirrorlist
+
+# An example of a custom package repository. See the pacman manpage for
+# tips on creating your own repositories.
+#[custom]
+#SigLevel = Optional TrustAll
+#Server = file:///home/custompkgs
diff --git a/cdist/conf/type/__pacman_conf_integrate/man.rst b/cdist/conf/type/__pacman_conf_integrate/man.rst
new file mode 100644
index 00000000..6a856efe
--- /dev/null
+++ b/cdist/conf/type/__pacman_conf_integrate/man.rst
@@ -0,0 +1,44 @@
+cdist-type__pacman_conf_integrate(7)
+====================================
+Integrate default pacman.conf to cdist conform and vice versa
+
+Dominique Roux
+
+
+DESCRIPTION
+-----------
+The type allows you to convert the default pacman.conf to a cdist conform one and vice versa
+
+
+REQUIRED PARAMETERS
+-------------------
+None.
+
+OPTIONAL PARAMETERS
+-------------------
+state
+ 'present' or 'absent', defaults to 'present'
+
+
+EXAMPLES
+--------
+
+.. code-block:: sh
+
+ # Convert normal to cdist conform
+ __pacman_conf_integrate convert
+
+ # Convert cdist conform to normal
+ __pacman_conf_integrate convert --state absent
+
+
+SEE ALSO
+--------
+- `cdist-type(7) `_
+- grep(1)
+
+
+COPYING
+-------
+Copyright \(C) 2015 Dominique Roux. Free use of this software is
+granted under the terms of the GNU General Public License version 3 (GPLv3).
diff --git a/cdist/conf/type/__pacman_conf_integrate/manifest b/cdist/conf/type/__pacman_conf_integrate/manifest
new file mode 100644
index 00000000..1d02f3b3
--- /dev/null
+++ b/cdist/conf/type/__pacman_conf_integrate/manifest
@@ -0,0 +1,59 @@
+#!/bin/sh
+#
+# 2015 Dominique Roux (dominique.roux4 at gmail.com
+#
+# This file is part of cdist.
+#
+# cdist is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# cdist is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with cdist. If not, see .
+#
+
+state=$(cat $__object/parameter/state 2>/dev/null)
+
+path="/etc/"
+
+if [ "${state}" = "present" ]; then
+ __file /etc/pacman.conf\
+ --owner root --group root --mode 644 --source $__type/files/pacman.conf.cdist
+
+ __file /etc/pacman.d/options\
+ --owner root --group root --mode 644 --source $__type/files/options
+
+ __file /etc/pacman.d/repo_empty_placeholder\
+ --owner root --group root --mode 644
+
+ __file /etc/pacman.d/plain_file_empty_placeholder\
+ --owner root --group root --mode 644
+
+elif [ "${state}" = "absent" ]; then
+
+ __file /etc/pacman.conf\
+ --owner root --group root --mode 644 --source $__type/files/pacman.conf.pacman
+
+ __file /etc/pacman.d/mirrorlist\
+ --owner root --group root --mode 644 --source $__type/files/mirrorlist
+
+ __file /etc/pacman.d/options\
+ --state absent
+
+ __file /etc/pacman.d/repo_empty_placeholder\
+ --state absent
+
+ __file /etc/pacman.d/plain_file_empty_placeholder\
+ --state absent
+
+else
+
+ echo "ERROR: Unknown state: ${state}" >&2
+
+fi
diff --git a/cdist/conf/type/__pacman_conf_integrate/parameter/default/state b/cdist/conf/type/__pacman_conf_integrate/parameter/default/state
new file mode 100644
index 00000000..e7f6134f
--- /dev/null
+++ b/cdist/conf/type/__pacman_conf_integrate/parameter/default/state
@@ -0,0 +1 @@
+present
diff --git a/cdist/conf/type/__pacman_conf_integrate/parameter/optional b/cdist/conf/type/__pacman_conf_integrate/parameter/optional
new file mode 100644
index 00000000..ff72b5c7
--- /dev/null
+++ b/cdist/conf/type/__pacman_conf_integrate/parameter/optional
@@ -0,0 +1 @@
+state
diff --git a/cdist/conf/type/__pf_apply/man.rst b/cdist/conf/type/__pf_apply/man.rst
new file mode 100644
index 00000000..0b440e2d
--- /dev/null
+++ b/cdist/conf/type/__pf_apply/man.rst
@@ -0,0 +1,53 @@
+cdist-type__pf_apply(7)
+=======================
+Apply pf(4) ruleset on \*BSD
+
+Jake Guffey
+
+
+NAME
+----
+
+
+DESCRIPTION
+-----------
+This type is used on \*BSD systems to manage the pf firewall's active ruleset.
+
+
+REQUIRED PARAMETERS
+-------------------
+NONE
+
+
+OPTIONAL PARAMETERS
+-------------------
+NONE
+
+
+EXAMPLES
+--------
+
+.. code-block:: sh
+
+ # Modify the ruleset on $__target_host:
+ __pf_ruleset --state present --source /my/pf/ruleset.conf
+ require="__pf_ruleset" \
+ __pf_apply
+
+ # Remove the ruleset on $__target_host (implies disabling pf(4):
+ __pf_ruleset --state absent
+ require="__pf_ruleset" \
+ __pf_apply
+
+
+SEE ALSO
+--------
+- `cdist-type(7) `_
+- `cdist-type__pf_ruleset(7) `_
+- pf(4)
+
+
+COPYING
+-------
+Copyright \(C) 2012 Jake Guffey. Free use of this software is
+granted under the terms of the GNU General Public License version 3 (GPLv3).
diff --git a/cdist/conf/type/__pf_apply/man.text b/cdist/conf/type/__pf_apply/man.text
deleted file mode 100644
index 2e0d7802..00000000
--- a/cdist/conf/type/__pf_apply/man.text
+++ /dev/null
@@ -1,52 +0,0 @@
-cdist-type__pf_apply(7)
-=======================
-Jake Guffey
-
-
-NAME
-----
-cdist-type__pf_apply - Apply pf(4) ruleset on *BSD
-
-
-DESCRIPTION
------------
-This type is used on *BSD systems to manage the pf firewall's active ruleset.
-
-
-REQUIRED PARAMETERS
--------------------
-NONE
-
-
-OPTIONAL PARAMETERS
--------------------
-NONE
-
-
-EXAMPLES
---------
-
---------------------------------------------------------------------------------
-# Modify the ruleset on $__target_host:
-__pf_ruleset --state present --source /my/pf/ruleset.conf
-require="__pf_ruleset" \
- __pf_apply
-
-# Remove the ruleset on $__target_host (implies disabling pf(4):
-__pf_ruleset --state absent
-require="__pf_ruleset" \
- __pf_apply
---------------------------------------------------------------------------------
-
-
-SEE ALSO
---------
-- cdist-type(7)
-- cdist-type__pf_ruleset(7)
-- pf(4)
-
-
-COPYING
--------
-Copyright \(C) 2012 Jake Guffey. Free use of this software is
-granted under the terms of the GNU General Public License version 3 (GPLv3).
diff --git a/cdist/conf/type/__pf_ruleset/man.text b/cdist/conf/type/__pf_ruleset/man.rst
similarity index 57%
rename from cdist/conf/type/__pf_ruleset/man.text
rename to cdist/conf/type/__pf_ruleset/man.rst
index 29efe065..b3e9b073 100644
--- a/cdist/conf/type/__pf_ruleset/man.text
+++ b/cdist/conf/type/__pf_ruleset/man.rst
@@ -1,27 +1,24 @@
cdist-type__pf_ruleset(7)
=========================
+Copy a pf(4) ruleset to $__target_host
+
Jake Guffey
-NAME
-----
-cdist-type__pf_ruleset - Copy a pf(4) ruleset to $__target_host
-
-
DESCRIPTION
-----------
-This type is used on *BSD systems to manage the pf firewall's ruleset.
+This type is used on \*BSD systems to manage the pf firewall's ruleset.
REQUIRED PARAMETERS
-------------------
-state::
+state
Either "absent" (no ruleset at all) or "present", defaults to "present".
OPTIONAL PARAMETERS
-------------------
-source::
+source
If supplied, use to define the ruleset to load onto the $__target_host for pf(4).
Note that this type is almost useless without a ruleset defined, but it's technically not
needed, e.g. for the case of disabling the firewall temporarily.
@@ -30,19 +27,18 @@ source::
EXAMPLES
--------
---------------------------------------------------------------------------------
-# Remove the current ruleset in place
-__pf_ruleset --state absent
+.. code-block:: sh
-# Enable the firewall with the ruleset defined in $__manifest/files/pf.conf
-__pf_ruleset --state present --source $__manifest/files/pf.conf
+ # Remove the current ruleset in place
+ __pf_ruleset --state absent
---------------------------------------------------------------------------------
+ # Enable the firewall with the ruleset defined in $__manifest/files/pf.conf
+ __pf_ruleset --state present --source $__manifest/files/pf.conf
SEE ALSO
--------
-- cdist-type(7)
+- `cdist-type(7) `_
- pf(4)
diff --git a/cdist/conf/type/__postfix/man.text b/cdist/conf/type/__postfix/man.rst
similarity index 66%
rename from cdist/conf/type/__postfix/man.text
rename to cdist/conf/type/__postfix/man.rst
index 1a91723a..d10a9960 100644
--- a/cdist/conf/type/__postfix/man.text
+++ b/cdist/conf/type/__postfix/man.rst
@@ -1,13 +1,10 @@
cdist-type__postfix(7)
======================
+Install postfix
+
Steven Armstrong
-NAME
-----
-cdist-type__postfix - install postfix
-
-
DESCRIPTION
-----------
This space intentionally left blank.
@@ -26,14 +23,14 @@ None.
EXAMPLES
--------
---------------------------------------------------------------------------------
-__postfix
---------------------------------------------------------------------------------
+.. code-block:: sh
+
+ __postfix
SEE ALSO
--------
-- cdist-type(7)
+- `cdist-type(7) `_
COPYING
diff --git a/cdist/conf/type/__postfix/manifest b/cdist/conf/type/__postfix/manifest
index 52a13919..43443e1e 100755
--- a/cdist/conf/type/__postfix/manifest
+++ b/cdist/conf/type/__postfix/manifest
@@ -1,6 +1,6 @@
#!/bin/sh
#
-# 2012 Steven Armstrong (steven-cdist at armstrong.cc)
+# 2012-2014 Steven Armstrong (steven-cdist at armstrong.cc)
#
# This file is part of cdist.
#
@@ -22,7 +22,7 @@
os=$(cat "$__global/explorer/os")
case "$os" in
- ubuntu|debian|archlinux|suse)
+ ubuntu|debian|archlinux|suse|centos|devuan)
__package postfix --state present
;;
*)
diff --git a/cdist/conf/type/__postfix_master/man.text b/cdist/conf/type/__postfix_master/man.rst
similarity index 51%
rename from cdist/conf/type/__postfix_master/man.text
rename to cdist/conf/type/__postfix_master/man.rst
index 0ec78752..4853e687 100644
--- a/cdist/conf/type/__postfix_master/man.text
+++ b/cdist/conf/type/__postfix_master/man.rst
@@ -1,13 +1,10 @@
cdist-type__postfix_master(7)
=============================
+Configure postfix master.cf
+
Steven Armstrong
-NAME
-----
-cdist-type__postfix_master - configure postfix master.cf
-
-
DESCRIPTION
-----------
See master(5) for more information.
@@ -15,54 +12,62 @@ See master(5) for more information.
REQUIRED PARAMETERS
-------------------
-type::
+type
See master(5)
-command::
+command
See master(5)
BOOLEAN PARAMETERS
------------------
-noreload::
+noreload
don't reload postfix after changes
OPTIONAL PARAMETERS
-------------------
-state::
+state
present or absent, defaults to present
-service::
-private::
-unpriv::
-chroot::
-wakeup::
-maxproc::
-option::
+
+service
+
+private
+
+unpriv
+
+chroot
+
+wakeup
+
+maxproc
+
+option
Pass an option to a service. Same as using -o in master.cf.
Can be specified multiple times.
-comment::
+
+comment
a textual comment to add with the master.cf entry
EXAMPLES
--------
---------------------------------------------------------------------------------
-__postfix_master smtp --type inet --command smtpd
+.. code-block:: sh
-__postfix_master smtp --type inet --chroot y --command smtpd \
- --option smtpd_enforce_tls=yes \
- --option smtpd_sasl_auth_enable=yes \
- --option smtpd_client_restrictions=permit_sasl_authenticated,reject
+ __postfix_master smtp --type inet --command smtpd
-__postfix_master submission --type inet --command smtpd \
- --comment "Run alternative smtp on submission port"
---------------------------------------------------------------------------------
+ __postfix_master smtp --type inet --chroot y --command smtpd \
+ --option smtpd_enforce_tls=yes \
+ --option smtpd_sasl_auth_enable=yes \
+ --option smtpd_client_restrictions=permit_sasl_authenticated,reject
+
+ __postfix_master submission --type inet --command smtpd \
+ --comment "Run alternative smtp on submission port"
SEE ALSO
--------
-- cdist-type(7)
+- `cdist-type(7) `_
- master(5)
diff --git a/cdist/conf/type/__postfix_master/manifest b/cdist/conf/type/__postfix_master/manifest
index 87e2329b..3d82c526 100755
--- a/cdist/conf/type/__postfix_master/manifest
+++ b/cdist/conf/type/__postfix_master/manifest
@@ -1,6 +1,6 @@
#!/bin/sh
#
-# 2012 - 2013 Steven Armstrong (steven-cdist at armstrong.cc)
+# 2012-2014 Steven Armstrong (steven-cdist at armstrong.cc)
#
# This file is part of cdist.
#
@@ -22,7 +22,7 @@
os=$(cat "$__global/explorer/os")
case "$os" in
- ubuntu|debian|archlinux)
+ ubuntu|debian|archlinux|centos|devuan)
:
;;
*)
diff --git a/cdist/conf/type/__postfix_postconf/explorer/value b/cdist/conf/type/__postfix_postconf/explorer/value
index e08c6da6..d451bce6 100755
--- a/cdist/conf/type/__postfix_postconf/explorer/value
+++ b/cdist/conf/type/__postfix_postconf/explorer/value
@@ -1,6 +1,6 @@
#!/bin/sh
#
-# 2012 Steven Armstrong (steven-cdist at armstrong.cc)
+# 2012-2014 Steven Armstrong (steven-cdist at armstrong.cc)
#
# This file is part of cdist.
#
@@ -22,7 +22,7 @@
os=$("$__explorer/os")
case "$os" in
- ubuntu|debian|archlinux|suse)
+ ubuntu|debian|archlinux|suse|centos|devuan)
:
;;
*)
diff --git a/cdist/conf/type/__postfix_postconf/gencode-remote b/cdist/conf/type/__postfix_postconf/gencode-remote
index 43c0482e..b3557640 100755
--- a/cdist/conf/type/__postfix_postconf/gencode-remote
+++ b/cdist/conf/type/__postfix_postconf/gencode-remote
@@ -1,6 +1,6 @@
#!/bin/sh
#
-# 2012 Steven Armstrong (steven-cdist at armstrong.cc)
+# 2012-2014 Steven Armstrong (steven-cdist at armstrong.cc)
#
# This file is part of cdist.
#
@@ -21,7 +21,7 @@
os=$(cat "$__global/explorer/os")
case "$os" in
- ubuntu|debian|archlinux|suse)
+ ubuntu|debian|archlinux|suse|centos|devuan)
:
;;
*)
diff --git a/cdist/conf/type/__postfix_postconf/man.text b/cdist/conf/type/__postfix_postconf/man.rst
similarity index 64%
rename from cdist/conf/type/__postfix_postconf/man.text
rename to cdist/conf/type/__postfix_postconf/man.rst
index 727637b1..e07e136f 100644
--- a/cdist/conf/type/__postfix_postconf/man.text
+++ b/cdist/conf/type/__postfix_postconf/man.rst
@@ -1,13 +1,10 @@
cdist-type__postfix_postconf(7)
===============================
+Configure postfix main.cf
+
Steven Armstrong
-NAME
-----
-cdist-type__postfix_postconf - configure postfix main.cf
-
-
DESCRIPTION
-----------
See postconf(5) for possible keys and values.
@@ -18,30 +15,29 @@ It does not make changes to /etc/postfix/main.cf itself.
REQUIRED PARAMETERS
-------------------
-value::
+value
the value for the postfix parameter
OPTIONAL PARAMETERS
-------------------
-key::
+key
the name of the parameter. Defaults to __object_id
EXAMPLES
--------
---------------------------------------------------------------------------------
-__postfix_postconf mydomain --value somedomain.com
+.. code-block:: sh
-__postfix_postconf bind-to-special-ip --key smtp_bind_address --value 127.0.0.5
+ __postfix_postconf mydomain --value somedomain.com
---------------------------------------------------------------------------------
+ __postfix_postconf bind-to-special-ip --key smtp_bind_address --value 127.0.0.5
SEE ALSO
--------
-- cdist-type(7)
+- `cdist-type(7) `_
- postconf(5)
diff --git a/cdist/conf/type/__postfix_postconf/manifest b/cdist/conf/type/__postfix_postconf/manifest
index 0dde64e9..dbce5364 100755
--- a/cdist/conf/type/__postfix_postconf/manifest
+++ b/cdist/conf/type/__postfix_postconf/manifest
@@ -1,6 +1,6 @@
#!/bin/sh
#
-# 2012 - 2013 Steven Armstrong (steven-cdist at armstrong.cc)
+# 2012-2014 Steven Armstrong (steven-cdist at armstrong.cc)
#
# This file is part of cdist.
#
diff --git a/cdist/conf/type/__postfix_postmap/man.text b/cdist/conf/type/__postfix_postmap/man.rst
similarity index 62%
rename from cdist/conf/type/__postfix_postmap/man.text
rename to cdist/conf/type/__postfix_postmap/man.rst
index 37060d04..ecee6722 100644
--- a/cdist/conf/type/__postfix_postmap/man.text
+++ b/cdist/conf/type/__postfix_postmap/man.rst
@@ -1,13 +1,10 @@
cdist-type__postfix_postmap(7)
==============================
+Run postmap on the given file
+
Steven Armstrong
-NAME
-----
-cdist-type__postfix_postmap - run postmap on the given file
-
-
DESCRIPTION
-----------
This space intentionally left blank.
@@ -26,14 +23,14 @@ None.
EXAMPLES
--------
---------------------------------------------------------------------------------
-__postfix_postmap /etc/postfix/generic
---------------------------------------------------------------------------------
+.. code-block:: sh
+
+ __postfix_postmap /etc/postfix/generic
SEE ALSO
--------
-- cdist-type(7)
+- `cdist-type(7) `_
COPYING
diff --git a/cdist/conf/type/__postfix_postmap/manifest b/cdist/conf/type/__postfix_postmap/manifest
index 0dde64e9..dbce5364 100755
--- a/cdist/conf/type/__postfix_postmap/manifest
+++ b/cdist/conf/type/__postfix_postmap/manifest
@@ -1,6 +1,6 @@
#!/bin/sh
#
-# 2012 - 2013 Steven Armstrong (steven-cdist at armstrong.cc)
+# 2012-2014 Steven Armstrong (steven-cdist at armstrong.cc)
#
# This file is part of cdist.
#
diff --git a/cdist/conf/type/__postfix_reload/gencode-remote b/cdist/conf/type/__postfix_reload/gencode-remote
index 5822f1e3..7323606c 100755
--- a/cdist/conf/type/__postfix_reload/gencode-remote
+++ b/cdist/conf/type/__postfix_reload/gencode-remote
@@ -1,6 +1,6 @@
#!/bin/sh
#
-# 2012 Steven Armstrong (steven-cdist at armstrong.cc)
+# 2012-2014 Steven Armstrong (steven-cdist at armstrong.cc)
#
# This file is part of cdist.
#
@@ -22,7 +22,7 @@
os=$(cat "$__global/explorer/os")
case "$os" in
- ubuntu|debian|archlinux)
+ ubuntu|debian|archlinux|centos|devuan)
echo "postfix reload"
;;
*)
diff --git a/cdist/conf/type/__postfix_reload/man.text b/cdist/conf/type/__postfix_reload/man.rst
similarity index 63%
rename from cdist/conf/type/__postfix_reload/man.text
rename to cdist/conf/type/__postfix_reload/man.rst
index c63356b5..c5101953 100644
--- a/cdist/conf/type/__postfix_reload/man.text
+++ b/cdist/conf/type/__postfix_reload/man.rst
@@ -1,13 +1,10 @@
cdist-type__postfix_reload(7)
=============================
+Tell postfix to reload its configuration
+
Steven Armstrong
-NAME
-----
-cdist-type__postfix_reload - tell postfix to reload its configuration
-
-
DESCRIPTION
-----------
This space intentionally left blank.
@@ -26,14 +23,14 @@ None.
EXAMPLES
--------
---------------------------------------------------------------------------------
-__postfix_reload
---------------------------------------------------------------------------------
+.. code-block:: sh
+
+ __postfix_reload
SEE ALSO
--------
-- cdist-type(7)
+- `cdist-type(7) `_
COPYING
diff --git a/cdist/conf/type/__postfix_reload/manifest b/cdist/conf/type/__postfix_reload/manifest
index 0dde64e9..dbce5364 100755
--- a/cdist/conf/type/__postfix_reload/manifest
+++ b/cdist/conf/type/__postfix_reload/manifest
@@ -1,6 +1,6 @@
#!/bin/sh
#
-# 2012 - 2013 Steven Armstrong (steven-cdist at armstrong.cc)
+# 2012-2014 Steven Armstrong (steven-cdist at armstrong.cc)
#
# This file is part of cdist.
#
diff --git a/cdist/conf/type/__postgres_database/man.text b/cdist/conf/type/__postgres_database/man.rst
similarity index 60%
rename from cdist/conf/type/__postgres_database/man.text
rename to cdist/conf/type/__postgres_database/man.rst
index c7c0d3cd..152ee910 100644
--- a/cdist/conf/type/__postgres_database/man.text
+++ b/cdist/conf/type/__postgres_database/man.rst
@@ -1,13 +1,10 @@
cdist-type__postgres_database(7)
================================
+Create/drop postgres databases
+
Steven Armstrong
-NAME
-----
-cdist-type__postgres_database - create/drop postgres databases
-
-
DESCRIPTION
-----------
This cdist type allows you to create or drop postgres databases.
@@ -15,25 +12,25 @@ This cdist type allows you to create or drop postgres databases.
OPTIONAL PARAMETERS
-------------------
-state::
+state
either 'present' or 'absent', defaults to 'present'.
-owner::
+owner
the role owning this database
EXAMPLES
--------
---------------------------------------------------------------------------------
-__postgres_database mydbname --owner mydbusername
---------------------------------------------------------------------------------
+.. code-block:: sh
+
+ __postgres_database mydbname --owner mydbusername
SEE ALSO
--------
-- cdist-type(7)
-- cdist-type__postgres_role(7)
+- `cdist-type(7) `_
+- `cdist-type__postgres_role(7) `_
COPYING
diff --git a/cdist/conf/type/__postgres_role/man.text b/cdist/conf/type/__postgres_role/man.rst
similarity index 59%
rename from cdist/conf/type/__postgres_role/man.text
rename to cdist/conf/type/__postgres_role/man.rst
index ac87754b..6384568f 100644
--- a/cdist/conf/type/__postgres_role/man.text
+++ b/cdist/conf/type/__postgres_role/man.rst
@@ -1,13 +1,10 @@
cdist-type__postgres_role(7)
============================
+Manage postgres roles
+
Steven Armstrong
-NAME
-----
-cdist-type__postgres_role - manage postgres roles
-
-
DESCRIPTION
-----------
This cdist type allows you to create or drop postgres roles.
@@ -15,43 +12,43 @@ This cdist type allows you to create or drop postgres roles.
OPTIONAL PARAMETERS
-------------------
-state::
+state
Either "present" or "absent", defaults to "present"
All other parameters map directly to the corresponding postgres createrole
parameters.
-password::
+password
BOOLEAN PARAMETERS
------------------
All parameter map directly to the corresponding postgres createrole
parameters.
-login::
-createdb::
-createrole::
-superuser::
-inherit::
+login
+createdb
+createrole
+superuser
+inherit
EXAMPLES
--------
---------------------------------------------------------------------------------
-__postgres_role myrole
+.. code-block:: sh
-__postgres_role myrole --password 'secret'
+ __postgres_role myrole
-__postgres_role admin --password 'very-secret' --superuser
+ __postgres_role myrole --password 'secret'
-__postgres_role dbcustomer --password 'bla' --createdb
---------------------------------------------------------------------------------
+ __postgres_role admin --password 'very-secret' --superuser
+
+ __postgres_role dbcustomer --password 'bla' --createdb
SEE ALSO
--------
-- cdist-type(7)
-- cdist-type__postgres_database(7)
+- `cdist-type(7) `_
+- `cdist-type__postgres_database(7) `_
- http://www.postgresql.org/docs/current/static/sql-createrole.html
diff --git a/cdist/conf/type/__process/man.rst b/cdist/conf/type/__process/man.rst
new file mode 100644
index 00000000..09032a1a
--- /dev/null
+++ b/cdist/conf/type/__process/man.rst
@@ -0,0 +1,67 @@
+cdist-type__process(7)
+======================
+Start or stop process
+
+Nico Schottelius
+
+
+DESCRIPTION
+-----------
+This cdist type allows you to define the state of a process.
+
+
+OPTIONAL PARAMETERS
+-------------------
+state
+ Either "present" or "absent", defaults to "present"
+
+name
+ Process name to match on when using pgrep -f -x.
+
+ This is useful, if the name starts with a "/",
+ because the leading slash is stripped away from
+ the object id by cdist.
+
+stop
+ Executable to use for stopping the process.
+
+start
+ Executable to use for starting the process.
+
+
+EXAMPLES
+--------
+
+.. code-block:: sh
+
+ # Start if not running
+ __process /usr/sbin/syslog-ng --state present
+
+ # Start if not running with a different binary
+ __process /usr/sbin/nginx --state present --start "/etc/rc.d/nginx start"
+
+ # Stop the process using kill (the type default) - DO NOT USE THIS
+ __process /usr/sbin/sshd --state absent
+
+ # Stop the process using /etc/rc.d/sshd stop - THIS ONE NOT AS WELL
+ __process /usr/sbin/sshd --state absent --stop "/etc/rc.d/sshd stop"
+
+ # Ensure cups is running, which runs with -C ...:
+ __process cups --start "/etc/rc.d/cups start" --state present \
+ --name "/usr/sbin/cupsd -C /etc/cups/cupsd.conf"
+
+ # Ensure rpc.statd is running (which usually runs with -L) using a regexp
+ __process rpcstatd --state present --start "/etc/init.d/statd start" \
+ --name "rpc.statd.*"
+
+
+SEE ALSO
+--------
+- `cdist-type(7) `_
+- `cdist-type__start_on_boot(7) `_
+
+
+COPYING
+-------
+Copyright \(C) 2011-2012 Nico Schottelius. Free use of this software is
+granted under the terms of the GNU General Public License version 3 (GPLv3).
diff --git a/cdist/conf/type/__process/man.text b/cdist/conf/type/__process/man.text
deleted file mode 100644
index 2fdd27aa..00000000
--- a/cdist/conf/type/__process/man.text
+++ /dev/null
@@ -1,70 +0,0 @@
-cdist-type__process(7)
-======================
-Nico Schottelius
-
-
-NAME
-----
-cdist-type__process - Start or stop process
-
-
-DESCRIPTION
------------
-This cdist type allows you to define the state of a process.
-
-
-OPTIONAL PARAMETERS
--------------------
-state::
- Either "present" or "absent", defaults to "present"
-
-name::
- Process name to match on when using pgrep -f -x.
-
- This is useful, if the name starts with a "/",
- because the leading slash is stripped away from
- the object id by cdist.
-
-stop::
- Executable to use for stopping the process.
-
-start::
- Executable to use for starting the process.
-
-
-EXAMPLES
---------
-
---------------------------------------------------------------------------------
-# Start if not running
-__process /usr/sbin/syslog-ng --state present
-
-# Start if not running with a different binary
-__process /usr/sbin/nginx --state present --start "/etc/rc.d/nginx start"
-
-# Stop the process using kill (the type default) - DO NOT USE THIS
-__process /usr/sbin/sshd --state absent
-
-# Stop the process using /etc/rc.d/sshd stop - THIS ONE NOT AS WELL
-__process /usr/sbin/sshd --state absent --stop "/etc/rc.d/sshd stop"
-
-# Ensure cups is running, which runs with -C ...:
-__process cups --start "/etc/rc.d/cups start" --state present \
- --name "/usr/sbin/cupsd -C /etc/cups/cupsd.conf"
-
-# Ensure rpc.statd is running (which usually runs with -L) using a regexp
-__process rpcstatd --state present --start "/etc/init.d/statd start" \
- --name "rpc.statd.*"
---------------------------------------------------------------------------------
-
-
-SEE ALSO
---------
-- cdist-type(7)
-- cdist-type__start_on_boot(7)
-
-
-COPYING
--------
-Copyright \(C) 2011-2012 Nico Schottelius. Free use of this software is
-granted under the terms of the GNU General Public License version 3 (GPLv3).
diff --git a/cdist/conf/type/__pyvenv/explorer/group b/cdist/conf/type/__pyvenv/explorer/group
new file mode 100755
index 00000000..ff072c5e
--- /dev/null
+++ b/cdist/conf/type/__pyvenv/explorer/group
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+destination="/$__object_id"
+
+stat --print "%G" ${destination} 2>/dev/null || exit 0
diff --git a/cdist/conf/type/__pyvenv/explorer/owner b/cdist/conf/type/__pyvenv/explorer/owner
new file mode 100755
index 00000000..b77e3c6e
--- /dev/null
+++ b/cdist/conf/type/__pyvenv/explorer/owner
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+destination="/$__object_id"
+
+stat --print "%U" ${destination} 2>/dev/null || exit 0
diff --git a/cdist/conf/type/__pyvenv/explorer/state b/cdist/conf/type/__pyvenv/explorer/state
new file mode 100755
index 00000000..ffe3cbbd
--- /dev/null
+++ b/cdist/conf/type/__pyvenv/explorer/state
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+destination="/$__object_id"
+
+if [ -d "$destination" ]; then
+ echo present
+else
+ echo absent
+fi
diff --git a/cdist/conf/type/__pyvenv/gencode-remote b/cdist/conf/type/__pyvenv/gencode-remote
new file mode 100755
index 00000000..907e0ff6
--- /dev/null
+++ b/cdist/conf/type/__pyvenv/gencode-remote
@@ -0,0 +1,67 @@
+#!/bin/sh
+#
+# 2016 Darko Poljak (darko.poljak at gmail.com)
+#
+# This file is part of cdist.
+#
+# cdist is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# cdist is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with cdist. If not, see .
+#
+#
+
+state_is="$(cat "$__object/explorer/state")"
+owner_is="$(cat "$__object/explorer/owner")"
+group_is="$(cat "$__object/explorer/group")"
+
+state_should="$(cat "$__object/parameter/state")"
+
+owner="$(cat "$__object/parameter/owner")"
+group="$(cat "$__object/parameter/group")"
+mode="$(cat "$__object/parameter/mode")"
+
+[ "$state_should" = "$state_is" -a \
+ "$owner" = "$owner_is" -a \
+ "$group" = "$group_is" -a \
+ -n "$mode" ] && exit 0
+
+destination="/$__object_id"
+venvparams="$(cat "$__object/parameter/venvparams")"
+pyvenvparam="$__object/parameter/pyvenv"
+if [ -f "$pyvenvparam" ]
+then
+ pyvenv=$(cat "$pyvenvparam")
+else
+ pyvenv="pyvenv"
+fi
+
+case $state_should in
+ present)
+ if [ "$state_should" != "$state_is" ]; then
+ echo $pyvenv $venvparams "$destination"
+ fi
+ if [ \( -n "$owner" -a "$owner_is" != "$owner" \) -o \
+ \( -n "$group" -a "$group_is" != "$group" \) ]; then
+ echo chown -R "${owner}:${group}" "$destination"
+ fi
+ if [ -n "$mode" ]; then
+ echo chmod -R "$mode" "$destination"
+ fi
+ ;;
+ absent)
+ ;;
+
+ *)
+ echo "Unknown state: $state_should" >&2
+ exit 1
+ ;;
+esac
diff --git a/cdist/conf/type/__pyvenv/man.rst b/cdist/conf/type/__pyvenv/man.rst
new file mode 100755
index 00000000..bdc1166c
--- /dev/null
+++ b/cdist/conf/type/__pyvenv/man.rst
@@ -0,0 +1,78 @@
+cdist-type__pyvenv(7)
+=====================
+Create or remove python virtual environment
+
+Darko Poljak
+
+
+DESCRIPTION
+-----------
+This cdist type allows you to create or remove python virtual
+environment using pyvenv.
+It assumes pyvenv is already installed. Concrete package depends
+on concrete OS and/or OS version/distribution.
+Ensure this for e.g. in your init manifest as in the following example:
+
+.. code-block sh
+
+ case "$__target_host" in
+ localhost)
+ __package python3-venv --state present
+ require="__package/python3-venv" __pyvenv /home/darko/testenv --pyvenv "pyvenv-3.4" --owner darko --group darko --mode 740 --state present
+ require="__pyvenv/home/darko/testenv" __package_pip docopt --pip /home/darko/testenv/bin/pip --runas darko --state present
+ ;;
+ esac
+
+
+REQUIRED PARAMETERS
+-------------------
+None
+
+OPTIONAL PARAMETERS
+-------------------
+state
+ Either "present" or "absent", defaults to "present"
+
+group
+ Group to chgrp to
+
+mode
+ Unix permissions, suitable for chmod
+
+owner
+ User to chown to
+
+pyvenv
+ Use this specific pyvenv
+
+venvparams
+ Specific parameters to pass to pyvenv invocation
+
+
+EXAMPLES
+--------
+
+.. code-block:: sh
+
+ __pyvenv /home/services/djangoenv
+
+ # Use specific pyvenv
+ __pyvenv /home/foo/fooenv --pyvenv /usr/local/bin/pyvenv-3.4
+
+ # Create python virtualenv for user foo.
+ __pyvenv /home/foo/fooenv --group foo --user foo
+
+ # Create python virtualenv with specific parameters.
+ __pyvenv /home/services/djangoenv --venvparams "--copies --system-site-packages"
+
+
+SEE ALSO
+--------
+- `cdist-type(7) `_
+
+
+COPYING
+-------
+Copyright \(C) 2016 Darko Poljak. Free use of this software is
+granted under the terms of the GNU General Public License version 3 (GPLv3).
+
diff --git a/cdist/conf/type/__pyvenv/manifest b/cdist/conf/type/__pyvenv/manifest
new file mode 100755
index 00000000..3e41ad04
--- /dev/null
+++ b/cdist/conf/type/__pyvenv/manifest
@@ -0,0 +1,46 @@
+#!/bin/sh
+#
+# 2016 Darko Poljak (darko.poljak at gmail.com)
+#
+# This file is part of cdist.
+#
+# cdist is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# cdist is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with cdist. If not, see .
+#
+
+# It assumes pyvenv is already installed. Concrete packages
+# or installation procedures depend on concrete OS and/or OS
+# version/distribution.
+
+state_should="$(cat "$__object/parameter/state")"
+owner="$(cat "$__object/parameter/owner")"
+group="$(cat "$__object/parameter/group")"
+mode="$(cat "$__object/parameter/mode")"
+
+case "$state_should" in
+ present)
+ :
+ ;;
+
+ absent)
+ __directory "$__object_id" --state absent \
+ --owner "$owner" \
+ --group "$group" \
+ --mode "$mode"
+ ;;
+
+ *)
+ echo "Unknown state: $state_should" >&2
+ exit 1
+ ;;
+esac
diff --git a/cdist/conf/type/__pyvenv/parameter/default/group b/cdist/conf/type/__pyvenv/parameter/default/group
new file mode 100755
index 00000000..8b137891
--- /dev/null
+++ b/cdist/conf/type/__pyvenv/parameter/default/group
@@ -0,0 +1 @@
+
diff --git a/cdist/conf/type/__pyvenv/parameter/default/mode b/cdist/conf/type/__pyvenv/parameter/default/mode
new file mode 100755
index 00000000..8b137891
--- /dev/null
+++ b/cdist/conf/type/__pyvenv/parameter/default/mode
@@ -0,0 +1 @@
+
diff --git a/cdist/conf/type/__pyvenv/parameter/default/owner b/cdist/conf/type/__pyvenv/parameter/default/owner
new file mode 100755
index 00000000..8b137891
--- /dev/null
+++ b/cdist/conf/type/__pyvenv/parameter/default/owner
@@ -0,0 +1 @@
+
diff --git a/cdist/conf/type/__pyvenv/parameter/default/state b/cdist/conf/type/__pyvenv/parameter/default/state
new file mode 100755
index 00000000..e7f6134f
--- /dev/null
+++ b/cdist/conf/type/__pyvenv/parameter/default/state
@@ -0,0 +1 @@
+present
diff --git a/cdist/conf/type/__pyvenv/parameter/default/venvparams b/cdist/conf/type/__pyvenv/parameter/default/venvparams
new file mode 100644
index 00000000..8b137891
--- /dev/null
+++ b/cdist/conf/type/__pyvenv/parameter/default/venvparams
@@ -0,0 +1 @@
+
diff --git a/cdist/conf/type/__pyvenv/parameter/optional b/cdist/conf/type/__pyvenv/parameter/optional
new file mode 100755
index 00000000..ed2218b1
--- /dev/null
+++ b/cdist/conf/type/__pyvenv/parameter/optional
@@ -0,0 +1,6 @@
+state
+group
+owner
+mode
+venvparams
+pyvenv
diff --git a/cdist/conf/type/__qemu_img/gencode-remote b/cdist/conf/type/__qemu_img/gencode-remote
index 6e4bb4d0..bffedd26 100644
--- a/cdist/conf/type/__qemu_img/gencode-remote
+++ b/cdist/conf/type/__qemu_img/gencode-remote
@@ -1,3 +1,5 @@
+#!/bin/sh
+#
################################################################################
# State: absent is handled by manifest - we need only to do stuff if image is
# not existing and state != absent
diff --git a/cdist/conf/type/__qemu_img/man.text b/cdist/conf/type/__qemu_img/man.rst
similarity index 56%
rename from cdist/conf/type/__qemu_img/man.text
rename to cdist/conf/type/__qemu_img/man.rst
index 0fe2bbec..598e06ab 100644
--- a/cdist/conf/type/__qemu_img/man.text
+++ b/cdist/conf/type/__qemu_img/man.rst
@@ -1,13 +1,10 @@
cdist-type__qemu_img(7)
-========================
+=======================
+Manage VM disk images
+
Nico Schottelius
-NAME
-----
-cdist-type__qemu_img - Manage VM disk images
-
-
DESCRIPTION
-----------
The qemu-img program is used to create qemu images for
@@ -17,9 +14,9 @@ qemu and (qemu-)kvm.
OPTIONAL PARAMETERS
-------------------
-state::
+state
Either "present" or "absent", defaults to "present"
-size::
+size
Size of the image in qemu-img compatible units.
Required if state is "present".
@@ -28,18 +25,18 @@ size::
EXAMPLES
--------
---------------------------------------------------------------------------------
-# Create a 50G size image
-__qemu_img /home/services/kvm/vm/myvmname/system-disk --size 50G
+.. code-block:: sh
-# Remove image
-__qemu_img /home/services/kvm/vm/myoldvm/system-disk --state absent
---------------------------------------------------------------------------------
+ # Create a 50G size image
+ __qemu_img /home/services/kvm/vm/myvmname/system-disk --size 50G
+
+ # Remove image
+ __qemu_img /home/services/kvm/vm/myoldvm/system-disk --state absent
SEE ALSO
--------
-- cdist-type(7)
+- `cdist-type(7) `_
- qemu-img(1)
diff --git a/cdist/conf/type/__qemu_img/manifest b/cdist/conf/type/__qemu_img/manifest
index bb2c9366..e0ff6e03 100644
--- a/cdist/conf/type/__qemu_img/manifest
+++ b/cdist/conf/type/__qemu_img/manifest
@@ -1,3 +1,5 @@
+#!/bin/sh
+#
################################################################################
# Default settings
#
diff --git a/cdist/conf/type/__rbenv/man.text b/cdist/conf/type/__rbenv/man.rst
similarity index 54%
rename from cdist/conf/type/__rbenv/man.text
rename to cdist/conf/type/__rbenv/man.rst
index c6ed5de2..314507fe 100644
--- a/cdist/conf/type/__rbenv/man.text
+++ b/cdist/conf/type/__rbenv/man.rst
@@ -1,13 +1,10 @@
cdist-type__rbenv(7)
====================
+Manage rbenv installation
+
Nico Schottelius
-NAME
-----
-cdist-type__rbenv - Manage rbenv installation
-
-
DESCRIPTION
-----------
This cdist type allows you to manage rbenv installations.
@@ -16,31 +13,31 @@ It also installs ruby-build.
OPTIONAL PARAMETERS
-------------------
-state::
+state
Either "present" or "absent", defaults to "present"
-owner::
+owner
Which user should own the rbenv installation, defaults to root
EXAMPLES
--------
---------------------------------------------------------------------------------
-# Install rbenv including ruby-build for nico
-__rbenv /home/nico
+.. code-block:: sh
-# Install rbenv including ruby-build for nico
-__rbenv /home/nico --owner nico
+ # Install rbenv including ruby-build for nico
+ __rbenv /home/nico
-# Bastian does not need rbenv anymore, he began to code C99
-__rbenv /home/bastian --state absent
---------------------------------------------------------------------------------
+ # Install rbenv including ruby-build for nico
+ __rbenv /home/nico --owner nico
+
+ # Bastian does not need rbenv anymore, he began to code C99
+ __rbenv /home/bastian --state absent
SEE ALSO
--------
-- cdist-type(7)
+- `cdist-type(7) `_
COPYING
diff --git a/cdist/conf/type/__rsync/gencode-local b/cdist/conf/type/__rsync/gencode-local
new file mode 100644
index 00000000..8d268d7e
--- /dev/null
+++ b/cdist/conf/type/__rsync/gencode-local
@@ -0,0 +1,39 @@
+#!/bin/sh
+#
+# 2015 Dominique Roux (dominique.roux4 at gmail.com)
+#
+# This file is part of cdist.
+#
+# cdist is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# cdist is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with cdist. If not, see .
+#
+
+source=$(cat "$__object/parameter/source")
+remote_user=$(cat "$__object/parameter/remote-user")
+
+if [ -f "$__object/parameter/destination" ]; then
+ destination=$(cat "$__object/parameter/destination")
+else
+ destination="/$__object_id"
+fi
+
+set --
+if [ -f "$__object/parameter/rsync-opts" ]; then
+ while read opts; do
+ set -- "$@" "--$opts"
+ done < $__object/parameter/rsync-opts
+fi
+
+echo rsync -a \
+ --no-owner --no-group \
+ -q "$@" "${source}/" "${remote_user}@${__target_host}:${destination}"
diff --git a/cdist/conf/type/__rsync/gencode-remote b/cdist/conf/type/__rsync/gencode-remote
new file mode 100644
index 00000000..a1135ea6
--- /dev/null
+++ b/cdist/conf/type/__rsync/gencode-remote
@@ -0,0 +1,37 @@
+#!/bin/sh
+#
+# 2015 Dominique Roux (dominique.roux4 at gmail.com)
+#
+# This file is part of cdist.
+#
+# cdist is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# cdist is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with cdist. If not, see .
+#
+
+if [ -f "$__object/parameter/destination" ]; then
+ destination=$(cat "$__object/parameter/destination")
+else
+ destination="/$__object_id"
+fi
+
+ownergroup=""
+if [ -f "$__object/parameter/owner" ]; then
+ ownergroup=$(cat "$__object/parameter/owner")
+fi
+if [ -f "$__object/parameter/group" ]; then
+ ownergroup="${ownergroup}:$(cat "$__object/parameter/group")"
+fi
+
+if [ "$ownergroup" ]; then
+ echo chown -R "$ownergroup" "$destination"
+fi
diff --git a/cdist/conf/type/__rsync/man.rst b/cdist/conf/type/__rsync/man.rst
new file mode 100644
index 00000000..bc7b1bca
--- /dev/null
+++ b/cdist/conf/type/__rsync/man.rst
@@ -0,0 +1,107 @@
+cdist-type__rsync(7)
+====================
+Mirror directories using rsync
+
+Nico Schottelius
+
+
+DESCRIPTION
+-----------
+WARNING: This type is of BETA quality:
+
+- it has not been tested widely
+- interfaces *may* change
+- if there is a better approach to solve the problem -> the type may even vanish
+
+If you are fine with these constraints, please read on.
+
+
+This cdist type allows you to mirror local directories to the
+target host using rsync. Rsync will be installed in the manifest of the type.
+If group or owner are giveng, a recursive chown will be executed on the
+target host.
+
+A slash will be appended to the source directory so that only the contents
+of the directory are taken and not the directory name itself.
+
+
+REQUIRED PARAMETERS
+-------------------
+source
+ Where to take files from
+
+
+OPTIONAL PARAMETERS
+-------------------
+group
+ Group to chgrp to.
+
+owner
+ User to chown to.
+
+destination
+ Use this as the base destination instead of the object id
+
+remote-user
+ Use this user instead of the default "root" for rsync operations.
+
+
+OPTIONAL MULTIPLE PARAMETERS
+----------------------------
+rsync-opts
+ Use this option to give rsync options with.
+ See rsync(1) for available options.
+ Only "--" options are supported.
+ Write the options without the beginning "--"
+ Can be specified multiple times.
+
+
+MESSAGES
+--------
+NONE
+
+
+EXAMPLES
+--------
+
+.. code-block:: sh
+
+ # You can use any source directory
+ __rsync /tmp/testdir \
+ --source /etc
+
+ # Use source from type
+ __rsync /etc \
+ --source "$__type/files/package"
+
+ # Allow multiple __rsync objects to write to the same dir
+ __rsync mystuff \
+ --destination /usr/local/bin \
+ --source "$__type/files/package"
+
+ __rsync otherstuff \
+ --destination /usr/local/bin \
+ --source "$__type/files/package2"
+
+ # Use rsync option --exclude
+ __rsync /tmp/testdir \
+ --source /etc \
+ --rsync-opts exclude=sshd_conf
+
+ # Use rsync with multiple options --exclude --dry-run
+ __rsync /tmp/testing \
+ --source /home/tester \
+ --rsync-opts exclude=id_rsa \
+ --rsync-opts dry-run
+
+
+SEE ALSO
+--------
+- `cdist-type(7) `_
+- rsync(1)
+
+
+COPYING
+-------
+Copyright \(C) 2015 Nico Schottelius. Free use of this software is
+granted under the terms of the GNU General Public License version 3 (GPLv3).
diff --git a/cdist/conf/type/__rsync/manifest b/cdist/conf/type/__rsync/manifest
new file mode 100644
index 00000000..0e4cc1f4
--- /dev/null
+++ b/cdist/conf/type/__rsync/manifest
@@ -0,0 +1,21 @@
+#!/bin/sh
+#
+# 2015 Dominique Roux (dominique.roux4 at gmail.com)
+#
+# This file is part of cdist.
+#
+# cdist is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# cdist is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with cdist. If not, see .
+#
+
+__package rsync
diff --git a/cdist/conf/type/__rsync/parameter/default/remote-user b/cdist/conf/type/__rsync/parameter/default/remote-user
new file mode 100644
index 00000000..d8649da3
--- /dev/null
+++ b/cdist/conf/type/__rsync/parameter/default/remote-user
@@ -0,0 +1 @@
+root
diff --git a/cdist/conf/type/__rsync/parameter/optional b/cdist/conf/type/__rsync/parameter/optional
new file mode 100644
index 00000000..ac2b2390
--- /dev/null
+++ b/cdist/conf/type/__rsync/parameter/optional
@@ -0,0 +1,4 @@
+destination
+owner
+group
+remote-user
diff --git a/cdist/conf/type/__rsync/parameter/optional_multiple b/cdist/conf/type/__rsync/parameter/optional_multiple
new file mode 100644
index 00000000..fdb7cd88
--- /dev/null
+++ b/cdist/conf/type/__rsync/parameter/optional_multiple
@@ -0,0 +1 @@
+rsync-opts
diff --git a/cdist/conf/type/__rsync/parameter/required b/cdist/conf/type/__rsync/parameter/required
new file mode 100644
index 00000000..5a18cd2f
--- /dev/null
+++ b/cdist/conf/type/__rsync/parameter/required
@@ -0,0 +1 @@
+source
diff --git a/cdist/conf/type/__rvm/man.text b/cdist/conf/type/__rvm/man.rst
similarity index 52%
rename from cdist/conf/type/__rvm/man.text
rename to cdist/conf/type/__rvm/man.rst
index 0408d125..8a3f72f5 100644
--- a/cdist/conf/type/__rvm/man.text
+++ b/cdist/conf/type/__rvm/man.rst
@@ -1,13 +1,10 @@
cdist-type__rvm(7)
==================
+Install rvm for a given user
+
Evax Software
-NAME
-----
-cdist-type__rvm - Install rvm for a given user
-
-
DESCRIPTION
-----------
RVM is the Ruby enVironment Manager for the Ruby programming language.
@@ -15,28 +12,28 @@ RVM is the Ruby enVironment Manager for the Ruby programming language.
REQUIRED PARAMETERS
-------------------
-state::
+state
Either "present" or "absent", defaults to "present".
EXAMPLES
--------
---------------------------------------------------------------------------------
-# Install rvm for user billie
-__rvm billie --state present
+.. code-block:: sh
-# Remove rvm
-__rvm billie --state absent
---------------------------------------------------------------------------------
+ # Install rvm for user billie
+ __rvm billie --state present
+
+ # Remove rvm
+ __rvm billie --state absent
SEE ALSO
--------
-- cdist-type(7)
-- cdist-type__rvm_ruby(7)
-- cdist-type__rvm_gemset(7)
-- cdist-type__rvm_gem(7)
+- `cdist-type(7) `_
+- `cdist-type__rvm_ruby(7) `_
+- `cdist-type__rvm_gemset(7) `_
+- `cdist-type__rvm_gem(7) `_
COPYING
diff --git a/cdist/conf/type/__rvm_gem/man.rst b/cdist/conf/type/__rvm_gem/man.rst
new file mode 100644
index 00000000..39d93065
--- /dev/null
+++ b/cdist/conf/type/__rvm_gem/man.rst
@@ -0,0 +1,54 @@
+cdist-type__rvm_gemset(7)
+==========================
+Manage Ruby gems through rvm
+
+Evax Software
+
+
+DESCRIPTION
+-----------
+RVM is the Ruby enVironment Manager for the Ruby programming language.
+
+
+REQUIRED PARAMETERS
+-------------------
+user
+ The remote user account to use
+gemset
+ The gemset to use
+state
+ Either "present" or "absent", defaults to "present".
+
+OPTIONAL PARAMETERS
+-------------------
+default
+ Make the selected gemset the default
+
+EXAMPLES
+--------
+
+.. code-block:: sh
+
+ # Install the rails gem in gemset ruby-1.9.3-p0@myset for user bill
+ __rvm_gemset rails --gemset ruby-1.9.3-p0@myset --user bill --state present
+
+ # Do the same and also make ruby-1.9.3-p0@myset the default gemset
+ __rvm_gemset rails --gemset ruby-1.9.3-p0@myset --user bill \
+ --state present --default
+
+ # Remove it
+ __rvm_ruby rails --gemset ruby-1.9.3-p0@myset --user bill --state absent
+
+
+SEE ALSO
+--------
+- `cdist-type(7) `_
+- `cdist-type__rvm(7) `_
+- `cdist-type__rvm_ruby(7) `_
+- `cdist-type__rvm_gemset(7) `_
+
+
+COPYING
+-------
+Copyright \(C) 2012 Evax Software. Free use of this software is granted under
+the terms of the GNU General Public License version 3 (GPLv3).
diff --git a/cdist/conf/type/__rvm_gem/man.text b/cdist/conf/type/__rvm_gem/man.text
deleted file mode 100644
index d7eff3be..00000000
--- a/cdist/conf/type/__rvm_gem/man.text
+++ /dev/null
@@ -1,57 +0,0 @@
-cdist-type__rvm_gemset(7)
-==========================
-Evax Software
-
-
-NAME
-----
-cdist-type__rvm_gem - Manage Ruby gems through rvm
-
-
-DESCRIPTION
------------
-RVM is the Ruby enVironment Manager for the Ruby programming language.
-
-
-REQUIRED PARAMETERS
--------------------
-user::
- The remote user account to use
-gemset::
- The gemset to use
-state::
- Either "present" or "absent", defaults to "present".
-
-OPTIONAL PARAMETERS
--------------------
-default::
- Make the selected gemset the default
-
-EXAMPLES
---------
-
---------------------------------------------------------------------------------
-# Install the rails gem in gemset ruby-1.9.3-p0@myset for user bill
-__rvm_gemset rails --gemset ruby-1.9.3-p0@myset --user bill --state present
-
-# Do the same and also make ruby-1.9.3-p0@myset the default gemset
-__rvm_gemset rails --gemset ruby-1.9.3-p0@myset --user bill \
- --state present --default
-
-# Remove it
-__rvm_ruby rails --gemset ruby-1.9.3-p0@myset --user bill --state absent
---------------------------------------------------------------------------------
-
-
-SEE ALSO
---------
-- cdist-type(7)
-- cdist-type__rvm(7)
-- cdist-type__rvm_ruby(7)
-- cdist-type__rvm_gemset(7)
-
-
-COPYING
--------
-Copyright \(C) 2012 Evax Software. Free use of this software is granted under
-the terms of the GNU General Public License version 3 (GPLv3).
diff --git a/cdist/conf/type/__rvm_gemset/man.rst b/cdist/conf/type/__rvm_gemset/man.rst
new file mode 100644
index 00000000..422130cb
--- /dev/null
+++ b/cdist/conf/type/__rvm_gemset/man.rst
@@ -0,0 +1,52 @@
+cdist-type__rvm_gemset(7)
+==========================
+Manage gemsets through rvm
+
+Evax Software
+
+
+DESCRIPTION
+-----------
+RVM is the Ruby enVironment Manager for the Ruby programming language.
+
+
+REQUIRED PARAMETERS
+-------------------
+user
+ The remote user account to use
+state
+ Either "present" or "absent", defaults to "present".
+
+BOOLEAN PARAMETERS
+-------------------
+default
+ If present, set the given gemset as default.
+
+
+EXAMPLES
+--------
+
+.. code-block:: sh
+
+ # Install the gemset @myset for user charles on based on ruby-1.9.3-0
+ __rvm_gemset ruby-1.9.3-p0@myset --user charles --state present
+
+ # Do the same and make ruby-1.9.3-p0@myset the default gemset
+ __rvm_gemset ruby-1.9.3-p0@myset --user charles --state present --default
+
+ # Remove the gemset @myset for user john
+ __rvm_ruby ruby-1.9.3-p0@myset --user john --state absent
+
+
+SEE ALSO
+--------
+- `cdist-type(7) `_
+- `cdist-type__rvm(7) `_
+- `cdist-type__rvm_ruby(7) `_
+- `cdist-type__rvm_gem(7) `_
+
+
+COPYING
+-------
+Copyright \(C) 2012 Evax Software. Free use of this software is granted under
+the terms of the GNU General Public License version 3 (GPLv3).
diff --git a/cdist/conf/type/__rvm_gemset/man.text b/cdist/conf/type/__rvm_gemset/man.text
deleted file mode 100644
index e85425f3..00000000
--- a/cdist/conf/type/__rvm_gemset/man.text
+++ /dev/null
@@ -1,55 +0,0 @@
-cdist-type__rvm_gemset(7)
-==========================
-Evax Software
-
-
-NAME
-----
-cdist-type__rvm_gemset - Manage gemsets through rvm
-
-
-DESCRIPTION
------------
-RVM is the Ruby enVironment Manager for the Ruby programming language.
-
-
-REQUIRED PARAMETERS
--------------------
-user::
- The remote user account to use
-state::
- Either "present" or "absent", defaults to "present".
-
-BOOLEAN PARAMETERS
--------------------
-default::
- If present, set the given gemset as default.
-
-
-EXAMPLES
---------
-
---------------------------------------------------------------------------------
-# Install the gemset @myset for user charles on based on ruby-1.9.3-0
-__rvm_gemset ruby-1.9.3-p0@myset --user charles --state present
-
-# Do the same and make ruby-1.9.3-p0@myset the default gemset
-__rvm_gemset ruby-1.9.3-p0@myset --user charles --state present --default
-
-# Remove the gemset @myset for user john
-__rvm_ruby ruby-1.9.3-p0@myset --user john --state absent
---------------------------------------------------------------------------------
-
-
-SEE ALSO
---------
-- cdist-type(7)
-- cdist-type__rvm(7)
-- cdist-type__rvm_ruby(7)
-- cdist-type__rvm_gem(7)
-
-
-COPYING
--------
-Copyright \(C) 2012 Evax Software. Free use of this software is granted under
-the terms of the GNU General Public License version 3 (GPLv3).
diff --git a/cdist/conf/type/__rvm_ruby/man.rst b/cdist/conf/type/__rvm_ruby/man.rst
new file mode 100644
index 00000000..dbb1c9a2
--- /dev/null
+++ b/cdist/conf/type/__rvm_ruby/man.rst
@@ -0,0 +1,53 @@
+cdist-type__rvm_ruby(7)
+=======================
+Manage ruby installations through rvm
+
+Evax Software
+
+
+DESCRIPTION
+-----------
+RVM is the Ruby enVironment Manager for the Ruby programming language.
+
+
+REQUIRED PARAMETERS
+-------------------
+user
+ The remote user account to use
+state
+ Either "present" or "absent", defaults to "present".
+
+
+BOOLEAN PARAMETERS
+------------------
+default
+ Set the given version as default
+
+
+EXAMPLES
+--------
+
+.. code-block:: sh
+
+ # Install ruby 1.9.3 through rvm for user thelonious
+ __rvm_ruby ruby-1.9.3-p0 --user thelonious --state present
+
+ # Install ruby 1.9.3 through rvm for user ornette and make it the default
+ __rvm_ruby ruby-1.9.3-p0 --user ornette --state present --default
+
+ # Remove ruby 1.9.3 for user john
+ __rvm_ruby ruby-1.9.3-p0 --user john --state absent
+
+
+SEE ALSO
+--------
+- `cdist-type(7) `_
+- `cdist-type__rvm(7) `_
+- `cdist-type__rvm_gemset(7) `_
+- `cdist-type__rvm_gem(7) `_
+
+
+COPYING
+-------
+Copyright \(C) 2012 Evax Software. Free use of this software is granted under
+the terms of the GNU General Public License version 3 (GPLv3).
diff --git a/cdist/conf/type/__rvm_ruby/man.text b/cdist/conf/type/__rvm_ruby/man.text
deleted file mode 100644
index 6419a4d4..00000000
--- a/cdist/conf/type/__rvm_ruby/man.text
+++ /dev/null
@@ -1,54 +0,0 @@
-cdist-type__rvm_ruby(7)
-=======================
-Evax Software
-
-
-NAME
-----
-cdist-type__rvm_ruby - Manage ruby installations through rvm
-
-
-DESCRIPTION
------------
-RVM is the Ruby enVironment Manager for the Ruby programming language.
-
-
-REQUIRED PARAMETERS
--------------------
-user::
- The remote user account to use
-state::
- Either "present" or "absent", defaults to "present".
-
-BOOLEAN PARAMETERS
-------------------
-default:
- Set the given version as default
-
-EXAMPLES
---------
-
---------------------------------------------------------------------------------
-# Install ruby 1.9.3 through rvm for user thelonious
-__rvm_ruby ruby-1.9.3-p0 --user thelonious --state present
-
-# Install ruby 1.9.3 through rvm for user ornette and make it the default
-__rvm_ruby ruby-1.9.3-p0 --user ornette --state present --default
-
-# Remove ruby 1.9.3 for user john
-__rvm_ruby ruby-1.9.3-p0 --user john --state absent
---------------------------------------------------------------------------------
-
-
-SEE ALSO
---------
-- cdist-type(7)
-- cdist-type__rvm(7)
-- cdist-type__rvm_gemset(7)
-- cdist-type__rvm_gem(7)
-
-
-COPYING
--------
-Copyright \(C) 2012 Evax Software. Free use of this software is granted under
-the terms of the GNU General Public License version 3 (GPLv3).
diff --git a/cdist/conf/type/__ssh_authorized_key/explorer/entry b/cdist/conf/type/__ssh_authorized_key/explorer/entry
new file mode 100755
index 00000000..78031ab5
--- /dev/null
+++ b/cdist/conf/type/__ssh_authorized_key/explorer/entry
@@ -0,0 +1,26 @@
+#!/bin/sh
+#
+# 2014 Steven Armstrong (steven-cdist at armstrong.cc)
+#
+# This file is part of cdist.
+#
+# cdist is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# cdist is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with cdist. If not, see .
+#
+
+# extract the keytype and base64 encoded key ignoring any options and comment
+type_and_key="$(cat "$__object/parameter/key" | tr ' ' '\n' | awk '/^(ssh|ecdsa)-[^ ]+/ { printf $1" "; getline; printf $1 }')"
+file="$(cat $__object/parameter/file)"
+
+# get any entries that match the type and key
+grep ".*$type_and_key[ \n]" "$file" || true
diff --git a/cdist/conf/type/__ssh_authorized_key/gencode-remote b/cdist/conf/type/__ssh_authorized_key/gencode-remote
new file mode 100755
index 00000000..6bbfa269
--- /dev/null
+++ b/cdist/conf/type/__ssh_authorized_key/gencode-remote
@@ -0,0 +1,109 @@
+#!/bin/sh
+#
+# 2014 Steven Armstrong (steven-cdist at armstrong.cc)
+#
+# This file is part of cdist.
+#
+# cdist is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# cdist is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with cdist. If not, see .
+#
+
+set -u
+
+remove_line() {
+ file="$1"
+ line="$2"
+ cat << DONE
+tmpfile=\$(mktemp ${file}.cdist.XXXXXXXXXX)
+# preserve ownership and permissions of existing file
+if [ -f "$file" ]; then
+ cp -p "$file" "\$tmpfile"
+fi
+grep -v -F -x '$line' '$file' > \$tmpfile || true
+mv -f "\$tmpfile" "$file"
+DONE
+}
+
+add_line() {
+ file="$1"
+ line="$2"
+ # escape single quotes
+ line_sanitised=$(echo "$line" | sed -e "s/'/'\"'\"'/g")
+ printf '%s' "printf '%s\n' '$line_sanitised' >> $file"
+}
+
+
+file="$(cat "$__object/parameter/file")"
+mkdir "$__object/files"
+
+# Generate the entry as it should be
+(
+ if [ -f "$__object/parameter/option" ]; then
+ # comma seperated list of options
+ options="$(cat "$__object/parameter/option" | tr '\n' ',')"
+ printf '%s ' "${options%*,}"
+ fi
+ if [ -f "$__object/parameter/comment" ]; then
+ # extract the keytype and base64 encoded key ignoring any options and comment
+ printf '%s ' "$(cat "$__object/parameter/key" | tr ' ' '\n' | awk '/^(ssh|ecdsa)-[^ ]+/ { printf $1" "; getline; printf $1 }')"
+ # override the comment with the one explicitly given
+ printf '%s' "$(cat "$__object/parameter/comment")"
+ else
+ printf '%s' "$(cat "$__object/parameter/key")"
+ fi
+ printf '\n'
+) > "$__object/files/should"
+
+# Remove conflicting entries if any
+if [ -s "$__object/explorer/entry" ]; then
+ # Note that the files have to be sorted for comparison with `comm`.
+ sort "$__object/explorer/entry" > "$__object/files/is"
+ comm -13 "$__object/files/should" "$__object/files/is" | {
+ while read entry; do
+ remove_line "$file" "$entry"
+ done
+ }
+fi
+
+# Determine the current state
+entry="$(cat "$__object/files/should")"
+state_should="$(cat "$__object/parameter/state")"
+num_existing_entries=$(grep -c -F -x "$entry" "$__object/explorer/entry" || true)
+if [ $num_existing_entries -eq 1 ]; then
+ state_is="present"
+else
+ # Posix grep does not define the -m option, so we can not remove a single
+ # occurence of a string from a file in the `remove_line` function. Instead
+ # _all_ occurences are removed.
+ # By using `comm` to detect conflicting entries this could lead to the
+ # situation that the key we want to add is actually removed.
+ # To workaround this we must treat 0 or more then 1 existing entries to
+ # mean current state is 'absent'. By doing this, the key is readded
+ # again after cleaning up conflicting entries.
+ state_is="absent"
+fi
+
+# Manage the actual entry as it should be
+if [ "$state_should" = "$state_is" ]; then
+ # Nothing to do
+ exit 0
+fi
+
+case "$state_should" in
+ present)
+ add_line "$file" "$entry"
+ ;;
+ absent)
+ remove_line "$file" "$entry"
+ ;;
+esac
diff --git a/cdist/conf/type/__ssh_authorized_key/man.rst b/cdist/conf/type/__ssh_authorized_key/man.rst
new file mode 100644
index 00000000..984ea51b
--- /dev/null
+++ b/cdist/conf/type/__ssh_authorized_key/man.rst
@@ -0,0 +1,64 @@
+cdist-type__ssh_authorized_key(7)
+=================================
+Manage a single ssh authorized key entry
+
+Steven Armstrong
+
+
+DESCRIPTION
+-----------
+Manage a single authorized key entry in an authorized_key file.
+This type was created to be used by the __ssh_authorized_keys type.
+
+
+REQUIRED PARAMETERS
+-------------------
+file
+ the authorized_keys file to which the given key should be added
+
+key
+ a string containing the ssh keytype, base 64 encoded key and optional
+ trailing comment which shall be added to the given authorized_keys file.
+
+
+OPTIONAL PARAMETERS
+-------------------
+comment
+ explicit comment instead of the one which may be trailing the given key
+
+option
+ an option to set for this authorized_key entry.
+ Can be specified multiple times.
+ See sshd(8) for available options.
+
+state
+ if the given keys should be 'present' or 'absent', defaults to 'present'.
+
+
+EXAMPLES
+--------
+
+.. code-block:: sh
+
+ __ssh_authorized_key some-id \
+ --file "/home/user/.ssh/autorized_keys" \
+ --key "$(cat ~/.ssh/id_rsa.pub)"
+
+ __ssh_authorized_key some-id \
+ --file "/home/user/.ssh/autorized_keys" \
+ --key "$(cat ~/.ssh/id_rsa.pub)" \
+ --option 'command="/path/to/script"' \
+ --option 'environment="FOO=bar"' \
+ --comment 'one to rule them all'
+
+
+SEE ALSO
+--------
+- `cdist-type(7) `_
+- `cdist__ssh_authorized_keys(7) `_
+- sshd(8)
+
+COPYING
+-------
+Copyright \(C) 2014 Steven Armstrong. Free use of this software is
+granted under the terms of the GNU General Public License version 3 (GPLv3).
diff --git a/cdist/conf/type/__ssh_authorized_key/parameter/default/state b/cdist/conf/type/__ssh_authorized_key/parameter/default/state
new file mode 100644
index 00000000..e7f6134f
--- /dev/null
+++ b/cdist/conf/type/__ssh_authorized_key/parameter/default/state
@@ -0,0 +1 @@
+present
diff --git a/cdist/conf/type/__ssh_authorized_key/parameter/optional b/cdist/conf/type/__ssh_authorized_key/parameter/optional
new file mode 100644
index 00000000..89e8d966
--- /dev/null
+++ b/cdist/conf/type/__ssh_authorized_key/parameter/optional
@@ -0,0 +1,2 @@
+comment
+state
diff --git a/cdist/conf/type/__ssh_authorized_key/parameter/optional_multiple b/cdist/conf/type/__ssh_authorized_key/parameter/optional_multiple
new file mode 100644
index 00000000..01925a15
--- /dev/null
+++ b/cdist/conf/type/__ssh_authorized_key/parameter/optional_multiple
@@ -0,0 +1 @@
+option
diff --git a/cdist/conf/type/__ssh_authorized_key/parameter/required b/cdist/conf/type/__ssh_authorized_key/parameter/required
new file mode 100644
index 00000000..d51426c3
--- /dev/null
+++ b/cdist/conf/type/__ssh_authorized_key/parameter/required
@@ -0,0 +1,2 @@
+file
+key
diff --git a/cdist/conf/type/__ssh_authorized_keys/explorer/file b/cdist/conf/type/__ssh_authorized_keys/explorer/file
new file mode 100755
index 00000000..5a02721a
--- /dev/null
+++ b/cdist/conf/type/__ssh_authorized_keys/explorer/file
@@ -0,0 +1,27 @@
+#!/bin/sh
+#
+# 2014 Steven Armstrong (steven-cdist at armstrong.cc)
+#
+# This file is part of cdist.
+#
+# cdist is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# cdist is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with cdist. If not, see .
+#
+
+if [ -f "$__object/parameter/file" ]; then
+ cat "$__object/parameter/file"
+else
+ owner="$(cat "$__object/parameter/owner" 2>/dev/null || echo "$__object_id")"
+ home=$(getent passwd "$owner" | cut -d':' -f 6)
+ echo "$home/.ssh/authorized_keys"
+fi
diff --git a/cdist/conf/type/__ssh_authorized_keys/explorer/group b/cdist/conf/type/__ssh_authorized_keys/explorer/group
index cdea6fe7..72a4e314 100755
--- a/cdist/conf/type/__ssh_authorized_keys/explorer/group
+++ b/cdist/conf/type/__ssh_authorized_keys/explorer/group
@@ -18,5 +18,6 @@
# along with cdist. If not, see .
#
-gid="$("$__type_explorer/passwd" | cut -d':' -f 4)"
+owner="$(cat "$__object/parameter/owner" 2>/dev/null || echo "$__object_id")"
+gid="$(getent passwd "$owner" | cut -d':' -f 4)"
getent group "$gid" || true
diff --git a/cdist/conf/type/__ssh_authorized_keys/man.rst b/cdist/conf/type/__ssh_authorized_keys/man.rst
new file mode 100644
index 00000000..0907c2b3
--- /dev/null
+++ b/cdist/conf/type/__ssh_authorized_keys/man.rst
@@ -0,0 +1,114 @@
+cdist-type__ssh_authorized_keys(7)
+==================================
+Manage ssh authorized_keys files
+
+Steven Armstrong
+
+
+DESCRIPTION
+-----------
+Adds or removes ssh keys from a authorized_keys file.
+
+This type uses the __ssh_dot_ssh type to manage the directory containing
+the authorized_keys file. You can disable this feature with the --noparent
+boolean parameter.
+
+The existence, ownership and permissions of the authorized_keys file itself are
+also managed. This can be disabled with the --nofile boolean parameter. It is
+then left to the user to ensure that the file exists and that ownership and
+permissions work with ssh.
+
+
+REQUIRED PARAMETERS
+-------------------
+key
+ the ssh key which shall be added to this authorized_keys file.
+ Must be a string and can be specified multiple times.
+
+
+OPTIONAL PARAMETERS
+-------------------
+comment
+ explicit comment instead of the one which may be trailing the given key
+
+file
+ an alternative destination file, defaults to ~$owner/.ssh/authorized_keys
+
+option
+ an option to set for all created authorized_key entries.
+ Can be specified multiple times.
+ See sshd(8) for available options.
+
+owner
+ the user owning the authorized_keys file, defaults to object_id.
+
+state
+ if the given keys should be 'present' or 'absent', defaults to 'present'.
+
+
+BOOLEAN PARAMETERS
+------------------
+noparent
+ don't create or change ownership and permissions of the directory containing
+ the authorized_keys file
+
+nofile
+ don't manage existence, ownership and permissions of the the authorized_keys
+ file
+
+
+EXAMPLES
+--------
+
+.. code-block:: sh
+
+ # add your ssh key to remote root's authorized_keys file
+ __ssh_authorized_keys root \
+ --key "$(cat ~/.ssh/id_rsa.pub)"
+
+ # allow key to login as user-name
+ __ssh_authorized_keys user-name \
+ --key "ssh-rsa AXYZAAB3NzaC1yc2..."
+
+ # allow key to login as user-name with options and expicit comment
+ __ssh_authorized_keys user-name \
+ --key "ssh-rsa AXYZAAB3NzaC1yc2..." \
+ --option no-agent-forwarding \
+ --option 'from="*.example.com"' \
+ --comment 'backup server'
+
+ # same as above, but with explicit owner and two keys
+ # note that the options are set for all given keys
+ __ssh_authorized_keys some-fancy-id \
+ --owner user-name \
+ --key "ssh-rsa AXYZAAB3NzaC1yc2..." \
+ --key "ssh-rsa AZXYAAB3NzaC1yc2..." \
+ --option no-agent-forwarding \
+ --option 'from="*.example.com"' \
+ --comment 'backup server'
+
+ # authorized_keys file in non standard location
+ __ssh_authorized_keys some-fancy-id \
+ --file /etc/ssh/keys/user-name/authorized_keys \
+ --owner user-name \
+ --key "ssh-rsa AXYZAAB3NzaC1yc2..."
+
+ # same as above, but directory and authorized_keys file is created elswhere
+ __ssh_authorized_keys some-fancy-id \
+ --file /etc/ssh/keys/user-name/authorized_keys \
+ --owner user-name \
+ --noparent \
+ --nofile \
+ --key "ssh-rsa AXYZAAB3NzaC1yc2..."
+
+
+SEE ALSO
+--------
+- `cdist-type(7) `_
+- sshd(8)
+
+
+COPYING
+-------
+Copyright \(C) 2012-2014 Steven Armstrong. Free use of this software is
+granted under the terms of the GNU General Public License version 3 (GPLv3).
diff --git a/cdist/conf/type/__ssh_authorized_keys/man.text b/cdist/conf/type/__ssh_authorized_keys/man.text
deleted file mode 100644
index 9fd683fd..00000000
--- a/cdist/conf/type/__ssh_authorized_keys/man.text
+++ /dev/null
@@ -1,97 +0,0 @@
-cdist-type__ssh_authorized_keys(7)
-==================================
-Steven Armstrong
-
-
-NAME
-----
-cdist-type__ssh_authorized_keys - manage ssh authorized_keys files
-
-
-DESCRIPTION
------------
-Adds or removes ssh keys from a authorized_keys file.
-
-This type also manages the directory containing the authorized_keys
-file and sets strict ownership and permissions. You can disable this feature
-with the --noparent boolean parameter.
-
-The existence, ownership and permissions of the authorized_keys file itself are
-also managed. This can be disabled with the --nofile boolean parameter. It is
-then left to the user to ensure that the file exists and that ownership and
-permissions work with ssh.
-
-
-REQUIRED PARAMETERS
--------------------
-key::
- the ssh key which shall be added to this authorized_keys file.
- Must be a string and can be specified multiple times.
-
-
-OPTIONAL PARAMETERS
--------------------
-owner::
- the user owning the authorized_keys file, defaults to object_id.
-
-state::
- if the given keys should be 'present' or 'absent', defaults to 'present'.
-
-file::
- an alternative destination file, defaults to ~$owner/.ssh/authorized_keys
-
-
-BOOLEAN PARAMETERS
-------------------
-noparent::
- don't create or change ownership and permissions of the directory containing
- the authorized_keys file
-
-nofile::
- don't manage existence, ownership and permissions of the the authorized_keys
- file
-
-
-EXAMPLES
---------
-
---------------------------------------------------------------------------------
-# add your ssh key to remote root's authorized_keys file
-__ssh_authorized_keys root \
- --key "$(cat ~/.ssh/id_rsa.pub)"
-
-# allow key to login as user-name
-__ssh_authorized_keys user-name \
- --key "ssh-rsa AXYZAAB3NzaC1yc2..."
-
-# same as above, but with explicit owner and two keys
-__ssh_authorized_keys some-fancy-id \
- --owner user-name \
- --key "ssh-rsa AXYZAAB3NzaC1yc2..." \
- --key "ssh-rsa AZXYAAB3NzaC1yc2..."
-
-# same as above, but authorized_keys file in non standard location
-__ssh_authorized_keys some-fancy-id \
- --file /etc/ssh/keys/user-name/authorized_keys \
- --owner user-name \
- --key "ssh-rsa AXYZAAB3NzaC1yc2..."
-
-# same as above, but directory and authorized_keys file is created elswhere
-__ssh_authorized_keys some-fancy-id \
- --file /etc/ssh/keys/user-name/authorized_keys \
- --owner user-name \
- --noparent \
- --nofile \
- --key "ssh-rsa AXYZAAB3NzaC1yc2..."
---------------------------------------------------------------------------------
-
-
-SEE ALSO
---------
-- cdist-type(7)
-
-
-COPYING
--------
-Copyright \(C) 2012-2014 Steven Armstrong. Free use of this software is
-granted under the terms of the GNU General Public License version 3 (GPLv3).
diff --git a/cdist/conf/type/__ssh_authorized_keys/manifest b/cdist/conf/type/__ssh_authorized_keys/manifest
index 1c9df208..6a536e1b 100755
--- a/cdist/conf/type/__ssh_authorized_keys/manifest
+++ b/cdist/conf/type/__ssh_authorized_keys/manifest
@@ -21,16 +21,7 @@
owner="$(cat "$__object/parameter/owner" 2>/dev/null || echo "$__object_id")"
state="$(cat "$__object/parameter/state" 2>/dev/null)"
-if [ -f "$__object/parameter/file" ]; then
- file="$(cat "$__object/parameter/file")"
-else
- home="$(cut -d':' -f 6 "$__object/explorer/passwd")"
- if [ -z "$home" ]; then
- echo "Failed to get home directory from explorer." >&2
- exit 1
- fi
- file="$home/.ssh/authorized_keys"
-fi
+file="$(cat "$__object/explorer/file")"
if [ ! -f "$__object/parameter/noparent" -o ! -f "$__object/parameter/nofile" ]; then
group="$(cut -d':' -f 1 "$__object/explorer/group")"
@@ -40,12 +31,8 @@ if [ ! -f "$__object/parameter/noparent" -o ! -f "$__object/parameter/nofile" ];
fi
if [ ! -f "$__object/parameter/noparent" ]; then
- # Ensure that the directory in which the authorized_keys shall be exists and
- # has the right permissions.
- ssh_directory="${file%/*}"
- __directory "$ssh_directory" --state present --parents \
- --owner "$owner" --group "$group" --mode 0700
- export require="__directory/$ssh_directory"
+ __ssh_dot_ssh "$owner"
+ export require="__ssh_dot_ssh/$owner"
fi
if [ ! -f "$__object/parameter/nofile" ]; then
# Ensure that authorized_keys file exists and has the right permissions.
@@ -54,6 +41,7 @@ if [ ! -f "$__object/parameter/noparent" -o ! -f "$__object/parameter/nofile" ];
--group "$group" \
--mode 0600 \
--state exists
+ export require="__file/$file"
fi
fi
@@ -67,22 +55,25 @@ __block "$__object_name" \
--text - << DONE
remove legacy block
DONE
+export require="__block/$__object_name"
_cksum() {
echo "$1" | cksum | cut -d' ' -f 1
}
while read key; do
- cksum_key="$(_cksum "$key")"
- line_id="${owner}-${cksum_key}"
-
- set -- "$line_id"
+ type_and_key="$(echo "$key" | tr ' ' '\n' | awk '/^(ssh|ecdsa)-[^ ]+/ { printf $1" "; getline; printf $1 }')"
+ object_id="$(_cksum "$file")-$(_cksum "$type_and_key")"
+ set -- "$object_id"
set -- "$@" --file "$file"
- set -- "$@" --regex ".*$key.*"
- if [ "$state" = 'present' ]; then
- set -- "$@" --line "$key"
- fi
+ set -- "$@" --key "$key"
set -- "$@" --state "$state"
- # Ensure __line does not read stdin
- require="__block/$__object_name" __line "$@" < /dev/null
+ if [ -f "$__object/parameter/option" ]; then
+ set -- "$@" --option "$(cat "$__object/parameter/option")"
+ fi
+ if [ -f "$__object/parameter/comment" ]; then
+ set -- "$@" --comment "$(cat "$__object/parameter/comment")"
+ fi
+ # Ensure __ssh_authorized_key does not read stdin
+ __ssh_authorized_key "$@" < /dev/null
done < "$__object/parameter/key"
diff --git a/cdist/conf/type/__ssh_authorized_keys/parameter/optional b/cdist/conf/type/__ssh_authorized_keys/parameter/optional
index 989750b3..21f9bc29 100644
--- a/cdist/conf/type/__ssh_authorized_keys/parameter/optional
+++ b/cdist/conf/type/__ssh_authorized_keys/parameter/optional
@@ -1,3 +1,5 @@
+comment
+file
+option
owner
state
-file
diff --git a/cdist/conf/type/__ssh_dot_ssh/explorer/group b/cdist/conf/type/__ssh_dot_ssh/explorer/group
new file mode 100755
index 00000000..cdea6fe7
--- /dev/null
+++ b/cdist/conf/type/__ssh_dot_ssh/explorer/group
@@ -0,0 +1,22 @@
+#!/bin/sh
+#
+# 2014 Steven Armstrong (steven-cdist at armstrong.cc)
+#
+# This file is part of cdist.
+#
+# cdist is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# cdist is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with cdist. If not, see .
+#
+
+gid="$("$__type_explorer/passwd" | cut -d':' -f 4)"
+getent group "$gid" || true
diff --git a/cdist/conf/type/__ssh_authorized_keys/explorer/passwd b/cdist/conf/type/__ssh_dot_ssh/explorer/passwd
similarity index 90%
rename from cdist/conf/type/__ssh_authorized_keys/explorer/passwd
rename to cdist/conf/type/__ssh_dot_ssh/explorer/passwd
index e6352ee0..3fbad06f 100755
--- a/cdist/conf/type/__ssh_authorized_keys/explorer/passwd
+++ b/cdist/conf/type/__ssh_dot_ssh/explorer/passwd
@@ -1,6 +1,7 @@
#!/bin/sh
#
# 2012 Steven Armstrong (steven-cdist at armstrong.cc)
+# 2014 Nico Schottelius (nico-cdist at schottelius.org)
#
# This file is part of cdist.
#
@@ -18,6 +19,6 @@
# along with cdist. If not, see .
#
-owner="$(cat "$__object/parameter/owner" 2>/dev/null || echo "$__object_id")"
+owner="$__object_id"
getent passwd "$owner" || true
diff --git a/cdist/conf/type/__ssh_dot_ssh/man.rst b/cdist/conf/type/__ssh_dot_ssh/man.rst
new file mode 100644
index 00000000..1b84c924
--- /dev/null
+++ b/cdist/conf/type/__ssh_dot_ssh/man.rst
@@ -0,0 +1,46 @@
+cdist-type__ssh_dot_ssh(7)
+==========================
+Manage .ssh directory
+
+Nico Schottelius
+
+
+NAME
+----
+
+
+DESCRIPTION
+-----------
+Adds or removes .ssh directory to a user home.
+
+This type is being used by __ssh_authorized_keys.
+
+
+OPTIONAL PARAMETERS
+-------------------
+state
+ if the directory should be 'present' or 'absent', defaults to 'present'.
+
+
+EXAMPLES
+--------
+
+.. code-block:: sh
+
+ # Ensure root has ~/.ssh with the right permissions
+ __ssh_dot_ssh root
+
+ # Nico does not need ~/.ssh anymore
+ __ssh_dot_ssh nico --state absent
+
+
+SEE ALSO
+--------
+- `cdist-type(7) `_
+- `cdist-type__ssh_authorized_keys(7) `_
+
+
+COPYING
+-------
+Copyright \(C) 2014 Nico Schottelius. Free use of this software is
+granted under the terms of the GNU General Public License version 3 (GPLv3).
diff --git a/cdist/conf/type/__ssh_dot_ssh/manifest b/cdist/conf/type/__ssh_dot_ssh/manifest
new file mode 100755
index 00000000..4b797afb
--- /dev/null
+++ b/cdist/conf/type/__ssh_dot_ssh/manifest
@@ -0,0 +1,44 @@
+#!/bin/sh
+#
+# 2012-2014 Steven Armstrong (steven-cdist at armstrong.cc)
+# 2014 Nico Schottelius (nico-cdist at schottelius.org)
+#
+# This file is part of cdist.
+#
+# cdist is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# cdist is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with cdist. If not, see