From 1e582dceece14690034d609f8610269c6cfa37dc Mon Sep 17 00:00:00 2001 From: Daniel Heule Date: Wed, 23 Jul 2014 09:22:03 +0200 Subject: [PATCH 01/70] bugfix of raw_command with raw_command, you can set env variables in crontab, but cron don't accept env vars if the definition is like this: SHELL=/bin/bash # marker of something ... so we need to make sure that raw commands are not apended by a marker --- cdist/conf/type/__cron/explorer/entry | 7 ++++++- cdist/conf/type/__cron/gencode-remote | 14 +++++++++----- 2 files changed, 15 insertions(+), 6 deletions(-) mode change 100755 => 100644 cdist/conf/type/__cron/gencode-remote diff --git a/cdist/conf/type/__cron/explorer/entry b/cdist/conf/type/__cron/explorer/entry index c3bf02d2..2167e045 100644 --- a/cdist/conf/type/__cron/explorer/entry +++ b/cdist/conf/type/__cron/explorer/entry @@ -22,4 +22,9 @@ name="$__object_name" user="$(cat "$__object/parameter/user")" -crontab -u $user -l 2>/dev/null | grep "# $name\$" || true +if [ -f "$__object/parameter/raw_command" ]; then + command="$(cat "$__object/parameter/command")" + crontab -u $user -l 2>/dev/null | grep "^$command\$" || true +else + crontab -u $user -l 2>/dev/null | grep "# $name\$" || true +fi diff --git a/cdist/conf/type/__cron/gencode-remote b/cdist/conf/type/__cron/gencode-remote old mode 100755 new mode 100644 index 77a63b9b..f5c1cc62 --- a/cdist/conf/type/__cron/gencode-remote +++ b/cdist/conf/type/__cron/gencode-remote @@ -26,7 +26,7 @@ command="$(cat "$__object/parameter/command")" if [ -f "$__object/parameter/raw" ]; then raw="$(cat "$__object/parameter/raw")" - entry="$raw $command" + entry="$raw $command # $name" elif [ -f "$__object/parameter/raw_command" ]; then entry="$command" else @@ -35,10 +35,9 @@ else day_of_month="$(cat "$__object/parameter/day_of_month" 2>/dev/null || echo "*")" month="$(cat "$__object/parameter/month" 2>/dev/null || echo "*")" day_of_week="$(cat "$__object/parameter/day_of_week" 2>/dev/null || echo "*")" - entry="$minute $hour $day_of_month $month $day_of_week $command" + entry="$minute $hour $day_of_month $month $day_of_week $command # $name" fi -entry="$entry # $name" mkdir "$__object/files" echo "$entry" > "$__object/files/entry" @@ -85,7 +84,12 @@ case "$state_should" in echo ") | crontab -u $user -" ;; absent) - echo "( crontab -u $user -l 2>/dev/null | grep -v -E \"$filter\" 2>/dev/null || true ) | \\" - echo "grep -v \"# $name\\$\" | crontab -u $user -" + if [ -f "$__object/parameter/raw_command" ]; then + echo "( crontab -u $user -l 2>/dev/null | grep -v -E \"$filter\" 2>/dev/null || true ) | \\" + echo "grep -v \"^$entry\\$\" | crontab -u $user -" + else + echo "( crontab -u $user -l 2>/dev/null | grep -v -E \"$filter\" 2>/dev/null || true ) | \\" + echo "grep -v \"# $name\\$\" | crontab -u $user -" + fi ;; esac From 88ec06d06fdd2cf0907e8f36614d20f970279ace Mon Sep 17 00:00:00 2001 From: Dmitry Bogatov Date: Fri, 22 Jul 2016 09:55:44 +0300 Subject: [PATCH 02/70] new type: __hosts This type adds or removes entries from /etc/hosts, ensuring that same hostname can never resolve to several different ip addresses. Signed-off-by: Dmitry Bogatov --- cdist/conf/type/__hosts/man.rst | 55 +++++++++++++++++++ cdist/conf/type/__hosts/manifest | 49 +++++++++++++++++ .../conf/type/__hosts/parameter/default/state | 1 + cdist/conf/type/__hosts/parameter/optional | 2 + 4 files changed, 107 insertions(+) create mode 100644 cdist/conf/type/__hosts/man.rst create mode 100755 cdist/conf/type/__hosts/manifest create mode 100644 cdist/conf/type/__hosts/parameter/default/state create mode 100644 cdist/conf/type/__hosts/parameter/optional diff --git a/cdist/conf/type/__hosts/man.rst b/cdist/conf/type/__hosts/man.rst new file mode 100644 index 00000000..f89a619c --- /dev/null +++ b/cdist/conf/type/__hosts/man.rst @@ -0,0 +1,55 @@ +cdist-type__hosts(7) +==================== + +NAME +---- + +cdist-type__hosts - manage entries in /etc/hosts + +DESCRIPTION +----------- + +Add or remove entries from */etc/hosts* file. + +OPTIONAL PARAMETERS +------------------- + +state + + If state is ``present``, make *object_id* resolve to *ip*. If + state is ``absent``, *object_id* will no longer resolve to + anything via */etc/hosts*. + +ip + + IP address, to which hostname (=\ *object_id*) must resolve. If + state is ``present``, this parameter is mandatory, if state is + ``absent``, this parameter is silently ignored. + +EXAMPLES +-------- + +.. code-block:: sh + + # Now `funny' resolves to 192.168.1.76, + __hosts funny --ip 192.168.1.76 + # and `happy' does not resolve (at least via /etc/hosts) + __hosts happy --state absent + +SEE ALSO +-------- + +:strong:`hosts`\ (5) + +AUTHORS +------- + +Dmitry Bogatov + + +COPYING +------- + +Copyright (C) 2015,2016 Dmitry Bogatov. Free use of this software is granted +under the terms of the GNU General Public License version 3 or later +(GPLv3+). diff --git a/cdist/conf/type/__hosts/manifest b/cdist/conf/type/__hosts/manifest new file mode 100755 index 00000000..99a06c09 --- /dev/null +++ b/cdist/conf/type/__hosts/manifest @@ -0,0 +1,49 @@ +#!/bin/sh +# Copyright (C) 2015 Bogatov Dmitry +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +hostname="$__object_id" +state="$(cat "$__object/parameter/state")" + +# First remove all lines for given hostname and then insert again. +# Otherwise, we risk having multiple entries for same hostname. +# +# There is a corner case, which we do not handle. Namely, /etc/hosts +# format allows several host names on single line, like following: +# +# 192.168.15.16 foo bar +# +# If this type manages hostname `foo', then hostname bar will get erased. + +__line "__hosts/delete/${hostname}" \ + --state absent \ + --regex " ${hostname}[ ]*$" \ + --file /etc/hosts +export require="__line/__hosts/delete/${hostname}" + +case "$state" in + absent) + : # Nothing to do + ;; + present) + ip="$(cat "$__object/parameter/ip")" + __line "__hosts/insert/${hostname}" \ + --line "${ip} ${hostname}" \ + --file /etc/hosts + ;; + *) + echo "ERROR: type (${__type##*/}) does not support state \`$state'" + exit 1 +esac diff --git a/cdist/conf/type/__hosts/parameter/default/state b/cdist/conf/type/__hosts/parameter/default/state new file mode 100644 index 00000000..e7f6134f --- /dev/null +++ b/cdist/conf/type/__hosts/parameter/default/state @@ -0,0 +1 @@ +present diff --git a/cdist/conf/type/__hosts/parameter/optional b/cdist/conf/type/__hosts/parameter/optional new file mode 100644 index 00000000..411fc5d2 --- /dev/null +++ b/cdist/conf/type/__hosts/parameter/optional @@ -0,0 +1,2 @@ +state +ip From fdd1062b857a56e55e2f54464561888ba4058522 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Sat, 23 Jul 2016 16:20:46 +0200 Subject: [PATCH 03/70] Update changelog --- docs/changelog | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/changelog b/docs/changelog index d85af785..db1cd080 100644 --- a/docs/changelog +++ b/docs/changelog @@ -1,6 +1,9 @@ Changelog --------- +next: + * New type: __hosts: manage entries in /etc/hosts (Dmitry Bogatov) + 4.2.1: 2016-07-18 * Build: Fix signed release (Darko Poljak) * Build: Fix building docs (Darko Poljak) From 493c8d61f400653ce235cbd27d717e51656a0e9b Mon Sep 17 00:00:00 2001 From: Andres Erbsen Date: Sun, 11 Sep 2016 22:23:06 -0400 Subject: [PATCH 04/70] __user_groups: refactor, support FreeBSD --- .../type/__user_groups/explorer/oldusermod | 7 ++-- cdist/conf/type/__user_groups/gencode-remote | 37 ++++++++++--------- 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/cdist/conf/type/__user_groups/explorer/oldusermod b/cdist/conf/type/__user_groups/explorer/oldusermod index bf43fcec..248d3922 100644 --- a/cdist/conf/type/__user_groups/explorer/oldusermod +++ b/cdist/conf/type/__user_groups/explorer/oldusermod @@ -22,7 +22,8 @@ os="$($__explorer/os)" if [ "$os" = "netbsd" ]; then echo netbsd - exit +elif [ "$os" = "freebsd" ]; then + echo freebsd +else + usermod --help | grep -q -- '-A group' && echo true || echo false fi - -usermod --help | grep -q -- '-A group' && echo true || echo false diff --git a/cdist/conf/type/__user_groups/gencode-remote b/cdist/conf/type/__user_groups/gencode-remote index 8b13f32c..6728228c 100755 --- a/cdist/conf/type/__user_groups/gencode-remote +++ b/cdist/conf/type/__user_groups/gencode-remote @@ -23,19 +23,6 @@ state_should="$(cat "$__object/parameter/state")" oldusermod="$(cat "$__object/explorer/oldusermod")" os=$(cat "$__global/explorer/os") -if [ "$os" = "netbsd" ]; then - # NetBSD does not have a command to remove a user from a group - oldusermod="true" - addparam="-G" - delparam=";;#" -elif [ "$oldusermod" = "true" ]; then - addparam="-A" - delparam="-R" -else - addparam="-a" - delparam="-d" -fi - mkdir "$__object/files" # file has to be sorted for comparison with `comm` sort "$__object/parameter/group" > "$__object/files/group.sorted" @@ -43,11 +30,9 @@ sort "$__object/parameter/group" > "$__object/files/group.sorted" case "$state_should" in present) changed_groups="$(comm -13 "$__object/explorer/group" "$__object/files/group.sorted")" - action="$addparam" ;; absent) changed_groups="$(comm -12 "$__object/explorer/group" "$__object/files/group.sorted")" - action="$delparam" ;; esac @@ -57,9 +42,25 @@ if [ -z "$changed_groups" ]; then fi for group in $changed_groups; do - if [ "$oldusermod" = "true" ]; then - echo "usermod $action \"$group\" \"$user\"" + if [ "$os" = "netbsd" ]; then + case "$state_should" in + present) echo "usermod -G \"$group\" \"$user\"" ;; + absent) echo 'NetBSD does not have a command to remove a user from a group' >&2 ; exit 1 ;; + esac + elif [ "$os" = "freebsd" ]; then + case "$state_should" in + present) echo "pw groupmod \"$group\" -m \"$user\"" ;; + absent) echo "pw groupmod \"$group\" -d \"$user\"" ;; + esac + elif [ "$oldusermod" = "true" ]; then + case "$state_should" in + present) echo "usermod -A \"$group\" \"$user\"" ;; + absent) echo "usermod -R \"$group\" \"$user\"" ;; + esac else - echo "gpasswd $action \"$user\" \"$group\"" + case "$state_should" in + present) echo "gpasswd -a \"$group\" \"$user\"" ;; + absent) echo "gpasswd -d \"$group\" \"$user\"" ;; + esac fi done From 7abb96b48d38ae7ed60981bdaa93300d7bb641fc Mon Sep 17 00:00:00 2001 From: Dominique Roux Date: Sun, 11 Dec 2016 22:12:44 +0100 Subject: [PATCH 05/70] Created __docker_compose type for cdist Features: - Install __docker_compose --- .../conf/type/__docker_compose/gencode-remote | 5 +++ cdist/conf/type/__docker_compose/man.rst | 45 +++++++++++++++++++ cdist/conf/type/__docker_compose/manifest | 24 ++++++++++ cdist/conf/type/__docker_compose/singleton | 0 4 files changed, 74 insertions(+) create mode 100644 cdist/conf/type/__docker_compose/gencode-remote create mode 100644 cdist/conf/type/__docker_compose/man.rst create mode 100644 cdist/conf/type/__docker_compose/manifest create mode 100644 cdist/conf/type/__docker_compose/singleton diff --git a/cdist/conf/type/__docker_compose/gencode-remote b/cdist/conf/type/__docker_compose/gencode-remote new file mode 100644 index 00000000..825dc17a --- /dev/null +++ b/cdist/conf/type/__docker_compose/gencode-remote @@ -0,0 +1,5 @@ +# Download docker-compose file +echo 'curl -L "https://github.com/docker/compose/releases/download/1.9.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose' + +# Change permissions +echo 'chmod +x /usr/local/bin/docker-compose' diff --git a/cdist/conf/type/__docker_compose/man.rst b/cdist/conf/type/__docker_compose/man.rst new file mode 100644 index 00000000..2eb1b964 --- /dev/null +++ b/cdist/conf/type/__docker_compose/man.rst @@ -0,0 +1,45 @@ +cdist-type__docker_compose(7) +============================= + +NAME +---- +cdist-type__docker_compose - install docker-compose + + +DESCRIPTION +----------- +Installs latest docker-compose package from dockerproject.org. + + +REQUIRED PARAMETERS +------------------- +None. + + +OPTIONAL PARAMETERS +------------------- +None. + + +BOOLEAN PARAMETERS +------------------ +None. + + +EXAMPLES +-------- + +.. code-block:: sh + + __docker_compose + + +AUTHORS +------- +Dominique Roux + + +COPYING +------- +Copyright \(C) 2016 Dominique Roux. Free use of this software is +granted under the terms of the GNU General Public License version 3 (GPLv3). diff --git a/cdist/conf/type/__docker_compose/manifest b/cdist/conf/type/__docker_compose/manifest new file mode 100644 index 00000000..2ff80aca --- /dev/null +++ b/cdist/conf/type/__docker_compose/manifest @@ -0,0 +1,24 @@ +#!/bin/sh +# +# 2016 Dominique Roux (dominique.roux at ungleich.ch) +# +# This file is part of cdist. +# +# cdist is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# cdist is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with cdist. If not, see . +# +# + +# Needed packages +__docker +__package curl diff --git a/cdist/conf/type/__docker_compose/singleton b/cdist/conf/type/__docker_compose/singleton new file mode 100644 index 00000000..e69de29b From afd0d8c8c824b1c7d921d68bc7997323111c8bfd Mon Sep 17 00:00:00 2001 From: Dominique Roux Date: Mon, 12 Dec 2016 09:09:48 +0100 Subject: [PATCH 06/70] Added / Changed license to GPLv3+ --- .../conf/type/__docker_compose/gencode-remote | 20 +++++++++++++++++++ cdist/conf/type/__docker_compose/man.rst | 2 +- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/cdist/conf/type/__docker_compose/gencode-remote b/cdist/conf/type/__docker_compose/gencode-remote index 825dc17a..93609172 100644 --- a/cdist/conf/type/__docker_compose/gencode-remote +++ b/cdist/conf/type/__docker_compose/gencode-remote @@ -1,3 +1,23 @@ +#!/bin/sh +# +# 2016 Dominique Roux (dominique.roux at ungleich.ch) +# +# This file is part of cdist. +# +# cdist is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# cdist is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with cdist. If not, see . +# + # Download docker-compose file echo 'curl -L "https://github.com/docker/compose/releases/download/1.9.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose' diff --git a/cdist/conf/type/__docker_compose/man.rst b/cdist/conf/type/__docker_compose/man.rst index 2eb1b964..4e57b156 100644 --- a/cdist/conf/type/__docker_compose/man.rst +++ b/cdist/conf/type/__docker_compose/man.rst @@ -42,4 +42,4 @@ Dominique Roux COPYING ------- Copyright \(C) 2016 Dominique Roux. Free use of this software is -granted under the terms of the GNU General Public License version 3 (GPLv3). +granted under the terms of the GNU General Public License version 3 or later (GPLv3+). From db50e2e9e28d8782d5bf87078547413babc0caa5 Mon Sep 17 00:00:00 2001 From: Dominique Roux Date: Mon, 12 Dec 2016 19:43:15 +0100 Subject: [PATCH 07/70] Added parameter --version to define the docker-compose version --- cdist/conf/type/__docker_compose/gencode-remote | 5 ++++- cdist/conf/type/__docker_compose/parameter/default/version | 1 + cdist/conf/type/__docker_compose/parameter/optional | 1 + 3 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 cdist/conf/type/__docker_compose/parameter/default/version create mode 100644 cdist/conf/type/__docker_compose/parameter/optional diff --git a/cdist/conf/type/__docker_compose/gencode-remote b/cdist/conf/type/__docker_compose/gencode-remote index 93609172..f22823d3 100644 --- a/cdist/conf/type/__docker_compose/gencode-remote +++ b/cdist/conf/type/__docker_compose/gencode-remote @@ -18,8 +18,11 @@ # along with cdist. If not, see . # +# Variables +version="$(cat "$__object/parameter/version")" + # Download docker-compose file -echo 'curl -L "https://github.com/docker/compose/releases/download/1.9.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose' +echo 'curl -L "https://github.com/docker/compose/releases/download/'${version}'/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose' # Change permissions echo 'chmod +x /usr/local/bin/docker-compose' diff --git a/cdist/conf/type/__docker_compose/parameter/default/version b/cdist/conf/type/__docker_compose/parameter/default/version new file mode 100644 index 00000000..f8e233b2 --- /dev/null +++ b/cdist/conf/type/__docker_compose/parameter/default/version @@ -0,0 +1 @@ +1.9.0 diff --git a/cdist/conf/type/__docker_compose/parameter/optional b/cdist/conf/type/__docker_compose/parameter/optional new file mode 100644 index 00000000..088eda41 --- /dev/null +++ b/cdist/conf/type/__docker_compose/parameter/optional @@ -0,0 +1 @@ +version From f180cbcb09d42400d110ef605d44b02fbc34327b Mon Sep 17 00:00:00 2001 From: Dominique Roux Date: Tue, 13 Dec 2016 08:09:14 +0100 Subject: [PATCH 08/70] documented --version parameter --- cdist/conf/type/__docker_compose/man.rst | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cdist/conf/type/__docker_compose/man.rst b/cdist/conf/type/__docker_compose/man.rst index 4e57b156..29c47fbf 100644 --- a/cdist/conf/type/__docker_compose/man.rst +++ b/cdist/conf/type/__docker_compose/man.rst @@ -18,7 +18,8 @@ None. OPTIONAL PARAMETERS ------------------- -None. +version + Define docker_compose version. BOOLEAN PARAMETERS @@ -33,6 +34,9 @@ EXAMPLES __docker_compose + # Install version 1.9.0-rc4 + __docker_compose --version 1.9.0-rc4 + AUTHORS ------- From d6f972057e7ed5b357a1709627fef4605b2ead1c Mon Sep 17 00:00:00 2001 From: Dominique Roux Date: Tue, 13 Dec 2016 08:16:24 +0100 Subject: [PATCH 09/70] updated documentation --- cdist/conf/type/__docker_compose/man.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cdist/conf/type/__docker_compose/man.rst b/cdist/conf/type/__docker_compose/man.rst index 29c47fbf..720a306e 100644 --- a/cdist/conf/type/__docker_compose/man.rst +++ b/cdist/conf/type/__docker_compose/man.rst @@ -8,7 +8,7 @@ cdist-type__docker_compose - install docker-compose DESCRIPTION ----------- -Installs latest docker-compose package from dockerproject.org. +Installs docker-compose package. REQUIRED PARAMETERS @@ -19,7 +19,7 @@ None. OPTIONAL PARAMETERS ------------------- version - Define docker_compose version. + Define docker_compose version, defaults to "1.9.0" BOOLEAN PARAMETERS From d597b64705a7c53908b87a6fdb3cb12cad5ebbdc Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Tue, 13 Dec 2016 11:41:04 +0100 Subject: [PATCH 10/70] Update changelog. --- docs/changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog b/docs/changelog index f0b296cc..68be920e 100644 --- a/docs/changelog +++ b/docs/changelog @@ -2,6 +2,7 @@ Changelog --------- next: + * New type: __docker_compose (Dominique Roux) * Type __apt_mark: Check supported apt version and if package is installed (Ander Punnar) * New type: __docker (Steven Armstrong) * New type: __package_dpkg (Tomas Pospisek) From d9c4a062eeefa3fd275d801127819c1f4ca62f7d Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Wed, 14 Dec 2016 09:08:43 +0100 Subject: [PATCH 11/70] Update changelog. --- docs/changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog b/docs/changelog index 68be920e..ec85c50d 100644 --- a/docs/changelog +++ b/docs/changelog @@ -2,6 +2,7 @@ Changelog --------- next: + * Type __cron: no '# marker' for raw_command due to cron security (Daniel Heule) * New type: __docker_compose (Dominique Roux) * Type __apt_mark: Check supported apt version and if package is installed (Ander Punnar) * New type: __docker (Steven Armstrong) From 2b45405898d8adb3b89e9005d21fc7bf69642191 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Fri, 16 Dec 2016 08:19:41 +0100 Subject: [PATCH 12/70] Update docs for types that used man.rst as symbolic links. --- cdist/conf/type/__chroot_mount/man.rst | 6 +- cdist/conf/type/__chroot_umount/man.rst | 8 +- .../conf/type/__install_chroot_mount/man.rst | 43 ++++++- .../conf/type/__install_chroot_umount/man.rst | 48 +++++++- cdist/conf/type/__install_file/man.rst | 113 +++++++++++++++++- docs/changelog | 1 + docs/src/cdist-type.rst | 25 ++++ 7 files changed, 234 insertions(+), 10 deletions(-) mode change 120000 => 100644 cdist/conf/type/__install_chroot_mount/man.rst mode change 120000 => 100644 cdist/conf/type/__install_chroot_umount/man.rst mode change 120000 => 100644 cdist/conf/type/__install_file/man.rst diff --git a/cdist/conf/type/__chroot_mount/man.rst b/cdist/conf/type/__chroot_mount/man.rst index 5ffd7de5..0d7cdce3 100644 --- a/cdist/conf/type/__chroot_mount/man.rst +++ b/cdist/conf/type/__chroot_mount/man.rst @@ -1,9 +1,9 @@ -cdist-type__install_chroot_mount(7) +cdist-type__chroot_mount(7) =================================== NAME ---- -cdist-type__install_chroot_mount - mount a chroot +cdist-type__chroot_mount - mount a chroot DESCRIPTION @@ -26,7 +26,7 @@ EXAMPLES .. code-block:: sh - __install_chroot_mount /path/to/chroot + __chroot_mount /path/to/chroot AUTHORS diff --git a/cdist/conf/type/__chroot_umount/man.rst b/cdist/conf/type/__chroot_umount/man.rst index a2ea1d9b..ff116da5 100644 --- a/cdist/conf/type/__chroot_umount/man.rst +++ b/cdist/conf/type/__chroot_umount/man.rst @@ -1,9 +1,9 @@ -cdist-type__install_chroot_umount(7) -==================================== +cdist-type__chroot_umount(7) +============================ NAME ---- -cdist-type__install_chroot_umount - unmount a chroot mounted by __chroot_mount +cdist-type__chroot_umount - unmount a chroot mounted by __chroot_mount DESCRIPTION @@ -26,7 +26,7 @@ EXAMPLES .. code-block:: sh - __install_chroot_umount /path/to/chroot + __chroot_umount /path/to/chroot SEE ALSO diff --git a/cdist/conf/type/__install_chroot_mount/man.rst b/cdist/conf/type/__install_chroot_mount/man.rst deleted file mode 120000 index 3267c3db..00000000 --- a/cdist/conf/type/__install_chroot_mount/man.rst +++ /dev/null @@ -1 +0,0 @@ -../__chroot_mount/man.rst \ No newline at end of file diff --git a/cdist/conf/type/__install_chroot_mount/man.rst b/cdist/conf/type/__install_chroot_mount/man.rst new file mode 100644 index 00000000..4054c4c4 --- /dev/null +++ b/cdist/conf/type/__install_chroot_mount/man.rst @@ -0,0 +1,42 @@ +cdist-type__install_chroot_mount(7) +=================================== + +NAME +---- +cdist-type__install_chroot_mount - mount a chroot with install command + + +DESCRIPTION +----------- +Mount and prepare a chroot for running commands within it. + + +REQUIRED PARAMETERS +------------------- +None + + +OPTIONAL PARAMETERS +------------------- +None + + +EXAMPLES +-------- + +.. code-block:: sh + + __install_chroot_mount /path/to/chroot + + +AUTHORS +------- +Steven Armstrong + + +COPYING +------- +Copyright \(C) 2012 Steven Armstrong. You can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation, either version 3 of the +License, or (at your option) any later version. diff --git a/cdist/conf/type/__install_chroot_umount/man.rst b/cdist/conf/type/__install_chroot_umount/man.rst deleted file mode 120000 index fa34c4b0..00000000 --- a/cdist/conf/type/__install_chroot_umount/man.rst +++ /dev/null @@ -1 +0,0 @@ -../__chroot_umount/man.rst \ No newline at end of file diff --git a/cdist/conf/type/__install_chroot_umount/man.rst b/cdist/conf/type/__install_chroot_umount/man.rst new file mode 100644 index 00000000..2e020c01 --- /dev/null +++ b/cdist/conf/type/__install_chroot_umount/man.rst @@ -0,0 +1,47 @@ +cdist-type__install_chroot_umount(7) +==================================== + +NAME +---- +cdist-type__install_chroot_umount - unmount a chroot mounted by __install_chroot_mount + + +DESCRIPTION +----------- +Undo what __install_chroot_mount did. + + +REQUIRED PARAMETERS +------------------- +None + + +OPTIONAL PARAMETERS +------------------- +None + + +EXAMPLES +-------- + +.. code-block:: sh + + __install_chroot_umount /path/to/chroot + + +SEE ALSO +-------- +:strong:`cdist-type__install_chroot_mount`\ (7) + + +AUTHORS +------- +Steven Armstrong + + +COPYING +------- +Copyright \(C) 2012 Steven Armstrong. You can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation, either version 3 of the +License, or (at your option) any later version. diff --git a/cdist/conf/type/__install_file/man.rst b/cdist/conf/type/__install_file/man.rst deleted file mode 120000 index c937b8af..00000000 --- a/cdist/conf/type/__install_file/man.rst +++ /dev/null @@ -1 +0,0 @@ -../__file/man.rst \ No newline at end of file diff --git a/cdist/conf/type/__install_file/man.rst b/cdist/conf/type/__install_file/man.rst new file mode 100644 index 00000000..c5409167 --- /dev/null +++ b/cdist/conf/type/__install_file/man.rst @@ -0,0 +1,112 @@ +cdist-type__install_file(7) +=========================== + +NAME +---- +cdist-type__install_file - Manage files with install command. + + +DESCRIPTION +----------- +This cdist type allows you to create files, remove files and set file +attributes on the target. + +If the file already exists on the target, then if it is a: + +regular file, and state is: + present + replace it with the source file if they are not equal + exists + do nothing +symlink + replace it with the source file +directory + replace it with the source file + +In any case, make sure that the file attributes are as specified. + + +REQUIRED PARAMETERS +------------------- +None. + +OPTIONAL PARAMETERS +------------------- +state + 'present', 'absent' or 'exists', defaults to 'present' where: + + present + the file is exactly the one from source + absent + the file does not exist + exists + the file from source but only if it doesn't already exist + +group + Group to chgrp to. + +mode + Unix permissions, suitable for chmod. + +owner + User to chown to. + +source + If supplied, copy this file from the host running cdist to the target. + If not supplied, an empty file or directory will be created. + If source is '-' (dash), take what was written to stdin as the file content. + +MESSAGES +-------- +chgrp + Changed group membership +chown + Changed owner +chmod + Changed mode +create + Empty file was created (no --source specified) +remove + File exists, but state is absent, file will be removed by generated code. +upload + File was uploaded + + +EXAMPLES +-------- + +.. code-block:: sh + + # Create /etc/cdist-configured as an empty file + __install_file /etc/cdist-configured + # The same thing + __install_file /etc/cdist-configured --state present + # Use __file from another type + __install_file /etc/issue --source "$__type/files/archlinux" --state present + # Delete existing file + __install_file /etc/cdist-configured --state absent + # Supply some more settings + __install_file /etc/shadow --source "$__type/files/shadow" \ + --owner root --group shadow --mode 0640 \ + --state present + # Provide a default file, but let the user change it + __install_file /home/frodo/.bashrc --source "/etc/skel/.bashrc" \ + --state exists \ + --owner frodo --mode 0600 + # Take file content from stdin + __install_file /tmp/whatever --owner root --group root --mode 644 --source - << DONE + Here goes the content for /tmp/whatever + DONE + + +AUTHORS +------- +Nico Schottelius + + +COPYING +------- +Copyright \(C) 2011-2013 Nico Schottelius. You can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation, either version 3 of the +License, or (at your option) any later version. diff --git a/docs/changelog b/docs/changelog index ec85c50d..a84ebf10 100644 --- a/docs/changelog +++ b/docs/changelog @@ -2,6 +2,7 @@ Changelog --------- next: + * Documentation: Update docs for types that used man.rst as symbolic links (Darko Poljak) * Type __cron: no '# marker' for raw_command due to cron security (Daniel Heule) * New type: __docker_compose (Dominique Roux) * Type __apt_mark: Check supported apt version and if package is installed (Ander Punnar) diff --git a/docs/src/cdist-type.rst b/docs/src/cdist-type.rst index 1ff82ce0..2c5f9f6a 100644 --- a/docs/src/cdist-type.rst +++ b/docs/src/cdist-type.rst @@ -51,6 +51,19 @@ Example: __myfancysingleton --colour green +Config types +------------ +By default types are used with config command. These are types that are not +flagged by any known command flag. If a type is marked then it will be skipped +with config command. + + +Install types +------------- +If a type is flagged with 'install' flag then it is used only with install command. +With other commands, i.e. config, these types are skipped if used. + + How to write a new type ----------------------- A type consists of @@ -209,6 +222,18 @@ As you can see, the object ID is omitted, because it does not make any sense, if your type can be used only once. +Install - type with install command +----------------------------------- +If you want a type to be used with install command, you must mark it as +install: create the (empty) file "install" in your type directory: + +.. code-block:: sh + + touch cdist/conf/type/__install_NAME/install + +With other commands, i.e. config, it will be skipped if used. + + The type explorers ------------------ If a type needs to explore specific details, it can provide type specific From 7868165e912581a23f4ec6761bb648a61826ca95 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Fri, 16 Dec 2016 20:27:00 +0100 Subject: [PATCH 13/70] Update changelog. --- docs/changelog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/changelog b/docs/changelog index a84ebf10..425a32f3 100644 --- a/docs/changelog +++ b/docs/changelog @@ -3,7 +3,7 @@ Changelog next: * Documentation: Update docs for types that used man.rst as symbolic links (Darko Poljak) - * Type __cron: no '# marker' for raw_command due to cron security (Daniel Heule) + * Type __cron: Remove '# marker' for raw_command due to cron security (Daniel Heule) * New type: __docker_compose (Dominique Roux) * Type __apt_mark: Check supported apt version and if package is installed (Ander Punnar) * New type: __docker (Steven Armstrong) From 4d106550148210fefa4982ae6b8f7e8c7b657ec4 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Sat, 17 Dec 2016 09:46:44 +0100 Subject: [PATCH 14/70] release++ --- docs/changelog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/changelog b/docs/changelog index 425a32f3..d5519f25 100644 --- a/docs/changelog +++ b/docs/changelog @@ -1,7 +1,7 @@ Changelog --------- -next: +4.4.1: 2016-12-17 * Documentation: Update docs for types that used man.rst as symbolic links (Darko Poljak) * Type __cron: Remove '# marker' for raw_command due to cron security (Daniel Heule) * New type: __docker_compose (Dominique Roux) From 7a5244bf7c5b4fb486de5c69b31e772626d4c5ad Mon Sep 17 00:00:00 2001 From: Dominique Roux Date: Wed, 21 Dec 2016 23:03:24 +0100 Subject: [PATCH 15/70] Bugfixed __docker_compose: If docker-compose is already running, curl won't override the binary I add an if the file does not exist before download --- cdist/conf/type/__docker_compose/gencode-remote | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cdist/conf/type/__docker_compose/gencode-remote b/cdist/conf/type/__docker_compose/gencode-remote index f22823d3..3f2fb940 100644 --- a/cdist/conf/type/__docker_compose/gencode-remote +++ b/cdist/conf/type/__docker_compose/gencode-remote @@ -22,7 +22,6 @@ version="$(cat "$__object/parameter/version")" # Download docker-compose file -echo 'curl -L "https://github.com/docker/compose/releases/download/'${version}'/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose' - + echo 'if [ ! -e /usr/local/bin/docker-compose ]; then curl -L "https://github.com/docker/compose/releases/download/'${version}'/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose ; fi' # Change permissions echo 'chmod +x /usr/local/bin/docker-compose' From 6fa7bfbfb57dfd29dfaac333f9e172ac6d23aaf1 Mon Sep 17 00:00:00 2001 From: Dominique Roux Date: Tue, 27 Dec 2016 13:20:57 +0100 Subject: [PATCH 16/70] Better bugfix: - Download the docker-compose binary first to /tmp then move it to its target location --- cdist/conf/type/__docker_compose/gencode-remote | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cdist/conf/type/__docker_compose/gencode-remote b/cdist/conf/type/__docker_compose/gencode-remote index 3f2fb940..3424ed6d 100644 --- a/cdist/conf/type/__docker_compose/gencode-remote +++ b/cdist/conf/type/__docker_compose/gencode-remote @@ -22,6 +22,7 @@ version="$(cat "$__object/parameter/version")" # Download docker-compose file - echo 'if [ ! -e /usr/local/bin/docker-compose ]; then curl -L "https://github.com/docker/compose/releases/download/'${version}'/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose ; fi' + echo 'curl -L "https://github.com/docker/compose/releases/download/'${version}'/docker-compose-$(uname -s)-$(uname -m)" -o /tmp/docker-compose' + echo 'mv /tmp/docker-compose /usr/local/bin/docker-compose' # Change permissions echo 'chmod +x /usr/local/bin/docker-compose' From 95b92627aa84bf73744724f02fbffd367c2c6751 Mon Sep 17 00:00:00 2001 From: Dominique Roux Date: Thu, 29 Dec 2016 14:36:46 +0100 Subject: [PATCH 17/70] Added --state absent functionality to docker types Changed types: __docker __docker_compose --- cdist/conf/type/__docker/manifest | 56 ++++++++++--------- .../type/__docker/parameter/default/state | 1 + cdist/conf/type/__docker/parameter/optional | 1 + .../conf/type/__docker_compose/gencode-remote | 13 +++-- cdist/conf/type/__docker_compose/manifest | 11 +++- .../__docker_compose/parameter/default/state | 1 + .../type/__docker_compose/parameter/optional | 1 + 7 files changed, 51 insertions(+), 33 deletions(-) create mode 100644 cdist/conf/type/__docker/parameter/default/state create mode 100644 cdist/conf/type/__docker/parameter/optional create mode 100644 cdist/conf/type/__docker_compose/parameter/default/state diff --git a/cdist/conf/type/__docker/manifest b/cdist/conf/type/__docker/manifest index ba13b3e4..1f473afb 100755 --- a/cdist/conf/type/__docker/manifest +++ b/cdist/conf/type/__docker/manifest @@ -20,38 +20,39 @@ os=$(cat "$__global/explorer/os") +state=$(cat "$__object/parameter/state") case "$os" in - centos) - component="main" + centos) + component="main" + if [ -f "$__object/parameter/experimental" ]; then + component="experimental" + fi + __yum_repo docker \ + --name 'Docker Repository' \ + --baseurl "https://yum.dockerproject.org/repo/$component/centos/\$releasever/" \ + --enabled \ + --gpgcheck 1 \ + --gpgkey 'https://yum.dockerproject.org/gpg' \ + --state ${state} + require="__yum_repo/docker" __package docker-engine --state ${state} + ;; + ubuntu) + component="main" if [ -f "$__object/parameter/experimental" ]; then component="experimental" fi - export CDIST_ORDER_DEPENDENCY=on - __yum_repo docker \ - --name 'Docker Repository' \ - --baseurl "https://yum.dockerproject.org/repo/$component/centos/\$releasever/" \ - --enabled \ - --gpgcheck \ - --gpgkey 'https://yum.dockerproject.org/gpg' - __package docker-engine - unset CDIST_ORDER_DEPENDENCY - ;; - ubuntu) - component="main" - if [ -f "$__object/parameter/experimental" ]; then - component="experimental" - fi - __package apparmor - __package ca-certificates - __package apt-transport-https - __apt_key docker --keyid 58118E89F3A912897C070ADBF76221572C52609D + __package apparmor --state ${state} + __package ca-certificates --state ${state} + __package apt-transport-https --state ${state} + __apt_key docker --keyid 58118E89F3A912897C070ADBF76221572C52609D --state ${state} export CDIST_ORDER_DEPENDENCY=on __apt_source docker \ --uri https://apt.dockerproject.org/repo \ --distribution "ubuntu-$(cat "$__global/explorer/lsb_codename")" \ + --state ${state} \ --component "$component" - __package docker-engine + __package docker-engine --state ${state} unset CDIST_ORDER_DEPENDENCY ;; debian) @@ -60,16 +61,17 @@ case "$os" in component="experimental" fi - __package apt-transport-https - __package ca-certificates - __package gnupg2 - __apt_key docker --keyid 58118E89F3A912897C070ADBF76221572C52609D + __package apt-transport-https --state ${state} + __package ca-certificates --state ${state} + __package gnupg2 --state ${state} + __apt_key docker --keyid 58118E89F3A912897C070ADBF76221572C52609D --state ${state} export CDIST_ORDER_DEPENDENCY=on __apt_source docker \ --uri https://apt.dockerproject.org/repo \ --distribution "debian-$(cat "$__global/explorer/lsb_codename")" \ + --state ${state} \ --component "$component" - __package docker-engine + __package docker-engine --state ${state} unset CDIST_ORDER_DEPENDENCY ;; diff --git a/cdist/conf/type/__docker/parameter/default/state b/cdist/conf/type/__docker/parameter/default/state new file mode 100644 index 00000000..e7f6134f --- /dev/null +++ b/cdist/conf/type/__docker/parameter/default/state @@ -0,0 +1 @@ +present diff --git a/cdist/conf/type/__docker/parameter/optional b/cdist/conf/type/__docker/parameter/optional new file mode 100644 index 00000000..ff72b5c7 --- /dev/null +++ b/cdist/conf/type/__docker/parameter/optional @@ -0,0 +1 @@ +state diff --git a/cdist/conf/type/__docker_compose/gencode-remote b/cdist/conf/type/__docker_compose/gencode-remote index 3424ed6d..bd1ad452 100644 --- a/cdist/conf/type/__docker_compose/gencode-remote +++ b/cdist/conf/type/__docker_compose/gencode-remote @@ -20,9 +20,12 @@ # Variables version="$(cat "$__object/parameter/version")" +state="$(cat "$__object/parameter/state")" -# Download docker-compose file - echo 'curl -L "https://github.com/docker/compose/releases/download/'${version}'/docker-compose-$(uname -s)-$(uname -m)" -o /tmp/docker-compose' - echo 'mv /tmp/docker-compose /usr/local/bin/docker-compose' -# Change permissions -echo 'chmod +x /usr/local/bin/docker-compose' +if [ ${state} = "present" ]; then + # Download docker-compose file + echo 'curl -L "https://github.com/docker/compose/releases/download/'${version}'/docker-compose-$(uname -s)-$(uname -m)" -o /tmp/docker-compose' + echo 'mv /tmp/docker-compose /usr/local/bin/docker-compose' + # Change permissions + echo 'chmod +x /usr/local/bin/docker-compose' +fi diff --git a/cdist/conf/type/__docker_compose/manifest b/cdist/conf/type/__docker_compose/manifest index 2ff80aca..113e87e9 100644 --- a/cdist/conf/type/__docker_compose/manifest +++ b/cdist/conf/type/__docker_compose/manifest @@ -19,6 +19,15 @@ # # +state="$(cat "$__object/parameter/state")" + # Needed packages -__docker +__docker --state ${state} __package curl + +if [ ${state} = "absent" ]; then + __file /usr/local/bin/docker-compose --state absent +elif [ ${state} != "present" -a ${state} != "absent" ]; then + echo "Unknown state: $state_should" >&2 + exit 1 +fi diff --git a/cdist/conf/type/__docker_compose/parameter/default/state b/cdist/conf/type/__docker_compose/parameter/default/state new file mode 100644 index 00000000..e7f6134f --- /dev/null +++ b/cdist/conf/type/__docker_compose/parameter/default/state @@ -0,0 +1 @@ +present diff --git a/cdist/conf/type/__docker_compose/parameter/optional b/cdist/conf/type/__docker_compose/parameter/optional index 088eda41..4d595ed7 100644 --- a/cdist/conf/type/__docker_compose/parameter/optional +++ b/cdist/conf/type/__docker_compose/parameter/optional @@ -1 +1,2 @@ +state version From 54a58abcaa23357d14f3825b5e31ee121a7b1ec2 Mon Sep 17 00:00:00 2001 From: Dominique Roux Date: Thu, 29 Dec 2016 14:47:29 +0100 Subject: [PATCH 18/70] Changed man.rst of __docker and __docker_compose - Added state parameter for both types in the man.rst - Changed --state absent behavior of __docker_compose -- only remove docker-compose binary not whole docker --- cdist/conf/type/__docker/man.rst | 9 ++++++++- cdist/conf/type/__docker_compose/man.rst | 7 +++++++ cdist/conf/type/__docker_compose/manifest | 10 +++++----- 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/cdist/conf/type/__docker/man.rst b/cdist/conf/type/__docker/man.rst index 42e71af5..70b92cc7 100644 --- a/cdist/conf/type/__docker/man.rst +++ b/cdist/conf/type/__docker/man.rst @@ -26,17 +26,24 @@ BOOLEAN PARAMETERS experimental Install the experimental docker-engine package instead of the latest stable release. +state + 'present' or 'absent', defaults to 'present' + EXAMPLES -------- .. code-block:: sh + # Install docker __docker - # experimental + # Install experimental __docker --experimental + # Remove docker + __docker --state absent + AUTHORS ------- diff --git a/cdist/conf/type/__docker_compose/man.rst b/cdist/conf/type/__docker_compose/man.rst index 720a306e..d54b3370 100644 --- a/cdist/conf/type/__docker_compose/man.rst +++ b/cdist/conf/type/__docker_compose/man.rst @@ -21,6 +21,9 @@ OPTIONAL PARAMETERS version Define docker_compose version, defaults to "1.9.0" +state + 'present' or 'absent', defaults to 'present' + BOOLEAN PARAMETERS ------------------ @@ -32,11 +35,15 @@ EXAMPLES .. code-block:: sh + # Install docker-compose __docker_compose # Install version 1.9.0-rc4 __docker_compose --version 1.9.0-rc4 + # Remove docker-compose + __docker_compose --state absent + AUTHORS ------- diff --git a/cdist/conf/type/__docker_compose/manifest b/cdist/conf/type/__docker_compose/manifest index 113e87e9..3ab27c63 100644 --- a/cdist/conf/type/__docker_compose/manifest +++ b/cdist/conf/type/__docker_compose/manifest @@ -22,12 +22,12 @@ state="$(cat "$__object/parameter/state")" # Needed packages -__docker --state ${state} -__package curl - -if [ ${state} = "absent" ]; then +if [ ${state} = "present" ]; then + __docker + __package curl +elif [ ${state} = "absent" ]; then __file /usr/local/bin/docker-compose --state absent -elif [ ${state} != "present" -a ${state} != "absent" ]; then +else echo "Unknown state: $state_should" >&2 exit 1 fi From 0dbe9e14286428437052fa7c9c96ef5335a11b82 Mon Sep 17 00:00:00 2001 From: Dominique Roux Date: Sat, 31 Dec 2016 11:03:28 +0100 Subject: [PATCH 19/70] updated man.rst --- cdist/conf/type/__docker_compose/man.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cdist/conf/type/__docker_compose/man.rst b/cdist/conf/type/__docker_compose/man.rst index d54b3370..38366157 100644 --- a/cdist/conf/type/__docker_compose/man.rst +++ b/cdist/conf/type/__docker_compose/man.rst @@ -9,6 +9,8 @@ cdist-type__docker_compose - install docker-compose DESCRIPTION ----------- Installs docker-compose package. +State 'absent' will not remove docker binary itself +only docker-compose binary will be removed REQUIRED PARAMETERS From 07906451b23abfe4c100d7413d6f362e183cff1d Mon Sep 17 00:00:00 2001 From: Dominique Roux Date: Sat, 31 Dec 2016 11:06:06 +0100 Subject: [PATCH 20/70] updated man.rst --- cdist/conf/type/__docker_compose/man.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cdist/conf/type/__docker_compose/man.rst b/cdist/conf/type/__docker_compose/man.rst index 38366157..7386e737 100644 --- a/cdist/conf/type/__docker_compose/man.rst +++ b/cdist/conf/type/__docker_compose/man.rst @@ -9,7 +9,7 @@ cdist-type__docker_compose - install docker-compose DESCRIPTION ----------- Installs docker-compose package. -State 'absent' will not remove docker binary itself +State 'absent' will not remove docker binary itself, only docker-compose binary will be removed From 4742913244ce33c7910b0b20224dba3439292147 Mon Sep 17 00:00:00 2001 From: Dominique Roux Date: Mon, 2 Jan 2017 11:48:07 +0100 Subject: [PATCH 21/70] fixed type --- cdist/conf/type/__docker_compose/manifest | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cdist/conf/type/__docker_compose/manifest b/cdist/conf/type/__docker_compose/manifest index 3ab27c63..559375ef 100644 --- a/cdist/conf/type/__docker_compose/manifest +++ b/cdist/conf/type/__docker_compose/manifest @@ -28,6 +28,6 @@ if [ ${state} = "present" ]; then elif [ ${state} = "absent" ]; then __file /usr/local/bin/docker-compose --state absent else - echo "Unknown state: $state_should" >&2 + echo "Unknown state: ${state}" >&2 exit 1 fi From 0ad767fa293b80960656d2fe2f3ec40b348de454 Mon Sep 17 00:00:00 2001 From: Daniel Heule Date: Wed, 11 Jan 2017 16:44:17 +0100 Subject: [PATCH 22/70] fix filter for new cron on sles12 sp2 --- cdist/conf/type/__cron/gencode-remote | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cdist/conf/type/__cron/gencode-remote b/cdist/conf/type/__cron/gencode-remote index f5c1cc62..3c3ed6b3 100644 --- a/cdist/conf/type/__cron/gencode-remote +++ b/cdist/conf/type/__cron/gencode-remote @@ -3,6 +3,7 @@ # 2011 Steven Armstrong (steven-cdist at armstrong.cc) # 2013 Nico Schottelius (nico-cdist at schottelius.org) # 2013 Thomas Oettli (otho at sfs.biz) +# 2017 Daniel Heule (hda at sfs.biz) # # This file is part of cdist. # @@ -57,7 +58,7 @@ state_should="$(cat "$__object/parameter/state" 2>/dev/null || echo "present")" # These are the old markers prefix="#cdist:__cron/$__object_id" suffix="#/cdist:__cron/$__object_id" -filter="^# DO NOT EDIT THIS FILE|^# \(.* installed on |^# \(Cron version V" +filter="^# DO NOT EDIT THIS FILE|^# \(.* installed on |^# \(Cron version V|^# \(Cronie version .\..\)$" cat << DONE crontab -u $user -l 2>/dev/null | grep -v -E "$filter" | awk -v prefix="$prefix" -v suffix="$suffix" ' { From 86678b5beb0a292273947c250796035de0814758 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Wed, 11 Jan 2017 21:32:52 +0100 Subject: [PATCH 23/70] Cleanup __user_groups oldusermod explorer. --- cdist/conf/type/__user_groups/explorer/oldusermod | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/cdist/conf/type/__user_groups/explorer/oldusermod b/cdist/conf/type/__user_groups/explorer/oldusermod index 248d3922..6ef25b13 100644 --- a/cdist/conf/type/__user_groups/explorer/oldusermod +++ b/cdist/conf/type/__user_groups/explorer/oldusermod @@ -18,12 +18,4 @@ # along with cdist. If not, see . # -os="$($__explorer/os)" - -if [ "$os" = "netbsd" ]; then - echo netbsd -elif [ "$os" = "freebsd" ]; then - echo freebsd -else - usermod --help | grep -q -- '-A group' && echo true || echo false -fi +usermod --help | grep -q -- '-A group' && echo true || echo false From 61c45e7eaba64fea0de259c5b3099418aff68cd3 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Sat, 14 Jan 2017 19:54:52 +0100 Subject: [PATCH 24/70] Update changelog. --- docs/changelog | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/changelog b/docs/changelog index d5519f25..3ffb0c68 100644 --- a/docs/changelog +++ b/docs/changelog @@ -1,6 +1,12 @@ Changelog --------- +next: + * Type __user_groups: Support FreeBSD (Andres Erbsen) + * Type __cron: Fix filter for new cron on sles12 sp2 (Daniel Heule) + * Type __docker: Support absent state (Dominique Roux) + * Type __docker_compose: Support absent state (Dominique Roux) + 4.4.1: 2016-12-17 * Documentation: Update docs for types that used man.rst as symbolic links (Darko Poljak) * Type __cron: Remove '# marker' for raw_command due to cron security (Daniel Heule) From 2087f7a28aa477a95e69b45a002402a3829bba7c Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Fri, 20 Jan 2017 15:22:25 +0100 Subject: [PATCH 25/70] Un-suppress manifest stdout. --- cdist/core/manifest.py | 6 ++++-- cdist/exec/local.py | 6 +++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/cdist/core/manifest.py b/cdist/core/manifest.py index a16e9346..574884a0 100644 --- a/cdist/core/manifest.py +++ b/cdist/core/manifest.py @@ -138,7 +138,8 @@ class Manifest(object): message_prefix = "initialmanifest" self.local.run_script(initial_manifest, env=self.env_initial_manifest(initial_manifest), - message_prefix=message_prefix) + message_prefix=message_prefix, + save_output=False) def env_type_manifest(self, cdist_object): type_manifest = os.path.join(self.local.type_path, @@ -163,4 +164,5 @@ class Manifest(object): if os.path.isfile(type_manifest): self.local.run_script(type_manifest, env=self.env_type_manifest(cdist_object), - message_prefix=message_prefix) + message_prefix=message_prefix, + save_output=False) diff --git a/cdist/exec/local.py b/cdist/exec/local.py index 93301063..ec7a6ee8 100644 --- a/cdist/exec/local.py +++ b/cdist/exec/local.py @@ -212,7 +212,7 @@ class Local(object): try: if save_output: output, errout = exec_util.call_get_output(command, env=env) - self.log.debug("Local stdout: {}".format(output)) + self.log.info("Local stdout: {}".format(output)) # Currently, stderr is not captured. # self.log.debug("Local stderr: {}".format(errout)) if return_output: @@ -231,7 +231,7 @@ class Local(object): message.merge_messages() def run_script(self, script, env=None, return_output=False, - message_prefix=None): + message_prefix=None, save_output=True): """Run the given script with the given environment. Return the output as a string. @@ -240,7 +240,7 @@ class Local(object): command.append(script) return self.run(command=command, env=env, return_output=return_output, - message_prefix=message_prefix) + message_prefix=message_prefix, save_output=save_output) def save_cache(self): destination = os.path.join(self.cache_path, self.hostdir) From 707f220f779fd13fda631bc8c1ed6c3d246bc9f4 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Sat, 21 Jan 2017 17:23:50 +0100 Subject: [PATCH 26/70] Update changelog. --- docs/changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog b/docs/changelog index 3ffb0c68..71ca7782 100644 --- a/docs/changelog +++ b/docs/changelog @@ -2,6 +2,7 @@ Changelog --------- next: + * Core: Fix suppression of manifests' outputs (Darko Poljak) * Type __user_groups: Support FreeBSD (Andres Erbsen) * Type __cron: Fix filter for new cron on sles12 sp2 (Daniel Heule) * Type __docker: Support absent state (Dominique Roux) From b03bed242572fad1931cc90f5bd36bd452d2dff0 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Sat, 28 Jan 2017 13:49:19 +0100 Subject: [PATCH 27/70] Better describe -v option. --- cdist/argparse.py | 8 +++++--- docs/src/man1/cdist.rst | 7 ++++--- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/cdist/argparse.py b/cdist/argparse.py index 04f6e6a4..e2a13c38 100644 --- a/cdist/argparse.py +++ b/cdist/argparse.py @@ -85,9 +85,11 @@ def get_parsers(): action='store_true', default=False) parser['loglevel'].add_argument( '-v', '--verbose', - help=('Increase log level, be more verbose. Use it more than once ' - 'to increase log level. The order of levels from the lowest ' - 'to the highest are: ERROR, WARNING, INFO, DEBUG.'), + help=('Increase the verbosity level. Every instance of -v ' + 'increments the verbosity level by one. Its default value is ' + '0. There are 4 levels of verbosity. The order of levels ' + 'from the lowest to the highest are: ERROR (0), WARNING (1), ' + 'INFO (2) and DEBUG (3 or higher).'), action='count', default=0) parser['beta'] = argparse.ArgumentParser(add_help=False) diff --git a/docs/src/man1/cdist.rst b/docs/src/man1/cdist.rst index 55901300..adabe052 100644 --- a/docs/src/man1/cdist.rst +++ b/docs/src/man1/cdist.rst @@ -50,9 +50,10 @@ All commands accept the following options: .. option:: -v, --verbose - Increase log level, be more verbose. Use it more than once to increase - log level. The order of levels from the lowest to the highest are: - ERROR, WARNING, INFO, DEBUG. + Increase the verbosity level. Every instance of -v increments the verbosity + level by one. Its default value is 0. There are 4 levels of verbosity. The + order of levels from the lowest to the highest are: ERROR (0), WARNING (1), + INFO (2) and DEBUG (3 or higher). .. option:: -V, --version From 444790aed29a020a57139b199335f2d1830d9022 Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Wed, 1 Feb 2017 23:10:26 +0100 Subject: [PATCH 28/70] explicitly create cache dir Signed-off-by: Steven Armstrong --- cdist/exec/local.py | 1 + 1 file changed, 1 insertion(+) diff --git a/cdist/exec/local.py b/cdist/exec/local.py index ec7a6ee8..fd764378 100644 --- a/cdist/exec/local.py +++ b/cdist/exec/local.py @@ -149,6 +149,7 @@ class Local(object): self.mkdir(self.global_explorer_out_path) self.mkdir(self.object_path) self.mkdir(self.bin_path) + self.mkdir(self.cache_path) def create_files_dirs(self): self._init_directories() From 574688c6e1f27fdcd3cc69c18b7e36506d528b95 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Thu, 2 Feb 2017 19:47:02 +0100 Subject: [PATCH 29/70] Rm due to new patch from Dmitry. --- cdist/conf/type/__hosts/man.rst | 55 ------------------- cdist/conf/type/__hosts/manifest | 49 ----------------- .../conf/type/__hosts/parameter/default/state | 1 - cdist/conf/type/__hosts/parameter/optional | 2 - 4 files changed, 107 deletions(-) delete mode 100644 cdist/conf/type/__hosts/man.rst delete mode 100755 cdist/conf/type/__hosts/manifest delete mode 100644 cdist/conf/type/__hosts/parameter/default/state delete mode 100644 cdist/conf/type/__hosts/parameter/optional diff --git a/cdist/conf/type/__hosts/man.rst b/cdist/conf/type/__hosts/man.rst deleted file mode 100644 index f89a619c..00000000 --- a/cdist/conf/type/__hosts/man.rst +++ /dev/null @@ -1,55 +0,0 @@ -cdist-type__hosts(7) -==================== - -NAME ----- - -cdist-type__hosts - manage entries in /etc/hosts - -DESCRIPTION ------------ - -Add or remove entries from */etc/hosts* file. - -OPTIONAL PARAMETERS -------------------- - -state - - If state is ``present``, make *object_id* resolve to *ip*. If - state is ``absent``, *object_id* will no longer resolve to - anything via */etc/hosts*. - -ip - - IP address, to which hostname (=\ *object_id*) must resolve. If - state is ``present``, this parameter is mandatory, if state is - ``absent``, this parameter is silently ignored. - -EXAMPLES --------- - -.. code-block:: sh - - # Now `funny' resolves to 192.168.1.76, - __hosts funny --ip 192.168.1.76 - # and `happy' does not resolve (at least via /etc/hosts) - __hosts happy --state absent - -SEE ALSO --------- - -:strong:`hosts`\ (5) - -AUTHORS -------- - -Dmitry Bogatov - - -COPYING -------- - -Copyright (C) 2015,2016 Dmitry Bogatov. Free use of this software is granted -under the terms of the GNU General Public License version 3 or later -(GPLv3+). diff --git a/cdist/conf/type/__hosts/manifest b/cdist/conf/type/__hosts/manifest deleted file mode 100755 index 99a06c09..00000000 --- a/cdist/conf/type/__hosts/manifest +++ /dev/null @@ -1,49 +0,0 @@ -#!/bin/sh -# Copyright (C) 2015 Bogatov Dmitry -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -hostname="$__object_id" -state="$(cat "$__object/parameter/state")" - -# First remove all lines for given hostname and then insert again. -# Otherwise, we risk having multiple entries for same hostname. -# -# There is a corner case, which we do not handle. Namely, /etc/hosts -# format allows several host names on single line, like following: -# -# 192.168.15.16 foo bar -# -# If this type manages hostname `foo', then hostname bar will get erased. - -__line "__hosts/delete/${hostname}" \ - --state absent \ - --regex " ${hostname}[ ]*$" \ - --file /etc/hosts -export require="__line/__hosts/delete/${hostname}" - -case "$state" in - absent) - : # Nothing to do - ;; - present) - ip="$(cat "$__object/parameter/ip")" - __line "__hosts/insert/${hostname}" \ - --line "${ip} ${hostname}" \ - --file /etc/hosts - ;; - *) - echo "ERROR: type (${__type##*/}) does not support state \`$state'" - exit 1 -esac diff --git a/cdist/conf/type/__hosts/parameter/default/state b/cdist/conf/type/__hosts/parameter/default/state deleted file mode 100644 index e7f6134f..00000000 --- a/cdist/conf/type/__hosts/parameter/default/state +++ /dev/null @@ -1 +0,0 @@ -present diff --git a/cdist/conf/type/__hosts/parameter/optional b/cdist/conf/type/__hosts/parameter/optional deleted file mode 100644 index 411fc5d2..00000000 --- a/cdist/conf/type/__hosts/parameter/optional +++ /dev/null @@ -1,2 +0,0 @@ -state -ip From c4c2d45e5956cab0d044cff93edc47ffd59f43fe Mon Sep 17 00:00:00 2001 From: Dmitry Bogatov Date: Thu, 2 Feb 2017 10:51:21 +0300 Subject: [PATCH 30/70] New type: __hosts --- cdist/conf/type/__hosts/man.rst | 57 +++++++++++++++++++ cdist/conf/type/__hosts/manifest | 29 ++++++++++ .../conf/type/__hosts/parameter/default/state | 1 + cdist/conf/type/__hosts/parameter/optional | 2 + docs/changelog | 1 + 5 files changed, 90 insertions(+) create mode 100644 cdist/conf/type/__hosts/man.rst create mode 100755 cdist/conf/type/__hosts/manifest create mode 100644 cdist/conf/type/__hosts/parameter/default/state create mode 100644 cdist/conf/type/__hosts/parameter/optional diff --git a/cdist/conf/type/__hosts/man.rst b/cdist/conf/type/__hosts/man.rst new file mode 100644 index 00000000..20f463e7 --- /dev/null +++ b/cdist/conf/type/__hosts/man.rst @@ -0,0 +1,57 @@ +cdist-type__hosts(7) +==================== + +NAME +---- + +cdist-type__hosts - manage entries in /etc/hosts + +DESCRIPTION +----------- + +Add or remove entries from */etc/hosts* file. + +OPTIONAL PARAMETERS +------------------- + +state + + If state is ``present``, make *object_id* resolve to *ip*. If + state is ``absent``, *object_id* will no longer resolve via + */etc/hosts*, if it was previously configured with this type. + Manually inserted entries are unaffected. + +ip + + IP address, to which hostname (=\ *object_id*) must resolve. If + state is ``present``, this parameter is mandatory, if state is + ``absent``, this parameter is silently ignored. + +EXAMPLES +-------- + +.. code-block:: sh + + # Now `funny' resolves to 192.168.1.76, + __hosts funny --ip 192.168.1.76 + # and `happy' no longer resolve via /etc/hosts if it was + # previously configured via __hosts. + __hosts happy --state absent + +SEE ALSO +-------- + +:strong:`hosts`\ (5) + +AUTHORS +------- + +Dmitry Bogatov + + +COPYING +------- + +Copyright (C) 2015,2016 Dmitry Bogatov. Free use of this software is granted +under the terms of the GNU General Public License version 3 or later +(GPLv3+). diff --git a/cdist/conf/type/__hosts/manifest b/cdist/conf/type/__hosts/manifest new file mode 100755 index 00000000..6fa21608 --- /dev/null +++ b/cdist/conf/type/__hosts/manifest @@ -0,0 +1,29 @@ +#!/bin/sh +# Copyright (C) 2015 Bogatov Dmitry +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +set -ue + +hostname="$__object_id" +state="$(cat "$__object/parameter/state")" +marker="# __hosts/$hostname" + +set -- "__hosts/$hostname" --file /etc/hosts --state "$state" + +if [ "$state" = absent ] ; then + __line "$@" --regex "$marker" +else + ip="$(cat "$__object/parameter/ip")" + __line "$@" --line "$ip $hostname $marker" +fi diff --git a/cdist/conf/type/__hosts/parameter/default/state b/cdist/conf/type/__hosts/parameter/default/state new file mode 100644 index 00000000..e7f6134f --- /dev/null +++ b/cdist/conf/type/__hosts/parameter/default/state @@ -0,0 +1 @@ +present diff --git a/cdist/conf/type/__hosts/parameter/optional b/cdist/conf/type/__hosts/parameter/optional new file mode 100644 index 00000000..411fc5d2 --- /dev/null +++ b/cdist/conf/type/__hosts/parameter/optional @@ -0,0 +1,2 @@ +state +ip diff --git a/docs/changelog b/docs/changelog index 6b869256..44631046 100644 --- a/docs/changelog +++ b/docs/changelog @@ -8,6 +8,7 @@ next: * Type __cron: Fix filter for new cron on sles12 sp2 (Daniel Heule) * Type __docker: Support absent state (Dominique Roux) * Type __docker_compose: Support absent state (Dominique Roux) + * New type: __hosts (Dmitry Bogatov) 4.4.1: 2016-12-17 * Documentation: Update docs for types that used man.rst as symbolic links (Darko Poljak) From 0eda926b8cfd8b66fd9bb40964254f5a2c81eb46 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Thu, 2 Feb 2017 19:49:39 +0100 Subject: [PATCH 31/70] Fix changelog. --- docs/changelog | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/changelog b/docs/changelog index 44631046..e50ed243 100644 --- a/docs/changelog +++ b/docs/changelog @@ -2,7 +2,6 @@ Changelog --------- next: - * New type: __hosts: manage entries in /etc/hosts (Dmitry Bogatov) * Core: Fix suppression of manifests' outputs (Darko Poljak) * Type __user_groups: Support FreeBSD (Andres Erbsen) * Type __cron: Fix filter for new cron on sles12 sp2 (Daniel Heule) From 72d73e307d020260d8c22ffde8626d5391235d57 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Thu, 2 Feb 2017 19:50:51 +0100 Subject: [PATCH 32/70] Fix changelog. --- docs/changelog | 1 - 1 file changed, 1 deletion(-) diff --git a/docs/changelog b/docs/changelog index e50ed243..93e6e24f 100644 --- a/docs/changelog +++ b/docs/changelog @@ -43,7 +43,6 @@ next: * Type __filesystem: Spelling fixes (Dmitry Bogatov) * Core: Add target_host file to cache since cache dir name can be hash (Darko Poljak) * Core: Improve hostfile: support comments, skip empty lines (Darko Poljak) ->>>>>>> ungleich/master 4.3.0: 2016-08-19 * Documentation: Add Parallelization chapter (Darko Poljak) From d5b12467910afaf90146ed8f9f31ddf5f5029fb1 Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Thu, 16 Feb 2017 22:43:27 +0100 Subject: [PATCH 33/70] change ControlPersist from 125 to 10 seconds Signed-off-by: Steven Armstrong --- cdist/util/remoteutil.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cdist/util/remoteutil.py b/cdist/util/remoteutil.py index c18d6705..2bd12fdf 100644 --- a/cdist/util/remoteutil.py +++ b/cdist/util/remoteutil.py @@ -36,7 +36,7 @@ def inspect_ssh_mux_opts(): wanted_mux_opts = { "ControlPath": "{}", "ControlMaster": "auto", - "ControlPersist": "125", + "ControlPersist": "10", } mux_opts = " ".join([" -o {}={}".format( x, wanted_mux_opts[x]) for x in wanted_mux_opts]) From 4a7ef82bf88efa579f6c1b102f96c5185b0400db Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Thu, 16 Feb 2017 23:16:16 +0100 Subject: [PATCH 34/70] cant depend on build-helper to have cdist.version module Signed-off-by: Steven Armstrong --- setup.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index f29a8998..b79e8340 100644 --- a/setup.py +++ b/setup.py @@ -1,9 +1,20 @@ from distutils.core import setup -import cdist import os import re +# Ensure version is present - the bundled/shipped version contains a static version, +# the git version contains a dynamic version +try: + import cdist.version +except ImportError: + import subprocess + version = subprocess.getoutput('git describe') + with open('cdist/version.py', 'w') as fd: + fd.write('VERSION = "%s"\n' % version) + +import cdist + def data_finder(data_dir): entries = [] for name in os.listdir(data_dir): From d10ba1e587ec91a78ed01dfe5e56f0707e78f114 Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Thu, 16 Feb 2017 23:38:24 +0100 Subject: [PATCH 35/70] Revert "cant depend on build-helper to have cdist.version module" This reverts commit 4a7ef82bf88efa579f6c1b102f96c5185b0400db. --- setup.py | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/setup.py b/setup.py index b79e8340..f29a8998 100644 --- a/setup.py +++ b/setup.py @@ -1,20 +1,9 @@ from distutils.core import setup +import cdist import os import re -# Ensure version is present - the bundled/shipped version contains a static version, -# the git version contains a dynamic version -try: - import cdist.version -except ImportError: - import subprocess - version = subprocess.getoutput('git describe') - with open('cdist/version.py', 'w') as fd: - fd.write('VERSION = "%s"\n' % version) - -import cdist - def data_finder(data_dir): entries = [] for name in os.listdir(data_dir): From 448126f4989a69a1f2159e8d035ead7032cf2dc0 Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Fri, 17 Feb 2017 12:31:22 +0100 Subject: [PATCH 36/70] no need to log stdout at log level info Signed-off-by: Steven Armstrong --- cdist/exec/local.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cdist/exec/local.py b/cdist/exec/local.py index fd764378..e078dbd2 100644 --- a/cdist/exec/local.py +++ b/cdist/exec/local.py @@ -213,7 +213,7 @@ class Local(object): try: if save_output: output, errout = exec_util.call_get_output(command, env=env) - self.log.info("Local stdout: {}".format(output)) + self.log.debug("Local stdout: {}".format(output)) # Currently, stderr is not captured. # self.log.debug("Local stderr: {}".format(errout)) if return_output: From 6d277ef1f1be1b4ab6e2cacbe5912cd4dad7541b Mon Sep 17 00:00:00 2001 From: Dmitry Bogatov Date: Tue, 14 Feb 2017 10:23:19 +0300 Subject: [PATCH 37/70] New type: __dot_file --- cdist/conf/type/__dot_file/explorer/home | 27 +++++++ .../type/__dot_file/explorer/primary_group | 21 ++++++ cdist/conf/type/__dot_file/man.rst | 75 +++++++++++++++++++ cdist/conf/type/__dot_file/manifest | 65 ++++++++++++++++ .../type/__dot_file/parameter/default/mode | 1 + cdist/conf/type/__dot_file/parameter/optional | 3 + cdist/conf/type/__dot_file/parameter/required | 1 + docs/changelog | 1 + 8 files changed, 194 insertions(+) create mode 100755 cdist/conf/type/__dot_file/explorer/home create mode 100755 cdist/conf/type/__dot_file/explorer/primary_group create mode 100644 cdist/conf/type/__dot_file/man.rst create mode 100755 cdist/conf/type/__dot_file/manifest create mode 100644 cdist/conf/type/__dot_file/parameter/default/mode create mode 100644 cdist/conf/type/__dot_file/parameter/optional create mode 100644 cdist/conf/type/__dot_file/parameter/required diff --git a/cdist/conf/type/__dot_file/explorer/home b/cdist/conf/type/__dot_file/explorer/home new file mode 100755 index 00000000..132cfc71 --- /dev/null +++ b/cdist/conf/type/__dot_file/explorer/home @@ -0,0 +1,27 @@ +#!/bin/sh +# Copyright (C) 2016 Dmitry Bogatov + +# Author: Dmitry Bogatov + +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 3 +# of the License, or (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +set -eu + +user="$(cat "${__object}/parameter/user")" + +if which getent >/dev/null 2>&1; then + line=$(getent passwd "${user}") +else + line=$(grep "^${user}:" /etc/passwd) +fi +printf '%s' "$line" | cut -d: -f6 diff --git a/cdist/conf/type/__dot_file/explorer/primary_group b/cdist/conf/type/__dot_file/explorer/primary_group new file mode 100755 index 00000000..30b303ac --- /dev/null +++ b/cdist/conf/type/__dot_file/explorer/primary_group @@ -0,0 +1,21 @@ +#!/bin/sh +# Copyright (C) 2016 Dmitry Bogatov + +# Author: Dmitry Bogatov + +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 3 +# of the License, or (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +set -eu + +user="$(cat "${__object}/parameter/user")" +id -gn "${user}" diff --git a/cdist/conf/type/__dot_file/man.rst b/cdist/conf/type/__dot_file/man.rst new file mode 100644 index 00000000..211c34a5 --- /dev/null +++ b/cdist/conf/type/__dot_file/man.rst @@ -0,0 +1,75 @@ +cdist-type__dot_file(7) +======================== + +NAME +---- + +cdist-type__dot_file - install file under user's home directory + +DESCRIPTION +----------- + +This type installs a file (=\ *__object_id*) under user's home directory, +providing a way to install per-user configuration files. File owner +and group is deduced from user, for who file is installed. + +Unlike regular __file type, you do not need make any assumptions, +where user's home directory is. + +REQUIRED PARAMETERS +------------------- + +user + + User, for who file is installed + +OPTIONAL PARAMETERS +------------------- + +mode + + forwarded to :bold:`__file` type + +state + + forwarded to :bold:`__file` type + +source + + forwarded to :bold:`__file` type + +MESSAGES +-------- + +This type inherits all messages from :bold:`file` type, and do not add +any new. + +EXAMPLES +-------- + +.. code-block:: sh + + # Install .forward file for user 'alice'. Since state is 'present', + # user is not meant to edit this file, all changes will be overridden. + # It is good idea to put warning about it in file itself. + __dot_file .forward --user alice --source "$__files/forward" + + # Install .muttrc for user 'bob', if not already present. User can safely + # edit it, his changes will not be overwritten. + __dot_file .muttrc --user bob --source "$__files/recommended_mutt_config" --state exists + + + # Install default xmonad config for user 'eve'. Parent directory is created automatically. + __dot_file .xmonad/xmonad.hs --user eve --state exists --source "$__files/xmonad.hs" + +SEE ALSO +-------- + +**cdist-type**\ (7), **cdist-type__file**\ (7) + +COPYING +------- + +Copyright (C) 2015 Dmitry Bogatov. Free use of this software is granted +under the terms of the GNU General Public License version 3 or later +(GPLv3+). diff --git a/cdist/conf/type/__dot_file/manifest b/cdist/conf/type/__dot_file/manifest new file mode 100755 index 00000000..4bc9f179 --- /dev/null +++ b/cdist/conf/type/__dot_file/manifest @@ -0,0 +1,65 @@ +#!/bin/sh +# +# Copyright (C) 2016 Bogatov Dmitry +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +set -eu + +user="$(cat "${__object}/parameter/user")" +home="$(cat "${__object}/explorer/home")" +primary_group="$(cat "${__object}/explorer/primary_group")" + +# Create parent directory. Type __directory has flag 'parents', but it +# will leave us with root-owned directory in user home, which is not +# acceptable. So we create parent directories one-by-one. XXX: maybe +# it should be fixed in '__directory'? +set -- +subpath=${__object_id} +while subpath="$(dirname "${subpath}")" ; do + [ "${subpath}" = . ] && break + set -- "${subpath}" "$@" +done +unset subpath + +export CDIST_ORDER_DEPENDENCY +for dir ; do + __directory "${home}/${dir}" \ + --group "${primary_group}" \ + --owner "${user}" +done + +# These parameters are forwarded to __file type. 'mode' is always +# present, since it have been given default. + +set -- +for p in state mode source ; do + if [ -f "${__object}/parameter/${p}" ] ; then + value="$(cat "${__object}/parameter/${p}")" + set -- "$@" "--${p}" "${value}" + unset value + fi +done + +# If source is `-' we can't just forward it, since stdin is already +# captured by __dot_file. So, we replace '-' with "$__object/stdin". +# +# It means that it is possible for __file to receive --source +# parameter twice, but, since latest wins, it is okay. +source="$(cat "${__object}/parameter/source")" +if [ "${source}" = "-" ] ; then + set -- "$@" --source "${__object}/stdin" +fi +unset source + +__file "${home}/${__object_id}" --owner "$user" --group "$primary_group" "$@" diff --git a/cdist/conf/type/__dot_file/parameter/default/mode b/cdist/conf/type/__dot_file/parameter/default/mode new file mode 100644 index 00000000..e9f960cf --- /dev/null +++ b/cdist/conf/type/__dot_file/parameter/default/mode @@ -0,0 +1 @@ +600 diff --git a/cdist/conf/type/__dot_file/parameter/optional b/cdist/conf/type/__dot_file/parameter/optional new file mode 100644 index 00000000..ccab9fa6 --- /dev/null +++ b/cdist/conf/type/__dot_file/parameter/optional @@ -0,0 +1,3 @@ +state +mode +source diff --git a/cdist/conf/type/__dot_file/parameter/required b/cdist/conf/type/__dot_file/parameter/required new file mode 100644 index 00000000..4eb8387f --- /dev/null +++ b/cdist/conf/type/__dot_file/parameter/required @@ -0,0 +1 @@ +user diff --git a/docs/changelog b/docs/changelog index 93e6e24f..f3e4986c 100644 --- a/docs/changelog +++ b/docs/changelog @@ -8,6 +8,7 @@ next: * Type __docker: Support absent state (Dominique Roux) * Type __docker_compose: Support absent state (Dominique Roux) * New type: __hosts (Dmitry Bogatov) + * New type: __dot_file (Dmitry Bogatov) 4.4.1: 2016-12-17 * Documentation: Update docs for types that used man.rst as symbolic links (Darko Poljak) From da4118dcf3101b0b3a2b85ab060dc81c8c78d283 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Wed, 8 Mar 2017 19:07:02 +0100 Subject: [PATCH 38/70] pep8 --- cdist/argparse.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cdist/argparse.py b/cdist/argparse.py index e2a13c38..3791e779 100644 --- a/cdist/argparse.py +++ b/cdist/argparse.py @@ -86,10 +86,10 @@ def get_parsers(): parser['loglevel'].add_argument( '-v', '--verbose', help=('Increase the verbosity level. Every instance of -v ' - 'increments the verbosity level by one. Its default value is ' - '0. There are 4 levels of verbosity. The order of levels ' - 'from the lowest to the highest are: ERROR (0), WARNING (1), ' - 'INFO (2) and DEBUG (3 or higher).'), + 'increments the verbosity level by one. Its default value ' + 'is 0. There are 4 levels of verbosity. The order of levels ' + 'from the lowest to the highest are: ERROR (0), ' + 'WARNING (1), INFO (2) and DEBUG (3 or higher).'), action='count', default=0) parser['beta'] = argparse.ArgumentParser(add_help=False) From 303c681bff7053f2756736d34f639f0f172571b6 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Wed, 8 Mar 2017 19:08:59 +0100 Subject: [PATCH 39/70] Release 4.4.2 --- docs/changelog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/changelog b/docs/changelog index f3e4986c..b61f818b 100644 --- a/docs/changelog +++ b/docs/changelog @@ -1,7 +1,7 @@ Changelog --------- -next: +4.4.2: 2017-03-08 * Core: Fix suppression of manifests' outputs (Darko Poljak) * Type __user_groups: Support FreeBSD (Andres Erbsen) * Type __cron: Fix filter for new cron on sles12 sp2 (Daniel Heule) From 57032af3564d5521a86f331704161664221b0c64 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Wed, 8 Mar 2017 19:16:23 +0100 Subject: [PATCH 40/70] Fix code-block argument missing. --- cdist/conf/type/__postgres_extension/man.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cdist/conf/type/__postgres_extension/man.rst b/cdist/conf/type/__postgres_extension/man.rst index ead51c83..79645b2b 100644 --- a/cdist/conf/type/__postgres_extension/man.rst +++ b/cdist/conf/type/__postgres_extension/man.rst @@ -14,13 +14,13 @@ The object you need to pass to __postgres_extension consists of the database name and the extension name joined by a colon in the following form: -.. code-block:: +.. code-block:: sh dbname:extension f.ex. -.. code-block:: +.. code-block:: sh rails_test:unaccent From 517493ea9256fd0e934f46bc035cfd71fdda4610 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Wed, 8 Mar 2017 19:36:34 +0100 Subject: [PATCH 41/70] reStructuredText fixes. --- cdist/conf/type/__dot_file/man.rst | 14 +++++--------- cdist/conf/type/__hosts/man.rst | 2 -- cdist/conf/type/__package_dpkg/man.rst | 8 ++++---- 3 files changed, 9 insertions(+), 15 deletions(-) diff --git a/cdist/conf/type/__dot_file/man.rst b/cdist/conf/type/__dot_file/man.rst index 211c34a5..ae65eb95 100644 --- a/cdist/conf/type/__dot_file/man.rst +++ b/cdist/conf/type/__dot_file/man.rst @@ -20,28 +20,24 @@ REQUIRED PARAMETERS ------------------- user - User, for who file is installed OPTIONAL PARAMETERS ------------------- mode - - forwarded to :bold:`__file` type + forwarded to :strong:`__file` type state - - forwarded to :bold:`__file` type + forwarded to :strong:`__file` type source - - forwarded to :bold:`__file` type + forwarded to :strong:`__file` type MESSAGES -------- -This type inherits all messages from :bold:`file` type, and do not add +This type inherits all messages from :strong:`file` type, and do not add any new. EXAMPLES @@ -65,7 +61,7 @@ EXAMPLES SEE ALSO -------- -**cdist-type**\ (7), **cdist-type__file**\ (7) +**cdist-type__file**\ (7) COPYING ------- diff --git a/cdist/conf/type/__hosts/man.rst b/cdist/conf/type/__hosts/man.rst index 20f463e7..bece7967 100644 --- a/cdist/conf/type/__hosts/man.rst +++ b/cdist/conf/type/__hosts/man.rst @@ -15,14 +15,12 @@ OPTIONAL PARAMETERS ------------------- state - If state is ``present``, make *object_id* resolve to *ip*. If state is ``absent``, *object_id* will no longer resolve via */etc/hosts*, if it was previously configured with this type. Manually inserted entries are unaffected. ip - IP address, to which hostname (=\ *object_id*) must resolve. If state is ``present``, this parameter is mandatory, if state is ``absent``, this parameter is silently ignored. diff --git a/cdist/conf/type/__package_dpkg/man.rst b/cdist/conf/type/__package_dpkg/man.rst index 65a695b5..df2d86a7 100644 --- a/cdist/conf/type/__package_dpkg/man.rst +++ b/cdist/conf/type/__package_dpkg/man.rst @@ -8,16 +8,16 @@ cdist-type__package_dpkg - Manage packages with dpkg DESCRIPTION ----------- -__package_dpkg is used on Debian and variants (like Ubuntu) to -install packages that are provided locally as *.deb files. +This type is used on Debian and variants (like Ubuntu) to +install packages that are provided locally as \*.deb files. -The object given to __package_dpkg must be the name of the deb package. +The object given to this type must be the name of the deb package. REQUIRED PARAMETERS ------------------- source - path to the *.deb package + path to the \*.deb package EXAMPLES -------- From 46bbafa5095bd3387c82f3d0ad6b42f8d908b699 Mon Sep 17 00:00:00 2001 From: Kamila Souckova Date: Wed, 22 Mar 2017 12:30:00 +0100 Subject: [PATCH 42/70] __start_on_boot: add support for devuan --- cdist/conf/type/__start_on_boot/gencode-remote | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cdist/conf/type/__start_on_boot/gencode-remote b/cdist/conf/type/__start_on_boot/gencode-remote index e77132c9..45de5465 100644 --- a/cdist/conf/type/__start_on_boot/gencode-remote +++ b/cdist/conf/type/__start_on_boot/gencode-remote @@ -54,6 +54,9 @@ case "$state_should" in ;; esac ;; + devuan) + echo "update-rc.d \"$name\" defaults >/dev/null" + ;; gentoo) echo rc-update add \"$name\" \"$target_runlevel\" From d3aafc45232cd84a0352b17d1b530974c118c815 Mon Sep 17 00:00:00 2001 From: Dominique Roux Date: Wed, 19 Apr 2017 11:51:04 +0200 Subject: [PATCH 43/70] changed docker-compose version to 1.12.0 --- cdist/conf/type/__docker_compose/parameter/default/version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cdist/conf/type/__docker_compose/parameter/default/version b/cdist/conf/type/__docker_compose/parameter/default/version index f8e233b2..0eed1a29 100644 --- a/cdist/conf/type/__docker_compose/parameter/default/version +++ b/cdist/conf/type/__docker_compose/parameter/default/version @@ -1 +1 @@ -1.9.0 +1.12.0 From 21a29ab5aa7926a478ad9a031532059337af95f5 Mon Sep 17 00:00:00 2001 From: Kamila Souckova Date: Thu, 4 May 2017 17:29:07 +0200 Subject: [PATCH 44/70] add __go_get, __golang_from_vendor --- cdist/conf/explorer/kernel_name | 1 + .../conf/type/__go_get/explorer/go-executable | 3 +++ cdist/conf/type/__go_get/gencode-remote | 8 ++++++ cdist/conf/type/__go_get/manifest | 17 ++++++++++++ .../type/__golang_from_vendor/gencode-remote | 26 +++++++++++++++++++ cdist/conf/type/__golang_from_vendor/manifest | 1 + .../parameter/default/version | 1 + .../__golang_from_vendor/parameter/optional | 1 + .../conf/type/__golang_from_vendor/singleton | 0 9 files changed, 58 insertions(+) create mode 100644 cdist/conf/explorer/kernel_name create mode 100644 cdist/conf/type/__go_get/explorer/go-executable create mode 100644 cdist/conf/type/__go_get/gencode-remote create mode 100644 cdist/conf/type/__go_get/manifest create mode 100644 cdist/conf/type/__golang_from_vendor/gencode-remote create mode 100644 cdist/conf/type/__golang_from_vendor/manifest create mode 100644 cdist/conf/type/__golang_from_vendor/parameter/default/version create mode 100644 cdist/conf/type/__golang_from_vendor/parameter/optional create mode 100644 cdist/conf/type/__golang_from_vendor/singleton diff --git a/cdist/conf/explorer/kernel_name b/cdist/conf/explorer/kernel_name new file mode 100644 index 00000000..98ebac2a --- /dev/null +++ b/cdist/conf/explorer/kernel_name @@ -0,0 +1 @@ +uname -s diff --git a/cdist/conf/type/__go_get/explorer/go-executable b/cdist/conf/type/__go_get/explorer/go-executable new file mode 100644 index 00000000..4c84ce07 --- /dev/null +++ b/cdist/conf/type/__go_get/explorer/go-executable @@ -0,0 +1,3 @@ +[ -f /etc/environment ] && . /etc/environment +[ -f /etc/profile ] && . /etc/profile +go version 2>/dev/null || true diff --git a/cdist/conf/type/__go_get/gencode-remote b/cdist/conf/type/__go_get/gencode-remote new file mode 100644 index 00000000..5f1d3aae --- /dev/null +++ b/cdist/conf/type/__go_get/gencode-remote @@ -0,0 +1,8 @@ +package=$__object_id + +cat<&2 && exit 1 + +os=$(cat "$__global/explorer/os") +case $os in + debian|devuan|ubuntu) + __package build-essential + ;; + *) + echo "__go_get: Don't know how to install g++ on $os" >&2 + echo "__go_get: Send a pull request or contact to add support for $os." >&2 + exit 1 + ;; +esac + diff --git a/cdist/conf/type/__golang_from_vendor/gencode-remote b/cdist/conf/type/__golang_from_vendor/gencode-remote new file mode 100644 index 00000000..e372bf61 --- /dev/null +++ b/cdist/conf/type/__golang_from_vendor/gencode-remote @@ -0,0 +1,26 @@ +#!/bin/sh + +version=$(cat "$__object/parameter/version") + +kernel_name=$(cat "$__global/explorer/kernel_name" | tr '[:upper:]' '[:lower:]') +machine=$(cat "$__global/explorer/machine") +case $machine in + x86_64|amd64) + arch=amd64 + ;; + x86) + arch=386 + ;; + *) + arch=$machine # at least try... + ;; +esac + +PACKAGE="go${version}.${kernel_name}-${arch}" +URL="https://storage.googleapis.com/golang/${PACKAGE}.tar.gz" +cat </dev/null)" = "xgo$version" ] && exit 0 # already there +wget --no-verbose "$URL" -O "/tmp/${PACKAGE}.tar.gz" +rm -rf /usr/local/go +tar -C /usr/local -xzf /tmp/${PACKAGE}.tar.gz +EOF diff --git a/cdist/conf/type/__golang_from_vendor/manifest b/cdist/conf/type/__golang_from_vendor/manifest new file mode 100644 index 00000000..9d320830 --- /dev/null +++ b/cdist/conf/type/__golang_from_vendor/manifest @@ -0,0 +1 @@ +__line go_in_path --line 'export PATH=/usr/local/go/bin:$PATH' --file /etc/profile diff --git a/cdist/conf/type/__golang_from_vendor/parameter/default/version b/cdist/conf/type/__golang_from_vendor/parameter/default/version new file mode 100644 index 00000000..a8fdfda1 --- /dev/null +++ b/cdist/conf/type/__golang_from_vendor/parameter/default/version @@ -0,0 +1 @@ +1.8.1 diff --git a/cdist/conf/type/__golang_from_vendor/parameter/optional b/cdist/conf/type/__golang_from_vendor/parameter/optional new file mode 100644 index 00000000..088eda41 --- /dev/null +++ b/cdist/conf/type/__golang_from_vendor/parameter/optional @@ -0,0 +1 @@ +version diff --git a/cdist/conf/type/__golang_from_vendor/singleton b/cdist/conf/type/__golang_from_vendor/singleton new file mode 100644 index 00000000..e69de29b From 8d4fd9e7d81acfc2feee0f65cca3095185d73aa7 Mon Sep 17 00:00:00 2001 From: Kamila Souckova Date: Thu, 4 May 2017 17:43:03 +0200 Subject: [PATCH 45/70] add __go_get, __golang_from_vendor manpages --- cdist/conf/type/__go_get/man.rst | 48 ++++++++++++++++++++ cdist/conf/type/__golang_from_vendor/man.rst | 48 ++++++++++++++++++++ 2 files changed, 96 insertions(+) create mode 100644 cdist/conf/type/__go_get/man.rst create mode 100644 cdist/conf/type/__golang_from_vendor/man.rst diff --git a/cdist/conf/type/__go_get/man.rst b/cdist/conf/type/__go_get/man.rst new file mode 100644 index 00000000..66d9bdba --- /dev/null +++ b/cdist/conf/type/__go_get/man.rst @@ -0,0 +1,48 @@ +cdist-type__go_get(7) +===================== + +NAME +---- +cdist-type__go_get - Install go packages with go get + + +DESCRIPTION +----------- +This cdist type allows you to install golang packages with go get. +A sufficiently recent version of go must be present on the system. + +The object ID is the go package to be installed. + + +REQUIRED PARAMETERS +------------------- +None. + + +OPTIONAL PARAMETERS +------------------- +None. + + +EXAMPLES +-------- + +.. code-block:: sh + + __go_get github.com/prometheus/prometheus/cmd/... + + # usually you'd need to require golang from somewhere: + require="__golang_from_vendor" __go_get github.com/prometheus/prometheus/cmd/... + + +AUTHORS +------- +Kamila Součková + + +COPYING +------- +Copyright \(C) 2017 Kamila Součková. You can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation, either version 3 of the +License, or (at your option) any later version. diff --git a/cdist/conf/type/__golang_from_vendor/man.rst b/cdist/conf/type/__golang_from_vendor/man.rst new file mode 100644 index 00000000..070710c1 --- /dev/null +++ b/cdist/conf/type/__golang_from_vendor/man.rst @@ -0,0 +1,48 @@ +cdist-type__golang_from_vendor(7) +===================== + +NAME +---- +cdist-type__golang_from_vendor - Install any version of golang from golang.org + + +DESCRIPTION +----------- +This cdist type allows you to install golang from archives provided by https://golang.org/dl/. + +See https://golang.org/dl/ for the list of supported versions, operating systems and architectures. + +This is a singleton type. + + +REQUIRED PARAMETERS +------------------- +None. + + +OPTIONAL PARAMETERS +------------------- +version + The golang version to install, defaults to 1.8.1 + + +EXAMPLES +-------- + +.. code-block:: sh + + __golang_from_vendor --version 1.8.1 + + + +AUTHORS +------- +Kamila Součková + + +COPYING +------- +Copyright \(C) 2017 Kamila Součková. You can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation, either version 3 of the +License, or (at your option) any later version. From d1fae4a75e84cdf043d0995609438b99ad950227 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamila=20Sou=C4=8Dkov=C3=A1?= Date: Fri, 5 May 2017 14:57:18 +0200 Subject: [PATCH 46/70] Update changelog --- docs/changelog | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/changelog b/docs/changelog index b61f818b..89c0c9b1 100644 --- a/docs/changelog +++ b/docs/changelog @@ -1,6 +1,10 @@ Changelog --------- +next: + * Type __golang_from_vendor: Install golang from https://golang.org/dl/ (Kamila Součková) + * Type __go_get: Install go packages using go get (Kamila Součková) + 4.4.2: 2017-03-08 * Core: Fix suppression of manifests' outputs (Darko Poljak) * Type __user_groups: Support FreeBSD (Andres Erbsen) From 0aec30907760099fa9a029cb67f9e25c68485695 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamila=20Sou=C4=8Dkov=C3=A1?= Date: Fri, 5 May 2017 14:58:00 +0200 Subject: [PATCH 47/70] Update changelog --- docs/changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog b/docs/changelog index 89c0c9b1..4ef58429 100644 --- a/docs/changelog +++ b/docs/changelog @@ -4,6 +4,7 @@ Changelog next: * Type __golang_from_vendor: Install golang from https://golang.org/dl/ (Kamila Součková) * Type __go_get: Install go packages using go get (Kamila Součková) + * Explorer kernel_name: uname -s 4.4.2: 2017-03-08 * Core: Fix suppression of manifests' outputs (Darko Poljak) From 3e83ee82c9d2efbbcda64c3ae58470bdfa85f89b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamila=20Sou=C4=8Dkov=C3=A1?= Date: Fri, 5 May 2017 14:58:27 +0200 Subject: [PATCH 48/70] Update changelog --- docs/changelog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/changelog b/docs/changelog index 4ef58429..292472c9 100644 --- a/docs/changelog +++ b/docs/changelog @@ -4,7 +4,7 @@ Changelog next: * Type __golang_from_vendor: Install golang from https://golang.org/dl/ (Kamila Součková) * Type __go_get: Install go packages using go get (Kamila Součková) - * Explorer kernel_name: uname -s + * Explorer kernel_name: uname -s (Kamila Součková) 4.4.2: 2017-03-08 * Core: Fix suppression of manifests' outputs (Darko Poljak) From abd5f11b989d304946570ec3758d8b7800a903bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamila=20Sou=C4=8Dkov=C3=A1?= Date: Fri, 5 May 2017 15:29:48 +0200 Subject: [PATCH 49/70] man.rst: fix underline --- cdist/conf/type/__golang_from_vendor/man.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cdist/conf/type/__golang_from_vendor/man.rst b/cdist/conf/type/__golang_from_vendor/man.rst index 070710c1..2b4f065e 100644 --- a/cdist/conf/type/__golang_from_vendor/man.rst +++ b/cdist/conf/type/__golang_from_vendor/man.rst @@ -1,5 +1,5 @@ cdist-type__golang_from_vendor(7) -===================== +================================= NAME ---- From fc9d7af18c4d30006f6847d50a32d627ee9f713a Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 16 May 2017 12:09:38 +0200 Subject: [PATCH 50/70] Add Devuan support for __sysctl --- cdist/conf/type/__sysctl/manifest | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cdist/conf/type/__sysctl/manifest b/cdist/conf/type/__sysctl/manifest index dd317806..ac9117c4 100755 --- a/cdist/conf/type/__sysctl/manifest +++ b/cdist/conf/type/__sysctl/manifest @@ -22,7 +22,7 @@ os=$(cat "$__global/explorer/os") case "$os" in - redhat|centos|ubuntu|debian|archlinux) + redhat|centos|ubuntu|debian|devuan|archlinux) : ;; *) From ecc169111c7fb8f1749342f4dc92631c0f39deac Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 16 May 2017 12:10:10 +0200 Subject: [PATCH 51/70] Also update changelog --- docs/changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog b/docs/changelog index 292472c9..524257a7 100644 --- a/docs/changelog +++ b/docs/changelog @@ -5,6 +5,7 @@ next: * Type __golang_from_vendor: Install golang from https://golang.org/dl/ (Kamila Součková) * Type __go_get: Install go packages using go get (Kamila Součková) * Explorer kernel_name: uname -s (Kamila Součková) + * Type __sysctl: Add devuan support (Nico Schottelius) 4.4.2: 2017-03-08 * Core: Fix suppression of manifests' outputs (Darko Poljak) From 1322e85eacdb08bfbd8b3ef6ad785b942cc7b501 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 21 May 2017 20:42:45 +0200 Subject: [PATCH 52/70] A new log file --- docs/dev/logs/2017-04-27.execution-order.org | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 docs/dev/logs/2017-04-27.execution-order.org diff --git a/docs/dev/logs/2017-04-27.execution-order.org b/docs/dev/logs/2017-04-27.execution-order.org new file mode 100644 index 00000000..5ee32062 --- /dev/null +++ b/docs/dev/logs/2017-04-27.execution-order.org @@ -0,0 +1,5 @@ +* After constructs don't exist + Flow as implemented on 2013-04-12 has the problem of not allowing + *after* constructs. +* "Type explorer & manifests only" is broken + Doesn't catch external dependencies From cf0ab2a5bdcd68e1804dd9270f55bd91bd5184e8 Mon Sep 17 00:00:00 2001 From: Kamila Souckova Date: Mon, 29 May 2017 16:23:24 +0200 Subject: [PATCH 53/70] new type: __daemontools_service --- .../conf/type/__daemontools_service/manifest | 31 +++++++++++++++++++ .../parameter/default/log-run | 1 + .../parameter/default/run | 0 .../parameter/default/run-file | 0 .../parameter/default/servicedir | 1 + .../__daemontools_service/parameter/optional | 4 +++ 6 files changed, 37 insertions(+) create mode 100644 cdist/conf/type/__daemontools_service/manifest create mode 100644 cdist/conf/type/__daemontools_service/parameter/default/log-run create mode 100644 cdist/conf/type/__daemontools_service/parameter/default/run create mode 100644 cdist/conf/type/__daemontools_service/parameter/default/run-file create mode 100644 cdist/conf/type/__daemontools_service/parameter/default/servicedir create mode 100644 cdist/conf/type/__daemontools_service/parameter/optional diff --git a/cdist/conf/type/__daemontools_service/manifest b/cdist/conf/type/__daemontools_service/manifest new file mode 100644 index 00000000..34f45545 --- /dev/null +++ b/cdist/conf/type/__daemontools_service/manifest @@ -0,0 +1,31 @@ +#!/bin/sh + +RUN_PREFIX="#!/bin/sh +exec 2>&1 +exec " # mind the space :D + +name=$__object_id +servicedir=$(cat "$__object/parameter/servicedir") +run=$(cat "$__object/parameter/run") +runfile=$(cat "$__object/parameter/run-file") +logrun=$(cat "$__object/parameter/log-run") + +badusage() { + echo "__daemontools_service/$__object_id: exactly one of --run, --run-file must be set" >&2 + exit 1 +} + +[ -z "$run$runfile" ] && badusage +[ -n "$run" ] && [ -n "$runfile" ] && badusage + +__directory $servicedir/$name/log/main --parents + +echo "$RUN_PREFIX$run" | require="__directory/$servicedir/$name/log/main" __config_file "$servicedir/$name/run" \ + --onchange "svc -t '$servicedir/$name' 2>/dev/null" \ + --mode 755 \ + --source "${runfile:--}" + +echo "$RUN_PREFIX$logrun" | require="__directory/$servicedir/$name/log/main" __config_file $servicedir/$name/log/run \ + --onchange "svc -t '$servicedir/$name/log' 2>/dev/null" \ + --mode 755 \ + --source "-" diff --git a/cdist/conf/type/__daemontools_service/parameter/default/log-run b/cdist/conf/type/__daemontools_service/parameter/default/log-run new file mode 100644 index 00000000..80d57a74 --- /dev/null +++ b/cdist/conf/type/__daemontools_service/parameter/default/log-run @@ -0,0 +1 @@ +multilog t ./main diff --git a/cdist/conf/type/__daemontools_service/parameter/default/run b/cdist/conf/type/__daemontools_service/parameter/default/run new file mode 100644 index 00000000..e69de29b diff --git a/cdist/conf/type/__daemontools_service/parameter/default/run-file b/cdist/conf/type/__daemontools_service/parameter/default/run-file new file mode 100644 index 00000000..e69de29b diff --git a/cdist/conf/type/__daemontools_service/parameter/default/servicedir b/cdist/conf/type/__daemontools_service/parameter/default/servicedir new file mode 100644 index 00000000..b74e27f6 --- /dev/null +++ b/cdist/conf/type/__daemontools_service/parameter/default/servicedir @@ -0,0 +1 @@ +/service diff --git a/cdist/conf/type/__daemontools_service/parameter/optional b/cdist/conf/type/__daemontools_service/parameter/optional new file mode 100644 index 00000000..7e54985f --- /dev/null +++ b/cdist/conf/type/__daemontools_service/parameter/optional @@ -0,0 +1,4 @@ +log-run +run +run-file +servicedir From 29bebc4af4944348e4c332b1acb6397e26a36e84 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Wed, 31 May 2017 09:55:33 +0200 Subject: [PATCH 54/70] Shorten ssh control path. On macos the path is too long due to long default TMP dir. --- cdist/config.py | 17 ++++++++++++----- docs/changelog | 1 + 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/cdist/config.py b/cdist/config.py index 6b57e7bf..c25c029b 100644 --- a/cdist/config.py +++ b/cdist/config.py @@ -27,6 +27,8 @@ import time import itertools import tempfile import socket +import atexit +import shutil import cdist import cdist.hostsource @@ -92,7 +94,6 @@ class Config(object): "failed: %s" % e)) args.manifest = initial_manifest_temp_path - import atexit atexit.register(lambda: os.remove(initial_manifest_temp_path)) # default remote cmd patterns @@ -176,8 +177,15 @@ class Config(object): " ".join(failed_hosts)) @classmethod - def _resolve_remote_cmds(cls, args, host_base_path): - control_path = os.path.join(host_base_path, "ssh-control-path") + def _resolve_ssh_control_path(cls): + base_path = tempfile.mkdtemp() + control_path = os.path.join(base_path, "s") + atexit.register(lambda: shutil.rmtree(base_path)) + return control_path + + @classmethod + def _resolve_remote_cmds(cls, args): + control_path = cls._resolve_ssh_control_path() # If we constructed patterns for remote commands then there is # placeholder for ssh ControlPath, format it and we have unique # ControlPath for each host. @@ -200,8 +208,7 @@ class Config(object): log = logging.getLogger(host) try: - remote_exec, remote_copy = cls._resolve_remote_cmds( - args, host_base_path) + remote_exec, remote_copy = cls._resolve_remote_cmds(args) log.debug("remote_exec for host \"{}\": {}".format( host, remote_exec)) log.debug("remote_copy for host \"{}\": {}".format( diff --git a/docs/changelog b/docs/changelog index 524257a7..be0ed2e3 100644 --- a/docs/changelog +++ b/docs/changelog @@ -6,6 +6,7 @@ next: * Type __go_get: Install go packages using go get (Kamila Součková) * Explorer kernel_name: uname -s (Kamila Součková) * Type __sysctl: Add devuan support (Nico Schottelius) + * Core: Shorten ssh control path (Darko Poljak) 4.4.2: 2017-03-08 * Core: Fix suppression of manifests' outputs (Darko Poljak) From 5ec8ac90d9f8e5dd2cafb003e86db9f804863c8a Mon Sep 17 00:00:00 2001 From: Kamila Souckova Date: Wed, 31 May 2017 18:21:24 +0200 Subject: [PATCH 55/70] consul: add http check; add new version --- cdist/conf/type/__consul/files/versions/0.8.1/cksum | 1 + cdist/conf/type/__consul/files/versions/0.8.1/source | 1 + cdist/conf/type/__consul/manifest | 2 +- cdist/conf/type/__consul_agent/manifest | 12 ++++++++---- cdist/conf/type/__consul_service/manifest | 10 ++++++++++ cdist/conf/type/__consul_service/parameter/optional | 1 + 6 files changed, 22 insertions(+), 5 deletions(-) create mode 100644 cdist/conf/type/__consul/files/versions/0.8.1/cksum create mode 100644 cdist/conf/type/__consul/files/versions/0.8.1/source diff --git a/cdist/conf/type/__consul/files/versions/0.8.1/cksum b/cdist/conf/type/__consul/files/versions/0.8.1/cksum new file mode 100644 index 00000000..9125cc8f --- /dev/null +++ b/cdist/conf/type/__consul/files/versions/0.8.1/cksum @@ -0,0 +1 @@ +283033689 36101209 consul diff --git a/cdist/conf/type/__consul/files/versions/0.8.1/source b/cdist/conf/type/__consul/files/versions/0.8.1/source new file mode 100644 index 00000000..92386c7c --- /dev/null +++ b/cdist/conf/type/__consul/files/versions/0.8.1/source @@ -0,0 +1 @@ +https://releases.hashicorp.com/consul/0.8.1/consul_0.8.1_linux_amd64.zip diff --git a/cdist/conf/type/__consul/manifest b/cdist/conf/type/__consul/manifest index b16c5749..7d0e73c5 100755 --- a/cdist/conf/type/__consul/manifest +++ b/cdist/conf/type/__consul/manifest @@ -23,7 +23,7 @@ os=$(cat "$__global/explorer/os") case "$os" in - scientific|centos|redhat|ubuntu|debian|archlinux|gentoo) + scientific|centos|redhat|ubuntu|debian|devuan|archlinux|gentoo) # any linux should work : ;; diff --git a/cdist/conf/type/__consul_agent/manifest b/cdist/conf/type/__consul_agent/manifest index 07bf3b26..64efd366 100755 --- a/cdist/conf/type/__consul_agent/manifest +++ b/cdist/conf/type/__consul_agent/manifest @@ -23,7 +23,7 @@ os=$(cat "$__global/explorer/os") case "$os" in - scientific|centos|debian|redhat|ubuntu) + scientific|centos|debian|devuan|redhat|ubuntu) # whitelist safeguard : ;; @@ -215,7 +215,11 @@ case "$os" in esac ;; - ubuntu) - init_upstart - ;; + devuan) + init_sysvinit debian + ;; + + ubuntu) + init_upstart + ;; esac diff --git a/cdist/conf/type/__consul_service/manifest b/cdist/conf/type/__consul_service/manifest index 9ba64141..4f52d542 100755 --- a/cdist/conf/type/__consul_service/manifest +++ b/cdist/conf/type/__consul_service/manifest @@ -32,6 +32,10 @@ if [ -f "$__object/parameter/check-script" -a ! -f "$__object/parameter/check-in echo "When using --check-script you must also define --check-interval" >&2 exit 1 fi +if [ -f "$__object/parameter/check-http" -a ! -f "$__object/parameter/check-interval" ]; then + echo "When using --check-http you must also define --check-interval" >&2 + exit 1 +fi # Generate json config file ( @@ -52,6 +56,12 @@ for param in $(ls "$__object/parameter/"); do printf ' "ttl": "%s"\n' "$(cat "$__object/parameter/check-ttl")" printf ' }\n' ;; + check-http) + printf ' ,"check": {\n' + printf ' "http": "%s"\n' "$(cat "$__object/parameter/check-http")" + printf ' ,"interval": "%s"\n' "$(cat "$__object/parameter/check-interval")" + printf ' }\n' + ;; tag) # create json array from newline delimited file tags="$(awk '{printf "\""$1"\","}' "$__object/parameter/tag")" diff --git a/cdist/conf/type/__consul_service/parameter/optional b/cdist/conf/type/__consul_service/parameter/optional index 496e31a3..2e3e8b63 100644 --- a/cdist/conf/type/__consul_service/parameter/optional +++ b/cdist/conf/type/__consul_service/parameter/optional @@ -1,3 +1,4 @@ +check-http check-interval check-script check-ttl From 06e1ddcf4712bd6ad6c759ccc43fdea2a0cb8bfe Mon Sep 17 00:00:00 2001 From: Kamila Souckova Date: Wed, 31 May 2017 18:57:21 +0200 Subject: [PATCH 56/70] __consul_agent: mention http-check in man page --- cdist/conf/type/__consul_service/man.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cdist/conf/type/__consul_service/man.rst b/cdist/conf/type/__consul_service/man.rst index bcfe4067..510be3d5 100644 --- a/cdist/conf/type/__consul_service/man.rst +++ b/cdist/conf/type/__consul_service/man.rst @@ -24,6 +24,9 @@ OPTIONAL PARAMETERS check-interval the interval in which the script given with --check-script should be run +check-http + the URL to check for HTTP 200-ish status every --check-interval + check-script the shell command to run every --check-interval From 0b37c79bf4cdca681472a9d4eca5f50aa339c430 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Thu, 1 Jun 2017 09:03:42 +0200 Subject: [PATCH 57/70] Update changelog --- docs/changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog b/docs/changelog index be0ed2e3..db0284a7 100644 --- a/docs/changelog +++ b/docs/changelog @@ -7,6 +7,7 @@ next: * Explorer kernel_name: uname -s (Kamila Součková) * Type __sysctl: Add devuan support (Nico Schottelius) * Core: Shorten ssh control path (Darko Poljak) + * Type __consul: Add new version and add http check (Kamila Součková) 4.4.2: 2017-03-08 * Core: Fix suppression of manifests' outputs (Darko Poljak) From d30103e9d2ea55013517ebd25029a5ab7292c6b5 Mon Sep 17 00:00:00 2001 From: Kamila Souckova Date: Thu, 1 Jun 2017 17:43:43 +0200 Subject: [PATCH 58/70] __daemontools*: add/improve; + add man pages --- .../type/__daemontools/files/init.d-svscan | 63 +++++++++++++++++++ cdist/conf/type/__daemontools/man.rst | 42 +++++++++++++ cdist/conf/type/__daemontools/manifest | 20 ++++++ .../conf/type/__daemontools/parameter/boolean | 1 + .../parameter/default/from-package | 1 + .../parameter/default/install-init-script | 0 .../type/__daemontools/parameter/optional | 1 + cdist/conf/type/__daemontools/singleton | 0 .../type/__daemontools_service/explorer/svc | 1 + cdist/conf/type/__daemontools_service/man.rst | 63 +++++++++++++++++++ .../conf/type/__daemontools_service/manifest | 7 +++ 11 files changed, 199 insertions(+) create mode 100644 cdist/conf/type/__daemontools/files/init.d-svscan create mode 100644 cdist/conf/type/__daemontools/man.rst create mode 100644 cdist/conf/type/__daemontools/manifest create mode 100644 cdist/conf/type/__daemontools/parameter/boolean create mode 100644 cdist/conf/type/__daemontools/parameter/default/from-package create mode 100644 cdist/conf/type/__daemontools/parameter/default/install-init-script create mode 100644 cdist/conf/type/__daemontools/parameter/optional create mode 100644 cdist/conf/type/__daemontools/singleton create mode 100644 cdist/conf/type/__daemontools_service/explorer/svc create mode 100644 cdist/conf/type/__daemontools_service/man.rst diff --git a/cdist/conf/type/__daemontools/files/init.d-svscan b/cdist/conf/type/__daemontools/files/init.d-svscan new file mode 100644 index 00000000..127dfdb3 --- /dev/null +++ b/cdist/conf/type/__daemontools/files/init.d-svscan @@ -0,0 +1,63 @@ +#!/bin/bash +### BEGIN INIT INFO +# Provides: svscan +# Required-Start: +# Required-Stop: +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: svscan +# Description: djb svscan +### END INIT INFO +# from https://gist.githubusercontent.com/pacojp/5766990/raw/2ed009ab19515afc9e58291b636d673c5ca864b3/init.d.svscan +# written by Adam McKenna +# edited by Kamila Součková + +export PATH=$PATH:/usr/local/bin + +l=/var/log/svscan + +if [ ! -d $l ]; then + mkdir $l + chown daemon $l +fi + +case "$1" in + start) + echo -n "Starting daemontools: " + if [ ! `pidof svscan` ]; then + echo -n "svscan " + env - PATH="$PATH" svscan /service 2>&1 | setuidgid daemon multilog t /var/log/svscan & + echo "." + else + echo "already running." + fi + ;; + stop) + echo -n "Stopping daemontools: " + if [ `pidof svscan` ]; then + echo -n "svscan" + while [ `pidof svscan` ]; do + kill `pidof svscan` + echo -n "." + done + fi + echo -n " services" + for i in `ls -d /service/*`; do + svc -dx $i + echo -n "." + done + echo -n " logging " + for i in `ls -d /service/*/log`; do + svc -dx $i + echo -n "." + done + echo "" + ;; + restart|force-reload) + $0 stop + $0 start + ;; + *) + echo 'Usage: /etc/init.d/svscan {start|stop|restart|force-reload}' + exit 1 +esac diff --git a/cdist/conf/type/__daemontools/man.rst b/cdist/conf/type/__daemontools/man.rst new file mode 100644 index 00000000..62dc5681 --- /dev/null +++ b/cdist/conf/type/__daemontools/man.rst @@ -0,0 +1,42 @@ +cdist-type__daemontools(7) +========================== + +NAME +---- +cdist-type__daemontools - Install daemontools + + +DESCRIPTION +----------- +Install djb daemontools and (optionally) an init script. + + +REQUIRED PARAMETERS +------------------- +None. + + +OPTIONAL PARAMETERS +------------------- +from-package + Package to install. Must be compatible with the original daemontools. Example: daemontools-encore. Default: daemontools. + +BOOLEAN PARAMETERS +------------------ +install-init-script + Add an init script and set it to start on boot. Default yes. + +EXAMPLES +-------- + +.. code-block:: sh + + __daemontools --from-package daemontools-encore # if you prefer + +SEE ALSO +-------- +cdist-type__daemontools_service + +AUTHORS +------- +Kamila Součková diff --git a/cdist/conf/type/__daemontools/manifest b/cdist/conf/type/__daemontools/manifest new file mode 100644 index 00000000..550994a7 --- /dev/null +++ b/cdist/conf/type/__daemontools/manifest @@ -0,0 +1,20 @@ +#!/bin/sh + +pkg=$(cat "$__object/parameter/from-package") + +__package $pkg + +if [ -f "$__object/parameter/install-init-script" ]; then + init=$(cat "$__global/explorer/init") + case $init in + init) + __config_file /etc/init.d/svscan --mode 755 --source "$__type/files/init.d-svscan" + require="$require __config_file/etc/init.d/svscan" __start_on_boot svscan + require="$require __start_on_boot/svscan" __process svscan --start 'service svscan start' + ;; + *) + echo "Your init system ($init) is not supported by this type. Submit a patch at github.com/ungleich/cdist!" + exit 1 + ;; + esac +fi diff --git a/cdist/conf/type/__daemontools/parameter/boolean b/cdist/conf/type/__daemontools/parameter/boolean new file mode 100644 index 00000000..99a1cefd --- /dev/null +++ b/cdist/conf/type/__daemontools/parameter/boolean @@ -0,0 +1 @@ +install-init-script diff --git a/cdist/conf/type/__daemontools/parameter/default/from-package b/cdist/conf/type/__daemontools/parameter/default/from-package new file mode 100644 index 00000000..598dd40a --- /dev/null +++ b/cdist/conf/type/__daemontools/parameter/default/from-package @@ -0,0 +1 @@ +daemontools diff --git a/cdist/conf/type/__daemontools/parameter/default/install-init-script b/cdist/conf/type/__daemontools/parameter/default/install-init-script new file mode 100644 index 00000000..e69de29b diff --git a/cdist/conf/type/__daemontools/parameter/optional b/cdist/conf/type/__daemontools/parameter/optional new file mode 100644 index 00000000..8eca305b --- /dev/null +++ b/cdist/conf/type/__daemontools/parameter/optional @@ -0,0 +1 @@ +from-package diff --git a/cdist/conf/type/__daemontools/singleton b/cdist/conf/type/__daemontools/singleton new file mode 100644 index 00000000..e69de29b diff --git a/cdist/conf/type/__daemontools_service/explorer/svc b/cdist/conf/type/__daemontools_service/explorer/svc new file mode 100644 index 00000000..4a867485 --- /dev/null +++ b/cdist/conf/type/__daemontools_service/explorer/svc @@ -0,0 +1 @@ +command -v svc diff --git a/cdist/conf/type/__daemontools_service/man.rst b/cdist/conf/type/__daemontools_service/man.rst new file mode 100644 index 00000000..aa15a826 --- /dev/null +++ b/cdist/conf/type/__daemontools_service/man.rst @@ -0,0 +1,63 @@ +cdist-type__daemontools_service(7) +================================== + +NAME +---- +cdist-type__daemontools_service - Create a daemontools-compatible service dir. + + +DESCRIPTION +----------- +Create a directory structure compatible with daemontools-like service management. + +Note that svc must be present on the target system. + +The object ID will be used as the service name. + +REQUIRED PARAMETERS +------------------- +None. + +OPTIONAL PARAMETERS +------------------- +run + Command to run. exec-ing and stderr redirection will be added. One of run, run-file must be specified. + + Example: `my-program` + +run-file + File to save as /run. One of run, run-file must be specified. + + Example: +.. code-block:: sh + #!/bin/sh + exec 2>&1 + exec my_program + + +log-run + Command to run for log consumption. Default: `multilog t ./main` + +servicedir + Directory to install into. Default: `/service` + +BOOLEAN PARAMETERS +------------------ +None. + +EXAMPLES +-------- + +.. code-block:: sh + + require="__daemontools" __daemontools_service prometheus --run "setuidgid prometheus $GOBIN/prometheus $FLAGS" + + +SEE ALSO +-------- +cdist-type__daemontools + + +AUTHORS +------- +Kamila Součková diff --git a/cdist/conf/type/__daemontools_service/manifest b/cdist/conf/type/__daemontools_service/manifest index 34f45545..175066af 100644 --- a/cdist/conf/type/__daemontools_service/manifest +++ b/cdist/conf/type/__daemontools_service/manifest @@ -10,6 +10,13 @@ run=$(cat "$__object/parameter/run") runfile=$(cat "$__object/parameter/run-file") logrun=$(cat "$__object/parameter/log-run") +svc=$(cat "$__type/explorer/svc") + +if [ -z "$svc" ]; then + echo "svc not found! Install daemontools first: see __daemontools" + exit 1 +fi + badusage() { echo "__daemontools_service/$__object_id: exactly one of --run, --run-file must be set" >&2 exit 1 From 5ac324cd91c12c088c531f69661f076421959e40 Mon Sep 17 00:00:00 2001 From: Kamila Souckova Date: Thu, 1 Jun 2017 22:26:18 +0200 Subject: [PATCH 59/70] sacrifice to the evil manpage demons --- cdist/conf/type/__daemontools/man.rst | 9 ++++++++- cdist/conf/type/__daemontools_service/man.rst | 9 ++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/cdist/conf/type/__daemontools/man.rst b/cdist/conf/type/__daemontools/man.rst index 62dc5681..2e012cb5 100644 --- a/cdist/conf/type/__daemontools/man.rst +++ b/cdist/conf/type/__daemontools/man.rst @@ -35,8 +35,15 @@ EXAMPLES SEE ALSO -------- -cdist-type__daemontools_service +:strong:`cdist-type__daemontools_service`\ (7) AUTHORS ------- Kamila Součková + +COPYING +------- +Copyright \(C) 2017 Kamila Součková. You can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation, either version 3 of the +License, or (at your option) any later version. diff --git a/cdist/conf/type/__daemontools_service/man.rst b/cdist/conf/type/__daemontools_service/man.rst index aa15a826..0d75917e 100644 --- a/cdist/conf/type/__daemontools_service/man.rst +++ b/cdist/conf/type/__daemontools_service/man.rst @@ -55,9 +55,16 @@ EXAMPLES SEE ALSO -------- -cdist-type__daemontools +:strong:`cdist-type__daemontools`\ (7) AUTHORS ------- Kamila Součková + +COPYING +------- +Copyright \(C) 2017 Kamila Součková. You can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation, either version 3 of the +License, or (at your option) any later version. From c16277bb8fc36f207fdabc533ce01406ff609188 Mon Sep 17 00:00:00 2001 From: Kamila Souckova Date: Thu, 1 Jun 2017 22:55:58 +0200 Subject: [PATCH 60/70] =?UTF-8?q?manpage=20d=C3=A6mons=20won't=20stop?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cdist/conf/type/__daemontools_service/man.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/cdist/conf/type/__daemontools_service/man.rst b/cdist/conf/type/__daemontools_service/man.rst index 0d75917e..66360361 100644 --- a/cdist/conf/type/__daemontools_service/man.rst +++ b/cdist/conf/type/__daemontools_service/man.rst @@ -29,6 +29,7 @@ run-file File to save as /run. One of run, run-file must be specified. Example: + .. code-block:: sh #!/bin/sh exec 2>&1 From 42bc5e28b90d4143c8f7318773bd601f8b54f3c7 Mon Sep 17 00:00:00 2001 From: Kamila Souckova Date: Thu, 1 Jun 2017 23:01:03 +0200 Subject: [PATCH 61/70] WHY can't I write a man page? --- cdist/conf/type/__daemontools_service/man.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/cdist/conf/type/__daemontools_service/man.rst b/cdist/conf/type/__daemontools_service/man.rst index 66360361..ec1d20ff 100644 --- a/cdist/conf/type/__daemontools_service/man.rst +++ b/cdist/conf/type/__daemontools_service/man.rst @@ -31,6 +31,7 @@ run-file Example: .. code-block:: sh + #!/bin/sh exec 2>&1 exec my_program From 8d5e20757778c1f7d27f2f188d5584aabda51a06 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Thu, 1 Jun 2017 23:08:25 +0200 Subject: [PATCH 62/70] Update changelog --- docs/changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog b/docs/changelog index db0284a7..e691145c 100644 --- a/docs/changelog +++ b/docs/changelog @@ -8,6 +8,7 @@ next: * Type __sysctl: Add devuan support (Nico Schottelius) * Core: Shorten ssh control path (Darko Poljak) * Type __consul: Add new version and add http check (Kamila Součková) + * New types: __daemontools and __daemontools_service (Kamila Součková) 4.4.2: 2017-03-08 * Core: Fix suppression of manifests' outputs (Darko Poljak) From 2272539c16e594a3c4705b9aa4466b42f680d716 Mon Sep 17 00:00:00 2001 From: Kamila Souckova Date: Thu, 1 Jun 2017 23:52:23 +0200 Subject: [PATCH 63/70] is it Christmas today? So many new awesome types! --- .../type/__prometheus_alertmanager/man.rst | 66 ++++++++++++++++ .../type/__prometheus_alertmanager/manifest | 39 ++++++++++ .../parameter/default/storage-path | 1 + .../parameter/optional | 1 + .../parameter/required | 2 + .../type/__prometheus_alertmanager/singleton | 0 cdist/conf/type/__prometheus_server/man.rst | 78 +++++++++++++++++++ cdist/conf/type/__prometheus_server/manifest | 57 ++++++++++++++ .../__prometheus_server/parameter/boolean | 1 + .../parameter/default/retention-days | 1 + .../parameter/default/rule-files | 0 .../parameter/default/storage-path | 1 + .../parameter/default/target-heap-size | 1 + .../parameter/default/with-daemontools | 0 .../__prometheus_server/parameter/optional | 4 + .../__prometheus_server/parameter/required | 3 + cdist/conf/type/__prometheus_server/singleton | 0 17 files changed, 255 insertions(+) create mode 100644 cdist/conf/type/__prometheus_alertmanager/man.rst create mode 100644 cdist/conf/type/__prometheus_alertmanager/manifest create mode 100644 cdist/conf/type/__prometheus_alertmanager/parameter/default/storage-path create mode 100644 cdist/conf/type/__prometheus_alertmanager/parameter/optional create mode 100644 cdist/conf/type/__prometheus_alertmanager/parameter/required create mode 100644 cdist/conf/type/__prometheus_alertmanager/singleton create mode 100644 cdist/conf/type/__prometheus_server/man.rst create mode 100644 cdist/conf/type/__prometheus_server/manifest create mode 100644 cdist/conf/type/__prometheus_server/parameter/boolean create mode 100644 cdist/conf/type/__prometheus_server/parameter/default/retention-days create mode 100644 cdist/conf/type/__prometheus_server/parameter/default/rule-files create mode 100644 cdist/conf/type/__prometheus_server/parameter/default/storage-path create mode 100644 cdist/conf/type/__prometheus_server/parameter/default/target-heap-size create mode 100644 cdist/conf/type/__prometheus_server/parameter/default/with-daemontools create mode 100644 cdist/conf/type/__prometheus_server/parameter/optional create mode 100644 cdist/conf/type/__prometheus_server/parameter/required create mode 100644 cdist/conf/type/__prometheus_server/singleton diff --git a/cdist/conf/type/__prometheus_alertmanager/man.rst b/cdist/conf/type/__prometheus_alertmanager/man.rst new file mode 100644 index 00000000..f218254e --- /dev/null +++ b/cdist/conf/type/__prometheus_alertmanager/man.rst @@ -0,0 +1,66 @@ +cdist-type__prometheus_alertmanager(7) +====================================== + +NAME +---- +cdist-type__prometheus_alertmanager - install Alertmanager + + +DESCRIPTION +----------- +Install and configure Prometheus Alertmanager (https://prometheus.io/docs/alerting/alertmanager/). + + +REQUIRED PARAMETERS +------------------- +config + Alertmanager configuration file. It will be saved as /etc/alertmanager/alertmanager.yml on the target. +listen-address + Passed as web.listen-address. + + +OPTIONAL PARAMETERS +------------------- +storage-path + Where to put data. Default: /data/alertmanager. (Directory will be created if needed.) + + +BOOLEAN PARAMETERS +------------------ +with-daemontools + Create a daemontools service directory under /service/prometheus. Default: yes. + Note: If you do not use this, Alertmanager will not be launched, and will not reload config on change. + If you use this, daemontools (or something compatible) must be installed. + + +EXAMPLES +-------- + +.. code-block:: sh + + ALERTPORT=9093 + + __daemontools + __golang_from_vendor --version 1.8.1 # required for prometheus and many exporters + + require="__daemontools __golang_from_vendor" __prometheus_alertmanager \ + --config "$__manifest/files/alertmanager.yml" \ + --storage-path /data/alertmanager \ + --listen-address "[::]:$ALERTPORT" + + +SEE ALSO +-------- +:strong:`cdist-type__prometheus_server`\ (7), :strong:`cdist-type__daemontools`\ (7), +Prometheus alerting documentation: https://prometheus.io/docs/alerting/overview/ + +AUTHORS +------- +Kamila Součková + +COPYING +------- +Copyright \(C) 2017 Kamila Součková. You can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation, either version 3 of the +License, or (at your option) any later version. diff --git a/cdist/conf/type/__prometheus_alertmanager/manifest b/cdist/conf/type/__prometheus_alertmanager/manifest new file mode 100644 index 00000000..61ac2d20 --- /dev/null +++ b/cdist/conf/type/__prometheus_alertmanager/manifest @@ -0,0 +1,39 @@ +#!/bin/sh + +GOBIN=/opt/gocode/bin # where to find go binaries +CONF_DIR=/etc/prometheus +LOGLEVEL=info +CONF=$CONF_DIR/alertmanager.yml + +### Prometheus server ####################################################### + +config="$(cat "$__object/parameter/config")" +storage_path="$(cat "$__object/parameter/storage-path")" +listen_address="$(cat "$__object/parameter/listen-address")" + +ONCHANGE="" +if [ -f "$__object/parameter/with-daemontools" ]; then + __daemontools_service prometheus --run "setuidgid prometheus $GOBIN/prometheus $REAL_FLAGS" + ONCHANGE="svc -h /service/prometheus" +fi + +FLAGS="config.file '$CONF' +storage.path '$storage_path' +web.listen-address '$listen_address' +log.level $LOGLEVEL" + +REAL_FLAGS="$(echo "$FLAGS" | sed -nE 's/^([^#]+).*/ --\1 \\/p')" + +__go_get github.com/prometheus/alertmanager/cmd/... + +__user prometheus --system +__directory "$storage_path" --owner prometheus +__directory "$CONF_DIR" --owner prometheus + +__daemontools_service alertmanager --run "setuidgid prometheus $GOBIN/alertmanager $REAL_FLAGS" + +require="$require __directory/$storage_path" \ +__config_file $CONF \ + --source $config \ + --group prometheus --mode 640 \ + --onchange "$ONCHANGE" diff --git a/cdist/conf/type/__prometheus_alertmanager/parameter/default/storage-path b/cdist/conf/type/__prometheus_alertmanager/parameter/default/storage-path new file mode 100644 index 00000000..4f3e7559 --- /dev/null +++ b/cdist/conf/type/__prometheus_alertmanager/parameter/default/storage-path @@ -0,0 +1 @@ +/data/alertmanager diff --git a/cdist/conf/type/__prometheus_alertmanager/parameter/optional b/cdist/conf/type/__prometheus_alertmanager/parameter/optional new file mode 100644 index 00000000..f99d0d37 --- /dev/null +++ b/cdist/conf/type/__prometheus_alertmanager/parameter/optional @@ -0,0 +1 @@ +storage-path diff --git a/cdist/conf/type/__prometheus_alertmanager/parameter/required b/cdist/conf/type/__prometheus_alertmanager/parameter/required new file mode 100644 index 00000000..02cb49d0 --- /dev/null +++ b/cdist/conf/type/__prometheus_alertmanager/parameter/required @@ -0,0 +1,2 @@ +config +listen-address diff --git a/cdist/conf/type/__prometheus_alertmanager/singleton b/cdist/conf/type/__prometheus_alertmanager/singleton new file mode 100644 index 00000000..e69de29b diff --git a/cdist/conf/type/__prometheus_server/man.rst b/cdist/conf/type/__prometheus_server/man.rst new file mode 100644 index 00000000..c03a71d5 --- /dev/null +++ b/cdist/conf/type/__prometheus_server/man.rst @@ -0,0 +1,78 @@ +cdist-type__prometheus_server(7) +================================ + +NAME +---- +cdist-type__prometheus_server - install Prometheus + + +DESCRIPTION +----------- +Install and configure Prometheus (https://prometheus.io/). + + +REQUIRED PARAMETERS +------------------- +config + Prometheus configuration file. It will be saved as /etc/prometheus/prometheus.yml on the target. +listen-address + Passed as web.listen-address. +alertmanager-url + Passed as alertmanager.url + + +OPTIONAL PARAMETERS +------------------- +retention-days + How long to keep data. Default: 30 +rule-files + Path to rule files. They will be installed under /etc/prometheus/. You need to include `rule_files: [/etc/prometheus/]` in the config file if you use this. +storage-path + Where to put data. Default: /data/prometheus. (Directory will be created if needed.) +target-heap-size + Passed as storage.local.target-heap-size. Default: 1/2 of RAM. + + +BOOLEAN PARAMETERS +------------------ +with-daemontools + Create a daemontools service directory under /service/prometheus. Default: yes. + Note: If you do not use this, Prometheus will not be launched, and will not reload config on change. + If you use this, daemontools (or something compatible) must be installed. + + +EXAMPLES +-------- + +.. code-block:: sh + + PROMPORT=9090 + ALERTPORT=9093 + + __daemontools + __golang_from_vendor --version 1.8.1 # required for prometheus and many exporters + + require="__daemontools __golang_from_vendor" __prometheus_server \ + --config "$__manifest/files/prometheus.yml" \ + --retention-days 14 \ + --storage-path /data/prometheus \ + --listen-address "[::]:$PROMPORT" \ + --rule-files "$__manifest/files/*.rules" \ + --alertmanager-url "http://monitoring1.node.consul:$ALERTPORT,http://monitoring2.node.consul:$ALERTPORT" + + +SEE ALSO +-------- +:strong:`cdist-type__prometheus_alertmanager`\ (7), :strong:`cdist-type__daemontools`\ (7), +Prometheus documentation: https://prometheus.io/docs/introduction/overview/ + +AUTHORS +------- +Kamila Součková + +COPYING +------- +Copyright \(C) 2017 Kamila Součková. You can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation, either version 3 of the +License, or (at your option) any later version. diff --git a/cdist/conf/type/__prometheus_server/manifest b/cdist/conf/type/__prometheus_server/manifest new file mode 100644 index 00000000..dd81701d --- /dev/null +++ b/cdist/conf/type/__prometheus_server/manifest @@ -0,0 +1,57 @@ +#!/bin/sh + +GOBIN=/opt/gocode/bin # where to find go binaries +CONF_DIR=/etc/prometheus +CONF=$CONF_DIR/prometheus.yml +LOGLEVEL=info + +config="$(cat "$__object/parameter/config")" +retention_days="$(cat "$__object/parameter/retention-days")" +storage_path="$(cat "$__object/parameter/storage-path")" +listen_address="$(cat "$__object/parameter/listen-address")" +alertmanager_url="$(cat "$__object/parameter/alertmanager-url")" +target_heap_size="$(cat "$__object/parameter/target-heap-size")" +rule_files="$(cat "$__object/parameter/rule-files")" + +# explorer in kB => convert; by default we go with 1/2 RAM +[ "$target_heap_size" = "auto" ] && target_heap_size=$(($(cat $__global/explorer/memory)*1024/2)) + +ONCHANGE="" +if [ -f "$__object/parameter/with-daemontools" ]; then + __daemontools_service prometheus --run "setuidgid prometheus $GOBIN/prometheus $REAL_FLAGS" + ONCHANGE="&& svc -h /service/prometheus" +fi + +FLAGS="config.file '$CONF' +storage.local.path '$storage_path' +storage.local.target-heap-size $(($target_heap_size)) # in bytes; should be 2/3 of available memory because it may be hungry +storage.local.retention $(($retention_days*24))h # golang doesn't have days :D +web.listen-address '$listen_address' +alertmanager.url '$alertmanager_url' +log.level $LOGLEVEL" + +REAL_FLAGS="$(echo "$FLAGS" | sed -nE 's/^([^#]+).*/ --\1 \\/p')" + +__go_get github.com/prometheus/prometheus/cmd/... + +__user prometheus --system +__directory "$storage_path" --owner prometheus +__directory "$CONF_DIR" --owner prometheus + + + +require="$require __directory/$storage_path" \ +__config_file $CONF \ + --source $config \ + --group prometheus --mode 640 \ + --onchange "$GOBIN/promtool check-config $CONF $ONCHANGE" + +for file in $rule_files; do + dest=$CONF_DIR/$(basename $file) + require="$require __directory/$CONF_DIR" \ + __config_file "$dest" \ + --source "$file" \ + --owner prometheus \ + --onchange "$GOBIN/promtool check-rules '$dest' $ONCHANGE" +done + diff --git a/cdist/conf/type/__prometheus_server/parameter/boolean b/cdist/conf/type/__prometheus_server/parameter/boolean new file mode 100644 index 00000000..de4eefdd --- /dev/null +++ b/cdist/conf/type/__prometheus_server/parameter/boolean @@ -0,0 +1 @@ +with-daemontools diff --git a/cdist/conf/type/__prometheus_server/parameter/default/retention-days b/cdist/conf/type/__prometheus_server/parameter/default/retention-days new file mode 100644 index 00000000..64bb6b74 --- /dev/null +++ b/cdist/conf/type/__prometheus_server/parameter/default/retention-days @@ -0,0 +1 @@ +30 diff --git a/cdist/conf/type/__prometheus_server/parameter/default/rule-files b/cdist/conf/type/__prometheus_server/parameter/default/rule-files new file mode 100644 index 00000000..e69de29b diff --git a/cdist/conf/type/__prometheus_server/parameter/default/storage-path b/cdist/conf/type/__prometheus_server/parameter/default/storage-path new file mode 100644 index 00000000..fc05f8f3 --- /dev/null +++ b/cdist/conf/type/__prometheus_server/parameter/default/storage-path @@ -0,0 +1 @@ +/data/prometheus diff --git a/cdist/conf/type/__prometheus_server/parameter/default/target-heap-size b/cdist/conf/type/__prometheus_server/parameter/default/target-heap-size new file mode 100644 index 00000000..865faf10 --- /dev/null +++ b/cdist/conf/type/__prometheus_server/parameter/default/target-heap-size @@ -0,0 +1 @@ +auto diff --git a/cdist/conf/type/__prometheus_server/parameter/default/with-daemontools b/cdist/conf/type/__prometheus_server/parameter/default/with-daemontools new file mode 100644 index 00000000..e69de29b diff --git a/cdist/conf/type/__prometheus_server/parameter/optional b/cdist/conf/type/__prometheus_server/parameter/optional new file mode 100644 index 00000000..4d8d8f3e --- /dev/null +++ b/cdist/conf/type/__prometheus_server/parameter/optional @@ -0,0 +1,4 @@ +target-heap-size +retention-days +rule-files +storage-path diff --git a/cdist/conf/type/__prometheus_server/parameter/required b/cdist/conf/type/__prometheus_server/parameter/required new file mode 100644 index 00000000..49abf924 --- /dev/null +++ b/cdist/conf/type/__prometheus_server/parameter/required @@ -0,0 +1,3 @@ +alertmanager-url +config +listen-address diff --git a/cdist/conf/type/__prometheus_server/singleton b/cdist/conf/type/__prometheus_server/singleton new file mode 100644 index 00000000..e69de29b From f87cce28d1ca0219c958a3c3bf032c18a852efa9 Mon Sep 17 00:00:00 2001 From: Kamila Souckova Date: Fri, 2 Jun 2017 15:28:52 +0200 Subject: [PATCH 64/70] new type: __grafana_dashboard --- cdist/conf/type/__grafana_dashboard/man.rst | 43 +++++++++++++++++++ cdist/conf/type/__grafana_dashboard/manifest | 23 ++++++++++ cdist/conf/type/__grafana_dashboard/singleton | 0 3 files changed, 66 insertions(+) create mode 100644 cdist/conf/type/__grafana_dashboard/man.rst create mode 100644 cdist/conf/type/__grafana_dashboard/manifest create mode 100644 cdist/conf/type/__grafana_dashboard/singleton diff --git a/cdist/conf/type/__grafana_dashboard/man.rst b/cdist/conf/type/__grafana_dashboard/man.rst new file mode 100644 index 00000000..b3974028 --- /dev/null +++ b/cdist/conf/type/__grafana_dashboard/man.rst @@ -0,0 +1,43 @@ +cdist-type__grafana_dashboard(7) +================================ + +NAME +---- +cdist-type__grafana_dashboard - Install Grafana (https://grafana.com) + + +DESCRIPTION +----------- +This cdist type adds the Grafana repository, installs the grafana package, and sets the server to start on boot. + +This is a singleton type. + +REQUIRED PARAMETERS +------------------- +None. + + +OPTIONAL PARAMETERS +------------------- +None. + + +EXAMPLES +-------- + +.. code-block:: sh + + __grafana_dashboard + + +AUTHORS +------- +Kamila Součková + + +COPYING +------- +Copyright \(C) 2017 Kamila Součková. You can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation, either version 3 of the +License, or (at your option) any later version. diff --git a/cdist/conf/type/__grafana_dashboard/manifest b/cdist/conf/type/__grafana_dashboard/manifest new file mode 100644 index 00000000..c5bc78d2 --- /dev/null +++ b/cdist/conf/type/__grafana_dashboard/manifest @@ -0,0 +1,23 @@ +os=$(cat $__global/explorer/os) + +case $os in + debian|devuan) + __apt_key_uri grafana \ + --name 'Grafana Release Signing Key' \ + --uri https://packagecloud.io/gpg.key + + require="__apt_key_uri/grafana" __apt_source grafana \ + --uri https://packagecloud.io/grafana/stable/debian/ \ + --distribution jessie \ + --component main + + __package apt-transport-https + + require="__apt_source/grafana __package/apt-transport-https" __package grafana + require="__package/grafana" __start_on_boot grafana-server + ;; + *) + echo "Don't know how to install Grafana on $os. Send us a pull request!" + exit 1 + ;; +esac diff --git a/cdist/conf/type/__grafana_dashboard/singleton b/cdist/conf/type/__grafana_dashboard/singleton new file mode 100644 index 00000000..e69de29b From 4c9863cc542e5e77bc17a19814dd8048de86488b Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Fri, 2 Jun 2017 17:39:43 +0200 Subject: [PATCH 65/70] Update changelog --- docs/changelog | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/changelog b/docs/changelog index e691145c..c33ad05a 100644 --- a/docs/changelog +++ b/docs/changelog @@ -8,7 +8,8 @@ next: * Type __sysctl: Add devuan support (Nico Schottelius) * Core: Shorten ssh control path (Darko Poljak) * Type __consul: Add new version and add http check (Kamila Součková) - * New types: __daemontools and __daemontools_service (Kamila Součková) + * New types: __daemontools and __daemontools_service (Kamila Součková) + * New types: __prometheus_server and __prometheus_alertmanager (Kamila Součková) 4.4.2: 2017-03-08 * Core: Fix suppression of manifests' outputs (Darko Poljak) From 91ff80fa6adce3b91790eff8bb51b2863a47dc7e Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 3 Jun 2017 18:15:44 +0200 Subject: [PATCH 66/70] Add devuan support for __start_on_boot --- cdist/conf/type/__start_on_boot/gencode-remote | 2 +- docs/changelog | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/cdist/conf/type/__start_on_boot/gencode-remote b/cdist/conf/type/__start_on_boot/gencode-remote index 45de5465..0ab67a1a 100644 --- a/cdist/conf/type/__start_on_boot/gencode-remote +++ b/cdist/conf/type/__start_on_boot/gencode-remote @@ -93,7 +93,7 @@ case "$state_should" in else case "$os" in - debian|ubuntu) + debian|ubuntu|devuan) echo update-rc.d -f \"$name\" remove ;; diff --git a/docs/changelog b/docs/changelog index 524257a7..92123b70 100644 --- a/docs/changelog +++ b/docs/changelog @@ -6,6 +6,7 @@ next: * Type __go_get: Install go packages using go get (Kamila Součková) * Explorer kernel_name: uname -s (Kamila Součková) * Type __sysctl: Add devuan support (Nico Schottelius) + * Type __start_on_boot: Add devuan support (Nico Schottelius) 4.4.2: 2017-03-08 * Core: Fix suppression of manifests' outputs (Darko Poljak) From 4c7327e81462d11d7ba53bf6c38a990f12549c84 Mon Sep 17 00:00:00 2001 From: Kamila Souckova Date: Fri, 9 Jun 2017 18:40:47 +0200 Subject: [PATCH 67/70] consider de(bi|vu)an version --- cdist/conf/type/__grafana_dashboard/manifest | 29 +++++++++++++------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/cdist/conf/type/__grafana_dashboard/manifest b/cdist/conf/type/__grafana_dashboard/manifest index c5bc78d2..b6e3020e 100644 --- a/cdist/conf/type/__grafana_dashboard/manifest +++ b/cdist/conf/type/__grafana_dashboard/manifest @@ -1,20 +1,29 @@ os=$(cat $__global/explorer/os) +os_version=$(cat $__global/explorer/os_version) case $os in debian|devuan) - __apt_key_uri grafana \ - --name 'Grafana Release Signing Key' \ - --uri https://packagecloud.io/gpg.key + case $os_version in + 8*|jessie) + __apt_key_uri grafana \ + --name 'Grafana Release Signing Key' \ + --uri https://packagecloud.io/gpg.key - require="__apt_key_uri/grafana" __apt_source grafana \ - --uri https://packagecloud.io/grafana/stable/debian/ \ - --distribution jessie \ - --component main + require="__apt_key_uri/grafana" __apt_source grafana \ + --uri https://packagecloud.io/grafana/stable/debian/ \ + --distribution jessie \ + --component main - __package apt-transport-https + __package apt-transport-https - require="__apt_source/grafana __package/apt-transport-https" __package grafana - require="__package/grafana" __start_on_boot grafana-server + require="__apt_source/grafana __package/apt-transport-https" __package grafana + require="__package/grafana" __start_on_boot grafana-server + ;; + *) + echo "Don't know how to install Grafana on $os $os_version. Send us a pull request!" + exit 1 + ;; + esac ;; *) echo "Don't know how to install Grafana on $os. Send us a pull request!" From d6ca07795991ffa444a0219a6edfd24b2430fea3 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Sun, 11 Jun 2017 13:58:47 +0200 Subject: [PATCH 68/70] Fix cdist man page text. --- docs/src/man1/cdist.rst | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/src/man1/cdist.rst b/docs/src/man1/cdist.rst index adabe052..e975a407 100644 --- a/docs/src/man1/cdist.rst +++ b/docs/src/man1/cdist.rst @@ -268,12 +268,12 @@ This limit is controlled with sshd :strong:`MaxSessions` configuration options. For more details refer to :strong:`sshd_config`\ (5). When requirements for the same object are defined in different manifests (see -example below) in init manifest and in some other type manifest and they differs -then dependency resolver cannot detect dependencies right. This happens because -cdist cannot prepare all objects first and then run objects because some -object can depend on the result of type explorer(s) and explorers are executed -during object run. cdist will detect such case and write warning message. -Example for such a case: +example below), for example, in init manifest and in some other type manifest +and those requirements differ then dependency resolver cannot detect +dependencies right. This happens because cdist cannot prepare all objects first +and run all objects afterwards. Some object can depend on the result of type +explorer(s) and explorers are executed during object run. cdist will detect +such case and write warning message. Example for such a case: .. code-block:: sh From d4ec3a709d2281f32e0b115aa324b7bbeafbe0dd Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Sun, 11 Jun 2017 14:01:16 +0200 Subject: [PATCH 69/70] Update cdist man page copyright. --- docs/src/man1/cdist.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/src/man1/cdist.rst b/docs/src/man1/cdist.rst index e975a407..72cee4cc 100644 --- a/docs/src/man1/cdist.rst +++ b/docs/src/man1/cdist.rst @@ -298,5 +298,5 @@ such case and write warning message. Example for such a case: COPYING ------- -Copyright \(C) 2011-2013 Nico Schottelius. Free use of this software is +Copyright \(C) 2011-2017 Nico Schottelius. Free use of this software is granted under the terms of the GNU General Public License v3 or later (GPLv3+). From 0ec361165dd558aa8aebfd18955f4c34c5b5afb6 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Sun, 11 Jun 2017 14:02:47 +0200 Subject: [PATCH 70/70] Update changelog. --- docs/changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog b/docs/changelog index a0eacaf4..75147776 100644 --- a/docs/changelog +++ b/docs/changelog @@ -11,6 +11,7 @@ next: * Type __consul: Add new version and add http check (Kamila Součková) * New types: __daemontools and __daemontools_service (Kamila Součková) * New types: __prometheus_server and __prometheus_alertmanager (Kamila Součková) + * New type: __grafana_dashboard (Kamila Součková) 4.4.2: 2017-03-08 * Core: Fix suppression of manifests' outputs (Darko Poljak)