diff --git a/cdist/argparse.py b/cdist/argparse.py index 04f6e6a4..3791e779 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/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/__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/__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/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 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 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..3c3ed6b3 --- 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. # @@ -26,7 +27,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 +36,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" @@ -58,7 +58,7 @@ state_should="$(cat "$__object/parameter/state" 2>/dev/null || echo "present")" # These are the old markers prefix="#cdist:__cron/$__object_id" suffix="#/cdist:__cron/$__object_id" -filter="^# DO NOT EDIT THIS FILE|^# \(.* installed on |^# \(Cron version V" +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" ' { @@ -85,7 +85,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 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..2e012cb5 --- /dev/null +++ b/cdist/conf/type/__daemontools/man.rst @@ -0,0 +1,49 @@ +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 +-------- +:strong:`cdist-type__daemontools_service`\ (7) + +AUTHORS +------- +Kamila Součková + +COPYING +------- +Copyright \(C) 2017 Kamila Součková. You can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation, either version 3 of the +License, or (at your option) any later version. diff --git a/cdist/conf/type/__daemontools/manifest b/cdist/conf/type/__daemontools/manifest 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..ec1d20ff --- /dev/null +++ b/cdist/conf/type/__daemontools_service/man.rst @@ -0,0 +1,72 @@ +cdist-type__daemontools_service(7) +================================== + +NAME +---- +cdist-type__daemontools_service - Create a daemontools-compatible service dir. + + +DESCRIPTION +----------- +Create a directory structure compatible with daemontools-like service management. + +Note that svc must be present on the target system. + +The object ID will be used as the service name. + +REQUIRED PARAMETERS +------------------- +None. + +OPTIONAL PARAMETERS +------------------- +run + Command to run. exec-ing and stderr redirection will be added. One of run, run-file must be specified. + + Example: `my-program` + +run-file + File to save as /run. One of run, run-file must be specified. + + Example: + +.. code-block:: sh + + #!/bin/sh + exec 2>&1 + exec my_program + + +log-run + Command to run for log consumption. Default: `multilog t ./main` + +servicedir + Directory to install into. Default: `/service` + +BOOLEAN PARAMETERS +------------------ +None. + +EXAMPLES +-------- + +.. code-block:: sh + + require="__daemontools" __daemontools_service prometheus --run "setuidgid prometheus $GOBIN/prometheus $FLAGS" + + +SEE ALSO +-------- +:strong:`cdist-type__daemontools`\ (7) + + +AUTHORS +------- +Kamila Součková + +COPYING +------- +Copyright \(C) 2017 Kamila Součková. You can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation, either version 3 of the +License, or (at your option) any later version. diff --git a/cdist/conf/type/__daemontools_service/manifest b/cdist/conf/type/__daemontools_service/manifest new file mode 100644 index 00000000..175066af --- /dev/null +++ b/cdist/conf/type/__daemontools_service/manifest @@ -0,0 +1,38 @@ +#!/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") + +svc=$(cat "$__type/explorer/svc") + +if [ -z "$svc" ]; then + echo "svc not found! Install daemontools first: see __daemontools" + exit 1 +fi + +badusage() { + echo "__daemontools_service/$__object_id: exactly one of --run, --run-file must be set" >&2 + exit 1 +} + +[ -z "$run$runfile" ] && badusage +[ -n "$run" ] && [ -n "$runfile" ] && badusage + +__directory $servicedir/$name/log/main --parents + +echo "$RUN_PREFIX$run" | require="__directory/$servicedir/$name/log/main" __config_file "$servicedir/$name/run" \ + --onchange "svc -t '$servicedir/$name' 2>/dev/null" \ + --mode 755 \ + --source "${runfile:--}" + +echo "$RUN_PREFIX$logrun" | require="__directory/$servicedir/$name/log/main" __config_file $servicedir/$name/log/run \ + --onchange "svc -t '$servicedir/$name/log' 2>/dev/null" \ + --mode 755 \ + --source "-" diff --git a/cdist/conf/type/__daemontools_service/parameter/default/log-run b/cdist/conf/type/__daemontools_service/parameter/default/log-run 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 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/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 new file mode 100644 index 00000000..bd1ad452 --- /dev/null +++ b/cdist/conf/type/__docker_compose/gencode-remote @@ -0,0 +1,31 @@ +#!/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 . +# + +# Variables +version="$(cat "$__object/parameter/version")" +state="$(cat "$__object/parameter/state")" + +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/man.rst b/cdist/conf/type/__docker_compose/man.rst new file mode 100644 index 00000000..7386e737 --- /dev/null +++ b/cdist/conf/type/__docker_compose/man.rst @@ -0,0 +1,58 @@ +cdist-type__docker_compose(7) +============================= + +NAME +---- +cdist-type__docker_compose - install docker-compose + + +DESCRIPTION +----------- +Installs docker-compose package. +State 'absent' will not remove docker binary itself, +only docker-compose binary will be removed + + +REQUIRED PARAMETERS +------------------- +None. + + +OPTIONAL PARAMETERS +------------------- +version + Define docker_compose version, defaults to "1.9.0" + +state + 'present' or 'absent', defaults to 'present' + + +BOOLEAN PARAMETERS +------------------ +None. + + +EXAMPLES +-------- + +.. code-block:: sh + + # Install docker-compose + __docker_compose + + # Install version 1.9.0-rc4 + __docker_compose --version 1.9.0-rc4 + + # Remove docker-compose + __docker_compose --state absent + + +AUTHORS +------- +Dominique Roux + + +COPYING +------- +Copyright \(C) 2016 Dominique Roux. Free use of this software is +granted under the terms of the GNU General Public License version 3 or later (GPLv3+). diff --git a/cdist/conf/type/__docker_compose/manifest b/cdist/conf/type/__docker_compose/manifest new file mode 100644 index 00000000..559375ef --- /dev/null +++ b/cdist/conf/type/__docker_compose/manifest @@ -0,0 +1,33 @@ +#!/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 . +# +# + +state="$(cat "$__object/parameter/state")" + +# Needed packages +if [ ${state} = "present" ]; then + __docker + __package curl +elif [ ${state} = "absent" ]; then + __file /usr/local/bin/docker-compose --state absent +else + echo "Unknown state: ${state}" >&2 + exit 1 +fi diff --git a/cdist/conf/type/__docker_compose/parameter/default/state b/cdist/conf/type/__docker_compose/parameter/default/state 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/default/version b/cdist/conf/type/__docker_compose/parameter/default/version new file mode 100644 index 00000000..0eed1a29 --- /dev/null +++ b/cdist/conf/type/__docker_compose/parameter/default/version @@ -0,0 +1 @@ +1.12.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..4d595ed7 --- /dev/null +++ b/cdist/conf/type/__docker_compose/parameter/optional @@ -0,0 +1,2 @@ +state +version diff --git a/cdist/conf/type/__docker_compose/singleton b/cdist/conf/type/__docker_compose/singleton new file mode 100644 index 00000000..e69de29b 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..ae65eb95 --- /dev/null +++ b/cdist/conf/type/__dot_file/man.rst @@ -0,0 +1,71 @@ +cdist-type__dot_file(7) +======================== + +NAME +---- + +cdist-type__dot_file - install file under user's home directory + +DESCRIPTION +----------- + +This type installs a file (=\ *__object_id*) under user's home directory, +providing a way to install per-user configuration files. File owner +and group is deduced from user, for who file is installed. + +Unlike regular __file type, you do not need make any assumptions, +where user's home directory is. + +REQUIRED PARAMETERS +------------------- + +user + User, for who file is installed + +OPTIONAL PARAMETERS +------------------- + +mode + forwarded to :strong:`__file` type + +state + forwarded to :strong:`__file` type + +source + forwarded to :strong:`__file` type + +MESSAGES +-------- + +This type inherits all messages from :strong:`file` type, and do not add +any new. + +EXAMPLES +-------- + +.. code-block:: sh + + # Install .forward file for user 'alice'. Since state is 'present', + # user is not meant to edit this file, all changes will be overridden. + # It is good idea to put warning about it in file itself. + __dot_file .forward --user alice --source "$__files/forward" + + # Install .muttrc for user 'bob', if not already present. User can safely + # edit it, his changes will not be overwritten. + __dot_file .muttrc --user bob --source "$__files/recommended_mutt_config" --state exists + + + # Install default xmonad config for user 'eve'. Parent directory is created automatically. + __dot_file .xmonad/xmonad.hs --user eve --state exists --source "$__files/xmonad.hs" + +SEE ALSO +-------- + +**cdist-type__file**\ (7) + +COPYING +------- + +Copyright (C) 2015 Dmitry Bogatov. Free use of this software is granted +under the terms of the GNU General Public License version 3 or later +(GPLv3+). diff --git a/cdist/conf/type/__dot_file/manifest b/cdist/conf/type/__dot_file/manifest 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/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< + + +COPYING +------- +Copyright \(C) 2017 Kamila Součková. You can redistribute it +and/or modify it under the terms of the GNU General Public License as +published by the Free Software Foundation, either version 3 of the +License, or (at your option) any later version. diff --git a/cdist/conf/type/__go_get/manifest b/cdist/conf/type/__go_get/manifest new file mode 100644 index 00000000..cfeb6396 --- /dev/null +++ b/cdist/conf/type/__go_get/manifest @@ -0,0 +1,17 @@ +#!/bin/sh + +go_executable=$(cat "$__object/explorer/go-executable") +[ -z "$go_executable" ] && echo "__go_get: Cannot find go executable; make sure it is installed and in PATH" >&2 && exit 1 + +os=$(cat "$__global/explorer/os") +case $os in + debian|devuan|ubuntu) + __package build-essential + ;; + *) + echo "__go_get: Don't know how to install g++ on $os" >&2 + echo "__go_get: Send a pull request or contact to add support for $os." >&2 + exit 1 + ;; +esac + 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/man.rst b/cdist/conf/type/__golang_from_vendor/man.rst new file mode 100644 index 00000000..2b4f065e --- /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. 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 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..b6e3020e --- /dev/null +++ b/cdist/conf/type/__grafana_dashboard/manifest @@ -0,0 +1,32 @@ +os=$(cat $__global/explorer/os) +os_version=$(cat $__global/explorer/os_version) + +case $os in + debian|devuan) + 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 + + __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 $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!" + 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 diff --git a/cdist/conf/type/__hosts/man.rst b/cdist/conf/type/__hosts/man.rst new file mode 100644 index 00000000..bece7967 --- /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 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/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/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 -------- 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 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 diff --git a/cdist/conf/type/__start_on_boot/gencode-remote b/cdist/conf/type/__start_on_boot/gencode-remote index e77132c9..0ab67a1a 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\" @@ -90,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/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) : ;; *) diff --git a/cdist/conf/type/__user_groups/explorer/oldusermod b/cdist/conf/type/__user_groups/explorer/oldusermod index bf43fcec..6ef25b13 100644 --- a/cdist/conf/type/__user_groups/explorer/oldusermod +++ b/cdist/conf/type/__user_groups/explorer/oldusermod @@ -18,11 +18,4 @@ # along with cdist. If not, see . # -os="$($__explorer/os)" - -if [ "$os" = "netbsd" ]; then - echo netbsd - exit -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 diff --git a/cdist/config.py b/cdist/config.py index a47811a9..03a2e6ee 100644 --- a/cdist/config.py +++ b/cdist/config.py @@ -29,6 +29,8 @@ import tempfile import socket import multiprocessing from cdist.mputil import mp_pool_run +import atexit +import shutil import cdist import cdist.hostsource @@ -94,7 +96,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 @@ -177,8 +178,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. @@ -201,8 +209,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/cdist/core/manifest.py b/cdist/core/manifest.py index 92a16190..29f96c4f 100644 --- a/cdist/core/manifest.py +++ b/cdist/core/manifest.py @@ -153,7 +153,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, @@ -178,4 +179,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..e078dbd2 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() @@ -231,7 +232,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 +241,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) 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]) diff --git a/docs/changelog b/docs/changelog index f0b296cc..75147776 100644 --- a/docs/changelog +++ b/docs/changelog @@ -2,6 +2,30 @@ 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 (Kamila Součková) + * Type __sysctl: Add devuan support (Nico Schottelius) + * Type __start_on_boot: Add devuan support (Nico Schottelius) + * Core: Shorten ssh control path (Darko Poljak) + * Type __consul: Add new version and add http check (Kamila Součková) + * New types: __daemontools and __daemontools_service (Kamila Součková) + * New types: __prometheus_server and __prometheus_alertmanager (Kamila Součková) + * New type: __grafana_dashboard (Kamila Součková) + +4.4.2: 2017-03-08 + * Core: Fix suppression of manifests' outputs (Darko Poljak) + * Type __user_groups: Support FreeBSD (Andres Erbsen) + * Type __cron: Fix filter for new cron on sles12 sp2 (Daniel Heule) + * Type __docker: Support absent state (Dominique Roux) + * Type __docker_compose: Support absent state (Dominique Roux) + * New type: __hosts (Dmitry Bogatov) + * New type: __dot_file (Dmitry Bogatov) + +4.4.1: 2016-12-17 + * Documentation: Update docs for types that used man.rst as symbolic links (Darko Poljak) + * Type __cron: Remove '# marker' for raw_command due to cron security (Daniel Heule) + * New type: __docker_compose (Dominique Roux) * Type __apt_mark: Check supported apt version and if package is installed (Ander Punnar) * New type: __docker (Steven Armstrong) * New type: __package_dpkg (Tomas Pospisek) 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 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 diff --git a/docs/src/man1/cdist.rst b/docs/src/man1/cdist.rst index 55901300..72cee4cc 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 @@ -267,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 @@ -297,5 +298,5 @@ 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+).