From 17afb5f5ad950393f82db8905ffd41d8a37b178b Mon Sep 17 00:00:00 2001 From: Antoine Catton Date: Sat, 27 Dec 2014 20:05:40 -0700 Subject: [PATCH 01/53] DRY: Remove default parameter value handeling in __apt_source --- cdist/conf/type/__apt_source/manifest | 8 +++----- cdist/conf/type/__apt_source/parameter/default/component | 0 2 files changed, 3 insertions(+), 5 deletions(-) create mode 100644 cdist/conf/type/__apt_source/parameter/default/component 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/conf/type/__apt_source/parameter/default/component b/cdist/conf/type/__apt_source/parameter/default/component new file mode 100644 index 00000000..e69de29b From 82f48ef27116ed458c7fc10d864292e843ddef0a Mon Sep 17 00:00:00 2001 From: Antoine Catton Date: Sat, 27 Dec 2014 20:11:14 -0700 Subject: [PATCH 02/53] DRY: Remove default parameter value handeling in __apt_source --- cdist/conf/type/__cdistmarker/gencode-remote | 12 ++---------- .../type/__cdistmarker/parameter/default/destination | 1 + .../conf/type/__cdistmarker/parameter/default/format | 1 + 3 files changed, 4 insertions(+), 10 deletions(-) create mode 100644 cdist/conf/type/__cdistmarker/parameter/default/destination create mode 100644 cdist/conf/type/__cdistmarker/parameter/default/format 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/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 From 0844f717a856dc6bed936fbf94045687cd86c27a Mon Sep 17 00:00:00 2001 From: Antoine Catton Date: Sat, 27 Dec 2014 20:26:29 -0700 Subject: [PATCH 03/53] Password is unused in the else branch --- cdist/conf/type/__mysql_database/gencode-remote | 1 - 1 file changed, 1 deletion(-) 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'; From 601346d48270ae0397a94612d8b167224b19b529 Mon Sep 17 00:00:00 2001 From: Antoine Catton Date: Sat, 27 Dec 2014 20:29:45 -0700 Subject: [PATCH 04/53] DRY: Remove default parameter value handeling in __package_apt --- cdist/conf/type/__package_apt/gencode-remote | 6 +----- cdist/conf/type/__package_apt/parameter/default/state | 1 + 2 files changed, 2 insertions(+), 5 deletions(-) create mode 100644 cdist/conf/type/__package_apt/parameter/default/state diff --git a/cdist/conf/type/__package_apt/gencode-remote b/cdist/conf/type/__package_apt/gencode-remote index 1feec012..ef313070 100755 --- a/cdist/conf/type/__package_apt/gencode-remote +++ b/cdist/conf/type/__package_apt/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 [ -f "$__object/parameter/target-release" ]; then target_release="--target-release $(cat "$__object/parameter/target-release")" 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 From de282c50f39aff65ae00bdc833ab8178c9e7854c Mon Sep 17 00:00:00 2001 From: Antoine Catton Date: Sat, 27 Dec 2014 20:31:46 -0700 Subject: [PATCH 05/53] DRY: Remove default parameter value handeling in __package_luarocks --- cdist/conf/type/__package_luarocks/gencode-remote | 6 +----- cdist/conf/type/__package_luarocks/parameter/default/state | 1 + 2 files changed, 2 insertions(+), 5 deletions(-) create mode 100644 cdist/conf/type/__package_luarocks/parameter/default/state 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/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 From 65f50b64b78e2c35f74c53eece5e2b530ae320db Mon Sep 17 00:00:00 2001 From: Antoine Catton Date: Sat, 27 Dec 2014 20:32:49 -0700 Subject: [PATCH 06/53] DRY: Remove default parameter value handeling in __package_opkg --- cdist/conf/type/__package_opkg/gencode-remote | 6 +----- cdist/conf/type/__package_opkg/parameter/default/state | 1 + 2 files changed, 2 insertions(+), 5 deletions(-) create mode 100644 cdist/conf/type/__package_opkg/parameter/default/state 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/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 From 5aaea371943d7836843006e10c03e95a5ae315a5 Mon Sep 17 00:00:00 2001 From: Antoine Catton Date: Sat, 27 Dec 2014 20:34:38 -0700 Subject: [PATCH 07/53] DRY: Remove default parameter value handeling in __package_pacman --- cdist/conf/type/__package_pacman/gencode-remote | 6 +----- cdist/conf/type/__package_pacman/parameter/default/state | 1 + 2 files changed, 2 insertions(+), 5 deletions(-) create mode 100644 cdist/conf/type/__package_pacman/parameter/default/state 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/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 From 9fd285da4c8f2424d08dd58be493b2335122c542 Mon Sep 17 00:00:00 2001 From: Antoine Catton Date: Sat, 27 Dec 2014 20:35:53 -0700 Subject: [PATCH 08/53] DRY: Remove default parameter value handeling in __package_pip --- cdist/conf/type/__package_pip/gencode-remote | 6 +----- cdist/conf/type/__package_pip/parameter/default/state | 1 + 2 files changed, 2 insertions(+), 5 deletions(-) create mode 100644 cdist/conf/type/__package_pip/parameter/default/state diff --git a/cdist/conf/type/__package_pip/gencode-remote b/cdist/conf/type/__package_pip/gencode-remote index ec1c89f8..ba44927a 100644 --- a/cdist/conf/type/__package_pip/gencode-remote +++ b/cdist/conf/type/__package_pip/gencode-remote @@ -22,11 +22,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 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 From f7bf6a058ec87780d19abb73fad65f93b1a3acde Mon Sep 17 00:00:00 2001 From: Antoine Catton Date: Sat, 27 Dec 2014 20:42:03 -0700 Subject: [PATCH 09/53] DRY: Remove default parameter value handeling in __package_pkg_freebsd flavor, pkgsite and version are expected to be empty. They're all checked with [ -n "$var" ] --- .../type/__package_pkg_freebsd/gencode-remote | 21 ++++--------------- .../parameter/default/flavor | 0 .../parameter/default/pkgsite | 0 .../parameter/default/state | 1 + .../parameter/default/version | 0 5 files changed, 5 insertions(+), 17 deletions(-) create mode 100644 cdist/conf/type/__package_pkg_freebsd/parameter/default/flavor create mode 100644 cdist/conf/type/__package_pkg_freebsd/parameter/default/pkgsite create mode 100644 cdist/conf/type/__package_pkg_freebsd/parameter/default/state create mode 100644 cdist/conf/type/__package_pkg_freebsd/parameter/default/version 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/parameter/default/flavor b/cdist/conf/type/__package_pkg_freebsd/parameter/default/flavor new file mode 100644 index 00000000..e69de29b diff --git a/cdist/conf/type/__package_pkg_freebsd/parameter/default/pkgsite b/cdist/conf/type/__package_pkg_freebsd/parameter/default/pkgsite new file mode 100644 index 00000000..e69de29b 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/conf/type/__package_pkg_freebsd/parameter/default/version b/cdist/conf/type/__package_pkg_freebsd/parameter/default/version new file mode 100644 index 00000000..e69de29b From ebf0479f60f5c03eed0e8a3160e32ff8e3ec44e2 Mon Sep 17 00:00:00 2001 From: Antoine Catton Date: Sat, 27 Dec 2014 20:44:47 -0700 Subject: [PATCH 10/53] DRY: Remove default parameter value handeling in __package_pkgng_freebsd flavor, repo and version are expected to be empty by default. They're all checked with [ -n "$var" ] --- .../__package_pkgng_freebsd/gencode-remote | 20 ++++--------------- .../parameter/default/flavor | 0 .../parameter/default/repo | 0 .../parameter/default/state | 1 + .../parameter/default/version | 0 5 files changed, 5 insertions(+), 16 deletions(-) create mode 100644 cdist/conf/type/__package_pkgng_freebsd/parameter/default/flavor create mode 100644 cdist/conf/type/__package_pkgng_freebsd/parameter/default/repo create mode 100644 cdist/conf/type/__package_pkgng_freebsd/parameter/default/state create mode 100644 cdist/conf/type/__package_pkgng_freebsd/parameter/default/version diff --git a/cdist/conf/type/__package_pkgng_freebsd/gencode-remote b/cdist/conf/type/__package_pkgng_freebsd/gencode-remote index 39965aca..3c3e41e9 100755 --- a/cdist/conf/type/__package_pkgng_freebsd/gencode-remote +++ b/cdist/conf/type/__package_pkgng_freebsd/gencode-remote @@ -31,13 +31,8 @@ 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 +flavor="$(cat "$__object/parameter/flavor")" +version="$(cat "$__object/parameter/version")" if [ -f "$__object/parameter/upgrade" ]; then upgrade="true" @@ -45,15 +40,8 @@ else upgrade="false" fi -if [ -f "$__object/parameter/repo" ]; then - repo="$(cat "$__object/parameter/repo")" -fi - -if [ -f "$__object/parameter/state" ]; then - state="$(cat "$__object/parameter/state")" -else - state="present" -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" diff --git a/cdist/conf/type/__package_pkgng_freebsd/parameter/default/flavor b/cdist/conf/type/__package_pkgng_freebsd/parameter/default/flavor new file mode 100644 index 00000000..e69de29b 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 From 33cc3b0fa2dd66e905cd253b2a89c0bd65a2e54d Mon Sep 17 00:00:00 2001 From: Antoine Catton Date: Sat, 27 Dec 2014 20:47:30 -0700 Subject: [PATCH 11/53] DRY: Remove default parameter value handeling in __package_pkg_openbsd --- cdist/conf/type/__package_pkg_openbsd/gencode-remote | 6 +----- .../conf/type/__package_pkg_openbsd/parameter/default/state | 1 + 2 files changed, 2 insertions(+), 5 deletions(-) create mode 100644 cdist/conf/type/__package_pkg_openbsd/parameter/default/state 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/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 From a938468bb04d68c29d837cf3bb6e8f4d97039a8e Mon Sep 17 00:00:00 2001 From: Antoine Catton Date: Sat, 27 Dec 2014 20:48:42 -0700 Subject: [PATCH 12/53] DRY: Remove default parameter value handeling in __package_rubygem --- cdist/conf/type/__package_rubygem/gencode-remote | 6 +----- cdist/conf/type/__package_rubygem/parameter/default/state | 1 + 2 files changed, 2 insertions(+), 5 deletions(-) create mode 100644 cdist/conf/type/__package_rubygem/parameter/default/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/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 From d247f083e828c11f92de6d4e9b407cd09e831deb Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Tue, 20 Jan 2015 21:29:04 +0100 Subject: [PATCH 13/53] cleanup and rewrite - add new --state parameter and support for deleting groups - add new --system parameter to create system groups if supported by the os - remove special case for legacy redhat/centos versions, they are long gone Signed-off-by: Steven Armstrong --- cdist/conf/type/__group/TODO | 2 - cdist/conf/type/__group/explorer/group | 2 +- cdist/conf/type/__group/explorer/gshadow | 14 +- cdist/conf/type/__group/gencode-remote | 148 ++++++++++----------- cdist/conf/type/__group/man.text | 18 ++- cdist/conf/type/__group/parameter/boolean | 1 + cdist/conf/type/__group/parameter/optional | 1 + 7 files changed, 93 insertions(+), 93 deletions(-) delete mode 100644 cdist/conf/type/__group/TODO create mode 100644 cdist/conf/type/__group/parameter/boolean 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..8d40e9e0 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,7 +22,6 @@ # name=$__object_id -os_version="$($__explorer/os_version)" os="$($__explorer/os)" if [ "$os" = "freebsd" ]; then @@ -30,13 +29,4 @@ if [ "$os" = "freebsd" ]; then exit 0 fi -case "$os_version" in - "Red Hat Enterprise Linux Server release "[45]*|"CentOS release "[45]*) - # TODO: find a way to get this information - echo "$os_version does not have getent gshadow" - ;; - *) - getent gshadow "$name" || true - ;; -esac - +getent gshadow "$name" || true diff --git a/cdist/conf/type/__group/gencode-remote b/cdist/conf/type/__group/gencode-remote index 1cffa8d4..f3c566d6 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,85 @@ # name="$__object_id" -os_version="$(cat "$__global/explorer/os_version")" os="$(cat "$__global/explorer/os")" -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 + if [ "$os" = "freebsd" ]; then + echo pw groupadd "$@" "$name" + else + echo groupadd "$@" "$name" + fi + done 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.text b/cdist/conf/type/__group/man.text index def0232f..4b18a552 100644 --- a/cdist/conf/type/__group/man.text +++ b/cdist/conf/type/__group/man.text @@ -20,18 +20,28 @@ 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 :: @@ -45,6 +55,12 @@ EXAMPLES # 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 @@ -60,5 +76,5 @@ SEE ALSO COPYING ------- -Copyright \(C) 2011 Steven Armstrong. Free use of this software is +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/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/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 From 7d73cc5ed6b5375bedd679bca9b46993591c9061 Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Tue, 20 Jan 2015 21:44:05 +0100 Subject: [PATCH 14/53] actually use new --state param Signed-off-by: Steven Armstrong --- cdist/conf/type/__group/gencode-remote | 1 + cdist/conf/type/__group/parameter/default/state | 1 + 2 files changed, 2 insertions(+) create mode 100644 cdist/conf/type/__group/parameter/default/state diff --git a/cdist/conf/type/__group/gencode-remote b/cdist/conf/type/__group/gencode-remote index f3c566d6..6315df43 100755 --- a/cdist/conf/type/__group/gencode-remote +++ b/cdist/conf/type/__group/gencode-remote @@ -24,6 +24,7 @@ name="$__object_id" os="$(cat "$__global/explorer/os")" +state="$(cat "$__object/parameter/state")" # Use short option names for portability 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 From 26143b8b777725fe5f89f7c211d92b7037d12de6 Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Fri, 23 Jan 2015 14:07:18 +0100 Subject: [PATCH 15/53] move code generation outside of loop Signed-off-by: Steven Armstrong --- cdist/conf/type/__group/gencode-remote | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cdist/conf/type/__group/gencode-remote b/cdist/conf/type/__group/gencode-remote index 6315df43..2aaa83f3 100755 --- a/cdist/conf/type/__group/gencode-remote +++ b/cdist/conf/type/__group/gencode-remote @@ -88,12 +88,12 @@ if [ "$state" = "present" ]; then set -- "$@" "$(shorten_property $property)" \'$new_value\' fi fi - if [ "$os" = "freebsd" ]; then - echo pw groupadd "$@" "$name" - else - echo groupadd "$@" "$name" - fi done + if [ "$os" = "freebsd" ]; then + echo pw groupadd "$@" "$name" + else + echo groupadd "$@" "$name" + fi fi else # delete existing From 82ffde7786afa310a259d8adcaa591e65c8ee893 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 10 Feb 2015 22:54:03 +0100 Subject: [PATCH 16/53] update changelog Signed-off-by: Nico Schottelius --- docs/changelog | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/changelog b/docs/changelog index d9e21deb..d6458f81 100644 --- a/docs/changelog +++ b/docs/changelog @@ -5,12 +5,13 @@ Changelog * Exception: No braces means author == Nico Schottelius -3.1.10: 2015-01-06 +3.1.10: 2015-02-10 * Core: Fix too many open files bug (#343) * Type __ssh_authorized_keys: Remove unneeded explorer (Steven Armstrong) * Type __ssh_authorized_keys: Fix empty output bug of entry explorer (Steven Armstrong) * Type __package_apt: Add support for --target-release * Type __locale: Add support for Ubuntu + * Type __group: Rewrite (Steven Armstrong) * Documentation: Fix typo in maintainer file (Stephan Kulla) 3.1.9: 2014-10-17 From 3db2dcb2d62ea48515e32f6c4e6561f420b02f6f Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 10 Feb 2015 23:10:23 +0100 Subject: [PATCH 17/53] fix release errors of 3.1.10 Signed-off-by: Nico Schottelius --- Makefile | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 03084a4b..a2003dcc 100644 --- a/Makefile +++ b/Makefile @@ -109,8 +109,8 @@ man-dist: man check-date 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 @@ -243,10 +243,7 @@ distclean: clean # The pub is Nico's "push to all git remotes" way ("make pub") pub: - for remote in "" sf; do \ - echo "Pushing to $$remote"; \ - git push --mirror $$remote; \ - done + git push --mirror test: $(helper) $@ From 745f1e2984655c85772d614782853bb66e12bf8c Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 10 Feb 2015 23:27:43 +0100 Subject: [PATCH 18/53] support ubuntu upstart in __start_on_boot Signed-off-by: Nico Schottelius --- cdist/conf/type/__start_on_boot/explorer/state | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/cdist/conf/type/__start_on_boot/explorer/state b/cdist/conf/type/__start_on_boot/explorer/state index e9e4318e..1906033c 100755 --- a/cdist/conf/type/__start_on_boot/explorer/state +++ b/cdist/conf/type/__start_on_boot/explorer/state @@ -1,6 +1,6 @@ #!/bin/sh # -# 2012-2013 Nico Schottelius (nico-cdist at schottelius.org) +# 2012-2015 Nico Schottelius (nico-cdist at schottelius.org) # 2013 Daniel Heule (hda at sfs.biz) # # This file is part of cdist. @@ -34,10 +34,15 @@ case "$os" in || echo absent) ;; - debian|ubuntu|openwrt) + debian|openwrt) state="present" [ -f "/etc/rc$runlevel.d/S"??"$name" ] || state="absent" ;; + ubuntu) + state="absent" + [ -f "/etc/rc$runlevel.d/S"??"$name" ] && state="present" + [ -f "/etc/init/${name}.conf" ] && state="present" + ;; amazon|centos|fedora|owl|redhat) state=$(chkconfig --level "$runlevel" "$name" || echo absent) From 6e483497de537f858979d28e049458a39baa7515 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 10 Feb 2015 23:28:30 +0100 Subject: [PATCH 19/53] ++changes Signed-off-by: Nico Schottelius --- docs/changelog | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/changelog b/docs/changelog index d6458f81..d61cf724 100644 --- a/docs/changelog +++ b/docs/changelog @@ -5,6 +5,9 @@ Changelog * Exception: No braces means author == Nico Schottelius +3.1.11: + * Type __start_on_boot: Support Ubuntu upstart + 3.1.10: 2015-02-10 * Core: Fix too many open files bug (#343) * Type __ssh_authorized_keys: Remove unneeded explorer (Steven Armstrong) From 3cc2f13b9b4b9ec832e5eac03f66131c105da138 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 11 Feb 2015 15:56:45 +0100 Subject: [PATCH 20/53] add initial version of __rsync Signed-off-by: Nico Schottelius --- cdist/conf/type/__rsync/gencode-local | 19 +++++ cdist/conf/type/__rsync/gencode-remote | 17 ++++ cdist/conf/type/__rsync/man.text | 77 +++++++++++++++++++ cdist/conf/type/__rsync/manifest | 1 + .../__rsync/parameter/default/remote-user | 1 + cdist/conf/type/__rsync/parameter/optional | 4 + cdist/conf/type/__rsync/parameter/required | 1 + 7 files changed, 120 insertions(+) create mode 100644 cdist/conf/type/__rsync/gencode-local create mode 100644 cdist/conf/type/__rsync/gencode-remote create mode 100644 cdist/conf/type/__rsync/man.text create mode 100644 cdist/conf/type/__rsync/manifest create mode 100644 cdist/conf/type/__rsync/parameter/default/remote-user create mode 100644 cdist/conf/type/__rsync/parameter/optional create mode 100644 cdist/conf/type/__rsync/parameter/required diff --git a/cdist/conf/type/__rsync/gencode-local b/cdist/conf/type/__rsync/gencode-local new file mode 100644 index 00000000..71e47af1 --- /dev/null +++ b/cdist/conf/type/__rsync/gencode-local @@ -0,0 +1,19 @@ +source_dir=$(cat "$__object/parameter/source-dir") +remote_user=$(cat "$__object/parameter/remote-user") + +if [ -f "$__object/parameter/destination-dir" ]; then + destination_dir=$(cat "$__object/parameter/destination-dir") +else + destination_dir="$__object_id" +fi + +set -- +if [ -f "$__object/parameter/rsync-opts" ]; then + while read opts; do + set -- "$@" "$opts" + done +fi + +echo rsync -a \ + --no-owner --no-group \ + -q "$@" "${source_dir}/" "${remote_user}@${__target_host}:$destination_dir" diff --git a/cdist/conf/type/__rsync/gencode-remote b/cdist/conf/type/__rsync/gencode-remote new file mode 100644 index 00000000..f1c6e4d7 --- /dev/null +++ b/cdist/conf/type/__rsync/gencode-remote @@ -0,0 +1,17 @@ +if [ -f "$__object/parameter/destination-dir" ]; then + destination_dir=$(cat "$__object/parameter/destination-dir") +else + destination_dir="$__object_id" +fi + +ownergroup="" +if [ -f "$__object/parameter/owner" ]; then + ownergroup=$(cat "$__object/parameter/owner") +fi +if [ -f "$__object/parameter/group" ]; then + ownergroup=":$(cat "$__object/parameter/group")" +fi + +if [ "$ownergroup" ]; then + echo chown -R "$ownergroup" "$destination_dir" +fi diff --git a/cdist/conf/type/__rsync/man.text b/cdist/conf/type/__rsync/man.text new file mode 100644 index 00000000..b90d445e --- /dev/null +++ b/cdist/conf/type/__rsync/man.text @@ -0,0 +1,77 @@ +cdist-type__rsync(7) +==================== +Nico Schottelius + + +NAME +---- +cdist-type__rsync - Mirror directories using rsync + + +DESCRIPTION +----------- +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. + +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. + +MESSAGES +-------- +NONE + + +EXAMPLES +-------- + +-------------------------------------------------------------------------------- +# 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" + + +-------------------------------------------------------------------------------- + +SEE ALSO +-------- +- cdist-type(7) + + +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..d25df45b --- /dev/null +++ b/cdist/conf/type/__rsync/manifest @@ -0,0 +1 @@ +__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/required b/cdist/conf/type/__rsync/parameter/required new file mode 100644 index 00000000..58420d42 --- /dev/null +++ b/cdist/conf/type/__rsync/parameter/required @@ -0,0 +1 @@ +source-dir From 055eaed7ade10e94f8999a14755a3a777c7f69ba Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 11 Feb 2015 16:01:22 +0100 Subject: [PATCH 21/53] add hint for / Signed-off-by: Nico Schottelius --- cdist/conf/type/__rsync/man.text | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/cdist/conf/type/__rsync/man.text b/cdist/conf/type/__rsync/man.text index b90d445e..e4d759c6 100644 --- a/cdist/conf/type/__rsync/man.text +++ b/cdist/conf/type/__rsync/man.text @@ -11,11 +11,12 @@ cdist-type__rsync - Mirror directories using rsync DESCRIPTION ----------- 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. +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. -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 ------------------- From 9d25295e1a6fd57633cfa5b08a17f8d02669c091 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 11 Feb 2015 16:44:15 +0100 Subject: [PATCH 22/53] use source, not source dir Signed-off-by: Nico Schottelius --- cdist/conf/type/__rsync/parameter/required | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cdist/conf/type/__rsync/parameter/required b/cdist/conf/type/__rsync/parameter/required index 58420d42..5a18cd2f 100644 --- a/cdist/conf/type/__rsync/parameter/required +++ b/cdist/conf/type/__rsync/parameter/required @@ -1 +1 @@ -source-dir +source From 34253a5c30c1ed09147864e9052d97a27f50d696 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 12 Feb 2015 10:35:07 +0100 Subject: [PATCH 23/53] update missing bits for __rsync Signed-off-by: Nico Schottelius --- cdist/conf/type/__rsync/gencode-local | 10 +++++----- cdist/conf/type/__rsync/gencode-remote | 8 ++++---- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/cdist/conf/type/__rsync/gencode-local b/cdist/conf/type/__rsync/gencode-local index 71e47af1..6df79c97 100644 --- a/cdist/conf/type/__rsync/gencode-local +++ b/cdist/conf/type/__rsync/gencode-local @@ -1,10 +1,10 @@ -source_dir=$(cat "$__object/parameter/source-dir") +source=$(cat "$__object/parameter/source") remote_user=$(cat "$__object/parameter/remote-user") -if [ -f "$__object/parameter/destination-dir" ]; then - destination_dir=$(cat "$__object/parameter/destination-dir") +if [ -f "$__object/parameter/destination" ]; then + destination=$(cat "$__object/parameter/destination") else - destination_dir="$__object_id" + destination="$__object_id" fi set -- @@ -16,4 +16,4 @@ fi echo rsync -a \ --no-owner --no-group \ - -q "$@" "${source_dir}/" "${remote_user}@${__target_host}:$destination_dir" + -q "$@" "${source}/" "${remote_user}@${__target_host}:${destination}" diff --git a/cdist/conf/type/__rsync/gencode-remote b/cdist/conf/type/__rsync/gencode-remote index f1c6e4d7..93125112 100644 --- a/cdist/conf/type/__rsync/gencode-remote +++ b/cdist/conf/type/__rsync/gencode-remote @@ -1,7 +1,7 @@ -if [ -f "$__object/parameter/destination-dir" ]; then - destination_dir=$(cat "$__object/parameter/destination-dir") +if [ -f "$__object/parameter/destination" ]; then + destination=$(cat "$__object/parameter/destination") else - destination_dir="$__object_id" + destination="$__object_id" fi ownergroup="" @@ -13,5 +13,5 @@ if [ -f "$__object/parameter/group" ]; then fi if [ "$ownergroup" ]; then - echo chown -R "$ownergroup" "$destination_dir" + echo chown -R "$ownergroup" "$destination" fi From 0ddc848b1ea438f4439a3c95fdb93277f09a5bae Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 12 Feb 2015 16:21:15 +0100 Subject: [PATCH 24/53] add missing leading / to destination in case object_id is taken Signed-off-by: Nico Schottelius --- cdist/conf/type/__rsync/gencode-local | 2 +- cdist/conf/type/__rsync/gencode-remote | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cdist/conf/type/__rsync/gencode-local b/cdist/conf/type/__rsync/gencode-local index 6df79c97..7d688115 100644 --- a/cdist/conf/type/__rsync/gencode-local +++ b/cdist/conf/type/__rsync/gencode-local @@ -4,7 +4,7 @@ remote_user=$(cat "$__object/parameter/remote-user") if [ -f "$__object/parameter/destination" ]; then destination=$(cat "$__object/parameter/destination") else - destination="$__object_id" + destination="/$__object_id" fi set -- diff --git a/cdist/conf/type/__rsync/gencode-remote b/cdist/conf/type/__rsync/gencode-remote index 93125112..f8d85313 100644 --- a/cdist/conf/type/__rsync/gencode-remote +++ b/cdist/conf/type/__rsync/gencode-remote @@ -1,7 +1,7 @@ if [ -f "$__object/parameter/destination" ]; then destination=$(cat "$__object/parameter/destination") else - destination="$__object_id" + destination="/$__object_id" fi ownergroup="" From 4496c579afed1584c7706f75fbd7f69d4701feb5 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 18 Feb 2015 10:22:34 +0100 Subject: [PATCH 25/53] add warning for __rsync Signed-off-by: Nico Schottelius --- cdist/conf/type/__rsync/man.text | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/cdist/conf/type/__rsync/man.text b/cdist/conf/type/__rsync/man.text index e4d759c6..744b4bc2 100644 --- a/cdist/conf/type/__rsync/man.text +++ b/cdist/conf/type/__rsync/man.text @@ -10,6 +10,15 @@ cdist-type__rsync - Mirror directories using rsync DESCRIPTION ----------- +WARNING: This type is of BETA quality: + +- it has not been tested widely +- interfaces *may* change +- if there is a better approach to solve the problem -> the type may even vanish + +If you are fine with these constraints, please read on. + + This cdist type allows you to mirror local directories to the target host using rsync. Rsync will be installed in the manifest of the type. If group or owner are giveng, a recursive chown will be executed on the From e3ae9a09bbb459edb321e234232b0d4821d50c1f Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 18 Feb 2015 10:23:39 +0100 Subject: [PATCH 26/53] ++changes Signed-off-by: Nico Schottelius --- docs/changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog b/docs/changelog index d61cf724..761eb3ce 100644 --- a/docs/changelog +++ b/docs/changelog @@ -7,6 +7,7 @@ Changelog 3.1.11: * Type __start_on_boot: Support Ubuntu upstart + * New Type: __rsync 3.1.10: 2015-02-10 * Core: Fix too many open files bug (#343) From 041569b41c00a8053824906382c93a9875180580 Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Tue, 24 Feb 2015 12:46:40 +0100 Subject: [PATCH 27/53] new type __config_file to manage configuration files Signed-off-by: Steven Armstrong --- cdist/conf/type/__config_file/gencode-remote | 34 +++++++++++ cdist/conf/type/__config_file/man.text | 60 +++++++++++++++++++ cdist/conf/type/__config_file/manifest | 41 +++++++++++++ .../__config_file/parameter/default/state | 1 + .../type/__config_file/parameter/optional | 6 ++ docs/changelog | 2 + 6 files changed, 144 insertions(+) create mode 100755 cdist/conf/type/__config_file/gencode-remote create mode 100644 cdist/conf/type/__config_file/man.text create mode 100755 cdist/conf/type/__config_file/manifest create mode 100644 cdist/conf/type/__config_file/parameter/default/state create mode 100644 cdist/conf/type/__config_file/parameter/optional 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.text b/cdist/conf/type/__config_file/man.text new file mode 100644 index 00000000..a4ec7363 --- /dev/null +++ b/cdist/conf/type/__config_file/man.text @@ -0,0 +1,60 @@ +cdist-type__config_file(7) +========================== +Steven Armstrong + + +NAME +---- +cdist-type__config_file - manages config files + + +DESCRIPTION +----------- +Deploy config files using the file type. +Run the given code if the files changes. + + +REQUIRED PARAMETERS +------------------- +None. + + +OPTIONAL PARAMETERS +------------------- +group:: + see cdist-type__file +mode:: + see cdist-type__file +onchange:: + the code to run if the file changes +owner:: + see cdist-type__file +source:: + Path to the config file. + If source is '-' (dash), take what was written to stdin as the config file content. +state:: + see cdist-type__file + + +EXAMPLES +-------- + +-------------------------------------------------------------------------------- +__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/docs/changelog b/docs/changelog index 761eb3ce..62095c27 100644 --- a/docs/changelog +++ b/docs/changelog @@ -4,6 +4,8 @@ Changelog * Changes are always commented with their author in (braces) * Exception: No braces means author == Nico Schottelius +next: + * New type __config_file: Manage configuration files and run code on change 3.1.11: * Type __start_on_boot: Support Ubuntu upstart From 4f7ae8425d6ce13653daca15b3339889bd707835 Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Tue, 24 Feb 2015 13:01:48 +0100 Subject: [PATCH 28/53] New type __staged_file: Manage staged files Signed-off-by: Steven Armstrong --- cdist/conf/type/__staged_file/gencode-local | 98 +++++++++++++++++ cdist/conf/type/__staged_file/man.text | 103 ++++++++++++++++++ cdist/conf/type/__staged_file/manifest | 38 +++++++ .../parameter/default/fetch-command | 1 + .../__staged_file/parameter/default/stage-dir | 1 + .../__staged_file/parameter/default/state | 1 + .../type/__staged_file/parameter/optional | 7 ++ .../type/__staged_file/parameter/required | 2 + docs/changelog | 1 + 9 files changed, 252 insertions(+) create mode 100755 cdist/conf/type/__staged_file/gencode-local create mode 100644 cdist/conf/type/__staged_file/man.text create mode 100755 cdist/conf/type/__staged_file/manifest create mode 100644 cdist/conf/type/__staged_file/parameter/default/fetch-command create mode 100644 cdist/conf/type/__staged_file/parameter/default/stage-dir create mode 100644 cdist/conf/type/__staged_file/parameter/default/state create mode 100644 cdist/conf/type/__staged_file/parameter/optional create mode 100644 cdist/conf/type/__staged_file/parameter/required diff --git a/cdist/conf/type/__staged_file/gencode-local b/cdist/conf/type/__staged_file/gencode-local new file mode 100755 index 00000000..87d79f4c --- /dev/null +++ b/cdist/conf/type/__staged_file/gencode-local @@ -0,0 +1,98 @@ +#!/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 -x + +destination="$__object_id" +source="$(cat "$__object/parameter/source")" +cksum="$(cat "$__object/parameter/cksum")" +stage_dir="$(cat "$__object/parameter/stage-dir")" +state="$(cat "$__object/parameter/state")" +fetch_command="$(cat "$__object/parameter/fetch-command")" +stage_file="${stage_dir}/${destination}" +stage_file_dir="${stage_file%/*}" +source_file_name="${source##*/}" + +if [ "$state" = "absent" ]; then + # nothing to do + exit 0 +fi + +#printf 'set -x\n' + +if [ ! -d "$stage_dir" ]; then + printf 'mkdir -p "%s"\n' "$stage_dir" + printf 'chmod 700 "%s"\n' "$stage_dir" +fi + +if [ ! -d "$stage_file_dir" ]; then + printf 'mkdir -p "%s"\n' "$stage_file_dir" +fi + + +get_file() { + if [ -f "$__object/parameter/prepare-command" ]; then + fetch_and_prepare_file + else + fetch_file + fi +} + +fetch_file() { + printf "$fetch_command" "$source" + printf ' > "%s"\n' "$stage_file" +} + +fetch_and_prepare_file() { + printf 'tmpdir="$(mktemp -d --tmpdir="/tmp" "%s")"\n' "${__type##*/}.XXXXXXXXXX" + printf 'cd "$tmpdir"\n' + printf "$fetch_command > \"%s\"\n" "$source" "$source_file_name" + prepare_command="$(cat "$__object/parameter/prepare-command")" + printf "$prepare_command > \"%s\"\n" "$source_file_name" "$stage_file" + printf 'cd - >/dev/null\n' + printf 'rm -rf "$tmpdir"\n' +} + +cat << DONE +verify_cksum() { + cksum_is="\$(cksum "$stage_file" | cut -d' ' -f1,2)" + cksum_should="$(cat "$__object/parameter/cksum" | cut -d' ' -f1,2)" + if [ "\$cksum_is" == "\$cksum_should" ]; then + return 0 + else + return 1 + fi +} +DONE + +if [ ! -f "$stage_file" ]; then + get_file +else + printf 'verify_cksum || {\n' + get_file + printf '}\n' +fi + +cat << DONE +verify_cksum || { + echo "Failed to verify checksum for $__object_name" >&2 + exit 1 +} +DONE diff --git a/cdist/conf/type/__staged_file/man.text b/cdist/conf/type/__staged_file/man.text new file mode 100644 index 00000000..e94e491d --- /dev/null +++ b/cdist/conf/type/__staged_file/man.text @@ -0,0 +1,103 @@ +cdist-type__staged_file(7) +========================== +Steven Armstrong + + +NAME +---- +cdist-type__staged_file - manage staged files + + +DESCRIPTION +----------- +Manages a staged file that is downloaded on the server (the machine running +cdist) and then deployed to the target host using the __file type. + + +REQUIRED PARAMETERS +------------------- +source:: + the URL from which to retreive the source file. + e.g. + https://dl.bintray.com/mitchellh/consul/0.4.1_linux_amd64.zip + file:///path/to/local/file +cksum:: + the output of running the command: `cksum $source-file` + e.g. + $ echo foobar > /tmp/foobar + $ cksum /tmp/foobar + 857691210 7 /tmp/foobar + If either checksum or file size has changed the file will be + (re)fetched from the --source. The file name can be omitted and is + ignored if given. + + +OPTIONAL PARAMETERS +------------------- +fetch-command:: + the command used to fetch the staged file using printf formatting. + Where a single %s will be replaced with the value of the given --source + parameter. The --fetch-command is expected to output the fetched file to + stdout. + Defaults to 'curl -s -L "%s"'. +group:: + see cdist-type__file +owner:: + see cdist-type__file +mode:: + see cdist-type__file +prepare-command:: + the optional command used to prepare or preprocess the staged file for later + use by the file type. + If given, it must be a string in printf formatting where a single %s will + be replaced with the last segment (filename) of the value of the given + --source parameter. + It is executed in the same directory into which the fetched file has been + saved. The --prepare-command is expected to output the final file to stdout. + + So for example given a --source of https://example.com/my-zip.zip, and a + --prepare-command of 'unzip -p "%s"', the code `unzip -p "my-zip.zip"` will + be executed in the folder containing the downloaded file my-zip.zip. + A more complex example might be --prepare-command 'tar -xz "%s"; cat path/from/archive' +stage-dir:: + the directory in which to store downloaded and prepared files. + Defaults to '/var/tmp/cdist/__staged_file' +state:: + see cdist-type__file + + +EXAMPLES +-------- + +-------------------------------------------------------------------------------- +__staged_file /usr/local/bin/consul \ + --source file:///path/to/local/copy/consul \ + --cksum '428915666 15738724' \ + --state present \ + --group root \ + --owner root \ + --mode 755 + +__staged_file /usr/local/bin/consul \ + --source https://dl.bintray.com/mitchellh/consul/0.4.1_linux_amd64.zip \ + --cksum '428915666 15738724' \ + --fetch-command 'curl -s -L "%s"' \ + --prepare-command 'unzip -p "%s"' \ + --state present \ + --group root \ + --owner root \ + --mode 755 + +-------------------------------------------------------------------------------- + + +SEE ALSO +-------- +- 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/__staged_file/manifest b/cdist/conf/type/__staged_file/manifest new file mode 100755 index 00000000..454948b4 --- /dev/null +++ b/cdist/conf/type/__staged_file/manifest @@ -0,0 +1,38 @@ +#!/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" +source="$(cat "$__object/parameter/source")" +cksum="$(cat "$__object/parameter/cksum")" +stage_dir="$(cat "$__object/parameter/stage-dir")" +state="$(cat "$__object/parameter/state")" +fetch_command="$(cat "$__object/parameter/fetch-command")" +stage_file="${stage_dir}/${destination}" + +set -- "/${destination}" +for param in owner group mode state; do + if [ -f "$__object/parameter/$param" ]; then + set -- "$@" "--${param}" "$(cat "$__object/parameter/$param")" + fi +done +set -- "$@" --source "$stage_file" + +require="$__object_name" \ + __file "$@" diff --git a/cdist/conf/type/__staged_file/parameter/default/fetch-command b/cdist/conf/type/__staged_file/parameter/default/fetch-command new file mode 100644 index 00000000..b4dc1211 --- /dev/null +++ b/cdist/conf/type/__staged_file/parameter/default/fetch-command @@ -0,0 +1 @@ +curl -s -L "%s" diff --git a/cdist/conf/type/__staged_file/parameter/default/stage-dir b/cdist/conf/type/__staged_file/parameter/default/stage-dir new file mode 100644 index 00000000..9420b510 --- /dev/null +++ b/cdist/conf/type/__staged_file/parameter/default/stage-dir @@ -0,0 +1 @@ +/var/tmp/cdist/__staged_file diff --git a/cdist/conf/type/__staged_file/parameter/default/state b/cdist/conf/type/__staged_file/parameter/default/state new file mode 100644 index 00000000..e7f6134f --- /dev/null +++ b/cdist/conf/type/__staged_file/parameter/default/state @@ -0,0 +1 @@ +present diff --git a/cdist/conf/type/__staged_file/parameter/optional b/cdist/conf/type/__staged_file/parameter/optional new file mode 100644 index 00000000..18f4e87a --- /dev/null +++ b/cdist/conf/type/__staged_file/parameter/optional @@ -0,0 +1,7 @@ +fetch-command +group +owner +mode +prepare-command +stage-dir +state diff --git a/cdist/conf/type/__staged_file/parameter/required b/cdist/conf/type/__staged_file/parameter/required new file mode 100644 index 00000000..bfb1d5bf --- /dev/null +++ b/cdist/conf/type/__staged_file/parameter/required @@ -0,0 +1,2 @@ +cksum +source diff --git a/docs/changelog b/docs/changelog index 62095c27..9017f526 100644 --- a/docs/changelog +++ b/docs/changelog @@ -5,6 +5,7 @@ Changelog * Exception: No braces means author == Nico Schottelius next: + * New type __staged_file: Manage staged files * New type __config_file: Manage configuration files and run code on change 3.1.11: From 2c7ab566e10c138dfbf013bda78aaee4b3af0c95 Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Tue, 24 Feb 2015 13:10:17 +0100 Subject: [PATCH 29/53] add new types to manage consul and friends Signed-off-by: Steven Armstrong --- cdist/conf/type/__consul/man.text | 71 +++++++ cdist/conf/type/__consul/manifest | 65 +++++++ .../__consul/parameter/default/install-from | 1 + .../__consul/parameter/default/install-to | 1 + .../type/__consul/parameter/default/state | 1 + cdist/conf/type/__consul/parameter/optional | 3 + cdist/conf/type/__consul/singleton | 0 .../type/__consul_agent/files/consul.systemd | 17 ++ .../type/__consul_agent/files/consul.sysv | 93 ++++++++++ .../type/__consul_agent/files/consul.upstart | 13 ++ cdist/conf/type/__consul_agent/gencode-remote | 31 ++++ cdist/conf/type/__consul_agent/man.text | 134 ++++++++++++++ cdist/conf/type/__consul_agent/manifest | 175 ++++++++++++++++++ .../type/__consul_agent/parameter/boolean | 8 + .../__consul_agent/parameter/default/group | 1 + .../__consul_agent/parameter/default/state | 1 + .../__consul_agent/parameter/default/user | 1 + .../type/__consul_agent/parameter/optional | 13 ++ .../parameter/optional_multiple | 1 + cdist/conf/type/__consul_agent/singleton | 0 cdist/conf/type/__consul_check/man.text | 68 +++++++ cdist/conf/type/__consul_check/manifest | 64 +++++++ .../__consul_check/parameter/default/state | 1 + .../type/__consul_check/parameter/optional | 7 + .../conf/type/__consul_reload/gencode-remote | 24 +++ cdist/conf/type/__consul_reload/man.text | 42 +++++ cdist/conf/type/__consul_reload/singleton | 0 cdist/conf/type/__consul_service/man.text | 71 +++++++ cdist/conf/type/__consul_service/manifest | 83 +++++++++ .../__consul_service/parameter/default/state | 1 + .../type/__consul_service/parameter/optional | 7 + .../parameter/optional_multiple | 1 + .../files/consul-template.systemd | 19 ++ .../files/consul-template.sysv | 89 +++++++++ .../files/consul-template.upstart | 12 ++ cdist/conf/type/__consul_template/man.text | 72 +++++++ cdist/conf/type/__consul_template/manifest | 121 ++++++++++++ .../type/__consul_template/parameter/boolean | 2 + .../parameter/default/consul | 1 + .../type/__consul_template/parameter/optional | 7 + cdist/conf/type/__consul_template/singleton | 0 .../type/__consul_template_template/man.text | 69 +++++++ .../type/__consul_template_template/manifest | 74 ++++++++ .../parameter/default/state | 1 + .../parameter/optional | 4 + .../parameter/required | 1 + .../conf/type/__consul_watch_checks/man.text | 64 +++++++ .../conf/type/__consul_watch_checks/manifest | 61 ++++++ .../parameter/default/state | 1 + .../__consul_watch_checks/parameter/optional | 5 + .../__consul_watch_checks/parameter/required | 1 + cdist/conf/type/__consul_watch_event/man.text | 58 ++++++ cdist/conf/type/__consul_watch_event/manifest | 51 +++++ .../parameter/default/state | 1 + .../__consul_watch_event/parameter/optional | 4 + .../__consul_watch_event/parameter/required | 1 + cdist/conf/type/__consul_watch_key/man.text | 55 ++++++ cdist/conf/type/__consul_watch_key/manifest | 51 +++++ .../parameter/default/state | 1 + .../__consul_watch_key/parameter/optional | 3 + .../__consul_watch_key/parameter/required | 2 + .../type/__consul_watch_keyprefix/man.text | 55 ++++++ .../type/__consul_watch_keyprefix/manifest | 51 +++++ .../parameter/default/state | 1 + .../parameter/optional | 3 + .../parameter/required | 2 + cdist/conf/type/__consul_watch_nodes/man.text | 52 ++++++ cdist/conf/type/__consul_watch_nodes/manifest | 51 +++++ .../parameter/default/state | 1 + .../__consul_watch_nodes/parameter/optional | 3 + .../__consul_watch_nodes/parameter/required | 1 + .../conf/type/__consul_watch_service/man.text | 74 ++++++++ .../conf/type/__consul_watch_service/manifest | 54 ++++++ .../__consul_watch_service/parameter/boolean | 1 + .../parameter/default/state | 1 + .../__consul_watch_service/parameter/optional | 4 + .../__consul_watch_service/parameter/required | 2 + .../type/__consul_watch_services/man.text | 52 ++++++ .../type/__consul_watch_services/manifest | 51 +++++ .../parameter/default/state | 1 + .../parameter/optional | 3 + .../parameter/required | 1 + docs/changelog | 14 ++ 83 files changed, 2308 insertions(+) create mode 100644 cdist/conf/type/__consul/man.text create mode 100755 cdist/conf/type/__consul/manifest create mode 100644 cdist/conf/type/__consul/parameter/default/install-from create mode 100644 cdist/conf/type/__consul/parameter/default/install-to create mode 100644 cdist/conf/type/__consul/parameter/default/state create mode 100644 cdist/conf/type/__consul/parameter/optional create mode 100644 cdist/conf/type/__consul/singleton create mode 100644 cdist/conf/type/__consul_agent/files/consul.systemd create mode 100644 cdist/conf/type/__consul_agent/files/consul.sysv create mode 100644 cdist/conf/type/__consul_agent/files/consul.upstart create mode 100755 cdist/conf/type/__consul_agent/gencode-remote create mode 100644 cdist/conf/type/__consul_agent/man.text create mode 100755 cdist/conf/type/__consul_agent/manifest create mode 100644 cdist/conf/type/__consul_agent/parameter/boolean create mode 100644 cdist/conf/type/__consul_agent/parameter/default/group create mode 100644 cdist/conf/type/__consul_agent/parameter/default/state create mode 100644 cdist/conf/type/__consul_agent/parameter/default/user create mode 100644 cdist/conf/type/__consul_agent/parameter/optional create mode 100644 cdist/conf/type/__consul_agent/parameter/optional_multiple create mode 100644 cdist/conf/type/__consul_agent/singleton create mode 100644 cdist/conf/type/__consul_check/man.text create mode 100755 cdist/conf/type/__consul_check/manifest create mode 100644 cdist/conf/type/__consul_check/parameter/default/state create mode 100644 cdist/conf/type/__consul_check/parameter/optional create mode 100755 cdist/conf/type/__consul_reload/gencode-remote create mode 100644 cdist/conf/type/__consul_reload/man.text create mode 100644 cdist/conf/type/__consul_reload/singleton create mode 100644 cdist/conf/type/__consul_service/man.text create mode 100755 cdist/conf/type/__consul_service/manifest create mode 100644 cdist/conf/type/__consul_service/parameter/default/state create mode 100644 cdist/conf/type/__consul_service/parameter/optional create mode 100644 cdist/conf/type/__consul_service/parameter/optional_multiple create mode 100644 cdist/conf/type/__consul_template/files/consul-template.systemd create mode 100644 cdist/conf/type/__consul_template/files/consul-template.sysv create mode 100644 cdist/conf/type/__consul_template/files/consul-template.upstart create mode 100644 cdist/conf/type/__consul_template/man.text create mode 100755 cdist/conf/type/__consul_template/manifest create mode 100644 cdist/conf/type/__consul_template/parameter/boolean create mode 100644 cdist/conf/type/__consul_template/parameter/default/consul create mode 100644 cdist/conf/type/__consul_template/parameter/optional create mode 100644 cdist/conf/type/__consul_template/singleton create mode 100644 cdist/conf/type/__consul_template_template/man.text create mode 100755 cdist/conf/type/__consul_template_template/manifest create mode 100644 cdist/conf/type/__consul_template_template/parameter/default/state create mode 100644 cdist/conf/type/__consul_template_template/parameter/optional create mode 100644 cdist/conf/type/__consul_template_template/parameter/required create mode 100644 cdist/conf/type/__consul_watch_checks/man.text create mode 100755 cdist/conf/type/__consul_watch_checks/manifest create mode 100644 cdist/conf/type/__consul_watch_checks/parameter/default/state create mode 100644 cdist/conf/type/__consul_watch_checks/parameter/optional create mode 100644 cdist/conf/type/__consul_watch_checks/parameter/required create mode 100644 cdist/conf/type/__consul_watch_event/man.text create mode 100755 cdist/conf/type/__consul_watch_event/manifest create mode 100644 cdist/conf/type/__consul_watch_event/parameter/default/state create mode 100644 cdist/conf/type/__consul_watch_event/parameter/optional create mode 100644 cdist/conf/type/__consul_watch_event/parameter/required create mode 100644 cdist/conf/type/__consul_watch_key/man.text create mode 100755 cdist/conf/type/__consul_watch_key/manifest create mode 100644 cdist/conf/type/__consul_watch_key/parameter/default/state create mode 100644 cdist/conf/type/__consul_watch_key/parameter/optional create mode 100644 cdist/conf/type/__consul_watch_key/parameter/required create mode 100644 cdist/conf/type/__consul_watch_keyprefix/man.text create mode 100755 cdist/conf/type/__consul_watch_keyprefix/manifest create mode 100644 cdist/conf/type/__consul_watch_keyprefix/parameter/default/state create mode 100644 cdist/conf/type/__consul_watch_keyprefix/parameter/optional create mode 100644 cdist/conf/type/__consul_watch_keyprefix/parameter/required create mode 100644 cdist/conf/type/__consul_watch_nodes/man.text create mode 100755 cdist/conf/type/__consul_watch_nodes/manifest create mode 100644 cdist/conf/type/__consul_watch_nodes/parameter/default/state create mode 100644 cdist/conf/type/__consul_watch_nodes/parameter/optional create mode 100644 cdist/conf/type/__consul_watch_nodes/parameter/required create mode 100644 cdist/conf/type/__consul_watch_service/man.text create mode 100755 cdist/conf/type/__consul_watch_service/manifest create mode 100644 cdist/conf/type/__consul_watch_service/parameter/boolean create mode 100644 cdist/conf/type/__consul_watch_service/parameter/default/state create mode 100644 cdist/conf/type/__consul_watch_service/parameter/optional create mode 100644 cdist/conf/type/__consul_watch_service/parameter/required create mode 100644 cdist/conf/type/__consul_watch_services/man.text create mode 100755 cdist/conf/type/__consul_watch_services/manifest create mode 100644 cdist/conf/type/__consul_watch_services/parameter/default/state create mode 100644 cdist/conf/type/__consul_watch_services/parameter/optional create mode 100644 cdist/conf/type/__consul_watch_services/parameter/required diff --git a/cdist/conf/type/__consul/man.text b/cdist/conf/type/__consul/man.text new file mode 100644 index 00000000..f91dcf5c --- /dev/null +++ b/cdist/conf/type/__consul/man.text @@ -0,0 +1,71 @@ +cdist-type__consul(7) +===================== +Steven Armstrong + + +NAME +---- +cdist-type__consul - install consul + + +DESCRIPTION +----------- +Quick and dirty installation of the consul binary. +Note that the consul binary is downloaded on the server and then deployed using +the __file type. + +Future ideas: +- get latest version info from https://checkpoint-api.hashicorp.com/v1/check/consul + - then download from + https://dl.bintray.com/mitchellh/consul/${current_version}_${os}_${arch}.zip +- install from given path to binary +- download from given url +- install from packet + + + +OPTIONAL PARAMETERS +------------------- +install-from:: + uri from where to download consul. This can be anything that curl understands. + If install-uri ends with .zip the downloaded file will be unziped and the + contained file deployed as the consul binary. If install-uri does not end in .zip + it is assumed to be the consul binary and will be deployed as is. + +install-to:: + where to install the binary. Defaults to /usr/local/bin/consul + +state:: + either 'present' or 'absent'. Defaults to 'present' + + +EXAMPLES +-------- + +-------------------------------------------------------------------------------- +# just install using defaults +__consul + +# download on the machine running cdist, then unzip, then upload to the target host +__consul \ + --install-from https://dl.bintray.com/mitchellh/consul/0.4.1_linux_amd64.zip + +# take binary from local folder on the machine running cdist +__consul \ + --install-from file:///cluster/adm/software/consul/bin/consul + +# install the consul binary to a specific location +__consul \ + --install-to /somewhere/special/consul +-------------------------------------------------------------------------------- + + +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..321a3e4c --- /dev/null +++ b/cdist/conf/type/__consul/manifest @@ -0,0 +1,65 @@ +#!/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|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 + + +state="$(cat "$__object/parameter/state")" +install_from="$(cat "$__object/parameter/install-from")" +install_to="$(cat "$__object/parameter/install-to")" + +if [ "$state" = "absent" ]; then + __file "$install_to" \ + --state absent + exit 0 +fi + +case "$install_from" in + /*|file://*) + source="${install_from#*file://}" + ;; + *.zip) + mkdir "$__object/files" + source="$__object/files/consul" + # FIXME: need some persistent place to cache downloaded files + curl -s "$install_from" | unzip -p > "$source" + ;; + *) + echo "Do not know how to install from: $install_from" >&2 + exit 1 + ;; +esac + +__file "$install_to" \ + --owner root --group root --mode 755 \ + --source "$source" diff --git a/cdist/conf/type/__consul/parameter/default/install-from b/cdist/conf/type/__consul/parameter/default/install-from new file mode 100644 index 00000000..b1e9908d --- /dev/null +++ b/cdist/conf/type/__consul/parameter/default/install-from @@ -0,0 +1 @@ +https://dl.bintray.com/mitchellh/consul/0.4.1_linux_amd64.zip diff --git a/cdist/conf/type/__consul/parameter/default/install-to b/cdist/conf/type/__consul/parameter/default/install-to new file mode 100644 index 00000000..f85c9e67 --- /dev/null +++ b/cdist/conf/type/__consul/parameter/default/install-to @@ -0,0 +1 @@ +/usr/local/bin/consul 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/optional b/cdist/conf/type/__consul/parameter/optional new file mode 100644 index 00000000..480f1bcd --- /dev/null +++ b/cdist/conf/type/__consul/parameter/optional @@ -0,0 +1,3 @@ +install-from +install-to +state diff --git a/cdist/conf/type/__consul/singleton b/cdist/conf/type/__consul/singleton new file mode 100644 index 00000000..e69de29b 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..db624fd1 --- /dev/null +++ b/cdist/conf/type/__consul_agent/files/consul.systemd @@ -0,0 +1,17 @@ +[Unit] +Description=Consul Agent +Wants=basic.target +After=basic.target network.target + +[Service] +User=consul +Group=consul +Environment="GOMAXPROCS=2" +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 b/cdist/conf/type/__consul_agent/files/consul.sysv new file mode 100644 index 00000000..9a2aaeb2 --- /dev/null +++ b/cdist/conf/type/__consul_agent/files/consul.sysv @@ -0,0 +1,93 @@ +#!/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 /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: " + "$CONSUL" leave + 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}" + 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.text b/cdist/conf/type/__consul_agent/man.text new file mode 100644 index 00000000..63337185 --- /dev/null +++ b/cdist/conf/type/__consul_agent/man.text @@ -0,0 +1,134 @@ +cdist-type__consul_agent(7) +=========================== +Steven Armstrong + + +NAME +---- +cdist-type__consul_agent - manage the consul agent + + +DESCRIPTION +----------- +Configure and manage the consul agent. + + +REQUIRED PARAMETERS +------------------- +None. + + +OPTIONAL PARAMETERS +------------------- +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 +-------- + +-------------------------------------------------------------------------------- +# 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) + + +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..f9514755 --- /dev/null +++ b/cdist/conf/type/__consul_agent/manifest @@ -0,0 +1,175 @@ +#!/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 + : + ;; + *) + 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" +printf ' ,"config_dir": "%s"\n' "$conf_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%*,}" + ;; + 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 + printf ',' + # remove trailing , + json=$(cat "$json_config") + echo "${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 - + + +# 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 + 7) + __file /lib/systemd/system/consul.service \ + --owner root --group root --mode 0555 \ + --state "$state" \ + --source "$__type/files/consul.systemd" + export require="__file/lib/systemd/system/consul.service" + ;; + *) + __file /etc/init.d/consul \ + --owner root --group root --mode 0555 \ + --state "$state" \ + --source "$__type/files/consul.sysv" + export require="__file/etc/init.d/consul" + ;; + esac + __start_on_boot consul --state "$state" + ;; + ubuntu) + __file /etc/init/consul.conf \ + --owner root --group root --mode 0644 \ + --state "$state" \ + --source "$__type/files/consul.upstart" + export require="__file/etc/init/consul.conf" + __start_on_boot consul --state "$state" + ;; +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..bceaf060 --- /dev/null +++ b/cdist/conf/type/__consul_agent/parameter/optional @@ -0,0 +1,13 @@ +bind-addr +bootstrap-expect +ca-file-source +cert-file-source +client-addr +datacenter +encrypt +group +json-config +key-file-source +node-name +user +state 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..12cd064c --- /dev/null +++ b/cdist/conf/type/__consul_agent/parameter/optional_multiple @@ -0,0 +1 @@ +retry-join diff --git a/cdist/conf/type/__consul_agent/singleton b/cdist/conf/type/__consul_agent/singleton new file mode 100644 index 00000000..e69de29b diff --git a/cdist/conf/type/__consul_check/man.text b/cdist/conf/type/__consul_check/man.text new file mode 100644 index 00000000..18eaf638 --- /dev/null +++ b/cdist/conf/type/__consul_check/man.text @@ -0,0 +1,68 @@ +cdist-type__consul_check(7) +============================= +Steven Armstrong + + +NAME +---- +cdist-type__consul_check - manages consul checks + + +DESCRIPTION +----------- +Generate and deploy check definitions for a consul agent. +See http://www.consul.io/docs/agent/checks.html for parameter documentation. + +Use either script 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 +-------- + +-------------------------------------------------------------------------------- +__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.text b/cdist/conf/type/__consul_reload/man.text new file mode 100644 index 00000000..8dd045cf --- /dev/null +++ b/cdist/conf/type/__consul_reload/man.text @@ -0,0 +1,42 @@ +cdist-type__consul_reload(7) +============================ +Steven Armstrong + + +NAME +---- +cdist-type__consul_reload - reload consul + + +DESCRIPTION +----------- +Reload consul after configuration changes. + + +REQUIRED PARAMETERS +------------------- +None. + + +OPTIONAL PARAMETERS +------------------- +None. + + +EXAMPLES +-------- + +-------------------------------------------------------------------------------- +__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/conf/type/__consul_reload/singleton b/cdist/conf/type/__consul_reload/singleton new file mode 100644 index 00000000..e69de29b diff --git a/cdist/conf/type/__consul_service/man.text b/cdist/conf/type/__consul_service/man.text new file mode 100644 index 00000000..6bb024b1 --- /dev/null +++ b/cdist/conf/type/__consul_service/man.text @@ -0,0 +1,71 @@ +cdist-type__consul_service(7) +============================= +Steven Armstrong + + +NAME +---- +cdist-type__consul_service - manages consul services + + +DESCRIPTION +----------- +Generate and deploy service definitions for a consul agent. +See http://www.consul.io/docs/agent/services.html for parameter documentation. + +Use either script together with interval, or use ttl. + + +REQUIRED PARAMETERS +------------------- +None. + + +OPTIONAL PARAMETERS +------------------- +check-interval:: + the interval in which the script given with --check-script should be run +check-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 +-------- + +-------------------------------------------------------------------------------- +__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/man.text b/cdist/conf/type/__consul_template/man.text new file mode 100644 index 00000000..26afd4f1 --- /dev/null +++ b/cdist/conf/type/__consul_template/man.text @@ -0,0 +1,72 @@ +cdist-type__consul_template(7) +============================== +Steven Armstrong + + +NAME +---- +cdist-type__consul_template - manage the consul-template service + + +DESCRIPTION +----------- +Installs consul-template, generates a global config file and creates directory +for per template config files. + + +REQUIRED PARAMETERS +------------------- +None. + + +OPTIONAL PARAMETERS +------------------- +auth:: + specify a username (and 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'. +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. +token:: + the Consul API token. +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. + + +EXAMPLES +-------- + +-------------------------------------------------------------------------------- +__consul_template \ + --consul consul.service.consul:8500 \ + --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..dba7e68e --- /dev/null +++ b/cdist/conf/type/__consul_template/manifest @@ -0,0 +1,121 @@ +#!/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 + : + ;; + *) + 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="present" +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 + + +__staged_file /usr/local/bin/consul-template \ + --source https://github.com/hashicorp/consul-template/releases/download/v0.6.5/consul-template_0.6.5_linux_amd64.tar.gz \ + --cksum '1356006333 8496656 consul-template' \ + --fetch-command 'curl -s -L "%s"' \ + --prepare-command 'tar -xzf "%s"; cat consul-template_*/consul-template' \ + --state present \ + --group root \ + --owner root \ + --mode 755 + + +# Generate hcl config file +( +for param in $(ls "$__object/parameter/"); do + case "$param" in + ssl|ssl-no-verify) # boolean + key="$(echo "$param" | tr '-' '_')" + printf '%s = true\n' "$key" + ;; + auth|batch-size|consul|max-stale|retry|token|wait) + key="$(echo "$param" | tr '-' '_')" + printf '%s = "%s"\n' "$key" "$(cat "$__object/parameter/$param")" + ;; + *) + # ignore unknown parameters + : + ;; + esac +done +) | \ +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 - + + +# 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" + ;; +esac diff --git a/cdist/conf/type/__consul_template/parameter/boolean b/cdist/conf/type/__consul_template/parameter/boolean new file mode 100644 index 00000000..5e17dcd7 --- /dev/null +++ b/cdist/conf/type/__consul_template/parameter/boolean @@ -0,0 +1,2 @@ +ssl +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/optional b/cdist/conf/type/__consul_template/parameter/optional new file mode 100644 index 00000000..34c277b9 --- /dev/null +++ b/cdist/conf/type/__consul_template/parameter/optional @@ -0,0 +1,7 @@ +auth +batch-size +consul +max-stale +retry +token +wait diff --git a/cdist/conf/type/__consul_template/singleton b/cdist/conf/type/__consul_template/singleton new file mode 100644 index 00000000..e69de29b diff --git a/cdist/conf/type/__consul_template_template/man.text b/cdist/conf/type/__consul_template_template/man.text new file mode 100644 index 00000000..159a63fb --- /dev/null +++ b/cdist/conf/type/__consul_template_template/man.text @@ -0,0 +1,69 @@ +cdist-type__consul_template_template(7) +======================================= +Steven Armstrong + + +NAME +---- +cdist-type__consul_template_template - manage consul-template templates + + +DESCRIPTION +----------- +Generate and deploy template definitions for a consul-template. +See https://github.com/hashicorp/consul-template#examples for documentation. +Templates are written in the Go template format. +Either the --source or the --source-file parameter must be given. + + +REQUIRED PARAMETERS +------------------- +destination:: + the destination where the generated file should go. + + +OPTIONAL PARAMETERS +------------------- +command:: + an optional command to run after rendering the template to its destination. +source:: + path to the template source. Conflicts --source-file. +source-file:: + path to a local file which is uploaded using the __file type and configured + as the source. + If source is '-' (dash), take what was written to stdin as the file content. + Conflicts --source. +state:: + if this template is 'present' or 'absent'. Defaults to 'present'. + + +EXAMPLES +-------- + +-------------------------------------------------------------------------------- +# 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.text b/cdist/conf/type/__consul_watch_checks/man.text new file mode 100644 index 00000000..75c42fc2 --- /dev/null +++ b/cdist/conf/type/__consul_watch_checks/man.text @@ -0,0 +1,64 @@ +cdist-type__consul_watch_checks(7) +================================== +Steven Armstrong + + +NAME +---- +cdist-type__consul_watch_checks - manages consul checks watches + + +DESCRIPTION +----------- +Generate and deploy watch definitions of type 'checks' for a consul agent. +See http://www.consul.io/docs/agent/watches.html for parameter documentation. + + +REQUIRED PARAMETERS +------------------- +handler:: + the handler to invoke when the data view updates + + +OPTIONAL PARAMETERS +------------------- +datacenter:: + can be provided to override the agent's default datacenter +filter-service:: + filter to a specific service. Conflicts with --filter-state. +filter-state:: + filter to a specific state. Conflicts with --filter-service. +state:: + if this watch is 'present' or 'absent'. Defaults to 'present'. +token:: + can be provided to override the agent's default ACL token + + +EXAMPLES +-------- + +-------------------------------------------------------------------------------- +__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.text b/cdist/conf/type/__consul_watch_event/man.text new file mode 100644 index 00000000..3b393241 --- /dev/null +++ b/cdist/conf/type/__consul_watch_event/man.text @@ -0,0 +1,58 @@ +cdist-type__consul_watch_event(7) +================================= +Steven Armstrong + + +NAME +---- +cdist-type__consul_watch_event - manages consul event watches + + +DESCRIPTION +----------- +Generate and deploy watch definitions of type 'event' for a consul agent. +See http://www.consul.io/docs/agent/watches.html for parameter documentation. + + +REQUIRED PARAMETERS +------------------- +handler:: + the handler to invoke when the data view updates + + +OPTIONAL PARAMETERS +------------------- +datacenter:: + can be provided to override the agent's default datacenter +name:: + restrict the watch to only events with the given name +state:: + if this watch is 'present' or 'absent'. Defaults to 'present'. +token:: + can be provided to override the agent's default ACL token + + +EXAMPLES +-------- + +-------------------------------------------------------------------------------- +__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.text b/cdist/conf/type/__consul_watch_key/man.text new file mode 100644 index 00000000..5d8381cb --- /dev/null +++ b/cdist/conf/type/__consul_watch_key/man.text @@ -0,0 +1,55 @@ +cdist-type__consul_watch_key(7) +=============================== +Steven Armstrong + + +NAME +---- +cdist-type__consul_watch_key - manages consul key watches + + +DESCRIPTION +----------- +Generate and deploy watch definitions of type 'key' for a consul agent. +See http://www.consul.io/docs/agent/watches.html for parameter documentation. + + +REQUIRED PARAMETERS +------------------- +handler:: + the handler to invoke when the data view updates +key:: + the key to watch for changes + + +OPTIONAL PARAMETERS +------------------- +datacenter:: + can be provided to override the agent's default datacenter +state:: + if this watch is 'present' or 'absent'. Defaults to 'present'. +token:: + can be provided to override the agent's default ACL token + + +EXAMPLES +-------- + +-------------------------------------------------------------------------------- +__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.text b/cdist/conf/type/__consul_watch_keyprefix/man.text new file mode 100644 index 00000000..e2f05de2 --- /dev/null +++ b/cdist/conf/type/__consul_watch_keyprefix/man.text @@ -0,0 +1,55 @@ +cdist-type__consul_watch_keyprefix(7) +===================================== +Steven Armstrong + + +NAME +---- +cdist-type__consul_watch_keyprefix - manages consul keyprefix watches + + +DESCRIPTION +----------- +Generate and deploy watch definitions of type 'keyprefix' for a consul agent. +See http://www.consul.io/docs/agent/watches.html for parameter documentation. + + +REQUIRED PARAMETERS +------------------- +handler:: + the handler to invoke when the data view updates +prefix:: + the prefix of keys to watch for changes + + +OPTIONAL PARAMETERS +------------------- +datacenter:: + can be provided to override the agent's default datacenter +state:: + if this watch is 'present' or 'absent'. Defaults to 'present'. +token:: + can be provided to override the agent's default ACL token + + +EXAMPLES +-------- + +-------------------------------------------------------------------------------- +__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.text b/cdist/conf/type/__consul_watch_nodes/man.text new file mode 100644 index 00000000..70b83e92 --- /dev/null +++ b/cdist/conf/type/__consul_watch_nodes/man.text @@ -0,0 +1,52 @@ +cdist-type__consul_watch_nodes(7) +================================= +Steven Armstrong + + +NAME +---- +cdist-type__consul_watch_nodes - manages consul nodes watches + + +DESCRIPTION +----------- +Generate and deploy watch definitions of type 'nodes' for a consul agent. +See http://www.consul.io/docs/agent/watches.html for parameter documentation. + + +REQUIRED PARAMETERS +------------------- +handler:: + the handler to invoke when the data view updates + + +OPTIONAL PARAMETERS +------------------- +datacenter:: + can be provided to override the agent's default datacenter +state:: + if this watch is 'present' or 'absent'. Defaults to 'present'. +token:: + can be provided to override the agent's default ACL token + + +EXAMPLES +-------- + +-------------------------------------------------------------------------------- +__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.text b/cdist/conf/type/__consul_watch_service/man.text new file mode 100644 index 00000000..c7731a97 --- /dev/null +++ b/cdist/conf/type/__consul_watch_service/man.text @@ -0,0 +1,74 @@ +cdist-type__consul_watch_service(7) +=================================== +Steven Armstrong + + +NAME +---- +cdist-type__consul_watch_service - manages consul service watches + + +DESCRIPTION +----------- +Generate and deploy watch definitions of type 'service' for a consul agent. +See http://www.consul.io/docs/agent/watches.html for parameter documentation. + + +REQUIRED PARAMETERS +------------------- +handler:: + the handler to invoke when the data view updates +service:: + the service to watch for changes + + +OPTIONAL PARAMETERS +------------------- +datacenter:: + can be provided to override the agent's default datacenter +state:: + if this watch is 'present' or 'absent'. Defaults to 'present'. +token:: + can be provided to override the agent's default ACL token +tag:: + filter by tag + + +BOOLEAN PARAMETERS +------------------ +passingonly:: + specifies if only hosts passing all checks are displayed + + +EXAMPLES +-------- + +-------------------------------------------------------------------------------- +__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.text b/cdist/conf/type/__consul_watch_services/man.text new file mode 100644 index 00000000..bc489493 --- /dev/null +++ b/cdist/conf/type/__consul_watch_services/man.text @@ -0,0 +1,52 @@ +cdist-type__consul_watch_services(7) +==================================== +Steven Armstrong + + +NAME +---- +cdist-type__consul_watch_services - manages consul services watches + + +DESCRIPTION +----------- +Generate and deploy watch definitions of type 'services' for a consul agent. +See http://www.consul.io/docs/agent/watches.html for parameter documentation. + + +REQUIRED PARAMETERS +------------------- +handler:: + the handler to invoke when the data view updates + + +OPTIONAL PARAMETERS +------------------- +datacenter:: + can be provided to override the agent's default datacenter +state:: + if this watch is 'present' or 'absent'. Defaults to 'present'. +token:: + can be provided to override the agent's default ACL token + + +EXAMPLES +-------- + +-------------------------------------------------------------------------------- +__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/docs/changelog b/docs/changelog index 9017f526..a9b64ca1 100644 --- a/docs/changelog +++ b/docs/changelog @@ -7,6 +7,20 @@ Changelog next: * New type __staged_file: Manage staged files * New type __config_file: Manage configuration files and run code on change + * New type __consul: install consul + * New type __consul_agent: manage the consul agent + * New type __consul_check: manages consul checks + * New type __consul_reload: reload consul + * New type __consul_service: manages consul services + * New type __consul_template: manage the consul-template service + * New type __consul_template_template: manage consul-template templates + * New type __consul_watch_checks: manages consul checks watches + * New type __consul_watch_event: manages consul event watches + * New type __consul_watch_key: manages consul key watches + * New type __consul_watch_keyprefix: manages consul keyprefix watches + * New type __consul_watch_nodes: manages consul nodes watches + * New type __consul_watch_service: manages consul service watches + * New type __consul_watch_services: manages consul services watches 3.1.11: * Type __start_on_boot: Support Ubuntu upstart From 66ad27521246b057bbccf112060b3ac6178a4282 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 24 Feb 2015 14:50:39 +0100 Subject: [PATCH 30/53] make Nico just another committer - no special role Signed-off-by: Nico Schottelius --- docs/changelog | 447 ++++++++++++++++++++++++------------------------- 1 file changed, 221 insertions(+), 226 deletions(-) diff --git a/docs/changelog b/docs/changelog index a9b64ca1..ce78ff74 100644 --- a/docs/changelog +++ b/docs/changelog @@ -1,37 +1,32 @@ Changelog --------- - * Changes are always commented with their author in (braces) - * Exception: No braces means author == Nico Schottelius - next: - * New type __staged_file: Manage staged files - * New type __config_file: Manage configuration files and run code on change - * New type __consul: install consul - * New type __consul_agent: manage the consul agent - * New type __consul_check: manages consul checks - * New type __consul_reload: reload consul - * New type __consul_service: manages consul services - * New type __consul_template: manage the consul-template service - * New type __consul_template_template: manage consul-template templates - * New type __consul_watch_checks: manages consul checks watches - * New type __consul_watch_event: manages consul event watches - * New type __consul_watch_key: manages consul key watches - * New type __consul_watch_keyprefix: manages consul keyprefix watches - * New type __consul_watch_nodes: manages consul nodes watches - * New type __consul_watch_service: manages consul service watches - * New type __consul_watch_services: manages consul services watches - -3.1.11: - * Type __start_on_boot: Support Ubuntu upstart - * New Type: __rsync + * New type __staged_file: Manage staged files (Steven Armstrong) + * New type __config_file: Manage configuration files and run code on change (Steven Armstrong) + * New type __consul: install consul (Steven Armstrong) + * New type __consul_agent: manage the consul agent (Steven Armstrong) + * New type __consul_check: manages consul checks (Steven Armstrong) + * New type __consul_reload: reload consul (Steven Armstrong) + * New type __consul_service: manages consul services (Steven Armstrong) + * New type __consul_template: manage the consul-template service (Steven Armstrong) + * New type __consul_template_template: manage consul-template templates (Steven Armstrong) + * New type __consul_watch_checks: manages consul checks watches (Steven Armstrong) + * New type __consul_watch_event: manages consul event watches (Steven Armstrong) + * New type __consul_watch_key: manages consul key watches (Steven Armstrong) + * New type __consul_watch_keyprefix: manages consul keyprefix watches (Steven Armstrong) + * New type __consul_watch_nodes: manages consul nodes watches (Steven Armstrong) + * New type __consul_watch_service: manages consul service watches (Steven Armstrong) + * New type __consul_watch_services: manages consul services watches (Steven Armstrong) + * New Type: __rsync (Nico Schottelius) + * Type __start_on_boot: Support Ubuntu upstart (Nico Schottelius) 3.1.10: 2015-02-10 * Core: Fix too many open files bug (#343) * Type __ssh_authorized_keys: Remove unneeded explorer (Steven Armstrong) * Type __ssh_authorized_keys: Fix empty output bug of entry explorer (Steven Armstrong) - * Type __package_apt: Add support for --target-release - * Type __locale: Add support for Ubuntu + * Type __package_apt: Add support for --target-release (Nico Schottelius) + * Type __locale: Add support for Ubuntu (Nico Schottelius) * Type __group: Rewrite (Steven Armstrong) * Documentation: Fix typo in maintainer file (Stephan Kulla) @@ -54,15 +49,15 @@ next: * New Type: __package_pkgng_freebsd (Jake Guffey) 3.1.6: 2014-08-18 - * New Type: __ssh_dot_ssh - * Type __package_yum: Support retrieving package via URL - * Type __hostname: Support SuSE and have CentOS use sysconfig value - * Type __locale: Support SuSE - * Type __locale: Support Archlinux - * Type __timezone: Support SuSE + * New Type: __ssh_dot_ssh (Nico Schottelius) + * Type __package_yum: Support retrieving package via URL (Nico Schottelius) + * Type __hostname: Support SuSE and have CentOS use sysconfig value (Nico Schottelius) + * Type __locale: Support SuSE (Nico Schottelius) + * Type __locale: Support Archlinux (Nico Schottelius) + * Type __timezone: Support SuSE (Nico Schottelius) * Type __file: Support MacOS X (Manuel Hutter) - * Type __iptables_apply: Add "reset" to init.d script of iptables - * Type __ssh_authorized_key: Use new type __ssh_dot_ssh + * Type __iptables_apply: Add "reset" to init.d script of iptables (Nico Schottelius) + * Type __ssh_authorized_key: Use new type __ssh_dot_ssh (Nico Schottelius) * Type __zypper_repo: Bugfix for pattern matching (Daniel Heule) 3.1.5: 2014-05-05 @@ -77,13 +72,13 @@ next: 3.1.3: 2014-04-29 * New Type: __yum_repo (Steven Armstrong) - * Type __hostname: Add support for CentOS + * Type __hostname: Add support for CentOS (Nico Schottelius) 3.1.2: 2014-04-12 - * Documentation: Add missing environment variables to reference - * Type __qemu_img: size is optional, if state is not present + * Documentation: Add missing environment variables to reference (Nico Schottelius) + * Type __qemu_img: size is optional, if state is not present (Nico Schottelius) * Type __key_value: Rewrite using awk (Daniel Heule) - * New Type: __dog_vdi + * New Type: __dog_vdi (Nico Schottelius) 3.1.1: 2014-03-26 * Core: Make __object and __object_id available to code (Daniel Heule) @@ -97,11 +92,11 @@ next: * Type __package_pkg_openbsd: Improve error handling (og) 3.1.0: 2014-03-19 - * New Type: __rbenv + * New Type: __rbenv (Nico Schottelius) * Type __file: Enhance OpenBSD Support (og) - * Type __git: Pass onwer/group/mode values to __directory + * Type __git: Pass onwer/group/mode values to __directory (Nico Schottelius) * Type __iptable_rule: Fix example documentation (Antoine Catton) - * Type __key_value: Add messaging support + * Type __key_value: Add messaging support (Nico Schottelius) * Type __package_pkg_openbsd: Allow to change PKG_PATH (og) * Type __ssh_authorized_keys: Allow managing existing keys (Steven Armstrong) * Type __user: Enhance OpenBSD Support (og) @@ -109,7 +104,7 @@ next: 3.0.9: 2014-02-14 * Core: Ignore order dependencies if override is set (Daniel Heule) * Core: Improve Mac OS X support for unit tests (Steven Armstrong) - * Type __locale: Error out in case of unsupported OS + * Type __locale: Error out in case of unsupported OS (Nico Schottelius) * Type __jail: Use default parameters for state (Daniel Heule) * Type __pf_ruleset: Use default parameters for state (Daniel Heule) * Type __postgres_database: Use default parameters for state (Daniel Heule) @@ -133,7 +128,7 @@ next: * New Type: __apt_key_uri (Steven Armstrong) * New Type: __apt_norecommends (Steven Armstrong) * New Type: __apt_source (Steven Armstrong) - * New Type: __ccollect_source + * New Type: __ccollect_source (Nico Schottelius) * Type __git: Use default parameters (Daniel Heule) * Type __jail: Use default parameters (Daniel Heule) * Type __package_yum: Use default parameters (Daniel Heule) @@ -143,24 +138,24 @@ next: 3.0.5: 2014-02-05 * Core: Introduce override concept (Daniel Heule) * Type __process: Make --state absent work (Steven Armstrong) - * Documentation: Update documentation for environment variables + * Documentation: Update documentation for environment variables (Nico Schottelius) 3.0.4: 2014-01-29 - * Core: Ignore install types in config mode - * Documentation: Update reference (files path in object space) - * Documentation: Update best practise: Replaces templates/ with files/ + * Core: Ignore install types in config mode (Nico Schottelius) + * Documentation: Update reference (files path in object space) (Nico Schottelius) + * Documentation: Update best practise: Replaces templates/ with files/ (Nico Schottelius) * Type __apt_ppa: Install required software (Steven Armstrong) - * Type __debconf_set_selections: Support --file - to read from stdin + * Type __debconf_set_selections: Support --file - to read from stdin (Nico Schottelius) * Type __jail: Fix jaildir parameter handling (Jake Guffey) 3.0.3: 2014-01-22 - * Core: Enhance error message when requirement is missing object id + * Core: Enhance error message when requirement is missing object id (Nico Schottelius) * Core: Add environment variable to select shell for executing scripts (Daniel Heule) - * Explorer hostname: Return host name by using uname -n + * Explorer hostname: Return host name by using uname -n (Nico Schottelius) * New Type: __hostname (Steven Armstrong) * Type __cdist: Use default paremeters (Daniel Heule) * Type __key_value: Use default paremeters (Daniel Heule) - * Type __line: Use printf instead of echo for printing user input + * Type __line: Use printf instead of echo for printing user input (Nico Schottelius) * Type __qemu_img: Use default paremeters (Daniel Heule) * Type __zypper_repo: Use default paremeters (Daniel Heule) * Type __zypper_service: Use default paremeters (Daniel Heule) @@ -174,16 +169,16 @@ next: 3.0.1: 2014-01-14 * Core: Copy only files, not directories (Steven Armstrong) - * Core: Allow hostnames to start with / - * Type __line: Remove unecessary backslash escape + * Core: Allow hostnames to start with / (Nico Schottelius) + * Type __line: Remove unecessary backslash escape (Nico Schottelius) * Type __directory: Add messaging support (Daniel Heule) * Type __directory: Do not generate code if mode is 0xxx (Daniel Heule) * Type __package: Fix typo in optional parameter ptype (Daniel Heule) * Type __start_on_boot: Fix for SuSE's chkconfig (Daniel Heule) 3.0.0: 2013-12-24 - * Core: Added messaging support - * Core: Removed unused "changed" attribute of objects + * Core: Added messaging support (Nico Schottelius) + * Core: Removed unused "changed" attribute of objects (Nico Schottelius) * Core: Support default values for multiple parameters (Steven Armstrong) * Core: Ensure Object Parameter file contains \n (Steven Armstrong) * New Type: __zypper_repo (Daniel Heule) @@ -193,8 +188,8 @@ next: * Type __cron: Add support for raw lines (Daniel Heule) * Type __cron: Suppress stderr output from crontab (Daniel Heule) * Type __cron: Fix quoting issue (Daniel Heule) - * Type __file: Do not generate code if mode is 0xxx - * Type __iptables_rule: Use default parameter + * Type __file: Do not generate code if mode is 0xxx (Nico Schottelius) + * Type __iptables_rule: Use default parameter (Nico Schottelius) * Type __key_value: Fix quoting issue (Steven Armstrong) * Type __package: Use state --present by default (Steven Armstrong) * Type __package_zypper: Support non packages as well (Daniel Heule) @@ -202,7 +197,7 @@ next: * Type __postfix_*: Depend on __postfix Type (Steven Armstrong) * Type __postfix_postconf: Enable support for SuSE (Daniel Heule) * Type __postfix: Enable support for SuSE (Daniel Heule) - * Type __start_on_boot: Use default parameter state + * Type __start_on_boot: Use default parameter state (Nico Schottelius) * Type __start_on_boot: Add support for gentoo (Daniel Heule) * Type __user: Add support for state parameter (Daniel Heule) * Type __user: Add support for system users (Daniel Heule) @@ -214,19 +209,19 @@ next: * Type __file: Only remove file when state is absent (Steven Armstrong) * Type __link: Only remove link when state is absent (Steven Armstrong) * Type __directory: Only remove directory when state is absent (Steven Armstrong) - * Type __directory: Fix newly introduced quoting issue + * Type __directory: Fix newly introduced quoting issue (Nico Schottelius) * Type __package_zypper: Fix explorer and parameter issue (Daniel Heule) - * Core: Fix backtrace when cache cannot be deleted + * Core: Fix backtrace when cache cannot be deleted (Nico Schottelius) 2.3.6: 2013-11-25 - * New Type: __locale - * Type __line: Ensure special characters are not interpreted + * New Type: __locale (Nico Schottelius) + * Type __line: Ensure special characters are not interpreted (Nico Schottelius) 2.3.5: 2013-10-10 * Core: Unit test fix for remote_copy (Steven Armstrong) * Documentation: Updated manpages of __package and __file (Alex Greif) * Documentation: Add more examples to cdist-manifest (Dan Levin) - * Type __package_apt: Do not install recommends by default + * Type __package_apt: Do not install recommends by default (Nico Schottelius) 2.3.4: 2013-10-03 * Core: Add missing bits to support dry run (Steven Armstrong) @@ -244,51 +239,51 @@ next: * Type __start_on_boot: Bugfix for systemd (Steven Armstrong) 2.3.2: 2013-09-05 - * Build: Ensure tests don't change attributes of non-test files - * Core: Fix typo in argument parser + * Build: Ensure tests don't change attributes of non-test files (Nico Schottelius) + * Core: Fix typo in argument parser (Nico Schottelius) * Core: Code cleanup: Remove old install code (Steven Armstrong) - * Core: Improve error message when using non-existing type in requirement - * New Type: __iptables_rule - * New Type: __iptables_apply - * Type __cdist: Also create home directory - * Type __cdist: Add support for --shell parameter - * Type __motd: Regenerate motd on Debian and Ubuntu + * Core: Improve error message when using non-existing type in requirement (Nico Schottelius) + * New Type: __iptables_rule (Nico Schottelius) + * New Type: __iptables_apply (Nico Schottelius) + * Type __cdist: Also create home directory (Nico Schottelius) + * Type __cdist: Add support for --shell parameter (Nico Schottelius) + * Type __motd: Regenerate motd on Debian and Ubuntu (Nico Schottelius) 2.3.1: 2013-08-28 - * Core: Support relative paths for configuration directories - * Core: Code cleanup (removed context class, added log class) - * Documentation: Add more best practises - * Documentation: Add troubleshooting chapter + * Core: Support relative paths for configuration directories (Nico Schottelius) + * Core: Code cleanup (removed context class, added log class) (Nico Schottelius) + * Documentation: Add more best practises (Nico Schottelius) + * Documentation: Add troubleshooting chapter (Nico Schottelius) * Type __key_value: Fix quoting problem (Steven Armstrong) 2.3.0: 2013-08-12 - * Core: Added support for cdist shell - * Documentation: Improved some manpages + * Core: Added support for cdist shell (Nico Schottelius) + * Documentation: Improved some manpages (Nico Schottelius) 2.2.0: 2013-07-12 - * Build: Cleanup the Makefile - * Type __package_opkg: Use shortcut version + * Build: Cleanup the Makefile (Nico Schottelius) + * Type __package_opkg: Use shortcut version (Nico Schottelius) * Core: Remove old pseudo object id "singleton" (Steven Armstrong) 2.1.2: 2013-07-09 - * Build: Change clean-dist target to "distclean" + * Build: Change clean-dist target to "distclean" (Nico Schottelius) * Build: Moved a lot of build logic into Makefile for dependency resolution * Core: Make global explorers available to initial manifest (Arkaitz Jimenez) - * Core: Change execution order to run object as one unit + * Core: Change execution order to run object as one unit (Nico Schottelius) * Documentation: Improved documentation (Tomáš Pospíšek) * New Remote Example: Add support for sudo operations (Chase James) - * New Type: __update_alternatives - * New Type: __cdist + * New Type: __update_alternatives (Nico Schottelius) + * New Type: __cdist (Nico Schottelius) * Type __apt_ppa: Fix comparison operator (Tyler Akins) - * Type __start_on_boot: Archlinux changed to use systemd - adapt type + * Type __start_on_boot: Archlinux changed to use systemd - adapt type (Nico Schottelius) * Type __git: Missing quotes added (Chase James) * Type __postgres_database: Make state parameter optional (Chase James) * Type __postgres_role: Make state parameter optional, fix password bug (Chase James) - * Type __process: Make state parameter optional - * Type __cron: Simplyfied and syntax change + * Type __process: Make state parameter optional (Nico Schottelius) + * Type __cron: Simplyfied and syntax change (Nico Schottelius) 2.1.1: 2013-04-08 - * Core: Use dynamic dependency resolver to allow indirect self dependencies + * Core: Use dynamic dependency resolver to allow indirect self dependencies (Nico Schottelius) * Core: Remove umask call - protect /var/lib/cdist only (Arkaitz Jimenez) * Explorer os: Added Slackware support (Eivind Uggedal) * Type __git: Support mode and fix owner/group settings (contradict) @@ -298,90 +293,90 @@ next: * Type __user: Add support for creating user home (Arkaitz Jimenez) 2.1.0: 2012-12-09 - * Core: Ensure global explorers are executable + * Core: Ensure global explorers are executable (Nico Schottelius) * Core: Ensure type explorers are executable (Steven Armstrong) - * New Type: __git + * New Type: __git (Nico Schottelius) * New Type: __ssh_authorized_keys (Steven Armstrong) * New Type: __user_groups (Steven Armstrong) - * Type __rvm_gemset: Change parameter "default" to be boolean + * Type __rvm_gemset: Change parameter "default" to be boolean (Nico Schottelius) * Type __user: Remove --groups support (now provided by __user_groups) * Type __apt_ppa: Bugfix: Installeded ppa detection (Steven Armstrong) * Type __jail: Change optional parameter "started" to boolean "stopped" parameter, change optional parameter "devfs-enable" to boolean "devfs-disable" parameter and - change optional parameter "onboot" to boolean. - * Type __package_pip: Bugfix: Installeded the package, not pyro - * Remove Type __ssh_authorized_key: Superseeded by __ssh_authorized_keys + change optional parameter "onboot" to boolean. (Nico Schottelius) + * Type __package_pip: Bugfix: Installeded the package, not pyro (Nico Schottelius) + * Remove Type __ssh_authorized_key: Superseeded by __ssh_authorized_keys (Nico Schottelius) * Support for CDIST_PATH (Steven Armstrong) 2.1.0pre8: 2012-11-15 * Type cleanup: __apt_ppa, __apt_ppa_update_index, __file, __ssh_authorized_key, __timezone, all install types (Steven Armstrong) - * Types: Remove all parameter changing code - * Type __rvm_ruby: Change parameter "default" to be boolean - * Documentation: Web documentation clean up + * Types: Remove all parameter changing code (Nico Schottelius) + * Type __rvm_ruby: Change parameter "default" to be boolean (Nico Schottelius) + * Documentation: Web documentation clean up (Nico Schottelius) 2.1.0pre7: 2012-11-07 - * Core: All unit tests restored back to working - * Core: Print error message when missing the initial manifest + * Core: All unit tests restored back to working (Nico Schottelius) + * Core: Print error message when missing the initial manifest (Nico Schottelius) 2.1.0pre6: 2012-11-05 - * New Example: Turn remote calls into local calls (used for unittesting) - * Core: Export PYTHONPATH, it's also needed by emulator - * Bugfix Type __rvm_ruby: Add clean package dependencies - * Bugfix Type __rvm_gem: Run rvm as user, not as root - * Cleanup Type __rvm, __rvm_gemset: Use shortcut version - * Bugfix __rvm_gemset: Correctly check for gemsets + * New Example: Turn remote calls into local calls (used for unittesting) (Nico Schottelius) + * Core: Export PYTHONPATH, it's also needed by emulator (Nico Schottelius) + * Bugfix Type __rvm_ruby: Add clean package dependencies (Nico Schottelius) + * Bugfix Type __rvm_gem: Run rvm as user, not as root (Nico Schottelius) + * Cleanup Type __rvm, __rvm_gemset: Use shortcut version (Nico Schottelius) + * Bugfix __rvm_gemset: Correctly check for gemsets (Nico Schottelius) * Cleanup Type __postgres_database, __postgres_role: Reference each other - in documentation - * Cleanp Type __postgres_role: Use boolean parameters where appropriate - * Cleanp Type __postgres_role: Use shortcut version + in documentation (Nico Schottelius) + * Cleanp Type __postgres_role: Use boolean parameters where appropriate (Nico Schottelius) + * Cleanp Type __postgres_role: Use shortcut version (Nico Schottelius) 2.1.0pre5: 2012-11-01 - * Core: First round of tests updated to work with multiple configuration directories + * Core: First round of tests updated to work with multiple configuration directories (Nico Schottelius) 2.1.0pre4: 2012-10-31 - * Dist: PyPi: Moved cdist.py to script/cdist to avoid double import - * Core: Added support for multiple configuration directories (no documentation) + * Dist: PyPi: Moved cdist.py to script/cdist to avoid double import (Nico Schottelius) + * Core: Added support for multiple configuration directories (no documentation) (Nico Schottelius) 2.1.0pre3: 2012-10-30 - * Dist: PyPi: Types and explorer included as package data + * Dist: PyPi: Types and explorer included as package data (Nico Schottelius) 2.1.0pre2: 2012-10-26 - * Dist: PyPi: Add conf/ directory to distribution - * Dist: Initial support for archlinux packaging + * Dist: PyPi: Add conf/ directory to distribution (Nico Schottelius) + * Dist: Initial support for archlinux packaging (Nico Schottelius) 2.1.0pre1: 2012-10-26 - * Core: Removed obsolete variable __self - * Removed type __addifnosuchline (replaced by __line) - * Removed type __removeline (replaced by __line) - * Type __directory: Parameter --parents and --recursive are now boolean + * Core: Removed obsolete variable __self (Nico Schottelius) + * Removed type __addifnosuchline (replaced by __line) (Nico Schottelius) + * Removed type __removeline (replaced by __line) (Nico Schottelius) + * Type __directory: Parameter --parents and --recursive are now boolean (Nico Schottelius) * Type __package_apt, __package_luarocks, __package_opkg, __package_pacman, __package_pkg_freebsd, __package_pkg_openbsd, __package_rubygem, __package_yum, __process: - Parameter state accepts only "present" and "absent" - * Dist: Initial support for pypi packaging + Parameter state accepts only "present" and "absent" (Nico Schottelius) + * Dist: Initial support for pypi packaging (Nico Schottelius) 2.0.15: 2012-11-02 * Core: Make variable __object_name available in type explorers (Steven Armtrong) - * New Type: __qemu_img - * New Type: __line + * New Type: __qemu_img (Nico Schottelius) + * New Type: __line (Nico Schottelius) * New Type: __pf_apply (Jake Guffey) * New Type: __pf_ruleset (Jake Guffey) - * Bugfix Type: __rvm: Make type work if rvm is already installed + * Bugfix Type: __rvm: Make type work if rvm is already installed (Nico Schottelius) 2.0.14: 2012-09-07 * Bugfix Type: __jail: Use correct variable (Jake Guffey) * Change Type: __jail: Parameter jailbase now optional (Jake Guffey) * Bugfix Type: __user: Use passwd database on FreeBSD (Jake Guffey) - * Bugfix Type: __start_on_boot: Do not change parameters + * Bugfix Type: __start_on_boot: Do not change parameters (Nico Schottelius) * Feature __user: Added support for BSDs (Sébastien Gross) * Feature __group: Added support for FreeBSD (Jake Guffey) - * New Type: __package_zypper - * Feature Types: Initial Support for SuSE Linux + * New Type: __package_zypper (Nico Schottelius) + * Feature Types: Initial Support for SuSE Linux (Nico Schottelius) 2.0.13: 2012-06-05 * Bugfix __ssh_authorized_key: Ensure it sets proper group (contradict) - * Bugfix __addifnosuchline: Fixed quotes/interpolation bug ("a b" became "a b") + * Bugfix __addifnosuchline: Fixed quotes/interpolation bug ("a b" became "a b") (Nico Schottelius) * New Explorer: interfaces (Sébastien Gross) * Feature core: Support reading from stdin in types (Steven Armstrong) * Feature core: Support multiple parameters for types (Steven Armstrong) @@ -389,24 +384,24 @@ next: 2.0.12: 2012-05-29 * Core: Correctly raise error on Python < 3.2 (Steven Armtrong) - * Core: Add support for --remote-exec and --remote-copy parameters + * Core: Add support for --remote-exec and --remote-copy parameters (Nico Schottelius) * Documentation: Debian Squeeze hints (Sébastien Gross) 2.0.11: 2012-05-23 - * Fix insecure file/directory creation: Use umask 077 + * Fix insecure file/directory creation: Use umask 077 (Nico Schottelius) 2.0.10: 2012-05-18 * Cleanup __group: No getent gshadow in old Redhat, use groupmod -g (Matt Coddington) - * Bugfix __package_yum: Missing cat + * Bugfix __package_yum: Missing cat (Nico Schottelius) * Bugfix __start_on_boot: Correctly use sed and quotes (Steven Armstrong) * Feature __file: Support for --state exists (Steven Armstrong) - * Feature core: Make variable __manifest available to type manifests + * Feature core: Make variable __manifest available to type manifests (Nico Schottelius) * Feature core: Correct parent dependency handling (Steven Armstrong) * Bugfix several types: Fix sed for FreeBSD (Istvan Beregszaszi) * New Type: __jail (Jake Guffey) * Change Type: __rvm*: --state present/absent not installed/remvoed (Evax Software) - * Bugfix Type: __cron: Hide error output from crontab + * Bugfix Type: __cron: Hide error output from crontab (Nico Schottelius) * Various smaller bugfixes (Chris Lamb) 2.0.9: 2012-03-12 @@ -420,19 +415,19 @@ next: * Feature __start_on_boot: Support for OpenWRT (Giel van Schijndel) * Feature __start_on_boot: Support for Amazon Linux (Matt Coddington) * New Example: Use rsync to backup files (Matt Coddington) - * Feature core: Exit non-zero, if configuration failed + * Feature core: Exit non-zero, if configuration failed (Nico Schottelius) * Documentation: Describe how to do templating (Aurélien Bondis) 2.0.8: 2012-02-20 - * Bugfix core: Remove another nasty traceback when sending SIGINT (aka Ctrl-C) - * Cleanup: Better hint to source of error - * Cleanup: Do not output failing script, but path to script only + * Bugfix core: Remove another nasty traceback when sending SIGINT (aka Ctrl-C) (Nico Schottelius) + * Cleanup: Better hint to source of error (Nico Schottelius) + * Cleanup: Do not output failing script, but path to script only (Nico Schottelius) * Cleanup: Remove support for __debug variable in manifests (Type != Core - debugging) + debugging) (Nico Schottelius) * Cleanup: Change __package_* to support absent/present (default state - name now). The values removed/installed will be removed in cdist 2.1. + name now). The values removed/installed will be removed in cdist 2.1. (Nico Schottelius) * Cleanup: Change __process to support absent/present (default state - name now). The values running/stopped will be removed in cdist 2.1. + name now). The values running/stopped will be removed in cdist 2.1. (Nico Schottelius) * Feature Core: Support boolean parameters (Steven Armstrong) 2.0.7: 2012-02-13 @@ -441,9 +436,9 @@ next: * Bugfix __link: Properly handle existing links (Steven Armstrong) * Bugfix __key_value: More robust implementation (Steven Armstrong) * Bugfix __user: Fix for changing a user's group by name (Matt Coddington) - * New Type: __package_pip + * New Type: __package_pip (Nico Schottelius) * Bugfix/Cleanup: Correctly allow Object ID to start and end with /, but - not contain //. + not contain //. (Nico Schottelius) 2.0.6: 2012-01-28 * Bugfix __apt_ppa: @@ -462,8 +457,8 @@ next: 2.0.5: 2012-01-18 * Bugfix __key_value: Use correct delimiters (Steven Armstrong, Daniel Maher) - * Cleanup: Explicitly require Python >= 3.2 (do not fail implicitly) - * Documentation: (Re)write of the tutorial + * Cleanup: Explicitly require Python >= 3.2 (do not fail implicitly) (Nico Schottelius) + * Documentation: (Re)write of the tutorial (Nico Schottelius) * Feature: __addifnosuchline supports matching on regular expressions (Daniel Maher) * Feature: __directory, __file, __link: @@ -472,11 +467,11 @@ next: * New Type: __cdistmarker (Daniel Maher) 2.0.4: 2011-11-18 - * Bugfix core: Remove traceback when sending SIGINT (aka Ctrl-C) + * Bugfix core: Remove traceback when sending SIGINT (aka Ctrl-C) (Nico Schottelius) * Bugfix core: Accept parameters with - in the name (Steven Armstrong) - * Cleanup: __object_fq variable removed (never used) - * Cleanup: Environment variable __self DEPRECATED, use __object_name instead - * Cleanup: Environment variable __self scheduled for removal in cdist 2.1 + * Cleanup: __object_fq variable removed (never used) (Nico Schottelius) + * Cleanup: Environment variable __self DEPRECATED, use __object_name instead (Nico Schottelius) + * Cleanup: Environment variable __self scheduled for removal in cdist 2.1 (Nico Schottelius) * Documentation: Many examples for use of __remote_* (Steven Armstrong) * Feature: Automatically require all used objects (Steven Armstrong) * New Type: __cron (Steven Armstrong) @@ -484,28 +479,28 @@ next: 2.0.3: 2011-10-18 * Improved logging, added --verbose, by more quiet by default * Bugfix __user: Correct quoting (Steven Armstrong) - * Bugfix __addifnosuchline: Falsely exited - * Bugfix requirements: Restore original require="" behaviour - * Feature requirements: Check for broken object_ids and abort + * Bugfix __addifnosuchline: Falsely exited (Nico Schottelius) + * Bugfix requirements: Restore original require="" behaviour (Nico Schottelius) + * Feature requirements: Check for broken object_ids and abort (Nico Schottelius) * Massive refactoring and unittesting introduced (Steven Armstrong) 2.0.2: 2011-09-27 * Add support for detection of OpenWall Linux (Matthias Teege) - * Add support for __debug variable in manifests - * Bugfix core: Various issues with type emulator + * Add support for __debug variable in manifests (Nico Schottelius) + * Bugfix core: Various issues with type emulator (Nico Schottelius) 2.0.1: 2011-09-23 - * Bugfix core: Always print source of error in case of exec errors - * Bugfix core: Various smaller bugs in string concatenation - * Feature: Add marker "changed" to changed objects + * Bugfix core: Always print source of error in case of exec errors (Nico Schottelius) + * Bugfix core: Various smaller bugs in string concatenation (Nico Schottelius) + * Feature: Add marker "changed" to changed objects (Nico Schottelius) 2.0.0: 2011-09-16 * New Type: __package_rubygem (Chase Allen James) - * __self replaced by __object_fq - * Rewrote cdist in Python + * __self replaced by __object_fq (Nico Schottelius) + * Rewrote cdist in Python (Nico Schottelius) 1.7.1: 2011-07-26 - * Documentation: Add explorers to reference + * Documentation: Add explorers to reference (Nico Schottelius) * Documentation: Typo cleanup (Derek Brost) * Type __key_value: Bugfix (Steven Armstrong) * New Type: __postgres_role (Steven Armstrong) @@ -515,42 +510,42 @@ next: * Bugfix type __package_yum: Fix redhat support (Ramon Salvadó) * Improved type __package_yum: Add centos support (Ramon Salvadó) * New Type: __timezone (Ramon Salvadó) - * Renamed explorer: hardware_type to machine - * Core: Do not execute empty code fragments + * Renamed explorer: hardware_type to machine (Nico Schottelius) + * Core: Do not execute empty code fragments (Nico Schottelius) 1.6.2: 2011-04-19 - * Core: Introduce __cdist_tmp_base_dir - * Core: Cleanup and enhance cdist-type-template - * Core: cdist-mass-deploy: Report failed cdist-deploy-to instances + * Core: Introduce __cdist_tmp_base_dir (Nico Schottelius) + * Core: Cleanup and enhance cdist-type-template (Nico Schottelius) + * Core: cdist-mass-deploy: Report failed cdist-deploy-to instances (Nico Schottelius) * New Type: __ssh_authorized_key (Aurélien Bondis) 1.6.1: 2011-04-07 - * Improved logging: Show code responsible for abort - * Improved logging: Consistently prefix with current object or core - * Bugfix: Type __debconf_set_selections used wrong contens for selection - * Bugfix: Don't fail, if cache directory is not existing - * Bugfix: __user and __group exited non-zero if no change was necessary - * New Explorer: hardware_type + * Improved logging: Show code responsible for abort (Nico Schottelius) + * Improved logging: Consistently prefix with current object or core (Nico Schottelius) + * Bugfix: Type __debconf_set_selections used wrong contens for selection (Nico Schottelius) + * Bugfix: Don't fail, if cache directory is not existing (Nico Schottelius) + * Bugfix: __user and __group exited non-zero if no change was necessary (Nico Schottelius) + * New Explorer: hardware_type (Nico Schottelius) * New Type: __package_pkg_openbsd (Andi Brönnimann) * New Type: __autofs_map (Steven Armstrong) * New Type: __autofs_master (Steven Armstrong) 1.6.0: 2011-04-06 - * New Type: __package_yum - * New type: __debconf_set_selections - * New explorer: os_version - * Bugfix: Type __group failed in case of __group NAME syntax + * New Type: __package_yum (Nico Schottelius) + * New type: __debconf_set_selections (Nico Schottelius) + * New explorer: os_version (Nico Schottelius) + * Bugfix: Type __group failed in case of __group NAME syntax (Nico Schottelius) * Bugfix: __package* types: consistently name --state removed instead of - uninstalled or deinstalled - * Type __package: Added Fedora support - * Type __package_apt: Removed --preseed support - * Explorer os gained Fedora support - * Simplified types __user and __group - * New helper binary: cdist-mass-deploy + uninstalled or deinstalled (Nico Schottelius) + * Type __package: Added Fedora support (Nico Schottelius) + * Type __package_apt: Removed --preseed support (Nico Schottelius) + * Explorer os gained Fedora support (Nico Schottelius) + * Simplified types __user and __group (Nico Schottelius) + * New helper binary: cdist-mass-deploy (Nico Schottelius) 1.5.0: 2011-04-01 - * Add basic cache functionality - * New type: __process + * Add basic cache functionality (Nico Schottelius) + * New type: __process (Nico Schottelius) * Restructured execution: (Steven Armstrong) Orientate processing on objects, resolve dependencies and ensure correct execution order. @@ -560,77 +555,77 @@ next: 1.4.1: 2011-03-25 * New type: __key_value (Steven Armstrong) * New type: __apt_ppa (Steven Armstrong) - * Documentation: Manpage generation cleanup + * Documentation: Manpage generation cleanup (Nico Schottelius) * Documentation: Manpage fix for __apt_ppa 1.4.0: 2011-03-24 - * Add --recursive to __directory - * Move cdist generated stuff to .cdist of an object - * Allow objects to be redefined + * Add --recursive to __directory (Nico Schottelius) + * Move cdist generated stuff to .cdist of an object (Nico Schottelius) + * Allow objects to be redefined (Nico Schottelius) 1.3.2: 2011-03-21 - * Add --source to __motd - * Add --preseed to __package_apt - * Include HTML documentation of manpages and publish them + * Add --source to __motd (Nico Schottelius) + * Add --preseed to __package_apt (Nico Schottelius) + * Include HTML documentation of manpages and publish them (Nico Schottelius) 1.3.1: 2011-03-21 - * Document: cdist-type-build-emulation - * Document: cdist-type-emulator - * Document: cdist-remote-explorer-run - * Fix dependencies in cdist-code-run - * Fix dependencies in cdist-manifest-run-all - * Add --source to __issue and fix os check + * Document: cdist-type-build-emulation (Nico Schottelius) + * Document: cdist-type-emulator (Nico Schottelius) + * Document: cdist-remote-explorer-run (Nico Schottelius) + * Fix dependencies in cdist-code-run (Nico Schottelius) + * Fix dependencies in cdist-manifest-run-all (Nico Schottelius) + * Add --source to __issue and fix os check (Nico Schottelius) 1.3.0: 2011-03-20 - * Add support for local and remote code generation and execution - * Bugfix: Remove obsolete $@ call in cdist-remote-explorer-run - * Bugfix: Correct manpage for __removeline (broke manpage generation) + * Add support for local and remote code generation and execution (Nico Schottelius) + * Bugfix: Remove obsolete $@ call in cdist-remote-explorer-run (Nico Schottelius) + * Bugfix: Correct manpage for __removeline (broke manpage generation) (Nico Schottelius) 1.2.0: 2011-03-19 - * Added dependencies (see cdist-type(7)) + * Added dependencies (see cdist-type(7)) (Nico Schottelius) * New type: __removeline (Daniel Roth) * New type: __group (Steven Armstrong) * New type: __user (Steven Armstrong) - * Documentation: cdist-run-remote - * Documentation: cdist-code-run-all - * Documentation: cdist-object-gencode - * Documentation: cdist-explorer-run-global - * Documentation: cdist-manifest-run-init - * Documentation: cdist-manifest-run-all - * Documentation: cdist-object-gencode-all - * Documentation: cdist-manifest-run + * Documentation: cdist-run-remote (Nico Schottelius) + * Documentation: cdist-code-run-all (Nico Schottelius) + * Documentation: cdist-object-gencode (Nico Schottelius) + * Documentation: cdist-explorer-run-global (Nico Schottelius) + * Documentation: cdist-manifest-run-init (Nico Schottelius) + * Documentation: cdist-manifest-run-all (Nico Schottelius) + * Documentation: cdist-object-gencode-all (Nico Schottelius) + * Documentation: cdist-manifest-run (Nico Schottelius) 1.1.0: 2011-03-16 - * Replace type __file with __file, __directory, __link - * Documentation: cdist-env - * Documentation: cdist-config - * Documentation: cdist-dir - * Documentation: cdist-quickstart + * Replace type __file with __file, __directory, __link (Nico Schottelius) + * Documentation: cdist-env (Nico Schottelius) + * Documentation: cdist-config (Nico Schottelius) + * Documentation: cdist-dir (Nico Schottelius) + * Documentation: cdist-quickstart (Nico Schottelius) 1.0.4: 2011-03-15 - * New type: __motd + * New type: __motd (Nico Schottelius) * New type: __addifnosuchline (Daniel Roth) - * New type: __user - * Document type: __issue - * Document type: __package - * Document type: __package_pacman - * Document type: __package_apt - * New parameter for __file: --owner and --group + * New type: __user (Nico Schottelius) + * Document type: __issue (Nico Schottelius) + * Document type: __package (Nico Schottelius) + * Document type: __package_pacman (Nico Schottelius) + * Document type: __package_apt (Nico Schottelius) + * New parameter for __file: --owner and --group (Nico Schottelius) 1.0.3: 2011-03-11 - * Update regexp used for sane characters - * Allow types without parameters - * Allow type to be singleton - * Type __file learned --type symlink + * Update regexp used for sane characters (Nico Schottelius) + * Allow types without parameters (Nico Schottelius) + * Allow type to be singleton (Nico Schottelius) + * Type __file learned --type symlink (Nico Schottelius) 1.0.2: 2011-03-09 - * Add manpages: cdist-type, cdist-type__file, cdist-reference, cdist-explorer - * Make doc/man/ usable as MANPATH entry + * Add manpages: cdist-type, cdist-type__file, cdist-reference, cdist-explorer (Nico Schottelius) + * Make doc/man/ usable as MANPATH entry (Nico Schottelius) 1.0.1: 2011-03-08 - * Added cdist-type-template including manpage - * Fix manpage building - * Add new manpages: cdist-stages, cdist-bin-transfer + * Added cdist-type-template including manpage (Nico Schottelius) + * Fix manpage building (Nico Schottelius) + * Add new manpages: cdist-stages, cdist-bin-transfer (Nico Schottelius) 1.0.0: 2011-03-07 - * Initial release + * Initial release (Nico Schottelius) From 40a582ca45770d43db61389ad5f9fd999096cd48 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 24 Feb 2015 20:43:31 +0100 Subject: [PATCH 31/53] remove config_dir from the consul configuration file - fixes #385 Signed-off-by: Nico Schottelius --- cdist/conf/type/__consul_agent/manifest | 1 - 1 file changed, 1 deletion(-) diff --git a/cdist/conf/type/__consul_agent/manifest b/cdist/conf/type/__consul_agent/manifest index f9514755..c4e947bc 100755 --- a/cdist/conf/type/__consul_agent/manifest +++ b/cdist/conf/type/__consul_agent/manifest @@ -82,7 +82,6 @@ echo "{" # parameters we define ourself printf ' "data_dir": "%s"\n' "$data_dir" -printf ' ,"config_dir": "%s"\n' "$conf_dir" for param in $(ls "$__object/parameter/"); do case "$param" in From 44d57497e08fe125586785f941962a6d7613d58c Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Tue, 24 Feb 2015 23:05:25 +0100 Subject: [PATCH 32/53] first attempt to make this type actually work Signed-off-by: Steven Armstrong --- .../type/__consul/files/versions/0.4.1/cksum | 1 + .../versions/0.4.1/source} | 0 .../type/__consul/files/versions/0.5.0/cksum | 1 + .../type/__consul/files/versions/0.5.0/source | 1 + cdist/conf/type/__consul/man.text | 34 ++++++--------- cdist/conf/type/__consul/manifest | 43 +++++++------------ .../type/__consul/parameter/default/version | 1 + cdist/conf/type/__consul/parameter/optional | 2 +- 8 files changed, 33 insertions(+), 50 deletions(-) create mode 100644 cdist/conf/type/__consul/files/versions/0.4.1/cksum rename cdist/conf/type/__consul/{parameter/default/install-from => files/versions/0.4.1/source} (100%) create mode 100644 cdist/conf/type/__consul/files/versions/0.5.0/cksum create mode 100644 cdist/conf/type/__consul/files/versions/0.5.0/source create mode 100644 cdist/conf/type/__consul/parameter/default/version 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/parameter/default/install-from b/cdist/conf/type/__consul/files/versions/0.4.1/source similarity index 100% rename from cdist/conf/type/__consul/parameter/default/install-from rename to cdist/conf/type/__consul/files/versions/0.4.1/source 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/man.text b/cdist/conf/type/__consul/man.text index f91dcf5c..25d8565f 100644 --- a/cdist/conf/type/__consul/man.text +++ b/cdist/conf/type/__consul/man.text @@ -10,34 +10,28 @@ cdist-type__consul - install consul DESCRIPTION ----------- -Quick and dirty installation of the consul binary. -Note that the consul binary is downloaded on the server and then deployed using -the __file type. +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. -Future ideas: -- get latest version info from https://checkpoint-api.hashicorp.com/v1/check/consul - - then download from - https://dl.bintray.com/mitchellh/consul/${current_version}_${os}_${arch}.zip -- install from given path to binary -- download from given url -- install from packet +REQUIRED PARAMETERS +------------------- +None. OPTIONAL PARAMETERS ------------------- -install-from:: - uri from where to download consul. This can be anything that curl understands. - If install-uri ends with .zip the downloaded file will be unziped and the - contained file deployed as the consul binary. If install-uri does not end in .zip - it is assumed to be the consul binary and will be deployed as is. - install-to:: where to install the binary. Defaults to /usr/local/bin/consul 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 -------- @@ -46,13 +40,9 @@ EXAMPLES # just install using defaults __consul -# download on the machine running cdist, then unzip, then upload to the target host +# specific version __consul \ - --install-from https://dl.bintray.com/mitchellh/consul/0.4.1_linux_amd64.zip - -# take binary from local folder on the machine running cdist -__consul \ - --install-from file:///cluster/adm/software/consul/bin/consul + --version 0.4.1 # install the consul binary to a specific location __consul \ diff --git a/cdist/conf/type/__consul/manifest b/cdist/conf/type/__consul/manifest index 321a3e4c..d32009c4 100755 --- a/cdist/conf/type/__consul/manifest +++ b/cdist/conf/type/__consul/manifest @@ -33,33 +33,22 @@ case "$os" in ;; esac +versions_dir="$__type/files/versions" +version="$(cat "$__object/parameter/version")" +version_dir="$versions_dir/$version" -state="$(cat "$__object/parameter/state")" -install_from="$(cat "$__object/parameter/install-from")" -install_to="$(cat "$__object/parameter/install-to")" - -if [ "$state" = "absent" ]; then - __file "$install_to" \ - --state absent - exit 0 +if [ ! -d "$version_dir" ]; then + echo "Unknown consul version '$version'. Expected one of:" >&2 + ls "$versions_dir" >&2 + exit 1 fi -case "$install_from" in - /*|file://*) - source="${install_from#*file://}" - ;; - *.zip) - mkdir "$__object/files" - source="$__object/files/consul" - # FIXME: need some persistent place to cache downloaded files - curl -s "$install_from" | unzip -p > "$source" - ;; - *) - echo "Do not know how to install from: $install_from" >&2 - exit 1 - ;; -esac - -__file "$install_to" \ - --owner root --group root --mode 755 \ - --source "$source" +__staged_file "$(cat "$__object/parameter/install-to")" \ + --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/version b/cdist/conf/type/__consul/parameter/default/version new file mode 100644 index 00000000..8f0916f7 --- /dev/null +++ b/cdist/conf/type/__consul/parameter/default/version @@ -0,0 +1 @@ +0.5.0 diff --git a/cdist/conf/type/__consul/parameter/optional b/cdist/conf/type/__consul/parameter/optional index 480f1bcd..ca68058b 100644 --- a/cdist/conf/type/__consul/parameter/optional +++ b/cdist/conf/type/__consul/parameter/optional @@ -1,3 +1,3 @@ -install-from install-to state +version From 3c720640dd38e660fd7975cb3e8e471387efd3b1 Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Tue, 24 Feb 2015 23:59:06 +0100 Subject: [PATCH 33/53] start working on supporting different versions of consul-template Signed-off-by: Steven Armstrong --- .../files/versions/0.6.5/cksum | 1 + .../files/versions/0.6.5/source | 1 + cdist/conf/type/__consul_template/man.text | 19 ++++++- cdist/conf/type/__consul_template/manifest | 51 ++++++++++++++----- .../parameter/default/install-to | 1 + .../__consul_template/parameter/default/state | 1 + .../parameter/default/version | 1 + .../type/__consul_template/parameter/optional | 3 ++ cdist/conf/type/__consul_template/todo | 3 ++ 9 files changed, 65 insertions(+), 16 deletions(-) create mode 100644 cdist/conf/type/__consul_template/files/versions/0.6.5/cksum create mode 100644 cdist/conf/type/__consul_template/files/versions/0.6.5/source create mode 100644 cdist/conf/type/__consul_template/parameter/default/install-to create mode 100644 cdist/conf/type/__consul_template/parameter/default/state create mode 100644 cdist/conf/type/__consul_template/parameter/default/version create mode 100644 cdist/conf/type/__consul_template/todo diff --git a/cdist/conf/type/__consul_template/files/versions/0.6.5/cksum b/cdist/conf/type/__consul_template/files/versions/0.6.5/cksum new file mode 100644 index 00000000..2dcac994 --- /dev/null +++ b/cdist/conf/type/__consul_template/files/versions/0.6.5/cksum @@ -0,0 +1 @@ +1356006333 8496656 consul-template diff --git a/cdist/conf/type/__consul_template/files/versions/0.6.5/source b/cdist/conf/type/__consul_template/files/versions/0.6.5/source new file mode 100644 index 00000000..09a1ce3a --- /dev/null +++ b/cdist/conf/type/__consul_template/files/versions/0.6.5/source @@ -0,0 +1 @@ +https://github.com/hashicorp/consul-template/releases/download/v0.6.5/consul-template_0.6.5_linux_amd64.tar.gz diff --git a/cdist/conf/type/__consul_template/man.text b/cdist/conf/type/__consul_template/man.text index 26afd4f1..66d04457 100644 --- a/cdist/conf/type/__consul_template/man.text +++ b/cdist/conf/type/__consul_template/man.text @@ -10,8 +10,11 @@ cdist-type__consul_template - manage the consul-template service DESCRIPTION ----------- -Installs consul-template, generates a global config file and creates directory -for per template config files. +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 @@ -28,14 +31,21 @@ batch-size:: consul:: the location of the Consul instance to query (may be an IP address or FQDN) with port. Defaults to 'localhost:8500'. +install-to:: + where to install the binary. Defaults to /usr/local/bin/consul-template 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' token:: the Consul API token. +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 @@ -57,6 +67,11 @@ EXAMPLES __consul_template \ --consul consul.service.consul:8500 \ --retry 30s + +# specific version +__consul_template \ + --version 0.6.5 \ + --retry 30s -------------------------------------------------------------------------------- diff --git a/cdist/conf/type/__consul_template/manifest b/cdist/conf/type/__consul_template/manifest index dba7e68e..aeee35bf 100755 --- a/cdist/conf/type/__consul_template/manifest +++ b/cdist/conf/type/__consul_template/manifest @@ -24,7 +24,10 @@ 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 @@ -33,7 +36,30 @@ case "$os" in ;; esac -state="present" +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")" +install_to="$(cat "$__object/parameter/install-to")" + +__staged_file "$install_to" \ + --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" @@ -48,17 +74,6 @@ require="__directory/etc/consul-template" \ --owner root --group root --mode 750 -__staged_file /usr/local/bin/consul-template \ - --source https://github.com/hashicorp/consul-template/releases/download/v0.6.5/consul-template_0.6.5_linux_amd64.tar.gz \ - --cksum '1356006333 8496656 consul-template' \ - --fetch-command 'curl -s -L "%s"' \ - --prepare-command 'tar -xzf "%s"; cat consul-template_*/consul-template' \ - --state present \ - --group root \ - --owner root \ - --mode 755 - - # Generate hcl config file ( for param in $(ls "$__object/parameter/"); do @@ -82,7 +97,7 @@ 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' \ + --onchange "$service_onchange" \ --source - @@ -118,4 +133,12 @@ case "$os" in 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/parameter/default/install-to b/cdist/conf/type/__consul_template/parameter/default/install-to new file mode 100644 index 00000000..8bd33a0a --- /dev/null +++ b/cdist/conf/type/__consul_template/parameter/default/install-to @@ -0,0 +1 @@ +/usr/local/bin/consul-template 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/version b/cdist/conf/type/__consul_template/parameter/default/version new file mode 100644 index 00000000..ef5e4454 --- /dev/null +++ b/cdist/conf/type/__consul_template/parameter/default/version @@ -0,0 +1 @@ +0.6.5 diff --git a/cdist/conf/type/__consul_template/parameter/optional b/cdist/conf/type/__consul_template/parameter/optional index 34c277b9..73c39582 100644 --- a/cdist/conf/type/__consul_template/parameter/optional +++ b/cdist/conf/type/__consul_template/parameter/optional @@ -1,7 +1,10 @@ auth batch-size consul +install-to max-stale retry +state token +version wait diff --git a/cdist/conf/type/__consul_template/todo b/cdist/conf/type/__consul_template/todo new file mode 100644 index 00000000..c09e09ac --- /dev/null +++ b/cdist/conf/type/__consul_template/todo @@ -0,0 +1,3 @@ +- add support for --install-to in init-system files/templates +- add support for latest version 0.7.0 + - config file format has changed From 2bcaaa744fb0ce493ccfeef340194ca50170a719 Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Wed, 25 Feb 2015 00:16:10 +0100 Subject: [PATCH 34/53] remove support for custom install location; to much dependencies in other types Signed-off-by: Steven Armstrong --- cdist/conf/type/__consul/man.text | 7 ------- cdist/conf/type/__consul/parameter/default/install-to | 1 - cdist/conf/type/__consul/parameter/optional | 1 - 3 files changed, 9 deletions(-) delete mode 100644 cdist/conf/type/__consul/parameter/default/install-to diff --git a/cdist/conf/type/__consul/man.text b/cdist/conf/type/__consul/man.text index 25d8565f..5ebaf1e8 100644 --- a/cdist/conf/type/__consul/man.text +++ b/cdist/conf/type/__consul/man.text @@ -22,9 +22,6 @@ None. OPTIONAL PARAMETERS ------------------- -install-to:: - where to install the binary. Defaults to /usr/local/bin/consul - state:: either 'present' or 'absent'. Defaults to 'present' @@ -43,10 +40,6 @@ __consul # specific version __consul \ --version 0.4.1 - -# install the consul binary to a specific location -__consul \ - --install-to /somewhere/special/consul -------------------------------------------------------------------------------- diff --git a/cdist/conf/type/__consul/parameter/default/install-to b/cdist/conf/type/__consul/parameter/default/install-to deleted file mode 100644 index f85c9e67..00000000 --- a/cdist/conf/type/__consul/parameter/default/install-to +++ /dev/null @@ -1 +0,0 @@ -/usr/local/bin/consul diff --git a/cdist/conf/type/__consul/parameter/optional b/cdist/conf/type/__consul/parameter/optional index ca68058b..4d595ed7 100644 --- a/cdist/conf/type/__consul/parameter/optional +++ b/cdist/conf/type/__consul/parameter/optional @@ -1,3 +1,2 @@ -install-to state version From b1ef2cffa47fdd6ea839f623babe0f303f039d34 Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Wed, 25 Feb 2015 00:19:10 +0100 Subject: [PATCH 35/53] hardcode path to binary Signed-off-by: Steven Armstrong --- cdist/conf/type/__consul/manifest | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cdist/conf/type/__consul/manifest b/cdist/conf/type/__consul/manifest index d32009c4..1cbc5413 100755 --- a/cdist/conf/type/__consul/manifest +++ b/cdist/conf/type/__consul/manifest @@ -43,7 +43,7 @@ if [ ! -d "$version_dir" ]; then exit 1 fi -__staged_file "$(cat "$__object/parameter/install-to")" \ +__staged_file /usr/local/bin/consul \ --source "$(cat "$version_dir/source")" \ --cksum "$(cat "$version_dir/cksum")" \ --fetch-command 'curl -s -L "%s"' \ From 79b16563ed11b96faba7689273f43215cacaa3ca Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Wed, 25 Feb 2015 00:22:38 +0100 Subject: [PATCH 36/53] remove support for custom install location Signed-off-by: Steven Armstrong --- cdist/conf/type/__consul_template/man.text | 2 -- cdist/conf/type/__consul_template/manifest | 3 +-- cdist/conf/type/__consul_template/parameter/default/install-to | 1 - cdist/conf/type/__consul_template/parameter/optional | 1 - cdist/conf/type/__consul_template/todo | 1 - 5 files changed, 1 insertion(+), 7 deletions(-) delete mode 100644 cdist/conf/type/__consul_template/parameter/default/install-to diff --git a/cdist/conf/type/__consul_template/man.text b/cdist/conf/type/__consul_template/man.text index 66d04457..9db958eb 100644 --- a/cdist/conf/type/__consul_template/man.text +++ b/cdist/conf/type/__consul_template/man.text @@ -31,8 +31,6 @@ batch-size:: consul:: the location of the Consul instance to query (may be an IP address or FQDN) with port. Defaults to 'localhost:8500'. -install-to:: - where to install the binary. Defaults to /usr/local/bin/consul-template max-stale:: the maximum staleness of a query. If specified, Consul will distribute work among all servers instead of just the leader. diff --git a/cdist/conf/type/__consul_template/manifest b/cdist/conf/type/__consul_template/manifest index aeee35bf..edeca89c 100755 --- a/cdist/conf/type/__consul_template/manifest +++ b/cdist/conf/type/__consul_template/manifest @@ -47,9 +47,8 @@ if [ ! -d "$version_dir" ]; then fi state="$(cat "$__object/parameter/state")" -install_to="$(cat "$__object/parameter/install-to")" -__staged_file "$install_to" \ +__staged_file /usr/local/bin/consul-template \ --source "$(cat "$version_dir/source")" \ --cksum "$(cat "$version_dir/cksum")" \ --fetch-command 'curl -s -L "%s"' \ diff --git a/cdist/conf/type/__consul_template/parameter/default/install-to b/cdist/conf/type/__consul_template/parameter/default/install-to deleted file mode 100644 index 8bd33a0a..00000000 --- a/cdist/conf/type/__consul_template/parameter/default/install-to +++ /dev/null @@ -1 +0,0 @@ -/usr/local/bin/consul-template diff --git a/cdist/conf/type/__consul_template/parameter/optional b/cdist/conf/type/__consul_template/parameter/optional index 73c39582..2848edb9 100644 --- a/cdist/conf/type/__consul_template/parameter/optional +++ b/cdist/conf/type/__consul_template/parameter/optional @@ -1,7 +1,6 @@ auth batch-size consul -install-to max-stale retry state diff --git a/cdist/conf/type/__consul_template/todo b/cdist/conf/type/__consul_template/todo index c09e09ac..a3786501 100644 --- a/cdist/conf/type/__consul_template/todo +++ b/cdist/conf/type/__consul_template/todo @@ -1,3 +1,2 @@ -- add support for --install-to in init-system files/templates - add support for latest version 0.7.0 - config file format has changed From 583aa41bf99ccfc563785237b301abf7b07ef2d3 Mon Sep 17 00:00:00 2001 From: Christian Kruse Date: Fri, 27 Feb 2015 02:08:06 +0100 Subject: [PATCH 37/53] support FreeBSD in __timezone type --- cdist/conf/type/__timezone/manifest | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/cdist/conf/type/__timezone/manifest b/cdist/conf/type/__timezone/manifest index 36caab72..2f600f88 100755 --- a/cdist/conf/type/__timezone/manifest +++ b/cdist/conf/type/__timezone/manifest @@ -24,6 +24,7 @@ timezone="$__object_id" os=$(cat "$__global/explorer/os") +package="" case "$os" in archlinux|debian|ubuntu) @@ -32,13 +33,21 @@ case "$os" in suse) package=timezone ;; + freebsd) + ;; *) echo "Unsupported OS $os" >&2 exit 1 ;; esac -__package "$package" --state present -require="__package/$package" __link /etc/localtime \ +if [ ! -z "$package" ]; then + __package "$package" --state present + require="__package/$package" __link /etc/localtime \ + --source "/usr/share/zoneinfo/${timezone}" \ + --type symbolic +fi + +__link /etc/localtime \ --source "/usr/share/zoneinfo/${timezone}" \ --type symbolic From 587a87e9769bc6ba314c89eba808f44dc7a85b33 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 27 Feb 2015 14:42:49 +0100 Subject: [PATCH 38/53] +changes Signed-off-by: Nico Schottelius --- docs/changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog b/docs/changelog index ce78ff74..e1de0954 100644 --- a/docs/changelog +++ b/docs/changelog @@ -20,6 +20,7 @@ next: * New type __consul_watch_services: manages consul services watches (Steven Armstrong) * New Type: __rsync (Nico Schottelius) * Type __start_on_boot: Support Ubuntu upstart (Nico Schottelius) + * Type __timezone: Added support for FreeBSD (Christian Kruse) 3.1.10: 2015-02-10 * Core: Fix too many open files bug (#343) From 47c17118f6ba8eab3245996d5c6b3f9e88d36d04 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Fri, 27 Feb 2015 14:46:21 +0100 Subject: [PATCH 39/53] Update changelog for 3.1.11 Signed-off-by: Nico Schottelius --- docs/changelog | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/docs/changelog b/docs/changelog index e1de0954..74f400a4 100644 --- a/docs/changelog +++ b/docs/changelog @@ -1,23 +1,23 @@ Changelog --------- -next: - * New type __staged_file: Manage staged files (Steven Armstrong) - * New type __config_file: Manage configuration files and run code on change (Steven Armstrong) - * New type __consul: install consul (Steven Armstrong) - * New type __consul_agent: manage the consul agent (Steven Armstrong) - * New type __consul_check: manages consul checks (Steven Armstrong) - * New type __consul_reload: reload consul (Steven Armstrong) - * New type __consul_service: manages consul services (Steven Armstrong) - * New type __consul_template: manage the consul-template service (Steven Armstrong) - * New type __consul_template_template: manage consul-template templates (Steven Armstrong) - * New type __consul_watch_checks: manages consul checks watches (Steven Armstrong) - * New type __consul_watch_event: manages consul event watches (Steven Armstrong) - * New type __consul_watch_key: manages consul key watches (Steven Armstrong) - * New type __consul_watch_keyprefix: manages consul keyprefix watches (Steven Armstrong) - * New type __consul_watch_nodes: manages consul nodes watches (Steven Armstrong) - * New type __consul_watch_service: manages consul service watches (Steven Armstrong) - * New type __consul_watch_services: manages consul services watches (Steven Armstrong) +3.1.11: 2015-02-27 + * New type: __staged_file: Manage staged files (Steven Armstrong) + * New type: __config_file: Manage configuration files and run code on change (Steven Armstrong) + * New type: __consul: install consul (Steven Armstrong) + * New type: __consul_agent: manage the consul agent (Steven Armstrong) + * New type: __consul_check: manages consul checks (Steven Armstrong) + * New type: __consul_reload: reload consul (Steven Armstrong) + * New type: __consul_service: manages consul services (Steven Armstrong) + * New type: __consul_template: manage the consul-template service (Steven Armstrong) + * New type: __consul_template_template: manage consul-template templates (Steven Armstrong) + * New type: __consul_watch_checks: manages consul checks watches (Steven Armstrong) + * New type: __consul_watch_event: manages consul event watches (Steven Armstrong) + * New type: __consul_watch_key: manages consul key watches (Steven Armstrong) + * New type: __consul_watch_keyprefix: manages consul keyprefix watches (Steven Armstrong) + * New type: __consul_watch_nodes: manages consul nodes watches (Steven Armstrong) + * New type: __consul_watch_service: manages consul service watches (Steven Armstrong) + * New type: __consul_watch_services: manages consul services watches (Steven Armstrong) * New Type: __rsync (Nico Schottelius) * Type __start_on_boot: Support Ubuntu upstart (Nico Schottelius) * Type __timezone: Added support for FreeBSD (Christian Kruse) From 0fe6b60efc88d7b7d615be3deef661878af04aa0 Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Fri, 21 Feb 2014 14:41:06 +0100 Subject: [PATCH 40/53] support for centos Signed-off-by: Steven Armstrong --- cdist/conf/type/__timezone/manifest | 35 ++++++++++++++++------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/cdist/conf/type/__timezone/manifest b/cdist/conf/type/__timezone/manifest index 2f600f88..443cc2c4 100755 --- a/cdist/conf/type/__timezone/manifest +++ b/cdist/conf/type/__timezone/manifest @@ -1,7 +1,7 @@ #!/bin/sh # # 2011 Ramon Salvadó (rsalvado at gnuine dot com) -# 2012 Steven Armstrong (steven-cdist at armstrong.cc) +# 2012-2015 Steven Armstrong (steven-cdist at armstrong.cc) # 2012 Nico Schottelius (nico-cdist at schottelius.org) # # This file is part of cdist. @@ -24,30 +24,35 @@ timezone="$__object_id" os=$(cat "$__global/explorer/os") -package="" - + case "$os" in archlinux|debian|ubuntu) - package=tzdata + __package tzdata + export require="__package/tzdata" ;; suse) - package=timezone + __package timezone + export require="__package/timezone" ;; freebsd) + # whitelist + : + ;; + centos) + __package tzdata --state present + export require="__package/tzdata" + __key_value ZONE \ + --file /etc/sysconfig/clock \ + --delimiter '=' \ + --value "\"$timezone\"" ;; *) - echo "Unsupported OS $os" >&2 + 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 -if [ ! -z "$package" ]; then - __package "$package" --state present - require="__package/$package" __link /etc/localtime \ - --source "/usr/share/zoneinfo/${timezone}" \ - --type symbolic -fi - -__link /etc/localtime \ - --source "/usr/share/zoneinfo/${timezone}" \ +__link /etc/localtime \ + --source "/usr/share/zoneinfo/${timezone}" \ --type symbolic From 40610310353f666b011302fb406309e122fee7ca Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Tue, 4 Mar 2014 14:10:43 +0100 Subject: [PATCH 41/53] add centos support to __postfix* types Signed-off-by: Steven Armstrong --- cdist/conf/type/__postfix/manifest | 4 ++-- cdist/conf/type/__postfix_master/manifest | 4 ++-- cdist/conf/type/__postfix_postconf/explorer/value | 4 ++-- cdist/conf/type/__postfix_postconf/gencode-remote | 4 ++-- cdist/conf/type/__postfix_postconf/manifest | 2 +- cdist/conf/type/__postfix_postmap/manifest | 2 +- cdist/conf/type/__postfix_reload/gencode-remote | 4 ++-- cdist/conf/type/__postfix_reload/manifest | 2 +- 8 files changed, 13 insertions(+), 13 deletions(-) diff --git a/cdist/conf/type/__postfix/manifest b/cdist/conf/type/__postfix/manifest index 52a13919..5a184910 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) __package postfix --state present ;; *) diff --git a/cdist/conf/type/__postfix_master/manifest b/cdist/conf/type/__postfix_master/manifest index 87e2329b..7777892b 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) : ;; *) diff --git a/cdist/conf/type/__postfix_postconf/explorer/value b/cdist/conf/type/__postfix_postconf/explorer/value index e08c6da6..3f319eda 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) : ;; *) diff --git a/cdist/conf/type/__postfix_postconf/gencode-remote b/cdist/conf/type/__postfix_postconf/gencode-remote index 43c0482e..4b4096a5 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) : ;; *) 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/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..8311568a 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) echo "postfix reload" ;; *) 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. # From 72104184b54982d4d4344b75a6cea9e74ea53b25 Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Wed, 19 Mar 2014 22:21:07 +0100 Subject: [PATCH 42/53] ensure file exists Signed-off-by: Steven Armstrong --- cdist/conf/type/__timezone/manifest | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/cdist/conf/type/__timezone/manifest b/cdist/conf/type/__timezone/manifest index 443cc2c4..6f34f71b 100755 --- a/cdist/conf/type/__timezone/manifest +++ b/cdist/conf/type/__timezone/manifest @@ -41,10 +41,14 @@ case "$os" in centos) __package tzdata --state present export require="__package/tzdata" - __key_value ZONE \ - --file /etc/sysconfig/clock \ - --delimiter '=' \ - --value "\"$timezone\"" + __file /etc/sysconfig/clock \ + --owner root --group root --mode 644 \ + --state exists + require="__file/etc/sysconfig/clock" \ + ___key_value ZONE \ + --file /etc/sysconfig/clock \ + --delimiter '=' \ + --value "\"$timezone\"" ;; *) echo "Your operating system ($os) is currently not supported by this type (${__type##*/})." >&2 From 64e22bdb11b736b03c79ab1c9b97ef7d518a3e04 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 1 Mar 2015 18:49:40 +0100 Subject: [PATCH 43/53] add new cdist type: __firewalld_rule Signed-off-by: Nico Schottelius --- .../conf/type/__firewalld_rule/explorer/rule | 31 ++++++++ .../conf/type/__firewalld_rule/gencode-remote | 45 +++++++++++ cdist/conf/type/__firewalld_rule/man.text | 78 +++++++++++++++++++ .../__firewalld_rule/parameter/default/state | 1 + .../type/__firewalld_rule/parameter/optional | 1 + .../type/__firewalld_rule/parameter/required | 5 ++ docs/changelog | 3 + 7 files changed, 164 insertions(+) create mode 100644 cdist/conf/type/__firewalld_rule/explorer/rule create mode 100644 cdist/conf/type/__firewalld_rule/gencode-remote create mode 100644 cdist/conf/type/__firewalld_rule/man.text create mode 100644 cdist/conf/type/__firewalld_rule/parameter/default/state create mode 100644 cdist/conf/type/__firewalld_rule/parameter/optional create mode 100644 cdist/conf/type/__firewalld_rule/parameter/required diff --git a/cdist/conf/type/__firewalld_rule/explorer/rule b/cdist/conf/type/__firewalld_rule/explorer/rule new file mode 100644 index 00000000..e9e1ebeb --- /dev/null +++ b/cdist/conf/type/__firewalld_rule/explorer/rule @@ -0,0 +1,31 @@ +# +# 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..a70dae13 --- /dev/null +++ b/cdist/conf/type/__firewalld_rule/gencode-remote @@ -0,0 +1,45 @@ +# +# 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 --permanent --direct --add-rule \"$protocol\" \"$table\" \"$chain\" \"$priority\" $rule + ;; + + present) + echo firewall-cmd --permanent --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.text b/cdist/conf/type/__firewalld_rule/man.text new file mode 100644 index 00000000..17296a25 --- /dev/null +++ b/cdist/conf/type/__firewalld_rule/man.text @@ -0,0 +1,78 @@ +cdist-type__firewalld_rule(7) +============================= +Nico Schottelius + + +NAME +---- +cdist-type__firewalld_rule - Configure firewalld rules + + +DESCRIPTION +----------- +This cdist type allows you to manage rules in firewalld +using the *direct* way (i.e. no zone support). + + +REQUIRED PARAMETERS +------------------- +rule:: + The rule to apply. Essentially an firewalld command + line without firewalld in front of it. +protocol:: + Either ipv4, ipv4 or eb. See firewall-cmd(1) +table:: + The table to use (like filter or nat). See firewall-cmd(1). +chain:: + The chain to use (like INPUT_direct or FORWARD_direct). See firewall-cmd(1). +priority:: + The priority to use (0 is topmost). See firewall-cmd(1). + + +OPTIONAL PARAMETERS +------------------- +state:: + 'present' or 'absent', defaults to 'present' + + +EXAMPLES +-------- + +-------------------------------------------------------------------------------- +# 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/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/docs/changelog b/docs/changelog index 74f400a4..f55a01ac 100644 --- a/docs/changelog +++ b/docs/changelog @@ -1,6 +1,9 @@ Changelog --------- +next: + * New type: __firewalld_rule (Nico Schottelius) + 3.1.11: 2015-02-27 * New type: __staged_file: Manage staged files (Steven Armstrong) * New type: __config_file: Manage configuration files and run code on change (Steven Armstrong) From e7308a1a619f3a32eb746952610a59be26cbeed6 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 1 Mar 2015 20:57:16 +0100 Subject: [PATCH 44/53] use absent instead of present twice Signed-off-by: Nico Schottelius --- cdist/conf/type/__firewalld_rule/gencode-remote | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cdist/conf/type/__firewalld_rule/gencode-remote b/cdist/conf/type/__firewalld_rule/gencode-remote index a70dae13..16291dd7 100644 --- a/cdist/conf/type/__firewalld_rule/gencode-remote +++ b/cdist/conf/type/__firewalld_rule/gencode-remote @@ -35,7 +35,7 @@ case "$state_should" in echo firewall-cmd --permanent --direct --add-rule \"$protocol\" \"$table\" \"$chain\" \"$priority\" $rule ;; - present) + absent) echo firewall-cmd --permanent --direct --remove-rule \"$protocol\" \"$table\" \"$chain\" \"$priority\" $rule ;; *) From 70a5e012d83ce2a6bd7d097974c6b01fa954dfc5 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 1 Mar 2015 21:04:25 +0100 Subject: [PATCH 45/53] need to issue rules twice (permanent & current) Signed-off-by: Nico Schottelius --- cdist/conf/type/__firewalld_rule/gencode-remote | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cdist/conf/type/__firewalld_rule/gencode-remote b/cdist/conf/type/__firewalld_rule/gencode-remote index 16291dd7..b0540bfd 100644 --- a/cdist/conf/type/__firewalld_rule/gencode-remote +++ b/cdist/conf/type/__firewalld_rule/gencode-remote @@ -33,10 +33,12 @@ rule="$(cat "$__object/parameter/rule")" case "$state_should" in present) echo firewall-cmd --permanent --direct --add-rule \"$protocol\" \"$table\" \"$chain\" \"$priority\" $rule + echo firewall-cmd --direct --add-rule \"$protocol\" \"$table\" \"$chain\" \"$priority\" $rule ;; absent) echo firewall-cmd --permanent --direct --remove-rule \"$protocol\" \"$table\" \"$chain\" \"$priority\" $rule + echo firewall-cmd --direct --remove-rule \"$protocol\" \"$table\" \"$chain\" \"$priority\" $rule ;; *) echo "Unknown state $state_should" >&2 From 9af4fcabff0b454ab6c1bfe5ca516175ba3b3504 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 1 Mar 2015 21:21:57 +0100 Subject: [PATCH 46/53] make firewalld more quiet Signed-off-by: Nico Schottelius --- cdist/conf/type/__firewalld_rule/gencode-remote | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cdist/conf/type/__firewalld_rule/gencode-remote b/cdist/conf/type/__firewalld_rule/gencode-remote index b0540bfd..e184f5b3 100644 --- a/cdist/conf/type/__firewalld_rule/gencode-remote +++ b/cdist/conf/type/__firewalld_rule/gencode-remote @@ -32,13 +32,13 @@ rule="$(cat "$__object/parameter/rule")" case "$state_should" in present) - echo firewall-cmd --permanent --direct --add-rule \"$protocol\" \"$table\" \"$chain\" \"$priority\" $rule - echo firewall-cmd --direct --add-rule \"$protocol\" \"$table\" \"$chain\" \"$priority\" $rule + 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 --permanent --direct --remove-rule \"$protocol\" \"$table\" \"$chain\" \"$priority\" $rule - echo firewall-cmd --direct --remove-rule \"$protocol\" \"$table\" \"$chain\" \"$priority\" $rule + 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 From 29cb89340e3d234f5d3306d160b315dce4b74f19 Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Thu, 5 Mar 2015 15:59:24 +0100 Subject: [PATCH 47/53] bugfix: /___key_value/__key_value/ Signed-off-by: Steven Armstrong --- cdist/conf/type/__timezone/manifest | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cdist/conf/type/__timezone/manifest b/cdist/conf/type/__timezone/manifest index 6f34f71b..3bcb05c6 100755 --- a/cdist/conf/type/__timezone/manifest +++ b/cdist/conf/type/__timezone/manifest @@ -45,7 +45,7 @@ case "$os" in --owner root --group root --mode 644 \ --state exists require="__file/etc/sysconfig/clock" \ - ___key_value ZONE \ + __key_value ZONE \ --file /etc/sysconfig/clock \ --delimiter '=' \ --value "\"$timezone\"" From 8820c1ca2b0d6643ad79f1d4dc71614583d3dcfe Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Thu, 5 Mar 2015 16:39:14 +0100 Subject: [PATCH 48/53] add support for acl options Signed-off-by: Steven Armstrong --- cdist/conf/type/__consul_agent/man.text | 18 ++++++++++++++++++ .../type/__consul_agent/parameter/optional | 6 ++++++ 2 files changed, 24 insertions(+) diff --git a/cdist/conf/type/__consul_agent/man.text b/cdist/conf/type/__consul_agent/man.text index 63337185..3491eb4c 100644 --- a/cdist/conf/type/__consul_agent/man.text +++ b/cdist/conf/type/__consul_agent/man.text @@ -20,6 +20,23 @@ 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:: @@ -126,6 +143,7 @@ __consul_agent \ SEE ALSO -------- - cdist-type(7) +- http://www.consul.io/docs/agent/options.html COPYING diff --git a/cdist/conf/type/__consul_agent/parameter/optional b/cdist/conf/type/__consul_agent/parameter/optional index bceaf060..8940023d 100644 --- a/cdist/conf/type/__consul_agent/parameter/optional +++ b/cdist/conf/type/__consul_agent/parameter/optional @@ -1,3 +1,9 @@ +acl-datacenter +acl-default-policy +acl-down-policy +acl-master-token +acl-token +acl-ttl bind-addr bootstrap-expect ca-file-source From 2fcfa42a26081622fc09edb940f44c642acb1364 Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Thu, 5 Mar 2015 16:40:36 +0100 Subject: [PATCH 49/53] changelog++ Signed-off-by: Steven Armstrong --- docs/changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog b/docs/changelog index f55a01ac..a7b45592 100644 --- a/docs/changelog +++ b/docs/changelog @@ -3,6 +3,7 @@ Changelog next: * New type: __firewalld_rule (Nico Schottelius) + * Type __consul_agent: add support for acl options (Steven Armstrong) 3.1.11: 2015-02-27 * New type: __staged_file: Manage staged files (Steven Armstrong) From 3be1e9a88c1199cf88d21ba42194e592cbb423ae Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 5 Mar 2015 19:45:41 +0100 Subject: [PATCH 50/53] ++changes Signed-off-by: Nico Schottelius --- docs/changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog b/docs/changelog index a7b45592..31a23505 100644 --- a/docs/changelog +++ b/docs/changelog @@ -4,6 +4,7 @@ Changelog next: * New type: __firewalld_rule (Nico Schottelius) * Type __consul_agent: add support for acl options (Steven Armstrong) + * Core: Support object ids '.cdist' (Nico Schottelius) 3.1.11: 2015-02-27 * New type: __staged_file: Manage staged files (Steven Armstrong) From 5239943bed5165d7d5504b77ae31825c28595d13 Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Fri, 6 Mar 2015 14:25:53 +0100 Subject: [PATCH 51/53] confirmed to work on ubuntu Signed-off-by: Steven Armstrong --- cdist/conf/type/__consul_agent/manifest | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cdist/conf/type/__consul_agent/manifest b/cdist/conf/type/__consul_agent/manifest index c4e947bc..1489c19d 100755 --- a/cdist/conf/type/__consul_agent/manifest +++ b/cdist/conf/type/__consul_agent/manifest @@ -22,7 +22,7 @@ os=$(cat "$__global/explorer/os") case "$os" in - centos|redhat) + centos|redhat|ubuntu) # whitelist safeguard : ;; From 55660621394a1b4c4e727dfed6eb320256d35e2e Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 16 Mar 2015 19:00:47 +0100 Subject: [PATCH 52/53] add debian support to __consul_agent Signed-off-by: Nico Schottelius --- .../__consul_agent/files/consul.sysv-debian | 76 +++++++++++++++++++ .../files/{consul.sysv => consul.sysv-redhat} | 0 cdist/conf/type/__consul_agent/manifest | 72 +++++++++++++----- 3 files changed, 130 insertions(+), 18 deletions(-) create mode 100644 cdist/conf/type/__consul_agent/files/consul.sysv-debian rename cdist/conf/type/__consul_agent/files/{consul.sysv => consul.sysv-redhat} (100%) 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..f4498041 --- /dev/null +++ b/cdist/conf/type/__consul_agent/files/consul.sysv-debian @@ -0,0 +1,76 @@ +#!/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 . +# + +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 + +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 b/cdist/conf/type/__consul_agent/files/consul.sysv-redhat similarity index 100% rename from cdist/conf/type/__consul_agent/files/consul.sysv rename to cdist/conf/type/__consul_agent/files/consul.sysv-redhat diff --git a/cdist/conf/type/__consul_agent/manifest b/cdist/conf/type/__consul_agent/manifest index 1489c19d..198b83d6 100755 --- a/cdist/conf/type/__consul_agent/manifest +++ b/cdist/conf/type/__consul_agent/manifest @@ -1,6 +1,7 @@ #!/bin/sh # # 2015 Steven Armstrong (steven-cdist at armstrong.cc) +# 2015 Nico Schottelius (nico-cdist at schottelius.org) # # This file is part of cdist. # @@ -22,7 +23,7 @@ os=$(cat "$__global/explorer/os") case "$os" in - centos|redhat|ubuntu) + centos|debian|redhat|ubuntu) # whitelist safeguard : ;; @@ -139,6 +140,32 @@ require="__directory${conf_dir}" \ --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.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 @@ -146,29 +173,38 @@ case "$os" in os_version="$(sed 's/[^0-9.]//g' "$__global/explorer/os_version")" major_version="${os_version%%.*}" case "$major_version" in + [456]) + init_sysvinit redhat + ;; 7) - __file /lib/systemd/system/consul.service \ - --owner root --group root --mode 0555 \ - --state "$state" \ - --source "$__type/files/consul.systemd" - export require="__file/lib/systemd/system/consul.service" + init_systemd ;; *) - __file /etc/init.d/consul \ - --owner root --group root --mode 0555 \ - --state "$state" \ - --source "$__type/files/consul.sysv" - export require="__file/etc/init.d/consul" + echo "Unsupported CentOS/Redhat version: $os_version" >&2 + exit 1 ;; esac - __start_on_boot consul --state "$state" ;; + + debian) + os_version=$(cat "$__global/explorer/os_version") + major_version="${os_version%%.*}" + + case "$major_version" in + [567]) + init_sysvinit debian + ;; + 8) + init_sysvinit + ;; + *) + echo "Unsupported Debian version $os_version" >&2 + exit 1 + ;; + esac + ;; + ubuntu) - __file /etc/init/consul.conf \ - --owner root --group root --mode 0644 \ - --state "$state" \ - --source "$__type/files/consul.upstart" - export require="__file/etc/init/consul.conf" - __start_on_boot consul --state "$state" + init_upstart ;; esac From 4f2d5290855c57864d5af721b9acc8623c61cef7 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 19 Mar 2015 18:21:06 +0900 Subject: [PATCH 53/53] add changes for 3.1.12 Signed-off-by: Nico Schottelius --- docs/changelog | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/docs/changelog b/docs/changelog index 31a23505..f71f8906 100644 --- a/docs/changelog +++ b/docs/changelog @@ -1,10 +1,19 @@ Changelog --------- -next: +3.1.12: 2015-03-19 + * Core: Support object ids '.cdist' (Nico Schottelius) * New type: __firewalld_rule (Nico Schottelius) * Type __consul_agent: add support for acl options (Steven Armstrong) - * Core: Support object ids '.cdist' (Nico Schottelius) + * Type __consul_agent: add support for Debian (Nico Schottelius) + * Type __package_apt: Use default parameters (Antoine Catton) + * Type __package_luarocks: Use default parameters (Antoine Catton) + * Type __package_opkg: Use default parameters (Antoine Catton) + * Type __package_pacman: Use default parameters (Antoine Catton) + * Type __package_pip: Use default parameters (Antoine Catton) + * Type __package_pkg_freebsd: Use default parameters (Antoine Catton) + * Type __package_pkg_openbsd: Use default parameters (Antoine Catton) + * Type __package_pkgng_openbsd: Use default parameters (Antoine Catton) 3.1.11: 2015-02-27 * New type: __staged_file: Manage staged files (Steven Armstrong)