From 54ca7b40c7b546e6460850ba1606d3858800e39c Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 6 Mar 2018 22:33:10 +0100 Subject: [PATCH 0001/1217] Update consul agent init script so that it works again on Devuan Error before: ---- BEGIN code-remote:stderr ---- insserv: warning: script 'consul' missing LSB tags and overrides insserv: There is a loop between service monit and consul if stopped insserv: loop involving service consul at depth 2 insserv: loop involving service monit at depth 1 insserv: Stopping consul depends on monit and therefore on system facility `$all' which can not be true! insserv: exiting now without changing boot order! update-rc.d: error: insserv rejected the script header --- .../type/__consul_agent/files/consul.sysv-debian | 13 ++++++++++++- docs/changelog | 1 + 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/cdist/conf/type/__consul_agent/files/consul.sysv-debian b/cdist/conf/type/__consul_agent/files/consul.sysv-debian index a75c555d..a699e64a 100644 --- a/cdist/conf/type/__consul_agent/files/consul.sysv-debian +++ b/cdist/conf/type/__consul_agent/files/consul.sysv-debian @@ -1,6 +1,6 @@ #!/bin/sh # -# 2015 Nico Schottelius (nico-cdist at schottelius.org) +# 2015-2018 Nico Schottelius (nico-cdist at schottelius.org) # 2015 Steven Armstrong (steven-cdist at armstrong.cc) # # This file is part of cdist. @@ -18,6 +18,17 @@ # You should have received a copy of the GNU General Public License # along with cdist. If not, see . # +### BEGIN INIT INFO +# Provides: consul +# Required-Start: $remote_fs +# Required-Stop: $remote_fs +# Should-Start: $all +# Should-Stop: $all +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: consul +# Description: consul agent +### END INIT INFO if [ -f "/etc/default/consul" ]; then . /etc/default/consul diff --git a/docs/changelog b/docs/changelog index 0b5c5f17..22249b92 100644 --- a/docs/changelog +++ b/docs/changelog @@ -16,6 +16,7 @@ next: * New type: __apt_default_release (Matthijs Kooijman) * Type __file: Add pre-exists state (Matthijs Kooijman) * Type __grafana_dashboard: Add support for stretch + ascii (Nico Schottelius) + * Type __consul_agent: Update Debian Sys-V-Init script (Nico Schottelius) 4.8.0: 2018-02-14 * Core: Skip empty lines in parameter files (Darko Poljak) From 7d20eb91872095e79bb22e23ee8374dc125efad7 Mon Sep 17 00:00:00 2001 From: Kamila Souckova Date: Sun, 25 Mar 2018 21:27:43 +0200 Subject: [PATCH 0002/1217] add freebsd support to a few types --- cdist/conf/type/__hostname/gencode-remote | 4 +-- cdist/conf/type/__hostname/manifest | 7 +++++ .../conf/type/__start_on_boot/explorer/state | 4 +++ .../conf/type/__start_on_boot/gencode-remote | 4 +++ cdist/conf/type/__start_on_boot/manifest | 28 +++++++++++++++++++ cdist/conf/type/__sysctl/gencode-remote | 12 +++++++- cdist/conf/type/__sysctl/manifest | 2 +- 7 files changed, 57 insertions(+), 4 deletions(-) create mode 100644 cdist/conf/type/__start_on_boot/manifest diff --git a/cdist/conf/type/__hostname/gencode-remote b/cdist/conf/type/__hostname/gencode-remote index dbffad61..89bf7b3f 100755 --- a/cdist/conf/type/__hostname/gencode-remote +++ b/cdist/conf/type/__hostname/gencode-remote @@ -40,7 +40,7 @@ case "$os" in exit 0 fi ;; - scientific|centos|openbsd) + scientific|centos|freebsd|openbsd) if [ "$name_sysconfig" = "$name_should" -a "$name_running" = "$name_should" ]; then exit 0 fi @@ -62,7 +62,7 @@ case "$os" in echo "printf '%s\n' '$name_should' > /etc/hostname" echo "hostname -F /etc/hostname" ;; - openbsd) + freebsd|openbsd) echo "hostname '$name_should'" ;; suse) diff --git a/cdist/conf/type/__hostname/manifest b/cdist/conf/type/__hostname/manifest index 4836c501..74664aa7 100755 --- a/cdist/conf/type/__hostname/manifest +++ b/cdist/conf/type/__hostname/manifest @@ -52,6 +52,13 @@ case "$os" in --key HOSTNAME \ --value "$name_should" --exact_delimiter ;; + freebsd) + __key_value rcconf-hostname \ + --file /etc/rc.conf \ + --delimiter '=' \ + --key 'hostname' \ + --value "$name_should" + ;; openbsd) echo "$name_should" | __file /etc/myname --source - ;; diff --git a/cdist/conf/type/__start_on_boot/explorer/state b/cdist/conf/type/__start_on_boot/explorer/state index d49f01c7..d8f9b7ba 100644 --- a/cdist/conf/type/__start_on_boot/explorer/state +++ b/cdist/conf/type/__start_on_boot/explorer/state @@ -64,6 +64,10 @@ else state="present" [ -f "/etc/runlevels/${target_runlevel}/${name}" ] || state="absent" ;; + freebsd) + state="absent" + service -e | grep "/$name$" && state="present" + ;; *) echo "Unsupported os: $os" >&2 exit 1 diff --git a/cdist/conf/type/__start_on_boot/gencode-remote b/cdist/conf/type/__start_on_boot/gencode-remote index 63f0ba3c..14ee7dab 100755 --- a/cdist/conf/type/__start_on_boot/gencode-remote +++ b/cdist/conf/type/__start_on_boot/gencode-remote @@ -77,6 +77,10 @@ case "$state_should" in echo "update-rc.d \"$name\" defaults >/dev/null" ;; + freebsd) + : # handled in manifest + ;; + *) echo "Unsupported os: $os" >&2 exit 1 diff --git a/cdist/conf/type/__start_on_boot/manifest b/cdist/conf/type/__start_on_boot/manifest new file mode 100644 index 00000000..8bc323dc --- /dev/null +++ b/cdist/conf/type/__start_on_boot/manifest @@ -0,0 +1,28 @@ +#!/bin/sh -e + +state_should="$(cat "$__object/parameter/state")" +state_is=$(cat "$__object/explorer/state") +name="$__object_id" + +# Short circuit if nothing is to be done +[ "$state_should" = "$state_is" ] && exit 0 + +os=$(cat "$__global/explorer/os") + +case "$os" in + freebsd) + if [ "$state_should" == 'present' ]; then + value='YES' + else + value='NO' + fi + __key_value rcconf-$name-enable \ + --file /etc/rc.conf \ + --key "${name}_enable" \ + --value "\"$value\"" \ + --delimiter '=' + ;; + *) + : # handled in gencode-remote + ;; +esac diff --git a/cdist/conf/type/__sysctl/gencode-remote b/cdist/conf/type/__sysctl/gencode-remote index b7fb02c8..a7aedb84 100755 --- a/cdist/conf/type/__sysctl/gencode-remote +++ b/cdist/conf/type/__sysctl/gencode-remote @@ -26,5 +26,15 @@ if [ "$value_should" = "$value_is" ]; then exit 0 fi +os=$(cat "$__global/explorer/os") +case "$os" in + redhat|centos|ubuntu|debian|devuan|archlinux|coreos) + flag='-w' + ;; + frebsd) + flag='' + ;; +esac + # set the current runtime value -printf 'sysctl -w %s="%s"\n' "$__object_id" "$value_should" +printf 'sysctl %s %s="%s"\n' "$flag" "$__object_id" "$value_should" diff --git a/cdist/conf/type/__sysctl/manifest b/cdist/conf/type/__sysctl/manifest index 39a2e53c..c903dbae 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|devuan|archlinux|coreos) + redhat|centos|ubuntu|debian|devuan|archlinux|coreos|freebsd) : ;; *) From edf312a26ce8b481b22bb1772469549a12df438d Mon Sep 17 00:00:00 2001 From: Kamila Souckova Date: Sun, 25 Mar 2018 21:27:58 +0200 Subject: [PATCH 0003/1217] add explorer: is-freebsd-jail --- cdist/conf/explorer/is-freebsd-jail | 1 + 1 file changed, 1 insertion(+) create mode 100644 cdist/conf/explorer/is-freebsd-jail diff --git a/cdist/conf/explorer/is-freebsd-jail b/cdist/conf/explorer/is-freebsd-jail new file mode 100644 index 00000000..a6d11d1a --- /dev/null +++ b/cdist/conf/explorer/is-freebsd-jail @@ -0,0 +1 @@ +sysctl -n security.jail.jailed 2>/dev/null | grep "1" || true From ad6a978229b6222024ceb6bb82f7a0ff0b26d9fa Mon Sep 17 00:00:00 2001 From: Kamila Souckova Date: Sun, 25 Mar 2018 21:47:33 +0200 Subject: [PATCH 0004/1217] I hate shell --- cdist/conf/type/__start_on_boot/manifest | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cdist/conf/type/__start_on_boot/manifest b/cdist/conf/type/__start_on_boot/manifest index 8bc323dc..b9ee20e2 100644 --- a/cdist/conf/type/__start_on_boot/manifest +++ b/cdist/conf/type/__start_on_boot/manifest @@ -11,7 +11,7 @@ os=$(cat "$__global/explorer/os") case "$os" in freebsd) - if [ "$state_should" == 'present' ]; then + if [ "$state_should" = 'present' ]; then value='YES' else value='NO' From b695e82becffc0c13243b517df05ab9a7d1d3d71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamila=20Sou=C4=8Dkov=C3=A1?= Date: Mon, 26 Mar 2018 08:53:31 +0200 Subject: [PATCH 0005/1217] FreeBSD improvements (#651) --- cdist/conf/explorer/is-freebsd-jail | 1 + cdist/conf/type/__hostname/gencode-remote | 4 +-- cdist/conf/type/__hostname/manifest | 7 +++++ .../conf/type/__start_on_boot/explorer/state | 4 +++ .../conf/type/__start_on_boot/gencode-remote | 4 +++ cdist/conf/type/__start_on_boot/manifest | 28 +++++++++++++++++++ cdist/conf/type/__sysctl/gencode-remote | 12 +++++++- cdist/conf/type/__sysctl/manifest | 2 +- 8 files changed, 58 insertions(+), 4 deletions(-) create mode 100644 cdist/conf/explorer/is-freebsd-jail create mode 100644 cdist/conf/type/__start_on_boot/manifest diff --git a/cdist/conf/explorer/is-freebsd-jail b/cdist/conf/explorer/is-freebsd-jail new file mode 100644 index 00000000..a6d11d1a --- /dev/null +++ b/cdist/conf/explorer/is-freebsd-jail @@ -0,0 +1 @@ +sysctl -n security.jail.jailed 2>/dev/null | grep "1" || true diff --git a/cdist/conf/type/__hostname/gencode-remote b/cdist/conf/type/__hostname/gencode-remote index dbffad61..89bf7b3f 100755 --- a/cdist/conf/type/__hostname/gencode-remote +++ b/cdist/conf/type/__hostname/gencode-remote @@ -40,7 +40,7 @@ case "$os" in exit 0 fi ;; - scientific|centos|openbsd) + scientific|centos|freebsd|openbsd) if [ "$name_sysconfig" = "$name_should" -a "$name_running" = "$name_should" ]; then exit 0 fi @@ -62,7 +62,7 @@ case "$os" in echo "printf '%s\n' '$name_should' > /etc/hostname" echo "hostname -F /etc/hostname" ;; - openbsd) + freebsd|openbsd) echo "hostname '$name_should'" ;; suse) diff --git a/cdist/conf/type/__hostname/manifest b/cdist/conf/type/__hostname/manifest index 4836c501..74664aa7 100755 --- a/cdist/conf/type/__hostname/manifest +++ b/cdist/conf/type/__hostname/manifest @@ -52,6 +52,13 @@ case "$os" in --key HOSTNAME \ --value "$name_should" --exact_delimiter ;; + freebsd) + __key_value rcconf-hostname \ + --file /etc/rc.conf \ + --delimiter '=' \ + --key 'hostname' \ + --value "$name_should" + ;; openbsd) echo "$name_should" | __file /etc/myname --source - ;; diff --git a/cdist/conf/type/__start_on_boot/explorer/state b/cdist/conf/type/__start_on_boot/explorer/state index d49f01c7..d8f9b7ba 100644 --- a/cdist/conf/type/__start_on_boot/explorer/state +++ b/cdist/conf/type/__start_on_boot/explorer/state @@ -64,6 +64,10 @@ else state="present" [ -f "/etc/runlevels/${target_runlevel}/${name}" ] || state="absent" ;; + freebsd) + state="absent" + service -e | grep "/$name$" && state="present" + ;; *) echo "Unsupported os: $os" >&2 exit 1 diff --git a/cdist/conf/type/__start_on_boot/gencode-remote b/cdist/conf/type/__start_on_boot/gencode-remote index 63f0ba3c..14ee7dab 100755 --- a/cdist/conf/type/__start_on_boot/gencode-remote +++ b/cdist/conf/type/__start_on_boot/gencode-remote @@ -77,6 +77,10 @@ case "$state_should" in echo "update-rc.d \"$name\" defaults >/dev/null" ;; + freebsd) + : # handled in manifest + ;; + *) echo "Unsupported os: $os" >&2 exit 1 diff --git a/cdist/conf/type/__start_on_boot/manifest b/cdist/conf/type/__start_on_boot/manifest new file mode 100644 index 00000000..b9ee20e2 --- /dev/null +++ b/cdist/conf/type/__start_on_boot/manifest @@ -0,0 +1,28 @@ +#!/bin/sh -e + +state_should="$(cat "$__object/parameter/state")" +state_is=$(cat "$__object/explorer/state") +name="$__object_id" + +# Short circuit if nothing is to be done +[ "$state_should" = "$state_is" ] && exit 0 + +os=$(cat "$__global/explorer/os") + +case "$os" in + freebsd) + if [ "$state_should" = 'present' ]; then + value='YES' + else + value='NO' + fi + __key_value rcconf-$name-enable \ + --file /etc/rc.conf \ + --key "${name}_enable" \ + --value "\"$value\"" \ + --delimiter '=' + ;; + *) + : # handled in gencode-remote + ;; +esac diff --git a/cdist/conf/type/__sysctl/gencode-remote b/cdist/conf/type/__sysctl/gencode-remote index b7fb02c8..a7aedb84 100755 --- a/cdist/conf/type/__sysctl/gencode-remote +++ b/cdist/conf/type/__sysctl/gencode-remote @@ -26,5 +26,15 @@ if [ "$value_should" = "$value_is" ]; then exit 0 fi +os=$(cat "$__global/explorer/os") +case "$os" in + redhat|centos|ubuntu|debian|devuan|archlinux|coreos) + flag='-w' + ;; + frebsd) + flag='' + ;; +esac + # set the current runtime value -printf 'sysctl -w %s="%s"\n' "$__object_id" "$value_should" +printf 'sysctl %s %s="%s"\n' "$flag" "$__object_id" "$value_should" diff --git a/cdist/conf/type/__sysctl/manifest b/cdist/conf/type/__sysctl/manifest index 39a2e53c..c903dbae 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|devuan|archlinux|coreos) + redhat|centos|ubuntu|debian|devuan|archlinux|coreos|freebsd) : ;; *) From 60eba4214137f2eb43052066cae8e585629603d4 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Mon, 26 Mar 2018 08:52:41 +0200 Subject: [PATCH 0006/1217] ++changelog --- docs/changelog | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/changelog b/docs/changelog index 272d1751..ce5a169d 100644 --- a/docs/changelog +++ b/docs/changelog @@ -3,6 +3,8 @@ Changelog next: * Documentation, type manpages: Fix spelling (Dmitry Bogatov) + * New explorer: is-freebsd-jail (Kamila Součková) + * Types __hostname, __start_on_boot, __sysctl: Support FreeBSD (Kamila Součková) 4.8.3: 2018-03-16 * Type __key_value: Add onchange parameter (Kamila Součková) From 999f221c880f2209c178627c892c5ec3fefebfb6 Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Thu, 5 Apr 2018 10:32:33 +0200 Subject: [PATCH 0007/1217] need a way to distinguish between install-config and normal config Signed-off-by: Steven Armstrong --- cdist/conf/type/__install_config/gencode-local | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cdist/conf/type/__install_config/gencode-local b/cdist/conf/type/__install_config/gencode-local index 8f24cf2e..dd4f2a78 100755 --- a/cdist/conf/type/__install_config/gencode-local +++ b/cdist/conf/type/__install_config/gencode-local @@ -1,6 +1,6 @@ #!/bin/sh -e # -# 2011-2017 Steven Armstrong (steven-cdist at armstrong.cc) +# 2011-2018 Steven Armstrong (steven-cdist at armstrong.cc) # # This file is part of cdist. # @@ -23,6 +23,7 @@ remote_exec="$__type/files/remote/exec" remote_copy="$__type/files/remote/copy" cat << DONE +export __cdist_install_config=yes export __cdist_log_level=$__cdist_log_level export __default_remote_exec="$__remote_exec" export __default_remote_copy="$__remote_copy" From 43a65d91b10cb2e393bf74e74a09f0e597992f32 Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Thu, 5 Apr 2018 10:36:38 +0200 Subject: [PATCH 0008/1217] changelog++ Signed-off-by: Steven Armstrong --- docs/changelog | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/changelog b/docs/changelog index ce5a169d..bd8996cb 100644 --- a/docs/changelog +++ b/docs/changelog @@ -5,6 +5,8 @@ next: * Documentation, type manpages: Fix spelling (Dmitry Bogatov) * New explorer: is-freebsd-jail (Kamila Součková) * Types __hostname, __start_on_boot, __sysctl: Support FreeBSD (Kamila Součková) + * Type __install_config: set environment variable to distinguish between + install-config and regular config (Steven Armstrong) 4.8.3: 2018-03-16 * Type __key_value: Add onchange parameter (Kamila Součková) From f09765a03af9fe9576acff4041b342d2ffb6324d Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Tue, 17 Apr 2018 11:15:28 +0200 Subject: [PATCH 0009/1217] Improve error reporting. --- cdist/__init__.py | 81 +++++++++++++++++++++++++++++++++----------- cdist/config.py | 3 +- cdist/exec/local.py | 6 ++-- cdist/exec/remote.py | 6 ++-- cdist/exec/util.py | 1 + 5 files changed, 68 insertions(+), 29 deletions(-) diff --git a/cdist/__init__.py b/cdist/__init__.py index e6fdfac6..b1b9df9f 100644 --- a/cdist/__init__.py +++ b/cdist/__init__.py @@ -83,41 +83,72 @@ class CdistBetaRequired(cdist.Error): class CdistEntityError(Error): """Something went wrong while executing cdist entity""" - def __init__(self, entity_name, entity_params, stderr_paths, subject=''): + def __init__(self, entity_name, entity_params, stdout_paths, + stderr_paths, subject=''): self.entity_name = entity_name self.entity_params = entity_params self.stderr_paths = stderr_paths + self.stdout_paths = stdout_paths if isinstance(subject, Error): self.original_error = subject else: self.original_error = None self.message = str(subject) - @property - def stderr(self): - output = [] - for stderr_name, stderr_path in self.stderr_paths: - if (os.path.exists(stderr_path) and - os.path.getsize(stderr_path) > 0): - label_begin = '---- BEGIN ' + stderr_name + ':stderr ----' - label_end = '---- END ' + stderr_name + ':stderr ----' - output.append('\n' + label_begin) - with open(stderr_path, 'r') as fd: + def _stdpath(self, stdpaths, header_name): + result = {} + for name, path in stdpaths: + if name not in result: + result[name] = [] + if os.path.exists(path) and os.path.getsize(path) > 0: + output = [] + label_begin = name + ":" + header_name + output.append(label_begin) + output.append('\n') + output.append('-' * len(label_begin)) + output.append('\n') + with open(path, 'r') as fd: output.append(fd.read()) - output.append(label_end) - return '\n'.join(output) + output.append('\n') + result[name].append(''.join(output)) + return result + + def _stderr(self): + return self._stdpath(self.stderr_paths, 'stderr') + + def _stdout(self): + return self._stdpath(self.stdout_paths, 'stdout') + + def _update_dict_list(self, target, source): + for x in source: + if x not in target: + target[x] = [] + target[x].extend(source[x]) + + @property + def std_streams(self): + std_dict = {} + self._update_dict_list(std_dict, self._stdout()) + self._update_dict_list(std_dict, self._stderr()) + return std_dict def __str__(self): output = [] output.append(self.message) - header = "\nError processing " + self.entity_name + output.append('\n\n') + header = "Error processing " + self.entity_name under_header = '=' * len(header) output.append(header) + output.append('\n') output.append(under_header) + output.append('\n') for param_name, param_value in self.entity_params: output.append(param_name + ': ' + str(param_value)) - output.append(self.stderr + '\n') - return '\n'.join(output) + output.append('\n') + output.append('\n') + for x in self.std_streams: + output.append(''.join(self.std_streams[x])) + return ''.join(output) class CdistObjectError(CdistEntityError): @@ -127,28 +158,38 @@ class CdistObjectError(CdistEntityError): ('name', cdist_object.name, ), ('path', cdist_object.absolute_path, ), ('source', " ".join(cdist_object.source), ), - ('type', cdist_object.cdist_type.absolute_path, ), + ('type', os.path.realpath(cdist_object.cdist_type.absolute_path), ), ] stderr_paths = [] for stderr_name in os.listdir(cdist_object.stderr_path): stderr_path = os.path.join(cdist_object.stderr_path, stderr_name) stderr_paths.append((stderr_name, stderr_path, )) + stdout_paths = [] + for stdout_name in os.listdir(cdist_object.stdout_path): + stdout_path = os.path.join(cdist_object.stdout_path, + stdout_name) + stdout_paths.append((stdout_name, stdout_path, )) super().__init__("object '{}'".format(cdist_object.name), - params, stderr_paths, subject) + params, stdout_paths, stderr_paths, subject) class InitialManifestError(CdistEntityError): """Something went wrong while executing initial manifest""" - def __init__(self, initial_manifest, stderr_path, subject=''): + def __init__(self, initial_manifest, stdout_path, stderr_path, subject=''): params = [ ('path', initial_manifest, ), ] + stdout_paths = [] + stdout_paths = [ + ('init', stdout_path, ), + ] stderr_paths = [] stderr_paths = [ ('init', stderr_path, ), ] - super().__init__('initial manifest', params, stderr_paths, subject) + super().__init__('initial manifest', params, stdout_paths, + stderr_paths, subject) def file_to_list(filename): diff --git a/cdist/config.py b/cdist/config.py index 74f68a72..2dcb1005 100644 --- a/cdist/config.py +++ b/cdist/config.py @@ -440,9 +440,10 @@ class Config(object): self.manifest.run_initial_manifest(self.local.initial_manifest) except cdist.Error as e: which = "init" + stdout_path = os.path.join(self.local.stdout_base_path, which) stderr_path = os.path.join(self.local.stderr_base_path, which) raise cdist.InitialManifestError(self.local.initial_manifest, - stderr_path, e) + stdout_path, stderr_path, e) self.iterate_until_finished() self.cleanup() self._remove_files_dirs() diff --git a/cdist/exec/local.py b/cdist/exec/local.py index a50fe072..f83c85df 100644 --- a/cdist/exec/local.py +++ b/cdist/exec/local.py @@ -259,10 +259,8 @@ class Local(object): util.log_std_fd(self.log, command, stderr, 'Local stderr') util.log_std_fd(self.log, command, stdout, 'Local stdout') return output - except subprocess.CalledProcessError as e: - util.handle_called_process_error(e, command) - except OSError as error: - raise cdist.Error(" ".join(command) + ": " + error.args[1]) + except (OSError, subprocess.CalledProcessError) as error: + raise cdist.Error(" ".join(command) + ": " + str(error.args[1])) finally: if message_prefix: message.merge_messages() diff --git a/cdist/exec/remote.py b/cdist/exec/remote.py index b75905ba..4466545e 100644 --- a/cdist/exec/remote.py +++ b/cdist/exec/remote.py @@ -343,10 +343,8 @@ class Remote(object): util.log_std_fd(self.log, command, stdout, 'Remote stdout') return output - except subprocess.CalledProcessError as e: - util.handle_called_process_error(e, command) - except OSError as error: - raise cdist.Error(" ".join(command) + ": " + error.args[1]) + except (OSError, subprocess.CalledProcessError) as error: + raise cdist.Error(" ".join(command) + ": " + str(error.args[1])) except UnicodeDecodeError: raise DecodeError(command) finally: diff --git a/cdist/exec/util.py b/cdist/exec/util.py index 2f2aa38c..c96f757b 100644 --- a/cdist/exec/util.py +++ b/cdist/exec/util.py @@ -127,6 +127,7 @@ def call_get_output(command, env=None, stderr=None): return (_call_get_stdout(command, env, stderr), None) +# Currently not used. def handle_called_process_error(err, command): # Currently, stderr is not captured. # errout = None From 2a9057f892f67014a67a34ffb260318ea8465349 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Thu, 19 Apr 2018 17:53:47 +0200 Subject: [PATCH 0010/1217] ++changelog --- docs/changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog b/docs/changelog index bd8996cb..e958ddff 100644 --- a/docs/changelog +++ b/docs/changelog @@ -7,6 +7,7 @@ next: * Types __hostname, __start_on_boot, __sysctl: Support FreeBSD (Kamila Součková) * Type __install_config: set environment variable to distinguish between install-config and regular config (Steven Armstrong) + * Core: Improve error reporting (Darko Poljak) 4.8.3: 2018-03-16 * Type __key_value: Add onchange parameter (Kamila Součková) From 7349da777be5316a9130033af7f9ebf852ddb02d Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Fri, 20 Apr 2018 14:24:51 +0200 Subject: [PATCH 0011/1217] ++changelog --- docs/changelog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/changelog b/docs/changelog index e958ddff..681256fc 100644 --- a/docs/changelog +++ b/docs/changelog @@ -6,7 +6,7 @@ next: * New explorer: is-freebsd-jail (Kamila Součková) * Types __hostname, __start_on_boot, __sysctl: Support FreeBSD (Kamila Součková) * Type __install_config: set environment variable to distinguish between - install-config and regular config (Steven Armstrong) + install-config and regular config (Steven Armstrong) * Core: Improve error reporting (Darko Poljak) 4.8.3: 2018-03-16 From 09642142f478ee61b804f7ad1f6f5ecd6fd70d66 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Fri, 20 Apr 2018 14:31:10 +0200 Subject: [PATCH 0012/1217] Release 4.8.4 --- cdist/__init__.py | 3 ++- docs/changelog | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/cdist/__init__.py b/cdist/__init__.py index b1b9df9f..b7602ff8 100644 --- a/cdist/__init__.py +++ b/cdist/__init__.py @@ -158,7 +158,8 @@ class CdistObjectError(CdistEntityError): ('name', cdist_object.name, ), ('path', cdist_object.absolute_path, ), ('source', " ".join(cdist_object.source), ), - ('type', os.path.realpath(cdist_object.cdist_type.absolute_path), ), + ('type', os.path.realpath( + cdist_object.cdist_type.absolute_path), ), ] stderr_paths = [] for stderr_name in os.listdir(cdist_object.stderr_path): diff --git a/docs/changelog b/docs/changelog index 681256fc..6330a149 100644 --- a/docs/changelog +++ b/docs/changelog @@ -1,7 +1,7 @@ Changelog --------- -next: +4.8.4: 2018-04-20 * Documentation, type manpages: Fix spelling (Dmitry Bogatov) * New explorer: is-freebsd-jail (Kamila Součková) * Types __hostname, __start_on_boot, __sysctl: Support FreeBSD (Kamila Součková) From aa20ed5ea1b3c833acc78c54166f655c2b9cd355 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=BDubom=C3=ADr=20Ku=C4=8Dera?= Date: Sun, 29 Apr 2018 13:02:18 +0200 Subject: [PATCH 0013/1217] __docker_stack: Use --with-registry-auth deploy option Without this option, Swarm agents are unable to download images from private registries. --- cdist/conf/type/__docker_stack/gencode-remote | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cdist/conf/type/__docker_stack/gencode-remote b/cdist/conf/type/__docker_stack/gencode-remote index 0d47dc52..586271d0 100755 --- a/cdist/conf/type/__docker_stack/gencode-remote +++ b/cdist/conf/type/__docker_stack/gencode-remote @@ -50,7 +50,7 @@ case "${state}" in eof docker stack deploy --compose-file "\${compose_file}" \ - --prune ${stack} + --prune --with-registry-auth ${stack} rm "\${compose_file}" EOF From 3869940fc8ae4a8c35656298ce40146a111b7064 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Sun, 29 Apr 2018 20:39:39 +0200 Subject: [PATCH 0014/1217] ++changelog --- docs/changelog | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/changelog b/docs/changelog index 6330a149..74d6d7c6 100644 --- a/docs/changelog +++ b/docs/changelog @@ -1,6 +1,9 @@ Changelog --------- +next: + * Type __docker_stack: Use --with-registry-auth option (Ľubomír Kučera) + 4.8.4: 2018-04-20 * Documentation, type manpages: Fix spelling (Dmitry Bogatov) * New explorer: is-freebsd-jail (Kamila Součková) From 4f61f6be9cd2052ede37dfb184211e23e9ec6328 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=BDubom=C3=ADr=20Ku=C4=8Dera?= Date: Mon, 30 Apr 2018 12:50:09 +0200 Subject: [PATCH 0015/1217] Add new type __docker_config --- .../type/__docker_config/explorer/config-data | 21 ++++++ .../__docker_config/explorer/config-exists | 25 +++++++ .../conf/type/__docker_config/gencode-remote | 69 +++++++++++++++++++ cdist/conf/type/__docker_config/man.rst | 55 +++++++++++++++ .../__docker_config/parameter/default/source | 0 .../__docker_config/parameter/default/state | 1 + .../type/__docker_config/parameter/optional | 2 + 7 files changed, 173 insertions(+) create mode 100644 cdist/conf/type/__docker_config/explorer/config-data create mode 100755 cdist/conf/type/__docker_config/explorer/config-exists create mode 100755 cdist/conf/type/__docker_config/gencode-remote create mode 100644 cdist/conf/type/__docker_config/man.rst create mode 100644 cdist/conf/type/__docker_config/parameter/default/source create mode 100644 cdist/conf/type/__docker_config/parameter/default/state create mode 100644 cdist/conf/type/__docker_config/parameter/optional diff --git a/cdist/conf/type/__docker_config/explorer/config-data b/cdist/conf/type/__docker_config/explorer/config-data new file mode 100644 index 00000000..926a795d --- /dev/null +++ b/cdist/conf/type/__docker_config/explorer/config-data @@ -0,0 +1,21 @@ +#!/bin/sh -e +# +# 2018 Ľubomír Kučera +# +# 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 . +# + +docker config inspect "${__object_id:?}" | jq -r '.[0].Spec.Data' | base64 -d diff --git a/cdist/conf/type/__docker_config/explorer/config-exists b/cdist/conf/type/__docker_config/explorer/config-exists new file mode 100755 index 00000000..58c207d4 --- /dev/null +++ b/cdist/conf/type/__docker_config/explorer/config-exists @@ -0,0 +1,25 @@ +#!/bin/sh -e +# +# 2018 Ľubomír Kučera +# +# This file is part of cdist. +# +# cdist is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# cdist is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with cdist. If not, see . +# + +if docker config ls | grep -q " ${__object_id:?} "; then + echo yes +else + echo no +fi diff --git a/cdist/conf/type/__docker_config/gencode-remote b/cdist/conf/type/__docker_config/gencode-remote new file mode 100755 index 00000000..65497b7e --- /dev/null +++ b/cdist/conf/type/__docker_config/gencode-remote @@ -0,0 +1,69 @@ +#!/bin/sh -e +# +# 2018 Ľubomír Kučera +# +# 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 . +# + +config="${__object_id:?}" +config_exists=$(cat "${__object:?}/explorer/config-exists") +state=$(cat "${__object:?}/parameter/state") + +case "${state}" in + absent) + if [ "${config_exists}" != "yes" ]; then + exit 0 + fi + + echo "docker config rm \"${config}\"" + ;; + present) + source=$(cat "${__object}/parameter/source") + + if [ -z "${source}" ]; then + exit 0 + fi + + if [ "${source}" = "-" ]; then + source="${__object}/stdin" + fi + + if [ "${config_exists}" = "yes" ]; then + if cmp -s "${source}" "${__object}/explorer/config-data"; then + exit 0 + else + echo "docker config rm \"${config}\"" + fi + fi + + cat <<-EOF + source_file="\$(mktemp cdist.XXXXXXXXXX)" + + base64 -d > "\${source_file}" << eof + $(base64 "${source}") + eof + + docker config create "${config}" "\${source_file}" + + rm "\${source_file}" + EOF + ;; + *) + echo "Unsupported state: ${state}" >&2 + + exit 1 + ;; +esac diff --git a/cdist/conf/type/__docker_config/man.rst b/cdist/conf/type/__docker_config/man.rst new file mode 100644 index 00000000..7c74c8af --- /dev/null +++ b/cdist/conf/type/__docker_config/man.rst @@ -0,0 +1,55 @@ +cdist-type__docker_config(7) +============================ + +NAME +---- + +cdist-type__docker_config - Manage Docker configs + +DESCRIPTION +----------- + +This type manages Docker configs. + +OPTIONAL PARAMETERS +------------------- + +source + Path to the source file. If it is '-' (dash), read standard input. + +state + 'present' or 'absent', defaults to 'present' where: + + present + if the config does not exist, it is created + absent + the config is removed + +CAVEATS +------- + +Since Docker configs cannot be updated once created, this type tries removing +and recreating the config if it changes. If the config is used by a service at +the time of removing, then this type will fail. + +EXAMPLES +-------- + +.. code-block:: sh + + # Creates "foo" config from "bar" source file + __docker_config foo --source bar + + +AUTHORS +------- + +Ľubomír Kučera + +COPYING +------- + +Copyright \(C) 2018 Ľubomír Kučera. 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/__docker_config/parameter/default/source b/cdist/conf/type/__docker_config/parameter/default/source new file mode 100644 index 00000000..e69de29b diff --git a/cdist/conf/type/__docker_config/parameter/default/state b/cdist/conf/type/__docker_config/parameter/default/state new file mode 100644 index 00000000..e7f6134f --- /dev/null +++ b/cdist/conf/type/__docker_config/parameter/default/state @@ -0,0 +1 @@ +present diff --git a/cdist/conf/type/__docker_config/parameter/optional b/cdist/conf/type/__docker_config/parameter/optional new file mode 100644 index 00000000..d77f3048 --- /dev/null +++ b/cdist/conf/type/__docker_config/parameter/optional @@ -0,0 +1,2 @@ +source +state From 5a7d74b90542de9ad179268c0561fbffbf0c8f1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=BDubom=C3=ADr=20Ku=C4=8Dera?= Date: Mon, 30 Apr 2018 12:52:54 +0200 Subject: [PATCH 0016/1217] Add new type __docker_secret --- .../__docker_secret/explorer/secret-exists | 25 +++++++ .../conf/type/__docker_secret/gencode-remote | 65 +++++++++++++++++++ cdist/conf/type/__docker_secret/man.rst | 54 +++++++++++++++ .../__docker_secret/parameter/default/source | 0 .../__docker_secret/parameter/default/state | 1 + .../type/__docker_secret/parameter/optional | 2 + 6 files changed, 147 insertions(+) create mode 100644 cdist/conf/type/__docker_secret/explorer/secret-exists create mode 100644 cdist/conf/type/__docker_secret/gencode-remote create mode 100644 cdist/conf/type/__docker_secret/man.rst create mode 100644 cdist/conf/type/__docker_secret/parameter/default/source create mode 100644 cdist/conf/type/__docker_secret/parameter/default/state create mode 100644 cdist/conf/type/__docker_secret/parameter/optional diff --git a/cdist/conf/type/__docker_secret/explorer/secret-exists b/cdist/conf/type/__docker_secret/explorer/secret-exists new file mode 100644 index 00000000..1405f8bc --- /dev/null +++ b/cdist/conf/type/__docker_secret/explorer/secret-exists @@ -0,0 +1,25 @@ +#!/bin/sh -e +# +# 2018 Ľubomír Kučera +# +# This file is part of cdist. +# +# cdist is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# cdist is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with cdist. If not, see . +# + +if docker secret ls | grep -q " ${__object_id:?} "; then + echo yes +else + echo no +fi diff --git a/cdist/conf/type/__docker_secret/gencode-remote b/cdist/conf/type/__docker_secret/gencode-remote new file mode 100644 index 00000000..c75e91d9 --- /dev/null +++ b/cdist/conf/type/__docker_secret/gencode-remote @@ -0,0 +1,65 @@ +#!/bin/sh -e +# +# 2018 Ľubomír Kučera +# +# 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 . +# + +secret="${__object_id:?}" +secret_exists=$(cat "${__object:?}/explorer/secret-exists") +state=$(cat "${__object:?}/parameter/state") + +case "${state}" in + absent) + if [ "${secret_exists}" != "yes" ]; then + exit 0 + fi + + echo "docker secret rm ${secret}" + ;; + present) + if [ "${secret_exists}" = "yes" ]; then + exit 0 + fi + + source=$(cat "${__object}/parameter/source") + + if [ -z "${source}" ]; then + exit 0 + fi + + if [ "${source}" = "-" ]; then + source="${__object}/stdin" + fi + + cat <<-EOF + source_file="\$(mktemp cdist.XXXXXXXXXX)" + + base64 -d > "\${source_file}" << eof + $(base64 "${source}") + eof + + docker secret create "${secret}" "\${source_file}" + + rm "\${source_file}" + EOF + ;; + *) + echo "Unsupported state: ${state}" >&2 + + exit 1 + ;; +esac diff --git a/cdist/conf/type/__docker_secret/man.rst b/cdist/conf/type/__docker_secret/man.rst new file mode 100644 index 00000000..7fe69623 --- /dev/null +++ b/cdist/conf/type/__docker_secret/man.rst @@ -0,0 +1,54 @@ +cdist-type__docker_secret(7) +============================ + +NAME +---- + +cdist-type__docker_secret - Manage Docker secrets + +DESCRIPTION +----------- + +This type manages Docker secrets. + +OPTIONAL PARAMETERS +------------------- + +source + Path to the source file. If it is '-' (dash), read standard input. + +state + 'present' or 'absent', defaults to 'present' where: + + present + if the secret does not exist, it is created + absent + the secret is removed + +CAVEATS +------- + +Since Docker secrets cannot be updated once created, this type takes no action +if the specified secret already exists. + +EXAMPLES +-------- + +.. code-block:: sh + + # Creates "foo" secret from "bar" source file + __docker_secret foo --source bar + + +AUTHORS +------- + +Ľubomír Kučera + +COPYING +------- + +Copyright \(C) 2018 Ľubomír Kučera. 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/__docker_secret/parameter/default/source b/cdist/conf/type/__docker_secret/parameter/default/source new file mode 100644 index 00000000..e69de29b diff --git a/cdist/conf/type/__docker_secret/parameter/default/state b/cdist/conf/type/__docker_secret/parameter/default/state new file mode 100644 index 00000000..e7f6134f --- /dev/null +++ b/cdist/conf/type/__docker_secret/parameter/default/state @@ -0,0 +1 @@ +present diff --git a/cdist/conf/type/__docker_secret/parameter/optional b/cdist/conf/type/__docker_secret/parameter/optional new file mode 100644 index 00000000..d77f3048 --- /dev/null +++ b/cdist/conf/type/__docker_secret/parameter/optional @@ -0,0 +1,2 @@ +source +state From b5e96efcbff20f403e5a3f4c5f3ab31c76dfde9e Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Wed, 2 May 2018 08:35:12 +0200 Subject: [PATCH 0017/1217] ++changelog --- docs/changelog | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/changelog b/docs/changelog index 74d6d7c6..3bdf446b 100644 --- a/docs/changelog +++ b/docs/changelog @@ -3,6 +3,8 @@ Changelog next: * Type __docker_stack: Use --with-registry-auth option (Ľubomír Kučera) + * New type: __docker_config (Ľubomír Kučera) + * New type: __docker_secret (Ľubomír Kučera) 4.8.4: 2018-04-20 * Documentation, type manpages: Fix spelling (Dmitry Bogatov) From 1efbd6a3a054d44dd4c399274fc6cd3e417e887f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=BDubom=C3=ADr=20Ku=C4=8Dera?= Date: Fri, 4 May 2018 16:37:45 +0200 Subject: [PATCH 0018/1217] __docker_config: Fix config-data explorer Before this fix, the explorer returned binary data when config did not exist. This commit also removes dependency on jq and sets executable flag on the explorer file. --- cdist/conf/type/__docker_config/explorer/config-data | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) mode change 100644 => 100755 cdist/conf/type/__docker_config/explorer/config-data diff --git a/cdist/conf/type/__docker_config/explorer/config-data b/cdist/conf/type/__docker_config/explorer/config-data old mode 100644 new mode 100755 index 926a795d..b4bb0e11 --- a/cdist/conf/type/__docker_config/explorer/config-data +++ b/cdist/conf/type/__docker_config/explorer/config-data @@ -18,4 +18,5 @@ # along with cdist. If not, see . # -docker config inspect "${__object_id:?}" | jq -r '.[0].Spec.Data' | base64 -d +docker config inspect "${__object_id:?}" --format '{{json .Spec.Data}}' \ + 2>/dev/null | tr -d '"' | base64 -d From fdb5bbcf91389626f9e32f6909db1c3bd8c89abe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=BDubom=C3=ADr=20Ku=C4=8Dera?= Date: Fri, 4 May 2018 16:47:09 +0200 Subject: [PATCH 0019/1217] __docker_secret: Set executable flag on scripts --- cdist/conf/type/__docker_secret/explorer/secret-exists | 0 cdist/conf/type/__docker_secret/gencode-remote | 0 2 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 cdist/conf/type/__docker_secret/explorer/secret-exists mode change 100644 => 100755 cdist/conf/type/__docker_secret/gencode-remote diff --git a/cdist/conf/type/__docker_secret/explorer/secret-exists b/cdist/conf/type/__docker_secret/explorer/secret-exists old mode 100644 new mode 100755 diff --git a/cdist/conf/type/__docker_secret/gencode-remote b/cdist/conf/type/__docker_secret/gencode-remote old mode 100644 new mode 100755 From 22d570ae6084710d7af60dcd36ad9f0ec8ea882c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=BDubom=C3=ADr=20Ku=C4=8Dera?= Date: Mon, 7 May 2018 12:57:48 +0200 Subject: [PATCH 0020/1217] Rewrite __letsencrypt_cert type This commit adds the following features: * Ability to expand existing certificate * Ability to manage object state * Ability to obtain test certificate * Ability to promote test certificate to production * Ability to specify custom certificate name * Ability to specify multiple domains per certificate * Ability to use Certbot in standalone mode * Messaging This commit also introduces the following behavioral changes: * Attempt to install Certbot only when it is not installed already * Installation of the cron job has to be enabled using `--automatic-renewal` parameter **Note:** Object ID is now treated as certificate name and new required parameter `--domain` was added. --- .../__letsencrypt_cert/explorer/certbot-path | 3 + .../explorer/certificate-domains | 4 + .../explorer/certificate-exists | 7 + .../explorer/certificate-is-test | 8 + .../type/__letsencrypt_cert/explorer/exists | 5 - .../type/__letsencrypt_cert/gencode-remote | 85 ++++++++-- cdist/conf/type/__letsencrypt_cert/man.rst | 73 +++++++-- cdist/conf/type/__letsencrypt_cert/manifest | 152 ++++++++++-------- .../type/__letsencrypt_cert/parameter/boolean | 2 + .../parameter/default/state | 1 + .../parameter/default/webroot | 0 .../__letsencrypt_cert/parameter/optional | 2 + .../__letsencrypt_cert/parameter/required | 1 - .../parameter/required_multiple | 1 + 14 files changed, 239 insertions(+), 105 deletions(-) create mode 100755 cdist/conf/type/__letsencrypt_cert/explorer/certbot-path create mode 100755 cdist/conf/type/__letsencrypt_cert/explorer/certificate-domains create mode 100755 cdist/conf/type/__letsencrypt_cert/explorer/certificate-exists create mode 100755 cdist/conf/type/__letsencrypt_cert/explorer/certificate-is-test delete mode 100644 cdist/conf/type/__letsencrypt_cert/explorer/exists mode change 100644 => 100755 cdist/conf/type/__letsencrypt_cert/gencode-remote mode change 100644 => 100755 cdist/conf/type/__letsencrypt_cert/manifest create mode 100644 cdist/conf/type/__letsencrypt_cert/parameter/boolean create mode 100644 cdist/conf/type/__letsencrypt_cert/parameter/default/state create mode 100644 cdist/conf/type/__letsencrypt_cert/parameter/default/webroot create mode 100644 cdist/conf/type/__letsencrypt_cert/parameter/optional create mode 100644 cdist/conf/type/__letsencrypt_cert/parameter/required_multiple diff --git a/cdist/conf/type/__letsencrypt_cert/explorer/certbot-path b/cdist/conf/type/__letsencrypt_cert/explorer/certbot-path new file mode 100755 index 00000000..3c6076df --- /dev/null +++ b/cdist/conf/type/__letsencrypt_cert/explorer/certbot-path @@ -0,0 +1,3 @@ +#!/bin/sh -e + +command -v certbot 2>/dev/null || true diff --git a/cdist/conf/type/__letsencrypt_cert/explorer/certificate-domains b/cdist/conf/type/__letsencrypt_cert/explorer/certificate-domains new file mode 100755 index 00000000..367fda93 --- /dev/null +++ b/cdist/conf/type/__letsencrypt_cert/explorer/certificate-domains @@ -0,0 +1,4 @@ +#!/bin/sh -e + +certbot certificates --cert-name "${__object_id:?}" | grep ' Domains: ' | \ + cut -d ' ' -f 6- | tr ' ' '\n' diff --git a/cdist/conf/type/__letsencrypt_cert/explorer/certificate-exists b/cdist/conf/type/__letsencrypt_cert/explorer/certificate-exists new file mode 100755 index 00000000..d2ea35cc --- /dev/null +++ b/cdist/conf/type/__letsencrypt_cert/explorer/certificate-exists @@ -0,0 +1,7 @@ +#!/bin/sh -e + +if certbot certificates | grep -q " Certificate Name: ${__object_id:?}$"; then + echo yes +else + echo no +fi diff --git a/cdist/conf/type/__letsencrypt_cert/explorer/certificate-is-test b/cdist/conf/type/__letsencrypt_cert/explorer/certificate-is-test new file mode 100755 index 00000000..6d7b0ae9 --- /dev/null +++ b/cdist/conf/type/__letsencrypt_cert/explorer/certificate-is-test @@ -0,0 +1,8 @@ +#!/bin/sh -e + +if certbot certificates --cert-name "${__object_id:?}" | \ + grep -q 'INVALID: TEST_CERT'; then + echo yes +else + echo no +fi diff --git a/cdist/conf/type/__letsencrypt_cert/explorer/exists b/cdist/conf/type/__letsencrypt_cert/explorer/exists deleted file mode 100644 index cb967663..00000000 --- a/cdist/conf/type/__letsencrypt_cert/explorer/exists +++ /dev/null @@ -1,5 +0,0 @@ -domain=$__object_id - -if [ -f "/etc/letsencrypt/live/$domain/fullchain.pem" ]; then - echo yes -fi diff --git a/cdist/conf/type/__letsencrypt_cert/gencode-remote b/cdist/conf/type/__letsencrypt_cert/gencode-remote old mode 100644 new mode 100755 index 62ada241..4bd05eff --- a/cdist/conf/type/__letsencrypt_cert/gencode-remote +++ b/cdist/conf/type/__letsencrypt_cert/gencode-remote @@ -1,18 +1,75 @@ -domain="$__object_id" +#!/bin/sh -e -exists=$(cat "$__object/explorer/exists") -webroot="$(cat "$__object/parameter/webroot")" -admin_email="$(cat "$__object/parameter/admin-email")" +certificate_exists=$(cat "${__object:?}/explorer/certificate-exists") +name="${__object_id:?}" +state=$(cat "${__object}/parameter/state") -if [ -n "$exists" ]; then - exit 0 -fi +case "${state}" in + absent) + if [ "${certificate_exists}" = "no" ]; then + exit 0 + fi -cat <> "${__messages_out:?}" + ;; + present) + requested_domains="${__object}/parameter/domain" + + staging=no + if [ -f "${__object}/parameter/staging" ]; then + staging=yes + fi + + if [ "${certificate_exists}" = "yes" ]; then + existing_domains="${__object}/explorer/certificate-domains" + certificate_is_test=$(cat "${__object}/explorer/certificate-is-test") + + sort -uo "${requested_domains}" "${requested_domains}" + sort -uo "${existing_domains}" "${existing_domains}" + + if [ -z "$(comm -23 "${requested_domains}" "${existing_domains}")" ] && \ + [ "${certificate_is_test}" = "${staging}" ]; then + exit 0 + fi + fi + + admin_email="$(cat "$__object/parameter/admin-email")" + webroot="$(cat "$__object/parameter/webroot")" + + cat <<-EOF + certbot certonly \ + --agree-tos \ + --cert-name '${name}' \ + --email '${admin_email}' \ + --expand \ + --non-interactive \ + --quiet \ + $(if [ "${staging}" = "yes" ]; then + echo "--staging" + elif [ "${certificate_is_test}" != "${staging}" ]; then + echo "--force-renewal" + fi) \ + $(if [ -z "${webroot}" ]; then + echo "--standalone" + else + echo "--webroot --webroot-path '${webroot}'" + fi) \ + $(while read -r domain; do + echo "--domain '${domain}' \\" + done < "${requested_domains}") + EOF + + if [ "${certificate_exists}" = "no" ]; then + echo create >> "${__messages_out}" + else + echo change >> "${__messages_out}" + fi + ;; + *) + echo "Unsupported state: ${state}" >&2 + + exit 1 + ;; +esac diff --git a/cdist/conf/type/__letsencrypt_cert/man.rst b/cdist/conf/type/__letsencrypt_cert/man.rst index bb1e5d05..16b23fea 100644 --- a/cdist/conf/type/__letsencrypt_cert/man.rst +++ b/cdist/conf/type/__letsencrypt_cert/man.rst @@ -3,54 +3,95 @@ cdist-type__letsencrypt_cert(7) NAME ---- -cdist-type__letsencrypt_cert - Get an SSL certificate from Let's Encrypt +cdist-type__letsencrypt_cert - Get an SSL certificate from Let's Encrypt DESCRIPTION ----------- -Automatically obtain a Let's Encrypt SSL certificate. Uses certbot's webroot -method. You must set up your web server to work with webroot. +Automatically obtain a Let's Encrypt SSL certificate using Certbot. REQUIRED PARAMETERS ------------------- -webroot - The path to your webroot, as set up in your webserver config. admin-email - Where to send Let's Encrypt emails like "certificate needs renewal". + Where to send Let's Encrypt emails like "certificate needs renewal". +REQUIRED MULTIPLE PARAMETERS +---------------------------- + +domain + A domain to be included in the certificate. OPTIONAL PARAMETERS ------------------- -None. +state + 'present' or 'absent', defaults to 'present' where: + + present + if the certificate does not exist, it will be obtained + absent + the certificate will be removed + +webroot + The path to your webroot, as set up in your webserver config. If this + parameter is not present, Certbot will be run in standalone mode. OPTIONAL MULTIPLE PARAMETERS ---------------------------- + renew-hook - Renew hook command directly passed to certbot in cron job. + Renew hook command directly passed to Certbot in cron job. + +BOOLEAN PARAMETERS +------------------ + +automatic-renewal + Install a cron job, which attempts to renew certificates daily. + +staging + Obtain a test certificate from a staging server. + +MESSAGES +-------- + +change + Certificte was changed. + +create + Certificte was created. + +remove + Certificte was removed. EXAMPLES -------- .. code-block:: sh - __letsencrypt_cert example.com --admin-email root@example.com --webroot /data/letsencrypt/root - - __letsencrypt_cert example.com --admin-email root@example.com --webroot /data/letsencrypt/root --renew-hook "service nginx reload" + __letsencrypt_cert example.com \ + --admin-email root@example.com \ + --automatic-renewal \ + --domain example.com \ + --domain foo.example.com \ + --domain bar.example.com \ + --renew-hook "service nginx reload" \ + --webroot /data/letsencrypt/root AUTHORS ------- + | Nico Schottelius | Kamila Součková | Darko Poljak - +| Ľubomír Kučera COPYING ------- -Copyright \(C) 2017 Nico Schottelius, Kamila Součková, Darko Poljak. You can redistribute it -and/or modify it under the terms of the GNU General Public License as -published by the Free Software Foundation, either version 3 of the -License, or (at your option) any later version. + +Copyright \(C) 2017-2018 Nico Schottelius, Kamila Součková, Darko Poljak and +Ľubomír Kučera. 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/__letsencrypt_cert/manifest b/cdist/conf/type/__letsencrypt_cert/manifest old mode 100644 new mode 100755 index 800e5e18..94e9d225 --- a/cdist/conf/type/__letsencrypt_cert/manifest +++ b/cdist/conf/type/__letsencrypt_cert/manifest @@ -1,79 +1,93 @@ -os=$(cat "$__global/explorer/os") -os_version=$(cat "$__global/explorer/os_version") +#!/bin/sh -case "$os" in - debian) - case "$os_version" in - 8*) - __apt_source jessie-backports \ - --uri http://http.debian.net/debian \ - --distribution jessie-backports \ - --component main +certbot_fullpath="$(cat "${__object:?}/explorer/certbot-path")" - require="__apt_source/jessie-backports" __package_apt python-certbot --target-release jessie-backports - require="__apt_source/jessie-backports" __package_apt certbot --target-release jessie-backports - # Seems to be a missing dependency on debian 8 - __package python-ndg-httpsclient - ;; - 9*) - __apt_source stretch-backports \ - --uri http://http.debian.net/debian \ - --distribution stretch-backports \ - --component main +if [ -z "${certbot_fullpath}" ]; then + os="$(cat "${__global:?}/explorer/os")" + os_version="$(cat "${__global}/explorer/os_version")" - require="__apt_source/stretch-backports" __package_apt python-certbot --target-release stretch-backports - require="__apt_source/stretch-backports" __package_apt certbot --target-release stretch-backports - ;; - *) - echo "Unsupported OS version: $os_version" >&2 - exit 1 - ;; - esac + case "$os" in + debian) + case "$os_version" in + 8*) + __apt_source jessie-backports \ + --uri http://http.debian.net/debian \ + --distribution jessie-backports \ + --component main - certbot_fullpath=/usr/bin/certbot - ;; - devuan) - case "$os_version" in - jessie) - __apt_source jessie-backports \ - --uri http://auto.mirror.devuan.org/merged \ - --distribution jessie-backports \ - --component main + require="__apt_source/jessie-backports" __package_apt python-certbot \ + --target-release jessie-backports + require="__apt_source/jessie-backports" __package_apt certbot \ + --target-release jessie-backports + # Seems to be a missing dependency on debian 8 + __package python-ndg-httpsclient + ;; + 9*) + __apt_source stretch-backports \ + --uri http://http.debian.net/debian \ + --distribution stretch-backports \ + --component main - require="__apt_source/jessie-backports" __package_apt python-certbot --target-release jessie-backports - require="__apt_source/jessie-backports" __package_apt certbot --target-release jessie-backports - # Seems to be a missing dependency on debian 8 - __package python-ndg-httpsclient - ;; - *) - echo "Unsupported OS version: $os_version" >&2 - exit 1 - ;; - esac + require="__apt_source/stretch-backports" __package_apt python-certbot \ + --target-release stretch-backports + require="__apt_source/stretch-backports" __package_apt certbot \ + --target-release stretch-backports + ;; + *) + echo "Unsupported OS version: $os_version" >&2 + exit 1 + ;; + esac - certbot_fullpath=/usr/bin/certbot - ;; - freebsd) - __package py27-certbot + certbot_fullpath=/usr/bin/certbot + ;; + devuan) + case "$os_version" in + jessie) + __apt_source jessie-backports \ + --uri http://auto.mirror.devuan.org/merged \ + --distribution jessie-backports \ + --component main - certbot_fullpath=/usr/local/bin/certbot - ;; - *) - echo "Unsupported os: $os" >&2 - exit 1 - ;; -esac + require="__apt_source/jessie-backports" __package_apt python-certbot \ + --target-release jessie-backports + require="__apt_source/jessie-backports" __package_apt certbot \ + --target-release jessie-backports + # Seems to be a missing dependency on debian 8 + __package python-ndg-httpsclient + ;; + *) + echo "Unsupported OS version: $os_version" >&2 + exit 1 + ;; + esac -renew_hook_param="$__object/parameter/renew-hook" -renew_hook="" -if [ -f "$renew_hook_param" ]; then - while read hook; do - renew_hook="$renew_hook --renew-hook \"$hook\"" - done < "$renew_hook_param" + certbot_fullpath=/usr/bin/certbot + ;; + freebsd) + __package py27-certbot + + certbot_fullpath=/usr/local/bin/certbot + ;; + *) + echo "Unsupported os: $os" >&2 + exit 1 + ;; + esac fi -__cron letsencrypt-certbot \ - --user root \ - --command "$certbot_fullpath renew -q $renew_hook" \ - --hour 0 \ - --minute 47 +if [ -f "${__object}/parameter/automatic-renewal" ]; then + renew_hook_param="${__object}/parameter/renew-hook" + renew_hook="" + if [ -f "${renew_hook_param}" ]; then + while read hook; do + renew_hook="${renew_hook} --renew-hook \"${hook}\"" + done < "${renew_hook_param}" + fi + + __cron letsencrypt-certbot \ + --user root \ + --command "${certbot_fullpath} renew -q ${renew_hook}" \ + --hour 0 \ + --minute 47 +fi diff --git a/cdist/conf/type/__letsencrypt_cert/parameter/boolean b/cdist/conf/type/__letsencrypt_cert/parameter/boolean new file mode 100644 index 00000000..d5b8be99 --- /dev/null +++ b/cdist/conf/type/__letsencrypt_cert/parameter/boolean @@ -0,0 +1,2 @@ +automatic-renewal +staging diff --git a/cdist/conf/type/__letsencrypt_cert/parameter/default/state b/cdist/conf/type/__letsencrypt_cert/parameter/default/state new file mode 100644 index 00000000..e7f6134f --- /dev/null +++ b/cdist/conf/type/__letsencrypt_cert/parameter/default/state @@ -0,0 +1 @@ +present diff --git a/cdist/conf/type/__letsencrypt_cert/parameter/default/webroot b/cdist/conf/type/__letsencrypt_cert/parameter/default/webroot new file mode 100644 index 00000000..e69de29b diff --git a/cdist/conf/type/__letsencrypt_cert/parameter/optional b/cdist/conf/type/__letsencrypt_cert/parameter/optional new file mode 100644 index 00000000..0a63b11e --- /dev/null +++ b/cdist/conf/type/__letsencrypt_cert/parameter/optional @@ -0,0 +1,2 @@ +state +webroot diff --git a/cdist/conf/type/__letsencrypt_cert/parameter/required b/cdist/conf/type/__letsencrypt_cert/parameter/required index 45fe4ea6..bfe77226 100644 --- a/cdist/conf/type/__letsencrypt_cert/parameter/required +++ b/cdist/conf/type/__letsencrypt_cert/parameter/required @@ -1,2 +1 @@ admin-email -webroot diff --git a/cdist/conf/type/__letsencrypt_cert/parameter/required_multiple b/cdist/conf/type/__letsencrypt_cert/parameter/required_multiple new file mode 100644 index 00000000..d23ab7ab --- /dev/null +++ b/cdist/conf/type/__letsencrypt_cert/parameter/required_multiple @@ -0,0 +1 @@ +domain From 72bb485db7964a37e2f3c93dc396f10b813ca1db Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Fri, 11 May 2018 18:29:43 +0200 Subject: [PATCH 0021/1217] ++changelog --- docs/changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog b/docs/changelog index 3bdf446b..64d2489e 100644 --- a/docs/changelog +++ b/docs/changelog @@ -5,6 +5,7 @@ next: * Type __docker_stack: Use --with-registry-auth option (Ľubomír Kučera) * New type: __docker_config (Ľubomír Kučera) * New type: __docker_secret (Ľubomír Kučera) + * Type __letsencrypt_cert: Rewritten; WARN: breaks backward compatibility (Ľubomír Kučera) 4.8.4: 2018-04-20 * Documentation, type manpages: Fix spelling (Dmitry Bogatov) From 3cf417fa2bb8152fd0bcef757ce29d3f24649d9c Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Tue, 15 May 2018 12:12:01 +0200 Subject: [PATCH 0022/1217] Fix NameError: name 'cdist_object' is not defined, #662 --- cdist/core/explorer.py | 29 +++++++++++++---------------- docs/changelog | 1 + 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/cdist/core/explorer.py b/cdist/core/explorer.py index 072ca692..874d36f2 100644 --- a/cdist/core/explorer.py +++ b/cdist/core/explorer.py @@ -214,22 +214,19 @@ class Explorer(object): def transfer_type_explorers(self, cdist_type): """Transfer the type explorers for the given type to the remote side.""" - try: - if cdist_type.explorers: - if cdist_type.name in self._type_explorers_transferred: - self.log.trace(("Skipping retransfer of type explorers " - "for: %s"), cdist_type) - else: - source = os.path.join(self.local.type_path, - cdist_type.explorer_path) - destination = os.path.join(self.remote.type_path, - cdist_type.explorer_path) - self.remote.mkdir(destination) - self.remote.transfer(source, destination) - self.remote.run(["chmod", "0700", "%s/*" % (destination)]) - self._type_explorers_transferred.append(cdist_type.name) - except cdist.Error as e: - raise cdist.CdistObjectError(cdist_object, e) + if cdist_type.explorers: + if cdist_type.name in self._type_explorers_transferred: + self.log.trace(("Skipping retransfer of type explorers " + "for: %s"), cdist_type) + else: + source = os.path.join(self.local.type_path, + cdist_type.explorer_path) + destination = os.path.join(self.remote.type_path, + cdist_type.explorer_path) + self.remote.mkdir(destination) + self.remote.transfer(source, destination) + self.remote.run(["chmod", "0700", "%s/*" % (destination)]) + self._type_explorers_transferred.append(cdist_type.name) def transfer_object_parameters(self, cdist_object): """Transfer the parameters for the given object to the remote side.""" diff --git a/docs/changelog b/docs/changelog index 64d2489e..1e3787fd 100644 --- a/docs/changelog +++ b/docs/changelog @@ -6,6 +6,7 @@ next: * New type: __docker_config (Ľubomír Kučera) * New type: __docker_secret (Ľubomír Kučera) * Type __letsencrypt_cert: Rewritten; WARN: breaks backward compatibility (Ľubomír Kučera) + * Core: Fix NameError: name 'cdist_object' is not defined (Darko Poljak) 4.8.4: 2018-04-20 * Documentation, type manpages: Fix spelling (Dmitry Bogatov) From 6946dc877a6e25980f6d9368cee77bcccfbc68ef Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Thu, 17 May 2018 13:33:58 +0200 Subject: [PATCH 0023/1217] pep8 --- cdist/core/explorer.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cdist/core/explorer.py b/cdist/core/explorer.py index 874d36f2..8c18a19f 100644 --- a/cdist/core/explorer.py +++ b/cdist/core/explorer.py @@ -220,9 +220,9 @@ class Explorer(object): "for: %s"), cdist_type) else: source = os.path.join(self.local.type_path, - cdist_type.explorer_path) + cdist_type.explorer_path) destination = os.path.join(self.remote.type_path, - cdist_type.explorer_path) + cdist_type.explorer_path) self.remote.mkdir(destination) self.remote.transfer(source, destination) self.remote.run(["chmod", "0700", "%s/*" % (destination)]) From e6b6925908c3daf01c3b16c1714a5b9e9184c926 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Thu, 17 May 2018 16:11:05 +0200 Subject: [PATCH 0024/1217] Release 4.9.0 --- docs/changelog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/changelog b/docs/changelog index 1e3787fd..da23589c 100644 --- a/docs/changelog +++ b/docs/changelog @@ -1,7 +1,7 @@ Changelog --------- -next: +4.9.0: 2018-05-17 * Type __docker_stack: Use --with-registry-auth option (Ľubomír Kučera) * New type: __docker_config (Ľubomír Kučera) * New type: __docker_secret (Ľubomír Kučera) From a3968f831306534c32aa3873e64c2e5a7fdfc811 Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Fri, 18 May 2018 01:25:35 +0200 Subject: [PATCH 0025/1217] rewrite __line type for --before and --after support Signed-off-by: Steven Armstrong --- cdist/conf/type/__line/explorer/state | 72 +++++++-- cdist/conf/type/__line/gencode-remote | 148 ++++++++++-------- cdist/conf/type/__line/man.rst | 100 +++++++----- .../conf/type/__line/parameter/default/state | 1 + cdist/conf/type/__line/parameter/optional | 6 +- 5 files changed, 211 insertions(+), 116 deletions(-) create mode 100644 cdist/conf/type/__line/parameter/default/state diff --git a/cdist/conf/type/__line/explorer/state b/cdist/conf/type/__line/explorer/state index 08056c86..1f81b540 100755 --- a/cdist/conf/type/__line/explorer/state +++ b/cdist/conf/type/__line/explorer/state @@ -1,6 +1,6 @@ -#!/bin/sh +#!/bin/sh -e # -# 2012-2013 Nico Schottelius (nico-cdist at schottelius.org) +# 2018 Steven Armstrong (steven-cdist at armstrong.cc) # # This file is part of cdist. # @@ -17,26 +17,64 @@ # You should have received a copy of the GNU General Public License # along with cdist. If not, see . # -# -file="/$__object_id" -[ -f "$__object/parameter/file" ] && file=$(cat "$__object/parameter/file") +if [ -f "$__object/parameter/before" ]; then + position="before" +elif [ -f "$__object/parameter/after" ]; then + position="after" +fi if [ -f "$__object/parameter/regex" ]; then - regex=$(cat "$__object/parameter/regex") - greparg="" + needle="regex" else - if [ ! -f "$__object/parameter/line" ]; then - echo "Parameter line and regex missing - cannot explore" >&2 - exit 1 - fi - regex="$(cat "$__object/parameter/line")" - greparg="-F -x" + needle="line" fi -# Allow missing file - thus 2>/dev/null -if grep -q $greparg -- "$regex" "$file" 2>/dev/null; then - echo present +if [ -f "$__object/parameter/file" ]; then + file="$(cat "$__object/parameter/file")" else - echo absent + file="/$__object_id" fi + +awk -v position="$position" -v needle="$needle" ' +BEGIN { + getline anchor < (ENVIRON["__object"] "/parameter/" position) + getline pattern < (ENVIRON["__object"] "/parameter/" needle) + state = "absent" +} +{ + if (position == "after") { + if (match($0, anchor)) { + getline + if (match($0, pattern)) { + state = "present" + } + else { + state = "wrongposition" + } + exit 0 + } + } + else if (position == "before") { + if (match($0, pattern)) { + getline + if (match($0, anchor)) { + state = "present" + } + else { + state = "wrongposition" + } + exit 0 + } + } + else { + if (match($0, pattern)) { + state = "present" + exit 0 + } + } +} +END { + print state +} +' "$file" diff --git a/cdist/conf/type/__line/gencode-remote b/cdist/conf/type/__line/gencode-remote index 4a75b4c5..7951ea49 100755 --- a/cdist/conf/type/__line/gencode-remote +++ b/cdist/conf/type/__line/gencode-remote @@ -1,7 +1,6 @@ #!/bin/sh -e # -# 2012 Nico Schottelius (nico-cdist at schottelius.org) -# 2014 Steven Armstrong (steven-cdist at armstrong.cc) +# 2018 Steven Armstrong (steven-cdist at armstrong.cc) # # This file is part of cdist. # @@ -18,76 +17,101 @@ # You should have received a copy of the GNU General Public License # along with cdist. If not, see . # -# -file="/$__object_id" -regex="" -state_should="present" -[ -f "$__object/parameter/file" ] && file=$(cat "$__object/parameter/file") -[ -f "$__object/parameter/regex" ] && regex=$(cat "$__object/parameter/regex") -[ -f "$__object/parameter/state" ] && state_should=$(cat "$__object/parameter/state") -[ -f "$__object/parameter/line" ] && line=$(cat "$__object/parameter/line") +if [ -f "$__object/parameter/before" -a -f "$__object/parameter/after" ]; then + echo "Use either --before OR --after but not both." >&2 + exit 1 +fi +state_should="$(cat "$__object/parameter/state")" state_is="$(cat "$__object/explorer/state")" -[ "$state_should" = "$state_is" ] && exit 0 +if [ "$state_should" = "$state_is" ]; then + # nothing to do + exit 0 +fi +if [ -f "$__object/parameter/before" ]; then + position="before" +elif [ -f "$__object/parameter/after" ]; then + position="after" +else + # By default we append to the end of the file. + position="end" +fi + +if [ -f "$__object/parameter/regex" ]; then + needle="regex" +else + needle="line" +fi + +if [ -f "$__object/parameter/file" ]; then + file="$(cat "$__object/parameter/file")" +else + file="/$__object_id" +fi + +add=0 +remove=0 case "$state_should" in - present) - if [ ! "$line" ]; then - echo "Required parameter \"line\" is missing" >&2 - exit 1 - fi + present) + if [ "$state_is" = "wrongposition" ]; then + echo updated >> "$__messages_out" + remove=1 + else + echo added >> "$__messages_out" + fi + add=1 + ;; + absent) + echo removed >> "$__messages_out" + remove=1 + ;; +esac - #echo "echo \"$line\" >> $file" - #line_sanitised=$(cat "$__object/parameter/line" | sed 's/"/\"/g') - # Idea: replace ' in the string: - # '"'"' - # |------> ': end the string - # |-|---> "'": create ' in the output string - # |--> ': continue the string - # - # Replace all \ so \t and other combinations are not interpreted - # - - - # line_sanitised=$(cat "$__object/parameter/line" | sed -e "s/'/'\"'\"'/g" -e 's/\\/\\\\/g') - # The one above does not work: - # --line "PS1='[\t] \[\033[1m\]\h\[\033[0m\]:\w\\$ '" - # becomes - # PS1='[\\t] \\[\\033[1m\\]\\h\\[\\033[0m\\]:\\w\\$ ' - - # Only replace ' with '"'"' and keep \ as they are - line_sanitised=$(cat "$__object/parameter/line" | sed -e "s/'/'\"'\"'/g") - printf '%s' "printf '%s\n' '$line_sanitised' >> $file" - echo "added" >> "$__messages_out" - - ;; - absent) - if [ "$regex" -a "$line" ]; then - echo "Mutally exclusive parameters regex and line given for state absent" >&2 - exit 1 - fi - - greparg="" - if [ "$line" ]; then - regex="$line" - greparg="-F -x" - fi - - cat << eof +cat << DONE tmpfile=\$(mktemp ${file}.cdist.XXXXXXXXXX) # preserve ownership and permissions of existing file if [ -f "$file" ]; then cp -p "$file" "\$tmpfile" fi -grep -v $greparg "$regex" '$file' > \$tmpfile || true + +awk -v position="$position" -v needle="$needle" -v remove=$remove -v add=$add ' +BEGIN { + line_file = ENVIRON["__object"] "/parameter/line" + getline line < line_file + # Need to close line file as it may be re-read as pattern below. + close(line_file) + getline pattern < (ENVIRON["__object"] "/parameter/" needle) + getline anchor < (ENVIRON["__object"] "/parameter/" position) +} +{ + if (remove) { + if (match(\$0, pattern)) { + # skip over this line -> remove it + next + } + } + if (add) { + if (anchor && match(\$0, anchor)) { + if (position == "before") { + print line + print + } else if (position == "after") { + print + print line + } + next + } + } + print +} +END { + if (add && position == "end") { + print line + } +} +' "$file" > "\$tmpfile" mv -f "\$tmpfile" "$file" -eof - echo "removed" >> "$__messages_out" - ;; - *) - echo "Unknown state: $state_should" >&2 - exit 1 - ;; -esac +DONE diff --git a/cdist/conf/type/__line/man.rst b/cdist/conf/type/__line/man.rst index b63ea2b3..d651985e 100644 --- a/cdist/conf/type/__line/man.rst +++ b/cdist/conf/type/__line/man.rst @@ -13,72 +13,102 @@ This cdist type allows you to add lines and remove lines from files. REQUIRED PARAMETERS ------------------- +None. + OPTIONAL PARAMETERS ------------------- -state - 'present' or 'absent', defaults to 'present' +after + Insert the given line after this pattern. -line - Specifies the line which should be absent or present - - Must be present, if state is present. - Must not be combined with regex, if state is absent. - -regex - If state is present, search for this pattern and add - given line, if the given regular expression does not match. - - In case of absent, ensure all lines matching the - regular expression are absent. - - The regular expression is interpreted by grep. - - Must not be combined with line, if state is absent. +before + Insert the given line before this pattern. file If supplied, use this as the destination file. Otherwise the object_id is used. +line + Specifies the line which should be absent or present. + + Must be present, if state is 'present'. + Ignored if regex is given and state is 'absent'. + +regex + If state is 'present', search for this pattern and if it matches add + the given line. + + If state is 'absent', ensure all lines matching the regular expression + are absent. + + The regular expression is interpreted by awk's match function. + +state + 'present' or 'absent', defaults to 'present' + + + +BOOLEAN PARAMETERS +------------------ +None. + + MESSAGES -------- added - The line was added. + The line was added. + +updated + The line or its position was changed. removed - The line was removed. + The line was removed. + EXAMPLES -------- .. code-block:: sh - # Manage the DAEMONS line in rc.conf - __line daemons --file /etc/rc.conf --line 'DAEMONS=(hwclock !network sshd crond postfix)' + # Manage a hosts entry for www.example.com. + __line /etc/hosts \ + --line '127.0.0.2 www.example.com' - # Ensure the home mount is present in /etc/fstab - explicitly make it present - __line home-fstab \ - --file /etc/fstab \ - --line 'filer.fs:/vol/home /home nfs defaults 0 0' \ - --state present + # Manage another hosts entry for test.example.com. + __line hosts:test.example.com \ + --file /etc/hosts \ + --line '127.0.0.3 test.example.com' - # Removes the line specifiend in "include_www" from the file "lighttpd.conf" - __line legacy_timezone --file /etc/rc.conf --regex 'TIMEZONE=.*' --state absent + # Remove the line starting with TIMEZONE from the /etc/rc.conf file. + __line legacy_timezone \ + --file /etc/rc.conf \ + --regex 'TIMEZONE=.*' \ + --state absent + + # Insert a line before another one. + __line password-auth-local:classify \ + --file /etc/pam.d/password-auth-local \ + --line '-session required pam_exec.so debug log=/tmp/classify.log /usr/local/libexec/classify' \ + --before '^session[[:space:]]+include[[:space:]]+password-auth-ac$' + + # Insert a line after another one. + __line password-auth-local:classify \ + --file /etc/pam.d/password-auth-local \ + --line '-session required pam_exec.so debug log=/tmp/classify.log /usr/local/libexec/classify' \ + --after '^session[[:space:]]+include[[:space:]]+password-auth-ac$' SEE ALSO -------- -:strong:`grep`\ (1) +:strong:`cdist-type`\ (7) AUTHORS ------- -Nico Schottelius +Steven Armstrong COPYING ------- -Copyright \(C) 2012-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. +Copyright \(C) 2018 Steven Armstrong. Free use of this software is +granted under the terms of the GNU General Public License version 3 (GPLv3). diff --git a/cdist/conf/type/__line/parameter/default/state b/cdist/conf/type/__line/parameter/default/state new file mode 100644 index 00000000..e7f6134f --- /dev/null +++ b/cdist/conf/type/__line/parameter/default/state @@ -0,0 +1 @@ +present diff --git a/cdist/conf/type/__line/parameter/optional b/cdist/conf/type/__line/parameter/optional index 604a203e..f89a2115 100644 --- a/cdist/conf/type/__line/parameter/optional +++ b/cdist/conf/type/__line/parameter/optional @@ -1,4 +1,6 @@ -state -regex +after +before file line +regex +state From fb26894cbd45268b62eb40d4ed285dd557ea4f6c Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Fri, 18 May 2018 16:57:34 +0200 Subject: [PATCH 0026/1217] when searching treat line as string, and regex as regexp Signed-off-by: Steven Armstrong --- cdist/conf/type/__line/explorer/state | 13 ++++++++++--- cdist/conf/type/__line/gencode-remote | 9 ++++++++- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/cdist/conf/type/__line/explorer/state b/cdist/conf/type/__line/explorer/state index 1f81b540..d27bca18 100755 --- a/cdist/conf/type/__line/explorer/state +++ b/cdist/conf/type/__line/explorer/state @@ -37,6 +37,13 @@ else fi awk -v position="$position" -v needle="$needle" ' +function _find(_text, _pattern) { + if (needle == "regex") { + return match(_text, _pattern) + } else { + return index(_text, _pattern) + } +} BEGIN { getline anchor < (ENVIRON["__object"] "/parameter/" position) getline pattern < (ENVIRON["__object"] "/parameter/" needle) @@ -46,7 +53,7 @@ BEGIN { if (position == "after") { if (match($0, anchor)) { getline - if (match($0, pattern)) { + if (_find($0, pattern)) { state = "present" } else { @@ -56,7 +63,7 @@ BEGIN { } } else if (position == "before") { - if (match($0, pattern)) { + if (_find($0, pattern)) { getline if (match($0, anchor)) { state = "present" @@ -68,7 +75,7 @@ BEGIN { } } else { - if (match($0, pattern)) { + if (_find($0, pattern)) { state = "present" exit 0 } diff --git a/cdist/conf/type/__line/gencode-remote b/cdist/conf/type/__line/gencode-remote index 7951ea49..996029f5 100755 --- a/cdist/conf/type/__line/gencode-remote +++ b/cdist/conf/type/__line/gencode-remote @@ -78,6 +78,13 @@ if [ -f "$file" ]; then fi awk -v position="$position" -v needle="$needle" -v remove=$remove -v add=$add ' +function _find(_text, _pattern) { + if (needle == "regex") { + return match(_text, _pattern) + } else { + return index(_text, _pattern) + } +} BEGIN { line_file = ENVIRON["__object"] "/parameter/line" getline line < line_file @@ -88,7 +95,7 @@ BEGIN { } { if (remove) { - if (match(\$0, pattern)) { + if (_find(\$0, pattern)) { # skip over this line -> remove it next } From e7e8f1428aafbffc8c391527ec5c84c8710f4082 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=BDubom=C3=ADr=20Ku=C4=8Dera?= Date: Sat, 19 May 2018 17:42:25 +0200 Subject: [PATCH 0027/1217] Add new type __install_coreos --- .../conf/type/__install_coreos/gencode-remote | 19 +++++++ cdist/conf/type/__install_coreos/install | 0 cdist/conf/type/__install_coreos/man.rst | 50 +++++++++++++++++++ .../parameter/default/ignition | 0 .../type/__install_coreos/parameter/optional | 1 + .../type/__install_coreos/parameter/required | 1 + cdist/conf/type/__install_coreos/singleton | 0 7 files changed, 71 insertions(+) create mode 100755 cdist/conf/type/__install_coreos/gencode-remote create mode 100644 cdist/conf/type/__install_coreos/install create mode 100644 cdist/conf/type/__install_coreos/man.rst create mode 100644 cdist/conf/type/__install_coreos/parameter/default/ignition create mode 100644 cdist/conf/type/__install_coreos/parameter/optional create mode 100644 cdist/conf/type/__install_coreos/parameter/required create mode 100644 cdist/conf/type/__install_coreos/singleton diff --git a/cdist/conf/type/__install_coreos/gencode-remote b/cdist/conf/type/__install_coreos/gencode-remote new file mode 100755 index 00000000..fbe86479 --- /dev/null +++ b/cdist/conf/type/__install_coreos/gencode-remote @@ -0,0 +1,19 @@ +#!/bin/sh -e + +device=$(cat "${__object:?}/parameter/device") +ignition=$(cat "${__object}/parameter/ignition") + +cat < "\${ignition_file}" << eof +$(base64 "${ignition}") +eof + +coreos-install -d "${device}" \ + \$(if [ -s "\${ignition_file}" ]; then + printf -- "-i \${ignition_file}\n" + fi) + +rm "\${ignition_file}" +EOF diff --git a/cdist/conf/type/__install_coreos/install b/cdist/conf/type/__install_coreos/install new file mode 100644 index 00000000..e69de29b diff --git a/cdist/conf/type/__install_coreos/man.rst b/cdist/conf/type/__install_coreos/man.rst new file mode 100644 index 00000000..314f9f2a --- /dev/null +++ b/cdist/conf/type/__install_coreos/man.rst @@ -0,0 +1,50 @@ +cdist-type__install_coreos(7) +============================= + +NAME +---- + +cdist-type__install_coreos - Install CoreOS + +DESCRIPTION +----------- + +This type installs CoreOS to a given device using coreos-install_, which is +present in CoreOS ISO by default. + +.. _coreos-install: https://raw.githubusercontent.com/coreos/init/master/bin/coreos-install + +REQUIRED PARAMETERS +------------------- + +device + A device CoreOS will be installed to. + +OPTIONAL PARAMETERS +------------------- + +ignition + Path to ignition config. + +EXAMPLES +-------- + +.. code-block:: sh + + __install_coreos \ + --device /dev/sda \ + --ignition ignition.json + + +AUTHORS +------- + +Ľubomír Kučera + +COPYING +------- + +Copyright \(C) 2018 Ľubomír Kučera. 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_coreos/parameter/default/ignition b/cdist/conf/type/__install_coreos/parameter/default/ignition new file mode 100644 index 00000000..e69de29b diff --git a/cdist/conf/type/__install_coreos/parameter/optional b/cdist/conf/type/__install_coreos/parameter/optional new file mode 100644 index 00000000..df284caa --- /dev/null +++ b/cdist/conf/type/__install_coreos/parameter/optional @@ -0,0 +1 @@ +ignition diff --git a/cdist/conf/type/__install_coreos/parameter/required b/cdist/conf/type/__install_coreos/parameter/required new file mode 100644 index 00000000..f89ee6a8 --- /dev/null +++ b/cdist/conf/type/__install_coreos/parameter/required @@ -0,0 +1 @@ +device diff --git a/cdist/conf/type/__install_coreos/singleton b/cdist/conf/type/__install_coreos/singleton new file mode 100644 index 00000000..e69de29b From ab696a8cb86800576db4c0d24c33338778041059 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Fri, 25 May 2018 18:01:26 +0200 Subject: [PATCH 0028/1217] ++changelog --- docs/changelog | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/changelog b/docs/changelog index da23589c..7a811271 100644 --- a/docs/changelog +++ b/docs/changelog @@ -1,6 +1,9 @@ Changelog --------- +next: + * New type: __install_coreos (Ľubomír Kučera) + 4.9.0: 2018-05-17 * Type __docker_stack: Use --with-registry-auth option (Ľubomír Kučera) * New type: __docker_config (Ľubomír Kučera) From b3a4152e00f3a86fbc741dd02ba839e956216490 Mon Sep 17 00:00:00 2001 From: Alexander Dinu Date: Sun, 27 May 2018 17:20:55 +0200 Subject: [PATCH 0029/1217] Fix __package_yum explorer Why: In case when name contains package name with exact version specified (e.g. rpm-build-4.11.3) ``` rpm -q --whatprovides "$pkg_name" ``` will tell you that no package could provide you with 'rpm-build-4.11.3', because it's not virtual or file-provide, but exact package name. This will lead to the installation of the package which was already installed. It slows down manifest execution a lot. My change will keep previous behaviour which relies on --whatprovides and will fix wrong behaviour when argument is full package name with version. --- cdist/conf/type/__package_yum/explorer/pkg_version | 2 +- cdist/conf/type/__package_yum/gencode-remote | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/cdist/conf/type/__package_yum/explorer/pkg_version b/cdist/conf/type/__package_yum/explorer/pkg_version index fb3b7753..b81b0fe9 100755 --- a/cdist/conf/type/__package_yum/explorer/pkg_version +++ b/cdist/conf/type/__package_yum/explorer/pkg_version @@ -27,4 +27,4 @@ else name="$__object_id" fi -rpm -q --whatprovides "$name" 2>/dev/null || true +rpm -q "$name" 2>/dev/null || rpm -q --whatprovides "$name" 2>/dev/null || true diff --git a/cdist/conf/type/__package_yum/gencode-remote b/cdist/conf/type/__package_yum/gencode-remote index e9b48ee8..e1323dea 100755 --- a/cdist/conf/type/__package_yum/gencode-remote +++ b/cdist/conf/type/__package_yum/gencode-remote @@ -43,10 +43,15 @@ else opts="--assumeyes --quiet" fi -not_installed="^no package provides" +not_provided="^no package provides" +not_installed='is not installed$' -if grep -q "$not_installed" "$__object/explorer/pkg_version"; then - state_is="absent" +if grep -q "$not_provided" "$__object/explorer/pkg_version"; then + if grep -q "$not_installed" "$__object/explorer/pkg_version"; then + state_is="absent" + else + state_is="present" + fi else state_is="present" fi From 709c216096fd6a9249d1a817e6e33864dd64a2b7 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 27 May 2018 19:07:57 +0200 Subject: [PATCH 0030/1217] [__consul_agent] Add LSB header so that innserv doe not fail --- .../conf/type/__consul_agent/files/consul.sysv-debian | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/cdist/conf/type/__consul_agent/files/consul.sysv-debian b/cdist/conf/type/__consul_agent/files/consul.sysv-debian index a75c555d..098328b3 100644 --- a/cdist/conf/type/__consul_agent/files/consul.sysv-debian +++ b/cdist/conf/type/__consul_agent/files/consul.sysv-debian @@ -18,6 +18,16 @@ # You should have received a copy of the GNU General Public License # along with cdist. If not, see . # +### BEGIN INIT INFO +# Provides: consul +# Required-Start: $network $local_fs $remote_fs +# Required-Stop: $local_fs +# Should-Start: +# Should-Stop: +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: libvirt management daemon +### END INIT INFO if [ -f "/etc/default/consul" ]; then . /etc/default/consul From ab62d5871545cb6df3103d7d8f7e4432ebd319f6 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sun, 27 May 2018 19:09:24 +0200 Subject: [PATCH 0031/1217] ++ changes --- docs/changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog b/docs/changelog index 7a811271..bf88e047 100644 --- a/docs/changelog +++ b/docs/changelog @@ -3,6 +3,7 @@ Changelog next: * New type: __install_coreos (Ľubomír Kučera) + * Type __consul_agent: Add LSB init header (Nico Schottelius) 4.9.0: 2018-05-17 * Type __docker_stack: Use --with-registry-auth option (Ľubomír Kučera) From 81adabd1ab286d22e15fa2ac8c89bc3f8e72222a Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Mon, 28 May 2018 08:04:41 +0200 Subject: [PATCH 0032/1217] ++changelog --- docs/changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog b/docs/changelog index bf88e047..99d9bb81 100644 --- a/docs/changelog +++ b/docs/changelog @@ -4,6 +4,7 @@ Changelog next: * New type: __install_coreos (Ľubomír Kučera) * Type __consul_agent: Add LSB init header (Nico Schottelius) + * Type __package_yum: Fix explorer when name contains package name with exact version specified (Aleksandr Dinu) 4.9.0: 2018-05-17 * Type __docker_stack: Use --with-registry-auth option (Ľubomír Kučera) From efebe153868e0fd6a51a89387097dc847a7ae14e Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Sun, 27 May 2018 15:32:44 +0200 Subject: [PATCH 0033/1217] Fix __letsencrypt_cert type: use object id as domain if domain param is not specified --- .../type/__letsencrypt_cert/gencode-remote | 8 +++++- cdist/conf/type/__letsencrypt_cert/man.rst | 26 ++++++++++++++----- .../parameter/optional_multiple | 1 + .../parameter/required_multiple | 1 - docs/changelog | 1 + 5 files changed, 28 insertions(+), 9 deletions(-) delete mode 100644 cdist/conf/type/__letsencrypt_cert/parameter/required_multiple diff --git a/cdist/conf/type/__letsencrypt_cert/gencode-remote b/cdist/conf/type/__letsencrypt_cert/gencode-remote index 4bd05eff..788da74c 100755 --- a/cdist/conf/type/__letsencrypt_cert/gencode-remote +++ b/cdist/conf/type/__letsencrypt_cert/gencode-remote @@ -15,7 +15,13 @@ case "${state}" in echo remove >> "${__messages_out:?}" ;; present) - requested_domains="${__object}/parameter/domain" + domain_param_file="${__object}/parameter/domain" + requested_domains=$(mktemp domain.cdist.XXXXXXXXXX) + if [ -f "${domain_param_file}" ]; then + cp "${domain_param_file}" "${requested_domains}" + else + echo "$__object_id" >> "${requested_domains}" + fi staging=no if [ -f "${__object}/parameter/staging" ]; then diff --git a/cdist/conf/type/__letsencrypt_cert/man.rst b/cdist/conf/type/__letsencrypt_cert/man.rst index 16b23fea..c4ffc6bc 100644 --- a/cdist/conf/type/__letsencrypt_cert/man.rst +++ b/cdist/conf/type/__letsencrypt_cert/man.rst @@ -14,15 +14,13 @@ Automatically obtain a Let's Encrypt SSL certificate using Certbot. REQUIRED PARAMETERS ------------------- +object id + A cert name. If domain parameter is not specified then it is used + as a domain to be included in the certificate. + admin-email Where to send Let's Encrypt emails like "certificate needs renewal". -REQUIRED MULTIPLE PARAMETERS ----------------------------- - -domain - A domain to be included in the certificate. - OPTIONAL PARAMETERS ------------------- @@ -44,6 +42,10 @@ OPTIONAL MULTIPLE PARAMETERS renew-hook Renew hook command directly passed to Certbot in cron job. +domain + Domains to be included in the certificate. When specified then object id + is not used as a domain. + BOOLEAN PARAMETERS ------------------ @@ -70,6 +72,17 @@ EXAMPLES .. code-block:: sh + # use object id as domain + __letsencrypt_cert example.com \ + --admin-email root@example.com \ + --automatic-renewal \ + --renew-hook "service nginx reload" \ + --webroot /data/letsencrypt/root + +.. code-block:: sh + + # domain parameter is specified so object id is not used as domain + # and example.com needs to be included again with domain parameter __letsencrypt_cert example.com \ --admin-email root@example.com \ --automatic-renewal \ @@ -79,7 +92,6 @@ EXAMPLES --renew-hook "service nginx reload" \ --webroot /data/letsencrypt/root - AUTHORS ------- diff --git a/cdist/conf/type/__letsencrypt_cert/parameter/optional_multiple b/cdist/conf/type/__letsencrypt_cert/parameter/optional_multiple index 3384c74f..0e866d45 100644 --- a/cdist/conf/type/__letsencrypt_cert/parameter/optional_multiple +++ b/cdist/conf/type/__letsencrypt_cert/parameter/optional_multiple @@ -1 +1,2 @@ +domain renew-hook diff --git a/cdist/conf/type/__letsencrypt_cert/parameter/required_multiple b/cdist/conf/type/__letsencrypt_cert/parameter/required_multiple deleted file mode 100644 index d23ab7ab..00000000 --- a/cdist/conf/type/__letsencrypt_cert/parameter/required_multiple +++ /dev/null @@ -1 +0,0 @@ -domain diff --git a/docs/changelog b/docs/changelog index 99d9bb81..250baae5 100644 --- a/docs/changelog +++ b/docs/changelog @@ -5,6 +5,7 @@ next: * New type: __install_coreos (Ľubomír Kučera) * Type __consul_agent: Add LSB init header (Nico Schottelius) * Type __package_yum: Fix explorer when name contains package name with exact version specified (Aleksandr Dinu) + * Type __letsencrypt_cert: Use object id as domain if domain param is not specified (Darko Poljak) 4.9.0: 2018-05-17 * Type __docker_stack: Use --with-registry-auth option (Ľubomír Kučera) From 5ec99ceda2a3d6a3c7478d46f9f941e89be3ca0d Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Wed, 30 May 2018 19:44:54 +0200 Subject: [PATCH 0034/1217] Release 4.9.1 --- docs/changelog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/changelog b/docs/changelog index 250baae5..38411e14 100644 --- a/docs/changelog +++ b/docs/changelog @@ -1,7 +1,7 @@ Changelog --------- -next: +4.9.1: 2018-05-30 * New type: __install_coreos (Ľubomír Kučera) * Type __consul_agent: Add LSB init header (Nico Schottelius) * Type __package_yum: Fix explorer when name contains package name with exact version specified (Aleksandr Dinu) From 4516ee0baabef2c3a612d624a60fce27fd43ced0 Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Fri, 1 Jun 2018 15:27:40 +0200 Subject: [PATCH 0035/1217] position can not be empty Signed-off-by: Steven Armstrong --- cdist/conf/type/__line/explorer/state | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cdist/conf/type/__line/explorer/state b/cdist/conf/type/__line/explorer/state index d27bca18..afdf3502 100755 --- a/cdist/conf/type/__line/explorer/state +++ b/cdist/conf/type/__line/explorer/state @@ -22,6 +22,9 @@ if [ -f "$__object/parameter/before" ]; then position="before" elif [ -f "$__object/parameter/after" ]; then position="after" +else + # By default we append to the end of the file. + position="end" fi if [ -f "$__object/parameter/regex" ]; then From 90adefe2e455e7ab8cef2629145ec0ad7136fbc4 Mon Sep 17 00:00:00 2001 From: Ander Punnar Date: Thu, 7 Jun 2018 15:07:00 +0300 Subject: [PATCH 0036/1217] add __acl: Basic wrapper around setfacl --- cdist/conf/type/__acl/explorer/acl_is | 23 ++++++ cdist/conf/type/__acl/gencode-remote | 81 +++++++++++++++++++ cdist/conf/type/__acl/man.rst | 62 ++++++++++++++ cdist/conf/type/__acl/parameter/boolean | 3 + .../type/__acl/parameter/optional_multiple | 2 + 5 files changed, 171 insertions(+) create mode 100755 cdist/conf/type/__acl/explorer/acl_is create mode 100755 cdist/conf/type/__acl/gencode-remote create mode 100644 cdist/conf/type/__acl/man.rst create mode 100644 cdist/conf/type/__acl/parameter/boolean create mode 100644 cdist/conf/type/__acl/parameter/optional_multiple diff --git a/cdist/conf/type/__acl/explorer/acl_is b/cdist/conf/type/__acl/explorer/acl_is new file mode 100755 index 00000000..4dc98c51 --- /dev/null +++ b/cdist/conf/type/__acl/explorer/acl_is @@ -0,0 +1,23 @@ +#!/bin/sh -e +# +# 2018 Ander Punnar (ander-at-kvlt-dot-ee) +# +# This file is part of cdist. +# +# cdist is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# cdist is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with cdist. If not, see . +# + +if [ -e "/$__object_id" ] +then getfacl "/$__object_id" | grep -E '^((default:|)(user|group)):[a-z]' || true +fi diff --git a/cdist/conf/type/__acl/gencode-remote b/cdist/conf/type/__acl/gencode-remote new file mode 100755 index 00000000..a9d14102 --- /dev/null +++ b/cdist/conf/type/__acl/gencode-remote @@ -0,0 +1,81 @@ +#!/bin/sh -e +# +# 2018 Ander Punnar (ander-at-kvlt-dot-ee) +# +# This file is part of cdist. +# +# cdist is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# cdist is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with cdist. If not, see . +# + +os="$( "$__explorer/os" )" + +acl_path="/$__object_id" + +acl_is="$( cat "$__object/explorer/acl_is" )" + +acl_should="$( for parameter in user group +do + if [ ! -f "$__object/parameter/$parameter" ] + then continue + fi + while read -r l + do + echo "$parameter:$l" + + if [ -f "$__object/parameter/default" ] + then echo "default:$parameter:$l" + fi + done < "$__object/parameter/$parameter" +done )" + +setfacl_exec='setfacl' + +if [ -f "$__object/parameter/recursive" ] +then + if echo "$os" | grep -E 'macosx|netbsd|freebsd|openbsd' + then + echo "$os setfacl do not support recursive operations" >&2 + else + setfacl_exec="$setfacl_exec -R" + fi +fi + +if [ -f "$__object/parameter/remove" ] +then + if echo "$os" | grep 'solaris' + then + # Solaris setfacl behaves differently. + # We will not support Solaris for now, because no way to test it. + # But adding support should be easy (use -s instead of -m on modify). + echo "$os setfacl do not support -x flag for ACL remove" >&2 + else + echo "$acl_is" | while read -r acl + do + if echo "$acl_should" | grep -Fq "$acl" + then continue + fi + + no_bits="$( echo "$acl" | sed -r 's/:[rwx-]+$//' )" + + echo "$setfacl_exec -x \"$no_bits\" \"$acl_path\"" + done + fi +fi + +for acl in $acl_should +do + if ! echo "$acl_is" | grep -Eq "^$acl" + then echo "$setfacl_exec -m \"$acl\" \"$acl_path\"" + fi +done diff --git a/cdist/conf/type/__acl/man.rst b/cdist/conf/type/__acl/man.rst new file mode 100644 index 00000000..39db4d75 --- /dev/null +++ b/cdist/conf/type/__acl/man.rst @@ -0,0 +1,62 @@ +cdist-type__acl(7) +================== + +NAME +---- +cdist-type__acl - Basic wrapper around `setfacl` + + +DESCRIPTION +----------- +ACL must be defined as 3-symbol combination, using `r`, `w`, `x` and `-`. + +See setfacl(1) and acl(5) for more details. + + +OPTIONAL MULTIPLE PARAMETERS +---------------------------- +user + Add user ACL entry. + +group + Add group ACL entry. + + +BOOLEAN PARAMETERS +------------------ +recursive + Operate recursively (Linux only). + +default + Add default ACL entries. + +remove + Remove undefined ACL entries (Solaris not supported). + + +EXAMPLES +-------- + +.. code-block:: sh + + __acl /srv/project \ + --recursive \ + --default \ + --remove \ + --user alice:rwx \ + --user bob:r-x \ + --group project-group:rwx \ + --group some-other-group:r-x + + +AUTHORS +------- +Ander Punnar + + +COPYING +------- +Copyright \(C) 2018 Ander Punnar. 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/__acl/parameter/boolean b/cdist/conf/type/__acl/parameter/boolean new file mode 100644 index 00000000..8b96693f --- /dev/null +++ b/cdist/conf/type/__acl/parameter/boolean @@ -0,0 +1,3 @@ +recursive +default +remove diff --git a/cdist/conf/type/__acl/parameter/optional_multiple b/cdist/conf/type/__acl/parameter/optional_multiple new file mode 100644 index 00000000..22f5a52c --- /dev/null +++ b/cdist/conf/type/__acl/parameter/optional_multiple @@ -0,0 +1,2 @@ +user +group From d7a1645e4ed3f9bca0d687c51feb209b9dbabb49 Mon Sep 17 00:00:00 2001 From: Ander Punnar Date: Mon, 11 Jun 2018 11:21:07 +0300 Subject: [PATCH 0037/1217] __acl: fix os explorer --- cdist/conf/type/__acl/gencode-remote | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cdist/conf/type/__acl/gencode-remote b/cdist/conf/type/__acl/gencode-remote index a9d14102..a59d49e0 100755 --- a/cdist/conf/type/__acl/gencode-remote +++ b/cdist/conf/type/__acl/gencode-remote @@ -18,7 +18,7 @@ # along with cdist. If not, see . # -os="$( "$__explorer/os" )" +os="$( cat "$__global/explorer/os" )" acl_path="/$__object_id" From b9a48c931689afe009075fc3ddc0b9ab7fb34d10 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Wed, 13 Jun 2018 06:20:02 +0200 Subject: [PATCH 0038/1217] ++changelog --- docs/changelog | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/changelog b/docs/changelog index 38411e14..241f4933 100644 --- a/docs/changelog +++ b/docs/changelog @@ -1,6 +1,9 @@ Changelog --------- +next: + * New type: __acl (Ander Punnar) + 4.9.1: 2018-05-30 * New type: __install_coreos (Ľubomír Kučera) * Type __consul_agent: Add LSB init header (Nico Schottelius) From 5aa8dac80a93b4158a713a7837f460042ecd11fe Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Wed, 13 Jun 2018 07:53:52 +0200 Subject: [PATCH 0039/1217] Disable config parser interpolation --- cdist/configuration.py | 2 +- cdist/test/configuration/__init__.py | 66 ++++++++++++------- .../fixtures/interpolation-test.cfg | 2 + docs/changelog | 1 + 4 files changed, 45 insertions(+), 26 deletions(-) create mode 100644 cdist/test/configuration/fixtures/interpolation-test.cfg diff --git a/cdist/configuration.py b/cdist/configuration.py index 848956aa..8df43f9f 100644 --- a/cdist/configuration.py +++ b/cdist/configuration.py @@ -382,7 +382,7 @@ class Configuration(metaclass=Singleton): return args def _read_config_file(self, files): - config_parser = configparser.ConfigParser() + config_parser = configparser.ConfigParser(interpolation=None) config_parser.read(files) d = dict() for section in config_parser.sections(): diff --git a/cdist/test/configuration/__init__.py b/cdist/test/configuration/__init__.py index e34c30b9..3319d320 100644 --- a/cdist/test/configuration/__init__.py +++ b/cdist/test/configuration/__init__.py @@ -31,6 +31,11 @@ import logging my_dir = op.abspath(op.dirname(__file__)) fixtures = op.join(my_dir, 'fixtures') +interpolation_config_file = op.join(fixtures, "interpolation-test.cfg") + + +def newConfigParser(): + return configparser.ConfigParser(interpolation=None) class ConfigurationOptionsTestCase(test.CdistTestCase): @@ -141,7 +146,7 @@ class ConfigurationTestCase(test.CdistTestCase): def setUp(self): # Create test config file. - config = configparser.ConfigParser() + config = newConfigParser() config['GLOBAL'] = { 'beta': 'off', 'local_shell': '/bin/sh', @@ -159,13 +164,13 @@ class ConfigurationTestCase(test.CdistTestCase): 'verbosity': 'INFO', 'archiving': 'none', } - config_custom = configparser.ConfigParser() + config_custom = newConfigParser() config_custom['GLOBAL'] = { 'parallel': '4', 'archiving': 'txz', } - config_custom2 = configparser.ConfigParser() + config_custom2 = newConfigParser() config_custom2['GLOBAL'] = { 'parallel': '16', 'archiving': 'tbz2', @@ -405,7 +410,7 @@ class ConfigurationTestCase(test.CdistTestCase): } args = argparse.Namespace() - config = configparser.ConfigParser() + config = newConfigParser() config['GLOBAL'] = { 'beta': 'off', 'local_shell': '/bin/sh', @@ -463,7 +468,7 @@ class ConfigurationTestCase(test.CdistTestCase): } args = argparse.Namespace() - config = configparser.ConfigParser() + config = newConfigParser() config['GLOBAL'] = { 'beta': 'off', 'local_shell': '/bin/sh', @@ -486,7 +491,7 @@ class ConfigurationTestCase(test.CdistTestCase): with open(global_config_file, 'w') as f: config.write(f) - config = configparser.ConfigParser() + config = newConfigParser() config['GLOBAL'] = { 'beta': 'on', 'local_shell': '/usr/bin/sh', @@ -544,7 +549,7 @@ class ConfigurationTestCase(test.CdistTestCase): } args = argparse.Namespace() - config = configparser.ConfigParser() + config = newConfigParser() config['GLOBAL'] = { 'beta': 'off', 'local_shell': '/bin/sh', @@ -611,7 +616,7 @@ class ConfigurationTestCase(test.CdistTestCase): } args = argparse.Namespace() - config = configparser.ConfigParser() + config = newConfigParser() config['GLOBAL'] = { 'beta': 'off', 'local_shell': '/bin/sh', @@ -634,7 +639,7 @@ class ConfigurationTestCase(test.CdistTestCase): with open(global_config_file, 'w') as f: config.write(f) - config = configparser.ConfigParser() + config = newConfigParser() config['GLOBAL'] = { 'beta': 'on', 'local_shell': '/usr/bin/sh', @@ -709,7 +714,7 @@ class ConfigurationTestCase(test.CdistTestCase): } args = argparse.Namespace() - config = configparser.ConfigParser() + config = newConfigParser() config['GLOBAL'] = { 'beta': 'off', 'local_shell': '/bin/sh', @@ -732,7 +737,7 @@ class ConfigurationTestCase(test.CdistTestCase): with open(global_config_file, 'w') as f: config.write(f) - config = configparser.ConfigParser() + config = newConfigParser() config['GLOBAL'] = { 'beta': 'on', 'local_shell': '/usr/bin/sh', @@ -800,7 +805,7 @@ class ConfigurationTestCase(test.CdistTestCase): } args = argparse.Namespace() - config = configparser.ConfigParser() + config = newConfigParser() config['GLOBAL'] = { 'beta': 'off', 'local_shell': '/bin/sh', @@ -823,7 +828,7 @@ class ConfigurationTestCase(test.CdistTestCase): with open(global_config_file, 'w') as f: config.write(f) - config = configparser.ConfigParser() + config = newConfigParser() config['GLOBAL'] = { 'beta': 'on', 'local_shell': '/usr/bin/sh', @@ -840,7 +845,7 @@ class ConfigurationTestCase(test.CdistTestCase): with open(local_config_file, 'w') as f: config.write(f) - config = configparser.ConfigParser() + config = newConfigParser() config['GLOBAL'] = { 'conf_dir': '/opt/conf/cdist', 'remote_copy': 'scpcustom', @@ -899,7 +904,7 @@ class ConfigurationTestCase(test.CdistTestCase): } args = argparse.Namespace() - config = configparser.ConfigParser() + config = newConfigParser() config['GLOBAL'] = { 'beta': 'off', 'local_shell': '/bin/sh', @@ -922,7 +927,7 @@ class ConfigurationTestCase(test.CdistTestCase): with open(global_config_file, 'w') as f: config.write(f) - config = configparser.ConfigParser() + config = newConfigParser() config['GLOBAL'] = { 'beta': 'on', 'local_shell': '/usr/bin/sh', @@ -939,7 +944,7 @@ class ConfigurationTestCase(test.CdistTestCase): with open(local_config_file, 'w') as f: config.write(f) - config = configparser.ConfigParser() + config = newConfigParser() config['GLOBAL'] = { 'conf_dir': '/opt/conf/cdist', 'remote_copy': 'scpcustom', @@ -998,7 +1003,7 @@ class ConfigurationTestCase(test.CdistTestCase): } args = argparse.Namespace() - config = configparser.ConfigParser() + config = newConfigParser() config['GLOBAL'] = { 'beta': 'off', 'local_shell': '/bin/sh', @@ -1021,7 +1026,7 @@ class ConfigurationTestCase(test.CdistTestCase): with open(global_config_file, 'w') as f: config.write(f) - config = configparser.ConfigParser() + config = newConfigParser() config['GLOBAL'] = { 'beta': 'on', 'local_shell': '/usr/bin/sh', @@ -1038,7 +1043,7 @@ class ConfigurationTestCase(test.CdistTestCase): with open(local_config_file, 'w') as f: config.write(f) - config = configparser.ConfigParser() + config = newConfigParser() config['GLOBAL'] = { 'conf_dir': '/opt/conf/cdist', 'remote_copy': 'scpcustom', @@ -1107,7 +1112,7 @@ class ConfigurationTestCase(test.CdistTestCase): self.assertEqual(dargs, expected_args) def test_configuration_empty_value_in_file(self): - config = configparser.ConfigParser() + config = newConfigParser() config['GLOBAL'] = { 'inventory_dir': '', 'conf_dir': '', @@ -1169,7 +1174,7 @@ class ConfigurationTestCase(test.CdistTestCase): config_files=()) def test_configuration_disable_saving_output_streams1(self): - config = configparser.ConfigParser() + config = newConfigParser() config['GLOBAL'] = { 'save_output_streams': 'True', } @@ -1197,7 +1202,7 @@ class ConfigurationTestCase(test.CdistTestCase): self.assertEqual(configuration.config, expected_config_dict) def test_configuration_disable_saving_output_streams2(self): - config = configparser.ConfigParser() + config = newConfigParser() config['GLOBAL'] = { 'save_output_streams': 'False', } @@ -1225,7 +1230,7 @@ class ConfigurationTestCase(test.CdistTestCase): self.assertEqual(configuration.config, expected_config_dict) def test_configuration_disable_saving_output_streams3(self): - config = configparser.ConfigParser() + config = newConfigParser() config['GLOBAL'] = { 'save_output_streams': 'False', } @@ -1253,7 +1258,7 @@ class ConfigurationTestCase(test.CdistTestCase): self.assertEqual(configuration.config, expected_config_dict) def test_configuration_disable_saving_output_streams4(self): - config = configparser.ConfigParser() + config = newConfigParser() config['GLOBAL'] = { 'save_output_streams': 'True', } @@ -1280,6 +1285,17 @@ class ConfigurationTestCase(test.CdistTestCase): config_files=config_files) self.assertEqual(configuration.config, expected_config_dict) + def test_read_config_file_with_interpolation(self): + try: + config = cc.Configuration(None, env={}, config_files=()) + d = config._read_config_file(interpolation_config_file) + val = d['GLOBAL']['cache_path_pattern'] + self.assertIsNotNone(val) + self.assertEqual(val, '%N') + except configparser.InterpolationSyntaxError as e: + self.fail("Exception should not have been raised: {}".format( + e)) + if __name__ == "__main__": import unittest diff --git a/cdist/test/configuration/fixtures/interpolation-test.cfg b/cdist/test/configuration/fixtures/interpolation-test.cfg new file mode 100644 index 00000000..df723121 --- /dev/null +++ b/cdist/test/configuration/fixtures/interpolation-test.cfg @@ -0,0 +1,2 @@ +[GLOBAL] +cache_path_pattern = %N diff --git a/docs/changelog b/docs/changelog index 241f4933..6a1e1318 100644 --- a/docs/changelog +++ b/docs/changelog @@ -3,6 +3,7 @@ Changelog next: * New type: __acl (Ander Punnar) + * Core: Disable config parser interpolation (Darko Poljak) 4.9.1: 2018-05-30 * New type: __install_coreos (Ľubomír Kučera) From 9d4c0331a9fd4772162c8ff98cdcae91040c94ac Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Fri, 15 Jun 2018 12:54:58 +0200 Subject: [PATCH 0040/1217] __sysctl: support sysctl.d --- cdist/conf/type/__sysctl/explorer/conf-path | 25 +++++++++++++++++++++ cdist/conf/type/__sysctl/manifest | 4 +++- 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100755 cdist/conf/type/__sysctl/explorer/conf-path diff --git a/cdist/conf/type/__sysctl/explorer/conf-path b/cdist/conf/type/__sysctl/explorer/conf-path new file mode 100755 index 00000000..ba35c4c6 --- /dev/null +++ b/cdist/conf/type/__sysctl/explorer/conf-path @@ -0,0 +1,25 @@ +#!/bin/sh +# +# 2018 Darko Poljak (darko.poljak at gmail.com) +# +# This file is part of cdist. +# +# cdist is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# cdist is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with cdist. If not, see . +# + +if [ -d "/etc/sysctl.d" ]; then + echo "/etc/sysctl.d/99-Z-sysctl-cdist.conf"; +else + echo "/etc/sysctl.conf"; +fi diff --git a/cdist/conf/type/__sysctl/manifest b/cdist/conf/type/__sysctl/manifest index c903dbae..6e337ccb 100755 --- a/cdist/conf/type/__sysctl/manifest +++ b/cdist/conf/type/__sysctl/manifest @@ -32,8 +32,10 @@ case "$os" in ;; esac +conf_path=$(cat "$__object/explorer/conf-path") + __key_value "$__object_name" \ --key "$__object_id" \ - --file /etc/sysctl.conf \ + --file "${conf_path}" \ --value "$(cat "$__object/parameter/value")" \ --delimiter '=' From d49daca3dc9e3af09e42ea37dc38d561cf3d5743 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Sat, 16 Jun 2018 10:51:46 +0200 Subject: [PATCH 0041/1217] ++changelog --- docs/changelog | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/changelog b/docs/changelog index 6a1e1318..509d0c44 100644 --- a/docs/changelog +++ b/docs/changelog @@ -4,6 +4,8 @@ Changelog next: * New type: __acl (Ander Punnar) * Core: Disable config parser interpolation (Darko Poljak) + * Type __sysctl: Use sysctl.d location if exists (Darko Poljak) + * Type __line: Rewrite and support --before and --after (Steven Armstrong) 4.9.1: 2018-05-30 * New type: __install_coreos (Ľubomír Kučera) From ee64936ff9f07a2129a6c809db0512aafd2d70bc Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Sun, 17 Jun 2018 10:57:06 +0200 Subject: [PATCH 0042/1217] Release 4.10.0 --- docs/changelog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/changelog b/docs/changelog index 509d0c44..0001b346 100644 --- a/docs/changelog +++ b/docs/changelog @@ -1,7 +1,7 @@ Changelog --------- -next: +4.10.0: 2018-06-17 * New type: __acl (Ander Punnar) * Core: Disable config parser interpolation (Darko Poljak) * Type __sysctl: Use sysctl.d location if exists (Darko Poljak) From ec8f2f9488ef6dc7f6bc3ae282979555f544e82c Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Wed, 20 Jun 2018 08:29:41 +0200 Subject: [PATCH 0043/1217] Fix temp file location and removal --- cdist/conf/type/__letsencrypt_cert/gencode-remote | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cdist/conf/type/__letsencrypt_cert/gencode-remote b/cdist/conf/type/__letsencrypt_cert/gencode-remote index 788da74c..375570a4 100755 --- a/cdist/conf/type/__letsencrypt_cert/gencode-remote +++ b/cdist/conf/type/__letsencrypt_cert/gencode-remote @@ -16,7 +16,7 @@ case "${state}" in ;; present) domain_param_file="${__object}/parameter/domain" - requested_domains=$(mktemp domain.cdist.XXXXXXXXXX) + requested_domains=$(mktemp "${TMPDIR:-/tmp}/domain.cdist.XXXXXXXXXX") if [ -f "${domain_param_file}" ]; then cp "${domain_param_file}" "${requested_domains}" else @@ -66,6 +66,7 @@ case "${state}" in echo "--domain '${domain}' \\" done < "${requested_domains}") EOF + rm -f "${requested_domains}" if [ "${certificate_exists}" = "no" ]; then echo create >> "${__messages_out}" From 41186d66d406a3eb411e6fc1e8aa4b68ffbd49a7 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Wed, 20 Jun 2018 09:23:12 +0200 Subject: [PATCH 0044/1217] ++changelog --- docs/changelog | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/changelog b/docs/changelog index 0001b346..b81c4939 100644 --- a/docs/changelog +++ b/docs/changelog @@ -1,6 +1,9 @@ Changelog --------- +next: + * Type __letsencrypt_cert: Fix temp file location and removal (Darko Poljak) + 4.10.0: 2018-06-17 * New type: __acl (Ander Punnar) * Core: Disable config parser interpolation (Darko Poljak) From 4eaace7dd5c427150cf99b07893bff7c1d072f8c Mon Sep 17 00:00:00 2001 From: Jonas Weber Date: Wed, 20 Jun 2018 11:14:25 +0200 Subject: [PATCH 0045/1217] Handle missing file in __line explorer gracefully closes #675 --- cdist/conf/type/__line/explorer/state | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cdist/conf/type/__line/explorer/state b/cdist/conf/type/__line/explorer/state index afdf3502..2ef252c8 100755 --- a/cdist/conf/type/__line/explorer/state +++ b/cdist/conf/type/__line/explorer/state @@ -39,6 +39,11 @@ else file="/$__object_id" fi +if [ ! -f "$file" ]; then + echo "file_missing" + exit 0 +fi + awk -v position="$position" -v needle="$needle" ' function _find(_text, _pattern) { if (needle == "regex") { From 58b0e83655895f5d92c7c4c63ba4b79651703ee6 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Wed, 20 Jun 2018 17:28:30 +0200 Subject: [PATCH 0046/1217] Add env vars usage idiom for writing types --- docs/src/cdist-type.rst | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/docs/src/cdist-type.rst b/docs/src/cdist-type.rst index a6587328..7c0dab8d 100644 --- a/docs/src/cdist-type.rst +++ b/docs/src/cdist-type.rst @@ -331,6 +331,19 @@ So when you generate a script with the following content, it will work: fi +Environment variable usage idiom +-------------------------------- +In type scripts you can support environment variables with default values if +environment variable is unset or null by using **${parameter:-[word]}** +parameter expansion. + +Example using mktemp in a portable way that supports TMPDIR environment variable. + +.. code-block:: sh + + tempfile=$(mktemp "${TMPDIR:-/tmp}/cdist.XXXXXXXXXX") + + Log level in types ------------------ cdist log level can be accessed from __cdist_log_level variable.One of: From 8350b6297ea2b03005d5b7beaaec64e02c8d4ff3 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Wed, 20 Jun 2018 17:28:38 +0200 Subject: [PATCH 0047/1217] ++changelog --- docs/changelog | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/changelog b/docs/changelog index b81c4939..3794221f 100644 --- a/docs/changelog +++ b/docs/changelog @@ -3,6 +3,8 @@ Changelog next: * Type __letsencrypt_cert: Fix temp file location and removal (Darko Poljak) + * Type __line: Handle missing file in __line explorer gracefully (Jonas Weber) + * Documentation: Add env vars usage idiom for writing types (Darko Poljak) 4.10.0: 2018-06-17 * New type: __acl (Ander Punnar) From 7eae68c11da10d294e181f099dd2c58fffc81be6 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Thu, 21 Jun 2018 08:33:48 +0200 Subject: [PATCH 0048/1217] Release 4.10.1 --- docs/changelog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/changelog b/docs/changelog index 3794221f..4453b6cb 100644 --- a/docs/changelog +++ b/docs/changelog @@ -1,7 +1,7 @@ Changelog --------- -next: +4.10.1: 2018-06-21 * Type __letsencrypt_cert: Fix temp file location and removal (Darko Poljak) * Type __line: Handle missing file in __line explorer gracefully (Jonas Weber) * Documentation: Add env vars usage idiom for writing types (Darko Poljak) From 6c8014b407cf28ee54764ffc6182cb28a580dc66 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Fri, 22 Jun 2018 14:09:31 +0200 Subject: [PATCH 0049/1217] __letsencrypt_cert: add support for devuan ascii --- cdist/conf/type/__letsencrypt_cert/manifest | 11 +++++++++++ docs/changelog | 3 +++ 2 files changed, 14 insertions(+) diff --git a/cdist/conf/type/__letsencrypt_cert/manifest b/cdist/conf/type/__letsencrypt_cert/manifest index 94e9d225..56e3532c 100755 --- a/cdist/conf/type/__letsencrypt_cert/manifest +++ b/cdist/conf/type/__letsencrypt_cert/manifest @@ -56,6 +56,17 @@ if [ -z "${certbot_fullpath}" ]; then # Seems to be a missing dependency on debian 8 __package python-ndg-httpsclient ;; + ascii*) + __apt_source ascii-backports \ + --uri http://auto.mirror.devuan.org/merged \ + --distribution ascii-backports \ + --component main + + require="__apt_source/ascii-backports" __package_apt python-certbot \ + --target-release ascii-backports + require="__apt_source/ascii-backports" __package_apt certbot \ + --target-release ascii-backports + ;; *) echo "Unsupported OS version: $os_version" >&2 exit 1 diff --git a/docs/changelog b/docs/changelog index 4453b6cb..921e0c26 100644 --- a/docs/changelog +++ b/docs/changelog @@ -1,6 +1,9 @@ Changelog --------- +next: + * Type __letsencrypt_cert: Add support for devuan ascii (Darko Poljak) + 4.10.1: 2018-06-21 * Type __letsencrypt_cert: Fix temp file location and removal (Darko Poljak) * Type __line: Handle missing file in __line explorer gracefully (Jonas Weber) From 8d84834db6f2bf16474161cff358496d76923801 Mon Sep 17 00:00:00 2001 From: Adam Dej Date: Wed, 11 Jul 2018 15:53:23 +0200 Subject: [PATCH 0050/1217] __systemd_unit: manpage clarifications Clarify that this type only operates on units in /etc/systemd/system. Also, when state=present, it is not always true that the type is "installed, enabled and started" --- cdist/conf/type/__systemd_unit/man.rst | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/cdist/conf/type/__systemd_unit/man.rst b/cdist/conf/type/__systemd_unit/man.rst index 88da6b30..5d68b253 100644 --- a/cdist/conf/type/__systemd_unit/man.rst +++ b/cdist/conf/type/__systemd_unit/man.rst @@ -9,9 +9,10 @@ cdist-type__systemd_unit - Install a systemd unit DESCRIPTION ----------- -This type can install, enable and start a systemd unit. This is particularly -useful on systems which take advantage of systemd heavily (e.g., CoreOS). For -more information about systemd units, see SYSTEMD.UNIT(5). +This type manages systemd units in ``/etc/systemd/system/``. It can install, +enable and start a systemd unit. This is particularly useful on systems which +take advantage of systemd heavily (e.g., CoreOS). For more information about +systemd units, see SYSTEMD.UNIT(5). REQUIRED PARAMETERS ------------------- @@ -37,7 +38,7 @@ state 'present' or 'absent', defaults to 'present' where: present - the unit is installed, enabled and started + the unit is installed absent the unit is stopped, disabled and uninstalled From 37b37f6e66d1d2d85b3eb2178787aec03221d2a6 Mon Sep 17 00:00:00 2001 From: Adam Dej Date: Wed, 11 Jul 2018 15:58:41 +0200 Subject: [PATCH 0051/1217] __systemd_unit: fix crash when transitioning to state=absent This type tried to disable an unit after it has removed it, which failed. Now the removal happens in gencode-remote, after the unit has been stopped and disabled. --- cdist/conf/type/__systemd_unit/gencode-remote | 2 ++ cdist/conf/type/__systemd_unit/manifest | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/cdist/conf/type/__systemd_unit/gencode-remote b/cdist/conf/type/__systemd_unit/gencode-remote index c608d9b3..9c64b6c4 100644 --- a/cdist/conf/type/__systemd_unit/gencode-remote +++ b/cdist/conf/type/__systemd_unit/gencode-remote @@ -25,6 +25,8 @@ current_enablement_state=$(cat "${__object}/explorer/enablement-state") if [ "${state}" = "absent" ]; then if [ ! -z "${current_enablement_state}" ]; then echo "systemctl --now disable ${name}" + echo "rm -f /etc/systemd/system/${name}" + echo "systemctl daemon-reload" fi exit 0 diff --git a/cdist/conf/type/__systemd_unit/manifest b/cdist/conf/type/__systemd_unit/manifest index 8b136605..7739c3d8 100644 --- a/cdist/conf/type/__systemd_unit/manifest +++ b/cdist/conf/type/__systemd_unit/manifest @@ -30,7 +30,9 @@ name="${__object_id}" source=$(cat "${__object}/parameter/source") state=$(cat "${__object}/parameter/state") -if [ -z "${source}" ] && [ "${state}" != "absent" ]; then +# The unit must be disabled before removing its unit file. The unit file is +# therefore removed by gencode-remote of this type, not here. +if [ -z "${source}" ] || [ "${state}" = "absent" ]; then exit 0 fi From 43982f821f6cae64a99673cf9541b5b0b0a940c1 Mon Sep 17 00:00:00 2001 From: Adam Dej Date: Wed, 11 Jul 2018 13:00:41 +0200 Subject: [PATCH 0052/1217] __systemd_unit: add support for masking units --- cdist/conf/type/__systemd_unit/gencode-remote | 17 ++++++++++++++--- cdist/conf/type/__systemd_unit/man.rst | 12 ++++++++---- cdist/conf/type/__systemd_unit/manifest | 12 +++++++++++- 3 files changed, 33 insertions(+), 8 deletions(-) diff --git a/cdist/conf/type/__systemd_unit/gencode-remote b/cdist/conf/type/__systemd_unit/gencode-remote index 9c64b6c4..60486c52 100644 --- a/cdist/conf/type/__systemd_unit/gencode-remote +++ b/cdist/conf/type/__systemd_unit/gencode-remote @@ -33,16 +33,24 @@ if [ "${state}" = "absent" ]; then fi unit_status=$(cat "${__object}/explorer/unit-status") +desired_enablement_state=$(cat "${__object}/parameter/enablement-state") + +if [ "${current_enablement_state}" = "masked" ] && \ + [ "${desired_enablement_state}" != "masked" ]; then + echo "systemctl unmask ${name}" +fi if [ -f "${__object}/parameter/restart" ]; then - if grep -q "^__file/etc/systemd/system/${name}" "${__messages_in}" || \ + if [ "${desired_enablement_state}" = "masked" ]; then + if [ "${unit_status}" = "active" ]; then + echo "systemctl stop ${name}" + fi + elif grep -q "^__file/etc/systemd/system/${name}" "${__messages_in}" || \ [ "${unit_status}" != "active" ]; then echo "systemctl restart ${name} || true" fi fi -desired_enablement_state=$(cat "${__object}/parameter/enablement-state") - if [ "${current_enablement_state}" = "${desired_enablement_state}" ]; then exit 0 fi @@ -58,6 +66,9 @@ case "${desired_enablement_state}" in disabled) echo "systemctl disable ${name}" ;; + masked) + echo "systemctl mask ${name}" + ;; *) echo "Unsupported unit status: ${desired_enablement_state}" >&2 exit 1 diff --git a/cdist/conf/type/__systemd_unit/man.rst b/cdist/conf/type/__systemd_unit/man.rst index 5d68b253..25a4e501 100644 --- a/cdist/conf/type/__systemd_unit/man.rst +++ b/cdist/conf/type/__systemd_unit/man.rst @@ -23,12 +23,14 @@ OPTIONAL PARAMETERS ------------------- enablement-state - 'enabled' or 'disabled', where: + 'enabled', 'disabled' or 'masked', where: enabled enables the unit disabled disables the unit + masked + masks the unit source Path to the config file. If source is '-' (dash), take what was written to @@ -38,15 +40,17 @@ state 'present' or 'absent', defaults to 'present' where: present - the unit is installed + the unit (or its mask) is installed absent - the unit is stopped, disabled and uninstalled + The unit is stopped, disabled and uninstalled. If the unit was masked, + the mask is removed. BOOLEAN PARAMETERS ------------------ restart - Restart the unit on unit file change or when the unit is inactive. + Start the unit if it was inactive. Restart the unit if the unit file + changed. Stop the unit if new ``enablement-state`` is ``masked``. MESSAGES -------- diff --git a/cdist/conf/type/__systemd_unit/manifest b/cdist/conf/type/__systemd_unit/manifest index 7739c3d8..688a00b1 100644 --- a/cdist/conf/type/__systemd_unit/manifest +++ b/cdist/conf/type/__systemd_unit/manifest @@ -29,6 +29,7 @@ fi name="${__object_id}" source=$(cat "${__object}/parameter/source") state=$(cat "${__object}/parameter/state") +enablement_state=$(cat "${__object}/parameter/enablement-state") # The unit must be disabled before removing its unit file. The unit file is # therefore removed by gencode-remote of this type, not here. @@ -41,8 +42,17 @@ if [ "${source}" = "-" ]; then source="${__object}/stdin" fi +unitfile_state="${state}" +if [ "${enablement_state}" = "masked" ]; then + # Masking creates a symlink from /etc/systemd/system/ to /dev/null. + # This process fails with "Failed to execute operation: Invalid argument" + # if file /etc/systemd/system/ already exists. We must therefore + # remove it. + unitfile_state="absent" +fi + __config_file "/etc/systemd/system/${name}" \ --mode 644 \ --onchange "systemctl daemon-reload" \ --source "${source}" \ - --state "${state}" + --state "${unitfile_state}" From 1f2b7c84c2c56b69267321174971794da2d1b986 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Wed, 18 Jul 2018 07:40:34 +0200 Subject: [PATCH 0053/1217] ++changelog --- docs/changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog b/docs/changelog index 921e0c26..370c034b 100644 --- a/docs/changelog +++ b/docs/changelog @@ -3,6 +3,7 @@ Changelog next: * Type __letsencrypt_cert: Add support for devuan ascii (Darko Poljak) + * Type __systemd_unit: Fix minor issues and add masking unit files support (Adam Dej) 4.10.1: 2018-06-21 * Type __letsencrypt_cert: Fix temp file location and removal (Darko Poljak) From f04f76524c60b8de865079e24a6143a83b8e5d7b Mon Sep 17 00:00:00 2001 From: Dominique Roux Date: Sun, 22 Jul 2018 18:35:30 +0200 Subject: [PATCH 0054/1217] Bugfix: - __grafana_dashboard had the wrong release name for devuan ascii --- cdist/conf/type/__grafana_dashboard/manifest | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cdist/conf/type/__grafana_dashboard/manifest b/cdist/conf/type/__grafana_dashboard/manifest index e62bd15f..308af59a 100755 --- a/cdist/conf/type/__grafana_dashboard/manifest +++ b/cdist/conf/type/__grafana_dashboard/manifest @@ -9,7 +9,7 @@ case $os in 8*|jessie) apt_source_distribution=jessie ;; - 9*|ascii/ceres) + 9*|ascii/ceres|ascii) apt_source_distribution=stretch ;; *) From eeb059015029208ec55131caf2e5f17c3bd0b738 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Mon, 23 Jul 2018 08:09:55 +0200 Subject: [PATCH 0055/1217] ++changelog --- docs/changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog b/docs/changelog index 370c034b..311d7a57 100644 --- a/docs/changelog +++ b/docs/changelog @@ -4,6 +4,7 @@ Changelog next: * Type __letsencrypt_cert: Add support for devuan ascii (Darko Poljak) * Type __systemd_unit: Fix minor issues and add masking unit files support (Adam Dej) + * Type __grafana_dashboard: Fix devuan ascii support (Dominique Roux) 4.10.1: 2018-06-21 * Type __letsencrypt_cert: Fix temp file location and removal (Darko Poljak) From 2f89d8a514a5996a76ca5a34397b3d087e2fe5c2 Mon Sep 17 00:00:00 2001 From: Stu Zhao Date: Tue, 28 Aug 2018 23:27:13 -0700 Subject: [PATCH 0056/1217] Fix __package_update_index processing error exit 1 in explorer will abort cdist. --- cdist/conf/type/__package_update_index/explorer/currage | 1 - docs/changelog | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/cdist/conf/type/__package_update_index/explorer/currage b/cdist/conf/type/__package_update_index/explorer/currage index cd042bd5..e86e3f13 100644 --- a/cdist/conf/type/__package_update_index/explorer/currage +++ b/cdist/conf/type/__package_update_index/explorer/currage @@ -29,6 +29,5 @@ case "$os" in ;; *) echo "Your operating system ($os) is currently not supported by this type (${__type##*/})." >&2 echo "Please contribute an implementation for it if you can." >&2 - exit 1 ;; esac diff --git a/docs/changelog b/docs/changelog index 311d7a57..12bdb1e0 100644 --- a/docs/changelog +++ b/docs/changelog @@ -5,6 +5,7 @@ next: * Type __letsencrypt_cert: Add support for devuan ascii (Darko Poljak) * Type __systemd_unit: Fix minor issues and add masking unit files support (Adam Dej) * Type __grafana_dashboard: Fix devuan ascii support (Dominique Roux) + * Type __package_update_index: Fix error when using OS not using apt (Stu Zhao) 4.10.1: 2018-06-21 * Type __letsencrypt_cert: Fix temp file location and removal (Darko Poljak) From b12c02138df4086e2e8e5e366e2156fa2ff95b3a Mon Sep 17 00:00:00 2001 From: Stu Zhao Date: Wed, 29 Aug 2018 00:07:19 -0700 Subject: [PATCH 0057/1217] Refactor __package_update_index explorers * add an type explorer to unify detecting of package type. * update currage use the type explorer, so if os and passed in type does not match, it behaves correctly. --- .../__package_update_index/explorer/currage | 8 ++--- .../type/__package_update_index/explorer/type | 34 +++++++++++++++++++ .../__package_update_index/gencode-remote | 18 +--------- 3 files changed, 39 insertions(+), 21 deletions(-) create mode 100644 cdist/conf/type/__package_update_index/explorer/type diff --git a/cdist/conf/type/__package_update_index/explorer/currage b/cdist/conf/type/__package_update_index/explorer/currage index e86e3f13..45653f91 100644 --- a/cdist/conf/type/__package_update_index/explorer/currage +++ b/cdist/conf/type/__package_update_index/explorer/currage @@ -17,17 +17,17 @@ # You should have received a copy of the GNU General Public License # along with cdist. If not, see . -os="$("$__explorer/os")" +type="$($__type_explorer/type)" -case "$os" in - debian|ubuntu|devuan) +case "$type" in + apt) if [ -f "/var/cache/apt/pkgcache.bin" ]; then echo $(($(date +"%s")-$(stat --format '%Y' /var/cache/apt/pkgcache.bin))) else echo 0 fi ;; - *) echo "Your operating system ($os) is currently not supported by this type (${__type##*/})." >&2 + *) echo "Your specified type ($type) is currently not supported." >&2 echo "Please contribute an implementation for it if you can." >&2 ;; esac diff --git a/cdist/conf/type/__package_update_index/explorer/type b/cdist/conf/type/__package_update_index/explorer/type new file mode 100644 index 00000000..805b9f04 --- /dev/null +++ b/cdist/conf/type/__package_update_index/explorer/type @@ -0,0 +1,34 @@ +#!/bin/sh +# +# 2018 Stu Zhao (z12y12l12 at gmail.com) +# +# This file is part of cdist. +# +# cdist is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# cdist is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with cdist. If not, see . + +if [ -f "$__object/parameter/type" ]; then + cat "$__object/parameter/type" +else + # By default determine package manager based on operating system + os="$($__explorer/os)" + case "$os" in + amazon|scientific|centos|fedora|redhat) echo "yum" ;; + debian|ubuntu|devuan) echo "apt" ;; + archlinux) echo "pacman" ;; + *) + echo "Don't know how to manage packages on: $os" >&2 + exit 1 + ;; + esac +fi diff --git a/cdist/conf/type/__package_update_index/gencode-remote b/cdist/conf/type/__package_update_index/gencode-remote index 37bfe7ab..132a3daa 100755 --- a/cdist/conf/type/__package_update_index/gencode-remote +++ b/cdist/conf/type/__package_update_index/gencode-remote @@ -21,28 +21,12 @@ # Update the package index with the appropriate package manager # -type="$__object/parameter/type" +type=$(cat "$__object/explorer/type") if [ -f "$__object/parameter/maxage" ]; then maxage="$(cat "$__object/parameter/maxage")" currage="$(cat "$__object/explorer/currage")" fi -if [ -f "$type" ]; then - type="$(cat "$type")" -else - # By default determine package manager based on operating system - os="$(cat "$__global/explorer/os")" - case "$os" in - amazon|scientific|centos|fedora|redhat) type="yum" ;; - debian|ubuntu|devuan) type="apt" ;; - archlinux) type="pacman" ;; - *) - echo "Don't know how to manage packages on: $os" >&2 - exit 1 - ;; - esac -fi - if [ -n "$maxage" ] && [ "$type" != "apt" ]; then echo "ERROR: \"--maxage\" only supported for \"apt\" pkg-manager." >&2 exit 1 From f143a70463e0740937370faa9492daf5cba9a2fd Mon Sep 17 00:00:00 2001 From: Stu Zhao Date: Wed, 29 Aug 2018 00:30:27 -0700 Subject: [PATCH 0058/1217] Support pacman with --maxage parameter --- .../__package_update_index/explorer/currage | 7 ++++ .../__package_update_index/gencode-remote | 35 ++++++++++--------- .../conf/type/__package_update_index/man.rst | 6 ++-- docs/changelog | 1 + 4 files changed, 30 insertions(+), 19 deletions(-) diff --git a/cdist/conf/type/__package_update_index/explorer/currage b/cdist/conf/type/__package_update_index/explorer/currage index 45653f91..50474fb3 100644 --- a/cdist/conf/type/__package_update_index/explorer/currage +++ b/cdist/conf/type/__package_update_index/explorer/currage @@ -27,6 +27,13 @@ case "$type" in echo 0 fi ;; + pacman) + if [ -d "/var/lib/pacman/sync" ]; then + echo $(($(date +"%s")-$(stat --format '%Y' /var/lib/pacman/sync))) + else + echo 0 + fi + ;; *) echo "Your specified type ($type) is currently not supported." >&2 echo "Please contribute an implementation for it if you can." >&2 ;; diff --git a/cdist/conf/type/__package_update_index/gencode-remote b/cdist/conf/type/__package_update_index/gencode-remote index 132a3daa..2cc76b81 100755 --- a/cdist/conf/type/__package_update_index/gencode-remote +++ b/cdist/conf/type/__package_update_index/gencode-remote @@ -22,32 +22,33 @@ # type=$(cat "$__object/explorer/type") +currage="$(cat "$__object/explorer/currage")" if [ -f "$__object/parameter/maxage" ]; then maxage="$(cat "$__object/parameter/maxage")" - currage="$(cat "$__object/explorer/currage")" fi -if [ -n "$maxage" ] && [ "$type" != "apt" ]; then - echo "ERROR: \"--maxage\" only supported for \"apt\" pkg-manager." >&2 - exit 1 +if [ -n "$maxage" ]; then + if [ "$type" != "apt" -a "$type" != "pacman" ]; then + echo "ERROR: \"--maxage\" only supported for \"apt\" or \"pacman\" pkg-manager." >&2 + exit 1 + elif [ $currage -lt $maxage ]; then + exit 0 # no need to update + fi fi + case "$type" in yum) ;; - apt) if [ -n "$maxage" ]; then - ## check if we need to update: - if [ $currage -ge $maxage ]; then - echo "apt-get --quiet update" - echo "apt-cache updated (age was: $currage)" >> "$__messages_out" - fi - else - echo "apt-get --quiet update" - echo "apt-cache updated (age was: $currage)" >> "$__messages_out" - fi - ;; - pacman) echo "pacman --noprogressbar --sync --refresh" ;; + apt) + echo "apt-get --quiet update" + echo "apt-cache updated (age was: $currage)" >> "$__messages_out" + ;; + pacman) + echo "pacman --noprogressbar --sync --refresh" + echo "pacman package database synced (age was: $currage)" >> "$__messages_out" + ;; *) - echo "Don't know how to manage packages on: $os" >&2 + echo "Don't know how to manage packages for type: $type" >&2 exit 1 ;; esac diff --git a/cdist/conf/type/__package_update_index/man.rst b/cdist/conf/type/__package_update_index/man.rst index b63af654..3cd787b9 100644 --- a/cdist/conf/type/__package_update_index/man.rst +++ b/cdist/conf/type/__package_update_index/man.rst @@ -28,8 +28,8 @@ type * pacman for Arch Linux maxage - Available for package manager apt, max time in seconds since last update. - Repo update is skipped if maxage is not reached yet. + Available for package manager apt and pacman, max time in seconds since + last update. Repo update is skipped if maxage is not reached yet. MESSAGES -------- @@ -51,6 +51,7 @@ EXAMPLES # Only update every hour: __package_update_index --maxage 3600 --type apt + # same as above (on apt-type systems): __package_update_index --maxage 3600 @@ -58,6 +59,7 @@ AUTHORS ------- | Ricardo Catalinas Jiménez | Thomas Eckert +| Stu Zhao COPYING diff --git a/docs/changelog b/docs/changelog index 12bdb1e0..e989fb61 100644 --- a/docs/changelog +++ b/docs/changelog @@ -6,6 +6,7 @@ next: * Type __systemd_unit: Fix minor issues and add masking unit files support (Adam Dej) * Type __grafana_dashboard: Fix devuan ascii support (Dominique Roux) * Type __package_update_index: Fix error when using OS not using apt (Stu Zhao) + * Type __package_update_index: Support --maxage for type pacman (Stu Zhao) 4.10.1: 2018-06-21 * Type __letsencrypt_cert: Fix temp file location and removal (Darko Poljak) From 93d877f5bff4d12510146051af032bc92e062fd3 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Thu, 30 Aug 2018 20:22:51 +0200 Subject: [PATCH 0059/1217] Add nonparallel marker for __apt_source type. --- cdist/conf/type/__apt_source/nonparallel | 0 docs/changelog | 1 + 2 files changed, 1 insertion(+) create mode 100644 cdist/conf/type/__apt_source/nonparallel diff --git a/cdist/conf/type/__apt_source/nonparallel b/cdist/conf/type/__apt_source/nonparallel new file mode 100644 index 00000000..e69de29b diff --git a/docs/changelog b/docs/changelog index 311d7a57..e7c59952 100644 --- a/docs/changelog +++ b/docs/changelog @@ -5,6 +5,7 @@ next: * Type __letsencrypt_cert: Add support for devuan ascii (Darko Poljak) * Type __systemd_unit: Fix minor issues and add masking unit files support (Adam Dej) * Type __grafana_dashboard: Fix devuan ascii support (Dominique Roux) + * Type __apt_source: Add nonparallel marker (Darko Poljak) 4.10.1: 2018-06-21 * Type __letsencrypt_cert: Fix temp file location and removal (Darko Poljak) From 282647a88c3bbaf66db53f643796dd76976320a6 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Fri, 31 Aug 2018 10:48:21 +0200 Subject: [PATCH 0060/1217] Fix changelog formatting. --- docs/changelog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/changelog b/docs/changelog index 23b0e352..7df1a38e 100644 --- a/docs/changelog +++ b/docs/changelog @@ -6,7 +6,7 @@ next: * Type __systemd_unit: Fix minor issues and add masking unit files support (Adam Dej) * Type __grafana_dashboard: Fix devuan ascii support (Dominique Roux) * Type __apt_source: Add nonparallel marker (Darko Poljak) - * Type __package_update_index: Fix error when using OS not using apt (Stu Zhao) + * Type __package_update_index: Fix error when using OS not using apt (Stu Zhao) * Type __package_update_index: Support --maxage for type pacman (Stu Zhao) 4.10.1: 2018-06-21 From a627247908bdce5b393a6296b71b5300f5fa6b30 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Sat, 1 Sep 2018 10:38:16 +0200 Subject: [PATCH 0061/1217] Check if certbot exists before using it. Fixes #685. --- .../__letsencrypt_cert/explorer/certificate-domains | 8 ++++++-- .../__letsencrypt_cert/explorer/certificate-exists | 10 ++++++++-- .../__letsencrypt_cert/explorer/certificate-is-test | 12 +++++++++--- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/cdist/conf/type/__letsencrypt_cert/explorer/certificate-domains b/cdist/conf/type/__letsencrypt_cert/explorer/certificate-domains index 367fda93..db605b63 100755 --- a/cdist/conf/type/__letsencrypt_cert/explorer/certificate-domains +++ b/cdist/conf/type/__letsencrypt_cert/explorer/certificate-domains @@ -1,4 +1,8 @@ #!/bin/sh -e -certbot certificates --cert-name "${__object_id:?}" | grep ' Domains: ' | \ - cut -d ' ' -f 6- | tr ' ' '\n' +certbot_path=$("${__type_explorer}/certbot-path") +if [ -n "${certbot_path}" ] +then + certbot certificates --cert-name "${__object_id:?}" | grep ' Domains: ' | \ + cut -d ' ' -f 6- | tr ' ' '\n' +fi diff --git a/cdist/conf/type/__letsencrypt_cert/explorer/certificate-exists b/cdist/conf/type/__letsencrypt_cert/explorer/certificate-exists index d2ea35cc..4e6f44db 100755 --- a/cdist/conf/type/__letsencrypt_cert/explorer/certificate-exists +++ b/cdist/conf/type/__letsencrypt_cert/explorer/certificate-exists @@ -1,7 +1,13 @@ #!/bin/sh -e -if certbot certificates | grep -q " Certificate Name: ${__object_id:?}$"; then - echo yes +certbot_path=$("${__type_explorer}/certbot-path") +if [ -n "${certbot_path}" ] +then + if certbot certificates | grep -q " Certificate Name: ${__object_id:?}$"; then + echo yes + else + echo no + fi else echo no fi diff --git a/cdist/conf/type/__letsencrypt_cert/explorer/certificate-is-test b/cdist/conf/type/__letsencrypt_cert/explorer/certificate-is-test index 6d7b0ae9..9b445059 100755 --- a/cdist/conf/type/__letsencrypt_cert/explorer/certificate-is-test +++ b/cdist/conf/type/__letsencrypt_cert/explorer/certificate-is-test @@ -1,8 +1,14 @@ #!/bin/sh -e -if certbot certificates --cert-name "${__object_id:?}" | \ - grep -q 'INVALID: TEST_CERT'; then - echo yes +certbot_path=$("${__type_explorer}/certbot-path") +if [ -n "${certbot_path}" ] +then + if certbot certificates --cert-name "${__object_id:?}" | \ + grep -q 'INVALID: TEST_CERT'; then + echo yes + else + echo no + fi else echo no fi From b9ddbb1aa04dd2217db0603e6a201378a5e7b145 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Sat, 1 Sep 2018 23:30:53 +0200 Subject: [PATCH 0062/1217] ++changelog --- docs/changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog b/docs/changelog index 7df1a38e..8a188501 100644 --- a/docs/changelog +++ b/docs/changelog @@ -8,6 +8,7 @@ next: * Type __apt_source: Add nonparallel marker (Darko Poljak) * Type __package_update_index: Fix error when using OS not using apt (Stu Zhao) * Type __package_update_index: Support --maxage for type pacman (Stu Zhao) + * Type __letsencrypt_cert: Fix explorers: check that certbot exists before using it (Darko Poljak) 4.10.1: 2018-06-21 * Type __letsencrypt_cert: Fix temp file location and removal (Darko Poljak) From 3782656569547b775f3b310ff6a226e49c0a7581 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Tue, 4 Sep 2018 08:27:20 +0200 Subject: [PATCH 0063/1217] Report encoding errors nicely. --- cdist/__init__.py | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/cdist/__init__.py b/cdist/__init__.py index b7602ff8..000a571c 100644 --- a/cdist/__init__.py +++ b/cdist/__init__.py @@ -100,17 +100,23 @@ class CdistEntityError(Error): for name, path in stdpaths: if name not in result: result[name] = [] - if os.path.exists(path) and os.path.getsize(path) > 0: - output = [] - label_begin = name + ":" + header_name - output.append(label_begin) - output.append('\n') - output.append('-' * len(label_begin)) - output.append('\n') - with open(path, 'r') as fd: - output.append(fd.read()) - output.append('\n') - result[name].append(''.join(output)) + try: + if os.path.exists(path) and os.path.getsize(path) > 0: + output = [] + label_begin = name + ":" + header_name + output.append(label_begin) + output.append('\n') + output.append('-' * len(label_begin)) + output.append('\n') + with open(path, 'r') as fd: + output.append(fd.read()) + output.append('\n') + result[name].append(''.join(output)) + except UnicodeError as ue: + result[name].append(('Cannot output {}:{} due to: {}.\n' + 'You can try to read the error file "{}"' + ' yourself.').format( + name, header_name, ue, path)) return result def _stderr(self): From 55dcaecafe53cbc54b89346e3ab37ae85a3d7c6d Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Thu, 6 Sep 2018 07:11:04 +0200 Subject: [PATCH 0064/1217] Release 4.10.2 --- docs/changelog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/changelog b/docs/changelog index 8a188501..c58e445b 100644 --- a/docs/changelog +++ b/docs/changelog @@ -1,7 +1,7 @@ Changelog --------- -next: +4.10.2: 2018-09-06 * Type __letsencrypt_cert: Add support for devuan ascii (Darko Poljak) * Type __systemd_unit: Fix minor issues and add masking unit files support (Adam Dej) * Type __grafana_dashboard: Fix devuan ascii support (Dominique Roux) From c2f8c7abb33ff971c30a00a29ef2c6f4016ebcca Mon Sep 17 00:00:00 2001 From: Adam Dej Date: Sat, 21 Jul 2018 14:52:50 +0200 Subject: [PATCH 0065/1217] Add explorer for info in /etc/os-release --- cdist/conf/explorer/os_release | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 cdist/conf/explorer/os_release diff --git a/cdist/conf/explorer/os_release b/cdist/conf/explorer/os_release new file mode 100644 index 00000000..cfc01004 --- /dev/null +++ b/cdist/conf/explorer/os_release @@ -0,0 +1,26 @@ +#!/bin/sh +# +# 2018 Adam Dej (dejko.a at gmail.com) +# +# This file is part of cdist. +# +# cdist is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# cdist is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with cdist. If not, see . +# +# + +# See os-release(5) and http://0pointer.de/blog/projects/os-release + +set +e + +cat /etc/os-release || cat /usr/lib/os-release || true From 2e653409c132f9869e962dc05c905f2204d9f0b7 Mon Sep 17 00:00:00 2001 From: Adam Dej Date: Sat, 21 Jul 2018 14:53:53 +0200 Subject: [PATCH 0066/1217] Update __docker type - Update installation method, following official installation instructions. - docker-engine was renamed to Docker CE around March 2017. Update manpage to reflect that change. - Remove flag `--experimental` since it is no longer necessary to install a different binary to get experimental features. Experimental features are included in the stable binary and can be enabled by a flag or in a config file. --- cdist/conf/type/__docker/man.rst | 16 ++---- cdist/conf/type/__docker/manifest | 66 ++++++++-------------- cdist/conf/type/__docker/parameter/boolean | 1 - 3 files changed, 28 insertions(+), 55 deletions(-) delete mode 100644 cdist/conf/type/__docker/parameter/boolean diff --git a/cdist/conf/type/__docker/man.rst b/cdist/conf/type/__docker/man.rst index 70b92cc7..5cb28ee1 100644 --- a/cdist/conf/type/__docker/man.rst +++ b/cdist/conf/type/__docker/man.rst @@ -3,12 +3,12 @@ cdist-type__docker(7) NAME ---- -cdist-type__docker - install docker-engine +cdist-type__docker - install Docker CE DESCRIPTION ----------- -Installs latest docker-engine package from dockerproject.org. +Installs latest Docker Community Edition package. REQUIRED PARAMETERS @@ -18,16 +18,13 @@ None. OPTIONAL PARAMETERS ------------------- -None. +state + 'present' or 'absent', defaults to 'present' BOOLEAN PARAMETERS ------------------ -experimental - Install the experimental docker-engine package instead of the latest stable release. - -state - 'present' or 'absent', defaults to 'present' +None. EXAMPLES @@ -38,9 +35,6 @@ EXAMPLES # Install docker __docker - # Install experimental - __docker --experimental - # Remove docker __docker --state absent diff --git a/cdist/conf/type/__docker/manifest b/cdist/conf/type/__docker/manifest index 1b1b1fb7..d501a9f1 100755 --- a/cdist/conf/type/__docker/manifest +++ b/cdist/conf/type/__docker/manifest @@ -24,57 +24,37 @@ state=$(cat "$__object/parameter/state") case "$os" in centos) - component="main" - if [ -f "$__object/parameter/experimental" ]; then - component="experimental" + if (source "$__global/explorer/os_release" && [ "${VERSION_ID}" = "7" ]); then + __yum_repo docker-ce-stable \ + --name 'Docker CE Stable' \ + --baseurl "https://download.docker.com/linux/centos/7/\$basearch/stable" \ + --enabled \ + --gpgcheck 1 \ + --gpgkey 'https://download.docker.com/linux/centos/gpg' \ + --state ${state} + require="__yum_repo/docker-ce-stable" __package docker-ce --state ${state} + else + echo "CentOS version 7 is required!" >&2 + exit 1 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" + ubuntu|debian) + if [ "${state}" = "present" ]; then + __package apt-transport-https + __package ca-certificates + __package gnupg2 fi - __package apparmor --state ${state} - __package ca-certificates --state ${state} - __package apt-transport-https --state ${state} - __apt_key docker --keyid 58118E89F3A912897C070ADBF76221572C52609D --state ${state} + __apt_key_uri docker --name "Docker Release (CE deb) " \ + --uri "https://download.docker.com/linux/${os}/gpg" --state ${state} export CDIST_ORDER_DEPENDENCY=on __apt_source docker \ - --uri https://apt.dockerproject.org/repo \ - --distribution "ubuntu-$(cat "$__global/explorer/lsb_codename")" \ + --uri "https://download.docker.com/linux/${os}" \ + --distribution "$(cat "$__global/explorer/lsb_codename")" \ --state ${state} \ - --component "$component" - __package docker-engine --state ${state} + --component "stable" + __package docker-ce --state ${state} unset CDIST_ORDER_DEPENDENCY ;; - debian) - component="main" - if [ -f "$__object/parameter/experimental" ]; then - component="experimental" - fi - - __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 --state ${state} - unset CDIST_ORDER_DEPENDENCY - - ;; *) echo "Your operating system ($os) is currently not supported by this type (${__type##*/})." >&2 echo "Please contribute an implementation for it if you can." >&2 diff --git a/cdist/conf/type/__docker/parameter/boolean b/cdist/conf/type/__docker/parameter/boolean deleted file mode 100644 index 9839eb20..00000000 --- a/cdist/conf/type/__docker/parameter/boolean +++ /dev/null @@ -1 +0,0 @@ -experimental From 19a55ac75a9c555033b8c46e5987baee52dac685 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Sun, 9 Sep 2018 19:27:39 +0200 Subject: [PATCH 0067/1217] ++changelog --- docs/changelog | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/changelog b/docs/changelog index c58e445b..6c4a69a9 100644 --- a/docs/changelog +++ b/docs/changelog @@ -1,6 +1,10 @@ Changelog --------- +next: + * New global explorer: os_release (Ľubomír Kučera) + * Type __docker: Update type, install docker CE (Ľubomír Kučera) + 4.10.2: 2018-09-06 * Type __letsencrypt_cert: Add support for devuan ascii (Darko Poljak) * Type __systemd_unit: Fix minor issues and add masking unit files support (Adam Dej) From 346f1f8af34de7a6a8fd21dc521211d31b2f33c0 Mon Sep 17 00:00:00 2001 From: Jonas Weber Date: Wed, 12 Sep 2018 11:36:06 +0200 Subject: [PATCH 0068/1217] Send messages when installing packages via __package_apt --- cdist/conf/type/__package_apt/gencode-remote | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cdist/conf/type/__package_apt/gencode-remote b/cdist/conf/type/__package_apt/gencode-remote index d9cc52b7..39584e30 100755 --- a/cdist/conf/type/__package_apt/gencode-remote +++ b/cdist/conf/type/__package_apt/gencode-remote @@ -78,9 +78,11 @@ case "$state_should" in name="${name}=${version}" fi echo $aptget install $target_release \"$name\" + echo "installed" >> "$__messages_out" ;; absent) echo $aptget remove $purgeparam \"$name\" + echo "removed" >> "$__messages_out" ;; *) echo "Unknown state: $state_should" >&2 From b3f3b907a49759db18f95ed48b7890328a755e96 Mon Sep 17 00:00:00 2001 From: Jonas Weber Date: Wed, 12 Sep 2018 11:35:23 +0200 Subject: [PATCH 0069/1217] Quote aptget command and params, simplify explorer --- cdist/conf/type/__package_apt/explorer/state | 2 +- cdist/conf/type/__package_apt/gencode-remote | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cdist/conf/type/__package_apt/explorer/state b/cdist/conf/type/__package_apt/explorer/state index 658429ac..7ccd6fce 100755 --- a/cdist/conf/type/__package_apt/explorer/state +++ b/cdist/conf/type/__package_apt/explorer/state @@ -30,7 +30,7 @@ fi # Except dpkg failing, if package is not known / installed packages="$(apt-cache showpkg "$name" | sed -e "1,/Reverse Provides:/d" | cut -d ' ' -f 1) $name" for p in $packages; do - if [ -n "$(dpkg -s "$p" 2>/dev/null | grep "^Status: install ok installed$")" ]; then + if dpkg -s "$p" 2>/dev/null | grep --quiet "^Status: install ok installed$" ; then version=$(dpkg -s "$p" 2>/dev/null | grep "^Version:" | cut -d ' ' -f 2) echo "present $p $version" exit 0 diff --git a/cdist/conf/type/__package_apt/gencode-remote b/cdist/conf/type/__package_apt/gencode-remote index 39584e30..cbe14787 100755 --- a/cdist/conf/type/__package_apt/gencode-remote +++ b/cdist/conf/type/__package_apt/gencode-remote @@ -77,11 +77,11 @@ case "$state_should" in if [ -n "$version" ]; then name="${name}=${version}" fi - echo $aptget install $target_release \"$name\" + echo "$aptget install $target_release \"$name\"" echo "installed" >> "$__messages_out" ;; absent) - echo $aptget remove $purgeparam \"$name\" + echo "$aptget remove $purgeparam \"$name\"" echo "removed" >> "$__messages_out" ;; *) From aa80e8f87deaf4348296306ae26504fe19dbdd03 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Wed, 12 Sep 2018 11:53:46 +0200 Subject: [PATCH 0070/1217] ++changelog --- docs/changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog b/docs/changelog index 6c4a69a9..682544ff 100644 --- a/docs/changelog +++ b/docs/changelog @@ -4,6 +4,7 @@ Changelog next: * New global explorer: os_release (Ľubomír Kučera) * Type __docker: Update type, install docker CE (Ľubomír Kučera) + * Type __package_apt: Write a message when a package is installed or removed; shellcheck (Jonas Weber) 4.10.2: 2018-09-06 * Type __letsencrypt_cert: Add support for devuan ascii (Darko Poljak) From d6952543a74e523a248342452cd4ecd4df81116b Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Thu, 6 Sep 2018 07:06:25 +0200 Subject: [PATCH 0071/1217] Add 'real world example' walkthrough docs chapter. --- docs/changelog | 1 + docs/src/cdist-real-world.rst | 573 ++++++++++++++++++++++++++++++++++ docs/src/index.rst | 1 + 3 files changed, 575 insertions(+) create mode 100644 docs/src/cdist-real-world.rst diff --git a/docs/changelog b/docs/changelog index 682544ff..62d44fbe 100644 --- a/docs/changelog +++ b/docs/changelog @@ -5,6 +5,7 @@ next: * New global explorer: os_release (Ľubomír Kučera) * Type __docker: Update type, install docker CE (Ľubomír Kučera) * Type __package_apt: Write a message when a package is installed or removed; shellcheck (Jonas Weber) + * Documentation: Add 'Dive into real world cdist' walkthrough chapter (Darko Poljak) 4.10.2: 2018-09-06 * Type __letsencrypt_cert: Add support for devuan ascii (Darko Poljak) diff --git a/docs/src/cdist-real-world.rst b/docs/src/cdist-real-world.rst new file mode 100644 index 00000000..8ccb0fc9 --- /dev/null +++ b/docs/src/cdist-real-world.rst @@ -0,0 +1,573 @@ +Dive into real world cdist +========================== + +Introduction +------------ + +This walkthrough shows real world cdist configuration example. + +Sample target host is named **test.ungleich.ch**. +Just replace **test.ungleich.ch** with your target hostname. + +Our goal is to configure python application hosting. For writing sample +application we will use `Bottle `_ WSGI micro web-framework. +It will use PostgreSQL database and it will list items from **items** table. +It will be served by uWSGI server. We will also use the Nginx web server +as a reverse proxy and we want HTTPS. +For HTTPS we will use Let's Encrypt certificate. + +For setting up hosting we want to use cdist so we will write a new type +for that. This type will: + +- install required packages +- create OS user, user home directory and application home directory +- create PostgreSQL database +- configure uWSGI +- configure Let's Encrypt certificate +- configure nginx. + +Our type will not create the actual python application. Its intention is only +to configure hosing for specified user and project. It is up to the user to +create his/her applications. + +So let's start. + +Creating type layout +-------------------- + +We will create a new custom type. Let's call it **__sample_bottle_hosting**. + +Go to **~/.cdist/type** directory (create it if it does not exist) and create +new type layout:: + + cd ~/.cdist/type + mkdir __sample_bottle_hosting + cd __sample_bottle_hosting + touch manifest gencode-remote + mkdir parameter + touch parameter/required + +Creating __sample_bottle_hosting type parameters +------------------------------------------------ + +Our type will be configurable through the means of parameters. Let's define +the following parameters: + +projectname + name for the project, needed for uWSGI ini file + +user + user name + +domain + target host domain, needed for Let's Encrypt certificate. + +We define parameters to make our type reusable for different projects, user and domain. + +Define required parameters:: + + printf "projectname\n" >> parameter/required + printf "user\n" >> parameter/required + printf "domain\n" >> parameter/required + +For details on type parameters see `Defining parameters `_. + +Creating __sample_bottle_hosting type manifest +---------------------------------------------- + +Next step is to define manifest (~/.cdist/type/__sample_bottle_hosting/manifest). +We also want our type to currently support only Devuan. So we will start by +checking target host OS. We will use `os `_ +global explorer:: + + os=$(cat "$__global/explorer/os") + + case "$os" in + devuan) + : + ;; + *) + echo "OS $os currently not supported" >&2 + exit 1 + ;; + esac + +If target host OS is not Devuan then we print error message to stderr +and exit. For other OS-es support we should check and change package names +we should install, because packages differ in different OS-es and in different +OS distributions like GNU/Linux distributions. There can also be a different +configuration locations (e.g. nginx config directory could be in /usr/local tree). +If we detected unsupported OS we should error out. cdist will stop configuration +process and output error message. + +Creating user and user directories +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Then we create user and his/her home directory and application home directory. +We will use existing cdist types `__user `_ and `__directory `_:: + + user="$(cat "$__object/parameter/user")" + home="/home/$user" + apphome="$home/app" + + # create user + __user "$user" --home "$home" --shell /bin/bash + # create user home dir + require="__user/$user" __directory "$home" \ + --owner "$user" --group "$user" --mode 0755 + # create app home dir + require="__user/$user __directory/$home" __directory "$apphome" \ + --state present --owner "$user" --group "$user" --mode 0755 + +First we define *user*, *home* and *apphome* variables. User is defined by type's +**user** parameter. Here we use **require** which is cdist's way to define dependencies. +User home directory should be created **after** user is created. And application +home directory is created **after** both user and user home directory are created. +For details on **require** see `Dependencies `_. + +Installing packages +~~~~~~~~~~~~~~~~~~~ + +Install required packages using existing `__package `_ type. +Before installing package we want to update apt package index using +`__apt_update_index `_:: + + # define packages that need to be installed + packages_to_install="nginx uwsgi-plugin-python3 python3-dev python3-pip postgresql postgresql-contrib libpq-dev python3-venv uwsgi python3-psycopg2" + + # update package index + __apt_update_index + # install packages + for package in $packages_to_install + do require="__apt_update_index" __package $package --state=present + done + +Here we use shell for loop. It executes **require="__apt_update_index" __package** +for each member in a list we define in **packages_to_install** variable. +This is much nicer then having as many **require="__apt_update_index" __package** +lines as there are packages we want to install. + +For python packages we use `__package_pip `_:: + + # install pip3 packages + for package in bottle bottle-pgsql; do + __package_pip --pip pip3 $package + done + +Creating PostgreSQL database +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Create PostgreSQL database using `__postgres_database `_ +and `__postgres_role `_ for creating database user:: + + #PostgreSQL db & user + postgres_server=postgresql + + # create PostgreSQL db user + require="__package/postgresql" __postgres_role $user --login --createdb + # create PostgreSQL db + require="__postgres_role/$user __package/postgresql" __postgres_database $user \ + --owner $user + +Configuring uWSGI +~~~~~~~~~~~~~~~~~ + +Configure uWSGI using `__file `_ type:: + + # configure uWSGI + projectname="$(cat "$__object/parameter/projectname")" + require="__package/uwsgi" __file /etc/uwsgi/apps-enabled/$user.ini \ + --owner root --group root --mode 0644 \ + --state present \ + --source - << EOF + [uwsgi] + socket = $apphome/uwsgi.sock + chdir = $apphome + wsgi-file = $projectname/wsgi.py + touch-reload = $projectname/wsgi.py + processes = 4 + threads = 2 + chmod-socket = 666 + daemonize=true + vacuum = true + uid = $user + gid = $user + EOF + +We require package uWSGI present in order to create **/etc/uwsgi/apps-enabled/$user.ini** file. +Installation of uWSGI also creates configuration layout: **/etc/uwsgi/apps-enabled**. +If this directory does not exist then **__file** type would error. +We also use stdin as file content source. For details see `Input from stdin `_. +For feading stdin we use here-document (**<<** operator). It allows redirection of subsequent +lines read by the shell to the input of a command until a line containing only the delimiter +and a newline, with no blank characters in between (EOF in our case). + +Configuring nginx for Let's Encrypt and HTTPS redirection +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Next configure nginx for Let's Encrypt and for HTTP -> HTTPS redirection. For this +purpose we will create new type **__sample_nginx_http_letsencrypt_and_ssl_redirect** +and use it here:: + + domain="$(cat "$__object/parameter/domain")" + webroot="/var/www/html" + __sample_nginx_http_letsencrypt_and_ssl_redirect "$domain" --webroot "$webroot" + +Configuring certificate creation +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +After HTTP nginx configuration we will create Let's Encrypt certificate using +`__letsencrypt_cert `_ type. +For Let's Encrypt cert configuration ensure that there is a DNS entry for your +domain. We assure that cert creation is applied after nginx HTTP is configured +for Let's Encrypt to work:: + + # create SSL cert + require="__package/nginx __sample_nginx_http_letsencrypt_and_ssl_redirect/$domain" \ + __letsencrypt_cert --admin-email admin@test.ungleich.ch \ + --webroot "$webroot" \ + --automatic-renewal \ + --renew-hook "service nginx reload" \ + --domain "$domain" \ + "$domain" + +Configuring nginx HTTPS server with uWSGI upstream +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Then we can configure nginx HTTPS server that will use created Let's Encrypt certificate:: + + # configure nginx + require="__package/nginx __letsencrypt_cert/$domain" \ + __file "/etc/nginx/sites-enabled/https-$domain" \ + --source - --mode 0644 << EOF + upstream _bottle { + server unix:$apphome/uwsgi.sock; + } + + server { + listen 443; + listen [::]:443; + + server_name $domain; + + access_log /var/log/nginx/access.log; + + ssl on; + ssl_certificate /etc/letsencrypt/live/$domain/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/$domain/privkey.pem; + + client_max_body_size 256m; + + location / { + try_files \$uri @uwsgi; + } + + location @uwsgi { + include uwsgi_params; + uwsgi_pass _bottle; + } + } + EOF + +Now our manifest is finished. + +Complete __sample_bottle_hosting type manifest listing +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Here is complete __sample_bottle_hosting type manifest listing, +located in ~/.cdist/type/__sample_bottle_hosting/manifest:: + + #!/bin/sh + + os=$(cat "$__global/explorer/os") + + case "$os" in + devuan) + : + ;; + *) + echo "OS $os currently not supported" >&2 + exit 1 + ;; + esac + + projectname="$(cat "$__object/parameter/projectname")" + user="$(cat "$__object/parameter/user")" + home="/home/$user" + apphome="$home/app" + domain="$(cat "$__object/parameter/domain")" + + # create user + __user "$user" --home "$home" --shell /bin/bash + # create user home dir + require="__user/$user" __directory "$home" \ + --owner "$user" --group "$user" --mode 0755 + # create app home dir + require="__user/$user __directory/$home" __directory "$apphome" \ + --state present --owner "$user" --group "$user" --mode 0755 + + # define packages that need to be installed + packages_to_install="nginx uwsgi-plugin-python3 python3-dev python3-pip postgresql postgresql-contrib libpq-dev python3-venv uwsgi python3-psycopg2" + + # update package index + __apt_update_index + # install packages + for package in $packages_to_install + do require="__apt_update_index" __package $package --state=present + done + # install pip3 packages + for package in bottle bottle-pgsql; do + __package_pip --pip pip3 $package + done + + #PostgreSQL db & user + postgres_server=postgresql + + # create PostgreSQL db user + require="__package/postgresql" __postgres_role $user --login --createdb + # create PostgreSQL db + require="__postgres_role/$user __package/postgresql" __postgres_database $user \ + --owner $user + # configure uWSGI + require="__package/uwsgi" __file /etc/uwsgi/apps-enabled/$user.ini \ + --owner root --group root --mode 0644 \ + --state present \ + --source - << EOF + [uwsgi] + socket = $apphome/uwsgi.sock + chdir = $apphome + wsgi-file = $projectname/wsgi.py + touch-reload = $projectname/wsgi.py + processes = 4 + threads = 2 + chmod-socket = 666 + daemonize=true + vacuum = true + uid = $user + gid = $user + EOF + + # setup nginx HTTP for Let's Encrypt and SSL redirect + domain="$(cat "$__object/parameter/domain")" + webroot="/var/www/html" + __sample_nginx_http_letsencrypt_and_ssl_redirect "$domain" --webroot "$webroot" + + # create SSL cert + require="__package/nginx __sample_nginx_http_letsencrypt_and_ssl_redirect/$domain" \ + __letsencrypt_cert --admin-email admin@test.ungleich.ch \ + --webroot "$webroot" \ + --automatic-renewal \ + --renew-hook "service nginx reload" \ + --domain "$domain" \ + "$domain" + + # configure nginx + require="__package/nginx __letsencrypt_cert/$domain" \ + __file "/etc/nginx/sites-enabled/https-$domain" \ + --source - --mode 0644 << EOF + upstream _bottle { + server unix:$apphome/uwsgi.sock; + } + + server { + listen 443; + listen [::]:443; + + server_name $domain; + + access_log /var/log/nginx/access.log; + + ssl on; + ssl_certificate /etc/letsencrypt/live/$domain/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/$domain/privkey.pem; + + client_max_body_size 256m; + + location / { + try_files \$uri @uwsgi; + } + + location @uwsgi { + include uwsgi_params; + uwsgi_pass _bottle; + } + } + EOF + +Creating __sample_bottle_hosting type gencode-remote +---------------------------------------------------- + +Now define **gencode-remote** script: ~/.cdist/type/__sample_bottle_hosting/gencode-remote. +After manifest is applied it should restart uWSGI and nginx services so that our +configuration is active. Our gencode-remote looks like the following:: + + echo "service uwsgi restart" + echo "service nginx restart" + +Our **__sample_bottle_hosting** type is now finished. + +Creating __sample_nginx_http_letsencrypt_and_ssl_redirect type +-------------------------------------------------------------- + +Let's now create **__sample_nginx_http_letsencrypt_and_ssl_redirect** type:: + + cd ~/.cdist/type + mkdir __sample_nginx_http_letsencrypt_and_ssl_redirect + cd __sample_nginx_http_letsencrypt_and_ssl_redirect + mkdir parameter + echo webroot > parameter/required + touch manifest + touch gencode-remote + +Edit manifest:: + + domain="$__object_id" + webroot="$(cat "$__object/parameter/webroot")" + # make sure we have nginx package + __package nginx + # setup Let's Encrypt HTTP acme challenge, redirect HTTP to HTTPS + require="__package/nginx" __file "/etc/nginx/sites-enabled/http-$domain" \ + --source - --mode 0644 << EOF + server { + listen *:80; + listen [::]:80; + + server_name $domain; + + # Let's Encrypt + location /.well-known/acme-challenge/ { + root $webroot; + } + + # Everything else -> SSL + location / { + return 301 https://\$host\$request_uri; + } + } + + EOF + +Edit gencode-remote:: + + echo "service nginx reload" + +Creating init manifest +---------------------- + +Next create init manifest:: + + cd ~/.cdist/manifest + printf "__sample_bottle_hosting --projectname sample --user app --domain \$__target_host sample\n" > sample + +Using this init manifest our target host will be configured using our **__sample_bottle_hosting** +type with projectname *sample*, user *app* and domain equal to **__target_host**. +Here the last positional argument *sample* is type's object id. For details on +**__target_host** and **__object_id** see +`Environment variables (for reading) `_ +reference. + +Configuring host +---------------- + +Finally configure test.ungleich.ch:: + + cdist config -v -i ~/.cdist/manifest/sample test.ungleich.ch + +After cdist configuration is successfully finished our host is ready. + +Creating python bottle application +---------------------------------- + +We now need to create Bottle application. As you remember from the beginning +of this walkthrough our type does not create the actual python application, +its intention is only to configure hosing for specified user and project. +It is up to the user to create his/her applications. + +Become app user:: + + su -l app + +Preparing database +~~~~~~~~~~~~~~~~~~ + +We need to prepare database for our application. Create table and +insert some items:: + + psql -c "create table items (item varchar(255));" + + psql -c "insert into items(item) values('spam');" + psql -c "insert into items(item) values('eggs');" + psql -c "insert into items(item) values('sausage');" + +Creating application +~~~~~~~~~~~~~~~~~~~~ + +Next create sample app:: + + cd /home/app/app + mkdir sample + cd sample + +Create app.py with the following content:: + + #!/usr/bin/env python3 + + import bottle + import bottle_pgsql + + app = application = bottle.Bottle() + plugin = bottle_pgsql.Plugin('dbname=app user=app password=') + app.install(plugin) + + @app.route('/') + def show_index(db): + db.execute('select * from items') + items = db.fetchall() or [] + rv = '

Items:

    ' + for item in items: + rv += '
  • ' + str(item['item']) + '
  • ' + rv += '
' + return rv + + if __name__ == '__main__': + bottle.run(app=app, host='0.0.0.0', port=8080) + +Create wsgi.py with the following content:: + + import os + + os.chdir(os.path.dirname(__file__)) + + import app + application = app.app + +We have configured uWSGI with **touch-reload = $projectname/wsgi.py** so after +we have changed our **wsgi.py** file uWSGI reloads the application. + +Our application selects and lists items from **items** table. + +Openning application +~~~~~~~~~~~~~~~~~~~~ + +Finally try the application:: + + http://test.ungleich.ch/ + +It should redirect to HTTPS and return: + +.. container:: highlight + + .. raw:: html + +

Items:

+ +
    +
  • spam
  • +
  • eggs
  • +
  • sausage
  • +
+ +What's next? +------------ + +Continue reading next sections ;) diff --git a/docs/src/index.rst b/docs/src/index.rst index 5d0bb537..bef91e1c 100644 --- a/docs/src/index.rst +++ b/docs/src/index.rst @@ -16,6 +16,7 @@ Contents: cdist-support cdist-features cdist-quickstart + cdist-real-world man1/cdist cdist-bootstrap cdist-configuration From f918acd725f911aa71afc14af5bf38d9c44fa6cc Mon Sep 17 00:00:00 2001 From: dhivael Date: Fri, 21 Sep 2018 22:54:37 +0200 Subject: [PATCH 0072/1217] don't duplicate Remote::mkdir in explorer transfer Remote::transfer contains a call to mkdir(destination) if the source is a directory. since the destination must also be a directory we can omit extra mkdir calls in Explorer. this saves about 10% on my manifests in sequential mode, and about 6% in parallel mode. --- cdist/core/explorer.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/cdist/core/explorer.py b/cdist/core/explorer.py index 8c18a19f..a42b0117 100644 --- a/cdist/core/explorer.py +++ b/cdist/core/explorer.py @@ -147,7 +147,6 @@ class Explorer(object): def transfer_global_explorers(self): """Transfer the global explorers to the remote side.""" - self.remote.mkdir(self.remote.global_explorer_path) self.remote.transfer(self.local.global_explorer_path, self.remote.global_explorer_path, self.jobs) @@ -223,7 +222,6 @@ class Explorer(object): cdist_type.explorer_path) destination = os.path.join(self.remote.type_path, cdist_type.explorer_path) - self.remote.mkdir(destination) self.remote.transfer(source, destination) self.remote.run(["chmod", "0700", "%s/*" % (destination)]) self._type_explorers_transferred.append(cdist_type.name) @@ -235,5 +233,4 @@ class Explorer(object): cdist_object.parameter_path) destination = os.path.join(self.remote.object_path, cdist_object.parameter_path) - self.remote.mkdir(destination) self.remote.transfer(source, destination) From c021cd15cdac8d7a474107531df71dd211c1c6d4 Mon Sep 17 00:00:00 2001 From: dhivael Date: Fri, 21 Sep 2018 23:17:41 +0200 Subject: [PATCH 0073/1217] transfer all files of a directory at once instead of calling the copy command once per file in a directory (eg a type explorer dir), call the copy command only once with all files of the directory. batch copy saves 20% of dry-run time on my test manifest in sequential mode, and 15% in parallel mode. --- cdist/exec/remote.py | 40 +++++++--------------------------------- 1 file changed, 7 insertions(+), 33 deletions(-) diff --git a/cdist/exec/remote.py b/cdist/exec/remote.py index 4466545e..ffb3ee00 100644 --- a/cdist/exec/remote.py +++ b/cdist/exec/remote.py @@ -203,46 +203,20 @@ class Remote(object): os.remove(tarpath) used_archiving = True if not used_archiving: - if jobs: - self._transfer_dir_parallel(source, destination, jobs) - else: - self._transfer_dir_sequential(source, destination) + self._transfer_dir(source, destination) elif jobs: raise cdist.Error("Source {} is not a directory".format(source)) else: self._transfer_file(source, destination) - def _transfer_dir_commands(self, source, destination): + def _transfer_dir(self, source, destination): + command = self._copy.split() for f in glob.glob1(source, '*'): - command = self._copy.split() path = os.path.join(source, f) - command.extend([path, '{0}:{1}'.format( - _wrap_addr(self.target_host[0]), destination)]) - yield command - - def _transfer_dir_sequential(self, source, destination): - for command in self._transfer_dir_commands(source, destination): - self._run_command(command) - - def _transfer_dir_parallel(self, source, destination, jobs): - """Transfer a directory to the remote side in parallel mode.""" - self.log.debug("Remote transfer in {} parallel jobs".format( - jobs)) - self.log.trace("Multiprocessing start method is {}".format( - multiprocessing.get_start_method())) - self.log.trace(("Starting multiprocessing Pool for parallel " - "remote transfer")) - args = [ - (command, ) - for command in self._transfer_dir_commands(source, destination) - ] - if len(args) == 1: - self.log.debug("Only one dir entry, transfering sequentially") - self._run_command(args[0]) - else: - mp_pool_run(self._run_command, args, jobs=jobs) - self.log.trace(("Multiprocessing for parallel transfer " - "finished")) + command.extend([path]) + command.extend(['{0}:{1}'.format( + _wrap_addr(self.target_host[0]), destination)]) + self._run_command(command) def run_script(self, script, env=None, return_output=False, stdout=None, stderr=None): From 1f703ab42ef4a1bc1730577c213cef5f980e921d Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Sat, 22 Sep 2018 20:52:43 +0200 Subject: [PATCH 0074/1217] ++changelog --- docs/changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog b/docs/changelog index 62d44fbe..d25c4462 100644 --- a/docs/changelog +++ b/docs/changelog @@ -6,6 +6,7 @@ next: * Type __docker: Update type, install docker CE (Ľubomír Kučera) * Type __package_apt: Write a message when a package is installed or removed; shellcheck (Jonas Weber) * Documentation: Add 'Dive into real world cdist' walkthrough chapter (Darko Poljak) + * Core: Remove duplicate remote mkdir calls in explorer transfer (myeisha) 4.10.2: 2018-09-06 * Type __letsencrypt_cert: Add support for devuan ascii (Darko Poljak) From 02982ca8bee500a0d0cdf1975074953278f4109e Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Sun, 23 Sep 2018 12:04:57 +0200 Subject: [PATCH 0075/1217] Release 4.10.3 --- docs/changelog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/changelog b/docs/changelog index d25c4462..8c310a22 100644 --- a/docs/changelog +++ b/docs/changelog @@ -1,7 +1,7 @@ Changelog --------- -next: +4.10.3: 2018-09-23 * New global explorer: os_release (Ľubomír Kučera) * Type __docker: Update type, install docker CE (Ľubomír Kučera) * Type __package_apt: Write a message when a package is installed or removed; shellcheck (Jonas Weber) From 6acf6f64dcf6a5768be6f2874a719b16b5ba6a4f Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Sun, 23 Sep 2018 20:34:42 +0200 Subject: [PATCH 0076/1217] Add timestamp to log messages. --- cdist/argparse.py | 5 +++++ cdist/config.py | 8 +++++++- cdist/log.py | 28 ++++++++++++++++++++++++++++ docs/src/man1/cdist.rst | 10 ++++++++-- 4 files changed, 48 insertions(+), 3 deletions(-) diff --git a/cdist/argparse.py b/cdist/argparse.py index 29620751..0ee9d7b1 100644 --- a/cdist/argparse.py +++ b/cdist/argparse.py @@ -251,6 +251,11 @@ def get_parsers(): 'line). If no host or host file is specified then, by ' 'default, read hosts from stdin.'), dest='hostfile', required=False) + parser['config_args'].add_argument( + '-P', '--timestamp', + help=('Timestamp log messages with the current local date and time ' + 'in the format: YYYYMMDDHHMMSS.us.'), + action='store_true', dest='timestamp') parser['config_args'].add_argument( '-p', '--parallel', nargs='?', metavar='HOST_MAX', type=functools.partial(check_lower_bounded_int, lower_bound=1, diff --git a/cdist/config.py b/cdist/config.py index 2dcb1005..bfb89419 100644 --- a/cdist/config.py +++ b/cdist/config.py @@ -175,7 +175,13 @@ class Config(object): if args.parallel or args.jobs: # If parallel execution then also log process id - cdist.log.setupParallelLogging() + if args.timestamp: + cdist.log.setupTimestampingParallelLogging() + else: + cdist.log.setupParallelLogging() + log = logging.getLogger("cdist") + elif args.timestamp: + cdist.log.setupTimestampingLogging() log = logging.getLogger("cdist") if args.parallel: diff --git a/cdist/log.py b/cdist/log.py index dba1ad2f..5d431130 100644 --- a/cdist/log.py +++ b/cdist/log.py @@ -22,6 +22,7 @@ import logging import sys +import datetime # Define additional cdist logging levels. @@ -95,15 +96,42 @@ class DefaultLog(logging.Logger): self.log(logging.TRACE, msg, *args, **kwargs) +class TimestampingLog(DefaultLog): + + def filter(self, record): + """Add timestamp to messages""" + + super().filter(record) + now = datetime.datetime.now() + timestamp = now.strftime("%Y%m%d%H%M%S.%f") + record.msg = "[" + timestamp + "] " + str(record.msg) + + return True + + class ParallelLog(DefaultLog): FORMAT = '%(levelname)s: [%(process)d]: %(message)s' +class TimestampingParallelLog(TimestampingLog, ParallelLog): + pass + + def setupDefaultLogging(): del logging.getLogger().handlers[:] logging.setLoggerClass(DefaultLog) +def setupTimestampingLogging(): + del logging.getLogger().handlers[:] + logging.setLoggerClass(TimestampingLog) + + +def setupTimestampingParallelLogging(): + del logging.getLogger().handlers[:] + logging.setLoggerClass(TimestampingParallelLog) + + def setupParallelLogging(): del logging.getLogger().handlers[:] logging.setLoggerClass(ParallelLog) diff --git a/docs/src/man1/cdist.rst b/docs/src/man1/cdist.rst index 79683883..0a628660 100644 --- a/docs/src/man1/cdist.rst +++ b/docs/src/man1/cdist.rst @@ -20,7 +20,8 @@ SYNOPSIS [-j [JOBS]] [-n] [-o OUT_PATH] [-R [{tar,tgz,tbz2,txz}]] [-r REMOTE_OUT_DIR] [--remote-copy REMOTE_COPY] [--remote-exec REMOTE_EXEC] [-I INVENTORY_DIR] [-4] [-6] - [-A] [-a] [-f HOSTFILE] [-p [HOST_MAX]] [-S] [-s] [-t] + [-A] [-a] [-f HOSTFILE] [-P] [-p [HOST_MAX]] [-S] [-s] + [-t] [host [host ...]] cdist install [-h] [-l LOGLEVEL] [-q] [-v] [-b] [-g CONFIG_FILE] @@ -28,7 +29,8 @@ SYNOPSIS [-j [JOBS]] [-n] [-o OUT_PATH] [-R [{tar,tgz,tbz2,txz}]] [-r REMOTE_OUT_DIR] [--remote-copy REMOTE_COPY] [--remote-exec REMOTE_EXEC] [-I INVENTORY_DIR] [-4] [-6] - [-A] [-a] [-f HOSTFILE] [-p [HOST_MAX]] [-S] [-s] [-t] + [-A] [-a] [-f HOSTFILE] [-P] [-p [HOST_MAX]] [-S] [-s] + [-t] [host [host ...]] cdist inventory [-h] {add-host,add-tag,del-host,del-tag,list} ... @@ -171,6 +173,10 @@ Install command is currently in beta. **-o OUT_PATH, --out-dir OUT_PATH** Directory to save cdist output in. +**-P, --timestamp** + Timestamp log messages with the current local date and time + in the format: YYYYMMDDHHMMSS.us. + **-p [HOST_MAX], --parallel [HOST_MAX]** Operate on multiple hosts in parallel for specified maximum hosts at a time. Without argument CPU count is From 0c57b3083ec4f43ff6fc56345a3007cfbd4dc3f6 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Sun, 23 Sep 2018 21:38:03 +0200 Subject: [PATCH 0077/1217] Fix getting loggers. --- cdist/config.py | 21 ++++++++------------- cdist/core/cdist_type.py | 2 +- scripts/cdist | 3 +-- 3 files changed, 10 insertions(+), 16 deletions(-) diff --git a/cdist/config.py b/cdist/config.py index bfb89419..e8fd5384 100644 --- a/cdist/config.py +++ b/cdist/config.py @@ -165,25 +165,20 @@ class Config(object): def commandline(cls, args): """Configure remote system""" - # FIXME: Refactor relict - remove later - log = logging.getLogger("cdist") + if (args.parallel and args.parallel != 1) or args.jobs: + if args.timestamp: + cdist.log.setupTimestampingParallelLogging() + else: + cdist.log.setupParallelLogging() + elif args.timestamp: + cdist.log.setupTimestampingLogging() + log = logging.getLogger("config") # No new child process if only one host at a time. if args.parallel == 1: log.debug("Only 1 parallel process, doing it sequentially") args.parallel = 0 - if args.parallel or args.jobs: - # If parallel execution then also log process id - if args.timestamp: - cdist.log.setupTimestampingParallelLogging() - else: - cdist.log.setupParallelLogging() - log = logging.getLogger("cdist") - elif args.timestamp: - cdist.log.setupTimestampingLogging() - log = logging.getLogger("cdist") - if args.parallel: import signal diff --git a/cdist/core/cdist_type.py b/cdist/core/cdist_type.py index 40194f94..99e40e70 100644 --- a/cdist/core/cdist_type.py +++ b/cdist/core/cdist_type.py @@ -47,7 +47,7 @@ class CdistType(object): """ - log = logging.getLogger("cdist") + log = logging.getLogger("cdist-type") def __init__(self, base_path, name): self.base_path = base_path diff --git a/scripts/cdist b/scripts/cdist index 088e4dc2..3110e657 100755 --- a/scripts/cdist +++ b/scripts/cdist @@ -69,8 +69,6 @@ if __name__ == "__main__": import re import os - log = logging.getLogger("cdist") - if re.match("__", os.path.basename(sys.argv[0])): import cdist.emulator emulator = cdist.emulator.Emulator(sys.argv) @@ -82,6 +80,7 @@ if __name__ == "__main__": exit_code = 2 except cdist.Error as e: + log = logging.getLogger("cdist") log.error(e) exit_code = 1 From c04325fdc5e2fb96aa7d3fbb26a06f13ec7e75ce Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Sun, 23 Sep 2018 22:26:16 +0200 Subject: [PATCH 0078/1217] ++changelog --- docs/changelog | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/changelog b/docs/changelog index 8c310a22..6d2ef147 100644 --- a/docs/changelog +++ b/docs/changelog @@ -1,6 +1,9 @@ Changelog --------- +next: + * Core: Transfer all files of a directory at once instead of calling copy once per file (myeisha) + 4.10.3: 2018-09-23 * New global explorer: os_release (Ľubomír Kučera) * Type __docker: Update type, install docker CE (Ľubomír Kučera) From e404ff4836f91956d7367363bf6217d3af623b3d Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Wed, 26 Sep 2018 20:35:32 +0200 Subject: [PATCH 0079/1217] ++changelog --- docs/changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog b/docs/changelog index 6d2ef147..8fd2ea49 100644 --- a/docs/changelog +++ b/docs/changelog @@ -3,6 +3,7 @@ Changelog next: * Core: Transfer all files of a directory at once instead of calling copy once per file (myeisha) + * Core: Add timestamp (optional) to log messages (Darko Poljak) 4.10.3: 2018-09-23 * New global explorer: os_release (Ľubomír Kučera) From 82077aff251c9d13e1aac4608ba7bf0a58ea5712 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Thu, 27 Sep 2018 18:55:33 +0200 Subject: [PATCH 0080/1217] Add timestamping log option to config file. --- cdist/configuration.py | 2 + cdist/test/configuration/__init__.py | 112 +++++++++++++++++++++++++++ docs/src/cdist-configuration.rst | 4 + docs/src/man1/cdist.rst | 4 + 4 files changed, 122 insertions(+) diff --git a/cdist/configuration.py b/cdist/configuration.py index 8df43f9f..f05a5963 100644 --- a/cdist/configuration.py +++ b/cdist/configuration.py @@ -261,6 +261,7 @@ _ARG_OPTION_MAPPING = { 'verbose': 'verbosity', 'use_archiving': 'archiving', 'save_output_streams': 'save_output_streams', + 'timestamp': 'timestamp', } @@ -304,6 +305,7 @@ class Configuration(metaclass=Singleton): 'archiving': ArchivingOption(), 'save_output_streams': BooleanOption('save_output_streams', default_overrides=False), + 'timestamp': BooleanOption('timestamp'), }, } diff --git a/cdist/test/configuration/__init__.py b/cdist/test/configuration/__init__.py index 3319d320..182868a6 100644 --- a/cdist/test/configuration/__init__.py +++ b/cdist/test/configuration/__init__.py @@ -1296,6 +1296,118 @@ class ConfigurationTestCase(test.CdistTestCase): self.fail("Exception should not have been raised: {}".format( e)) + def test_configuration_timestamping_log_1(self): + config = newConfigParser() + config['GLOBAL'] = { + 'timestamp': 'True', + } + + global_config_file = os.path.join(fixtures, 'cdist-global.cfg') + with open(global_config_file, 'w') as f: + config.write(f) + + expected_config_dict = { + 'GLOBAL': { + 'timestamp': True, + 'verbosity': 0, + }, + } + + config_files = (global_config_file, ) + + # bypass singleton so we can test further + cc.Configuration.instance = None + + args = argparse.Namespace() + args.timestamp = True + configuration = cc.Configuration(args, env=None, + config_files=config_files) + self.assertEqual(configuration.config, expected_config_dict) + + def test_configuration_timestamping_log_2(self): + config = newConfigParser() + config['GLOBAL'] = { + 'timestamp': 'False', + } + + global_config_file = os.path.join(fixtures, 'cdist-global.cfg') + with open(global_config_file, 'w') as f: + config.write(f) + + expected_config_dict = { + 'GLOBAL': { + 'timestamp': True, + 'verbosity': 0, + }, + } + + config_files = (global_config_file, ) + + # bypass singleton so we can test further + cc.Configuration.instance = None + + args = argparse.Namespace() + args.timestamp = True + configuration = cc.Configuration(args, env=None, + config_files=config_files) + self.assertEqual(configuration.config, expected_config_dict) + + def test_configuration_timestamping_log_3(self): + config = newConfigParser() + config['GLOBAL'] = { + 'timestamp': 'False', + } + + global_config_file = os.path.join(fixtures, 'cdist-global.cfg') + with open(global_config_file, 'w') as f: + config.write(f) + + expected_config_dict = { + 'GLOBAL': { + 'timestamp': False, + 'verbosity': 0, + }, + } + + config_files = (global_config_file, ) + + # bypass singleton so we can test further + cc.Configuration.instance = None + + args = argparse.Namespace() + args.timestamp = False + configuration = cc.Configuration(args, env=None, + config_files=config_files) + self.assertEqual(configuration.config, expected_config_dict) + + def test_configuration_timestamping_log_4(self): + config = newConfigParser() + config['GLOBAL'] = { + 'timestamp': 'True', + } + + global_config_file = os.path.join(fixtures, 'cdist-global.cfg') + with open(global_config_file, 'w') as f: + config.write(f) + + expected_config_dict = { + 'GLOBAL': { + 'timestamp': False, + 'verbosity': 0, + }, + } + + config_files = (global_config_file, ) + + # bypass singleton so we can test further + cc.Configuration.instance = None + + args = argparse.Namespace() + args.timestamp = False + configuration = cc.Configuration(args, env=None, + config_files=config_files) + self.assertEqual(configuration.config, expected_config_dict) + if __name__ == "__main__": import unittest diff --git a/docs/src/cdist-configuration.rst b/docs/src/cdist-configuration.rst index cf1e373b..4c9b4d33 100644 --- a/docs/src/cdist-configuration.rst +++ b/docs/src/cdist-configuration.rst @@ -94,6 +94,10 @@ The possible keywords and their meanings are as follows: It recognizes boolean values from 'yes'/'no', 'on'/'off', 'true'/'false' and '1'/'0'. +:strong:`timestamp` + Timestamp log messages with the current local date and time + in the format: YYYYMMDDHHMMSS.us. + :strong:`verbosity` Set verbosity level. Valid values are: 'ERROR', 'WARNING', 'INFO', 'VERBOSE', 'DEBUG', 'TRACE' and 'OFF'. diff --git a/docs/src/man1/cdist.rst b/docs/src/man1/cdist.rst index 0a628660..3a74f1ef 100644 --- a/docs/src/man1/cdist.rst +++ b/docs/src/man1/cdist.rst @@ -521,6 +521,10 @@ The possible keywords and their meanings are as follows: It recognizes boolean values from 'yes'/'no', 'on'/'off', 'true'/'false' and '1'/'0'. +:strong:`timestamp` + Timestamp log messages with the current local date and time + in the format: YYYYMMDDHHMMSS.us. + :strong:`verbosity` Set verbosity level. Valid values are: 'ERROR', 'WARNING', 'INFO', 'VERBOSE', 'DEBUG', 'TRACE' and 'OFF'. From 9cb9771e3347a7ab5830021822c04121130bfb29 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Sat, 29 Sep 2018 11:15:20 +0200 Subject: [PATCH 0081/1217] Exclude man7 empty directory from archive. --- .gitattributes | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitattributes b/.gitattributes index 76eac516..aeaab8b9 100644 --- a/.gitattributes +++ b/.gitattributes @@ -3,3 +3,4 @@ .gitkeep export-ignore docs/speeches export-ignore docs/video export-ignore +docs/src/man7 export-ignore From e551348cd74be0c6506af183fa242021567b2849 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Sat, 29 Sep 2018 11:15:48 +0200 Subject: [PATCH 0082/1217] Create man7 directory if needed. --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index d727bccc..3a1819be 100644 --- a/Makefile +++ b/Makefile @@ -54,6 +54,7 @@ MANTYPES=$(subst /man.rst,.rst,$(MANTYPEPREFIX)) # Link manpage: do not create man.html but correct named file $(MAN7DSTDIR)/cdist-type%.rst: $(TYPEDIR)/%/man.rst + mkdir -p $(MAN7DSTDIR) ln -sf "../../../$^" $@ # Manpages #2: reference From 6326eae1bb724a2ecb8eb45099472f93c9852cbf Mon Sep 17 00:00:00 2001 From: Jonas Weber Date: Mon, 1 Oct 2018 22:13:24 +0200 Subject: [PATCH 0083/1217] Fix SC2166 on all manfest/gencode/explorers --- cdist/conf/type/__ccollect_source/gencode-remote | 2 +- cdist/conf/type/__consul_agent/manifest | 2 +- cdist/conf/type/__consul_check/manifest | 2 +- cdist/conf/type/__consul_service/manifest | 6 +++--- cdist/conf/type/__consul_template_template/manifest | 4 ++-- cdist/conf/type/__consul_watch_checks/manifest | 2 +- cdist/conf/type/__file/gencode-local | 6 +++--- cdist/conf/type/__file/gencode-remote | 2 +- cdist/conf/type/__git/gencode-remote | 12 ++++++------ cdist/conf/type/__hostname/gencode-remote | 4 ++-- .../__install_partition_msdos_apply/gencode-remote | 2 +- cdist/conf/type/__jail_freebsd10/gencode-remote | 4 ++-- cdist/conf/type/__jail_freebsd9/gencode-remote | 4 ++-- cdist/conf/type/__key_value/manifest | 2 +- cdist/conf/type/__line/gencode-remote | 2 +- cdist/conf/type/__link/gencode-remote | 2 +- cdist/conf/type/__package/manifest | 2 +- cdist/conf/type/__package_emerge/gencode-remote | 4 ++-- cdist/conf/type/__package_pkg_freebsd/gencode-remote | 2 +- cdist/conf/type/__package_pkg_openbsd/gencode-remote | 2 +- .../conf/type/__package_update_index/gencode-remote | 2 +- cdist/conf/type/__pyvenv/gencode-remote | 12 ++++++------ cdist/conf/type/__ssh_authorized_keys/manifest | 2 +- 23 files changed, 42 insertions(+), 42 deletions(-) diff --git a/cdist/conf/type/__ccollect_source/gencode-remote b/cdist/conf/type/__ccollect_source/gencode-remote index 56003fef..763f219e 100755 --- a/cdist/conf/type/__ccollect_source/gencode-remote +++ b/cdist/conf/type/__ccollect_source/gencode-remote @@ -71,7 +71,7 @@ case "$state_should" in fi value_is="$(get_current_value "$attribute" "$value_should")" - if [ -f "$__object/files/set-attributes" -o "$value_should" != "$value_is" ]; then + if [ -f "$__object/files/set-attributes" ] || [ "$value_should" != "$value_is" ]; then "set_$attribute" "$value_should" fi fi diff --git a/cdist/conf/type/__consul_agent/manifest b/cdist/conf/type/__consul_agent/manifest index 820018c9..a696894b 100755 --- a/cdist/conf/type/__consul_agent/manifest +++ b/cdist/conf/type/__consul_agent/manifest @@ -66,7 +66,7 @@ require="__directory/etc/consul" \ __directory "$conf_dir" \ --owner root --group "$group" --mode 750 --state "$state" -if [ -f "$__object/parameter/ca-file-source" -o -f "$__object/parameter/cert-file-source" -o -f "$__object/parameter/key-file-source" ]; then +if [ -f "$__object/parameter/ca-file-source" ] || [ -f "$__object/parameter/cert-file-source" ] || [ -f "$__object/parameter/key-file-source" ]; then # create directory for ssl certs require="__directory/etc/consul" \ __directory /etc/consul/ssl \ diff --git a/cdist/conf/type/__consul_check/manifest b/cdist/conf/type/__consul_check/manifest index 8149b130..554c0680 100755 --- a/cdist/conf/type/__consul_check/manifest +++ b/cdist/conf/type/__consul_check/manifest @@ -40,7 +40,7 @@ if [ ! -f "$__object/parameter/interval" ]; then fi done fi -if [ -f "$__object/parameter/docker-container-id" -a ! -f "$__object/parameter/script" ]; then +if [ -f "$__object/parameter/docker-container-id" ] && [ ! -f "$__object/parameter/script" ]; then echo "When using --docker-container-id you must also define --script." >&2 exit 1 fi diff --git a/cdist/conf/type/__consul_service/manifest b/cdist/conf/type/__consul_service/manifest index d7a1b6e3..f6d29b4a 100755 --- a/cdist/conf/type/__consul_service/manifest +++ b/cdist/conf/type/__consul_service/manifest @@ -24,15 +24,15 @@ conf_file="service_${name}.json" state="$(cat "$__object/parameter/state")" # Sanity checks -if [ -f "$__object/parameter/check-script" -a -f "$__object/parameter/check-ttl" ]; then +if [ -f "$__object/parameter/check-script" ] && [ -f "$__object/parameter/check-ttl" ]; then echo "Use either --check-script together with --check-interval OR --check-ttl, but not both" >&2 exit 1 fi -if [ -f "$__object/parameter/check-script" -a ! -f "$__object/parameter/check-interval" ]; then +if [ -f "$__object/parameter/check-script" ] && [ ! -f "$__object/parameter/check-interval" ]; then 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 +if [ -f "$__object/parameter/check-http" ] && [ ! -f "$__object/parameter/check-interval" ]; then echo "When using --check-http you must also define --check-interval" >&2 exit 1 fi diff --git a/cdist/conf/type/__consul_template_template/manifest b/cdist/conf/type/__consul_template_template/manifest index 5fe657d0..488a0f5d 100755 --- a/cdist/conf/type/__consul_template_template/manifest +++ b/cdist/conf/type/__consul_template_template/manifest @@ -26,11 +26,11 @@ template_dir="/etc/consul-template/template" require="" # Sanity checks -if [ -f "$__object/parameter/source" -a -f "$__object/parameter/source-file" ]; then +if [ -f "$__object/parameter/source" ] && [ -f "$__object/parameter/source-file" ]; then echo "Use either --source OR --source-file, but not both." >&2 exit 1 fi -if [ ! -f "$__object/parameter/source" -a ! -f "$__object/parameter/source-file" ]; then +if [ ! -f "$__object/parameter/source" ] && [ ! -f "$__object/parameter/source-file" ]; then echo "Either --source OR --source-file must be given." >&2 exit 1 fi diff --git a/cdist/conf/type/__consul_watch_checks/manifest b/cdist/conf/type/__consul_watch_checks/manifest index ebb49e2e..146f609e 100755 --- a/cdist/conf/type/__consul_watch_checks/manifest +++ b/cdist/conf/type/__consul_watch_checks/manifest @@ -25,7 +25,7 @@ conf_file="watch_${watch_type}_${__object_id}.json" state="$(cat "$__object/parameter/state")" # Sanity checks -if [ -f "$__object/parameter/filter-service" -a -f "$__object/parameter/filter-state" ]; then +if [ -f "$__object/parameter/filter-service" ] && [ -f "$__object/parameter/filter-state" ]; then echo "Use either --filter-service or --filter-state but not both." >&2 exit 1 fi diff --git a/cdist/conf/type/__file/gencode-local b/cdist/conf/type/__file/gencode-local index 15a9ee0e..3f60b4b3 100755 --- a/cdist/conf/type/__file/gencode-local +++ b/cdist/conf/type/__file/gencode-local @@ -23,7 +23,7 @@ destination="/$__object_id" state_should="$(cat "$__object/parameter/state")" type="$(cat "$__object/explorer/type")" -[ "$state_should" = "exists" -a "$type" = "file" ] && exit 0 # nothing to do +[ "$state_should" = "exists" ] && [ "$type" = "file" ] && exit 0 # nothing to do if [ "$state_should" = "pre-exists" ]; then if [ -f "$__object/parameter/source" ]; then @@ -41,7 +41,7 @@ fi upload_file= create_file= -if [ "$state_should" = "present" -o "$state_should" = "exists" ]; then +if [ "$state_should" = "present" ] || [ "$state_should" = "exists" ]; then if [ ! -f "$__object/parameter/source" ]; then remote_stat="$(cat "$__object/explorer/stat")" if [ -z "$remote_stat" ]; then @@ -70,7 +70,7 @@ if [ "$state_should" = "present" -o "$state_should" = "exists" ]; then fi fi fi - if [ "$create_file" -o "$upload_file" ]; then + if [ "$create_file" ] || [ "$upload_file" ]; then # tell gencode-remote that we created or uploaded a file and that it must # set all attributes no matter what the explorer retreived mkdir "$__object/files" diff --git a/cdist/conf/type/__file/gencode-remote b/cdist/conf/type/__file/gencode-remote index c90be0be..9dfd1833 100755 --- a/cdist/conf/type/__file/gencode-remote +++ b/cdist/conf/type/__file/gencode-remote @@ -72,7 +72,7 @@ case "$state_should" in fi value_is="$(get_current_value "$attribute" "$value_should")" - if [ -f "$__object/files/set-attributes" -o "$value_should" != "$value_is" ]; then + if [ -f "$__object/files/set-attributes" ] || [ "$value_should" != "$value_is" ]; then "set_$attribute" "$value_should" fi fi diff --git a/cdist/conf/type/__git/gencode-remote b/cdist/conf/type/__git/gencode-remote index d0d0d4ed..5a9e23fc 100755 --- a/cdist/conf/type/__git/gencode-remote +++ b/cdist/conf/type/__git/gencode-remote @@ -35,10 +35,10 @@ owner="$(cat "$__object/parameter/owner")" group="$(cat "$__object/parameter/group")" mode="$(cat "$__object/parameter/mode")" -[ "$state_should" = "$state_is" -a \ - "$owner" = "$owner_is" -a \ - "$group" = "$group_is" -a \ - -n "$mode" ] && exit 0 +[ "$state_should" = "$state_is" ] && \ +[ "$owner" = "$owner_is" ] && \ +[ "$group" = "$group_is" ] && \ +[ -n "$mode" ] && exit 0 case $state_should in present) @@ -46,8 +46,8 @@ case $state_should in if [ "$state_should" != "$state_is" ]; then echo git clone --quiet --branch "$branch" "$source" "$destination" fi - if [ \( -n "$owner" -a "$owner_is" != "$owner" \) -o \ - \( -n "$group" -a "$group_is" != "$group" \) ]; then + if { [ -n "$owner" ] && [ "$owner_is" != "$owner" ]; } || \ + { [ -n "$group" ] && [ "$group_is" != "$group" ]; }; then echo chown -R "${owner}:${group}" "$destination" fi if [ -n "$mode" ]; then diff --git a/cdist/conf/type/__hostname/gencode-remote b/cdist/conf/type/__hostname/gencode-remote index 89bf7b3f..3f784188 100755 --- a/cdist/conf/type/__hostname/gencode-remote +++ b/cdist/conf/type/__hostname/gencode-remote @@ -36,12 +36,12 @@ has_hostnamectl=$(cat "$__object/explorer/has_hostnamectl") # case "$os" in archlinux|debian|suse|ubuntu|devuan|coreos) - if [ "$name_config" = "$name_should" -a "$name_running" = "$name_should" ]; then + if [ "$name_config" = "$name_should" ] && [ "$name_running" = "$name_should" ]; then exit 0 fi ;; scientific|centos|freebsd|openbsd) - if [ "$name_sysconfig" = "$name_should" -a "$name_running" = "$name_should" ]; then + if [ "$name_sysconfig" = "$name_should" ] && [ "$name_running" = "$name_should" ]; then exit 0 fi ;; diff --git a/cdist/conf/type/__install_partition_msdos_apply/gencode-remote b/cdist/conf/type/__install_partition_msdos_apply/gencode-remote index 090a5d86..bed40ffa 100755 --- a/cdist/conf/type/__install_partition_msdos_apply/gencode-remote +++ b/cdist/conf/type/__install_partition_msdos_apply/gencode-remote @@ -127,7 +127,7 @@ for object in $objects; do if [ "${minor}" -lt "5" ]; then # Primary partitions available_device_size=$available_size - if [ "$type" = "extended" -o "$type" = "5" ]; then + if [ "$type" = "extended" ] || [ "$type" = "5" ]; then # Extended partition available_extended_size=$partition_size fi diff --git a/cdist/conf/type/__jail_freebsd10/gencode-remote b/cdist/conf/type/__jail_freebsd10/gencode-remote index 76241e0e..d8bc5eb7 100755 --- a/cdist/conf/type/__jail_freebsd10/gencode-remote +++ b/cdist/conf/type/__jail_freebsd10/gencode-remote @@ -36,7 +36,7 @@ state="$(cat "$__object/parameter/state")" started="true" # If the user wants the jail gone, it implies it shouldn't be started. -[ -f "$__object/parameter/stopped" -o "$state" = "absent" ] && started="false" +{ [ -f "$__object/parameter/stopped" ] || [ "$state" = "absent" ]; } && started="false" if [ -f "$__object/parameter/ip" ]; then ip="$(cat "$__object/parameter/ip")" @@ -66,7 +66,7 @@ devfsruleset="$(cat "$__object/parameter/devfs-ruleset")" # devfs_ruleset being defined without devfs_enable being true # is pointless. Treat this as an error. -if [ -n "$devfsruleset" -a "$devfsenable" = "false" ]; then +if [ -n "$devfsruleset" ] && [ "$devfsenable" = "false" ]; then exec >&2 echo "Can't have --devfs-ruleset defined with --devfs-disable" exit 1 diff --git a/cdist/conf/type/__jail_freebsd9/gencode-remote b/cdist/conf/type/__jail_freebsd9/gencode-remote index 63b48e5c..d883dec4 100755 --- a/cdist/conf/type/__jail_freebsd9/gencode-remote +++ b/cdist/conf/type/__jail_freebsd9/gencode-remote @@ -36,7 +36,7 @@ state="$(cat "$__object/parameter/state")" started="true" # If the user wants the jail gone, it implies it shouldn't be started. -[ -f "$__object/parameter/stopped" -o "$state" = "absent" ] && started="false" +{ [ -f "$__object/parameter/stopped" ] || [ "$state" = "absent" ]; } && started="false" if [ -f "$__object/parameter/ip" ]; then ip="$(cat "$__object/parameter/ip")" @@ -70,7 +70,7 @@ devfsruleset="$(cat "$__object/parameter/devfs-ruleset")" # devfs_ruleset being defined without devfs_enable being true # is pointless. Treat this as an error. -if [ -n "$devfsruleset" -a "$devfsenable" = "false" ]; then +if [ -n "$devfsruleset" ] && [ "$devfsenable" = "false" ]; then exec >&2 echo "Can't have --devfs-ruleset defined with --devfs-disable" exit 1 diff --git a/cdist/conf/type/__key_value/manifest b/cdist/conf/type/__key_value/manifest index c7801c89..5a91f60c 100755 --- a/cdist/conf/type/__key_value/manifest +++ b/cdist/conf/type/__key_value/manifest @@ -21,7 +21,7 @@ state_should="$(cat "$__object/parameter/state")" -if [ "$state_should" = "present" -a ! -f "$__object/parameter/value" ]; then +if [ "$state_should" = "present" ] && [ ! -f "$__object/parameter/value" ]; then echo "Missing required parameter 'value'" >&2 exit 1 fi diff --git a/cdist/conf/type/__line/gencode-remote b/cdist/conf/type/__line/gencode-remote index 996029f5..044ebe90 100755 --- a/cdist/conf/type/__line/gencode-remote +++ b/cdist/conf/type/__line/gencode-remote @@ -18,7 +18,7 @@ # along with cdist. If not, see . # -if [ -f "$__object/parameter/before" -a -f "$__object/parameter/after" ]; then +if [ -f "$__object/parameter/before" ] && [ -f "$__object/parameter/after" ]; then echo "Use either --before OR --after but not both." >&2 exit 1 fi diff --git a/cdist/conf/type/__link/gencode-remote b/cdist/conf/type/__link/gencode-remote index 4467fb8e..dc7f3193 100755 --- a/cdist/conf/type/__link/gencode-remote +++ b/cdist/conf/type/__link/gencode-remote @@ -61,7 +61,7 @@ case "$state_should" in ;; absent) # only delete if it is a sym/hard link - if [ "$file_type" = "symlink" -o "$file_type" = "hardlink" ]; then + if [ "$file_type" = "symlink" ] || [ "$file_type" = "hardlink" ]; then printf 'rm -f "%s"\n' "$destination" fi ;; diff --git a/cdist/conf/type/__package/manifest b/cdist/conf/type/__package/manifest index fe7abedc..3ab0f546 100755 --- a/cdist/conf/type/__package/manifest +++ b/cdist/conf/type/__package/manifest @@ -56,7 +56,7 @@ state="$(cat "$__object/parameter/state")" set -- "$@" "$__object_id" "--state" "$state" cd "$__object/parameter" for property in $(ls .); do - if [ "$property" != "type" -a "$property" != "state" ]; then + if [ "$property" != "type" ] && [ "$property" != "state" ]; then set -- "$@" "--$property" "$(cat "$property")" fi done diff --git a/cdist/conf/type/__package_emerge/gencode-remote b/cdist/conf/type/__package_emerge/gencode-remote index 6abe2d61..ada2b414 100755 --- a/cdist/conf/type/__package_emerge/gencode-remote +++ b/cdist/conf/type/__package_emerge/gencode-remote @@ -38,11 +38,11 @@ fi pkg_version="$(cat "$__object/explorer/pkg_version")" if [ -z "$pkg_version" ]; then state_is="absent" -elif [ -z "$version" -a $(echo "$pkg_version" | wc -l) -gt 1 ]; then +elif [ -z "$version" ] && [ $(echo "$pkg_version" | wc -l) -gt 1 ]; then echo "Package name is not unique! The following packages are installed:" echo "$pkg_version" exit 1 -elif [ -n "$version" -a $(echo "$pkg_version" | cut -d " " -f 1 | sort | uniq | wc -l) -gt 1 ]; then +elif [ -n "$version" ] && [ $(echo "$pkg_version" | cut -d " " -f 1 | sort | uniq | wc -l) -gt 1 ]; then echo "Package name is not unique! The following packages are installed:" echo "$pkg_version" exit 1 diff --git a/cdist/conf/type/__package_pkg_freebsd/gencode-remote b/cdist/conf/type/__package_pkg_freebsd/gencode-remote index b51c3153..012bf2ad 100755 --- a/cdist/conf/type/__package_pkg_freebsd/gencode-remote +++ b/cdist/conf/type/__package_pkg_freebsd/gencode-remote @@ -66,7 +66,7 @@ cmd="" # FIXME: This is ugly. execcmd(){ # Set the PACKAGESITE if we're ADDing a new package - if [ "$1" = "add" -a -n "$pkgsite" ]; then + if [ "$1" = "add" ] && [ -n "$pkgsite" ]; then # Use http.../All/ if we know the exact version we want, use .../Latest/ otherwise pkgsite="export PACKAGESITE=${pkgsite}" [ -n "$version" ] && pkgsite="${pkgsite}/All/" || pkgsite="${pkgsite}/Latest/" diff --git a/cdist/conf/type/__package_pkg_openbsd/gencode-remote b/cdist/conf/type/__package_pkg_openbsd/gencode-remote index 4a6763cd..61383edb 100755 --- a/cdist/conf/type/__package_pkg_openbsd/gencode-remote +++ b/cdist/conf/type/__package_pkg_openbsd/gencode-remote @@ -46,7 +46,7 @@ else name="$__object_id" fi -if [ -n "$version" -a -n "$flavor" ]; then +if [ -n "$version" ] && [ -n "$flavor" ]; then pkgid="$name-$version-$flavor" elif [ -n "$version" ]; then pkgid="$name-$version" diff --git a/cdist/conf/type/__package_update_index/gencode-remote b/cdist/conf/type/__package_update_index/gencode-remote index 2cc76b81..8589c6d1 100755 --- a/cdist/conf/type/__package_update_index/gencode-remote +++ b/cdist/conf/type/__package_update_index/gencode-remote @@ -28,7 +28,7 @@ if [ -f "$__object/parameter/maxage" ]; then fi if [ -n "$maxage" ]; then - if [ "$type" != "apt" -a "$type" != "pacman" ]; then + if [ "$type" != "apt" ] && [ "$type" != "pacman" ]; then echo "ERROR: \"--maxage\" only supported for \"apt\" or \"pacman\" pkg-manager." >&2 exit 1 elif [ $currage -lt $maxage ]; then diff --git a/cdist/conf/type/__pyvenv/gencode-remote b/cdist/conf/type/__pyvenv/gencode-remote index a4f078c5..4cba5987 100755 --- a/cdist/conf/type/__pyvenv/gencode-remote +++ b/cdist/conf/type/__pyvenv/gencode-remote @@ -29,10 +29,10 @@ owner="$(cat "$__object/parameter/owner")" group="$(cat "$__object/parameter/group")" mode="$(cat "$__object/parameter/mode")" -[ "$state_should" = "$state_is" -a \ - "$owner" = "$owner_is" -a \ - "$group" = "$group_is" -a \ - -n "$mode" ] && exit 0 +[ "$state_should" = "$state_is" ] && \ +[ "$owner" = "$owner_is" ] && \ +[ "$group" = "$group_is" ] && \ +[ -n "$mode" ] && exit 0 destination="/$__object_id" venvparams="$(cat "$__object/parameter/venvparams")" @@ -49,8 +49,8 @@ case $state_should in if [ "$state_should" != "$state_is" ]; then echo $pyvenv $venvparams "$destination" fi - if [ \( -n "$owner" -a "$owner_is" != "$owner" \) -o \ - \( -n "$group" -a "$group_is" != "$group" \) ]; then + if { [ -n "$owner" ] && [ "$owner_is" != "$owner" ]; } || \ + { [ -n "$group" ] && [ "$group_is" != "$group" ]; }; then echo chown -R "${owner}:${group}" "$destination" fi if [ -n "$mode" ]; then diff --git a/cdist/conf/type/__ssh_authorized_keys/manifest b/cdist/conf/type/__ssh_authorized_keys/manifest index 9fad8896..8cac3449 100755 --- a/cdist/conf/type/__ssh_authorized_keys/manifest +++ b/cdist/conf/type/__ssh_authorized_keys/manifest @@ -23,7 +23,7 @@ owner="$(cat "$__object/parameter/owner" 2>/dev/null || echo "$__object_id")" state="$(cat "$__object/parameter/state" 2>/dev/null)" file="$(cat "$__object/explorer/file")" -if [ ! -f "$__object/parameter/noparent" -o ! -f "$__object/parameter/nofile" ]; then +if [ ! -f "$__object/parameter/noparent" ] || [ ! -f "$__object/parameter/nofile" ]; then group="$(cut -d':' -f 1 "$__object/explorer/group")" if [ -z "$group" ]; then echo "Failed to get owners group from explorer." >&2 From aef14ad39e9428299cc7dd05305209773ad4fcc6 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Tue, 2 Oct 2018 17:21:24 +0200 Subject: [PATCH 0084/1217] ++changelog --- docs/changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog b/docs/changelog index 8fd2ea49..a3d60fbb 100644 --- a/docs/changelog +++ b/docs/changelog @@ -4,6 +4,7 @@ Changelog next: * Core: Transfer all files of a directory at once instead of calling copy once per file (myeisha) * Core: Add timestamp (optional) to log messages (Darko Poljak) + * Explorers, manifests, gencodes: Fix SC2166: and/or operators in test (shellcheck) (Jonas Weber) 4.10.3: 2018-09-23 * New global explorer: os_release (Ľubomír Kučera) From 5ed95ce93b145e41079e9458129f4b82614314bd Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Tue, 2 Oct 2018 20:22:44 +0200 Subject: [PATCH 0085/1217] Fix SC2005 --- cdist/conf/explorer/cpu_cores | 2 +- cdist/conf/explorer/cpu_sockets | 2 +- cdist/conf/type/__zypper_repo/explorer/all_repo_ids | 2 +- cdist/conf/type/__zypper_repo/explorer/enabled_repo_ids | 2 +- cdist/conf/type/__zypper_repo/explorer/repo_id | 2 +- cdist/conf/type/__zypper_service/explorer/repo_ids | 2 +- cdist/conf/type/__zypper_service/explorer/service_id | 2 +- cdist/conf/type/__zypper_service/explorer/service_ids | 2 +- cdist/conf/type/__zypper_service/explorer/service_uri | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/cdist/conf/explorer/cpu_cores b/cdist/conf/explorer/cpu_cores index 7f7a955e..2f676f7a 100755 --- a/cdist/conf/explorer/cpu_cores +++ b/cdist/conf/explorer/cpu_cores @@ -25,7 +25,7 @@ os=$("$__explorer/os") case "$os" in "macosx") - echo "$(sysctl -n hw.physicalcpu)" + sysctl -n hw.physicalcpu ;; *) diff --git a/cdist/conf/explorer/cpu_sockets b/cdist/conf/explorer/cpu_sockets index 8a8194df..903cc743 100755 --- a/cdist/conf/explorer/cpu_sockets +++ b/cdist/conf/explorer/cpu_sockets @@ -25,7 +25,7 @@ os=$("$__explorer/os") case "$os" in "macosx") - echo "$(system_profiler SPHardwareDataType | grep "Number of Processors" | awk -F': ' '{print $2}')" + system_profiler SPHardwareDataType | grep "Number of Processors" | awk -F': ' '{print $2}' ;; *) diff --git a/cdist/conf/type/__zypper_repo/explorer/all_repo_ids b/cdist/conf/type/__zypper_repo/explorer/all_repo_ids index b37d8ac5..dde6d554 100644 --- a/cdist/conf/type/__zypper_repo/explorer/all_repo_ids +++ b/cdist/conf/type/__zypper_repo/explorer/all_repo_ids @@ -21,4 +21,4 @@ # Retrieve all repo id nummbers - parsed zypper output # # -echo $(zypper lr | cut -d'|' -f 1 | grep -E '^[0-9]') +zypper lr | cut -d'|' -f 1 | grep -E '^[0-9]' diff --git a/cdist/conf/type/__zypper_repo/explorer/enabled_repo_ids b/cdist/conf/type/__zypper_repo/explorer/enabled_repo_ids index 2dfb946f..b011c258 100644 --- a/cdist/conf/type/__zypper_repo/explorer/enabled_repo_ids +++ b/cdist/conf/type/__zypper_repo/explorer/enabled_repo_ids @@ -23,4 +23,4 @@ # # simpler command which works only on SLES11 SP3 or newer: # echo $(zypper lr -E | cut -d'|' -f 1 | grep -E '^[0-9]') -echo $(zypper lr | grep -E '^[0-9]([^|]+\|){3,3} Yes' | cut -d'|' -f 1) +zypper lr | grep -E '^[0-9]([^|]+\|){3,3} Yes' | cut -d'|' -f 1 diff --git a/cdist/conf/type/__zypper_repo/explorer/repo_id b/cdist/conf/type/__zypper_repo/explorer/repo_id index 6a4791e6..114c6fe7 100644 --- a/cdist/conf/type/__zypper_repo/explorer/repo_id +++ b/cdist/conf/type/__zypper_repo/explorer/repo_id @@ -26,4 +26,4 @@ if [ -f "$__object/parameter/uri" ]; then else uri="$__object_id" fi -echo $(zypper lr -u | grep -F "$uri" | cut -d'|' -f 1 | grep -E '^[0-9]' ) +zypper lr -u | grep -F "$uri" | cut -d'|' -f 1 | grep -E '^[0-9]' diff --git a/cdist/conf/type/__zypper_service/explorer/repo_ids b/cdist/conf/type/__zypper_service/explorer/repo_ids index e831b76c..787e9869 100644 --- a/cdist/conf/type/__zypper_service/explorer/repo_ids +++ b/cdist/conf/type/__zypper_service/explorer/repo_ids @@ -24,4 +24,4 @@ # simpler command which works only on SLES11 SP3 or newer: # echo $(zypper lr -u -E | cut -d'|' -f 1 | grep -E '^[0-9]') # on older systems, zypper doesn't know the parameter -E -echo $(zypper lr -u | grep -E '^([^|]+\|){3,3} Yes' | cut -d'|' -f 1 | grep -E '^[0-9]') +zypper lr -u | grep -E '^([^|]+\|){3,3} Yes' | cut -d'|' -f 1 | grep -E '^[0-9]' diff --git a/cdist/conf/type/__zypper_service/explorer/service_id b/cdist/conf/type/__zypper_service/explorer/service_id index bf5f0260..91858d84 100644 --- a/cdist/conf/type/__zypper_service/explorer/service_id +++ b/cdist/conf/type/__zypper_service/explorer/service_id @@ -27,4 +27,4 @@ else fi # simpler command which works only on SLES11 SP3 or newer: # echo $(zypper ls -u -E | grep -E "\<$uri\>" | cut -d'|' -f 1 ) -echo $(zypper ls -u | grep -E '^([^|]+\|){3,3} Yes' | grep -E "\<$uri\>" | cut -d'|' -f 1 ) +zypper ls -u | grep -E '^([^|]+\|){3,3} Yes' | grep -E "\<$uri\>" | cut -d'|' -f 1 diff --git a/cdist/conf/type/__zypper_service/explorer/service_ids b/cdist/conf/type/__zypper_service/explorer/service_ids index 0f1f4186..6491ab90 100644 --- a/cdist/conf/type/__zypper_service/explorer/service_ids +++ b/cdist/conf/type/__zypper_service/explorer/service_ids @@ -22,4 +22,4 @@ # # simpler command which works only on SLES11 SP3 or newer: # echo $(zypper ls -u -E | cut -d'|' -f 1 | grep -E '^[0-9]') -echo $(zypper ls -u | grep -E '^([^|]+\|){3,3} Yes' | cut -d'|' -f 1 | grep -E '^[0-9]') +zypper ls -u | grep -E '^([^|]+\|){3,3} Yes' | cut -d'|' -f 1 | grep -E '^[0-9]' diff --git a/cdist/conf/type/__zypper_service/explorer/service_uri b/cdist/conf/type/__zypper_service/explorer/service_uri index 6eee47fb..b8de0dcd 100644 --- a/cdist/conf/type/__zypper_service/explorer/service_uri +++ b/cdist/conf/type/__zypper_service/explorer/service_uri @@ -25,4 +25,4 @@ if [ -f "$__object/parameter/uri" ]; then else uri="/$__object_id" fi -echo $(zypper ls -u | awk 'BEGIN { FS = "[ ]+\\|[ ]+" } ; $4 == "Yes" && $NF == "'$uri'" {print $NF}') +zypper ls -u | awk 'BEGIN { FS = "[ ]+\\|[ ]+" } ; $4 == "Yes" && $NF == "'$uri'" {print $NF}' From 0928708d19b77a1ca0ad7f0b3f7c0d74c81bfa9a Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Tue, 2 Oct 2018 20:34:54 +0200 Subject: [PATCH 0086/1217] Fix SC2004 --- .../__install_partition_msdos_apply/gencode-remote | 10 +++++----- cdist/conf/type/__prometheus_alertmanager/manifest | 2 +- cdist/conf/type/__prometheus_server/manifest | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/cdist/conf/type/__install_partition_msdos_apply/gencode-remote b/cdist/conf/type/__install_partition_msdos_apply/gencode-remote index 090a5d86..7e8eef4e 100755 --- a/cdist/conf/type/__install_partition_msdos_apply/gencode-remote +++ b/cdist/conf/type/__install_partition_msdos_apply/gencode-remote @@ -40,16 +40,16 @@ size_to_mb() { case "$suffix" in K|k) - size="$(( $number / 1024 ))" + size="$(( number / 1024 ))" ;; M|m) size="$number" ;; G|g) - size="$(( $number * 1024 ))" + size="$(( number * 1024 ))" ;; %) - size="$(( $available_size * $number / 100 ))" + size="$(( available_size * number / 100 ))" ;; *) size="-1" @@ -108,7 +108,7 @@ for object in $objects; do if [ "${minor}" -lt "5" ]; then # Primary partitions - primary_count=$(( $primary_count + 1 )) + primary_count=$(( primary_count + 1 )) available_size=$available_device_size else # Logical partitions @@ -121,7 +121,7 @@ for object in $objects; do available_size=0 else partition_size=$(size_to_mb "$size" "$available_size") - available_size="$(( $available_size - $partition_size ))" + available_size="$(( available_size - partition_size ))" fi if [ "${minor}" -lt "5" ]; then diff --git a/cdist/conf/type/__prometheus_alertmanager/manifest b/cdist/conf/type/__prometheus_alertmanager/manifest index be50b71e..054e44cb 100755 --- a/cdist/conf/type/__prometheus_alertmanager/manifest +++ b/cdist/conf/type/__prometheus_alertmanager/manifest @@ -48,7 +48,7 @@ __key_value alertmanager_fix_init_script --file /etc/init.d/prometheus-alertmana ##### CONFIGURE ############################################################# -FLAGS="--storage.path $storage_path --data.retention $(($retention_days*24))h --web.listen-address [::]:9093" +FLAGS="--storage.path $storage_path --data.retention $((retention_days*24))h --web.listen-address [::]:9093" require="$require $require_pkg" \ __key_value alertmanager_args --file /etc/default/prometheus-alertmanager \ diff --git a/cdist/conf/type/__prometheus_server/manifest b/cdist/conf/type/__prometheus_server/manifest index 84ba53cf..e2f32fd5 100755 --- a/cdist/conf/type/__prometheus_server/manifest +++ b/cdist/conf/type/__prometheus_server/manifest @@ -45,7 +45,7 @@ require="$require $require_pkg" __directory "$storage_path" --owner prometheus - ##### CONFIGURE ############################################################# -FLAGS="--storage.tsdb.path $storage_path --storage.tsdb.retention $(($retention_days*24))h --web.listen-address [::]:9090" +FLAGS="--storage.tsdb.path $storage_path --storage.tsdb.retention $((retention_days*24))h --web.listen-address [::]:9090" # TODO it would be neat to restart prometheus on change -- __key_value really should have an --onchange parameter require="$require $require_pkg" \ From 3757e8c2c504367bdd2d6b69a5aafbbf0fdba772 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Tue, 2 Oct 2018 21:50:17 +0200 Subject: [PATCH 0087/1217] ++changelog --- docs/changelog | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/changelog b/docs/changelog index a3d60fbb..e51c198c 100644 --- a/docs/changelog +++ b/docs/changelog @@ -5,6 +5,8 @@ next: * Core: Transfer all files of a directory at once instead of calling copy once per file (myeisha) * Core: Add timestamp (optional) to log messages (Darko Poljak) * Explorers, manifests, gencodes: Fix SC2166: and/or operators in test (shellcheck) (Jonas Weber) + * Explorers and types: Fix SC2004: $/${} is unnecessary on arithmetic variables (shellcheck) (Darko Poljak) + * Explorers and types: Fix SC2005: Useless echo? Instead of echo $(cmd), just use cmd (shellcheck) (Darko Poljak) 4.10.3: 2018-09-23 * New global explorer: os_release (Ľubomír Kučera) From 44acfcdd12a8e1d8cfaa91c38c87e277c79f819d Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Tue, 2 Oct 2018 20:44:46 +0200 Subject: [PATCH 0088/1217] Fix SC2002 --- cdist/conf/explorer/cpu_sockets | 4 ++-- cdist/conf/explorer/machine_type | 2 +- cdist/conf/type/__ccollect_source/manifest | 2 +- cdist/conf/type/__consul/gencode-remote | 2 +- cdist/conf/type/__golang_from_vendor/gencode-remote | 2 +- cdist/conf/type/__ssh_authorized_key/explorer/entry | 2 +- cdist/conf/type/__ssh_authorized_key/gencode-remote | 2 +- cdist/conf/type/__staged_file/gencode-local | 2 +- cdist/conf/type/__zypper_service/gencode-remote | 2 +- cdist/conf/type/__zypper_service/manifest | 2 +- 10 files changed, 11 insertions(+), 11 deletions(-) diff --git a/cdist/conf/explorer/cpu_sockets b/cdist/conf/explorer/cpu_sockets index 903cc743..2d577043 100755 --- a/cdist/conf/explorer/cpu_sockets +++ b/cdist/conf/explorer/cpu_sockets @@ -30,9 +30,9 @@ case "$os" in *) if [ -r /proc/cpuinfo ]; then - sockets="$(grep "physical id" /proc/cpuinfo | sort | uniq | wc -l)" + sockets="$(grep "physical id" /proc/cpuinfo | sort -u | wc -l)" if [ ${sockets} -eq 0 ]; then - sockets="$(cat /proc/cpuinfo | grep "processor" | wc -l)" + sockets="$(grep -c "processor" /proc/cpuinfo)" fi echo "${sockets}" fi diff --git a/cdist/conf/explorer/machine_type b/cdist/conf/explorer/machine_type index 3b4f0308..3a3cd0c1 100755 --- a/cdist/conf/explorer/machine_type +++ b/cdist/conf/explorer/machine_type @@ -28,7 +28,7 @@ if [ -d "/proc/vz" -a ! -d "/proc/bc" ]; then fi if [ -e "/proc/1/environ" ] && - cat "/proc/1/environ" | tr '\000' '\n' | grep -Eiq '^container='; then + tr '\000' '\n' < "/proc/1/environ" | grep -Eiq '^container='; then echo lxc exit fi diff --git a/cdist/conf/type/__ccollect_source/manifest b/cdist/conf/type/__ccollect_source/manifest index 238c7e76..26c6cc99 100755 --- a/cdist/conf/type/__ccollect_source/manifest +++ b/cdist/conf/type/__ccollect_source/manifest @@ -22,7 +22,7 @@ name="$__object_id" state="$(cat "$__object/parameter/state")" source="$(cat "$__object/parameter/source")" destination="$(cat "$__object/parameter/destination")" -ccollectconf="$(cat "$__object/parameter/ccollectconf" | sed 's,/$,,')" +ccollectconf="$(sed 's,/$,,' "$__object/parameter/ccollectconf")" sourcedir="$ccollectconf/sources" basedir="$sourcedir/$name" diff --git a/cdist/conf/type/__consul/gencode-remote b/cdist/conf/type/__consul/gencode-remote index 22e9eea1..1d2244ea 100755 --- a/cdist/conf/type/__consul/gencode-remote +++ b/cdist/conf/type/__consul/gencode-remote @@ -39,7 +39,7 @@ version_dir="$versions_dir/$version" source=$(cat "$version_dir/source") source_file_name="${source##*/}" -cksum_should=$(cat "$version_dir/cksum" | cut -d' ' -f1,2) +cksum_should=$(cut -d' ' -f1,2 "$version_dir/cksum") cat << eof tmpdir=\$(mktemp -d --tmpdir="/tmp" "${__type##*/}.XXXXXXXXXX") diff --git a/cdist/conf/type/__golang_from_vendor/gencode-remote b/cdist/conf/type/__golang_from_vendor/gencode-remote index 1654978b..5200e9e3 100755 --- a/cdist/conf/type/__golang_from_vendor/gencode-remote +++ b/cdist/conf/type/__golang_from_vendor/gencode-remote @@ -2,7 +2,7 @@ version=$(cat "$__object/parameter/version") -kernel_name=$(cat "$__global/explorer/kernel_name" | tr '[:upper:]' '[:lower:]') +kernel_name=$(tr '[:upper:]' '[:lower:]' < "$__global/explorer/kernel_name") machine=$(cat "$__global/explorer/machine") case $machine in x86_64|amd64) diff --git a/cdist/conf/type/__ssh_authorized_key/explorer/entry b/cdist/conf/type/__ssh_authorized_key/explorer/entry index 1535d348..157d70f1 100755 --- a/cdist/conf/type/__ssh_authorized_key/explorer/entry +++ b/cdist/conf/type/__ssh_authorized_key/explorer/entry @@ -19,7 +19,7 @@ # # extract the keytype and base64 encoded key ignoring any options and comment -type_and_key="$(cat "$__object/parameter/key" | tr ' ' '\n' | awk '/^(ssh|ecdsa)-[^ ]+/ { printf $1" "; getline; printf $1 }')" +type_and_key="$(tr ' ' '\n' < "$__object/parameter/key"| awk '/^(ssh|ecdsa)-[^ ]+/ { printf $1" "; getline; printf $1 }')" # If type_and_key is empty, which is the case with an invalid key, do not grep $file because it results # in greping everything in file and all entries from file are removed. if [ -n "${type_and_key}" ] diff --git a/cdist/conf/type/__ssh_authorized_key/gencode-remote b/cdist/conf/type/__ssh_authorized_key/gencode-remote index 7ded7dc6..333dfa03 100755 --- a/cdist/conf/type/__ssh_authorized_key/gencode-remote +++ b/cdist/conf/type/__ssh_authorized_key/gencode-remote @@ -59,7 +59,7 @@ mkdir "$__object/files" ( if [ -f "$__object/parameter/option" ]; then # comma seperated list of options - options="$(cat "$__object/parameter/option" | tr '\n' ',')" + options="$(tr '\n' ',' < "$__object/parameter/option")" printf '%s ' "${options%*,}" fi if [ -f "$__object/parameter/comment" ]; then diff --git a/cdist/conf/type/__staged_file/gencode-local b/cdist/conf/type/__staged_file/gencode-local index 8e2003af..18bf09f5 100755 --- a/cdist/conf/type/__staged_file/gencode-local +++ b/cdist/conf/type/__staged_file/gencode-local @@ -74,7 +74,7 @@ fetch_and_prepare_file() { cat << DONE verify_cksum() { cksum_is="\$(cksum "$stage_file" | cut -d' ' -f1,2)" - cksum_should="$(cat "$__object/parameter/cksum" | cut -d' ' -f1,2)" + cksum_should="$(cut -d' ' -f1,2 "$__object/parameter/cksum")" if [ "\$cksum_is" = "\$cksum_should" ]; then return 0 else diff --git a/cdist/conf/type/__zypper_service/gencode-remote b/cdist/conf/type/__zypper_service/gencode-remote index e5b41cc6..955698d1 100755 --- a/cdist/conf/type/__zypper_service/gencode-remote +++ b/cdist/conf/type/__zypper_service/gencode-remote @@ -46,7 +46,7 @@ exp_uri="$(cat "$__object/explorer/service_uri")" exp_id="$(cat "$__object/explorer/service_id")" # we need this list to remove ids, but we must do this in reverse order -exp_ids="$(cat "$__object/explorer/service_ids" | rev)" +exp_ids="$(rev "$__object/explorer/service_ids")" if [ "$uri" = "$exp_uri" ] ; then state_is="present" diff --git a/cdist/conf/type/__zypper_service/manifest b/cdist/conf/type/__zypper_service/manifest index e4f0bcf6..42a56830 100755 --- a/cdist/conf/type/__zypper_service/manifest +++ b/cdist/conf/type/__zypper_service/manifest @@ -47,7 +47,7 @@ fi [ "$state_is" = "$state_should" ] && exit 0 # we need this list to remove ids, but we must do this in reverse order -exp_repos="$(cat "$__object/explorer/repo_ids" | rev)" +exp_repos="$(rev "$__object/explorer/repo_ids")" # boolean parameter if [ -f "$__object/parameter/remove-all-repos" ]; then From 8ef2773c0db54179ccb456961758aaea53aef2ee Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Wed, 3 Oct 2018 14:32:28 +0200 Subject: [PATCH 0089/1217] Fix SC2039 --- cdist/conf/type/__docker/manifest | 2 +- cdist/conf/type/__group/gencode-remote | 6 +++--- .../files/lib.sh | 20 +++++++++---------- .../gencode-remote | 10 +++++----- .../explorer/pkg_version | 2 +- .../explorer/pkg_version | 2 +- .../__package_pkgng_freebsd/gencode-remote | 2 +- 7 files changed, 22 insertions(+), 22 deletions(-) diff --git a/cdist/conf/type/__docker/manifest b/cdist/conf/type/__docker/manifest index d501a9f1..e0558b46 100755 --- a/cdist/conf/type/__docker/manifest +++ b/cdist/conf/type/__docker/manifest @@ -24,7 +24,7 @@ state=$(cat "$__object/parameter/state") case "$os" in centos) - if (source "$__global/explorer/os_release" && [ "${VERSION_ID}" = "7" ]); then + if (. "$__global/explorer/os_release" && [ "${VERSION_ID}" = "7" ]); then __yum_repo docker-ce-stable \ --name 'Docker CE Stable' \ --baseurl "https://download.docker.com/linux/centos/7/\$basearch/stable" \ diff --git a/cdist/conf/type/__group/gencode-remote b/cdist/conf/type/__group/gencode-remote index 5847cb66..68475178 100755 --- a/cdist/conf/type/__group/gencode-remote +++ b/cdist/conf/type/__group/gencode-remote @@ -30,9 +30,9 @@ state="$(cat "$__object/parameter/state")" # Use short option names for portability shorten_property() { case "$1" in - gid) echo "-g";; - password) echo "-p";; - system) echo "-r";; + gid) echo -- "-g";; + password) echo -- "-p";; + system) echo -- "-r";; esac } diff --git a/cdist/conf/type/__install_partition_msdos_apply/files/lib.sh b/cdist/conf/type/__install_partition_msdos_apply/files/lib.sh index cddc575d..13ead401 100644 --- a/cdist/conf/type/__install_partition_msdos_apply/files/lib.sh +++ b/cdist/conf/type/__install_partition_msdos_apply/files/lib.sh @@ -8,8 +8,8 @@ debug() { } fdisk_command() { - local device="$1" - local cmd="$2" + device="$1" + cmd="$2" debug fdisk_command "running fdisk command '${cmd}' on device ${device}" printf "${cmd}\nw\n" | fdisk -c -u "$device" @@ -20,7 +20,7 @@ fdisk_command() { } create_disklabel() { - local device=$1 + device=$1 debug create_disklabel "creating new msdos disklabel" fdisk_command ${device} "o" @@ -28,18 +28,18 @@ create_disklabel() { } toggle_bootable() { - local device="$1" - local minor="$2" + device="$1" + minor="$2" fdisk_command ${device} "a\n${minor}\n" return $? } create_partition() { - local device="$1" - local minor="$2" - local size="$3" - local type="$4" - local primary_count="$5" + device="$1" + minor="$2" + size="$3" + type="$4" + primary_count="$5" if [ "$type" = "extended" -o "$type" = "5" ]; then # Extended partition diff --git a/cdist/conf/type/__install_partition_msdos_apply/gencode-remote b/cdist/conf/type/__install_partition_msdos_apply/gencode-remote index 312e6f81..9e5fcd00 100755 --- a/cdist/conf/type/__install_partition_msdos_apply/gencode-remote +++ b/cdist/conf/type/__install_partition_msdos_apply/gencode-remote @@ -31,12 +31,12 @@ debug() { # Convert a size specifier 1G 100M or 50% into the corresponding numeric MB. size_to_mb() { - local size=$1 - local available_size="$2" + size=$1 + available_size="$2" - local number_suffix="$(echo ${size} | sed -e 's:\.[0-9]\+::' -e 's:\([0-9]\+\)\([KkMmGg%]\)[Bb]\?:\1|\2:')" - local number="$(echo ${number_suffix} | cut -d '|' -f1)" - local suffix="$(echo ${number_suffix} | cut -d '|' -f2)" + number_suffix="$(echo ${size} | sed -e 's:\.[0-9]\+::' -e 's:\([0-9]\+\)\([KkMmGg%]\)[Bb]\?:\1|\2:')" + number="$(echo ${number_suffix} | cut -d '|' -f1)" + suffix="$(echo ${number_suffix} | cut -d '|' -f2)" case "$suffix" in K|k) diff --git a/cdist/conf/type/__package_pkg_freebsd/explorer/pkg_version b/cdist/conf/type/__package_pkg_freebsd/explorer/pkg_version index 1335ba79..0a1ab75c 100755 --- a/cdist/conf/type/__package_pkg_freebsd/explorer/pkg_version +++ b/cdist/conf/type/__package_pkg_freebsd/explorer/pkg_version @@ -30,7 +30,7 @@ fi # Don't produce "no pkgs installed" output -- breaks things PKG_OUTPUT=$(pkg_info 2>&1) if [ ! "$PKG_OUTPUT" = "pkg_info: no packages installed" ]; then - echo -n "$(echo "$PKG_OUTPUT" \ + printf "%s" "$(echo "$PKG_OUTPUT" \ | awk '{print $1}' \ | sed 's/^\(.*\)-\([^-]*\)$/name:\1 ver:\2/g' \ | grep "name:$name ver:" \ diff --git a/cdist/conf/type/__package_pkgng_freebsd/explorer/pkg_version b/cdist/conf/type/__package_pkgng_freebsd/explorer/pkg_version index 947857b9..92ce0623 100755 --- a/cdist/conf/type/__package_pkgng_freebsd/explorer/pkg_version +++ b/cdist/conf/type/__package_pkgng_freebsd/explorer/pkg_version @@ -29,7 +29,7 @@ fi # Don't produce "no pkgs installed" output -- breaks things PKG_OUTPUT=$(pkg info 2>&1) -echo -n "$(echo "$PKG_OUTPUT" \ +printf "%s" "$(echo "$PKG_OUTPUT" \ | awk '{print $1}' \ | sed 's/^\(.*\)-\([^-]*\)$/name:\1 ver:\2/g' \ | grep "name:$name ver:" \ diff --git a/cdist/conf/type/__package_pkgng_freebsd/gencode-remote b/cdist/conf/type/__package_pkgng_freebsd/gencode-remote index d21e9e2a..b59e3648 100755 --- a/cdist/conf/type/__package_pkgng_freebsd/gencode-remote +++ b/cdist/conf/type/__package_pkgng_freebsd/gencode-remote @@ -52,7 +52,7 @@ cmd="" # Parms: $1 -- mode, "rm", "add", or "upg" # $2 -- the command to be echoed execcmd(){ - local _cmd="" + _cmd="" case "$1" in add) From 383af6736f968cd79d742b300fffaf97a0c82713 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Wed, 3 Oct 2018 14:52:17 +0200 Subject: [PATCH 0090/1217] ++changelog --- docs/changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog b/docs/changelog index e51c198c..ecd52327 100644 --- a/docs/changelog +++ b/docs/changelog @@ -7,6 +7,7 @@ next: * Explorers, manifests, gencodes: Fix SC2166: and/or operators in test (shellcheck) (Jonas Weber) * Explorers and types: Fix SC2004: $/${} is unnecessary on arithmetic variables (shellcheck) (Darko Poljak) * Explorers and types: Fix SC2005: Useless echo? Instead of echo $(cmd), just use cmd (shellcheck) (Darko Poljak) + * Explorers and types: Fix SC2002: Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead (shellcheck) (Darko Poljak) 4.10.3: 2018-09-23 * New global explorer: os_release (Ľubomír Kučera) From ab9e2264df73c9f97db502ab4efa7701a2c90371 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Thu, 4 Oct 2018 09:10:31 +0200 Subject: [PATCH 0091/1217] ++changelog --- docs/changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog b/docs/changelog index ecd52327..100b914d 100644 --- a/docs/changelog +++ b/docs/changelog @@ -8,6 +8,7 @@ next: * Explorers and types: Fix SC2004: $/${} is unnecessary on arithmetic variables (shellcheck) (Darko Poljak) * Explorers and types: Fix SC2005: Useless echo? Instead of echo $(cmd), just use cmd (shellcheck) (Darko Poljak) * Explorers and types: Fix SC2002: Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead (shellcheck) (Darko Poljak) + * Explorers and types: Fix SC2039: In POSIX sh, something is undefined (shellcheck) (Darko Poljak) 4.10.3: 2018-09-23 * New global explorer: os_release (Ľubomír Kučera) From 134c84607f0ae90666ca17d7454462cb111fde90 Mon Sep 17 00:00:00 2001 From: Thomas Eckert Date: Thu, 4 Oct 2018 12:28:59 +0200 Subject: [PATCH 0092/1217] fix another SC2166 (test `[ .. -a.. ]` replaced by `[ .. ] && ]`) --- cdist/conf/explorer/machine_type | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cdist/conf/explorer/machine_type b/cdist/conf/explorer/machine_type index 3a3cd0c1..bb21f69c 100755 --- a/cdist/conf/explorer/machine_type +++ b/cdist/conf/explorer/machine_type @@ -22,7 +22,7 @@ # FIXME: other system types (not linux ...) -if [ -d "/proc/vz" -a ! -d "/proc/bc" ]; then +if [ -d "/proc/vz" ] && [ ! -d "/proc/bc" ]; then echo openvz exit fi From 31bf6ab230f68b55bd53b7646c3abd3487fc7303 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Thu, 4 Oct 2018 12:38:40 +0200 Subject: [PATCH 0093/1217] ++changelog --- docs/changelog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/changelog b/docs/changelog index 100b914d..5fccbc55 100644 --- a/docs/changelog +++ b/docs/changelog @@ -4,7 +4,7 @@ Changelog next: * Core: Transfer all files of a directory at once instead of calling copy once per file (myeisha) * Core: Add timestamp (optional) to log messages (Darko Poljak) - * Explorers, manifests, gencodes: Fix SC2166: and/or operators in test (shellcheck) (Jonas Weber) + * Explorers, manifests, gencodes: Fix SC2166: and/or operators in test (shellcheck) (Jonas Weber, Thomas Eckert) * Explorers and types: Fix SC2004: $/${} is unnecessary on arithmetic variables (shellcheck) (Darko Poljak) * Explorers and types: Fix SC2005: Useless echo? Instead of echo $(cmd), just use cmd (shellcheck) (Darko Poljak) * Explorers and types: Fix SC2002: Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead (shellcheck) (Darko Poljak) From d950ddada3a43c8c3d1498a533c91abb6604b51e Mon Sep 17 00:00:00 2001 From: Thomas Eckert Date: Thu, 4 Oct 2018 16:01:45 +0200 Subject: [PATCH 0094/1217] fix SC2045 (use globs instead of `ls`) --- cdist/conf/type/__config_file/manifest | 3 ++- cdist/conf/type/__consul_agent/manifest | 3 ++- cdist/conf/type/__consul_check/manifest | 3 ++- cdist/conf/type/__consul_service/manifest | 3 ++- cdist/conf/type/__consul_template/manifest | 3 ++- cdist/conf/type/__consul_template_template/manifest | 3 ++- cdist/conf/type/__consul_watch_checks/manifest | 3 ++- cdist/conf/type/__consul_watch_event/manifest | 3 ++- cdist/conf/type/__consul_watch_key/manifest | 3 ++- cdist/conf/type/__consul_watch_keyprefix/manifest | 3 ++- cdist/conf/type/__consul_watch_nodes/manifest | 3 ++- cdist/conf/type/__consul_watch_service/manifest | 3 ++- cdist/conf/type/__consul_watch_services/manifest | 3 ++- cdist/conf/type/__jail/manifest | 2 +- cdist/conf/type/__package/manifest | 2 +- cdist/conf/type/__user/gencode-remote | 4 ++-- 16 files changed, 30 insertions(+), 17 deletions(-) diff --git a/cdist/conf/type/__config_file/manifest b/cdist/conf/type/__config_file/manifest index 3155f79b..be8f9f67 100755 --- a/cdist/conf/type/__config_file/manifest +++ b/cdist/conf/type/__config_file/manifest @@ -19,7 +19,8 @@ # set -- "/${__object_id}" -for param in $(ls "$__object/parameter/"); do +cd "$__object/parameter/" +for param in *; do case "$param" in source) source="$(cat "$__object/parameter/source")" diff --git a/cdist/conf/type/__consul_agent/manifest b/cdist/conf/type/__consul_agent/manifest index a696894b..3951f728 100755 --- a/cdist/conf/type/__consul_agent/manifest +++ b/cdist/conf/type/__consul_agent/manifest @@ -84,7 +84,8 @@ echo "{" # parameters we define ourself printf ' "data_dir": "%s"\n' "$data_dir" -for param in $(ls "$__object/parameter/"); do +cd "$__object/parameter/" +for param in *; do case "$param" in state|user|group|json-config) continue ;; ca-file-source|cert-file-source|key-file-source) diff --git a/cdist/conf/type/__consul_check/manifest b/cdist/conf/type/__consul_check/manifest index 554c0680..c9f7add9 100755 --- a/cdist/conf/type/__consul_check/manifest +++ b/cdist/conf/type/__consul_check/manifest @@ -50,7 +50,8 @@ fi echo "{" printf ' "check": {\n' printf ' "name": "%s"\n' "$name" -for param in $(ls "$__object/parameter/"); do +cd "$__object/parameter/" +for param in *; do case "$param" in state|name) continue ;; *) diff --git a/cdist/conf/type/__consul_service/manifest b/cdist/conf/type/__consul_service/manifest index f6d29b4a..60397db7 100755 --- a/cdist/conf/type/__consul_service/manifest +++ b/cdist/conf/type/__consul_service/manifest @@ -42,7 +42,8 @@ fi echo "{" printf ' "service": {\n' printf ' "name": "%s"\n' "$name" -for param in $(ls "$__object/parameter/"); do +cd "$__object/parameter/" +for param in *; do case "$param" in state|name|check-interval) continue ;; check-script) diff --git a/cdist/conf/type/__consul_template/manifest b/cdist/conf/type/__consul_template/manifest index 2236e5bd..b02fc332 100755 --- a/cdist/conf/type/__consul_template/manifest +++ b/cdist/conf/type/__consul_template/manifest @@ -75,7 +75,8 @@ require="__directory/etc/consul-template" \ # Generate hcl config file ( -for param in $(ls "$__object/parameter/"); do +cd "$__object/parameter/" +for param in *; do case "$param" in auth-password|state|ssl-*|syslog-*|version|vault-token|vault-ssl*) continue ;; auth-username) diff --git a/cdist/conf/type/__consul_template_template/manifest b/cdist/conf/type/__consul_template_template/manifest index 488a0f5d..7834ae9c 100755 --- a/cdist/conf/type/__consul_template_template/manifest +++ b/cdist/conf/type/__consul_template_template/manifest @@ -38,7 +38,8 @@ fi # Generate hcl config file ( printf 'template {\n' -for param in $(ls "$__object/parameter/"); do +cd "$__object/parameter/" +for param in *; do case "$param" in source-file) source="$(cat "$__object/parameter/$param")" diff --git a/cdist/conf/type/__consul_watch_checks/manifest b/cdist/conf/type/__consul_watch_checks/manifest index 146f609e..5fdd7a74 100755 --- a/cdist/conf/type/__consul_watch_checks/manifest +++ b/cdist/conf/type/__consul_watch_checks/manifest @@ -35,7 +35,8 @@ fi echo "{" printf ' "watches": [{\n' printf ' "type": "%s"\n' "$watch_type" -for param in $(ls "$__object/parameter/"); do +cd "$__object/parameter/" +for param in *; do case "$param" in state) continue ;; filter-*) diff --git a/cdist/conf/type/__consul_watch_event/manifest b/cdist/conf/type/__consul_watch_event/manifest index 099054a5..61934656 100755 --- a/cdist/conf/type/__consul_watch_event/manifest +++ b/cdist/conf/type/__consul_watch_event/manifest @@ -29,7 +29,8 @@ state="$(cat "$__object/parameter/state")" echo "{" printf ' "watches": [{\n' printf ' "type": "%s"\n' "$watch_type" -for param in $(ls "$__object/parameter/"); do +cd "$__object/parameter/" +for param in *; do case "$param" in state) continue ;; *) diff --git a/cdist/conf/type/__consul_watch_key/manifest b/cdist/conf/type/__consul_watch_key/manifest index 099054a5..61934656 100755 --- a/cdist/conf/type/__consul_watch_key/manifest +++ b/cdist/conf/type/__consul_watch_key/manifest @@ -29,7 +29,8 @@ state="$(cat "$__object/parameter/state")" echo "{" printf ' "watches": [{\n' printf ' "type": "%s"\n' "$watch_type" -for param in $(ls "$__object/parameter/"); do +cd "$__object/parameter/" +for param in *; do case "$param" in state) continue ;; *) diff --git a/cdist/conf/type/__consul_watch_keyprefix/manifest b/cdist/conf/type/__consul_watch_keyprefix/manifest index 099054a5..61934656 100755 --- a/cdist/conf/type/__consul_watch_keyprefix/manifest +++ b/cdist/conf/type/__consul_watch_keyprefix/manifest @@ -29,7 +29,8 @@ state="$(cat "$__object/parameter/state")" echo "{" printf ' "watches": [{\n' printf ' "type": "%s"\n' "$watch_type" -for param in $(ls "$__object/parameter/"); do +cd "$__object/parameter/" +for param in *; do case "$param" in state) continue ;; *) diff --git a/cdist/conf/type/__consul_watch_nodes/manifest b/cdist/conf/type/__consul_watch_nodes/manifest index 099054a5..61934656 100755 --- a/cdist/conf/type/__consul_watch_nodes/manifest +++ b/cdist/conf/type/__consul_watch_nodes/manifest @@ -29,7 +29,8 @@ state="$(cat "$__object/parameter/state")" echo "{" printf ' "watches": [{\n' printf ' "type": "%s"\n' "$watch_type" -for param in $(ls "$__object/parameter/"); do +cd "$__object/parameter/" +for param in *; do case "$param" in state) continue ;; *) diff --git a/cdist/conf/type/__consul_watch_service/manifest b/cdist/conf/type/__consul_watch_service/manifest index 2825c716..db38eb18 100755 --- a/cdist/conf/type/__consul_watch_service/manifest +++ b/cdist/conf/type/__consul_watch_service/manifest @@ -29,7 +29,8 @@ state="$(cat "$__object/parameter/state")" echo "{" printf ' "watches": [{\n' printf ' "type": "%s"\n' "$watch_type" -for param in $(ls "$__object/parameter/"); do +cd "$__object/parameter/" +for param in *; do case "$param" in state) continue ;; passingonly) diff --git a/cdist/conf/type/__consul_watch_services/manifest b/cdist/conf/type/__consul_watch_services/manifest index 099054a5..61934656 100755 --- a/cdist/conf/type/__consul_watch_services/manifest +++ b/cdist/conf/type/__consul_watch_services/manifest @@ -29,7 +29,8 @@ state="$(cat "$__object/parameter/state")" echo "{" printf ' "watches": [{\n' printf ' "type": "%s"\n' "$watch_type" -for param in $(ls "$__object/parameter/"); do +cd "$__object/parameter/" +for param in *; do case "$param" in state) continue ;; *) diff --git a/cdist/conf/type/__jail/manifest b/cdist/conf/type/__jail/manifest index c3d9dfbe..7564be26 100755 --- a/cdist/conf/type/__jail/manifest +++ b/cdist/conf/type/__jail/manifest @@ -39,7 +39,7 @@ __directory ${jaildir} --parents set -- "$@" "$__object_id" "--state" "$state" cd "$__object/parameter" -for property in $(ls .); do +for property in *; do set -- "$@" "--$property" "$(cat "$property")" done diff --git a/cdist/conf/type/__package/manifest b/cdist/conf/type/__package/manifest index 3ab0f546..f9de1145 100755 --- a/cdist/conf/type/__package/manifest +++ b/cdist/conf/type/__package/manifest @@ -55,7 +55,7 @@ state="$(cat "$__object/parameter/state")" set -- "$@" "$__object_id" "--state" "$state" cd "$__object/parameter" -for property in $(ls .); do +for property in *; do if [ "$property" != "type" ] && [ "$property" != "state" ]; then set -- "$@" "--$property" "$(cat "$property")" fi diff --git a/cdist/conf/type/__user/gencode-remote b/cdist/conf/type/__user/gencode-remote index 23762065..332e93f1 100755 --- a/cdist/conf/type/__user/gencode-remote +++ b/cdist/conf/type/__user/gencode-remote @@ -52,7 +52,7 @@ shorten_property() { if [ "$state" = "present" ]; then cd "$__object/parameter" if grep -q "^${name}:" "$__object/explorer/passwd"; then - for property in $(ls .); do + for property in *; do new_value="$(cat "$property")" unset current_value @@ -113,7 +113,7 @@ if [ "$state" = "present" ]; then fi else echo add >> "$__messages_out" - for property in $(ls .); do + for property in *; do [ "$property" = "state" ] && continue [ "$property" = "remove-home" ] && continue new_value="$(cat "$property")" From d49d38481fb996e47c51f50fad60097c9068c067 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Thu, 4 Oct 2018 17:31:37 +0200 Subject: [PATCH 0095/1217] ++changelog --- docs/changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog b/docs/changelog index 5fccbc55..47639dd5 100644 --- a/docs/changelog +++ b/docs/changelog @@ -9,6 +9,7 @@ next: * Explorers and types: Fix SC2005: Useless echo? Instead of echo $(cmd), just use cmd (shellcheck) (Darko Poljak) * Explorers and types: Fix SC2002: Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead (shellcheck) (Darko Poljak) * Explorers and types: Fix SC2039: In POSIX sh, something is undefined (shellcheck) (Darko Poljak) + * Explorers and types: Fix SC2045: Iterating over ls output is fragile. Use globs. (shellcheck) (Thomas Eckert) 4.10.3: 2018-09-23 * New global explorer: os_release (Ľubomír Kučera) From a46da35bbcb9aef6e0106e764f2a3332048896d6 Mon Sep 17 00:00:00 2001 From: Thomas Eckert Date: Thu, 4 Oct 2018 12:20:50 +0200 Subject: [PATCH 0096/1217] fix SC2148 (missing shebang) and make executable --- cdist/conf/explorer/disks | 1 + cdist/conf/explorer/is-freebsd-jail | 1 + cdist/conf/explorer/kernel_name | 1 + cdist/conf/type/__daemontools_service/explorer/svc | 1 + cdist/conf/type/__go_get/explorer/go-executable | 1 + 5 files changed, 5 insertions(+) mode change 100644 => 100755 cdist/conf/explorer/disks mode change 100644 => 100755 cdist/conf/explorer/is-freebsd-jail mode change 100644 => 100755 cdist/conf/explorer/kernel_name mode change 100644 => 100755 cdist/conf/type/__daemontools_service/explorer/svc mode change 100644 => 100755 cdist/conf/type/__go_get/explorer/go-executable diff --git a/cdist/conf/explorer/disks b/cdist/conf/explorer/disks old mode 100644 new mode 100755 index 52fef81e..6febdbb4 --- a/cdist/conf/explorer/disks +++ b/cdist/conf/explorer/disks @@ -1,2 +1,3 @@ +#!/bin/sh -e cd /dev echo sd? hd? vd? diff --git a/cdist/conf/explorer/is-freebsd-jail b/cdist/conf/explorer/is-freebsd-jail old mode 100644 new mode 100755 index a6d11d1a..d8f8b0ac --- a/cdist/conf/explorer/is-freebsd-jail +++ b/cdist/conf/explorer/is-freebsd-jail @@ -1 +1,2 @@ +#!/bin/sh -e sysctl -n security.jail.jailed 2>/dev/null | grep "1" || true diff --git a/cdist/conf/explorer/kernel_name b/cdist/conf/explorer/kernel_name old mode 100644 new mode 100755 index 98ebac2a..365b5029 --- a/cdist/conf/explorer/kernel_name +++ b/cdist/conf/explorer/kernel_name @@ -1 +1,2 @@ +#!/bin/sh -e uname -s diff --git a/cdist/conf/type/__daemontools_service/explorer/svc b/cdist/conf/type/__daemontools_service/explorer/svc old mode 100644 new mode 100755 index d33fcea4..fdca5e34 --- a/cdist/conf/type/__daemontools_service/explorer/svc +++ b/cdist/conf/type/__daemontools_service/explorer/svc @@ -1 +1,2 @@ +#!/bin/sh -e command -v svc || true diff --git a/cdist/conf/type/__go_get/explorer/go-executable b/cdist/conf/type/__go_get/explorer/go-executable old mode 100644 new mode 100755 index 4c84ce07..b1dc0984 --- a/cdist/conf/type/__go_get/explorer/go-executable +++ b/cdist/conf/type/__go_get/explorer/go-executable @@ -1,3 +1,4 @@ +#!/bin/sh -e [ -f /etc/environment ] && . /etc/environment [ -f /etc/profile ] && . /etc/profile go version 2>/dev/null || true From 085b2a2b104cdeeac8200e5d991137f248244a44 Mon Sep 17 00:00:00 2001 From: Thomas Eckert Date: Thu, 4 Oct 2018 15:15:57 +0200 Subject: [PATCH 0097/1217] remove `set -e` on explorers (they should be able to fail gracefully) --- cdist/conf/explorer/disks | 2 +- cdist/conf/explorer/is-freebsd-jail | 2 +- cdist/conf/explorer/kernel_name | 2 +- cdist/conf/type/__daemontools_service/explorer/svc | 2 +- cdist/conf/type/__go_get/explorer/go-executable | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cdist/conf/explorer/disks b/cdist/conf/explorer/disks index 6febdbb4..7a5c0da0 100755 --- a/cdist/conf/explorer/disks +++ b/cdist/conf/explorer/disks @@ -1,3 +1,3 @@ -#!/bin/sh -e +#!/bin/sh cd /dev echo sd? hd? vd? diff --git a/cdist/conf/explorer/is-freebsd-jail b/cdist/conf/explorer/is-freebsd-jail index d8f8b0ac..010917f5 100755 --- a/cdist/conf/explorer/is-freebsd-jail +++ b/cdist/conf/explorer/is-freebsd-jail @@ -1,2 +1,2 @@ -#!/bin/sh -e +#!/bin/sh sysctl -n security.jail.jailed 2>/dev/null | grep "1" || true diff --git a/cdist/conf/explorer/kernel_name b/cdist/conf/explorer/kernel_name index 365b5029..1f9cfca4 100755 --- a/cdist/conf/explorer/kernel_name +++ b/cdist/conf/explorer/kernel_name @@ -1,2 +1,2 @@ -#!/bin/sh -e +#!/bin/sh uname -s diff --git a/cdist/conf/type/__daemontools_service/explorer/svc b/cdist/conf/type/__daemontools_service/explorer/svc index fdca5e34..9ba462f2 100755 --- a/cdist/conf/type/__daemontools_service/explorer/svc +++ b/cdist/conf/type/__daemontools_service/explorer/svc @@ -1,2 +1,2 @@ -#!/bin/sh -e +#!/bin/sh command -v svc || true diff --git a/cdist/conf/type/__go_get/explorer/go-executable b/cdist/conf/type/__go_get/explorer/go-executable index b1dc0984..bdce7559 100755 --- a/cdist/conf/type/__go_get/explorer/go-executable +++ b/cdist/conf/type/__go_get/explorer/go-executable @@ -1,4 +1,4 @@ -#!/bin/sh -e +#!/bin/sh [ -f /etc/environment ] && . /etc/environment [ -f /etc/profile ] && . /etc/profile go version 2>/dev/null || true From ef8ec8641e4959f6536f6f5d5caa417954195468 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Thu, 4 Oct 2018 18:47:28 +0200 Subject: [PATCH 0098/1217] ++ --- docs/changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog b/docs/changelog index 47639dd5..1405ad3c 100644 --- a/docs/changelog +++ b/docs/changelog @@ -10,6 +10,7 @@ next: * Explorers and types: Fix SC2002: Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead (shellcheck) (Darko Poljak) * Explorers and types: Fix SC2039: In POSIX sh, something is undefined (shellcheck) (Darko Poljak) * Explorers and types: Fix SC2045: Iterating over ls output is fragile. Use globs. (shellcheck) (Thomas Eckert) + * Explorers and types: Fix SC2148: Tips depend on target shell and yours is unknown. Add a shebang. (shellcheck) (Thomas Eckert) 4.10.3: 2018-09-23 * New global explorer: os_release (Ľubomír Kučera) From 6b0f8fba22a56e853b97706813e59e98963bc7a5 Mon Sep 17 00:00:00 2001 From: Jonas Weber Date: Wed, 3 Oct 2018 21:11:59 +0200 Subject: [PATCH 0099/1217] Remove unused variables (almost, found bugs?) Solves SC2034 references #540. --- cdist/conf/type/__apt_ppa/manifest | 2 -- cdist/conf/type/__block/manifest | 2 -- cdist/conf/type/__ccollect_source/gencode-remote | 1 - cdist/conf/type/__file/gencode-remote | 1 - cdist/conf/type/__firewalld_rule/gencode-remote | 1 - cdist/conf/type/__group/gencode-remote | 2 -- cdist/conf/type/__install_generate_fstab/gencode-local | 1 - cdist/conf/type/__install_mkfs/manifest | 8 +------- cdist/conf/type/__install_reboot/gencode-remote | 2 -- cdist/conf/type/__install_reboot/manifest | 6 ++++-- cdist/conf/type/__install_umount/manifest | 6 ++++-- cdist/conf/type/__jail_freebsd10/gencode-remote | 1 + cdist/conf/type/__jail_freebsd9/gencode-remote | 1 + cdist/conf/type/__pacman_conf_integrate/manifest | 2 -- cdist/conf/type/__postfix_master/manifest | 1 - cdist/conf/type/__qemu_img/manifest | 1 - cdist/conf/type/__rvm_gem/gencode-remote | 2 -- cdist/conf/type/__rvm_gemset/explorer/state | 3 --- cdist/conf/type/__rvm_ruby/gencode-remote | 1 - cdist/conf/type/__staged_file/gencode-local | 1 - cdist/conf/type/__staged_file/manifest | 4 ---- 21 files changed, 11 insertions(+), 38 deletions(-) diff --git a/cdist/conf/type/__apt_ppa/manifest b/cdist/conf/type/__apt_ppa/manifest index e1af21bd..c6f4e876 100755 --- a/cdist/conf/type/__apt_ppa/manifest +++ b/cdist/conf/type/__apt_ppa/manifest @@ -18,8 +18,6 @@ # along with cdist. If not, see . # -name="$__object_id" - __package software-properties-common require="__package/software-properties-common" \ diff --git a/cdist/conf/type/__block/manifest b/cdist/conf/type/__block/manifest index 8fea3e83..726950d3 100755 --- a/cdist/conf/type/__block/manifest +++ b/cdist/conf/type/__block/manifest @@ -18,8 +18,6 @@ # along with cdist. If not, see . # - -file="$(cat "$__object/parameter/file" 2>/dev/null || echo "/$__object_id")" prefix=$(cat "$__object/parameter/prefix" 2>/dev/null || echo "#cdist:__block/$__object_id") suffix=$(cat "$__object/parameter/suffix" 2>/dev/null || echo "#/cdist:__block/$__object_id") text=$(cat "$__object/parameter/text") diff --git a/cdist/conf/type/__ccollect_source/gencode-remote b/cdist/conf/type/__ccollect_source/gencode-remote index 763f219e..c8892c9e 100755 --- a/cdist/conf/type/__ccollect_source/gencode-remote +++ b/cdist/conf/type/__ccollect_source/gencode-remote @@ -56,7 +56,6 @@ set_mode() { echo chmod $1 >> "$__messages_out" } -set_attributes= case "$state_should" in present|exists) # Note: Mode - needs to happen last as a chown/chgrp can alter mode by diff --git a/cdist/conf/type/__file/gencode-remote b/cdist/conf/type/__file/gencode-remote index 9dfd1833..6632935c 100755 --- a/cdist/conf/type/__file/gencode-remote +++ b/cdist/conf/type/__file/gencode-remote @@ -57,7 +57,6 @@ set_mode() { echo chmod $1 >> "$__messages_out" } -set_attributes= case "$state_should" in present|exists|pre-exists) # Note: Mode - needs to happen last as a chown/chgrp can alter mode by diff --git a/cdist/conf/type/__firewalld_rule/gencode-remote b/cdist/conf/type/__firewalld_rule/gencode-remote index 4c824d39..b9b930e7 100755 --- a/cdist/conf/type/__firewalld_rule/gencode-remote +++ b/cdist/conf/type/__firewalld_rule/gencode-remote @@ -19,7 +19,6 @@ # # -name="$__object_id" state_should="$(cat "$__object/parameter/state")" state_is="$(cat "$__object/explorer/rule")" diff --git a/cdist/conf/type/__group/gencode-remote b/cdist/conf/type/__group/gencode-remote index 68475178..033228c5 100755 --- a/cdist/conf/type/__group/gencode-remote +++ b/cdist/conf/type/__group/gencode-remote @@ -40,11 +40,9 @@ shorten_property() { if [ "$state" = "present" ]; then case "$os" in freebsd) - supported_add_properties="gid" supported_change_properties="gid" ;; *) - supported_add_properties="gid password system" supported_change_properties="gid password" ;; esac diff --git a/cdist/conf/type/__install_generate_fstab/gencode-local b/cdist/conf/type/__install_generate_fstab/gencode-local index 5cc7d877..b5158a39 100755 --- a/cdist/conf/type/__install_generate_fstab/gencode-local +++ b/cdist/conf/type/__install_generate_fstab/gencode-local @@ -28,7 +28,6 @@ $__remote_exec $__target_host blkid > "$__object/files/blkid" for object in $(find "$__global/object/__install_mount" -type d -name "$__cdist_object_marker"); do device="$(cat "$object/parameter/device")" dir="$(cat "$object/parameter/dir")" - prefix="$(cat "$object/parameter/prefix")" type="$(cat "$object/parameter/type")" if [ -f "$object/parameter/options" ]; then options="$(cat "$object/parameter/options")" diff --git a/cdist/conf/type/__install_mkfs/manifest b/cdist/conf/type/__install_mkfs/manifest index eb65757f..b0a21dae 100755 --- a/cdist/conf/type/__install_mkfs/manifest +++ b/cdist/conf/type/__install_mkfs/manifest @@ -19,13 +19,7 @@ # # set defaults -if [ -f "$__object/parameter/device" ]; then - device="(cat "$__object/parameter/device")" -else +if [ ! -f "$__object/parameter/device" ]; then device="/$__object_id" echo "$device" > "$__object/parameter/device" fi - -type="(cat "$__object/parameter/type")" - -options="(cat "$__object/parameter/options")" diff --git a/cdist/conf/type/__install_reboot/gencode-remote b/cdist/conf/type/__install_reboot/gencode-remote index 00c04523..9a6322c1 100755 --- a/cdist/conf/type/__install_reboot/gencode-remote +++ b/cdist/conf/type/__install_reboot/gencode-remote @@ -18,8 +18,6 @@ # along with cdist. If not, see . # -options="$(cat "$__object/parameter/options")" - #echo "reboot $options" cat << DONE echo 1 > /proc/sys/kernel/sysrq diff --git a/cdist/conf/type/__install_reboot/manifest b/cdist/conf/type/__install_reboot/manifest index 02689d82..46a6356e 100755 --- a/cdist/conf/type/__install_reboot/manifest +++ b/cdist/conf/type/__install_reboot/manifest @@ -19,5 +19,7 @@ # # set defaults -options="$(cat "$__object/parameter/options" 2>/dev/null \ - || echo "" | tee "$__object/parameter/options")" +# TODO is this neccesary or should this be handled using the usual parameter/default workflow? +if [ ! -f "$__object/parameter/options" ]; then + touch "$__object/parameter/options" +fi diff --git a/cdist/conf/type/__install_umount/manifest b/cdist/conf/type/__install_umount/manifest index 42cd19bf..d900df1b 100755 --- a/cdist/conf/type/__install_umount/manifest +++ b/cdist/conf/type/__install_umount/manifest @@ -19,5 +19,7 @@ # # set defaults -target="$(cat "$__object/parameter/target" 2>/dev/null \ - || echo "/target" | tee "$__object/parameter/target")" +# TODO is this neccesary or should this be handled using the usual parameter/default workflow? +if [ ! -f "$__object/parameter/target" ]; then + echo "/target" > "$__object/parameter/target" +fi diff --git a/cdist/conf/type/__jail_freebsd10/gencode-remote b/cdist/conf/type/__jail_freebsd10/gencode-remote index d8bc5eb7..8ce77768 100755 --- a/cdist/conf/type/__jail_freebsd10/gencode-remote +++ b/cdist/conf/type/__jail_freebsd10/gencode-remote @@ -87,6 +87,7 @@ if [ $(expr "${ip}" : ".*, .*") -gt "0" ]; then SAVE_IFS="$IFS" IFS=", " for cur_ip in ${ip}; do + # TODO BUG? Why is cur_ip unused in the following line? # Just get the last IP address for SSH to listen on mgmt_ip=$(echo "${ip}" | cut '-d ' -f1) # In case using "ip netmask" format rather than CIDR done diff --git a/cdist/conf/type/__jail_freebsd9/gencode-remote b/cdist/conf/type/__jail_freebsd9/gencode-remote index d883dec4..c76bb014 100755 --- a/cdist/conf/type/__jail_freebsd9/gencode-remote +++ b/cdist/conf/type/__jail_freebsd9/gencode-remote @@ -92,6 +92,7 @@ if [ $(expr "${ip}" : ".*|.*") -gt "0" ]; then SAVE_IFS="$IFS" IFS=", " for cur_ip in ${ip}; do + # TODO BUG? Why is cur_ip unused in the following line? # Just get the last IP address for SSH to listen on mgmt_ip=$(echo "${ip}" | sed -E -e 's/^.*\|(.*)\/[0-9]+$/\1/') done diff --git a/cdist/conf/type/__pacman_conf_integrate/manifest b/cdist/conf/type/__pacman_conf_integrate/manifest index b26bca50..829fb34b 100755 --- a/cdist/conf/type/__pacman_conf_integrate/manifest +++ b/cdist/conf/type/__pacman_conf_integrate/manifest @@ -20,8 +20,6 @@ state=$(cat $__object/parameter/state 2>/dev/null) -path="/etc/" - if [ "${state}" = "present" ]; then __file /etc/pacman.conf\ --owner root --group root --mode 644 --source $__type/files/pacman.conf.cdist diff --git a/cdist/conf/type/__postfix_master/manifest b/cdist/conf/type/__postfix_master/manifest index 4991a13d..94b5044f 100755 --- a/cdist/conf/type/__postfix_master/manifest +++ b/cdist/conf/type/__postfix_master/manifest @@ -36,7 +36,6 @@ __postfix # Default to object_id service="$(cat "$__object/parameter/service" 2>/dev/null || echo "$__object_id")" -state="$(cat "$__object/parameter/state")" # NOTE: keep variables in sync in manifest,explorer,gencode-* prefix="#cdist:$__object_name" diff --git a/cdist/conf/type/__qemu_img/manifest b/cdist/conf/type/__qemu_img/manifest index e7417389..55f3bf16 100755 --- a/cdist/conf/type/__qemu_img/manifest +++ b/cdist/conf/type/__qemu_img/manifest @@ -4,7 +4,6 @@ # Default settings # -format="$(cat "$__object/parameter/format")" state_should="$(cat "$__object/parameter/state")" diskimage="/$__object_id" diff --git a/cdist/conf/type/__rvm_gem/gencode-remote b/cdist/conf/type/__rvm_gem/gencode-remote index 1fe6e78e..9212de91 100755 --- a/cdist/conf/type/__rvm_gem/gencode-remote +++ b/cdist/conf/type/__rvm_gem/gencode-remote @@ -20,8 +20,6 @@ gem="$__object_id" gemset="$(cat "$__object/parameter/gemset")" -ruby="$(echo "$gemset" | cut -d '@' -f 1)" -gemsetname="$(echo "$gemset" | cut -d '@' -f 2)" state_is="$(cat "$__object/explorer/state")" user="$(cat "$__object/parameter/user")" state_should="$(cat "$__object/parameter/state")" diff --git a/cdist/conf/type/__rvm_gemset/explorer/state b/cdist/conf/type/__rvm_gemset/explorer/state index fa643a6e..d1462134 100755 --- a/cdist/conf/type/__rvm_gemset/explorer/state +++ b/cdist/conf/type/__rvm_gemset/explorer/state @@ -18,9 +18,6 @@ # along with cdist. If not, see . # -gemset="$__object_id" -ruby="$(echo "$gemset" | cut -d '@' -f 1)" -gemsetname="$(echo "$gemset" | cut -d '@' -f2)" user="$(cat "$__object/parameter/user")" if [ ! -e "~$user/.rvm/scripts/rvm" ] ; then diff --git a/cdist/conf/type/__rvm_ruby/gencode-remote b/cdist/conf/type/__rvm_ruby/gencode-remote index 9bbc6031..f2fd41ef 100755 --- a/cdist/conf/type/__rvm_ruby/gencode-remote +++ b/cdist/conf/type/__rvm_ruby/gencode-remote @@ -21,7 +21,6 @@ ruby="$__object_id" state_is="$(cat "$__object/explorer/state")" user="$(cat "$__object/parameter/user")" -default="$(cat "$__object/parameter/default" 2>/dev/null || true)" state_should="$(cat "$__object/parameter/state")" [ "$state_is" = "$state_should" ] && exit 0 diff --git a/cdist/conf/type/__staged_file/gencode-local b/cdist/conf/type/__staged_file/gencode-local index 18bf09f5..851970e8 100755 --- a/cdist/conf/type/__staged_file/gencode-local +++ b/cdist/conf/type/__staged_file/gencode-local @@ -23,7 +23,6 @@ destination="$__object_id" source="$(cat "$__object/parameter/source")" -cksum="$(cat "$__object/parameter/cksum")" stage_dir="$(cat "$__object/parameter/stage-dir")" state="$(cat "$__object/parameter/state")" fetch_command="$(cat "$__object/parameter/fetch-command")" diff --git a/cdist/conf/type/__staged_file/manifest b/cdist/conf/type/__staged_file/manifest index 1654e1d9..c8e1fbbb 100755 --- a/cdist/conf/type/__staged_file/manifest +++ b/cdist/conf/type/__staged_file/manifest @@ -19,11 +19,7 @@ # destination="$__object_id" -source="$(cat "$__object/parameter/source")" -cksum="$(cat "$__object/parameter/cksum")" stage_dir="$(cat "$__object/parameter/stage-dir")" -state="$(cat "$__object/parameter/state")" -fetch_command="$(cat "$__object/parameter/fetch-command")" stage_file="${stage_dir}/${destination}" set -- "/${destination}" From b3f4d3849a687a1795302cb25d3c50c251a4417c Mon Sep 17 00:00:00 2001 From: Jonas Weber Date: Thu, 4 Oct 2018 13:34:11 +0200 Subject: [PATCH 0100/1217] Fix __install_umount target parameter --- cdist/conf/type/__install_umount/manifest | 25 ------------------- .../__install_umount/parameter/default/target | 1 + .../type/__install_umount/parameter/optional | 1 + 3 files changed, 2 insertions(+), 25 deletions(-) delete mode 100755 cdist/conf/type/__install_umount/manifest create mode 100644 cdist/conf/type/__install_umount/parameter/default/target create mode 100644 cdist/conf/type/__install_umount/parameter/optional diff --git a/cdist/conf/type/__install_umount/manifest b/cdist/conf/type/__install_umount/manifest deleted file mode 100755 index d900df1b..00000000 --- a/cdist/conf/type/__install_umount/manifest +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/sh -e -# -# 2011 Steven Armstrong (steven-cdist at armstrong.cc) -# -# This file is part of cdist. -# -# cdist is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# cdist is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with cdist. If not, see . -# - -# set defaults -# TODO is this neccesary or should this be handled using the usual parameter/default workflow? -if [ ! -f "$__object/parameter/target" ]; then - echo "/target" > "$__object/parameter/target" -fi diff --git a/cdist/conf/type/__install_umount/parameter/default/target b/cdist/conf/type/__install_umount/parameter/default/target new file mode 100644 index 00000000..ea8c4bf7 --- /dev/null +++ b/cdist/conf/type/__install_umount/parameter/default/target @@ -0,0 +1 @@ +/target diff --git a/cdist/conf/type/__install_umount/parameter/optional b/cdist/conf/type/__install_umount/parameter/optional new file mode 100644 index 00000000..eb5a316c --- /dev/null +++ b/cdist/conf/type/__install_umount/parameter/optional @@ -0,0 +1 @@ +target From 352679386dc9acd18b7e98de0dfb3d2b8a75b81c Mon Sep 17 00:00:00 2001 From: Jonas Weber Date: Thu, 4 Oct 2018 13:36:45 +0200 Subject: [PATCH 0101/1217] Drop unused options parameter in __install_reboot --- cdist/conf/type/__install_reboot/man.rst | 3 +-- cdist/conf/type/__install_reboot/manifest | 25 ----------------------- 2 files changed, 1 insertion(+), 27 deletions(-) delete mode 100755 cdist/conf/type/__install_reboot/manifest diff --git a/cdist/conf/type/__install_reboot/man.rst b/cdist/conf/type/__install_reboot/man.rst index ecf78ca7..9a53b37a 100644 --- a/cdist/conf/type/__install_reboot/man.rst +++ b/cdist/conf/type/__install_reboot/man.rst @@ -18,8 +18,7 @@ None OPTIONAL PARAMETERS ------------------- -options - options to pass to the reboot command. e.g. -f +None EXAMPLES diff --git a/cdist/conf/type/__install_reboot/manifest b/cdist/conf/type/__install_reboot/manifest deleted file mode 100755 index 46a6356e..00000000 --- a/cdist/conf/type/__install_reboot/manifest +++ /dev/null @@ -1,25 +0,0 @@ -#!/bin/sh -e -# -# 2011 Steven Armstrong (steven-cdist at armstrong.cc) -# -# This file is part of cdist. -# -# cdist is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# cdist is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with cdist. If not, see . -# - -# set defaults -# TODO is this neccesary or should this be handled using the usual parameter/default workflow? -if [ ! -f "$__object/parameter/options" ]; then - touch "$__object/parameter/options" -fi From 23debd5b6f27bcafd6b91149af9280f4398016df Mon Sep 17 00:00:00 2001 From: Jonas Weber Date: Thu, 4 Oct 2018 19:21:59 +0200 Subject: [PATCH 0102/1217] Use cur_ip in jail for freebsd --- cdist/conf/type/__jail_freebsd10/gencode-remote | 3 +-- cdist/conf/type/__jail_freebsd9/gencode-remote | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/cdist/conf/type/__jail_freebsd10/gencode-remote b/cdist/conf/type/__jail_freebsd10/gencode-remote index 8ce77768..5be04bc6 100755 --- a/cdist/conf/type/__jail_freebsd10/gencode-remote +++ b/cdist/conf/type/__jail_freebsd10/gencode-remote @@ -87,9 +87,8 @@ if [ $(expr "${ip}" : ".*, .*") -gt "0" ]; then SAVE_IFS="$IFS" IFS=", " for cur_ip in ${ip}; do - # TODO BUG? Why is cur_ip unused in the following line? # Just get the last IP address for SSH to listen on - mgmt_ip=$(echo "${ip}" | cut '-d ' -f1) # In case using "ip netmask" format rather than CIDR + mgmt_ip=$(echo "${cur_ip}" | cut '-d ' -f1) # In case using "ip netmask" format rather than CIDR done IFS="$SAVE_IFS" else diff --git a/cdist/conf/type/__jail_freebsd9/gencode-remote b/cdist/conf/type/__jail_freebsd9/gencode-remote index c76bb014..177bdf74 100755 --- a/cdist/conf/type/__jail_freebsd9/gencode-remote +++ b/cdist/conf/type/__jail_freebsd9/gencode-remote @@ -92,9 +92,8 @@ if [ $(expr "${ip}" : ".*|.*") -gt "0" ]; then SAVE_IFS="$IFS" IFS=", " for cur_ip in ${ip}; do - # TODO BUG? Why is cur_ip unused in the following line? # Just get the last IP address for SSH to listen on - mgmt_ip=$(echo "${ip}" | sed -E -e 's/^.*\|(.*)\/[0-9]+$/\1/') + mgmt_ip=$(echo "${cur_ip}" | sed -E -e 's/^.*\|(.*)\/[0-9]+$/\1/') done IFS="$SAVE_IFS" else From ae7ccc59959ce45948bd6b767d8559ff9715cdbf Mon Sep 17 00:00:00 2001 From: Jonas Weber Date: Tue, 2 Oct 2018 21:44:27 +0200 Subject: [PATCH 0103/1217] Fix SC2086 on all scripts Relevant documentation: https://github.com/koalaman/shellcheck/wiki/SC2086 relates to: #540 This commit addresses 241 separate cases of missing quotes around variables. --- cdist/conf/explorer/cpu_cores | 2 +- cdist/conf/explorer/cpu_sockets | 2 +- cdist/conf/explorer/lsb_codename | 2 +- cdist/conf/explorer/lsb_description | 2 +- cdist/conf/explorer/lsb_id | 2 +- cdist/conf/explorer/lsb_release | 2 +- cdist/conf/explorer/os_version | 2 +- cdist/conf/type/__apt_ppa/gencode-remote | 4 ++-- .../type/__ccollect_source/gencode-remote | 16 ++++++------- cdist/conf/type/__ccollect_source/manifest | 2 +- cdist/conf/type/__cron/explorer/entry | 4 ++-- cdist/conf/type/__daemontools/manifest | 4 ++-- .../conf/type/__daemontools_service/manifest | 4 ++-- cdist/conf/type/__directory/gencode-remote | 16 ++++++------- cdist/conf/type/__docker/manifest | 10 ++++---- .../conf/type/__docker_compose/gencode-remote | 4 ++-- cdist/conf/type/__docker_compose/manifest | 4 ++-- cdist/conf/type/__file/gencode-remote | 16 ++++++------- .../conf/type/__firewalld_rule/explorer/rule | 2 +- .../conf/type/__firewalld_rule/gencode-remote | 8 +++---- cdist/conf/type/__git/explorer/group | 2 +- cdist/conf/type/__git/explorer/owner | 2 +- cdist/conf/type/__grafana_dashboard/manifest | 4 ++-- cdist/conf/type/__group/explorer/gshadow | 2 +- cdist/conf/type/__group/gencode-remote | 8 +++---- .../__install_bootloader_grub/gencode-remote | 2 +- .../__install_generate_fstab/gencode-local | 4 ++-- .../gencode-remote | 14 +++++------ cdist/conf/type/__jail/manifest | 2 +- cdist/conf/type/__link/explorer/type | 2 +- .../conf/type/__package/explorer/pkgng_exists | 2 +- .../type/__package_luarocks/gencode-remote | 4 ++-- cdist/conf/type/__package_opkg/gencode-remote | 4 ++-- .../conf/type/__package_pacman/gencode-remote | 4 ++-- .../type/__package_pkg_freebsd/gencode-remote | 2 +- .../type/__package_rubygem/gencode-remote | 4 ++-- .../__package_update_index/explorer/currage | 2 +- .../type/__package_update_index/explorer/type | 2 +- .../__package_update_index/gencode-remote | 2 +- .../type/__package_upgrade_all/gencode-remote | 4 ++-- cdist/conf/type/__package_yum/gencode-remote | 4 ++-- .../conf/type/__package_zypper/gencode-remote | 6 ++--- cdist/conf/type/__pacman_conf/manifest | 24 +++++++++---------- .../type/__pacman_conf_integrate/manifest | 10 ++++---- cdist/conf/type/__pf_apply/explorer/rcvar | 2 +- cdist/conf/type/__pf_ruleset/explorer/cksum | 2 +- cdist/conf/type/__pf_ruleset/explorer/rcvar | 2 +- .../type/__prometheus_alertmanager/manifest | 2 +- .../conf/type/__prometheus_exporter/manifest | 8 +++---- cdist/conf/type/__prometheus_server/manifest | 6 ++--- cdist/conf/type/__pyvenv/explorer/group | 2 +- cdist/conf/type/__pyvenv/explorer/owner | 2 +- cdist/conf/type/__pyvenv/gencode-remote | 2 +- cdist/conf/type/__qemu_img/gencode-remote | 2 +- cdist/conf/type/__rsync/gencode-local | 2 +- cdist/conf/type/__rvm/explorer/state | 2 +- .../type/__ssh_authorized_key/explorer/entry | 2 +- .../type/__ssh_authorized_key/gencode-remote | 2 +- .../conf/type/__start_on_boot/gencode-remote | 10 ++++---- cdist/conf/type/__start_on_boot/manifest | 2 +- cdist/conf/type/__user/explorer/shadow | 2 +- cdist/conf/type/__user/gencode-remote | 6 ++--- cdist/conf/type/__zypper_repo/gencode-remote | 8 +++---- .../__zypper_service/explorer/service_uri | 2 +- .../conf/type/__zypper_service/gencode-remote | 16 ++++++------- 65 files changed, 154 insertions(+), 154 deletions(-) diff --git a/cdist/conf/explorer/cpu_cores b/cdist/conf/explorer/cpu_cores index 2f676f7a..27cc6800 100755 --- a/cdist/conf/explorer/cpu_cores +++ b/cdist/conf/explorer/cpu_cores @@ -31,7 +31,7 @@ case "$os" in *) if [ -r /proc/cpuinfo ]; then cores="$(grep "core id" /proc/cpuinfo | sort | uniq | wc -l)" - if [ ${cores} -eq 0 ]; then + if [ "${cores}" -eq 0 ]; then cores="1" fi echo "$cores" diff --git a/cdist/conf/explorer/cpu_sockets b/cdist/conf/explorer/cpu_sockets index 2d577043..a32e2f00 100755 --- a/cdist/conf/explorer/cpu_sockets +++ b/cdist/conf/explorer/cpu_sockets @@ -31,7 +31,7 @@ case "$os" in *) if [ -r /proc/cpuinfo ]; then sockets="$(grep "physical id" /proc/cpuinfo | sort -u | wc -l)" - if [ ${sockets} -eq 0 ]; then + if [ "${sockets}" -eq 0 ]; then sockets="$(grep -c "processor" /proc/cpuinfo)" fi echo "${sockets}" diff --git a/cdist/conf/explorer/lsb_codename b/cdist/conf/explorer/lsb_codename index eebd3e0f..bfabd444 100755 --- a/cdist/conf/explorer/lsb_codename +++ b/cdist/conf/explorer/lsb_codename @@ -20,7 +20,7 @@ # set +e -case "$($__explorer/os)" in +case "$("$__explorer/os")" in openwrt) (. /etc/openwrt_release && echo "$DISTRIB_CODENAME") ;; diff --git a/cdist/conf/explorer/lsb_description b/cdist/conf/explorer/lsb_description index 23f45421..441fdbf3 100755 --- a/cdist/conf/explorer/lsb_description +++ b/cdist/conf/explorer/lsb_description @@ -20,7 +20,7 @@ # set +e -case "$($__explorer/os)" in +case "$("$__explorer/os")" in openwrt) (. /etc/openwrt_release && echo "$DISTRIB_DESCRIPTION") ;; diff --git a/cdist/conf/explorer/lsb_id b/cdist/conf/explorer/lsb_id index 9754eb63..1a12b610 100755 --- a/cdist/conf/explorer/lsb_id +++ b/cdist/conf/explorer/lsb_id @@ -20,7 +20,7 @@ # set +e -case "$($__explorer/os)" in +case "$("$__explorer/os")" in openwrt) (. /etc/openwrt_release && echo "$DISTRIB_ID") ;; diff --git a/cdist/conf/explorer/lsb_release b/cdist/conf/explorer/lsb_release index 35b5547c..25eb95b1 100755 --- a/cdist/conf/explorer/lsb_release +++ b/cdist/conf/explorer/lsb_release @@ -20,7 +20,7 @@ # set +e -case "$($__explorer/os)" in +case "$("$__explorer/os")" in openwrt) (. /etc/openwrt_release && echo "$DISTRIB_RELEASE") ;; diff --git a/cdist/conf/explorer/os_version b/cdist/conf/explorer/os_version index 380782cc..4c41695b 100755 --- a/cdist/conf/explorer/os_version +++ b/cdist/conf/explorer/os_version @@ -22,7 +22,7 @@ # # -case "$($__explorer/os)" in +case "$("$__explorer/os")" in amazon) cat /etc/system-release ;; diff --git a/cdist/conf/type/__apt_ppa/gencode-remote b/cdist/conf/type/__apt_ppa/gencode-remote index f60cb7ac..25dec58d 100755 --- a/cdist/conf/type/__apt_ppa/gencode-remote +++ b/cdist/conf/type/__apt_ppa/gencode-remote @@ -29,9 +29,9 @@ fi case "$state_should" in present) - echo add-apt-repository \"$name\" + echo "add-apt-repository \"$name\"" ;; absent) - echo remove-apt-repository \"$name\" + echo "remove-apt-repository \"$name\"" ;; esac diff --git a/cdist/conf/type/__ccollect_source/gencode-remote b/cdist/conf/type/__ccollect_source/gencode-remote index 763f219e..5f2f97e3 100755 --- a/cdist/conf/type/__ccollect_source/gencode-remote +++ b/cdist/conf/type/__ccollect_source/gencode-remote @@ -42,18 +42,18 @@ get_current_value() { } set_group() { - echo chgrp \"$1\" \"$destination\" - echo chgrp $1 >> "$__messages_out" + echo chgrp \""$1"\" \""$destination"\" + echo chgrp "$1" >> "$__messages_out" } set_owner() { - echo chown \"$1\" \"$destination\" - echo chown $1 >> "$__messages_out" + echo chown \""$1"\" \""$destination"\" + echo chown "$1" >> "$__messages_out" } set_mode() { - echo chmod \"$1\" \"$destination\" - echo chmod $1 >> "$__messages_out" + echo chmod \""$1"\" \""$destination"\" + echo chmod "$1" >> "$__messages_out" } set_attributes= @@ -67,7 +67,7 @@ case "$state_should" in # change 0xxx format to xxx format => same as stat returns if [ "$attribute" = mode ]; then - value_should="$(echo $value_should | sed 's/^0\(...\)/\1/')" + value_should="$(echo "$value_should" | sed 's/^0\(...\)/\1/')" fi value_is="$(get_current_value "$attribute" "$value_should")" @@ -81,7 +81,7 @@ case "$state_should" in absent) if [ "$type" = "file" ]; then - echo rm -f \"$destination\" + echo rm -f \""$destination"\" echo remove >> "$__messages_out" fi ;; diff --git a/cdist/conf/type/__ccollect_source/manifest b/cdist/conf/type/__ccollect_source/manifest index 26c6cc99..727a4c97 100755 --- a/cdist/conf/type/__ccollect_source/manifest +++ b/cdist/conf/type/__ccollect_source/manifest @@ -55,5 +55,5 @@ if [ -f "$__object/parameter/exclude" ]; then fi if [ -f "$__object/parameter/create-destination" ]; then - __directory "${destination}" --parents --state ${state} + __directory "${destination}" --parents --state "${state}" fi diff --git a/cdist/conf/type/__cron/explorer/entry b/cdist/conf/type/__cron/explorer/entry index 2167e045..801861a3 100644 --- a/cdist/conf/type/__cron/explorer/entry +++ b/cdist/conf/type/__cron/explorer/entry @@ -24,7 +24,7 @@ user="$(cat "$__object/parameter/user")" if [ -f "$__object/parameter/raw_command" ]; then command="$(cat "$__object/parameter/command")" - crontab -u $user -l 2>/dev/null | grep "^$command\$" || true + crontab -u "$user" -l 2>/dev/null | grep "^$command\$" || true else - crontab -u $user -l 2>/dev/null | grep "# $name\$" || true + crontab -u "$user" -l 2>/dev/null | grep "# $name\$" || true fi diff --git a/cdist/conf/type/__daemontools/manifest b/cdist/conf/type/__daemontools/manifest index 45ce3df6..656f4984 100755 --- a/cdist/conf/type/__daemontools/manifest +++ b/cdist/conf/type/__daemontools/manifest @@ -3,8 +3,8 @@ pkg=$(cat "$__object/parameter/from-package") servicedir=$(cat "$__object/parameter/servicedir") -__package $pkg -__directory $servicedir --mode 700 +__package "$pkg" +__directory "$servicedir" --mode 700 os=$(cat "$__global/explorer/os") init=$(cat "$__global/explorer/init") diff --git a/cdist/conf/type/__daemontools_service/manifest b/cdist/conf/type/__daemontools_service/manifest index 9e8e0bee..78bae285 100755 --- a/cdist/conf/type/__daemontools_service/manifest +++ b/cdist/conf/type/__daemontools_service/manifest @@ -25,14 +25,14 @@ badusage() { [ -z "$run$runfile" ] && badusage [ -n "$run" ] && [ -n "$runfile" ] && badusage -__directory $servicedir/$name/log/main --parents +__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 \ +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/__directory/gencode-remote b/cdist/conf/type/__directory/gencode-remote index cced4624..35866eb4 100755 --- a/cdist/conf/type/__directory/gencode-remote +++ b/cdist/conf/type/__directory/gencode-remote @@ -57,18 +57,18 @@ get_current_value() { } set_group() { - echo chgrp $recursive \"$1\" \"$destination\" - echo chgrp $recursive $1 >> "$__messages_out" + echo chgrp "$recursive" \""$1"\" \""$destination"\" + echo chgrp "$recursive" "$1" >> "$__messages_out" } set_owner() { - echo chown $recursive \"$1\" \"$destination\" - echo chown $recursive $1 >> "$__messages_out" + echo chown "$recursive" \""$1"\" \""$destination"\" + echo chown "$recursive" "$1" >> "$__messages_out" } set_mode() { - echo chmod $recursive \"$1\" \"$destination\" - echo chmod $recursive $1 >> "$__messages_out" + echo chmod "$recursive" \""$1"\" \""$destination"\" + echo chmod "$recursive" "$1" >> "$__messages_out" } case "$state_should" in @@ -94,7 +94,7 @@ case "$state_should" in # change 0xxx format to xxx format => same as stat returns if [ "$attribute" = mode ]; then - value_should="$(echo $value_should | sed 's/^0\(...\)/\1/')" + value_should="$(echo "$value_should" | sed 's/^0\(...\)/\1/')" fi if [ "$set_attributes" = 1 ] || [ "$value_should" != "$value_is" ]; then @@ -105,7 +105,7 @@ case "$state_should" in ;; absent) if [ "$type" = "directory" ]; then - echo rm -rf \"$destination\" + echo rm -rf \""$destination"\" echo remove >> "$__messages_out" fi ;; diff --git a/cdist/conf/type/__docker/manifest b/cdist/conf/type/__docker/manifest index e0558b46..35760cef 100755 --- a/cdist/conf/type/__docker/manifest +++ b/cdist/conf/type/__docker/manifest @@ -31,8 +31,8 @@ case "$os" in --enabled \ --gpgcheck 1 \ --gpgkey 'https://download.docker.com/linux/centos/gpg' \ - --state ${state} - require="__yum_repo/docker-ce-stable" __package docker-ce --state ${state} + --state "${state}" + require="__yum_repo/docker-ce-stable" __package docker-ce --state "${state}" else echo "CentOS version 7 is required!" >&2 exit 1 @@ -45,14 +45,14 @@ case "$os" in __package gnupg2 fi __apt_key_uri docker --name "Docker Release (CE deb) " \ - --uri "https://download.docker.com/linux/${os}/gpg" --state ${state} + --uri "https://download.docker.com/linux/${os}/gpg" --state "${state}" export CDIST_ORDER_DEPENDENCY=on __apt_source docker \ --uri "https://download.docker.com/linux/${os}" \ --distribution "$(cat "$__global/explorer/lsb_codename")" \ - --state ${state} \ + --state "${state}" \ --component "stable" - __package docker-ce --state ${state} + __package docker-ce --state "${state}" unset CDIST_ORDER_DEPENDENCY ;; *) diff --git a/cdist/conf/type/__docker_compose/gencode-remote b/cdist/conf/type/__docker_compose/gencode-remote index 2b8267a9..396c93ac 100755 --- a/cdist/conf/type/__docker_compose/gencode-remote +++ b/cdist/conf/type/__docker_compose/gencode-remote @@ -22,9 +22,9 @@ version="$(cat "$__object/parameter/version")" state="$(cat "$__object/parameter/state")" -if [ ${state} = "present" ]; then +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 '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' diff --git a/cdist/conf/type/__docker_compose/manifest b/cdist/conf/type/__docker_compose/manifest index c17f0f33..f7de3a76 100755 --- a/cdist/conf/type/__docker_compose/manifest +++ b/cdist/conf/type/__docker_compose/manifest @@ -22,10 +22,10 @@ state="$(cat "$__object/parameter/state")" # Needed packages -if [ ${state} = "present" ]; then +if [ "${state}" = "present" ]; then __docker __package curl -elif [ ${state} = "absent" ]; then +elif [ "${state}" = "absent" ]; then __file /usr/local/bin/docker-compose --state absent else echo "Unknown state: ${state}" >&2 diff --git a/cdist/conf/type/__file/gencode-remote b/cdist/conf/type/__file/gencode-remote index 9dfd1833..ebc30fd9 100755 --- a/cdist/conf/type/__file/gencode-remote +++ b/cdist/conf/type/__file/gencode-remote @@ -43,18 +43,18 @@ get_current_value() { } set_group() { - echo chgrp \"$1\" \"$destination\" - echo chgrp $1 >> "$__messages_out" + echo chgrp \""$1"\" \""$destination"\" + echo chgrp "$1" >> "$__messages_out" } set_owner() { - echo chown \"$1\" \"$destination\" - echo chown $1 >> "$__messages_out" + echo chown \""$1"\" \""$destination"\" + echo chown "$1" >> "$__messages_out" } set_mode() { - echo chmod \"$1\" \"$destination\" - echo chmod $1 >> "$__messages_out" + echo chmod \""$1"\" \""$destination"\" + echo chmod "$1" >> "$__messages_out" } set_attributes= @@ -68,7 +68,7 @@ case "$state_should" in # change 0xxx format to xxx format => same as stat returns if [ "$attribute" = mode ]; then - value_should="$(echo $value_should | sed 's/^0\(...\)/\1/')" + value_should="$(echo "$value_should" | sed 's/^0\(...\)/\1/')" fi value_is="$(get_current_value "$attribute" "$value_should")" @@ -82,7 +82,7 @@ case "$state_should" in absent) if [ "$type" = "file" ]; then - echo rm -f \"$destination\" + echo rm -f \""$destination"\" echo remove >> "$__messages_out" fi ;; diff --git a/cdist/conf/type/__firewalld_rule/explorer/rule b/cdist/conf/type/__firewalld_rule/explorer/rule index 5a0e0265..0234e5b6 100644 --- a/cdist/conf/type/__firewalld_rule/explorer/rule +++ b/cdist/conf/type/__firewalld_rule/explorer/rule @@ -25,7 +25,7 @@ chain="$(cat "$__object/parameter/chain")" priority="$(cat "$__object/parameter/priority")" rule="$(cat "$__object/parameter/rule")" -if firewall-cmd --permanent --direct --query-rule "$protocol" "$table" "$chain" "$priority" $rule >/dev/null; then +if firewall-cmd --permanent --direct --query-rule "$protocol" "$table" "$chain" "$priority" "$rule" >/dev/null; then echo present else echo absent diff --git a/cdist/conf/type/__firewalld_rule/gencode-remote b/cdist/conf/type/__firewalld_rule/gencode-remote index 4c824d39..bc218d9a 100755 --- a/cdist/conf/type/__firewalld_rule/gencode-remote +++ b/cdist/conf/type/__firewalld_rule/gencode-remote @@ -33,13 +33,13 @@ rule="$(cat "$__object/parameter/rule")" case "$state_should" in present) - echo firewall-cmd --quiet --permanent --direct --add-rule \"$protocol\" \"$table\" \"$chain\" \"$priority\" $rule - echo firewall-cmd --quiet --direct --add-rule \"$protocol\" \"$table\" \"$chain\" \"$priority\" $rule + echo "firewall-cmd --quiet --permanent --direct --add-rule \"$protocol\" \"$table\" \"$chain\" \"$priority\" $rule" + echo "firewall-cmd --quiet --direct --add-rule \"$protocol\" \"$table\" \"$chain\" \"$priority\" $rule" ;; absent) - echo firewall-cmd --quiet --permanent --direct --remove-rule \"$protocol\" \"$table\" \"$chain\" \"$priority\" $rule - echo firewall-cmd --quiet --direct --remove-rule \"$protocol\" \"$table\" \"$chain\" \"$priority\" $rule + echo "firewall-cmd --quiet --permanent --direct --remove-rule \"$protocol\" \"$table\" \"$chain\" \"$priority\" $rule" + echo "firewall-cmd --quiet --direct --remove-rule \"$protocol\" \"$table\" \"$chain\" \"$priority\" $rule" ;; *) echo "Unknown state $state_should" >&2 diff --git a/cdist/conf/type/__git/explorer/group b/cdist/conf/type/__git/explorer/group index 1308c710..3ddf9656 100644 --- a/cdist/conf/type/__git/explorer/group +++ b/cdist/conf/type/__git/explorer/group @@ -2,4 +2,4 @@ destination="/$__object_id/.git" -stat --print "%G" ${destination} 2>/dev/null || exit 0 +stat --print "%G" "${destination}" 2>/dev/null || exit 0 diff --git a/cdist/conf/type/__git/explorer/owner b/cdist/conf/type/__git/explorer/owner index 8c36b035..4c3cd431 100644 --- a/cdist/conf/type/__git/explorer/owner +++ b/cdist/conf/type/__git/explorer/owner @@ -2,4 +2,4 @@ destination="/$__object_id/.git" -stat --print "%U" ${destination} 2>/dev/null || exit 0 +stat --print "%U" "${destination}" 2>/dev/null || exit 0 diff --git a/cdist/conf/type/__grafana_dashboard/manifest b/cdist/conf/type/__grafana_dashboard/manifest index 308af59a..2e9bd115 100755 --- a/cdist/conf/type/__grafana_dashboard/manifest +++ b/cdist/conf/type/__grafana_dashboard/manifest @@ -1,7 +1,7 @@ #!/bin/sh -e -os=$(cat $__global/explorer/os) -os_version=$(cat $__global/explorer/os_version) +os=$(cat "$__global/explorer/os") +os_version=$(cat "$__global/explorer/os_version") case $os in debian|devuan) diff --git a/cdist/conf/type/__group/explorer/gshadow b/cdist/conf/type/__group/explorer/gshadow index 2e2ab29d..ef40b7bc 100755 --- a/cdist/conf/type/__group/explorer/gshadow +++ b/cdist/conf/type/__group/explorer/gshadow @@ -22,7 +22,7 @@ # name=$__object_id -os="$($__explorer/os)" +os="$("$__explorer/os")" case "$os" in "freebsd"|"netbsd") diff --git a/cdist/conf/type/__group/gencode-remote b/cdist/conf/type/__group/gencode-remote index 68475178..5b3947dc 100755 --- a/cdist/conf/type/__group/gencode-remote +++ b/cdist/conf/type/__group/gencode-remote @@ -63,8 +63,8 @@ if [ "$state" = "present" ]; then ;; esac if [ "$new_value" != "$current_value" ]; then - set -- "$@" "$(shorten_property $property)" \'$new_value\' - echo change $property $new_value $current_value >> "$__messages_out" + set -- "$@" "$(shorten_property "$property")" \'"$new_value"\' + echo "change $property $new_value $current_value" >> "$__messages_out" fi fi done @@ -83,9 +83,9 @@ if [ "$state" = "present" ]; then new_value="$(cat "$__object/parameter/$property")" if [ -z "$new_value" ]; then # Boolean parameters have no value - set -- "$@" "$(shorten_property $property)" + set -- "$@" "$(shorten_property "$property")" else - set -- "$@" "$(shorten_property $property)" \'$new_value\' + set -- "$@" "$(shorten_property "$property")" \'"$new_value"\' fi fi done diff --git a/cdist/conf/type/__install_bootloader_grub/gencode-remote b/cdist/conf/type/__install_bootloader_grub/gencode-remote index 6e6e5e85..1caebbbf 100755 --- a/cdist/conf/type/__install_bootloader_grub/gencode-remote +++ b/cdist/conf/type/__install_bootloader_grub/gencode-remote @@ -28,7 +28,7 @@ install_script="$__object/files/install_script" # Link file descriptor #6 with stdout exec 6>&1 # Link stdout with $install_script -exec > $install_script +exec > "$install_script" # Generate script to install bootloader on distro printf '#!/bin/sh -l\n' diff --git a/cdist/conf/type/__install_generate_fstab/gencode-local b/cdist/conf/type/__install_generate_fstab/gencode-local index 5cc7d877..d0f99f61 100755 --- a/cdist/conf/type/__install_generate_fstab/gencode-local +++ b/cdist/conf/type/__install_generate_fstab/gencode-local @@ -23,7 +23,7 @@ cat "$__type/files/fstab.header" > "$destination" mkdir "$__object/files" # get current UUID's from target_host -$__remote_exec $__target_host blkid > "$__object/files/blkid" +$__remote_exec "$__target_host" blkid > "$__object/files/blkid" for object in $(find "$__global/object/__install_mount" -type d -name "$__cdist_object_marker"); do device="$(cat "$object/parameter/device")" @@ -54,7 +54,7 @@ for object in $(find "$__global/object/__install_mount" -type d -name "$__cdist_ ;; esac if [ -f "$__object/parameter/uuid" ]; then - uuid="$(grep -w $device "$__object/files/blkid" | awk '{print $2}')" + uuid="$(grep -w "$device" "$__object/files/blkid" | awk '{print $2}')" if [ -n "$uuid" ]; then echo "# $dir was on $device during installation" >> "$destination" device="$uuid" diff --git a/cdist/conf/type/__install_partition_msdos_apply/gencode-remote b/cdist/conf/type/__install_partition_msdos_apply/gencode-remote index 9e5fcd00..b8100c52 100755 --- a/cdist/conf/type/__install_partition_msdos_apply/gencode-remote +++ b/cdist/conf/type/__install_partition_msdos_apply/gencode-remote @@ -34,9 +34,9 @@ size_to_mb() { size=$1 available_size="$2" - number_suffix="$(echo ${size} | sed -e 's:\.[0-9]\+::' -e 's:\([0-9]\+\)\([KkMmGg%]\)[Bb]\?:\1|\2:')" - number="$(echo ${number_suffix} | cut -d '|' -f1)" - suffix="$(echo ${number_suffix} | cut -d '|' -f2)" + number_suffix="$(echo "${size}" | sed -e 's:\.[0-9]\+::' -e 's:\([0-9]\+\)\([KkMmGg%]\)[Bb]\?:\1|\2:')" + number="$(echo "${number_suffix}" | cut -d '|' -f1)" + suffix="$(echo "${number_suffix}" | cut -d '|' -f2)" case "$suffix" in K|k) @@ -62,10 +62,10 @@ get_objects() { for object in $(find "$__global/object/__install_partition_msdos" -type d -name "$__cdist_object_marker"); do object_device="$(cat "$object/parameter/device")" object_minor="$(cat "$object/parameter/minor")" - echo "$object_device $object_minor $object" >> $objects_file + echo "$object_device $object_minor $object" >> "$objects_file" done - sort -k 1,2 $objects_file | cut -d' ' -f 3 - rm $objects_file + sort -k 1,2 "$objects_file" | cut -d' ' -f 3 + rm "$objects_file" unset objects_file unset object unset object_device @@ -87,7 +87,7 @@ for object in $objects; do if [ "$current_device" != "$device" ]; then echo "create_disklabel \"$device\" || die 'Failed to create disklabel for $device'" current_device="$device" - device_name=$(echo ${device} | sed -e 's:^/dev/::;s:/:\\/:g') + device_name=$(echo "${device}" | sed -e 's:^/dev/::;s:/:\\/:g') available_device_size=$(( $(awk "/${device_name}\$/ { print \$3; }" "$partitions") / 1024)) # make sure we don't go past the end of the drive available_device_size=$((available_device_size - 2)) diff --git a/cdist/conf/type/__jail/manifest b/cdist/conf/type/__jail/manifest index 7564be26..222cb859 100755 --- a/cdist/conf/type/__jail/manifest +++ b/cdist/conf/type/__jail/manifest @@ -35,7 +35,7 @@ fi jaildir="$(cat "$__object/parameter/jaildir")" -__directory ${jaildir} --parents +__directory "${jaildir}" --parents set -- "$@" "$__object_id" "--state" "$state" cd "$__object/parameter" diff --git a/cdist/conf/type/__link/explorer/type b/cdist/conf/type/__link/explorer/type index 579fd081..48a79bf0 100755 --- a/cdist/conf/type/__link/explorer/type +++ b/cdist/conf/type/__link/explorer/type @@ -32,7 +32,7 @@ elif [ -f "$destination" ]; then case "$type" in hard) link_count=$(ls -l "$destination" | awk '{ print $2 }') - if [ $link_count -gt 1 ]; then + if [ "$link_count" -gt 1 ]; then echo hardlink exit 0 fi diff --git a/cdist/conf/type/__package/explorer/pkgng_exists b/cdist/conf/type/__package/explorer/pkgng_exists index 355c5d65..6d69ba14 100755 --- a/cdist/conf/type/__package/explorer/pkgng_exists +++ b/cdist/conf/type/__package/explorer/pkgng_exists @@ -21,7 +21,7 @@ # Retrieve the status of a package - parsed dpkg output # -if [ "$($__explorer/os)" = "freebsd" ]; then +if [ "$("$__explorer/os")" = "freebsd" ]; then command -v pkg fi diff --git a/cdist/conf/type/__package_luarocks/gencode-remote b/cdist/conf/type/__package_luarocks/gencode-remote index cae06b22..e14d7a8e 100755 --- a/cdist/conf/type/__package_luarocks/gencode-remote +++ b/cdist/conf/type/__package_luarocks/gencode-remote @@ -42,10 +42,10 @@ fi case "$state_should" in present) - echo luarocks install \"$name\" + echo luarocks install \""$name"\" ;; absent) - echo luarocks remove \"$name\" + echo luarocks remove \""$name"\" ;; *) echo "Unknown state: $state_should" >&2 diff --git a/cdist/conf/type/__package_opkg/gencode-remote b/cdist/conf/type/__package_opkg/gencode-remote index 09fe69a4..53f154a5 100755 --- a/cdist/conf/type/__package_opkg/gencode-remote +++ b/cdist/conf/type/__package_opkg/gencode-remote @@ -45,10 +45,10 @@ case "$state_should" in if [ "$present" = "notpresent" ]; then echo opkg --verbosity=0 update fi - echo opkg --verbosity=0 install \"$name\" + echo opkg --verbosity=0 install \""$name"\" ;; absent) - echo opkg --verbosity=0 remove \"$name\" + echo opkg --verbosity=0 remove \""$name"\" ;; *) echo "Unknown state: $state" >&2 diff --git a/cdist/conf/type/__package_pacman/gencode-remote b/cdist/conf/type/__package_pacman/gencode-remote index 69a5d62a..43649124 100755 --- a/cdist/conf/type/__package_pacman/gencode-remote +++ b/cdist/conf/type/__package_pacman/gencode-remote @@ -45,10 +45,10 @@ fi case "$state_should" in present) - echo pacman --needed --noconfirm --noprogressbar -S \"$name\" + echo pacman --needed --noconfirm --noprogressbar -S \""$name"\" ;; absent) - echo pacman --noconfirm --noprogressbar -R \"$name\" + echo pacman --noconfirm --noprogressbar -R \""$name"\" ;; *) echo "Unknown state: $state_should" >&2 diff --git a/cdist/conf/type/__package_pkg_freebsd/gencode-remote b/cdist/conf/type/__package_pkg_freebsd/gencode-remote index 012bf2ad..6c6e15b1 100755 --- a/cdist/conf/type/__package_pkg_freebsd/gencode-remote +++ b/cdist/conf/type/__package_pkg_freebsd/gencode-remote @@ -33,7 +33,7 @@ assert () # If condition false, lineno=$2 - if [ ! $1 ] + if [ ! "$1" ] then echo "Assertion failed: \"$1\"" echo "File \"$0\", line $lineno, called by $(caller 0)" diff --git a/cdist/conf/type/__package_rubygem/gencode-remote b/cdist/conf/type/__package_rubygem/gencode-remote index 6d793ac0..d474db20 100755 --- a/cdist/conf/type/__package_rubygem/gencode-remote +++ b/cdist/conf/type/__package_rubygem/gencode-remote @@ -39,10 +39,10 @@ fi case "$state_should" in present) - echo gem install \"$name\" --no-ri --no-rdoc + echo gem install \""$name"\" --no-ri --no-rdoc ;; absent) - echo gem uninstall \"$name\" + echo gem uninstall \""$name"\" ;; *) echo "Unknown state: $state_should" >&2 diff --git a/cdist/conf/type/__package_update_index/explorer/currage b/cdist/conf/type/__package_update_index/explorer/currage index 50474fb3..3539b8e1 100644 --- a/cdist/conf/type/__package_update_index/explorer/currage +++ b/cdist/conf/type/__package_update_index/explorer/currage @@ -17,7 +17,7 @@ # You should have received a copy of the GNU General Public License # along with cdist. If not, see . -type="$($__type_explorer/type)" +type="$("$__type_explorer/type")" case "$type" in apt) diff --git a/cdist/conf/type/__package_update_index/explorer/type b/cdist/conf/type/__package_update_index/explorer/type index 805b9f04..35254c5f 100644 --- a/cdist/conf/type/__package_update_index/explorer/type +++ b/cdist/conf/type/__package_update_index/explorer/type @@ -21,7 +21,7 @@ if [ -f "$__object/parameter/type" ]; then cat "$__object/parameter/type" else # By default determine package manager based on operating system - os="$($__explorer/os)" + os="$("$__explorer/os")" case "$os" in amazon|scientific|centos|fedora|redhat) echo "yum" ;; debian|ubuntu|devuan) echo "apt" ;; diff --git a/cdist/conf/type/__package_update_index/gencode-remote b/cdist/conf/type/__package_update_index/gencode-remote index 8589c6d1..738d38eb 100755 --- a/cdist/conf/type/__package_update_index/gencode-remote +++ b/cdist/conf/type/__package_update_index/gencode-remote @@ -31,7 +31,7 @@ if [ -n "$maxage" ]; then if [ "$type" != "apt" ] && [ "$type" != "pacman" ]; then echo "ERROR: \"--maxage\" only supported for \"apt\" or \"pacman\" pkg-manager." >&2 exit 1 - elif [ $currage -lt $maxage ]; then + elif [ "$currage" -lt "$maxage" ]; then exit 0 # no need to update fi fi diff --git a/cdist/conf/type/__package_upgrade_all/gencode-remote b/cdist/conf/type/__package_upgrade_all/gencode-remote index bcad8a43..38aa001e 100755 --- a/cdist/conf/type/__package_upgrade_all/gencode-remote +++ b/cdist/conf/type/__package_upgrade_all/gencode-remote @@ -53,8 +53,8 @@ case "$type" in ;; apt) if [ -f "$apt_dist_upgrade" ] - then echo $aptget dist-upgrade - else echo $aptget upgrade + then echo "$aptget dist-upgrade" + else echo "$aptget upgrade" fi if [ -f "$apt_clean" ] diff --git a/cdist/conf/type/__package_yum/gencode-remote b/cdist/conf/type/__package_yum/gencode-remote index e1323dea..d860c48c 100755 --- a/cdist/conf/type/__package_yum/gencode-remote +++ b/cdist/conf/type/__package_yum/gencode-remote @@ -60,10 +60,10 @@ fi case "$state_should" in present) - echo yum $opts install \"$install_name\" + echo "yum $opts install \"$install_name\"" ;; absent) - echo yum $opts remove \"$name\" + echo "yum $opts remove \"$name\"" ;; *) echo "Unknown state: $state_should" >&2 diff --git a/cdist/conf/type/__package_zypper/gencode-remote b/cdist/conf/type/__package_zypper/gencode-remote index d9372b6d..5b1b763e 100755 --- a/cdist/conf/type/__package_zypper/gencode-remote +++ b/cdist/conf/type/__package_zypper/gencode-remote @@ -61,15 +61,15 @@ case "$state_should" in present) if [ -z "$version_should" ]; then [ "$state_is" = "present" ] && exit 0 # if state is present, we dont need to do anything - echo zypper $globalopts install --type \"$ptype\" --auto-agree-with-licenses \"$name\" ">/dev/null" + echo "zypper $globalopts install --type \"$ptype\" --auto-agree-with-licenses \"$name\" >/dev/null" else [ "$state_is" = "present" ] && [ "$version_should" = "$version_is" ] && exit 0 # if state is present and version is correct, we dont need to do anything - echo zypper $globalopts install --oldpackage --type \"$ptype\" --auto-agree-with-licenses \"$name\" = \"$version_should\" ">/dev/null" + echo "zypper $globalopts install --oldpackage --type \"$ptype\" --auto-agree-with-licenses \"$name\" = \"$version_should\" >/dev/null" fi ;; absent) [ "$state_is" = "absent" ] && exit 0 # if state is absent, we dont need to do anything - echo zypper $globalopts remove --type \"$ptype\" \"$name\" ">/dev/null" + echo "zypper $globalopts remove --type \"$ptype\" \"$name\" >/dev/null" ;; *) echo "Unknown state: $state_should" >&2 diff --git a/cdist/conf/type/__pacman_conf/manifest b/cdist/conf/type/__pacman_conf/manifest index 1561d613..a43f18a1 100755 --- a/cdist/conf/type/__pacman_conf/manifest +++ b/cdist/conf/type/__pacman_conf/manifest @@ -59,13 +59,13 @@ if [ "${file}" ]; then if [ "${state}" = "present" ]; then - require="__file/${sec_path}/plain_file_${file}" __key_value ${file}_${key}\ - --file ${sec_path}/plain_file_${file} --key ${key} --value ${value} --delimiter ' = ' + require="__file/${sec_path}/plain_file_${file}" __key_value "${file}_${key}" \ + --file "${sec_path}/plain_file_${file}" --key "${key}" --value "${value}" --delimiter ' = ' exit 0 elif [ "${state}" = "absent" ]; then - require="__file/${sec_path}/plain_file_${file}" __key_value ${file}_${key}\ + require="__file/${sec_path}/plain_file_${file}" __key_value "${file}_${key}" \ --state absent exit 0 @@ -87,19 +87,19 @@ eof if [ "${MATCH}" -eq 1 ]; then if [ "${value}" = "on" ]; then - require="__file/${sec_path}/${section}" __line ${key}_${value}\ - --file ${sec_path}/${section} --line ${key} + require="__file/${sec_path}/${section}" __line "${key}_${value}" \ + --file "${sec_path}/${section}" --line "${key}" elif [ "${value}" = "off" ]; then - require="__file/${sec_path}/${section}" __line ${key}_${value}\ - --file ${sec_path}/${section} --line ${key} --state absent + require="__file/${sec_path}/${section}" __line "${key}_${value}" \ + --file "${sec_path}/${section}" --line "${key}" --state absent fi else contains_element "${key}" "${allowed_option_keys}" if [ "${MATCH}" -eq 1 ]; then - require="__file/${sec_path}/${section}" __key_value ${section}_${key}\ - --file ${sec_path}/${section} --key ${key} --value ${value} --delimiter ' = ' + require="__file/${sec_path}/${section}" __key_value "${section}_${key}" \ + --file "${sec_path}/${section}" --key "${key}" --value "${value}" --delimiter ' = ' else echo "Key: ${key} is not valid. Have a look at man pacman.conf" >&2 fi @@ -118,12 +118,12 @@ eof exit fi - require="__file/${sec_path}/repo_${section}" __key_value ${section}_${key}\ - --file ${sec_path}/repo_${section} --key ${key} --value ${value} --delimiter ' = ' + require="__file/${sec_path}/repo_${section}" __key_value "${section}_${key}" \ + --file "${sec_path}/repo_${section}" --key "${key}" --value "${value}" --delimiter ' = ' elif [ "${state}" = "absent" ]; then - require="__file/${sec_path}/repo_${section}" __key_value ${section}_${key}\ + require="__file/${sec_path}/repo_${section}" __key_value "${section}_${key}" \ --state absent else diff --git a/cdist/conf/type/__pacman_conf_integrate/manifest b/cdist/conf/type/__pacman_conf_integrate/manifest index b26bca50..884af74d 100755 --- a/cdist/conf/type/__pacman_conf_integrate/manifest +++ b/cdist/conf/type/__pacman_conf_integrate/manifest @@ -18,16 +18,16 @@ # along with cdist. If not, see . # -state=$(cat $__object/parameter/state 2>/dev/null) +state=$(cat "$__object/parameter/state" 2>/dev/null) path="/etc/" if [ "${state}" = "present" ]; then __file /etc/pacman.conf\ - --owner root --group root --mode 644 --source $__type/files/pacman.conf.cdist + --owner root --group root --mode 644 --source "$__type/files/pacman.conf.cdist" __file /etc/pacman.d/options\ - --owner root --group root --mode 644 --source $__type/files/options + --owner root --group root --mode 644 --source "$__type/files/options" __file /etc/pacman.d/repo_empty_placeholder\ --owner root --group root --mode 644 @@ -38,10 +38,10 @@ if [ "${state}" = "present" ]; then elif [ "${state}" = "absent" ]; then __file /etc/pacman.conf\ - --owner root --group root --mode 644 --source $__type/files/pacman.conf.pacman + --owner root --group root --mode 644 --source "$__type/files/pacman.conf.pacman" __file /etc/pacman.d/mirrorlist\ - --owner root --group root --mode 644 --source $__type/files/mirrorlist + --owner root --group root --mode 644 --source "$__type/files/mirrorlist" __file /etc/pacman.d/options\ --state absent diff --git a/cdist/conf/type/__pf_apply/explorer/rcvar b/cdist/conf/type/__pf_apply/explorer/rcvar index 20e9dfcc..7c8d535f 100755 --- a/cdist/conf/type/__pf_apply/explorer/rcvar +++ b/cdist/conf/type/__pf_apply/explorer/rcvar @@ -29,7 +29,7 @@ RC="/etc/rc.conf" PFCONF="$(grep '^pf_rules=' ${RC} | cut -d= -f2 | sed 's/"//g')" -echo ${PFCONF:-"/etc/pf.conf"} +echo "${PFCONF:-"/etc/pf.conf"}" # Debug #set +x diff --git a/cdist/conf/type/__pf_ruleset/explorer/cksum b/cdist/conf/type/__pf_ruleset/explorer/cksum index f8679836..9be6c901 100755 --- a/cdist/conf/type/__pf_ruleset/explorer/cksum +++ b/cdist/conf/type/__pf_ruleset/explorer/cksum @@ -33,7 +33,7 @@ TMP="$(grep '^pf_rules=' ${RC} | cut -d= -f2 | sed 's/"//g')" PFCONF="${TMP:-"/etc/pf.conf"}" if [ -f "${PFCONF}" ]; then # The pf config file exists, find its cksum. - cksum -o 1 ${PFCONF} | cut -d= -f2 | awk '{print $1}' + cksum -o 1 "${PFCONF}" | cut -d= -f2 | awk '{print $1}' fi # Debug diff --git a/cdist/conf/type/__pf_ruleset/explorer/rcvar b/cdist/conf/type/__pf_ruleset/explorer/rcvar index 20e9dfcc..7c8d535f 100755 --- a/cdist/conf/type/__pf_ruleset/explorer/rcvar +++ b/cdist/conf/type/__pf_ruleset/explorer/rcvar @@ -29,7 +29,7 @@ RC="/etc/rc.conf" PFCONF="$(grep '^pf_rules=' ${RC} | cut -d= -f2 | sed 's/"//g')" -echo ${PFCONF:-"/etc/pf.conf"} +echo "${PFCONF:-"/etc/pf.conf"}" # Debug #set +x diff --git a/cdist/conf/type/__prometheus_alertmanager/manifest b/cdist/conf/type/__prometheus_alertmanager/manifest index 054e44cb..3f417526 100755 --- a/cdist/conf/type/__prometheus_alertmanager/manifest +++ b/cdist/conf/type/__prometheus_alertmanager/manifest @@ -57,7 +57,7 @@ __key_value alertmanager_args --file /etc/default/prometheus-alertmanager \ require="$require __directory/$storage_path $require_pkg" \ __config_file $CONF \ - --source $config \ + --source "$config" \ --group prometheus --mode 640 \ --onchange "service prometheus-alertmanager reload" # TODO when a config-check tool is available, check config here diff --git a/cdist/conf/type/__prometheus_exporter/manifest b/cdist/conf/type/__prometheus_exporter/manifest index ae4ed94a..35e654e2 100644 --- a/cdist/conf/type/__prometheus_exporter/manifest +++ b/cdist/conf/type/__prometheus_exporter/manifest @@ -2,7 +2,7 @@ export GOBIN=/opt/gocode/bin # where to find go binaries -exporter="$(cat $__object/parameter/exporter)" +exporter="$(cat "$__object/parameter/exporter")" [ -z "$exporter" ] && exporter="$__object_id" __user prometheus --system @@ -18,7 +18,7 @@ case $exporter in ;; blackbox) require="$require __daemontools_service/${exporter}-exporter __user/prometheus" __config_file "/service/${exporter}-exporter/blackbox.yml" \ - --source $__type/files/blackbox.yml \ + --source "$__type/files/blackbox.yml" \ --group prometheus --mode 640 \ --onchange "svc -h /service/${exporter}-exporter" require="$require __golang_from_vendor" __go_get github.com/prometheus/blackbox_exporter @@ -39,9 +39,9 @@ case $exporter in ;; esac -require="$require __daemontools" __daemontools_service ${exporter}-exporter --run "$run" +require="$require __daemontools" __daemontools_service "${exporter}-exporter" --run "$run" if [ -f "$__object/parameter/add-consul-service" ]; then - __consul_service ${exporter}-exporter --port $port --check-http "http://localhost:$port/metrics" --check-interval 10s + __consul_service "${exporter}-exporter" --port "$port" --check-http "http://localhost:$port/metrics" --check-interval 10s fi #__daemontools --install-init-script diff --git a/cdist/conf/type/__prometheus_server/manifest b/cdist/conf/type/__prometheus_server/manifest index e2f32fd5..63b7b438 100755 --- a/cdist/conf/type/__prometheus_server/manifest +++ b/cdist/conf/type/__prometheus_server/manifest @@ -13,7 +13,7 @@ storage_path="$(cat "$__object/parameter/storage-path")" 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)) +[ "$target_heap_size" = "auto" ] && target_heap_size=$(($(cat "$__global/explorer/memory")*1024/2)) ##### INSTALL THE PACKAGE ################################################### @@ -55,12 +55,12 @@ __key_value prometheus_args --file /etc/default/prometheus \ require="$require __directory/$storage_path $require_pkg" \ __config_file $CONF \ - --source $config \ + --source "$config" \ --group prometheus --mode 640 \ --onchange "promtool check config $CONF && service prometheus reload" for file in $rule_files; do - dest=$CONF_DIR/$(basename $file) + dest=$CONF_DIR/$(basename "$file") require="$require $require_pkg" \ __config_file "$dest" \ --source "$file" \ diff --git a/cdist/conf/type/__pyvenv/explorer/group b/cdist/conf/type/__pyvenv/explorer/group index ff072c5e..a655bda7 100755 --- a/cdist/conf/type/__pyvenv/explorer/group +++ b/cdist/conf/type/__pyvenv/explorer/group @@ -2,4 +2,4 @@ destination="/$__object_id" -stat --print "%G" ${destination} 2>/dev/null || exit 0 +stat --print "%G" "${destination}" 2>/dev/null || exit 0 diff --git a/cdist/conf/type/__pyvenv/explorer/owner b/cdist/conf/type/__pyvenv/explorer/owner index b77e3c6e..8b3c7f8e 100755 --- a/cdist/conf/type/__pyvenv/explorer/owner +++ b/cdist/conf/type/__pyvenv/explorer/owner @@ -2,4 +2,4 @@ destination="/$__object_id" -stat --print "%U" ${destination} 2>/dev/null || exit 0 +stat --print "%U" "${destination}" 2>/dev/null || exit 0 diff --git a/cdist/conf/type/__pyvenv/gencode-remote b/cdist/conf/type/__pyvenv/gencode-remote index 4cba5987..04700683 100755 --- a/cdist/conf/type/__pyvenv/gencode-remote +++ b/cdist/conf/type/__pyvenv/gencode-remote @@ -47,7 +47,7 @@ fi case $state_should in present) if [ "$state_should" != "$state_is" ]; then - echo $pyvenv $venvparams "$destination" + echo "$pyvenv $venvparams $destination" fi if { [ -n "$owner" ] && [ "$owner_is" != "$owner" ]; } || \ { [ -n "$group" ] && [ "$group_is" != "$group" ]; }; then diff --git a/cdist/conf/type/__qemu_img/gencode-remote b/cdist/conf/type/__qemu_img/gencode-remote index 9127e5ef..95d07b7a 100755 --- a/cdist/conf/type/__qemu_img/gencode-remote +++ b/cdist/conf/type/__qemu_img/gencode-remote @@ -18,4 +18,4 @@ format="$(cat "$__object/parameter/format")" size="$(cat "$__object/parameter/size")" diskimage="/$__object_id" -echo qemu-img create -f \"$format\" \"$diskimage\" \"$size\" +echo "qemu-img create -f \"$format\" \"$diskimage\" \"$size\"" diff --git a/cdist/conf/type/__rsync/gencode-local b/cdist/conf/type/__rsync/gencode-local index 155f3a3a..c7196175 100755 --- a/cdist/conf/type/__rsync/gencode-local +++ b/cdist/conf/type/__rsync/gencode-local @@ -31,7 +31,7 @@ set -- if [ -f "$__object/parameter/rsync-opts" ]; then while read opts; do set -- "$@" "--$opts" - done < $__object/parameter/rsync-opts + done < "$__object/parameter/rsync-opts" fi echo rsync -a \ diff --git a/cdist/conf/type/__rvm/explorer/state b/cdist/conf/type/__rvm/explorer/state index f43f5509..74d17048 100755 --- a/cdist/conf/type/__rvm/explorer/state +++ b/cdist/conf/type/__rvm/explorer/state @@ -28,7 +28,7 @@ if [ "$user" = "root" ]; then echo absent fi else - if su - $user -c "[ -d \"\$HOME/.rvm\" ]" ; then + if su - "$user" -c "[ -d \"\$HOME/.rvm\" ]" ; then echo "present" else echo "absent" diff --git a/cdist/conf/type/__ssh_authorized_key/explorer/entry b/cdist/conf/type/__ssh_authorized_key/explorer/entry index 157d70f1..b528b26e 100755 --- a/cdist/conf/type/__ssh_authorized_key/explorer/entry +++ b/cdist/conf/type/__ssh_authorized_key/explorer/entry @@ -24,7 +24,7 @@ type_and_key="$(tr ' ' '\n' < "$__object/parameter/key"| awk '/^(ssh|ecdsa)-[^ ] # in greping everything in file and all entries from file are removed. if [ -n "${type_and_key}" ] then - file="$(cat $__object/parameter/file)" + file="$(cat "$__object/parameter/file")" # get any entries that match the type and key grep ".*$type_and_key\([ \n]\|$\)" "$file" || true diff --git a/cdist/conf/type/__ssh_authorized_key/gencode-remote b/cdist/conf/type/__ssh_authorized_key/gencode-remote index 333dfa03..325854c2 100755 --- a/cdist/conf/type/__ssh_authorized_key/gencode-remote +++ b/cdist/conf/type/__ssh_authorized_key/gencode-remote @@ -88,7 +88,7 @@ fi entry="$(cat "$__object/files/should")" state_should="$(cat "$__object/parameter/state")" num_existing_entries=$(grep -c -F -x "$entry" "$__object/explorer/entry" || true) -if [ $num_existing_entries -eq 1 ]; then +if [ "$num_existing_entries" -eq 1 ]; then state_is="present" else # Posix grep does not define the -m option, so we can not remove a single diff --git a/cdist/conf/type/__start_on_boot/gencode-remote b/cdist/conf/type/__start_on_boot/gencode-remote index 14ee7dab..0ecea85b 100755 --- a/cdist/conf/type/__start_on_boot/gencode-remote +++ b/cdist/conf/type/__start_on_boot/gencode-remote @@ -59,11 +59,11 @@ case "$state_should" in ;; gentoo) - echo rc-update add \"$name\" \"$target_runlevel\" + echo "rc-update add \"$name\" \"$target_runlevel\"" ;; amazon|scientific|centos|fedora|owl|redhat|suse) - echo chkconfig \"$name\" on + echo "chkconfig \"$name\" on" ;; openwrt) @@ -98,15 +98,15 @@ case "$state_should" in else case "$os" in debian|ubuntu|devuan) - echo update-rc.d -f \"$name\" remove + echo "update-rc.d -f \"$name\" remove" ;; gentoo) - echo rc-update del \"$name\" \"$target_runlevel\" + echo "rc-update del \"$name\" \"$target_runlevel\"" ;; centos|fedora|owl|redhat|suse) - echo chkconfig \"$name\" off + echo "chkconfig \"$name\" off" ;; openwrt) diff --git a/cdist/conf/type/__start_on_boot/manifest b/cdist/conf/type/__start_on_boot/manifest index b9ee20e2..c1c983ec 100644 --- a/cdist/conf/type/__start_on_boot/manifest +++ b/cdist/conf/type/__start_on_boot/manifest @@ -16,7 +16,7 @@ case "$os" in else value='NO' fi - __key_value rcconf-$name-enable \ + __key_value "rcconf-$name-enable" \ --file /etc/rc.conf \ --key "${name}_enable" \ --value "\"$value\"" \ diff --git a/cdist/conf/type/__user/explorer/shadow b/cdist/conf/type/__user/explorer/shadow index 1e6658d4..c49992d5 100755 --- a/cdist/conf/type/__user/explorer/shadow +++ b/cdist/conf/type/__user/explorer/shadow @@ -22,7 +22,7 @@ # name=$__object_id -os="$($__explorer/os)" +os="$("$__explorer/os")" # Default to using shadow passwords database="shadow" diff --git a/cdist/conf/type/__user/gencode-remote b/cdist/conf/type/__user/gencode-remote index 332e93f1..23f01114 100755 --- a/cdist/conf/type/__user/gencode-remote +++ b/cdist/conf/type/__user/gencode-remote @@ -97,7 +97,7 @@ if [ "$state" = "present" ]; then fi if [ "$new_value" != "$current_value" ]; then - set -- "$@" "$(shorten_property $property)" \'$new_value\' + set -- "$@" "$(shorten_property "$property")" \'"$new_value"\' fi done @@ -118,9 +118,9 @@ if [ "$state" = "present" ]; then [ "$property" = "remove-home" ] && continue new_value="$(cat "$property")" if [ -z "$new_value" ];then # Boolean values have no value - set -- "$@" "$(shorten_property $property)" + set -- "$@" "$(shorten_property "$property")" else - set -- "$@" "$(shorten_property $property)" \'$new_value\' + set -- "$@" "$(shorten_property "$property")" \'"$new_value"\' fi done diff --git a/cdist/conf/type/__zypper_repo/gencode-remote b/cdist/conf/type/__zypper_repo/gencode-remote index 94c3f146..b8eeef0f 100755 --- a/cdist/conf/type/__zypper_repo/gencode-remote +++ b/cdist/conf/type/__zypper_repo/gencode-remote @@ -70,25 +70,25 @@ case "$state" in fi if [ -z "$repo_id" ]; then # Repo not present, so we need to create it - echo zypper $zypper_def_opts addrepo "'$uri'" "'$desc'" + echo "zypper $zypper_def_opts addrepo '$uri' '$desc'" fi ;; absent) if [ ! -z "$act_id" ]; then # Repo present (act_id not ""), so we ned to delete it - echo zypper $zypper_def_opts removerepo "$act_id" + echo "zypper $zypper_def_opts removerepo $act_id" fi ;; enabled) if [ ! -z "$act_id" ] && [ "$repostate" = "disabled" ]; then # Repo present (act_id not "") and repostate not enabled, so a enable call is needed - echo zypper $zypper_def_opts modifyrepo -e "$act_id" + echo "zypper $zypper_def_opts modifyrepo -e $act_id" fi ;; disabled) if [ ! -z "$act_id" ] && [ "$repostate" = "enabled" ]; then # Repo present (act_id not "") and repostate enabled, so a disable call is needed - echo zypper $zypper_def_opts modifyrepo -d "$act_id" + echo "zypper $zypper_def_opts modifyrepo -d $act_id" fi ;; *) diff --git a/cdist/conf/type/__zypper_service/explorer/service_uri b/cdist/conf/type/__zypper_service/explorer/service_uri index b8de0dcd..2476ab71 100644 --- a/cdist/conf/type/__zypper_service/explorer/service_uri +++ b/cdist/conf/type/__zypper_service/explorer/service_uri @@ -25,4 +25,4 @@ if [ -f "$__object/parameter/uri" ]; then else uri="/$__object_id" fi -zypper ls -u | awk 'BEGIN { FS = "[ ]+\\|[ ]+" } ; $4 == "Yes" && $NF == "'$uri'" {print $NF}' +zypper ls -u | awk 'BEGIN { FS = "[ ]+\\|[ ]+" } ; $4 == "Yes" && $NF == "'"$uri"'" {print $NF}' diff --git a/cdist/conf/type/__zypper_service/gencode-remote b/cdist/conf/type/__zypper_service/gencode-remote index 955698d1..6701347f 100755 --- a/cdist/conf/type/__zypper_service/gencode-remote +++ b/cdist/conf/type/__zypper_service/gencode-remote @@ -59,10 +59,10 @@ if [ -f "$__object/parameter/remove-all-other-services" ]; then # file exists -> True for i in $exp_ids; do if [ "$i" != "$exp_id" ] ; then - echo zypper $zypper_def_opts removeservice "$i" "&>/dev/null" + echo "zypper $zypper_def_opts removeservice $i &>/dev/null" fi done - echo zypper $zypper_def_opts refs "&>/dev/null" + echo "zypper $zypper_def_opts refs &>/dev/null" fi @@ -71,14 +71,14 @@ fi case "$state_should" in present) - echo zypper $zypper_def_opts addservice -t "$stype" "$uri" \"$desc\" - echo zypper $zypper_def_opts refs - echo zypper $zypper_def_opts ref + echo "zypper $zypper_def_opts addservice -t $stype $uri \"$desc\"" + echo "zypper $zypper_def_opts refs" + echo "zypper $zypper_def_opts ref" ;; absent) - echo zypper $zypper_def_opts removeservice "$service_id" - echo zypper $zypper_def_opts refs - echo zypper $zypper_def_opts ref + echo "zypper $zypper_def_opts removeservice $service_id" + echo "zypper $zypper_def_opts refs" + echo "zypper $zypper_def_opts ref" ;; *) echo "Unknown state: $state_should" >&2 From 53728a7ff0c1ac16d7dddb827915390d2c59abe9 Mon Sep 17 00:00:00 2001 From: Jonas Weber Date: Wed, 3 Oct 2018 19:38:47 +0200 Subject: [PATCH 0104/1217] Change backslash-dquote to single quote Slightly breaking change, but improves security and readability. --- cdist/conf/type/__apt_ppa/gencode-remote | 4 +-- .../type/__ccollect_source/gencode-remote | 14 +++++----- cdist/conf/type/__directory/gencode-remote | 18 ++++++------- cdist/conf/type/__file/gencode-remote | 14 +++++----- .../conf/type/__firewalld_rule/gencode-remote | 8 +++--- .../gencode-remote | 2 +- cdist/conf/type/__package_apt/gencode-remote | 4 +-- .../conf/type/__package_emerge/gencode-remote | 4 +-- .../type/__package_luarocks/gencode-remote | 4 +-- cdist/conf/type/__package_opkg/gencode-remote | 4 +-- .../conf/type/__package_pacman/gencode-remote | 4 +-- cdist/conf/type/__package_pip/gencode-remote | 4 +-- .../type/__package_rubygem/gencode-remote | 4 +-- cdist/conf/type/__package_yum/gencode-remote | 4 +-- .../conf/type/__package_zypper/gencode-remote | 6 ++--- cdist/conf/type/__qemu_img/gencode-remote | 2 +- .../conf/type/__start_on_boot/gencode-remote | 26 +++++++++---------- .../conf/type/__zypper_service/gencode-remote | 2 +- 18 files changed, 64 insertions(+), 64 deletions(-) diff --git a/cdist/conf/type/__apt_ppa/gencode-remote b/cdist/conf/type/__apt_ppa/gencode-remote index 25dec58d..84ebebfe 100755 --- a/cdist/conf/type/__apt_ppa/gencode-remote +++ b/cdist/conf/type/__apt_ppa/gencode-remote @@ -29,9 +29,9 @@ fi case "$state_should" in present) - echo "add-apt-repository \"$name\"" + echo "add-apt-repository '$name'" ;; absent) - echo "remove-apt-repository \"$name\"" + echo "remove-apt-repository '$name'" ;; esac diff --git a/cdist/conf/type/__ccollect_source/gencode-remote b/cdist/conf/type/__ccollect_source/gencode-remote index 5f2f97e3..5daa3fd3 100755 --- a/cdist/conf/type/__ccollect_source/gencode-remote +++ b/cdist/conf/type/__ccollect_source/gencode-remote @@ -42,18 +42,18 @@ get_current_value() { } set_group() { - echo chgrp \""$1"\" \""$destination"\" - echo chgrp "$1" >> "$__messages_out" + echo "chgrp '$1' '$destination'" + echo "chgrp '$1'" >> "$__messages_out" } set_owner() { - echo chown \""$1"\" \""$destination"\" - echo chown "$1" >> "$__messages_out" + echo "chown '$1' '$destination'" + echo "chown '$1'" >> "$__messages_out" } set_mode() { - echo chmod \""$1"\" \""$destination"\" - echo chmod "$1" >> "$__messages_out" + echo "chmod '$1' '$destination'" + echo "chmod '$1'" >> "$__messages_out" } set_attributes= @@ -81,7 +81,7 @@ case "$state_should" in absent) if [ "$type" = "file" ]; then - echo rm -f \""$destination"\" + echo "rm -f '$destination'" echo remove >> "$__messages_out" fi ;; diff --git a/cdist/conf/type/__directory/gencode-remote b/cdist/conf/type/__directory/gencode-remote index 35866eb4..4220c6fb 100755 --- a/cdist/conf/type/__directory/gencode-remote +++ b/cdist/conf/type/__directory/gencode-remote @@ -57,18 +57,18 @@ get_current_value() { } set_group() { - echo chgrp "$recursive" \""$1"\" \""$destination"\" - echo chgrp "$recursive" "$1" >> "$__messages_out" + echo "chgrp '$recursive' '$1' '$destination'" + echo "chgrp '$recursive' '$1'" >> "$__messages_out" } set_owner() { - echo chown "$recursive" \""$1"\" \""$destination"\" - echo chown "$recursive" "$1" >> "$__messages_out" + echo "chown '$recursive' '$1' '$destination'" + echo "chown '$recursive' '$1'" >> "$__messages_out" } set_mode() { - echo chmod "$recursive" \""$1"\" \""$destination"\" - echo chmod "$recursive" "$1" >> "$__messages_out" + echo "chmod '$recursive' '$1' '$destination'" + echo "chmod '$recursive' '$1'" >> "$__messages_out" } case "$state_should" in @@ -78,10 +78,10 @@ case "$state_should" in if [ "$type" != "none" ]; then # our destination is not a directory, remove whatever is there # and then create our directory and set all attributes - echo rm -f "\"$destination\"" + echo "rm -f '$destination'" echo "remove non directory" >> "$__messages_out" fi - echo "mkdir $mkdiropt \"$destination\"" + echo "mkdir $mkdiropt '$destination'" echo "create" >> "$__messages_out" fi @@ -105,7 +105,7 @@ case "$state_should" in ;; absent) if [ "$type" = "directory" ]; then - echo rm -rf \""$destination"\" + echo "rm -rf '$destination'" echo remove >> "$__messages_out" fi ;; diff --git a/cdist/conf/type/__file/gencode-remote b/cdist/conf/type/__file/gencode-remote index ebc30fd9..ab9c2fd1 100755 --- a/cdist/conf/type/__file/gencode-remote +++ b/cdist/conf/type/__file/gencode-remote @@ -43,18 +43,18 @@ get_current_value() { } set_group() { - echo chgrp \""$1"\" \""$destination"\" - echo chgrp "$1" >> "$__messages_out" + echo "chgrp '$1' '$destination'" + echo "chgrp '$1'" >> "$__messages_out" } set_owner() { - echo chown \""$1"\" \""$destination"\" - echo chown "$1" >> "$__messages_out" + echo "chown '$1' '$destination'" + echo "chown '$1'" >> "$__messages_out" } set_mode() { - echo chmod \""$1"\" \""$destination"\" - echo chmod "$1" >> "$__messages_out" + echo "chmod '$1' '$destination'" + echo "chmod '$1'" >> "$__messages_out" } set_attributes= @@ -82,7 +82,7 @@ case "$state_should" in absent) if [ "$type" = "file" ]; then - echo rm -f \""$destination"\" + echo "rm -f '$destination'" echo remove >> "$__messages_out" fi ;; diff --git a/cdist/conf/type/__firewalld_rule/gencode-remote b/cdist/conf/type/__firewalld_rule/gencode-remote index bc218d9a..225a0502 100755 --- a/cdist/conf/type/__firewalld_rule/gencode-remote +++ b/cdist/conf/type/__firewalld_rule/gencode-remote @@ -33,13 +33,13 @@ rule="$(cat "$__object/parameter/rule")" case "$state_should" in present) - echo "firewall-cmd --quiet --permanent --direct --add-rule \"$protocol\" \"$table\" \"$chain\" \"$priority\" $rule" - echo "firewall-cmd --quiet --direct --add-rule \"$protocol\" \"$table\" \"$chain\" \"$priority\" $rule" + echo "firewall-cmd --quiet --permanent --direct --add-rule '$protocol' '$table' '$chain' '$priority' $rule" + echo "firewall-cmd --quiet --direct --add-rule '$protocol' '$table' '$chain' '$priority' $rule" ;; absent) - echo "firewall-cmd --quiet --permanent --direct --remove-rule \"$protocol\" \"$table\" \"$chain\" \"$priority\" $rule" - echo "firewall-cmd --quiet --direct --remove-rule \"$protocol\" \"$table\" \"$chain\" \"$priority\" $rule" + echo "firewall-cmd --quiet --permanent --direct --remove-rule '$protocol' '$table' '$chain' '$priority' $rule" + echo "firewall-cmd --quiet --direct --remove-rule '$protocol' '$table' '$chain' '$priority' $rule" ;; *) echo "Unknown state $state_should" >&2 diff --git a/cdist/conf/type/__install_partition_msdos_apply/gencode-remote b/cdist/conf/type/__install_partition_msdos_apply/gencode-remote index b8100c52..644de33c 100755 --- a/cdist/conf/type/__install_partition_msdos_apply/gencode-remote +++ b/cdist/conf/type/__install_partition_msdos_apply/gencode-remote @@ -85,7 +85,7 @@ primary_count=0 for object in $objects; do device="$(cat "$object/parameter/device")" if [ "$current_device" != "$device" ]; then - echo "create_disklabel \"$device\" || die 'Failed to create disklabel for $device'" + echo "create_disklabel '$device' || die 'Failed to create disklabel for $device'" current_device="$device" device_name=$(echo "${device}" | sed -e 's:^/dev/::;s:/:\\/:g') available_device_size=$(( $(awk "/${device_name}\$/ { print \$3; }" "$partitions") / 1024)) diff --git a/cdist/conf/type/__package_apt/gencode-remote b/cdist/conf/type/__package_apt/gencode-remote index cbe14787..699eb0c9 100755 --- a/cdist/conf/type/__package_apt/gencode-remote +++ b/cdist/conf/type/__package_apt/gencode-remote @@ -77,11 +77,11 @@ case "$state_should" in if [ -n "$version" ]; then name="${name}=${version}" fi - echo "$aptget install $target_release \"$name\"" + echo "$aptget install $target_release '$name'" echo "installed" >> "$__messages_out" ;; absent) - echo "$aptget remove $purgeparam \"$name\"" + echo "$aptget remove $purgeparam '$name'" echo "removed" >> "$__messages_out" ;; *) diff --git a/cdist/conf/type/__package_emerge/gencode-remote b/cdist/conf/type/__package_emerge/gencode-remote index ada2b414..8abcb5b1 100755 --- a/cdist/conf/type/__package_emerge/gencode-remote +++ b/cdist/conf/type/__package_emerge/gencode-remote @@ -63,10 +63,10 @@ fi case "$state_should" in present) - echo "emerge \"$name\" &>/dev/null || exit 1" + echo "emerge '$name' &>/dev/null || exit 1" ;; absent) - echo "emerge -C \"$name\" &>/dev/null || exit 1" + echo "emerge -C '$name' &>/dev/null || exit 1" ;; *) echo "Unknown state: $state_should" >&2 diff --git a/cdist/conf/type/__package_luarocks/gencode-remote b/cdist/conf/type/__package_luarocks/gencode-remote index e14d7a8e..60b9bfea 100755 --- a/cdist/conf/type/__package_luarocks/gencode-remote +++ b/cdist/conf/type/__package_luarocks/gencode-remote @@ -42,10 +42,10 @@ fi case "$state_should" in present) - echo luarocks install \""$name"\" + echo "luarocks install '$name'" ;; absent) - echo luarocks remove \""$name"\" + echo "luarocks remove '$name'" ;; *) echo "Unknown state: $state_should" >&2 diff --git a/cdist/conf/type/__package_opkg/gencode-remote b/cdist/conf/type/__package_opkg/gencode-remote index 53f154a5..7013ec9f 100755 --- a/cdist/conf/type/__package_opkg/gencode-remote +++ b/cdist/conf/type/__package_opkg/gencode-remote @@ -45,10 +45,10 @@ case "$state_should" in if [ "$present" = "notpresent" ]; then echo opkg --verbosity=0 update fi - echo opkg --verbosity=0 install \""$name"\" + echo "opkg --verbosity=0 install '$name'" ;; absent) - echo opkg --verbosity=0 remove \""$name"\" + echo "opkg --verbosity=0 remove '$name'" ;; *) echo "Unknown state: $state" >&2 diff --git a/cdist/conf/type/__package_pacman/gencode-remote b/cdist/conf/type/__package_pacman/gencode-remote index 43649124..7ba85479 100755 --- a/cdist/conf/type/__package_pacman/gencode-remote +++ b/cdist/conf/type/__package_pacman/gencode-remote @@ -45,10 +45,10 @@ fi case "$state_should" in present) - echo pacman --needed --noconfirm --noprogressbar -S \""$name"\" + echo "pacman --needed --noconfirm --noprogressbar -S '$name'" ;; absent) - echo pacman --noconfirm --noprogressbar -R \""$name"\" + echo "pacman --noconfirm --noprogressbar -R '$name'" ;; *) echo "Unknown state: $state_should" >&2 diff --git a/cdist/conf/type/__package_pip/gencode-remote b/cdist/conf/type/__package_pip/gencode-remote index 933406f2..33556bec 100755 --- a/cdist/conf/type/__package_pip/gencode-remote +++ b/cdist/conf/type/__package_pip/gencode-remote @@ -53,7 +53,7 @@ case "$state_should" in present) if [ "$runas" ] then - echo "su -c \"$pip install -q $name\" $runas" + echo "su -c '$pip install -q $name' $runas" else echo $pip install -q "$name" fi @@ -61,7 +61,7 @@ case "$state_should" in absent) if [ "$runas" ] then - echo "su -c \"$pip uninstall -q -y $name\" $runas" + echo "su -c '$pip uninstall -q -y $name' $runas" else echo $pip uninstall -q -y "$name" fi diff --git a/cdist/conf/type/__package_rubygem/gencode-remote b/cdist/conf/type/__package_rubygem/gencode-remote index d474db20..ee563ef8 100755 --- a/cdist/conf/type/__package_rubygem/gencode-remote +++ b/cdist/conf/type/__package_rubygem/gencode-remote @@ -39,10 +39,10 @@ fi case "$state_should" in present) - echo gem install \""$name"\" --no-ri --no-rdoc + echo "gem install '$name' --no-ri --no-rdoc" ;; absent) - echo gem uninstall \""$name"\" + echo "gem uninstall '$name'" ;; *) echo "Unknown state: $state_should" >&2 diff --git a/cdist/conf/type/__package_yum/gencode-remote b/cdist/conf/type/__package_yum/gencode-remote index d860c48c..97265827 100755 --- a/cdist/conf/type/__package_yum/gencode-remote +++ b/cdist/conf/type/__package_yum/gencode-remote @@ -60,10 +60,10 @@ fi case "$state_should" in present) - echo "yum $opts install \"$install_name\"" + echo "yum $opts install '$install_name'" ;; absent) - echo "yum $opts remove \"$name\"" + echo "yum $opts remove '$name'" ;; *) echo "Unknown state: $state_should" >&2 diff --git a/cdist/conf/type/__package_zypper/gencode-remote b/cdist/conf/type/__package_zypper/gencode-remote index 5b1b763e..1f15c531 100755 --- a/cdist/conf/type/__package_zypper/gencode-remote +++ b/cdist/conf/type/__package_zypper/gencode-remote @@ -61,15 +61,15 @@ case "$state_should" in present) if [ -z "$version_should" ]; then [ "$state_is" = "present" ] && exit 0 # if state is present, we dont need to do anything - echo "zypper $globalopts install --type \"$ptype\" --auto-agree-with-licenses \"$name\" >/dev/null" + echo "zypper $globalopts install --type '$ptype' --auto-agree-with-licenses '$name' >/dev/null" else [ "$state_is" = "present" ] && [ "$version_should" = "$version_is" ] && exit 0 # if state is present and version is correct, we dont need to do anything - echo "zypper $globalopts install --oldpackage --type \"$ptype\" --auto-agree-with-licenses \"$name\" = \"$version_should\" >/dev/null" + echo "zypper $globalopts install --oldpackage --type '$ptype' --auto-agree-with-licenses '$name' = '$version_should' >/dev/null" fi ;; absent) [ "$state_is" = "absent" ] && exit 0 # if state is absent, we dont need to do anything - echo "zypper $globalopts remove --type \"$ptype\" \"$name\" >/dev/null" + echo "zypper $globalopts remove --type '$ptype' '$name' >/dev/null" ;; *) echo "Unknown state: $state_should" >&2 diff --git a/cdist/conf/type/__qemu_img/gencode-remote b/cdist/conf/type/__qemu_img/gencode-remote index 95d07b7a..94816f58 100755 --- a/cdist/conf/type/__qemu_img/gencode-remote +++ b/cdist/conf/type/__qemu_img/gencode-remote @@ -18,4 +18,4 @@ format="$(cat "$__object/parameter/format")" size="$(cat "$__object/parameter/size")" diskimage="/$__object_id" -echo "qemu-img create -f \"$format\" \"$diskimage\" \"$size\"" +echo "qemu-img create -f '$format' '$diskimage' '$size'" diff --git a/cdist/conf/type/__start_on_boot/gencode-remote b/cdist/conf/type/__start_on_boot/gencode-remote index 0ecea85b..122692ec 100755 --- a/cdist/conf/type/__start_on_boot/gencode-remote +++ b/cdist/conf/type/__start_on_boot/gencode-remote @@ -37,16 +37,16 @@ case "$state_should" in if [ "$init" = 'systemd' ]; then # this handles ALL linux distros with systemd # e.g. archlinux, gentoo in some cases, new RHEL and SLES versions - echo "systemctl -q enable \"$name\"" + echo "systemctl -q enable '$name'" else case "$os" in debian) case "$os_version" in [1-7]*) - echo "update-rc.d \"$name\" defaults >/dev/null" + echo "update-rc.d '$name' defaults >/dev/null" ;; 8*) - echo "systemctl enable \"$name\"" + echo "systemctl enable '$name'" ;; *) echo "Unsupported version $os_version of $os" >&2 @@ -55,26 +55,26 @@ case "$state_should" in esac ;; devuan) - echo "update-rc.d \"$name\" defaults >/dev/null" + echo "update-rc.d '$name' defaults >/dev/null" ;; gentoo) - echo "rc-update add \"$name\" \"$target_runlevel\"" + echo "rc-update add '$name' '$target_runlevel'" ;; amazon|scientific|centos|fedora|owl|redhat|suse) - echo "chkconfig \"$name\" on" + echo "chkconfig '$name' on" ;; openwrt) # 'enable' can be successful and still return a non-zero exit # code, deal with it by checking for success ourselves in that # case (the || ... part). - echo "/etc/init.d/\"$name\" enable || [ -f /etc/rc.d/S??\"$name\" ]" + echo "'/etc/init.d/$name' enable || [ -f /etc/rc.d/S??'$name' ]" ;; ubuntu) - echo "update-rc.d \"$name\" defaults >/dev/null" + echo "update-rc.d '$name' defaults >/dev/null" ;; freebsd) @@ -93,24 +93,24 @@ case "$state_should" in if [ "$init" = 'systemd' ]; then # this handles ALL linux distros with systemd # e.g. archlinux, gentoo in some cases, new RHEL and SLES versions - echo "systemctl -q disable \"$name\"" + echo "systemctl -q disable '$name'" else case "$os" in debian|ubuntu|devuan) - echo "update-rc.d -f \"$name\" remove" + echo "update-rc.d -f '$name' remove" ;; gentoo) - echo "rc-update del \"$name\" \"$target_runlevel\"" + echo "rc-update del '$name' '$target_runlevel'" ;; centos|fedora|owl|redhat|suse) - echo "chkconfig \"$name\" off" + echo "chkconfig '$name' off" ;; openwrt) - echo "\"/etc/init.d/$name\" disable" + echo "'/etc/init.d/$name' disable" ;; *) diff --git a/cdist/conf/type/__zypper_service/gencode-remote b/cdist/conf/type/__zypper_service/gencode-remote index 6701347f..59ffc942 100755 --- a/cdist/conf/type/__zypper_service/gencode-remote +++ b/cdist/conf/type/__zypper_service/gencode-remote @@ -71,7 +71,7 @@ fi case "$state_should" in present) - echo "zypper $zypper_def_opts addservice -t $stype $uri \"$desc\"" + echo "zypper $zypper_def_opts addservice -t $stype $uri '$desc'" echo "zypper $zypper_def_opts refs" echo "zypper $zypper_def_opts ref" ;; From fff656d1acc596646249eb31903b5bcbb6003caf Mon Sep 17 00:00:00 2001 From: Jonas Weber Date: Thu, 4 Oct 2018 19:28:36 +0200 Subject: [PATCH 0105/1217] Unquote $recursive to support empty-case This is safe to do, as the value of $recursive is not dependent on user-supplied code. --- cdist/conf/type/__directory/gencode-remote | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/cdist/conf/type/__directory/gencode-remote b/cdist/conf/type/__directory/gencode-remote index 4220c6fb..374db47a 100755 --- a/cdist/conf/type/__directory/gencode-remote +++ b/cdist/conf/type/__directory/gencode-remote @@ -57,18 +57,18 @@ get_current_value() { } set_group() { - echo "chgrp '$recursive' '$1' '$destination'" - echo "chgrp '$recursive' '$1'" >> "$__messages_out" + echo "chgrp $recursive '$1' '$destination'" + echo "chgrp $recursive '$1'" >> "$__messages_out" } set_owner() { - echo "chown '$recursive' '$1' '$destination'" - echo "chown '$recursive' '$1'" >> "$__messages_out" + echo "chown $recursive '$1' '$destination'" + echo "chown $recursive '$1'" >> "$__messages_out" } set_mode() { - echo "chmod '$recursive' '$1' '$destination'" - echo "chmod '$recursive' '$1'" >> "$__messages_out" + echo "chmod $recursive '$1' '$destination'" + echo "chmod $recursive '$1'" >> "$__messages_out" } case "$state_should" in From e2593c0dcbababa2d0f0cb1fd0d29dbbb5da24bb Mon Sep 17 00:00:00 2001 From: Jonas Weber Date: Thu, 4 Oct 2018 21:23:12 +0200 Subject: [PATCH 0106/1217] Fix SC2215 (missing brackets on if) This might have never worked as intended, but how would you know? --- cdist/conf/type/__rvm_gemset/gencode-remote | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cdist/conf/type/__rvm_gemset/gencode-remote b/cdist/conf/type/__rvm_gemset/gencode-remote index 78851f9a..3cdc66a6 100755 --- a/cdist/conf/type/__rvm_gemset/gencode-remote +++ b/cdist/conf/type/__rvm_gemset/gencode-remote @@ -33,7 +33,7 @@ case "$state_should" in cat << DONE su - "$user" -c "source ~/.rvm/scripts/rvm; rvm $gemset --create" DONE - if -f "$__object/parameter/default"; then + if [ -f "$__object/parameter/default" ]; then cat << DONE su - "$user" -c "source ~/.rvm/scripts/rvm; rvm use --default $gemset" DONE From a6fdf4255aa877850890330c91d9330617b99fb3 Mon Sep 17 00:00:00 2001 From: Jonas Weber Date: Thu, 4 Oct 2018 21:17:31 +0200 Subject: [PATCH 0107/1217] Fix SC2069 (wrong stdout/stderr redirect order) In the original order, stderr was connected to the old stdout (terminal). This was _probably_ not intended. The new order fixes this by first connecting stdout to /dev/null and then attaching stderr to that as well. --- cdist/conf/explorer/machine | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cdist/conf/explorer/machine b/cdist/conf/explorer/machine index d4a0e106..7ecb67e3 100755 --- a/cdist/conf/explorer/machine +++ b/cdist/conf/explorer/machine @@ -22,6 +22,6 @@ # # -if command -v uname 2>&1 >/dev/null; then +if command -v uname >/dev/null 2>&1 ; then uname -m fi From a0db375f91bad2e288a36ce298146e22672718d9 Mon Sep 17 00:00:00 2001 From: Jonas Weber Date: Thu, 4 Oct 2018 21:30:28 +0200 Subject: [PATCH 0108/1217] Disable SC2059 (printf injection) for staged_file We're explicitly allowing for 'printf injection' here, so it's ok to just disable the corresponding shellcheck check. --- cdist/conf/type/__staged_file/gencode-local | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cdist/conf/type/__staged_file/gencode-local b/cdist/conf/type/__staged_file/gencode-local index 18bf09f5..c0d94e92 100755 --- a/cdist/conf/type/__staged_file/gencode-local +++ b/cdist/conf/type/__staged_file/gencode-local @@ -57,6 +57,7 @@ get_file() { } fetch_file() { + # shellcheck disable=SC2059 printf "$fetch_command" "$source" printf ' > "%s"\n' "$stage_file" } @@ -64,8 +65,10 @@ fetch_file() { fetch_and_prepare_file() { printf 'tmpdir="$(mktemp -d --tmpdir="/tmp" "%s")"\n' "${__type##*/}.XXXXXXXXXX" printf 'cd "$tmpdir"\n' + # shellcheck disable=SC2059 printf "$fetch_command > \"%s\"\n" "$source" "$source_file_name" prepare_command="$(cat "$__object/parameter/prepare-command")" + # shellcheck disable=SC2059 printf "$prepare_command > \"%s\"\n" "$source_file_name" "$stage_file" printf 'cd - >/dev/null\n' printf 'rm -rf "$tmpdir"\n' From bcd7fbbcc48b72eb0f5ec378f0555428a0dac8d8 Mon Sep 17 00:00:00 2001 From: Jonas Weber Date: Thu, 4 Oct 2018 22:01:25 +0200 Subject: [PATCH 0109/1217] Fix SC2155 (directly export computed variables) --- cdist/conf/type/__key_value/explorer/state | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/cdist/conf/type/__key_value/explorer/state b/cdist/conf/type/__key_value/explorer/state index b990733d..7b2de1df 100755 --- a/cdist/conf/type/__key_value/explorer/state +++ b/cdist/conf/type/__key_value/explorer/state @@ -19,9 +19,9 @@ # along with cdist. If not, see . # -export key="$(cat "$__object/parameter/key" 2>/dev/null \ +key="$(cat "$__object/parameter/key" 2>/dev/null \ || echo "$__object_id")" -export state="$(cat "$__object/parameter/state")" +state="$(cat "$__object/parameter/state")" file="$(cat "$__object/parameter/file")" @@ -30,14 +30,15 @@ if [ ! -f "$file" ]; then exit fi -export delimiter="$(cat "$__object/parameter/delimiter")" -export value="$(cat "$__object/parameter/value" 2>/dev/null \ +delimiter="$(cat "$__object/parameter/delimiter")" +value="$(cat "$__object/parameter/value" 2>/dev/null \ || echo "__CDIST_NOTSET__")" if [ -f "$__object/parameter/exact_delimiter" ]; then - export exact_delimiter=1 + exact_delimiter=1 else - export exact_delimiter=0 + exact_delimiter=0 fi +export key state delimiter value exact_delimiter awk -f - "$file" <<"AWK_EOF" BEGIN { From 34b571b7d9d98451910650339231c3c3c06cfb61 Mon Sep 17 00:00:00 2001 From: Jonas Weber Date: Thu, 4 Oct 2018 22:22:22 +0200 Subject: [PATCH 0110/1217] Fix SC2091 (execute result of condition) For some reason, the echo|grep pattern was enclosed four times in a $() operation. Nothing happened, since grep is always invoked with -q (quiet, nothing printed to stdout). --- cdist/conf/type/__file/gencode-local | 2 +- cdist/conf/type/__jail_freebsd10/gencode-local | 2 +- cdist/conf/type/__jail_freebsd9/gencode-local | 2 +- cdist/conf/type/__user/gencode-remote | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cdist/conf/type/__file/gencode-local b/cdist/conf/type/__file/gencode-local index 3f60b4b3..fb9f9a92 100755 --- a/cdist/conf/type/__file/gencode-local +++ b/cdist/conf/type/__file/gencode-local @@ -84,7 +84,7 @@ DONE if [ "$upload_file" ]; then echo upload >> "$__messages_out" # IPv6 fix - if $(echo "${__target_host}" | grep -q -E '^[0-9a-fA-F:]+$') + if echo "${__target_host}" | grep -q -E '^[0-9a-fA-F:]+$' then my_target_host="[${__target_host}]" else diff --git a/cdist/conf/type/__jail_freebsd10/gencode-local b/cdist/conf/type/__jail_freebsd10/gencode-local index b2016f86..f163cad3 100755 --- a/cdist/conf/type/__jail_freebsd10/gencode-local +++ b/cdist/conf/type/__jail_freebsd10/gencode-local @@ -44,7 +44,7 @@ basepresent="$(cat "$__object/explorer/basepresent")" if [ "$state" = "present" ]; then if [ "$basepresent" = "NONE" ]; then # IPv6 fix - if $(echo "${__target_host}" | grep -q -E '^[0-9a-fA-F:]+$') + if echo "${__target_host}" | grep -q -E '^[0-9a-fA-F:]+$' then my_target_host="[${__target_host}]" else diff --git a/cdist/conf/type/__jail_freebsd9/gencode-local b/cdist/conf/type/__jail_freebsd9/gencode-local index 1ab7ff1a..bbdc9fcc 100755 --- a/cdist/conf/type/__jail_freebsd9/gencode-local +++ b/cdist/conf/type/__jail_freebsd9/gencode-local @@ -40,7 +40,7 @@ basepresent="$(cat "$__object/explorer/basepresent")" if [ "$state" = "present" ]; then if [ "$basepresent" = "NONE" ]; then # IPv6 fix - if $(echo "${__target_host}" | grep -q -E '^[0-9a-fA-F:]+$') + if echo "${__target_host}" | grep -q -E '^[0-9a-fA-F:]+$' then my_target_host="[${__target_host}]" else diff --git a/cdist/conf/type/__user/gencode-remote b/cdist/conf/type/__user/gencode-remote index 332e93f1..a1347a6f 100755 --- a/cdist/conf/type/__user/gencode-remote +++ b/cdist/conf/type/__user/gencode-remote @@ -60,7 +60,7 @@ if [ "$state" = "present" ]; then case "$property" in gid) - if $(echo "$new_value" | grep -q '^[0-9][0-9]*$'); then + if echo "$new_value" | grep -q '^[0-9][0-9]*$'; then field=4 else # We were passed a group name. Compare the gid in From 738f0538775ae182e10ae90c56a38af094ba7063 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Thu, 4 Oct 2018 22:39:06 +0200 Subject: [PATCH 0111/1217] ++changelog --- docs/changelog | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/changelog b/docs/changelog index 1405ad3c..151b11e5 100644 --- a/docs/changelog +++ b/docs/changelog @@ -11,6 +11,9 @@ next: * Explorers and types: Fix SC2039: In POSIX sh, something is undefined (shellcheck) (Darko Poljak) * Explorers and types: Fix SC2045: Iterating over ls output is fragile. Use globs. (shellcheck) (Thomas Eckert) * Explorers and types: Fix SC2148: Tips depend on target shell and yours is unknown. Add a shebang. (shellcheck) (Thomas Eckert) + * Explorers and types: Fix SC2069: To redirect stdout+stderr, 2>&1 must be last (or use '{ cmd > file; } 2>&1' to clarify). (shellcheck) (Jonas Weber) + * Explorers and types: Fix SC2034: foo appears unused. Verify it or export it. (shellcheck) (Jonas Weber) + * Explorers and types: Fix SC2215, SC2059, SC2155, SC2091. (shellcheck) (Jonas Weber) 4.10.3: 2018-09-23 * New global explorer: os_release (Ľubomír Kučera) From c01cf386608cbef77c53d6b2bf3c2f6d2b2be91d Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Thu, 4 Oct 2018 23:10:42 +0200 Subject: [PATCH 0112/1217] Fix SC2164 --- cdist/conf/explorer/disks | 2 +- cdist/conf/type/__link/explorer/state | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cdist/conf/explorer/disks b/cdist/conf/explorer/disks index 7a5c0da0..7c60b17a 100755 --- a/cdist/conf/explorer/disks +++ b/cdist/conf/explorer/disks @@ -1,3 +1,3 @@ #!/bin/sh -cd /dev +cd /dev || exit 0 echo sd? hd? vd? diff --git a/cdist/conf/type/__link/explorer/state b/cdist/conf/type/__link/explorer/state index b8d8fc2b..587835a2 100755 --- a/cdist/conf/type/__link/explorer/state +++ b/cdist/conf/type/__link/explorer/state @@ -32,7 +32,7 @@ destination_dir="${destination%/*}" case "$type" in symbolic) - cd "$destination_dir" + cd "$destination_dir" || exit 1 source_is=$(ls -l "$destination" | sed 's/.*-> //g') if [ -h "$destination" ]; then # ignore trailing slashes for comparison @@ -46,7 +46,7 @@ case "$type" in fi ;; hard) - cd "$destination_dir" + cd "$destination_dir" || exit 1 # check source relative to destination_dir if [ ! -e "$source" ]; then echo sourcemissing From d2f1d6185d7c9e46ae60e99cefc31f0b113ec148 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Fri, 5 Oct 2018 10:29:47 +0200 Subject: [PATCH 0113/1217] ++changelog --- docs/changelog | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/changelog b/docs/changelog index 151b11e5..d53edba2 100644 --- a/docs/changelog +++ b/docs/changelog @@ -14,6 +14,8 @@ next: * Explorers and types: Fix SC2069: To redirect stdout+stderr, 2>&1 must be last (or use '{ cmd > file; } 2>&1' to clarify). (shellcheck) (Jonas Weber) * Explorers and types: Fix SC2034: foo appears unused. Verify it or export it. (shellcheck) (Jonas Weber) * Explorers and types: Fix SC2215, SC2059, SC2155, SC2091. (shellcheck) (Jonas Weber) + * Explorers and types: Fix SC2086: Double quote to prevent globbing and word splitting. (shellcheck) (Jonas Weber) + * Explorers and types: Fix SC2164: Use cd ... || exit in case cd fails. (shellcheck) (Darko Poljak) 4.10.3: 2018-09-23 * New global explorer: os_release (Ľubomír Kučera) From 3b6d75966011a80a2d396933abe7d1816245c8e5 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Thu, 4 Oct 2018 23:24:30 +0200 Subject: [PATCH 0114/1217] Disable SC2016 check. --- cdist/conf/type/__docker_compose/gencode-remote | 5 +++-- cdist/conf/type/__golang_from_vendor/manifest | 1 + cdist/conf/type/__package_emerge/explorer/pkg_version | 1 + cdist/conf/type/__rvm_gemset/explorer/state | 2 ++ cdist/conf/type/__staged_file/gencode-local | 3 +++ 5 files changed, 10 insertions(+), 2 deletions(-) diff --git a/cdist/conf/type/__docker_compose/gencode-remote b/cdist/conf/type/__docker_compose/gencode-remote index 396c93ac..77fc2fdf 100755 --- a/cdist/conf/type/__docker_compose/gencode-remote +++ b/cdist/conf/type/__docker_compose/gencode-remote @@ -24,8 +24,9 @@ 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' + #shellcheck disable=SC2016 + 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/__golang_from_vendor/manifest b/cdist/conf/type/__golang_from_vendor/manifest index cf164524..ad39ddfb 100755 --- a/cdist/conf/type/__golang_from_vendor/manifest +++ b/cdist/conf/type/__golang_from_vendor/manifest @@ -1,3 +1,4 @@ #!/bin/sh -e +# shellcheck disable=SC2016 __line go_in_path --line 'export PATH=/usr/local/go/bin:$PATH' --file /etc/profile diff --git a/cdist/conf/type/__package_emerge/explorer/pkg_version b/cdist/conf/type/__package_emerge/explorer/pkg_version index 7053eaff..d02b9d6b 100644 --- a/cdist/conf/type/__package_emerge/explorer/pkg_version +++ b/cdist/conf/type/__package_emerge/explorer/pkg_version @@ -32,4 +32,5 @@ else name="$__object_id" fi +# shellcheck disable=SC2016 equery -q l -F '$cp $fullversion' "$name" || true diff --git a/cdist/conf/type/__rvm_gemset/explorer/state b/cdist/conf/type/__rvm_gemset/explorer/state index d1462134..e300453b 100755 --- a/cdist/conf/type/__rvm_gemset/explorer/state +++ b/cdist/conf/type/__rvm_gemset/explorer/state @@ -25,7 +25,9 @@ if [ ! -e "~$user/.rvm/scripts/rvm" ] ; then exit 0 fi +# shellcheck disable=SC2016 if su - "$user" -c 'source ~/.rvm/scripts/rvm; rvm list strings | grep -q "^$ruby\$"'; then + # shellcheck disable=SC2016 if su - "$user" -c 'source ~/.rvm/scripts/rvm; rvm use "$ruby" > /dev/null; rvm gemset list strings | cut -f 1 -d " " | grep -q "^$gemsetname\$"'; then echo "present" exit 0 diff --git a/cdist/conf/type/__staged_file/gencode-local b/cdist/conf/type/__staged_file/gencode-local index 617ca23a..4edaba7f 100755 --- a/cdist/conf/type/__staged_file/gencode-local +++ b/cdist/conf/type/__staged_file/gencode-local @@ -62,7 +62,9 @@ fetch_file() { } fetch_and_prepare_file() { + # shellcheck disable=SC2016 printf 'tmpdir="$(mktemp -d --tmpdir="/tmp" "%s")"\n' "${__type##*/}.XXXXXXXXXX" + # shellcheck disable=SC2016 printf 'cd "$tmpdir"\n' # shellcheck disable=SC2059 printf "$fetch_command > \"%s\"\n" "$source" "$source_file_name" @@ -70,6 +72,7 @@ fetch_and_prepare_file() { # shellcheck disable=SC2059 printf "$prepare_command > \"%s\"\n" "$source_file_name" "$stage_file" printf 'cd - >/dev/null\n' + # shellcheck disable=SC2016 printf 'rm -rf "$tmpdir"\n' } From 5f8c631e344ed8b54c670748a08615161aea2ada Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Fri, 5 Oct 2018 11:26:47 +0200 Subject: [PATCH 0115/1217] ++changelog --- docs/changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog b/docs/changelog index d53edba2..b5c218bc 100644 --- a/docs/changelog +++ b/docs/changelog @@ -16,6 +16,7 @@ next: * Explorers and types: Fix SC2215, SC2059, SC2155, SC2091. (shellcheck) (Jonas Weber) * Explorers and types: Fix SC2086: Double quote to prevent globbing and word splitting. (shellcheck) (Jonas Weber) * Explorers and types: Fix SC2164: Use cd ... || exit in case cd fails. (shellcheck) (Darko Poljak) + * Explorers and types: Disable SC2016 where it is intended: Expressions don't expand in single quotes, use double quotes for that. (shellcheck) (Darko Poljak) 4.10.3: 2018-09-23 * New global explorer: os_release (Ľubomír Kučera) From a601fa91d9c2eecc75bb476f81ccfb46e7d6d2c5 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Fri, 5 Oct 2018 11:34:10 +0200 Subject: [PATCH 0116/1217] Fix SC2116. --- cdist/conf/type/__hostname/gencode-remote | 2 +- cdist/conf/type/__hostname/manifest | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cdist/conf/type/__hostname/gencode-remote b/cdist/conf/type/__hostname/gencode-remote index 3f784188..b729b667 100755 --- a/cdist/conf/type/__hostname/gencode-remote +++ b/cdist/conf/type/__hostname/gencode-remote @@ -22,7 +22,7 @@ if [ -f "$__object/parameter/name" ]; then name_should="$(cat "$__object/parameter/name")" else - name_should="$(echo "${__target_host%%.*}")" + name_should="${__target_host%%.*}" fi os=$(cat "$__global/explorer/os") diff --git a/cdist/conf/type/__hostname/manifest b/cdist/conf/type/__hostname/manifest index 74664aa7..c03b2eac 100755 --- a/cdist/conf/type/__hostname/manifest +++ b/cdist/conf/type/__hostname/manifest @@ -25,10 +25,10 @@ if [ -f "$__object/parameter/name" ]; then else case "$os" in openbsd) - name_should="$(echo "${__target_host}")" + name_should="${__target_host}" ;; *) - name_should="$(echo "${__target_host%%.*}")" + name_should="${__target_host%%.*}" ;; esac fi From b25aff17c6cbeaf26cec3ce17f250bdacdd38df2 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Fri, 5 Oct 2018 11:49:28 +0200 Subject: [PATCH 0117/1217] Disable SC2039 where appropriate. --- cdist/conf/type/__package_pkg_freebsd/gencode-remote | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cdist/conf/type/__package_pkg_freebsd/gencode-remote b/cdist/conf/type/__package_pkg_freebsd/gencode-remote index 6c6e15b1..fd02d939 100755 --- a/cdist/conf/type/__package_pkg_freebsd/gencode-remote +++ b/cdist/conf/type/__package_pkg_freebsd/gencode-remote @@ -36,6 +36,7 @@ assert () # If condition false, if [ ! "$1" ] then echo "Assertion failed: \"$1\"" + # shellcheck disable=SC2039 echo "File \"$0\", line $lineno, called by $(caller 0)" exit $E_ASSERT_FAILED fi @@ -95,6 +96,7 @@ if [ -n "$curr_version" ]; then # PKG *is* installed exit 0 else # Current version is wrong, fix #updatepkg "$name" "$version" + # shellcheck disable=SC2039 assert "! ${version} = ${curr_version}" $LINENO cmd="${rm_cmd} ${name}-${curr_version}" execcmd "remove" "${cmd}" From ed542cc7cb3f8e02a2dea1388e8434d0987eeac4 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Fri, 5 Oct 2018 11:57:31 +0200 Subject: [PATCH 0118/1217] Fix SC2046. --- cdist/conf/type/__jail_freebsd10/gencode-remote | 2 +- cdist/conf/type/__jail_freebsd9/gencode-remote | 2 +- cdist/conf/type/__package_emerge/gencode-remote | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cdist/conf/type/__jail_freebsd10/gencode-remote b/cdist/conf/type/__jail_freebsd10/gencode-remote index 5be04bc6..84b2bae8 100755 --- a/cdist/conf/type/__jail_freebsd10/gencode-remote +++ b/cdist/conf/type/__jail_freebsd10/gencode-remote @@ -83,7 +83,7 @@ present="$(cat "$__object/explorer/present")" status="$(cat "$__object/explorer/status")" # Handle ip="addr, addr" format -if [ $(expr "${ip}" : ".*, .*") -gt "0" ]; then +if [ "$(expr "${ip}" : ".*, .*")" -gt "0" ]; then SAVE_IFS="$IFS" IFS=", " for cur_ip in ${ip}; do diff --git a/cdist/conf/type/__jail_freebsd9/gencode-remote b/cdist/conf/type/__jail_freebsd9/gencode-remote index 177bdf74..5b103ebc 100755 --- a/cdist/conf/type/__jail_freebsd9/gencode-remote +++ b/cdist/conf/type/__jail_freebsd9/gencode-remote @@ -86,7 +86,7 @@ present="$(cat "$__object/explorer/present")" status="$(cat "$__object/explorer/status")" # Handle ip="iface|addr, iface|addr" format -if [ $(expr "${ip}" : ".*|.*") -gt "0" ]; then +if [ "$(expr "${ip}" : ".*|.*")" -gt "0" ]; then # If we have multiple IPs defined, $interface doesn't make sense because ip="iface|addr, iface|addr" implies it interface="" SAVE_IFS="$IFS" diff --git a/cdist/conf/type/__package_emerge/gencode-remote b/cdist/conf/type/__package_emerge/gencode-remote index 8abcb5b1..c8a79c1f 100755 --- a/cdist/conf/type/__package_emerge/gencode-remote +++ b/cdist/conf/type/__package_emerge/gencode-remote @@ -38,11 +38,11 @@ fi pkg_version="$(cat "$__object/explorer/pkg_version")" if [ -z "$pkg_version" ]; then state_is="absent" -elif [ -z "$version" ] && [ $(echo "$pkg_version" | wc -l) -gt 1 ]; then +elif [ -z "$version" ] && [ "$(echo "$pkg_version" | wc -l)" -gt 1 ]; then echo "Package name is not unique! The following packages are installed:" echo "$pkg_version" exit 1 -elif [ -n "$version" ] && [ $(echo "$pkg_version" | cut -d " " -f 1 | sort | uniq | wc -l) -gt 1 ]; then +elif [ -n "$version" ] && [ "$(echo "$pkg_version" | cut -d " " -f 1 | sort | uniq | wc -l)" -gt 1 ]; then echo "Package name is not unique! The following packages are installed:" echo "$pkg_version" exit 1 From 28889ef38a08f53b193a7cc561372e8c03175853 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Fri, 5 Oct 2018 12:02:10 +0200 Subject: [PATCH 0119/1217] Disable SC2028 where intended. --- cdist/conf/type/__hostname/gencode-remote | 2 ++ cdist/conf/type/__jail_freebsd10/gencode-remote | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/cdist/conf/type/__hostname/gencode-remote b/cdist/conf/type/__hostname/gencode-remote index b729b667..fd9e7c98 100755 --- a/cdist/conf/type/__hostname/gencode-remote +++ b/cdist/conf/type/__hostname/gencode-remote @@ -59,6 +59,7 @@ echo changed >> "$__messages_out" # Use the good old way to set the hostname even on machines running systemd. case "$os" in archlinux|debian|ubuntu|devuan|centos|coreos) + # shellcheck disable=SC2028 echo "printf '%s\n' '$name_should' > /etc/hostname" echo "hostname -F /etc/hostname" ;; @@ -67,6 +68,7 @@ case "$os" in ;; suse) echo "hostname '$name_should'" + # shellcheck disable=SC2028 echo "printf '%s\n' '$name_should' > /etc/HOSTNAME" ;; esac diff --git a/cdist/conf/type/__jail_freebsd10/gencode-remote b/cdist/conf/type/__jail_freebsd10/gencode-remote index 84b2bae8..81912050 100755 --- a/cdist/conf/type/__jail_freebsd10/gencode-remote +++ b/cdist/conf/type/__jail_freebsd10/gencode-remote @@ -298,7 +298,7 @@ END fi EOF - + # shellcheck disable=SC2028 echo "printf \"%s\\n%s\n%s\n\" \"\$jailheader\" \"\$jaildata\" \"\$jailtrailer\" >>\"\$jailfile\"" # Add $name to jail_list if $onboot=yes From 73acb35a8acf1f7f235e6cda40dc43563b261b00 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Fri, 5 Oct 2018 12:04:45 +0200 Subject: [PATCH 0120/1217] Fix SC2196. --- cdist/conf/type/__package_luarocks/explorer/pkg_status | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cdist/conf/type/__package_luarocks/explorer/pkg_status b/cdist/conf/type/__package_luarocks/explorer/pkg_status index 3eb73298..e83e8ce6 100755 --- a/cdist/conf/type/__package_luarocks/explorer/pkg_status +++ b/cdist/conf/type/__package_luarocks/explorer/pkg_status @@ -28,4 +28,4 @@ else fi # Accept luarocks failing if package is not known/installed -luarocks list "$name" | egrep -A1 "^$name$" || exit 0 +luarocks list "$name" | grep -E -A1 "^$name$" || exit 0 From 73d0a5bbbed2e777ea721e47b9e5dd6a2bc7859c Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Fri, 5 Oct 2018 12:14:51 +0200 Subject: [PATCH 0121/1217] Fix SC2235. --- cdist/conf/type/__package_emerge/gencode-remote | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cdist/conf/type/__package_emerge/gencode-remote b/cdist/conf/type/__package_emerge/gencode-remote index c8a79c1f..48462bde 100755 --- a/cdist/conf/type/__package_emerge/gencode-remote +++ b/cdist/conf/type/__package_emerge/gencode-remote @@ -57,7 +57,7 @@ fi # Exit if nothing is needed to be done -[ "$state_is" = "$state_should" ] && ( [ -z "$version" ] || [ "$installed_version" = "$version" ] ) && exit 0 +[ "$state_is" = "$state_should" ] && { [ -z "$version" ] || [ "$installed_version" = "$version" ]; } && exit 0 [ "$state_should" = "absent" ] && [ ! -z "$version" ] && [ "$installed_version" != "$version" ] && exit 0 From 2f7b8e6db9ed4900c3fdc9f3dac26654e706b8ae Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Fri, 5 Oct 2018 12:16:27 +0200 Subject: [PATCH 0122/1217] Fix SC2153. --- cdist/conf/type/__pf_ruleset/gencode-local | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cdist/conf/type/__pf_ruleset/gencode-local b/cdist/conf/type/__pf_ruleset/gencode-local index b4bded98..b9de1bce 100755 --- a/cdist/conf/type/__pf_ruleset/gencode-local +++ b/cdist/conf/type/__pf_ruleset/gencode-local @@ -54,7 +54,7 @@ case $uname in currentSum=\$(cksum -o 1 ${source} | cut -d= -f2 | sed 's/ //g') ;; *) - echo "Sorry, I do not know how to find a cksum on ${UNAME}." >&2 + echo "Sorry, I do not know how to find a cksum on ${uname}." >&2 exit 1 ;; esac From e46420e7f57560a5b833d42dfcf10c40549f83d9 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Fri, 5 Oct 2018 12:19:16 +0200 Subject: [PATCH 0123/1217] Fix SC1090. --- cdist/conf/type/__docker/manifest | 1 + 1 file changed, 1 insertion(+) diff --git a/cdist/conf/type/__docker/manifest b/cdist/conf/type/__docker/manifest index 35760cef..8f26feec 100755 --- a/cdist/conf/type/__docker/manifest +++ b/cdist/conf/type/__docker/manifest @@ -24,6 +24,7 @@ state=$(cat "$__object/parameter/state") case "$os" in centos) + # shellcheck source=/dev/null if (. "$__global/explorer/os_release" && [ "${VERSION_ID}" = "7" ]); then __yum_repo docker-ce-stable \ --name 'Docker CE Stable' \ From 7b17ad473303a48a70b1d959141bdf22b8747607 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Fri, 5 Oct 2018 12:21:59 +0200 Subject: [PATCH 0124/1217] Fix SC2143. --- cdist/conf/type/__jail/manifest | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cdist/conf/type/__jail/manifest b/cdist/conf/type/__jail/manifest index 222cb859..6fb4a306 100755 --- a/cdist/conf/type/__jail/manifest +++ b/cdist/conf/type/__jail/manifest @@ -44,7 +44,7 @@ for property in *; do done ver="$(cat "$__global/explorer/os_version")" -if [ -n "$(echo "$ver" | grep '^10\.' )" ]; then # Version is 10.x +if echo "$ver" | grep -q '^10\.'; then # Version is 10.x __jail_freebsd10 "$@" else __jail_freebsd9 "$@" From b120a813a2e2db27e29c8442fba9d0091f67a45c Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Fri, 5 Oct 2018 12:24:03 +0200 Subject: [PATCH 0125/1217] Disable SC2030 where appropriate. --- cdist/conf/type/__consul_template_template/manifest | 1 + 1 file changed, 1 insertion(+) diff --git a/cdist/conf/type/__consul_template_template/manifest b/cdist/conf/type/__consul_template_template/manifest index 7834ae9c..4ba0329f 100755 --- a/cdist/conf/type/__consul_template_template/manifest +++ b/cdist/conf/type/__consul_template_template/manifest @@ -52,6 +52,7 @@ for param in *; do --owner root --group root --mode 640 \ --source "$source" \ --state "$state" + # shellcheck disable=SC2030 export require="__file${destination}" printf ' source = "%s"\n' "$destination" From 8cea8e67aaa71d911b70326efd7c8e61103b1502 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Fri, 5 Oct 2018 12:25:40 +0200 Subject: [PATCH 0126/1217] Disable SC2031 where appropriate. --- cdist/conf/type/__consul_template_template/manifest | 1 + 1 file changed, 1 insertion(+) diff --git a/cdist/conf/type/__consul_template_template/manifest b/cdist/conf/type/__consul_template_template/manifest index 4ba0329f..2fd0a46c 100755 --- a/cdist/conf/type/__consul_template_template/manifest +++ b/cdist/conf/type/__consul_template_template/manifest @@ -17,6 +17,7 @@ # You should have received a copy of the GNU General Public License # along with cdist. If not, see . # +# shellcheck disable=SC2031 name="$(cat "$__object/parameter/name" 2>/dev/null || echo "$__object_id")" state="$(cat "$__object/parameter/state")" From 9b567ed8f7030de20066f65f0d78e7bc323e6af1 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Fri, 5 Oct 2018 12:27:43 +0200 Subject: [PATCH 0127/1217] Fix SC2230. --- cdist/conf/type/__dot_file/explorer/home | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cdist/conf/type/__dot_file/explorer/home b/cdist/conf/type/__dot_file/explorer/home index 132cfc71..08d941bf 100755 --- a/cdist/conf/type/__dot_file/explorer/home +++ b/cdist/conf/type/__dot_file/explorer/home @@ -19,7 +19,7 @@ set -eu user="$(cat "${__object}/parameter/user")" -if which getent >/dev/null 2>&1; then +if command -v getent >/dev/null 2>&1; then line=$(getent passwd "${user}") else line=$(grep "^${user}:" /etc/passwd) From 596f3cf227c3e0ee219caf00a1973baf0d68db87 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Fri, 5 Oct 2018 12:30:52 +0200 Subject: [PATCH 0128/1217] Disable SC2119,SC2120 where appropriate. --- cdist/conf/type/__jail_freebsd10/gencode-remote | 2 ++ cdist/conf/type/__jail_freebsd9/gencode-remote | 2 ++ 2 files changed, 4 insertions(+) diff --git a/cdist/conf/type/__jail_freebsd10/gencode-remote b/cdist/conf/type/__jail_freebsd10/gencode-remote index 81912050..d01b30c6 100755 --- a/cdist/conf/type/__jail_freebsd10/gencode-remote +++ b/cdist/conf/type/__jail_freebsd10/gencode-remote @@ -111,6 +111,7 @@ startJail() { fi } +# shellcheck disable=SC2120 deleteJail() { # Unmount the jail's mountpoints if necessary cat < Date: Fri, 5 Oct 2018 12:32:56 +0200 Subject: [PATCH 0129/1217] Fix SC2145. --- .../conf/type/__install_partition_msdos_apply/gencode-remote | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cdist/conf/type/__install_partition_msdos_apply/gencode-remote b/cdist/conf/type/__install_partition_msdos_apply/gencode-remote index 644de33c..d699d8ad 100755 --- a/cdist/conf/type/__install_partition_msdos_apply/gencode-remote +++ b/cdist/conf/type/__install_partition_msdos_apply/gencode-remote @@ -21,11 +21,11 @@ #set -x die() { - echo "[__install_partition_msdos_apply] $@" >&2 + echo "[__install_partition_msdos_apply] $*" >&2 exit 1 } debug() { - #echo "[__install_partition_msdos_apply] $@" >&2 + #echo "[__install_partition_msdos_apply] $*" >&2 : } From 644ec85d801e17f38b8917b2822e611db97a1979 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Fri, 5 Oct 2018 12:50:01 +0200 Subject: [PATCH 0130/1217] Fix SC2162. --- cdist/conf/type/__rsync/gencode-local | 2 +- cdist/conf/type/__ssh_authorized_key/gencode-remote | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cdist/conf/type/__rsync/gencode-local b/cdist/conf/type/__rsync/gencode-local index c7196175..e36ded2f 100755 --- a/cdist/conf/type/__rsync/gencode-local +++ b/cdist/conf/type/__rsync/gencode-local @@ -29,7 +29,7 @@ fi set -- if [ -f "$__object/parameter/rsync-opts" ]; then - while read opts; do + while read -r opts; do set -- "$@" "--$opts" done < "$__object/parameter/rsync-opts" fi diff --git a/cdist/conf/type/__ssh_authorized_key/gencode-remote b/cdist/conf/type/__ssh_authorized_key/gencode-remote index 325854c2..82c90d61 100755 --- a/cdist/conf/type/__ssh_authorized_key/gencode-remote +++ b/cdist/conf/type/__ssh_authorized_key/gencode-remote @@ -78,7 +78,7 @@ if [ -s "$__object/explorer/entry" ]; then # Note that the files have to be sorted for comparison with `comm`. sort "$__object/explorer/entry" > "$__object/files/is" comm -13 "$__object/files/should" "$__object/files/is" | { - while read entry; do + while read -r entry; do remove_line "$file" "$entry" done } From a369acea72d173aa7f8bb2793ece4b8a91839caa Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Fri, 5 Oct 2018 12:52:44 +0200 Subject: [PATCH 0131/1217] Fix SC2021. --- cdist/conf/type/__postgres_role/gencode-remote | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cdist/conf/type/__postgres_role/gencode-remote b/cdist/conf/type/__postgres_role/gencode-remote index 14240992..f977e73e 100755 --- a/cdist/conf/type/__postgres_role/gencode-remote +++ b/cdist/conf/type/__postgres_role/gencode-remote @@ -34,7 +34,7 @@ case "$state_should" in if [ ! -f "$__object/parameter/$boolean" ]; then boolean="no${boolean}" fi - upper=$(echo $boolean | tr '[a-z]' '[A-Z]') + upper=$(echo $boolean | tr '[:lower:]' '[:upper:]') booleans="$booleans $upper" done From bf270b6f9c32ab345ed3ee30dc70aeb7a1ca8d81 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Fri, 5 Oct 2018 13:05:01 +0200 Subject: [PATCH 0132/1217] Fix SC2044. --- cdist/conf/type/__install_generate_fstab/gencode-local | 4 +++- cdist/conf/type/__install_mount/gencode-remote | 4 +++- .../conf/type/__install_partition_msdos_apply/gencode-remote | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/cdist/conf/type/__install_generate_fstab/gencode-local b/cdist/conf/type/__install_generate_fstab/gencode-local index aca42761..80455aaa 100755 --- a/cdist/conf/type/__install_generate_fstab/gencode-local +++ b/cdist/conf/type/__install_generate_fstab/gencode-local @@ -25,7 +25,9 @@ mkdir "$__object/files" # get current UUID's from target_host $__remote_exec "$__target_host" blkid > "$__object/files/blkid" -for object in $(find "$__global/object/__install_mount" -type d -name "$__cdist_object_marker"); do +find "$__global/object/__install_mount" -type d -name "$__cdist_object_marker" | +while IFS= read -r object +do device="$(cat "$object/parameter/device")" dir="$(cat "$object/parameter/dir")" type="$(cat "$object/parameter/type")" diff --git a/cdist/conf/type/__install_mount/gencode-remote b/cdist/conf/type/__install_mount/gencode-remote index ce96279a..4415f0ff 100755 --- a/cdist/conf/type/__install_mount/gencode-remote +++ b/cdist/conf/type/__install_mount/gencode-remote @@ -20,7 +20,9 @@ get_type_from_mkfs() { _device="$1" - for mkfs_object in $(find "$__global/object/__install_mkfs" -type d -name "$__cdist_object_marker"); do + find "$__global/object/__install_mkfs" -type d -name "$__cdist_object_marker" | + while IFS= read -r mkfs_object + do mkfs_device="$(cat "$mkfs_object/parameter/device")" if [ "$_device" = "$mkfs_device" ]; then cat "$mkfs_object/parameter/type" diff --git a/cdist/conf/type/__install_partition_msdos_apply/gencode-remote b/cdist/conf/type/__install_partition_msdos_apply/gencode-remote index 644de33c..69be8daf 100755 --- a/cdist/conf/type/__install_partition_msdos_apply/gencode-remote +++ b/cdist/conf/type/__install_partition_msdos_apply/gencode-remote @@ -59,7 +59,9 @@ size_to_mb() { get_objects() { objects_file=$(mktemp) - for object in $(find "$__global/object/__install_partition_msdos" -type d -name "$__cdist_object_marker"); do + find "$__global/object/__install_partition_msdos" -type d -name "$__cdist_object_marker" | + while IFS= read -r object + do object_device="$(cat "$object/parameter/device")" object_minor="$(cat "$object/parameter/minor")" echo "$object_device $object_minor $object" >> "$objects_file" From 9a61aab631a9a0a8425d20affe603f1ab2d194ae Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Fri, 5 Oct 2018 14:59:35 +0200 Subject: [PATCH 0133/1217] ++ --- docs/changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog b/docs/changelog index b5c218bc..419a3003 100644 --- a/docs/changelog +++ b/docs/changelog @@ -17,6 +17,7 @@ next: * Explorers and types: Fix SC2086: Double quote to prevent globbing and word splitting. (shellcheck) (Jonas Weber) * Explorers and types: Fix SC2164: Use cd ... || exit in case cd fails. (shellcheck) (Darko Poljak) * Explorers and types: Disable SC2016 where it is intended: Expressions don't expand in single quotes, use double quotes for that. (shellcheck) (Darko Poljak) + * Explorers and types: Fix SC2044: For loops over find output are fragile. Use find -exec or a while read loop. (shellcheck) (Darko Poljak) 4.10.3: 2018-09-23 * New global explorer: os_release (Ľubomír Kučera) From 0d80b4473b58623eaea63e115310e03201dd11fc Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Fri, 5 Oct 2018 15:04:22 +0200 Subject: [PATCH 0134/1217] Disable SC2031 for the single incident. --- cdist/conf/type/__consul_template_template/manifest | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cdist/conf/type/__consul_template_template/manifest b/cdist/conf/type/__consul_template_template/manifest index 2fd0a46c..506bc528 100755 --- a/cdist/conf/type/__consul_template_template/manifest +++ b/cdist/conf/type/__consul_template_template/manifest @@ -17,7 +17,6 @@ # You should have received a copy of the GNU General Public License # along with cdist. If not, see . # -# shellcheck disable=SC2031 name="$(cat "$__object/parameter/name" 2>/dev/null || echo "$__object_id")" state="$(cat "$__object/parameter/state")" @@ -37,6 +36,7 @@ if [ ! -f "$__object/parameter/source" ] && [ ! -f "$__object/parameter/source-f fi # Generate hcl config file +# shellcheck disable=SC2031 ( printf 'template {\n' cd "$__object/parameter/" From 02f39bcf6f32647e7ee2c4cbd7781439c3567f16 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Fri, 5 Oct 2018 15:08:25 +0200 Subject: [PATCH 0135/1217] Fix SC2028. --- cdist/conf/type/__hostname/gencode-remote | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/cdist/conf/type/__hostname/gencode-remote b/cdist/conf/type/__hostname/gencode-remote index fd9e7c98..fc50b651 100755 --- a/cdist/conf/type/__hostname/gencode-remote +++ b/cdist/conf/type/__hostname/gencode-remote @@ -59,8 +59,7 @@ echo changed >> "$__messages_out" # Use the good old way to set the hostname even on machines running systemd. case "$os" in archlinux|debian|ubuntu|devuan|centos|coreos) - # shellcheck disable=SC2028 - echo "printf '%s\n' '$name_should' > /etc/hostname" + printf "printf '%s\\n' '$name_should' > /etc/hostname\\n" echo "hostname -F /etc/hostname" ;; freebsd|openbsd) @@ -68,8 +67,7 @@ case "$os" in ;; suse) echo "hostname '$name_should'" - # shellcheck disable=SC2028 - echo "printf '%s\n' '$name_should' > /etc/HOSTNAME" + printf "printf '%s\\n' '$name_should' > /etc/HOSTNAME\\n" ;; esac From b284bafbee38be49b57b2b6caf8af8d6df4be2c9 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Fri, 5 Oct 2018 15:14:03 +0200 Subject: [PATCH 0136/1217] grep directly on the explorer file --- cdist/conf/type/__jail/manifest | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cdist/conf/type/__jail/manifest b/cdist/conf/type/__jail/manifest index 6fb4a306..adf9bd99 100755 --- a/cdist/conf/type/__jail/manifest +++ b/cdist/conf/type/__jail/manifest @@ -43,8 +43,7 @@ for property in *; do set -- "$@" "--$property" "$(cat "$property")" done -ver="$(cat "$__global/explorer/os_version")" -if echo "$ver" | grep -q '^10\.'; then # Version is 10.x +if grep -q '^10\.' "$(cat "$__global/explorer/os_version")" ; then # Version is 10.x __jail_freebsd10 "$@" else __jail_freebsd9 "$@" From 68fad03a6b98c48abf6cca05488998d7df872c7b Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Fri, 5 Oct 2018 15:18:59 +0200 Subject: [PATCH 0137/1217] Fix SC2120, SC2119. --- cdist/conf/type/__jail_freebsd10/gencode-remote | 6 ++---- cdist/conf/type/__jail_freebsd9/gencode-remote | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/cdist/conf/type/__jail_freebsd10/gencode-remote b/cdist/conf/type/__jail_freebsd10/gencode-remote index d01b30c6..230370c2 100755 --- a/cdist/conf/type/__jail_freebsd10/gencode-remote +++ b/cdist/conf/type/__jail_freebsd10/gencode-remote @@ -111,7 +111,6 @@ startJail() { fi } -# shellcheck disable=SC2120 deleteJail() { # Unmount the jail's mountpoints if necessary cat <=1 rw mount is mounted still for DIR in "${output}"; do - umount -F "/etc/fstab.${name}" "\$(echo "${DIR}" | awk '{print $3}')" + umount -F "/etc/fstab.${name}" "\$(echo "${DIR}" | awk '{print \$3}')" done fi output="\$(mount | grep "\/${name} (")" || true if [ -n "\${output}" ]; then # ro mount is mounted still - umount -F "/etc/fstab.${name}" "\$(echo "${output}" | awk '{print $3}')" + umount -F "/etc/fstab.${name}" "\$(echo "${output}" | awk '{print \$3}')" fi EOF # Remove the jail's rw mountpoints @@ -348,7 +347,6 @@ if [ "$present" = "EXISTS" ]; then # The jail currently exists exit 0 else # The jail is not supposed to exist stopJail - # shellcheck disable=SC2119 deleteJail exit 0 fi diff --git a/cdist/conf/type/__jail_freebsd9/gencode-remote b/cdist/conf/type/__jail_freebsd9/gencode-remote index e89672c2..13c237a9 100755 --- a/cdist/conf/type/__jail_freebsd9/gencode-remote +++ b/cdist/conf/type/__jail_freebsd9/gencode-remote @@ -116,7 +116,6 @@ startJail() { fi } -# shellcheck disable=SC2120 deleteJail() { # Unmount the jail's mountpoints if necessary cat <=1 rw mount is mounted still for DIR in "${output}"; do - umount -F "/etc/fstab.${name}" "\$(echo "${DIR}" | awk '{print $3}')" + umount -F "/etc/fstab.${name}" "\$(echo "${DIR}" | awk '{print \$3}')" done fi output="\$(mount | grep "\/${name} (")" || true if [ -n "\${output}" ]; then # ro mount is mounted still - umount -F "/etc/fstab.${name}" "\$(echo "${output}" | awk '{print $3}')" + umount -F "/etc/fstab.${name}" "\$(echo "${output}" | awk '{print \$3}')" fi EOF # Remove the jail's rw mountpoints @@ -343,7 +342,6 @@ if [ "$present" = "EXISTS" ]; then # The jail currently exists exit 0 else # The jail is not supposed to exist stopJail - # shellcheck disable=SC2119 deleteJail exit 0 fi From f039b0e6e5e4d90793061cc2a6dc73883367d767 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Sat, 6 Oct 2018 08:36:06 +0200 Subject: [PATCH 0138/1217] Fix SC2030,SC2031. --- cdist/conf/type/__consul_template_template/manifest | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/cdist/conf/type/__consul_template_template/manifest b/cdist/conf/type/__consul_template_template/manifest index 506bc528..1eae1fad 100755 --- a/cdist/conf/type/__consul_template_template/manifest +++ b/cdist/conf/type/__consul_template_template/manifest @@ -35,9 +35,13 @@ if [ ! -f "$__object/parameter/source" ] && [ ! -f "$__object/parameter/source-f exit 1 fi +if [ -f "$__object/parameter/source-file" ]; then + destination="${template_dir}/${name}" + require="__file${destination}" +fi + # Generate hcl config file -# shellcheck disable=SC2031 -( +{ printf 'template {\n' cd "$__object/parameter/" for param in *; do @@ -47,14 +51,11 @@ for param in *; do if [ "$source" = "-" ]; then source="$__object/stdin" fi - destination="${template_dir}/${name}" require="__directory${template_dir}" \ __file "$destination" \ --owner root --group root --mode 640 \ --source "$source" \ --state "$state" - # shellcheck disable=SC2030 - export require="__file${destination}" printf ' source = "%s"\n' "$destination" ;; @@ -68,7 +69,7 @@ for param in *; do esac done printf '}\n' -) | \ +} | \ require="$require __directory${conf_dir}" \ __config_file "${conf_dir}/${conf_file}" \ --owner root --group root --mode 640 \ From 877b4d2748018096fded1c9e81ee73a2257c53b5 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Sat, 6 Oct 2018 15:15:53 +0200 Subject: [PATCH 0139/1217] ++changelog --- docs/changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog b/docs/changelog index 419a3003..bc51c81b 100644 --- a/docs/changelog +++ b/docs/changelog @@ -18,6 +18,7 @@ next: * Explorers and types: Fix SC2164: Use cd ... || exit in case cd fails. (shellcheck) (Darko Poljak) * Explorers and types: Disable SC2016 where it is intended: Expressions don't expand in single quotes, use double quotes for that. (shellcheck) (Darko Poljak) * Explorers and types: Fix SC2044: For loops over find output are fragile. Use find -exec or a while read loop. (shellcheck) (Darko Poljak) + * Explorers and types: Fix SC1090,SC2021,SC2028,SC2030,SC2031,SC2039,SC2046,SC2116,SC2119,SC2120,SC2143,SC2145,SC2153,SC2162,SC2196,SC2230,SC2235. (shellcheck) (Darko Poljak) 4.10.3: 2018-09-23 * New global explorer: os_release (Ľubomír Kučera) From 8436f872a9cc32162e8991751558ecfcbcc7e967 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Sat, 6 Oct 2018 14:57:55 +0200 Subject: [PATCH 0140/1217] Add shellcheck makefile target. shellcheck when doing release. --- Makefile | 20 ++++++++++++++++++++ bin/build-helper | 25 ++++++++++++++++++++++++- bin/build-helper.freebsd | 25 ++++++++++++++++++++++++- 3 files changed, 68 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 3a1819be..4a756808 100644 --- a/Makefile +++ b/Makefile @@ -39,6 +39,9 @@ PYTHON_VERSION=cdist/version.py SPHINXM=make -C $(DOCS_SRC_DIR) man SPHINXH=make -C $(DOCS_SRC_DIR) html SPHINXC=make -C $(DOCS_SRC_DIR) clean + +SHELLCHECKCMD=shellcheck -s sh -f gcc -x +SHELLCHECK_SKIP=grep -v ': __.*is referenced but not assigned.*\[SC2154\]' ################################################################################ # Manpages # @@ -253,3 +256,20 @@ test-remote: pep8: $(helper) $@ + +shellcheck-global-explorers: + @find cdist/conf/explorer -type f -exec $(SHELLCHECKCMD) {} + | $(SHELLCHECK_SKIP) +shellcheck-manifests: + @find cdist/conf/type -type f -name manifest -exec $(SHELLCHECKCMD) {} + | $(SHELLCHECK_SKIP) + +shellcheck-local-gencodes: + @find cdist/conf/type -type f -name gencode-local -exec $(SHELLCHECKCMD) {} + | $(SHELLCHECK_SKIP) + +shellcheck-remote-gencodes: + @find cdist/conf/type -type f -name gencode-remote -exec $(SHELLCHECKCMD) {} + | $(SHELLCHECK_SKIP) + +shellcheck-gencodes: shellcheck-local-gencodes shellcheck-remote-gencodes + +shellcheck-types: shellcheck-manifests shellcheck-gencodes + +shellcheck: shellcheck-global-explorers shellcheck-types diff --git a/bin/build-helper b/bin/build-helper index ef15b6c2..02fa67d6 100755 --- a/bin/build-helper +++ b/bin/build-helper @@ -250,6 +250,7 @@ eof "$0" check-date "$0" check-unittest "$0" check-pep8 + "$0" shellcheck # Generate version file to be included in packaging "$0" target-version @@ -370,7 +371,29 @@ eof check-pep8) "$0" pep8 - echo "Please review pep8 report." + printf "\\nPlease review pep8 report.\\n" + while true + do + echo "Continue (yes/no)?" + any= + read any + case "$any" in + yes) + break + ;; + no) + exit 1 + ;; + *) + echo "Please answer with 'yes' or 'no' explicitly." + ;; + esac + done + ;; + + shellcheck) + make helper=${helper} WEBDIR=${WEBDIR} shellcheck + printf "\\nPlease review shellcheck report.\\n" while true do echo "Continue (yes/no)?" diff --git a/bin/build-helper.freebsd b/bin/build-helper.freebsd index e49b2f7a..081feb54 100755 --- a/bin/build-helper.freebsd +++ b/bin/build-helper.freebsd @@ -285,6 +285,7 @@ eof "$0" check-date "$0" check-unittest "$0" check-pep8 + "$0" shellcheck # Generate version file to be included in packaging "$0" target-version @@ -432,7 +433,29 @@ eof check-pep8) "$0" pep8 - echo "Please review pep8 report." + printf "\\nPlease review pep8 report.\\n" + while true + do + echo "Continue (yes/no)?" + any= + read any + case "$any" in + yes) + break + ;; + no) + exit 1 + ;; + *) + echo "Please answer with 'yes' or 'no' explicitly." + ;; + esac + done + ;; + + shellcheck) + make helper=${helper} WEBDIR=${WEBDIR} shellcheck + printf "\\nPlease review shellcheck report.\\n" while true do echo "Continue (yes/no)?" From 140518f1b0dddb1778d4e4c9ce3903f893a5a53e Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Sat, 6 Oct 2018 15:00:31 +0200 Subject: [PATCH 0141/1217] Add comment for SHELLCHECK_SKIP. --- Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Makefile b/Makefile index 4a756808..56229496 100644 --- a/Makefile +++ b/Makefile @@ -41,6 +41,8 @@ SPHINXH=make -C $(DOCS_SRC_DIR) html SPHINXC=make -C $(DOCS_SRC_DIR) clean SHELLCHECKCMD=shellcheck -s sh -f gcc -x +# Skip SC2154 for variables starting with __ since such variables are cdist +# environment variables. SHELLCHECK_SKIP=grep -v ': __.*is referenced but not assigned.*\[SC2154\]' ################################################################################ # Manpages From edaf4b46a521e2073de829ce5989127451b216ee Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Sat, 6 Oct 2018 22:53:07 +0200 Subject: [PATCH 0142/1217] ++changelog --- docs/changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog b/docs/changelog index bc51c81b..d7d31f52 100644 --- a/docs/changelog +++ b/docs/changelog @@ -19,6 +19,7 @@ next: * Explorers and types: Disable SC2016 where it is intended: Expressions don't expand in single quotes, use double quotes for that. (shellcheck) (Darko Poljak) * Explorers and types: Fix SC2044: For loops over find output are fragile. Use find -exec or a while read loop. (shellcheck) (Darko Poljak) * Explorers and types: Fix SC1090,SC2021,SC2028,SC2030,SC2031,SC2039,SC2046,SC2116,SC2119,SC2120,SC2143,SC2145,SC2153,SC2162,SC2196,SC2230,SC2235. (shellcheck) (Darko Poljak) + * Build: Add shellcheck makefile target and check when doing release (Darko Poljak) 4.10.3: 2018-09-23 * New global explorer: os_release (Ľubomír Kučera) From 3be1c4ad6f4a5f97d346f0a2a54b5526d8deb0ca Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Sun, 7 Oct 2018 10:21:08 +0200 Subject: [PATCH 0143/1217] If nothing found shellcheck targets should succeed. --- Makefile | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 56229496..e9cacced 100644 --- a/Makefile +++ b/Makefile @@ -260,15 +260,16 @@ pep8: $(helper) $@ shellcheck-global-explorers: - @find cdist/conf/explorer -type f -exec $(SHELLCHECKCMD) {} + | $(SHELLCHECK_SKIP) + @find cdist/conf/explorer -type f -exec $(SHELLCHECKCMD) {} + | $(SHELLCHECK_SKIP) || exit 0 + shellcheck-manifests: - @find cdist/conf/type -type f -name manifest -exec $(SHELLCHECKCMD) {} + | $(SHELLCHECK_SKIP) + @find cdist/conf/type -type f -name manifest -exec $(SHELLCHECKCMD) {} + | $(SHELLCHECK_SKIP) || exit 0 shellcheck-local-gencodes: - @find cdist/conf/type -type f -name gencode-local -exec $(SHELLCHECKCMD) {} + | $(SHELLCHECK_SKIP) + @find cdist/conf/type -type f -name gencode-local -exec $(SHELLCHECKCMD) {} + | $(SHELLCHECK_SKIP) || exit 0 shellcheck-remote-gencodes: - @find cdist/conf/type -type f -name gencode-remote -exec $(SHELLCHECKCMD) {} + | $(SHELLCHECK_SKIP) + @find cdist/conf/type -type f -name gencode-remote -exec $(SHELLCHECKCMD) {} + | $(SHELLCHECK_SKIP) || exit 0 shellcheck-gencodes: shellcheck-local-gencodes shellcheck-remote-gencodes From 83806e767a834ce80cc35f756090356fe276a205 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Sat, 6 Oct 2018 13:25:16 +0200 Subject: [PATCH 0144/1217] Disable SC1091 where appropriate. --- cdist/conf/explorer/lsb_codename | 1 + cdist/conf/explorer/lsb_description | 1 + cdist/conf/explorer/lsb_id | 1 + cdist/conf/explorer/lsb_release | 1 + 4 files changed, 4 insertions(+) diff --git a/cdist/conf/explorer/lsb_codename b/cdist/conf/explorer/lsb_codename index bfabd444..26bb8e3d 100755 --- a/cdist/conf/explorer/lsb_codename +++ b/cdist/conf/explorer/lsb_codename @@ -22,6 +22,7 @@ set +e case "$("$__explorer/os")" in openwrt) + # shellcheck disable=SC1091 (. /etc/openwrt_release && echo "$DISTRIB_CODENAME") ;; *) diff --git a/cdist/conf/explorer/lsb_description b/cdist/conf/explorer/lsb_description index 441fdbf3..b1009627 100755 --- a/cdist/conf/explorer/lsb_description +++ b/cdist/conf/explorer/lsb_description @@ -22,6 +22,7 @@ set +e case "$("$__explorer/os")" in openwrt) + # shellcheck disable=SC1091 (. /etc/openwrt_release && echo "$DISTRIB_DESCRIPTION") ;; *) diff --git a/cdist/conf/explorer/lsb_id b/cdist/conf/explorer/lsb_id index 1a12b610..82ff9977 100755 --- a/cdist/conf/explorer/lsb_id +++ b/cdist/conf/explorer/lsb_id @@ -22,6 +22,7 @@ set +e case "$("$__explorer/os")" in openwrt) + # shellcheck disable=SC1091 (. /etc/openwrt_release && echo "$DISTRIB_ID") ;; *) diff --git a/cdist/conf/explorer/lsb_release b/cdist/conf/explorer/lsb_release index 25eb95b1..5ebfff1a 100755 --- a/cdist/conf/explorer/lsb_release +++ b/cdist/conf/explorer/lsb_release @@ -22,6 +22,7 @@ set +e case "$("$__explorer/os")" in openwrt) + # shellcheck disable=SC1091 (. /etc/openwrt_release && echo "$DISTRIB_RELEASE") ;; *) From a9f27beb983b2f29e0af7b4b62434088556d292b Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Sat, 6 Oct 2018 13:41:09 +0200 Subject: [PATCH 0145/1217] Fix SC1117. --- cdist/conf/type/__cron/gencode-remote | 2 +- cdist/conf/type/__install_coreos/gencode-remote | 2 +- .../type/__install_reset_disk/gencode-remote | 2 +- cdist/conf/type/__jail_freebsd10/gencode-remote | 16 ++++++++-------- cdist/conf/type/__jail_freebsd9/gencode-remote | 12 ++++++------ cdist/conf/type/__mount/gencode-remote | 2 +- .../type/__package_pkgng_freebsd/gencode-remote | 2 +- cdist/conf/type/__rvm/gencode-remote | 2 +- .../type/__ssh_authorized_key/gencode-remote | 2 +- cdist/conf/type/__staged_file/gencode-local | 4 ++-- 10 files changed, 23 insertions(+), 23 deletions(-) diff --git a/cdist/conf/type/__cron/gencode-remote b/cdist/conf/type/__cron/gencode-remote index f58896af..ee626485 100755 --- a/cdist/conf/type/__cron/gencode-remote +++ b/cdist/conf/type/__cron/gencode-remote @@ -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|^# \(Cronie version .\..\)$" +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" ' { diff --git a/cdist/conf/type/__install_coreos/gencode-remote b/cdist/conf/type/__install_coreos/gencode-remote index fbe86479..f550b5a5 100755 --- a/cdist/conf/type/__install_coreos/gencode-remote +++ b/cdist/conf/type/__install_coreos/gencode-remote @@ -12,7 +12,7 @@ eof coreos-install -d "${device}" \ \$(if [ -s "\${ignition_file}" ]; then - printf -- "-i \${ignition_file}\n" + printf -- "-i \${ignition_file}\\n" fi) rm "\${ignition_file}" diff --git a/cdist/conf/type/__install_reset_disk/gencode-remote b/cdist/conf/type/__install_reset_disk/gencode-remote index 947dd472..ac9ae6cf 100755 --- a/cdist/conf/type/__install_reset_disk/gencode-remote +++ b/cdist/conf/type/__install_reset_disk/gencode-remote @@ -67,5 +67,5 @@ fi # erase partition table dd if=/dev/zero of=$disk bs=512 count=1 -printf 'w\n' | fdisk -u -c $disk || true +printf 'w\\n' | fdisk -u -c $disk || true DONE diff --git a/cdist/conf/type/__jail_freebsd10/gencode-remote b/cdist/conf/type/__jail_freebsd10/gencode-remote index 230370c2..a5e097f9 100755 --- a/cdist/conf/type/__jail_freebsd10/gencode-remote +++ b/cdist/conf/type/__jail_freebsd10/gencode-remote @@ -45,7 +45,7 @@ else # when $state=present, it's required. Enforce this. if [ "$state" = "present" ]; then exec >&2 - echo "If --state is 'present,' --ip must be given\!" + echo "If --state is 'present,' --ip must be given\\!" exit 1 fi fi @@ -114,17 +114,17 @@ startJail() { deleteJail() { # Unmount the jail's mountpoints if necessary cat <=1 rw mount is mounted still for DIR in "${output}"; do umount -F "/etc/fstab.${name}" "\$(echo "${DIR}" | awk '{print \$3}')" done fi - output="\$(mount | grep "\/${name} (")" || true + output="\$(mount | grep "\\/${name} (")" || true if [ -n "\${output}" ]; then # ro mount is mounted still umount -F "/etc/fstab.${name}" "\$(echo "${output}" | awk '{print \$3}')" fi @@ -275,9 +275,9 @@ cat <&1 >/dev/null # Close the FD==fail... @@ -290,7 +290,7 @@ add include \\\$devfsrules_unhide_basic add include \\\$devfsrules_unhide_login END fi - devfsruleset_num=\$(grep "\[${devfsruleset}=" /etc/devfs.rules | sed -n 's/\[.*=\([0-9]*\)\]/\1/pg') + devfsruleset_num=\$(grep "\\[${devfsruleset}=" /etc/devfs.rules | sed -n 's/\\[.*=\\([0-9]*\\)\\]/\\1/pg') if [ -n "\$devfsruleset_num" ]; then jaildata="\$jaildata devfs_ruleset=\"\${devfsruleset_num}\";" @@ -299,7 +299,7 @@ END EOF # shellcheck disable=SC2028 - echo "printf \"%s\\n%s\n%s\n\" \"\$jailheader\" \"\$jaildata\" \"\$jailtrailer\" >>\"\$jailfile\"" + echo "printf \"%s\\n%s\\n%s\\n\" \"\$jailheader\" \"\$jaildata\" \"\$jailtrailer\" >>\"\$jailfile\"" # Add $name to jail_list if $onboot=yes if [ "$onboot" = "yes" ]; then diff --git a/cdist/conf/type/__jail_freebsd9/gencode-remote b/cdist/conf/type/__jail_freebsd9/gencode-remote index 13c237a9..7f3828b2 100755 --- a/cdist/conf/type/__jail_freebsd9/gencode-remote +++ b/cdist/conf/type/__jail_freebsd9/gencode-remote @@ -45,7 +45,7 @@ else # when $state=present, it's required. Enforce this. if [ "$state" = "present" ]; then exec >&2 - echo "If --state is 'present,' --ip must be given\!" + echo "If --state is 'present,' --ip must be given\\!" exit 1 fi fi @@ -119,17 +119,17 @@ startJail() { deleteJail() { # Unmount the jail's mountpoints if necessary cat <=1 rw mount is mounted still for DIR in "${output}"; do umount -F "/etc/fstab.${name}" "\$(echo "${DIR}" | awk '{print \$3}')" done fi - output="\$(mount | grep "\/${name} (")" || true + output="\$(mount | grep "\\/${name} (")" || true if [ -n "\${output}" ]; then # ro mount is mounted still umount -F "/etc/fstab.${name}" "\$(echo "${output}" | awk '{print \$3}')" fi @@ -279,9 +279,9 @@ END if [ ! -f /etc/devfs.rules ]; then touch /etc/devfs.rules fi - if [ -z "\$(grep '\[jailrules=' /etc/devfs.rules)" ]; then # The default ruleset doesn't exist + if [ -z "\$(grep '\\[jailrules=' /etc/devfs.rules)" ]; then # The default ruleset doesn't exist # Get the highest-numbered ruleset - highest="\$(sed -n 's/\[.*=\([0-9]*\)\]/\1/pg' /etc/devfs.rules | sort -u | tail -n 1)" || true + highest="\$(sed -n 's/\\[.*=\\([0-9]*\\)\\]/\\1/pg' /etc/devfs.rules | sort -u | tail -n 1)" || true # increment by 1 let num="\${highest}+1" 2>&- >&- # add default ruleset diff --git a/cdist/conf/type/__mount/gencode-remote b/cdist/conf/type/__mount/gencode-remote index 66d85f88..e8266a0b 100755 --- a/cdist/conf/type/__mount/gencode-remote +++ b/cdist/conf/type/__mount/gencode-remote @@ -39,7 +39,7 @@ case "$state_should" in printf ' -o %s' "$(cat "$__object/parameter/options")" fi printf ' %s' "$(cat "$__object/parameter/device")" - printf " %s\n" "$path" + printf " %s\\n" "$path" else # mount using existing fstab entry printf 'mount "%s"\n' "$path" diff --git a/cdist/conf/type/__package_pkgng_freebsd/gencode-remote b/cdist/conf/type/__package_pkgng_freebsd/gencode-remote index b59e3648..592d4d0f 100755 --- a/cdist/conf/type/__package_pkgng_freebsd/gencode-remote +++ b/cdist/conf/type/__package_pkgng_freebsd/gencode-remote @@ -95,7 +95,7 @@ if [ -n "$curr_version" ]; then # PKG *is* installed if [ "$upgrade" = "true" ]; then execcmd "upg" "${cmd}" else - printf "Version %s is already installed and pkg-ng can't upgrade directly to version %s.\nTo upgrade to the latest version, use the --upgrade flag.\n" "$curr_version" "$version" >&2 + printf "Version %s is already installed and pkg-ng can't upgrade directly to version %s.\\nTo upgrade to the latest version, use the --upgrade flag.\\n" "$curr_version" "$version" >&2 exit 1 fi # PKG is supposed to be installed to the latest version diff --git a/cdist/conf/type/__rvm/gencode-remote b/cdist/conf/type/__rvm/gencode-remote index 494c8fd8..993191c1 100755 --- a/cdist/conf/type/__rvm/gencode-remote +++ b/cdist/conf/type/__rvm/gencode-remote @@ -34,7 +34,7 @@ DONE absent) cat << DONE su - $user -c "rm -Rf \"\\\$HOME/.rvm\"; -sed '/rvm\/scripts\/rvm/d' \"\\\$HOME/.bashrc\" > \"\\\$HOME/.bashrc.cdist-tmp\" +sed '/rvm\\/scripts\\/rvm/d' \"\\\$HOME/.bashrc\" > \"\\\$HOME/.bashrc.cdist-tmp\" mv \"\\\$HOME/.bashrc.cdist-tmp\" \"\\\$HOME/.bashrc\"" DONE ;; diff --git a/cdist/conf/type/__ssh_authorized_key/gencode-remote b/cdist/conf/type/__ssh_authorized_key/gencode-remote index 82c90d61..f37aa565 100755 --- a/cdist/conf/type/__ssh_authorized_key/gencode-remote +++ b/cdist/conf/type/__ssh_authorized_key/gencode-remote @@ -48,7 +48,7 @@ add_line() { line="$2" # escape single quotes line_sanitised=$(echo "$line" | sed -e "s/'/'\"'\"'/g") - printf '%s' "printf '%s\n' '$line_sanitised' >> $file" + printf '%s' "printf '%s\\n' '$line_sanitised' >> $file" } diff --git a/cdist/conf/type/__staged_file/gencode-local b/cdist/conf/type/__staged_file/gencode-local index 4edaba7f..e78b50bd 100755 --- a/cdist/conf/type/__staged_file/gencode-local +++ b/cdist/conf/type/__staged_file/gencode-local @@ -67,10 +67,10 @@ fetch_and_prepare_file() { # shellcheck disable=SC2016 printf 'cd "$tmpdir"\n' # shellcheck disable=SC2059 - printf "$fetch_command > \"%s\"\n" "$source" "$source_file_name" + printf "$fetch_command > \"%s\"\\n" "$source" "$source_file_name" prepare_command="$(cat "$__object/parameter/prepare-command")" # shellcheck disable=SC2059 - printf "$prepare_command > \"%s\"\n" "$source_file_name" "$stage_file" + printf "$prepare_command > \"%s\"\\n" "$source_file_name" "$stage_file" printf 'cd - >/dev/null\n' # shellcheck disable=SC2016 printf 'rm -rf "$tmpdir"\n' From a78baccc827ece35501888cf83dab62144dac1ea Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Sat, 6 Oct 2018 13:59:47 +0200 Subject: [PATCH 0146/1217] Fix SC2154. Note: ignoring __ vars. --- cdist/conf/type/__jail_freebsd10/gencode-remote | 4 ++-- cdist/conf/type/__jail_freebsd9/gencode-remote | 4 ++-- cdist/conf/type/__package_opkg/gencode-remote | 2 +- cdist/conf/type/__pf_ruleset/gencode-local | 4 ++-- cdist/conf/type/__postgres_extension/gencode-remote | 2 +- cdist/conf/type/__process/gencode-remote | 1 + cdist/conf/type/__zypper_service/gencode-remote | 2 +- 7 files changed, 10 insertions(+), 9 deletions(-) diff --git a/cdist/conf/type/__jail_freebsd10/gencode-remote b/cdist/conf/type/__jail_freebsd10/gencode-remote index a5e097f9..73518326 100755 --- a/cdist/conf/type/__jail_freebsd10/gencode-remote +++ b/cdist/conf/type/__jail_freebsd10/gencode-remote @@ -120,13 +120,13 @@ deleteJail() { fi output="\$(mount | grep "\\/rw\\/${name}\\/")" || true if [ -n "\${output}" ]; then # >=1 rw mount is mounted still - for DIR in "${output}"; do + for DIR in "\${output}"; do umount -F "/etc/fstab.${name}" "\$(echo "${DIR}" | awk '{print \$3}')" done fi output="\$(mount | grep "\\/${name} (")" || true if [ -n "\${output}" ]; then # ro mount is mounted still - umount -F "/etc/fstab.${name}" "\$(echo "${output}" | awk '{print \$3}')" + umount -F "/etc/fstab.${name}" "\$(echo "\${output}" | awk '{print \$3}')" fi EOF # Remove the jail's rw mountpoints diff --git a/cdist/conf/type/__jail_freebsd9/gencode-remote b/cdist/conf/type/__jail_freebsd9/gencode-remote index 7f3828b2..be583e5d 100755 --- a/cdist/conf/type/__jail_freebsd9/gencode-remote +++ b/cdist/conf/type/__jail_freebsd9/gencode-remote @@ -125,13 +125,13 @@ deleteJail() { fi output="\$(mount | grep "\\/rw\\/${name}\\/")" || true if [ -n "\${output}" ]; then # >=1 rw mount is mounted still - for DIR in "${output}"; do + for DIR in "\${output}"; do umount -F "/etc/fstab.${name}" "\$(echo "${DIR}" | awk '{print \$3}')" done fi output="\$(mount | grep "\\/${name} (")" || true if [ -n "\${output}" ]; then # ro mount is mounted still - umount -F "/etc/fstab.${name}" "\$(echo "${output}" | awk '{print \$3}')" + umount -F "/etc/fstab.${name}" "\$(echo "\${output}" | awk '{print \$3}')" fi EOF # Remove the jail's rw mountpoints diff --git a/cdist/conf/type/__package_opkg/gencode-remote b/cdist/conf/type/__package_opkg/gencode-remote index 7013ec9f..e94ff388 100755 --- a/cdist/conf/type/__package_opkg/gencode-remote +++ b/cdist/conf/type/__package_opkg/gencode-remote @@ -51,7 +51,7 @@ case "$state_should" in echo "opkg --verbosity=0 remove '$name'" ;; *) - echo "Unknown state: $state" >&2 + echo "Unknown state: ${state_should}" >&2 exit 1 ;; esac diff --git a/cdist/conf/type/__pf_ruleset/gencode-local b/cdist/conf/type/__pf_ruleset/gencode-local index b9de1bce..11bfb0b1 100755 --- a/cdist/conf/type/__pf_ruleset/gencode-local +++ b/cdist/conf/type/__pf_ruleset/gencode-local @@ -69,10 +69,10 @@ fi if [ -n "${cksum}" ]; then if [ ! "\${currentSum}" = "${cksum}" ]; then - $__remote_copy "${source}" "${my_target_host}:${rcvar}.new" + $__remote_copy "${source}" "\${my_target_host}:${rcvar}.new" fi else # File just doesn't exist yet - $__remote_copy "${source}" "${my_target_host}:${rcvar}.new" + $__remote_copy "${source}" "\${my_target_host}:${rcvar}.new" fi EOF diff --git a/cdist/conf/type/__postgres_extension/gencode-remote b/cdist/conf/type/__postgres_extension/gencode-remote index f7895103..627067c7 100755 --- a/cdist/conf/type/__postgres_extension/gencode-remote +++ b/cdist/conf/type/__postgres_extension/gencode-remote @@ -33,7 +33,7 @@ case "$state_should" in echo "su - postgres -c 'psql -c \"$cmd\" \"$dbname\"'" ;; absent) - cmd="DROP EXTENSION IF EXISTS $extenstion" + cmd="DROP EXTENSION IF EXISTS $extension" echo "su - postgres -c 'psql -c \"$cmd\" \"$dbname\"'" ;; esac diff --git a/cdist/conf/type/__process/gencode-remote b/cdist/conf/type/__process/gencode-remote index fc491321..d14cf506 100755 --- a/cdist/conf/type/__process/gencode-remote +++ b/cdist/conf/type/__process/gencode-remote @@ -52,6 +52,7 @@ case "$state_should" in if [ -f "$__object/parameter/stop" ]; then cat "$__object/parameter/stop" else + # TODO: what should be runs variable? echo kill "${runs}" fi echo "stopped" >> "$__messages_out" diff --git a/cdist/conf/type/__zypper_service/gencode-remote b/cdist/conf/type/__zypper_service/gencode-remote index 59ffc942..4ccfe301 100755 --- a/cdist/conf/type/__zypper_service/gencode-remote +++ b/cdist/conf/type/__zypper_service/gencode-remote @@ -76,7 +76,7 @@ case "$state_should" in echo "zypper $zypper_def_opts ref" ;; absent) - echo "zypper $zypper_def_opts removeservice $service_id" + echo "zypper $zypper_def_opts removeservice $exp_id" echo "zypper $zypper_def_opts refs" echo "zypper $zypper_def_opts ref" ;; From e9b823bc390c30cb9294591c628c5353d194d0ef Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Sun, 7 Oct 2018 09:59:01 +0200 Subject: [PATCH 0147/1217] Better fixes. --- cdist/conf/type/__cron/gencode-remote | 2 +- cdist/conf/type/__jail_freebsd10/gencode-remote | 2 +- cdist/conf/type/__jail_freebsd9/gencode-remote | 2 +- cdist/conf/type/__mount/gencode-remote | 2 +- cdist/conf/type/__package_pkgng_freebsd/gencode-remote | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cdist/conf/type/__cron/gencode-remote b/cdist/conf/type/__cron/gencode-remote index ee626485..59398058 100755 --- a/cdist/conf/type/__cron/gencode-remote +++ b/cdist/conf/type/__cron/gencode-remote @@ -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|^# \\(Cronie version .\\..\\)$" +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" ' { diff --git a/cdist/conf/type/__jail_freebsd10/gencode-remote b/cdist/conf/type/__jail_freebsd10/gencode-remote index 73518326..4f376c25 100755 --- a/cdist/conf/type/__jail_freebsd10/gencode-remote +++ b/cdist/conf/type/__jail_freebsd10/gencode-remote @@ -45,7 +45,7 @@ else # when $state=present, it's required. Enforce this. if [ "$state" = "present" ]; then exec >&2 - echo "If --state is 'present,' --ip must be given\\!" + printf 'If --state is "present", --ip must be given\!\n' exit 1 fi fi diff --git a/cdist/conf/type/__jail_freebsd9/gencode-remote b/cdist/conf/type/__jail_freebsd9/gencode-remote index be583e5d..68229d3e 100755 --- a/cdist/conf/type/__jail_freebsd9/gencode-remote +++ b/cdist/conf/type/__jail_freebsd9/gencode-remote @@ -45,7 +45,7 @@ else # when $state=present, it's required. Enforce this. if [ "$state" = "present" ]; then exec >&2 - echo "If --state is 'present,' --ip must be given\\!" + printf 'If --state is "present", --ip must be given\!\n' exit 1 fi fi diff --git a/cdist/conf/type/__mount/gencode-remote b/cdist/conf/type/__mount/gencode-remote index e8266a0b..b2096764 100755 --- a/cdist/conf/type/__mount/gencode-remote +++ b/cdist/conf/type/__mount/gencode-remote @@ -39,7 +39,7 @@ case "$state_should" in printf ' -o %s' "$(cat "$__object/parameter/options")" fi printf ' %s' "$(cat "$__object/parameter/device")" - printf " %s\\n" "$path" + printf ' %s\n' "$path" else # mount using existing fstab entry printf 'mount "%s"\n' "$path" diff --git a/cdist/conf/type/__package_pkgng_freebsd/gencode-remote b/cdist/conf/type/__package_pkgng_freebsd/gencode-remote index 592d4d0f..b72544c1 100755 --- a/cdist/conf/type/__package_pkgng_freebsd/gencode-remote +++ b/cdist/conf/type/__package_pkgng_freebsd/gencode-remote @@ -95,7 +95,7 @@ if [ -n "$curr_version" ]; then # PKG *is* installed if [ "$upgrade" = "true" ]; then execcmd "upg" "${cmd}" else - printf "Version %s is already installed and pkg-ng can't upgrade directly to version %s.\\nTo upgrade to the latest version, use the --upgrade flag.\\n" "$curr_version" "$version" >&2 + printf 'Version %s is already installed and pkg-ng cannot upgrade directly to version %s.\nTo upgrade to the latest version, use the --upgrade flag.\n' "$curr_version" "$version" >&2 exit 1 fi # PKG is supposed to be installed to the latest version From 334201b9452ef8bc6207e7cc8b118dc1ba0607e5 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Sun, 7 Oct 2018 10:20:08 +0200 Subject: [PATCH 0148/1217] Fix remaining shellcheck problems. --- cdist/conf/type/__daemontools/manifest | 1 + cdist/conf/type/__grafana_dashboard/manifest | 1 + cdist/conf/type/__jail/manifest | 2 +- cdist/conf/type/__letsencrypt_cert/manifest | 2 +- cdist/conf/type/__mount/manifest | 2 +- cdist/conf/type/__postfix_master/manifest | 1 - cdist/conf/type/__process/gencode-remote | 3 +-- cdist/conf/type/__prometheus_alertmanager/manifest | 1 + cdist/conf/type/__prometheus_exporter/manifest | 1 + cdist/conf/type/__prometheus_server/manifest | 1 + cdist/conf/type/__ssh_authorized_keys/manifest | 2 +- 11 files changed, 10 insertions(+), 7 deletions(-) diff --git a/cdist/conf/type/__daemontools/manifest b/cdist/conf/type/__daemontools/manifest index 656f4984..b04c7e07 100755 --- a/cdist/conf/type/__daemontools/manifest +++ b/cdist/conf/type/__daemontools/manifest @@ -9,6 +9,7 @@ __directory "$servicedir" --mode 700 os=$(cat "$__global/explorer/os") init=$(cat "$__global/explorer/init") +require="" case $os in freebsd) # TODO change to __start_on_boot once it supports freebsd diff --git a/cdist/conf/type/__grafana_dashboard/manifest b/cdist/conf/type/__grafana_dashboard/manifest index 2e9bd115..9cd1465d 100755 --- a/cdist/conf/type/__grafana_dashboard/manifest +++ b/cdist/conf/type/__grafana_dashboard/manifest @@ -3,6 +3,7 @@ os=$(cat "$__global/explorer/os") os_version=$(cat "$__global/explorer/os_version") +require="" case $os in debian|devuan) case $os_version in diff --git a/cdist/conf/type/__jail/manifest b/cdist/conf/type/__jail/manifest index adf9bd99..fad6a3a1 100755 --- a/cdist/conf/type/__jail/manifest +++ b/cdist/conf/type/__jail/manifest @@ -37,7 +37,7 @@ jaildir="$(cat "$__object/parameter/jaildir")" __directory "${jaildir}" --parents -set -- "$@" "$__object_id" "--state" "$state" +set -- "$@" "$__object_id" cd "$__object/parameter" for property in *; do set -- "$@" "--$property" "$(cat "$property")" diff --git a/cdist/conf/type/__letsencrypt_cert/manifest b/cdist/conf/type/__letsencrypt_cert/manifest index 56e3532c..d6892c9b 100755 --- a/cdist/conf/type/__letsencrypt_cert/manifest +++ b/cdist/conf/type/__letsencrypt_cert/manifest @@ -91,7 +91,7 @@ if [ -f "${__object}/parameter/automatic-renewal" ]; then renew_hook_param="${__object}/parameter/renew-hook" renew_hook="" if [ -f "${renew_hook_param}" ]; then - while read hook; do + while read -r hook; do renew_hook="${renew_hook} --renew-hook \"${hook}\"" done < "${renew_hook_param}" fi diff --git a/cdist/conf/type/__mount/manifest b/cdist/conf/type/__mount/manifest index 73937899..999d806c 100755 --- a/cdist/conf/type/__mount/manifest +++ b/cdist/conf/type/__mount/manifest @@ -31,7 +31,7 @@ printf " %s" "$type" options="$(cat "$__object/parameter/options")" printf " %s" "$options" printf " %s" "$(cat "$__object/parameter/dump")" -printf " %s\n" "$(cat "$__object/parameter/pass")" +printf ' %s\n' "$(cat "$__object/parameter/pass")" ) | \ __block "$__object_name" \ --file "/etc/fstab" \ diff --git a/cdist/conf/type/__postfix_master/manifest b/cdist/conf/type/__postfix_master/manifest index 94b5044f..0960ea41 100755 --- a/cdist/conf/type/__postfix_master/manifest +++ b/cdist/conf/type/__postfix_master/manifest @@ -50,7 +50,6 @@ entry="$__object/files/entry" echo "# $(cat "$__object/parameter/comment")" fi printf "%s " "$service" - printf "%s " "$type" for parameter in type private unpriv chroot wakeup maxproc; do printf "%s " "$(cat "$__object/parameter/$parameter")" done diff --git a/cdist/conf/type/__process/gencode-remote b/cdist/conf/type/__process/gencode-remote index d14cf506..ec9691b9 100755 --- a/cdist/conf/type/__process/gencode-remote +++ b/cdist/conf/type/__process/gencode-remote @@ -52,8 +52,7 @@ case "$state_should" in if [ -f "$__object/parameter/stop" ]; then cat "$__object/parameter/stop" else - # TODO: what should be runs variable? - echo kill "${runs}" + echo kill "$(cat "$__object/parameter/runs")" fi echo "stopped" >> "$__messages_out" ;; diff --git a/cdist/conf/type/__prometheus_alertmanager/manifest b/cdist/conf/type/__prometheus_alertmanager/manifest index 3f417526..64ef76af 100755 --- a/cdist/conf/type/__prometheus_alertmanager/manifest +++ b/cdist/conf/type/__prometheus_alertmanager/manifest @@ -15,6 +15,7 @@ storage_path="$(cat "$__object/parameter/storage-path")" ##### INSTALL THE PACKAGE ################################################### require_pkg="" # what to require if I want to require "the package" +require="" if [ -f "$__object/parameter/install-from-backports" ]; then os=$(cat "$__global/explorer/os") os_version=$(cat "$__global/explorer/os_version") diff --git a/cdist/conf/type/__prometheus_exporter/manifest b/cdist/conf/type/__prometheus_exporter/manifest index 35e654e2..b9e14531 100644 --- a/cdist/conf/type/__prometheus_exporter/manifest +++ b/cdist/conf/type/__prometheus_exporter/manifest @@ -7,6 +7,7 @@ exporter="$(cat "$__object/parameter/exporter")" __user prometheus --system +require="" case $exporter in node) TEXTFILES=/service/node-exporter/textfiles # path for the textfiles collector diff --git a/cdist/conf/type/__prometheus_server/manifest b/cdist/conf/type/__prometheus_server/manifest index 63b7b438..8685130f 100755 --- a/cdist/conf/type/__prometheus_server/manifest +++ b/cdist/conf/type/__prometheus_server/manifest @@ -18,6 +18,7 @@ rule_files="$(cat "$__object/parameter/rule-files")" ##### INSTALL THE PACKAGE ################################################### require_pkg="" # what to require if I want to require "the package" +require="" if [ -f "$__object/parameter/install-from-backports" ]; then os=$(cat "$__global/explorer/os") os_version=$(cat "$__global/explorer/os_version") diff --git a/cdist/conf/type/__ssh_authorized_keys/manifest b/cdist/conf/type/__ssh_authorized_keys/manifest index 8cac3449..f6ff74c3 100755 --- a/cdist/conf/type/__ssh_authorized_keys/manifest +++ b/cdist/conf/type/__ssh_authorized_keys/manifest @@ -61,7 +61,7 @@ _cksum() { echo "$1" | cksum | cut -d' ' -f 1 } -while read key; do +while read -r key; do type_and_key="$(echo "$key" | tr ' ' '\n' | awk '/^(ssh|ecdsa)-[^ ]+/ { printf $1" "; getline; printf $1 }')" object_id="$(_cksum "$file")-$(_cksum "$type_and_key")" set -- "$object_id" From cb826ad5708a3ceaadd6616098fbb9cd793ee652 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Sun, 7 Oct 2018 18:47:38 +0200 Subject: [PATCH 0149/1217] ++changelog --- docs/changelog | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/docs/changelog b/docs/changelog index d7d31f52..1a3a7e2a 100644 --- a/docs/changelog +++ b/docs/changelog @@ -4,21 +4,7 @@ Changelog next: * Core: Transfer all files of a directory at once instead of calling copy once per file (myeisha) * Core: Add timestamp (optional) to log messages (Darko Poljak) - * Explorers, manifests, gencodes: Fix SC2166: and/or operators in test (shellcheck) (Jonas Weber, Thomas Eckert) - * Explorers and types: Fix SC2004: $/${} is unnecessary on arithmetic variables (shellcheck) (Darko Poljak) - * Explorers and types: Fix SC2005: Useless echo? Instead of echo $(cmd), just use cmd (shellcheck) (Darko Poljak) - * Explorers and types: Fix SC2002: Useless cat. Consider 'cmd < file | ..' or 'cmd file | ..' instead (shellcheck) (Darko Poljak) - * Explorers and types: Fix SC2039: In POSIX sh, something is undefined (shellcheck) (Darko Poljak) - * Explorers and types: Fix SC2045: Iterating over ls output is fragile. Use globs. (shellcheck) (Thomas Eckert) - * Explorers and types: Fix SC2148: Tips depend on target shell and yours is unknown. Add a shebang. (shellcheck) (Thomas Eckert) - * Explorers and types: Fix SC2069: To redirect stdout+stderr, 2>&1 must be last (or use '{ cmd > file; } 2>&1' to clarify). (shellcheck) (Jonas Weber) - * Explorers and types: Fix SC2034: foo appears unused. Verify it or export it. (shellcheck) (Jonas Weber) - * Explorers and types: Fix SC2215, SC2059, SC2155, SC2091. (shellcheck) (Jonas Weber) - * Explorers and types: Fix SC2086: Double quote to prevent globbing and word splitting. (shellcheck) (Jonas Weber) - * Explorers and types: Fix SC2164: Use cd ... || exit in case cd fails. (shellcheck) (Darko Poljak) - * Explorers and types: Disable SC2016 where it is intended: Expressions don't expand in single quotes, use double quotes for that. (shellcheck) (Darko Poljak) - * Explorers and types: Fix SC2044: For loops over find output are fragile. Use find -exec or a while read loop. (shellcheck) (Darko Poljak) - * Explorers and types: Fix SC1090,SC2021,SC2028,SC2030,SC2031,SC2039,SC2046,SC2116,SC2119,SC2120,SC2143,SC2145,SC2153,SC2162,SC2196,SC2230,SC2235. (shellcheck) (Darko Poljak) + * Explorers and types: Fix shellcheck found problems and encountered bugs (Jonas Weber, Thomas Eckert, Darko Poljak) * Build: Add shellcheck makefile target and check when doing release (Darko Poljak) 4.10.3: 2018-09-23 From ab8f87864e2be88a9529eb68f346f6139f7443c1 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Sun, 7 Oct 2018 19:09:14 +0200 Subject: [PATCH 0150/1217] Add shellcheck-ing for type explorers and auxiliary files. --- Makefile | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index e9cacced..9f81cf06 100644 --- a/Makefile +++ b/Makefile @@ -262,6 +262,9 @@ pep8: shellcheck-global-explorers: @find cdist/conf/explorer -type f -exec $(SHELLCHECKCMD) {} + | $(SHELLCHECK_SKIP) || exit 0 +shellcheck-type-explorers: + @find cdist/conf/type -type f -path "*/explorer/*" -exec $(SHELLCHECKCMD) {} + | $(SHELLCHECK_SKIP) || exit 0 + shellcheck-manifests: @find cdist/conf/type -type f -name manifest -exec $(SHELLCHECKCMD) {} + | $(SHELLCHECK_SKIP) || exit 0 @@ -273,6 +276,11 @@ shellcheck-remote-gencodes: shellcheck-gencodes: shellcheck-local-gencodes shellcheck-remote-gencodes -shellcheck-types: shellcheck-manifests shellcheck-gencodes +shellcheck-types: shellcheck-type-explorers shellcheck-manifests shellcheck-gencodes shellcheck: shellcheck-global-explorers shellcheck-types + +shellcheck-type-files: + @find cdist/conf/type -type f -path "*/files/*" -exec $(SHELLCHECKCMD) {} + | $(SHELLCHECK_SKIP) || exit 0 + +shellcheck-with-files: shellcheck shellcheck-type-files From 638ddd95d6b7f07c88baa44a8c6aa1022bf405e0 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Sun, 7 Oct 2018 19:41:44 +0200 Subject: [PATCH 0151/1217] Fix problems found by sellcheck in type explorers. --- cdist/conf/type/__apt_ppa/explorer/state | 3 ++- .../conf/type/__go_get/explorer/go-executable | 2 ++ .../type/__jail_freebsd10/explorer/status | 2 +- .../conf/type/__jail_freebsd9/explorer/status | 2 +- .../type/__postgres_database/explorer/state | 2 +- .../conf/type/__postgres_role/explorer/state | 2 +- .../type/__ssh_authorized_key/explorer/entry | 2 +- .../conf/type/__start_on_boot/explorer/state | 21 ++++++++++++++++--- .../type/__zypper_service/explorer/service_id | 2 +- 9 files changed, 28 insertions(+), 10 deletions(-) diff --git a/cdist/conf/type/__apt_ppa/explorer/state b/cdist/conf/type/__apt_ppa/explorer/state index 2bb4f65a..d47e7d20 100755 --- a/cdist/conf/type/__apt_ppa/explorer/state +++ b/cdist/conf/type/__apt_ppa/explorer/state @@ -23,10 +23,11 @@ name="$__object_id" +# shellcheck disable=SC1091 . /etc/lsb-release repo_name="${name#ppa:}" -repo_file_name="$(echo "$repo_name" | sed -e "s|[/:]|-|" -e "s|\.|_|")-${DISTRIB_CODENAME}.list" +repo_file_name="$(echo "$repo_name" | sed -e 's|[/:]|-|' -e 's|\.|_|')-${DISTRIB_CODENAME}.list" [ -s "/etc/apt/sources.list.d/${repo_file_name}" ] \ && echo present || echo absent diff --git a/cdist/conf/type/__go_get/explorer/go-executable b/cdist/conf/type/__go_get/explorer/go-executable index bdce7559..87182282 100755 --- a/cdist/conf/type/__go_get/explorer/go-executable +++ b/cdist/conf/type/__go_get/explorer/go-executable @@ -1,4 +1,6 @@ #!/bin/sh +# shellcheck disable=SC1091 [ -f /etc/environment ] && . /etc/environment +# shellcheck disable=SC1091 [ -f /etc/profile ] && . /etc/profile go version 2>/dev/null || true diff --git a/cdist/conf/type/__jail_freebsd10/explorer/status b/cdist/conf/type/__jail_freebsd10/explorer/status index 1ceba212..c8039f21 100755 --- a/cdist/conf/type/__jail_freebsd10/explorer/status +++ b/cdist/conf/type/__jail_freebsd10/explorer/status @@ -39,7 +39,7 @@ fi # backslash-escaped $jaildir sjaildir="$(echo ${jaildir} | sed 's#/#\\/#g')" -jls_output="$(jls | grep "[ ]${sjaildir}\/${name}\$")" || true +jls_output="$(jls | grep "[ ]${sjaildir}\\/${name}\$")" || true if [ -n "${jls_output}" ]; then echo "STARTED" diff --git a/cdist/conf/type/__jail_freebsd9/explorer/status b/cdist/conf/type/__jail_freebsd9/explorer/status index 1ceba212..c8039f21 100755 --- a/cdist/conf/type/__jail_freebsd9/explorer/status +++ b/cdist/conf/type/__jail_freebsd9/explorer/status @@ -39,7 +39,7 @@ fi # backslash-escaped $jaildir sjaildir="$(echo ${jaildir} | sed 's#/#\\/#g')" -jls_output="$(jls | grep "[ ]${sjaildir}\/${name}\$")" || true +jls_output="$(jls | grep "[ ]${sjaildir}\\/${name}\$")" || true if [ -n "${jls_output}" ]; then echo "STARTED" diff --git a/cdist/conf/type/__postgres_database/explorer/state b/cdist/conf/type/__postgres_database/explorer/state index dc9659e2..54eb768d 100755 --- a/cdist/conf/type/__postgres_database/explorer/state +++ b/cdist/conf/type/__postgres_database/explorer/state @@ -20,7 +20,7 @@ name="$__object_id" -if su - postgres -c "echo '\q' | psql '$name'" 2>/dev/null; then +if su - postgres -c "echo '\\q' | psql '$name'" 2>/dev/null; then echo "present" else echo "absent" diff --git a/cdist/conf/type/__postgres_role/explorer/state b/cdist/conf/type/__postgres_role/explorer/state index 8c102df9..40f64cef 100755 --- a/cdist/conf/type/__postgres_role/explorer/state +++ b/cdist/conf/type/__postgres_role/explorer/state @@ -20,7 +20,7 @@ name="$__object_id" -if su - postgres -c "psql -c '\du' | grep -q '^ *$name *|'"; then +if su - postgres -c "psql -c '\\du' | grep -q '^ *$name *|'"; then echo "present" else echo "absent" diff --git a/cdist/conf/type/__ssh_authorized_key/explorer/entry b/cdist/conf/type/__ssh_authorized_key/explorer/entry index b528b26e..78efbb48 100755 --- a/cdist/conf/type/__ssh_authorized_key/explorer/entry +++ b/cdist/conf/type/__ssh_authorized_key/explorer/entry @@ -27,5 +27,5 @@ then file="$(cat "$__object/parameter/file")" # get any entries that match the type and key - grep ".*$type_and_key\([ \n]\|$\)" "$file" || true + grep ".*$type_and_key\\([ \\n]\\|$\\)" "$file" || true fi diff --git a/cdist/conf/type/__start_on_boot/explorer/state b/cdist/conf/type/__start_on_boot/explorer/state index d8f9b7ba..cef9013e 100644 --- a/cdist/conf/type/__start_on_boot/explorer/state +++ b/cdist/conf/type/__start_on_boot/explorer/state @@ -38,12 +38,27 @@ if [ "$init" = 'systemd' ]; then else case "$os" in debian|openwrt|devuan) - state="present" - [ -f "/etc/rc$runlevel.d/S"??"$name" ] || state="absent" + state="absent" + for file in "/etc/rc$runlevel.d/S"??"$name" + do + if [ -f "$file" ] + then + state="present" + break + fi + done ;; ubuntu) state="absent" - [ -f "/etc/rc$runlevel.d/S"??"$name" ] && state="present" + for file in "/etc/rc$runlevel.d/S"??"$name" + do + if [ -f "$file" ] + then + state="present" + break + fi + done + [ -f "/etc/init/${name}.conf" ] && state="present" ;; diff --git a/cdist/conf/type/__zypper_service/explorer/service_id b/cdist/conf/type/__zypper_service/explorer/service_id index 91858d84..7161f804 100644 --- a/cdist/conf/type/__zypper_service/explorer/service_id +++ b/cdist/conf/type/__zypper_service/explorer/service_id @@ -27,4 +27,4 @@ else fi # simpler command which works only on SLES11 SP3 or newer: # echo $(zypper ls -u -E | grep -E "\<$uri\>" | cut -d'|' -f 1 ) -zypper ls -u | grep -E '^([^|]+\|){3,3} Yes' | grep -E "\<$uri\>" | cut -d'|' -f 1 +zypper ls -u | grep -E '^([^|]+\|){3,3} Yes' | grep -E "\\<$uri\\>" | cut -d'|' -f 1 From ec186673bf4021d67221d011921ce7165e9473f0 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Sun, 7 Oct 2018 19:46:34 +0200 Subject: [PATCH 0152/1217] Add TODO markers for SC2012. --- cdist/conf/type/__link/explorer/state | 3 +++ cdist/conf/type/__link/explorer/type | 1 + 2 files changed, 4 insertions(+) diff --git a/cdist/conf/type/__link/explorer/state b/cdist/conf/type/__link/explorer/state index 587835a2..edccf08d 100755 --- a/cdist/conf/type/__link/explorer/state +++ b/cdist/conf/type/__link/explorer/state @@ -33,6 +33,7 @@ destination_dir="${destination%/*}" case "$type" in symbolic) cd "$destination_dir" || exit 1 + # TODO SC2012: use readlink or something? source_is=$(ls -l "$destination" | sed 's/.*-> //g') if [ -h "$destination" ]; then # ignore trailing slashes for comparison @@ -52,7 +53,9 @@ case "$type" in echo sourcemissing exit 0 fi + # TODO SC2012: use stat? destination_inode=$(ls -i "$destination" | awk '{print $1}') + # TODO SC2012: use stat? source_inode=$(ls -i "$source" | awk '{print $1}') if [ "$destination_inode" -eq "$source_inode" ]; then echo present diff --git a/cdist/conf/type/__link/explorer/type b/cdist/conf/type/__link/explorer/type index 48a79bf0..aa1aff2c 100755 --- a/cdist/conf/type/__link/explorer/type +++ b/cdist/conf/type/__link/explorer/type @@ -31,6 +31,7 @@ elif [ -f "$destination" ]; then type="$(cat "$__object/parameter/type")" case "$type" in hard) + # TODO SC2012: use stat? link_count=$(ls -l "$destination" | awk '{ print $2 }') if [ "$link_count" -gt 1 ]; then echo hardlink From 0458f66c96b1061b81f759cfa47f8fe20f2d66ae Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Mon, 8 Oct 2018 15:35:29 +0200 Subject: [PATCH 0153/1217] Resolve SC2012. --- cdist/conf/type/__link/explorer/state | 11 +++++---- cdist/conf/type/__link/explorer/type | 34 ++++++++++++++------------- 2 files changed, 25 insertions(+), 20 deletions(-) diff --git a/cdist/conf/type/__link/explorer/state b/cdist/conf/type/__link/explorer/state index edccf08d..a601d53b 100755 --- a/cdist/conf/type/__link/explorer/state +++ b/cdist/conf/type/__link/explorer/state @@ -33,8 +33,7 @@ destination_dir="${destination%/*}" case "$type" in symbolic) cd "$destination_dir" || exit 1 - # TODO SC2012: use readlink or something? - source_is=$(ls -l "$destination" | sed 's/.*-> //g') + source_is=$(readlink "$destination") if [ -h "$destination" ]; then # ignore trailing slashes for comparison if [ "${source_is%/}" = "${source%/}" ]; then @@ -53,9 +52,13 @@ case "$type" in echo sourcemissing exit 0 fi - # TODO SC2012: use stat? + # Currently not worth the effor to change it, stat is not defined by POSIX + # and different OSes has different implementations for it. + # shellcheck disable=SC2012 destination_inode=$(ls -i "$destination" | awk '{print $1}') - # TODO SC2012: use stat? + # Currently not worth the effor to change it, stat is not defined by POSIX + # and different OSes has different implementations for it. + # shellcheck disable=SC2012 source_inode=$(ls -i "$source" | awk '{print $1}') if [ "$destination_inode" -eq "$source_inode" ]; then echo present diff --git a/cdist/conf/type/__link/explorer/type b/cdist/conf/type/__link/explorer/type index aa1aff2c..796f1ac6 100755 --- a/cdist/conf/type/__link/explorer/type +++ b/cdist/conf/type/__link/explorer/type @@ -24,24 +24,26 @@ destination="/$__object_id" if [ ! -e "$destination" ]; then - echo none + echo none elif [ -h "$destination" ]; then - echo symlink + echo symlink elif [ -f "$destination" ]; then - type="$(cat "$__object/parameter/type")" - case "$type" in - hard) - # TODO SC2012: use stat? - link_count=$(ls -l "$destination" | awk '{ print $2 }') - if [ "$link_count" -gt 1 ]; then - echo hardlink - exit 0 - fi - ;; - esac - echo file + type="$(cat "$__object/parameter/type")" + case "$type" in + hard) + # Currently not worth the effor to change it, stat is not defined by POSIX + # and different OSes has different implementations for it. + # shellcheck disable=SC2012 + ink_count=$(ls -l "$destination" | awk '{ print $2 }') + if [ "$link_count" -gt 1 ]; then + echo hardlink + exit 0 + fi + ;; + esac + echo file elif [ -d "$destination" ]; then - echo directory + echo directory else - echo unknown + echo unknown fi From 69790ec138a9ef63c179b5d2ca3777c758ed7347 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Mon, 8 Oct 2018 15:43:42 +0200 Subject: [PATCH 0154/1217] Fix typing error. --- cdist/conf/type/__link/explorer/type | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cdist/conf/type/__link/explorer/type b/cdist/conf/type/__link/explorer/type index 796f1ac6..b322bf42 100755 --- a/cdist/conf/type/__link/explorer/type +++ b/cdist/conf/type/__link/explorer/type @@ -34,7 +34,7 @@ elif [ -f "$destination" ]; then # Currently not worth the effor to change it, stat is not defined by POSIX # and different OSes has different implementations for it. # shellcheck disable=SC2012 - ink_count=$(ls -l "$destination" | awk '{ print $2 }') + link_count=$(ls -l "$destination" | awk '{ print $2 }') if [ "$link_count" -gt 1 ]; then echo hardlink exit 0 From 9afc17f3f8fee41285fa915264aac4ae52046efc Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Wed, 10 Oct 2018 10:37:29 +0200 Subject: [PATCH 0155/1217] Make cdist.test return exit code. --- cdist/test/__main__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cdist/test/__main__.py b/cdist/test/__main__.py index 08e839d1..c8c7df3b 100644 --- a/cdist/test/__main__.py +++ b/cdist/test/__main__.py @@ -45,4 +45,5 @@ for test_module in test_modules: suites.append(suite) all_suites = unittest.TestSuite(suites) -unittest.TextTestRunner(verbosity=2).run(all_suites) +rv = unittest.TextTestRunner(verbosity=2).run(all_suites).wasSuccessful() +sys.exit(not rv) From 0b58ab8c83d86d72eb33d220e9a2e76ac95a04d6 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Wed, 10 Oct 2018 12:34:31 +0200 Subject: [PATCH 0156/1217] Bypass Configuration singleton from other tests if any. --- cdist/test/exec/local.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cdist/test/exec/local.py b/cdist/test/exec/local.py index 0e0cc755..0865b7dc 100644 --- a/cdist/test/exec/local.py +++ b/cdist/test/exec/local.py @@ -170,6 +170,9 @@ class LocalTestCase(test.CdistTestCase): os.environ['CDIST_PATH'] = conf_dir + # bypass singleton from other tests if any + cc.Configuration.instance = None + configuration = cc.Configuration(argparse.Namespace(), env=os.environ) From c58e12a4b9b321346159d54f0aea63a7430add43 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Sun, 7 Oct 2018 20:27:57 +0200 Subject: [PATCH 0157/1217] shellcheck on /files/ scripts. --- .../__consul_agent/files/consul.sysv-debian | 2 ++ .../__consul_agent/files/consul.sysv-redhat | 18 +++++----- .../files/consul-template.sysv | 18 +++++----- .../type/__daemontools/files/init.d-svscan | 34 +++++++++---------- .../type/__install_config/files/remote/copy | 4 +-- .../type/__install_config/files/remote/exec | 4 +-- .../files/lib.sh | 34 ++++++++++--------- .../type/__iptables_apply/files/init-script | 4 +-- .../type/__key_value/files/remote_script.sh | 14 ++++---- .../conf/type/__yum_repo/files/repo.template | 2 +- 10 files changed, 72 insertions(+), 62 deletions(-) diff --git a/cdist/conf/type/__consul_agent/files/consul.sysv-debian b/cdist/conf/type/__consul_agent/files/consul.sysv-debian index d364d6c4..4f43c000 100644 --- a/cdist/conf/type/__consul_agent/files/consul.sysv-debian +++ b/cdist/conf/type/__consul_agent/files/consul.sysv-debian @@ -31,9 +31,11 @@ ### END INIT INFO if [ -f "/etc/default/consul" ]; then + # shellcheck disable=SC1091 . /etc/default/consul fi +# shellcheck disable=SC1091 . /lib/lsb/init-functions NAME=consul diff --git a/cdist/conf/type/__consul_agent/files/consul.sysv-redhat b/cdist/conf/type/__consul_agent/files/consul.sysv-redhat index 13dafd2e..e9c869e5 100644 --- a/cdist/conf/type/__consul_agent/files/consul.sysv-redhat +++ b/cdist/conf/type/__consul_agent/files/consul.sysv-redhat @@ -11,6 +11,7 @@ # pidfile: /var/run/consul/pidfile # Source function library. +# shellcheck disable=SC1091 . /etc/init.d/functions NAME=consul CONSUL=/usr/local/bin/consul @@ -18,6 +19,7 @@ CONFIG=/etc/$NAME/conf.d PID_FILE=/var/run/$NAME/pidfile LOG_FILE=/var/log/$NAME +# shellcheck disable=SC1090 [ -e /etc/sysconfig/$NAME ] && . /etc/sysconfig/$NAME export GOMAXPROCS=${GOMAXPROCS:-2} @@ -27,7 +29,7 @@ chmod 2770 /var/run/$NAME start() { - echo -n "Starting $NAME: " + printf "Starting %s" "$NAME: " daemon --user=consul \ --pidfile="$PID_FILE" \ "$CONSUL" agent -pid-file="$PID_FILE" -config-dir "$CONFIG" >> "$LOG_FILE" & @@ -37,7 +39,7 @@ start() { } stop() { - echo -n "Shutting down $NAME: " + printf "Shutting down %s" "$NAME: " killproc -p "$PID_FILE" $NAME retcode=$? rm -f /var/lock/subsys/$NAME @@ -46,14 +48,14 @@ stop() { case "$1" in start) - if $(status -p "$PID_FILE" $NAME >/dev/null); then + if status -p "$PID_FILE" $NAME >/dev/null; then echo "$NAME already running" else start fi ;; stop) - if $(status -p "$PID_FILE" $NAME >/dev/null); then + if status -p "$PID_FILE" $NAME >/dev/null; then stop else echo "$NAME not running" @@ -67,21 +69,21 @@ case "$1" in exit $? ;; restart) - if $(status -p "$PID_FILE" $NAME >/dev/null); then + if status -p "$PID_FILE" $NAME >/dev/null; then stop fi start ;; reload) - if $(status -p "$PID_FILE" $NAME >/dev/null); then - kill -HUP `cat $PID_FILE` + if status -p "$PID_FILE" $NAME >/dev/null; then + kill -HUP "$(cat "$PID_FILE")" else echo "$NAME not running" fi ;; condrestart) if [ -f /var/lock/subsys/$NAME ]; then - if $(status -p "$PID_FILE" $NAME >/dev/null); then + if status -p "$PID_FILE" $NAME >/dev/null; then stop fi start diff --git a/cdist/conf/type/__consul_template/files/consul-template.sysv b/cdist/conf/type/__consul_template/files/consul-template.sysv index 0a463020..2375f8cf 100644 --- a/cdist/conf/type/__consul_template/files/consul-template.sysv +++ b/cdist/conf/type/__consul_template/files/consul-template.sysv @@ -10,6 +10,7 @@ # pidfile: /var/run/consul-template/pidfile # Source function library. +# shellcheck disable=SC1091 . /etc/init.d/functions NAME=consul-template CONSUL_TEMPLATE=/usr/local/bin/consul-template @@ -17,6 +18,7 @@ CONFIG=/etc/$NAME/conf.d PID_FILE=/var/run/$NAME/pidfile LOG_FILE=/var/log/$NAME +# shellcheck disable=SC1090 [ -e /etc/sysconfig/$NAME ] && . /etc/sysconfig/$NAME export CONSUL_TEMPLATE_LOG=${CONSUL_TEMPLATE_LOG:-info} export GOMAXPROCS=${GOMAXPROCS:-2} @@ -24,7 +26,7 @@ export GOMAXPROCS=${GOMAXPROCS:-2} mkdir -p /var/run/$NAME start() { - echo -n "Starting $NAME: " + printf "Starting %s" "$NAME: " daemon --pidfile="$PID_FILE" \ "$CONSUL_TEMPLATE" -config "$CONFIG" >> "$LOG_FILE" 2>&1 & echo $! > "$PID_FILE" @@ -34,7 +36,7 @@ start() { } stop() { - echo -n "Shutting down $NAME: " + printf "Shutting down %s" "$NAME: " killproc -p $PID_FILE $CONSUL_TEMPLATE retcode=$? rm -f /var/lock/subsys/$NAME @@ -43,14 +45,14 @@ stop() { case "$1" in start) - if $(status -p "$PID_FILE" $NAME >/dev/null); then + if status -p "$PID_FILE" $NAME >/dev/null; then echo "$NAME already running" else start fi ;; stop) - if $(status -p "$PID_FILE" $NAME >/dev/null); then + if status -p "$PID_FILE" $NAME >/dev/null; then stop else echo "$NAME not running" @@ -61,21 +63,21 @@ case "$1" in exit $? ;; restart) - if $(status -p "$PID_FILE" $NAME >/dev/null); then + if status -p "$PID_FILE" $NAME >/dev/null; then stop fi start ;; reload) - if $(status -p "$PID_FILE" $NAME >/dev/null); then - kill -HUP `cat $PID_FILE` + if status -p "$PID_FILE" $NAME >/dev/null; then + kill -HUP "$(cat "$PID_FILE")" else echo "$NAME not running" fi ;; condrestart) if [ -f /var/lock/subsys/$NAME ]; then - if $(status -p "$PID_FILE" $NAME >/dev/null); then + if status -p "$PID_FILE" $NAME >/dev/null; then stop fi start diff --git a/cdist/conf/type/__daemontools/files/init.d-svscan b/cdist/conf/type/__daemontools/files/init.d-svscan index 127dfdb3..6b4dba1d 100644 --- a/cdist/conf/type/__daemontools/files/init.d-svscan +++ b/cdist/conf/type/__daemontools/files/init.d-svscan @@ -23,9 +23,9 @@ fi case "$1" in start) - echo -n "Starting daemontools: " - if [ ! `pidof svscan` ]; then - echo -n "svscan " + printf "Starting daemontools: " + if [ ! "$(pidof svscan)" ]; then + printf "svscan " env - PATH="$PATH" svscan /service 2>&1 | setuidgid daemon multilog t /var/log/svscan & echo "." else @@ -33,23 +33,23 @@ case "$1" in fi ;; stop) - echo -n "Stopping daemontools: " - if [ `pidof svscan` ]; then - echo -n "svscan" - while [ `pidof svscan` ]; do - kill `pidof svscan` - echo -n "." + printf "Stopping daemontools: " + if [ "$(pidof svscan)" ]; then + printf "svscan" + while [ "$(pidof svscan)" ]; do + kill "$(pidof svscan)" + printf "." done fi - echo -n " services" - for i in `ls -d /service/*`; do - svc -dx $i - echo -n "." + printf " services" + for i in /service/*; do + svc -dx "$i" + printf "." done - echo -n " logging " - for i in `ls -d /service/*/log`; do - svc -dx $i - echo -n "." + printf " logging " + for i in /service/*/log; do + svc -dx "$i" + printf "." done echo "" ;; diff --git a/cdist/conf/type/__install_config/files/remote/copy b/cdist/conf/type/__install_config/files/remote/copy index 15c901f9..78af31b9 100755 --- a/cdist/conf/type/__install_config/files/remote/copy +++ b/cdist/conf/type/__install_config/files/remote/copy @@ -37,10 +37,10 @@ code="$(echo "$@" | sed "s|$target_host:|$target_host:$chroot|g")" log "target_host: $target_host" log "chroot: $chroot" -log "@: $@" +log "@: $*" log "code: $code" # copy files into chroot -$__default_remote_copy $code +"$__default_remote_copy" "$code" log "-----" diff --git a/cdist/conf/type/__install_config/files/remote/exec b/cdist/conf/type/__install_config/files/remote/exec index 5b25e41e..ea7396e0 100755 --- a/cdist/conf/type/__install_config/files/remote/exec +++ b/cdist/conf/type/__install_config/files/remote/exec @@ -40,10 +40,10 @@ code="chroot $chroot sh -e -c '$code'" log "target_host: $target_host" log "chroot: $chroot" -log "@: $@" +log "@: $*" log "code: $code" # Run the code -$__default_remote_exec $target_host $code +"$__default_remote_exec" "$target_host" "$code" log "-----" diff --git a/cdist/conf/type/__install_partition_msdos_apply/files/lib.sh b/cdist/conf/type/__install_partition_msdos_apply/files/lib.sh index 13ead401..2db9a441 100644 --- a/cdist/conf/type/__install_partition_msdos_apply/files/lib.sh +++ b/cdist/conf/type/__install_partition_msdos_apply/files/lib.sh @@ -1,9 +1,11 @@ +#!/bin/sh + die() { - echo "[__install_partition_msdos_apply] $@" >&2 + echo "[__install_partition_msdos_apply] $*" >&2 exit 1 } debug() { - #echo "[__install_partition_msdos_apply] $@" >&2 + #echo "[__install_partition_msdos_apply] $*" >&2 : } @@ -12,7 +14,7 @@ fdisk_command() { cmd="$2" debug fdisk_command "running fdisk command '${cmd}' on device ${device}" - printf "${cmd}\nw\n" | fdisk -c -u "$device" + printf '%s\nw\n' "${cmd}" | fdisk -c -u "$device" ret=$? # give disk some time sleep 1 @@ -23,14 +25,14 @@ create_disklabel() { device=$1 debug create_disklabel "creating new msdos disklabel" - fdisk_command ${device} "o" + fdisk_command "${device}" "o" return $? } toggle_bootable() { device="$1" minor="$2" - fdisk_command ${device} "a\n${minor}\n" + fdisk_command "${device}" "a\\n${minor}\\n" return $? } @@ -41,28 +43,28 @@ create_partition() { type="$4" primary_count="$5" - if [ "$type" = "extended" -o "$type" = "5" ]; then + if [ "$type" = "extended" ] || [ "$type" = "5" ]; then # Extended partition - primary_extended="e\n" - first_minor="${minor}\n" + primary_extended='e\n' + first_minor="${minor}\\n" [ "${minor}" = "4" ] && first_minor="" - type_minor="${minor}\n" + type_minor="${minor}\\n" [ "${minor}" = "1" ] && type_minor="" type="5" elif [ "${minor}" -lt "5" ]; then - primary_extended="p\n" - first_minor="${minor}\n" + primary_extended='p\n' + first_minor="${minor}\\n" [ "${minor}" = "4" ] && first_minor="" - type_minor="${minor}\n" + type_minor="${minor}\\n" [ "${minor}" = "1" ] && type_minor="" else # Logical partitions - first_minor="${minor}\n" - type_minor="${minor}\n" - primary_extended="l\n" + first_minor="${minor}\\n" + type_minor="${minor}\\n" + primary_extended='l\n' [ "$primary_count" -gt "3" ] && primary_extended="" fi [ -n "${size}" ] && size="+${size}M" - fdisk_command ${device} "n\n${primary_extended}${first_minor}\n${size}\nt\n${type_minor}${type}\n" + fdisk_command "${device}" "n\\n${primary_extended}${first_minor}\\n${size}\\nt\\n${type_minor}${type}\\n" return $? } diff --git a/cdist/conf/type/__iptables_apply/files/init-script b/cdist/conf/type/__iptables_apply/files/init-script index 2247dcf5..7c08ce08 100644 --- a/cdist/conf/type/__iptables_apply/files/init-script +++ b/cdist/conf/type/__iptables_apply/files/init-script @@ -24,14 +24,14 @@ case $1 in iptables-save > "$status" # Apply our ruleset - cd "$basedir" + cd "$basedir" || exit count="$(ls -1 | wc -l)" # Only do something if there are rules if [ "$count" -ge 1 ]; then for rule in *; do echo "Applying iptables rule $rule ..." - iptables $(cat "$rule") + iptables "$(cat "$rule")" done fi ;; diff --git a/cdist/conf/type/__key_value/files/remote_script.sh b/cdist/conf/type/__key_value/files/remote_script.sh index 52b3f2de..f7a1add5 100644 --- a/cdist/conf/type/__key_value/files/remote_script.sh +++ b/cdist/conf/type/__key_value/files/remote_script.sh @@ -1,19 +1,21 @@ #!/bin/sh -export key="$(cat "$__object/parameter/key" 2>/dev/null \ +key="$(cat "$__object/parameter/key" 2>/dev/null \ || echo "$__object_id")" -export state="$(cat "$__object/parameter/state")" +state="$(cat "$__object/parameter/state")" file="$(cat "$__object/parameter/file")" -export delimiter="$(cat "$__object/parameter/delimiter")" -export value="$(cat "$__object/parameter/value" 2>/dev/null \ +delimiter="$(cat "$__object/parameter/delimiter")" +value="$(cat "$__object/parameter/value" 2>/dev/null \ || echo "__CDIST_NOTSET__")" +export key state delimiter value if [ -f "$__object/parameter/exact_delimiter" ]; then - export exact_delimiter=1 + exact_delimiter=1 else - export exact_delimiter=0 + exact_delimiter=0 fi +export exact_delimiter tmpfile=$(mktemp "${file}.cdist.XXXXXXXXXX") # preserve ownership and permissions by copying existing file over tmpfile diff --git a/cdist/conf/type/__yum_repo/files/repo.template b/cdist/conf/type/__yum_repo/files/repo.template index 3e14c8b6..18ea9d2b 100755 --- a/cdist/conf/type/__yum_repo/files/repo.template +++ b/cdist/conf/type/__yum_repo/files/repo.template @@ -43,7 +43,7 @@ for key in baseurl gpgkey; do if [ -f "$__object/parameter/$key" ]; then printf '%s=' "$key" prefix='' - while read line; do + while read -r line; do printf '%s%s\n' "$prefix" "$line" prefix=' ' done < "$__object/parameter/$key" From 0f31a550cc2a6a4e5468c40b854d3f5bd08e83e2 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Sun, 7 Oct 2018 22:26:18 +0200 Subject: [PATCH 0158/1217] Fix SC2012. --- cdist/conf/type/__iptables_apply/files/init-script | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cdist/conf/type/__iptables_apply/files/init-script b/cdist/conf/type/__iptables_apply/files/init-script index 7c08ce08..aee40cbb 100644 --- a/cdist/conf/type/__iptables_apply/files/init-script +++ b/cdist/conf/type/__iptables_apply/files/init-script @@ -25,7 +25,7 @@ case $1 in # Apply our ruleset cd "$basedir" || exit - count="$(ls -1 | wc -l)" + count="$(find . ! -name . -prune | wc -l)" # Only do something if there are rules if [ "$count" -ge 1 ]; then From dcb4395909124e5680686cb314df6bda6b30fdcf Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Mon, 8 Oct 2018 17:13:13 +0200 Subject: [PATCH 0159/1217] Resolve custom remote copy/exec shellcheck (non-)issues. --- cdist/conf/type/__install_config/files/remote/copy | 4 +++- cdist/conf/type/__install_config/files/remote/exec | 5 ++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/cdist/conf/type/__install_config/files/remote/copy b/cdist/conf/type/__install_config/files/remote/copy index 78af31b9..0f68b1ea 100755 --- a/cdist/conf/type/__install_config/files/remote/copy +++ b/cdist/conf/type/__install_config/files/remote/copy @@ -41,6 +41,8 @@ log "@: $*" log "code: $code" # copy files into chroot -"$__default_remote_copy" "$code" +# code should be split on spaces +# shellcheck disable=SC2086 +"$__default_remote_copy" $code log "-----" diff --git a/cdist/conf/type/__install_config/files/remote/exec b/cdist/conf/type/__install_config/files/remote/exec index ea7396e0..3a48c58f 100755 --- a/cdist/conf/type/__install_config/files/remote/exec +++ b/cdist/conf/type/__install_config/files/remote/exec @@ -36,6 +36,7 @@ shift # escape ' with '"'"' code="$(echo "$@" | sed -e "s/'/'\"'\"'/g")" +# shellcheck disable=SC2089 code="chroot $chroot sh -e -c '$code'" log "target_host: $target_host" @@ -44,6 +45,8 @@ log "@: $*" log "code: $code" # Run the code -"$__default_remote_exec" "$target_host" "$code" +# code should be split on spaces +# shellcheck disable=SC2086,SC2090 +"$__default_remote_exec" "$target_host" $code log "-----" From 53300b1004adf33405e6637117ae97e279716772 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Tue, 9 Oct 2018 18:25:03 +0200 Subject: [PATCH 0160/1217] Fix after shellcheck. --- cdist/conf/type/__install_config/files/remote/copy | 4 ++-- cdist/conf/type/__install_config/files/remote/exec | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cdist/conf/type/__install_config/files/remote/copy b/cdist/conf/type/__install_config/files/remote/copy index 0f68b1ea..fa7fa9b7 100755 --- a/cdist/conf/type/__install_config/files/remote/copy +++ b/cdist/conf/type/__install_config/files/remote/copy @@ -41,8 +41,8 @@ log "@: $*" log "code: $code" # copy files into chroot -# code should be split on spaces +# __default_remote_copy and code should be split # shellcheck disable=SC2086 -"$__default_remote_copy" $code +$__default_remote_copy $code log "-----" diff --git a/cdist/conf/type/__install_config/files/remote/exec b/cdist/conf/type/__install_config/files/remote/exec index 3a48c58f..c2057ebf 100755 --- a/cdist/conf/type/__install_config/files/remote/exec +++ b/cdist/conf/type/__install_config/files/remote/exec @@ -45,8 +45,8 @@ log "@: $*" log "code: $code" # Run the code -# code should be split on spaces +# __default_remote_exec and code should be split # shellcheck disable=SC2086,SC2090 -"$__default_remote_exec" "$target_host" $code +$__default_remote_exec "$target_host" $code log "-----" From 8669ccb9c17616a20c4fe7f7074e2aaade5aeca0 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Tue, 9 Oct 2018 18:25:35 +0200 Subject: [PATCH 0161/1217] Improve shell code. --- cdist/conf/type/__daemontools/files/init.d-svscan | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/cdist/conf/type/__daemontools/files/init.d-svscan b/cdist/conf/type/__daemontools/files/init.d-svscan index 6b4dba1d..996eb4e8 100644 --- a/cdist/conf/type/__daemontools/files/init.d-svscan +++ b/cdist/conf/type/__daemontools/files/init.d-svscan @@ -24,7 +24,7 @@ fi case "$1" in start) printf "Starting daemontools: " - if [ ! "$(pidof svscan)" ]; then + if ! pidof svscan > /dev/null 2>&1; then printf "svscan " env - PATH="$PATH" svscan /service 2>&1 | setuidgid daemon multilog t /var/log/svscan & echo "." @@ -34,11 +34,16 @@ case "$1" in ;; stop) printf "Stopping daemontools: " - if [ "$(pidof svscan)" ]; then + pids="$(pidof svscan)" + if [ -n "${pids}" ] + then printf "svscan" - while [ "$(pidof svscan)" ]; do - kill "$(pidof svscan)" - printf "." + while [ -n "${pids}" ] + do + # shellcheck disable=SC2086 + kill ${pids} + printf "." + pids="$(pidof svscan)" done fi printf " services" From 610deba4543ed1f52a4831fcd61f1a375a4135bf Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Wed, 10 Oct 2018 12:52:50 +0200 Subject: [PATCH 0162/1217] Improve quoting. --- .../files/consul-template.sysv | 45 ++++++++++--------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/cdist/conf/type/__consul_template/files/consul-template.sysv b/cdist/conf/type/__consul_template/files/consul-template.sysv index 2375f8cf..b263915a 100644 --- a/cdist/conf/type/__consul_template/files/consul-template.sysv +++ b/cdist/conf/type/__consul_template/files/consul-template.sysv @@ -10,74 +10,75 @@ # pidfile: /var/run/consul-template/pidfile # Source function library. + # shellcheck disable=SC1091 . /etc/init.d/functions NAME=consul-template CONSUL_TEMPLATE=/usr/local/bin/consul-template -CONFIG=/etc/$NAME/conf.d -PID_FILE=/var/run/$NAME/pidfile -LOG_FILE=/var/log/$NAME +CONFIG="/etc/$NAME/conf.d" +PID_FILE="/var/run/$NAME/pidfile" +LOG_FILE="/var/log/$NAME" # shellcheck disable=SC1090 -[ -e /etc/sysconfig/$NAME ] && . /etc/sysconfig/$NAME -export CONSUL_TEMPLATE_LOG=${CONSUL_TEMPLATE_LOG:-info} -export GOMAXPROCS=${GOMAXPROCS:-2} +[ -e "/etc/sysconfig/$NAME" ] && . "/etc/sysconfig/$NAME" +export CONSUL_TEMPLATE_LOG="${CONSUL_TEMPLATE_LOG:-info}" +export GOMAXPROCS="${GOMAXPROCS:-2}" -mkdir -p /var/run/$NAME +mkdir -p "/var/run/$NAME" start() { - printf "Starting %s" "$NAME: " + printf "Starting %s: " "$NAME" daemon --pidfile="$PID_FILE" \ "$CONSUL_TEMPLATE" -config "$CONFIG" >> "$LOG_FILE" 2>&1 & - echo $! > "$PID_FILE" + echo "$!" > "$PID_FILE" retcode=$? - touch /var/lock/subsys/$NAME - return $retcode + touch "/var/lock/subsys/$NAME" + return "$retcode" } stop() { - printf "Shutting down %s" "$NAME: " - killproc -p $PID_FILE $CONSUL_TEMPLATE + printf "Shutting down %s: " "$NAME" + killproc -p "$PID_FILE" "$CONSUL_TEMPLATE" retcode=$? - rm -f /var/lock/subsys/$NAME - return $retcode + rm -f "/var/lock/subsys/$NAME" + return "$retcode" } case "$1" in start) - if status -p "$PID_FILE" $NAME >/dev/null; then + if status -p "$PID_FILE" "$NAME" >/dev/null; then echo "$NAME already running" else start fi ;; stop) - if status -p "$PID_FILE" $NAME >/dev/null; then + if status -p "$PID_FILE" "$NAME" >/dev/null; then stop else echo "$NAME not running" fi ;; status) - status -p "$PID_FILE" $NAME + status -p "$PID_FILE" "$NAME" exit $? ;; restart) - if status -p "$PID_FILE" $NAME >/dev/null; then + if status -p "$PID_FILE" "$NAME" >/dev/null; then stop fi start ;; reload) - if status -p "$PID_FILE" $NAME >/dev/null; then + if status -p "$PID_FILE" "$NAME" >/dev/null; then kill -HUP "$(cat "$PID_FILE")" else echo "$NAME not running" fi ;; condrestart) - if [ -f /var/lock/subsys/$NAME ]; then - if status -p "$PID_FILE" $NAME >/dev/null; then + if [ -f "/var/lock/subsys/$NAME" ]; then + if status -p "$PID_FILE" "$NAME" >/dev/null; then stop fi start From 7a9dea975439fc4894107f9c124d5874cc416c84 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Wed, 10 Oct 2018 12:56:48 +0200 Subject: [PATCH 0163/1217] Improve quoting. --- .../__consul_agent/files/consul.sysv-redhat | 45 ++++++++++--------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/cdist/conf/type/__consul_agent/files/consul.sysv-redhat b/cdist/conf/type/__consul_agent/files/consul.sysv-redhat index e9c869e5..58fc9bd9 100644 --- a/cdist/conf/type/__consul_agent/files/consul.sysv-redhat +++ b/cdist/conf/type/__consul_agent/files/consul.sysv-redhat @@ -11,51 +11,52 @@ # pidfile: /var/run/consul/pidfile # Source function library. + # shellcheck disable=SC1091 . /etc/init.d/functions NAME=consul CONSUL=/usr/local/bin/consul -CONFIG=/etc/$NAME/conf.d -PID_FILE=/var/run/$NAME/pidfile -LOG_FILE=/var/log/$NAME +CONFIG="/etc/$NAME/conf.d" +PID_FILE="/var/run/$NAME/pidfile" +LOG_FILE="/var/log/$NAME" # shellcheck disable=SC1090 -[ -e /etc/sysconfig/$NAME ] && . /etc/sysconfig/$NAME -export GOMAXPROCS=${GOMAXPROCS:-2} +[ -e "/etc/sysconfig/$NAME" ] && . "/etc/sysconfig/$NAME" +export GOMAXPROCS="${GOMAXPROCS:-2}" -mkdir -p /var/run/$NAME -chown consul:consul /var/run/$NAME -chmod 2770 /var/run/$NAME +mkdir -p "/var/run/$NAME" +chown consul:consul "/var/run/$NAME" +chmod 2770 "/var/run/$NAME" start() { - printf "Starting %s" "$NAME: " + printf "Starting %s: " "$NAME" daemon --user=consul \ --pidfile="$PID_FILE" \ "$CONSUL" agent -pid-file="$PID_FILE" -config-dir "$CONFIG" >> "$LOG_FILE" & retcode=$? - touch /var/lock/subsys/$NAME - return $retcode + touch "/var/lock/subsys/$NAME" + return "$retcode" } stop() { - printf "Shutting down %s" "$NAME: " - killproc -p "$PID_FILE" $NAME + printf "Shutting down %s: " "$NAME" + killproc -p "$PID_FILE" "$NAME" retcode=$? - rm -f /var/lock/subsys/$NAME - return $retcode + rm -f "/var/lock/subsys/$NAME" + return "$retcode" } case "$1" in start) - if status -p "$PID_FILE" $NAME >/dev/null; then + if status -p "$PID_FILE" "$NAME" >/dev/null; then echo "$NAME already running" else start fi ;; stop) - if status -p "$PID_FILE" $NAME >/dev/null; then + if status -p "$PID_FILE" "$NAME" >/dev/null; then stop else echo "$NAME not running" @@ -65,25 +66,25 @@ case "$1" in "$CONSUL" info ;; status) - status -p "$PID_FILE" $NAME + status -p "$PID_FILE" "$NAME" exit $? ;; restart) - if status -p "$PID_FILE" $NAME >/dev/null; then + if status -p "$PID_FILE" "$NAME" >/dev/null; then stop fi start ;; reload) - if status -p "$PID_FILE" $NAME >/dev/null; then + if status -p "$PID_FILE" "$NAME" >/dev/null; then kill -HUP "$(cat "$PID_FILE")" else echo "$NAME not running" fi ;; condrestart) - if [ -f /var/lock/subsys/$NAME ]; then - if status -p "$PID_FILE" $NAME >/dev/null; then + if [ -f "/var/lock/subsys/$NAME" ]; then + if status -p "$PID_FILE" "$NAME" >/dev/null; then stop fi start From faed292a4e667005e4c4f906d6268743d2917568 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Wed, 10 Oct 2018 15:01:03 +0200 Subject: [PATCH 0164/1217] Rule should be split. --- cdist/conf/type/__iptables_apply/files/init-script | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cdist/conf/type/__iptables_apply/files/init-script b/cdist/conf/type/__iptables_apply/files/init-script index aee40cbb..d9c79ef7 100644 --- a/cdist/conf/type/__iptables_apply/files/init-script +++ b/cdist/conf/type/__iptables_apply/files/init-script @@ -31,7 +31,9 @@ case $1 in if [ "$count" -ge 1 ]; then for rule in *; do echo "Applying iptables rule $rule ..." - iptables "$(cat "$rule")" + # Rule should be split. + # shellcheck disable=SC2046 + iptables $(cat "$rule") done fi ;; From dd5a45a809f604a299b44bec8c04ce29bc45000c Mon Sep 17 00:00:00 2001 From: Dominique Roux Date: Fri, 12 Oct 2018 11:42:42 +0200 Subject: [PATCH 0165/1217] [CONSUL] add newest versions --- cdist/conf/type/__consul/files/versions/1.2.3/cksum | 1 + cdist/conf/type/__consul/files/versions/1.2.3/source | 1 + cdist/conf/type/__consul/files/versions/1.3.0/cksum | 1 + cdist/conf/type/__consul/files/versions/1.3.0/source | 1 + 4 files changed, 4 insertions(+) create mode 100644 cdist/conf/type/__consul/files/versions/1.2.3/cksum create mode 100644 cdist/conf/type/__consul/files/versions/1.2.3/source create mode 100644 cdist/conf/type/__consul/files/versions/1.3.0/cksum create mode 100644 cdist/conf/type/__consul/files/versions/1.3.0/source diff --git a/cdist/conf/type/__consul/files/versions/1.2.3/cksum b/cdist/conf/type/__consul/files/versions/1.2.3/cksum new file mode 100644 index 00000000..6352409e --- /dev/null +++ b/cdist/conf/type/__consul/files/versions/1.2.3/cksum @@ -0,0 +1 @@ +191982 110369685 diff --git a/cdist/conf/type/__consul/files/versions/1.2.3/source b/cdist/conf/type/__consul/files/versions/1.2.3/source new file mode 100644 index 00000000..5e67bc37 --- /dev/null +++ b/cdist/conf/type/__consul/files/versions/1.2.3/source @@ -0,0 +1 @@ +https://releases.hashicorp.com/consul/1.2.3/consul_1.2.3_linux_amd64.zip diff --git a/cdist/conf/type/__consul/files/versions/1.3.0/cksum b/cdist/conf/type/__consul/files/versions/1.3.0/cksum new file mode 100644 index 00000000..7a885378 --- /dev/null +++ b/cdist/conf/type/__consul/files/versions/1.3.0/cksum @@ -0,0 +1 @@ +1714523667 98363467 consul diff --git a/cdist/conf/type/__consul/files/versions/1.3.0/source b/cdist/conf/type/__consul/files/versions/1.3.0/source new file mode 100644 index 00000000..18a1ba8e --- /dev/null +++ b/cdist/conf/type/__consul/files/versions/1.3.0/source @@ -0,0 +1 @@ +https://releases.hashicorp.com/consul/1.3.0/consul_1.3.0_linux_amd64.zip From 09870ece59f5c341208be7b447fa7873463054f4 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Fri, 12 Oct 2018 13:57:02 +0200 Subject: [PATCH 0166/1217] ++changelog --- docs/changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog b/docs/changelog index 1a3a7e2a..0cbbf6bb 100644 --- a/docs/changelog +++ b/docs/changelog @@ -6,6 +6,7 @@ next: * Core: Add timestamp (optional) to log messages (Darko Poljak) * Explorers and types: Fix shellcheck found problems and encountered bugs (Jonas Weber, Thomas Eckert, Darko Poljak) * Build: Add shellcheck makefile target and check when doing release (Darko Poljak) + * Type __consul: Add newest versions (Dominique Roux) 4.10.3: 2018-09-23 * New global explorer: os_release (Ľubomír Kučera) From 409d736339f9c2041b8733cad982beb129bf1a3c Mon Sep 17 00:00:00 2001 From: Thomas Eckert Date: Thu, 11 Oct 2018 15:58:30 +0200 Subject: [PATCH 0167/1217] explicitly check for `absent` to handle state-typos gracefully --- cdist/conf/type/__user/gencode-remote | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cdist/conf/type/__user/gencode-remote b/cdist/conf/type/__user/gencode-remote index b908874b..ef04ed3a 100755 --- a/cdist/conf/type/__user/gencode-remote +++ b/cdist/conf/type/__user/gencode-remote @@ -3,6 +3,7 @@ # 2011 Steven Armstrong (steven-cdist at armstrong.cc) # 2011 Nico Schottelius (nico-cdist at schottelius.org) # 2013 Daniel Heule (hda at sfs.biz) +# 2018 Thomas Eckert (tom at it-eckert.de) # # This file is part of cdist. # @@ -130,7 +131,7 @@ if [ "$state" = "present" ]; then echo useradd "$@" "$name" fi fi -else +elif [ "$state" = "absent" ]; then if grep -q "^${name}:" "$__object/explorer/passwd"; then #user exists, but state != present, so delete it if [ -f "$__object/parameter/remove-home" ]; then @@ -139,4 +140,6 @@ else echo userdel "${name}" fi fi +else + echo "Invalid state $state" >&2 fi From a1bf3813705117f3ae7a513a4d893cc5094bc59c Mon Sep 17 00:00:00 2001 From: Thomas Eckert Date: Thu, 11 Oct 2018 15:59:47 +0200 Subject: [PATCH 0168/1217] add messaging --- cdist/conf/type/__user/gencode-remote | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cdist/conf/type/__user/gencode-remote b/cdist/conf/type/__user/gencode-remote index ef04ed3a..a5b60ac6 100755 --- a/cdist/conf/type/__user/gencode-remote +++ b/cdist/conf/type/__user/gencode-remote @@ -136,8 +136,10 @@ elif [ "$state" = "absent" ]; then #user exists, but state != present, so delete it if [ -f "$__object/parameter/remove-home" ]; then echo userdel -r "${name}" + echo "userdel -r" >> "$__messages_out" else echo userdel "${name}" + echo "userdel" >> "$__messages_out" fi fi else From c995d08ce2305ec75bed9362d4a0ed845c7fcc92 Mon Sep 17 00:00:00 2001 From: Thomas Eckert Date: Thu, 11 Oct 2018 16:01:50 +0200 Subject: [PATCH 0169/1217] redirect stdout+stderr of `userdel` If no mail-spoolfile exists for the user the error reporting was visible in the cdist-run. --- cdist/conf/type/__user/gencode-remote | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cdist/conf/type/__user/gencode-remote b/cdist/conf/type/__user/gencode-remote index a5b60ac6..8f2a422a 100755 --- a/cdist/conf/type/__user/gencode-remote +++ b/cdist/conf/type/__user/gencode-remote @@ -135,10 +135,10 @@ elif [ "$state" = "absent" ]; then if grep -q "^${name}:" "$__object/explorer/passwd"; then #user exists, but state != present, so delete it if [ -f "$__object/parameter/remove-home" ]; then - echo userdel -r "${name}" + printf "userdel -r %s >/dev/null 2>&1\n" "${name}" echo "userdel -r" >> "$__messages_out" else - echo userdel "${name}" + printf "userdel %s >/dev/null 2>&1\n" "${name}" echo "userdel" >> "$__messages_out" fi fi From 5761939fa93e921706e854675dd5e7acbe7619c1 Mon Sep 17 00:00:00 2001 From: Thomas Eckert Date: Thu, 11 Oct 2018 16:05:57 +0200 Subject: [PATCH 0170/1217] add new messages to man.rst --- cdist/conf/type/__user/man.rst | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cdist/conf/type/__user/man.rst b/cdist/conf/type/__user/man.rst index 5001bfa4..ef6b77af 100644 --- a/cdist/conf/type/__user/man.rst +++ b/cdist/conf/type/__user/man.rst @@ -60,6 +60,11 @@ mod add New user added +userdel -r + If user was deleted with homedir + +userdel + If user was deleted (keeping homedir) EXAMPLES -------- From c950dd1e9022c2a8965d648d1ab7d3fe25aa3ad4 Mon Sep 17 00:00:00 2001 From: Thomas Eckert Date: Thu, 11 Oct 2018 19:00:44 +0200 Subject: [PATCH 0171/1217] quote "remote user", ensuring `user` is handled as one parameter --- cdist/conf/type/__user/gencode-remote | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cdist/conf/type/__user/gencode-remote b/cdist/conf/type/__user/gencode-remote index 8f2a422a..90e3707d 100755 --- a/cdist/conf/type/__user/gencode-remote +++ b/cdist/conf/type/__user/gencode-remote @@ -135,10 +135,10 @@ elif [ "$state" = "absent" ]; then if grep -q "^${name}:" "$__object/explorer/passwd"; then #user exists, but state != present, so delete it if [ -f "$__object/parameter/remove-home" ]; then - printf "userdel -r %s >/dev/null 2>&1\n" "${name}" + printf "userdel -r '%s' >/dev/null 2>&1\n" "${name}" echo "userdel -r" >> "$__messages_out" else - printf "userdel %s >/dev/null 2>&1\n" "${name}" + printf "userdel '%s' >/dev/null 2>&1\n" "${name}" echo "userdel" >> "$__messages_out" fi fi From c5098dfcc50ab88ce524346ed369cfede4f387da Mon Sep 17 00:00:00 2001 From: Thomas Eckert Date: Fri, 12 Oct 2018 14:02:11 +0200 Subject: [PATCH 0172/1217] fix [SC1117] (explicitly excaping `\n`) --- cdist/conf/type/__user/gencode-remote | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cdist/conf/type/__user/gencode-remote b/cdist/conf/type/__user/gencode-remote index 90e3707d..ee18c18f 100755 --- a/cdist/conf/type/__user/gencode-remote +++ b/cdist/conf/type/__user/gencode-remote @@ -135,10 +135,10 @@ elif [ "$state" = "absent" ]; then if grep -q "^${name}:" "$__object/explorer/passwd"; then #user exists, but state != present, so delete it if [ -f "$__object/parameter/remove-home" ]; then - printf "userdel -r '%s' >/dev/null 2>&1\n" "${name}" + printf "userdel -r '%s' >/dev/null 2>&1\\n" "${name}" echo "userdel -r" >> "$__messages_out" else - printf "userdel '%s' >/dev/null 2>&1\n" "${name}" + printf "userdel '%s' >/dev/null 2>&1\\n" "${name}" echo "userdel" >> "$__messages_out" fi fi From 3b7f39cab7aeb3e682f38d2462885b4289beee6c Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Fri, 12 Oct 2018 15:14:30 +0200 Subject: [PATCH 0173/1217] ++changelog --- docs/changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog b/docs/changelog index 0cbbf6bb..b4425df0 100644 --- a/docs/changelog +++ b/docs/changelog @@ -7,6 +7,7 @@ next: * Explorers and types: Fix shellcheck found problems and encountered bugs (Jonas Weber, Thomas Eckert, Darko Poljak) * Build: Add shellcheck makefile target and check when doing release (Darko Poljak) * Type __consul: Add newest versions (Dominique Roux) + * Type __user: Remove annoying output, handle state param gracefully, add messages for removal (Thomas Eckert) 4.10.3: 2018-09-23 * New global explorer: os_release (Ľubomír Kučera) From 151edc63980e9f9f90df24b952e5b894dc30f15d Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Fri, 12 Oct 2018 19:08:36 +0200 Subject: [PATCH 0174/1217] Fix DirectoryDict getitem. --- cdist/util/fsproperty.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/cdist/util/fsproperty.py b/cdist/util/fsproperty.py index e458fd9e..5a27c9d7 100644 --- a/cdist/util/fsproperty.py +++ b/cdist/util/fsproperty.py @@ -58,7 +58,7 @@ class FileList(collections.MutableSequence): with open(self.path) as fd: for line in fd: lines.append(line.rstrip('\n')) - except EnvironmentError as e: + except EnvironmentError: # error ignored pass return lines @@ -127,7 +127,16 @@ class DirectoryDict(collections.MutableMapping): def __getitem__(self, key): try: with open(os.path.join(self.path, key), "r") as fd: - return fd.read().rstrip('\n') + value = fd.read().splitlines() + # if there is no value/empty line then return '' + # if there is only one value then return that value + # if there are multiple lines in file then return list + if not value: + return '' + elif len(value) == 1: + return value[0] + else: + return value except EnvironmentError: raise KeyError(key) From 5480c22020ac8cd45c630672a07dff105c6289c7 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Sat, 13 Oct 2018 16:11:51 +0200 Subject: [PATCH 0175/1217] Adapt object_parameters before checking conflicting parameters. --- cdist/emulator.py | 30 ++++++++- cdist/test/emulator/__init__.py | 63 +++++++++++++++++++ .../type/__arguments_all/parameter/boolean | 1 + .../type/__arguments_all/parameter/optional | 1 + .../parameter/optional_multiple | 2 + .../type/__arguments_all/parameter/required | 1 + .../parameter/required_multiple | 2 + .../parameter/optional_multiple | 1 + .../parameter/required_multiple | 1 + 9 files changed, 99 insertions(+), 3 deletions(-) create mode 100644 cdist/test/emulator/fixtures/conf/type/__arguments_all/parameter/boolean create mode 100644 cdist/test/emulator/fixtures/conf/type/__arguments_all/parameter/optional create mode 100644 cdist/test/emulator/fixtures/conf/type/__arguments_all/parameter/optional_multiple create mode 100644 cdist/test/emulator/fixtures/conf/type/__arguments_all/parameter/required create mode 100644 cdist/test/emulator/fixtures/conf/type/__arguments_all/parameter/required_multiple create mode 100644 cdist/test/emulator/fixtures/conf/type/__arguments_optional_multiple/parameter/optional_multiple create mode 100644 cdist/test/emulator/fixtures/conf/type/__arguments_required_multiple/parameter/required_multiple diff --git a/cdist/emulator.py b/cdist/emulator.py index 4123a353..65d044d7 100644 --- a/cdist/emulator.py +++ b/cdist/emulator.py @@ -182,6 +182,29 @@ class Emulator(object): lockfname = lockfname.replace(os.sep, '_') self.flock_path = os.path.join(self.object_base_path, lockfname) + def _object_params_in_context(self): + ''' Get cdist_object parameters dict adopted by context. + Context consists of cdist_type boolean, optional, required, + optional_multiple and required_multiple parameters. If parameter + is multiple parameter then its value is a list. + This adaptation works on cdist_object.parameters which are read from + directory based dict where it is unknown what kind of data is in + file. If there is only one line in the file it is unknown if this + is a value of required/optional parameter or if it is one value of + multiple values parameter. + ''' + params = {} + if self.cdist_object.exists: + for param in self.cdist_object.parameters: + value = ('' if param in self.cdist_type.boolean_parameters + else self.cdist_object.parameters[param]) + if ((param in self.cdist_type.required_multiple_parameters or + param in self.cdist_type.optional_multiple_parameters) and + not isinstance(value, list)): + value = [value] + params[param] = value + return params + def setup_object(self): # Create object with given parameters self.parameters = {} @@ -193,12 +216,13 @@ class Emulator(object): # Make existing requirements a set so that we can compare it # later with new requirements. self._existing_reqs = set(self.cdist_object.requirements) - if self.cdist_object.parameters != self.parameters: + obj_params = self._object_params_in_context() + if obj_params != self.parameters: errmsg = ("Object %s already exists with conflicting " "parameters:\n%s: %s\n%s: %s" % ( self.cdist_object.name, " ".join(self.cdist_object.source), - self.cdist_object.parameters, + obj_params, self.object_source, self.parameters)) raise cdist.Error(errmsg) @@ -252,7 +276,7 @@ class Emulator(object): self.cdist_object.name, requirement, e.name, self.object_source))) raise - except core.cdist_object.MissingObjectIdError as e: + except core.cdist_object.MissingObjectIdError: self.log.error(("%s requires object %s without object id." " Defined at %s" % (self.cdist_object.name, requirement, diff --git a/cdist/test/emulator/__init__.py b/cdist/test/emulator/__init__.py index f94ce96d..5691093c 100644 --- a/cdist/test/emulator/__init__.py +++ b/cdist/test/emulator/__init__.py @@ -420,6 +420,27 @@ class ArgumentsTestCase(test.CdistTestCase): self.assertEqual(cdist_object.parameters['required1'], value) self.assertEqual(cdist_object.parameters['required2'], value) + def test_required_multiple_arguments(self): + """check whether assigning required multiple parameter works""" + + type_name = '__arguments_required_multiple' + object_id = 'some-id' + value1 = 'value1' + value2 = 'value2' + argv = [type_name, object_id, '--required1', value1, + '--required1', value2] + os.environ.update(self.env) + emu = emulator.Emulator(argv) + emu.run() + + cdist_type = core.CdistType(self.local.type_path, type_name) + cdist_object = core.CdistObject(cdist_type, self.local.object_path, + self.local.object_marker_name, + object_id) + self.assertTrue('required1' in cdist_object.parameters) + self.assertTrue(value1 in cdist_object.parameters['required1']) + self.assertTrue(value2 in cdist_object.parameters['required1']) + # def test_required_missing(self): # type_name = '__arguments_required' # object_id = 'some-id' @@ -447,6 +468,25 @@ class ArgumentsTestCase(test.CdistTestCase): self.assertFalse('optional2' in cdist_object.parameters) self.assertEqual(cdist_object.parameters['optional1'], value) + def test_optional_multiple(self): + type_name = '__arguments_optional_multiple' + object_id = 'some-id' + value1 = 'value1' + value2 = 'value2' + argv = [type_name, object_id, '--optional1', value1, '--optional1', + value2] + os.environ.update(self.env) + emu = emulator.Emulator(argv) + emu.run() + + cdist_type = core.CdistType(self.local.type_path, type_name) + cdist_object = core.CdistObject(cdist_type, self.local.object_path, + self.local.object_marker_name, + object_id) + self.assertTrue('optional1' in cdist_object.parameters) + self.assertTrue(value1 in cdist_object.parameters['optional1']) + self.assertTrue(value2 in cdist_object.parameters['optional1']) + def test_argument_defaults(self): type_name = '__argument_defaults' object_id = 'some-id' @@ -464,6 +504,29 @@ class ArgumentsTestCase(test.CdistTestCase): self.assertFalse('optional2' in cdist_object.parameters) self.assertEqual(cdist_object.parameters['optional1'], value) + def test_object_params_in_context(self): + type_name = '__arguments_all' + object_id = 'some-id' + argv = [type_name, object_id, '--opt', 'opt', '--req', 'req', + '--bool', '--optmul', 'val1', '--optmul', 'val2', + '--reqmul', 'val3', '--reqmul', 'val4', + '--optmul1', 'val5', '--reqmul1', 'val6'] + os.environ.update(self.env) + emu = emulator.Emulator(argv) + emu.run() + + obj_params = emu._object_params_in_context() + obj_params_expected = { + 'bool': '', + 'opt': 'opt', + 'optmul1': ['val5', ], + 'optmul': ['val1', 'val2', ], + 'req': 'req', + 'reqmul1': ['val6', ], + 'reqmul': ['val3', 'val4', ], + } + self.assertEqual(obj_params, obj_params_expected) + class StdinTestCase(test.CdistTestCase): diff --git a/cdist/test/emulator/fixtures/conf/type/__arguments_all/parameter/boolean b/cdist/test/emulator/fixtures/conf/type/__arguments_all/parameter/boolean new file mode 100644 index 00000000..46a27912 --- /dev/null +++ b/cdist/test/emulator/fixtures/conf/type/__arguments_all/parameter/boolean @@ -0,0 +1 @@ +bool diff --git a/cdist/test/emulator/fixtures/conf/type/__arguments_all/parameter/optional b/cdist/test/emulator/fixtures/conf/type/__arguments_all/parameter/optional new file mode 100644 index 00000000..d6eba11a --- /dev/null +++ b/cdist/test/emulator/fixtures/conf/type/__arguments_all/parameter/optional @@ -0,0 +1 @@ +opt diff --git a/cdist/test/emulator/fixtures/conf/type/__arguments_all/parameter/optional_multiple b/cdist/test/emulator/fixtures/conf/type/__arguments_all/parameter/optional_multiple new file mode 100644 index 00000000..04893522 --- /dev/null +++ b/cdist/test/emulator/fixtures/conf/type/__arguments_all/parameter/optional_multiple @@ -0,0 +1,2 @@ +optmul +optmul1 diff --git a/cdist/test/emulator/fixtures/conf/type/__arguments_all/parameter/required b/cdist/test/emulator/fixtures/conf/type/__arguments_all/parameter/required new file mode 100644 index 00000000..da45f08d --- /dev/null +++ b/cdist/test/emulator/fixtures/conf/type/__arguments_all/parameter/required @@ -0,0 +1 @@ +req diff --git a/cdist/test/emulator/fixtures/conf/type/__arguments_all/parameter/required_multiple b/cdist/test/emulator/fixtures/conf/type/__arguments_all/parameter/required_multiple new file mode 100644 index 00000000..28c1a19b --- /dev/null +++ b/cdist/test/emulator/fixtures/conf/type/__arguments_all/parameter/required_multiple @@ -0,0 +1,2 @@ +reqmul +reqmul1 diff --git a/cdist/test/emulator/fixtures/conf/type/__arguments_optional_multiple/parameter/optional_multiple b/cdist/test/emulator/fixtures/conf/type/__arguments_optional_multiple/parameter/optional_multiple new file mode 100644 index 00000000..31647628 --- /dev/null +++ b/cdist/test/emulator/fixtures/conf/type/__arguments_optional_multiple/parameter/optional_multiple @@ -0,0 +1 @@ +optional1 diff --git a/cdist/test/emulator/fixtures/conf/type/__arguments_required_multiple/parameter/required_multiple b/cdist/test/emulator/fixtures/conf/type/__arguments_required_multiple/parameter/required_multiple new file mode 100644 index 00000000..180d60c7 --- /dev/null +++ b/cdist/test/emulator/fixtures/conf/type/__arguments_required_multiple/parameter/required_multiple @@ -0,0 +1 @@ +required1 From 3d56aa83ac7a7fb0fac92c2e97a7a7324b6dc877 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Sun, 14 Oct 2018 10:32:30 +0200 Subject: [PATCH 0176/1217] ++changelog --- docs/changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog b/docs/changelog index b4425df0..364e5ef2 100644 --- a/docs/changelog +++ b/docs/changelog @@ -8,6 +8,7 @@ next: * Build: Add shellcheck makefile target and check when doing release (Darko Poljak) * Type __consul: Add newest versions (Dominique Roux) * Type __user: Remove annoying output, handle state param gracefully, add messages for removal (Thomas Eckert) + * Core: Fix checking for conflicting parameters for multiple values parameters (Darko Poljak) 4.10.3: 2018-09-23 * New global explorer: os_release (Ľubomír Kučera) From 8c035189629ebca424092fbf4a216d5b7222ba04 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Wed, 17 Oct 2018 07:09:59 +0200 Subject: [PATCH 0177/1217] Fix spelling. --- cdist/config.py | 6 +++--- cdist/core/explorer.py | 6 +++--- cdist/exec/remote.py | 8 ++++---- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/cdist/config.py b/cdist/config.py index e8fd5384..11c433db 100644 --- a/cdist/config.py +++ b/cdist/config.py @@ -556,19 +556,19 @@ class Config(object): self.log.trace("Multiprocessing cargo_types: %s", cargo_types) nt = len(cargo_types) if nt == 1: - self.log.debug(("Only one type, transfering explorers " + self.log.debug(("Only one type, transferring explorers " "sequentially")) self.explorer.transfer_type_explorers(cargo_types.pop()) else: self.log.trace(("Starting multiprocessing Pool for {} " - "parallel transfering types' explorers".format( + "parallel types explorers transferring".format( nt))) args = [ (ct, ) for ct in cargo_types ] mp_pool_run(self.explorer.transfer_type_explorers, args, jobs=self.jobs) - self.log.trace(("Multiprocessing for parallel transfering " + self.log.trace(("Multiprocessing for parallel transferring " "types' explorers finished")) self.log.trace(("Starting multiprocessing Pool for {} parallel " diff --git a/cdist/core/explorer.py b/cdist/core/explorer.py index a42b0117..0b3d7b2e 100644 --- a/cdist/core/explorer.py +++ b/cdist/core/explorer.py @@ -176,14 +176,14 @@ class Explorer(object): self.log.verbose("Running type explorers for {}".format( cdist_object.cdist_type)) if transfer_type_explorers: - self.log.trace("Transfering type explorers for type: %s", + self.log.trace("Transferring type explorers for type: %s", cdist_object.cdist_type) self.transfer_type_explorers(cdist_object.cdist_type) else: - self.log.trace(("No need for transfering type explorers for " + self.log.trace(("No need for transferring type explorers for " "type: %s"), cdist_object.cdist_type) - self.log.trace("Transfering object parameters for object: %s", + self.log.trace("Transferring object parameters for object: %s", cdist_object.name) self.transfer_object_parameters(cdist_object) for explorer in self.list_type_explorer_names(cdist_object.cdist_type): diff --git a/cdist/exec/remote.py b/cdist/exec/remote.py index ffb3ee00..9e3e279e 100644 --- a/cdist/exec/remote.py +++ b/cdist/exec/remote.py @@ -190,7 +190,7 @@ class Remote(object): self.log.trace( "Archiving mode desttarpath: %s", desttarpath) # transfer archive to the remote side - self.log.trace("Archiving mode: transfering") + self.log.trace("Archiving mode: transferring") self._transfer_file(tarpath, desttarpath) # extract archive at the remote self.log.trace("Archiving mode: extracting") @@ -248,15 +248,15 @@ class Remote(object): # variable declarations # cdist command prepended with variable assignments expects - # posix shell (bourne, bash) at the remote as user default shell. - # If remote user shell isn't poxis shell, but for e.g. csh/tcsh + # POSIX shell (bourne, bash) at the remote as user default shell. + # If remote user shell isn't POSIX shell, but for e.g. csh/tcsh # then these var assignments are not var assignments for this # remote shell, it tries to execute it as a command and fails. # So really do this by default: # /bin/sh -c 'export ; command' # so that constructed remote command isn't dependent on remote # shell. Do this only if env is not None. env breaks this. - # Explicitly use /bin/sh, because var assignments assume poxis + # Explicitly use /bin/sh, because var assignments assume POSIX # shell already. # This leaves the posibility to write script that needs to be run # remotely in e.g. csh and setting up CDIST_REMOTE_SHELL to e.g. From 6895ad0207a58a5d22efd2943b872afbd1225204 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Wed, 24 Oct 2018 18:26:33 +0200 Subject: [PATCH 0178/1217] Fix post-shellcheck bug. --- cdist/conf/type/__hostname/gencode-remote | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cdist/conf/type/__hostname/gencode-remote b/cdist/conf/type/__hostname/gencode-remote index fc50b651..33947f7f 100755 --- a/cdist/conf/type/__hostname/gencode-remote +++ b/cdist/conf/type/__hostname/gencode-remote @@ -59,7 +59,7 @@ echo changed >> "$__messages_out" # Use the good old way to set the hostname even on machines running systemd. case "$os" in archlinux|debian|ubuntu|devuan|centos|coreos) - printf "printf '%s\\n' '$name_should' > /etc/hostname\\n" + printf "printf '%%s\\\\n' '$name_should' > /etc/hostname\\n" echo "hostname -F /etc/hostname" ;; freebsd|openbsd) @@ -67,7 +67,7 @@ case "$os" in ;; suse) echo "hostname '$name_should'" - printf "printf '%s\\n' '$name_should' > /etc/HOSTNAME\\n" + printf "printf '%%s\\\\n' '$name_should' > /etc/HOSTNAME\\n" ;; esac From 1bae2be4068dfdd2eea99e7859622ec7dbdb488f Mon Sep 17 00:00:00 2001 From: Thomas Eckert Date: Wed, 31 Oct 2018 20:22:41 +0100 Subject: [PATCH 0179/1217] Synchronize notes on ssh-connection multipexing with current state. --- docs/src/cdist-best-practice.rst | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/docs/src/cdist-best-practice.rst b/docs/src/cdist-best-practice.rst index 45aba11b..a99ba88e 100644 --- a/docs/src/cdist-best-practice.rst +++ b/docs/src/cdist-best-practice.rst @@ -13,15 +13,18 @@ See sshd_config(5) and ssh-keygen(1). Speeding up ssh connections --------------------------- When connecting to a new host, the initial delay with ssh connections -is pretty big. You can work around this by -"sharing of multiple sessions over a single network connection" -(quote from ssh_config(5)). The following code is suitable for -inclusion into your ~/.ssh/config:: +is pretty big. As cdist makes many connections to each host successive +connections can be sped up by "sharing of multiple sessions over a single +network connection" (quote from ssh_config(5)). This is also called "connection +multiplexing". - Host * - ControlPath ~/.ssh/master-%l-%r@%h:%p - ControlMaster auto - ControlPersist 10 +Cdist implements this since v4.0.0 by executing ssh with the appropriate +options (`-o ControlMaster=auto -o ControlPath=/tmp//s -o +ControlPersist=2h`). + +Note that the sshd_config on the server can configure the maximum number of +parallel multiplexed connections this with `MaxSessions N` (N defaults to 10 +for OpenSSH v7.4). Speeding up shell execution From a3a0023b2a44db53fd4fa5c8243068e5cc3e154e Mon Sep 17 00:00:00 2001 From: Thomas Eckert Date: Wed, 31 Oct 2018 20:24:07 +0100 Subject: [PATCH 0180/1217] man-pages are no longer in asciidoc but in ReSTructured text instead --- docs/src/cdist-hacker.rst | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/docs/src/cdist-hacker.rst b/docs/src/cdist-hacker.rst index ea5dceb3..d65c41a6 100644 --- a/docs/src/cdist-hacker.rst +++ b/docs/src/cdist-hacker.rst @@ -59,10 +59,9 @@ How to submit a new type For detailed information about types, see `cdist type `_. Submitting a type works as described above, with the additional requirement -that a corresponding manpage named man.text in asciidoc format with +that a corresponding manpage named man.rst in ReSTructured text format with the manpage-name "cdist-type__NAME" is included in the type directory -AND asciidoc is able to compile it (i.e. do NOT have to many "=" in the second -line). +AND the manpage builds (`make man`). Warning: Submitting "exec" or "run" types that simply echo their parameter in **gencode** will not be accepted, because they are of no use. Every type can output From e860f1c79273731382f0c788ef1b462c6cbb8adc Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Fri, 2 Nov 2018 14:35:06 +0100 Subject: [PATCH 0181/1217] Determine source_is only if destination is symlink. --- cdist/conf/type/__link/explorer/state | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cdist/conf/type/__link/explorer/state b/cdist/conf/type/__link/explorer/state index a601d53b..7150df25 100755 --- a/cdist/conf/type/__link/explorer/state +++ b/cdist/conf/type/__link/explorer/state @@ -33,8 +33,8 @@ destination_dir="${destination%/*}" case "$type" in symbolic) cd "$destination_dir" || exit 1 - source_is=$(readlink "$destination") if [ -h "$destination" ]; then + source_is=$(readlink "$destination") # ignore trailing slashes for comparison if [ "${source_is%/}" = "${source%/}" ]; then echo present From 6d702053199760703a51d31820210f4e80445755 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Fri, 2 Nov 2018 15:25:13 +0100 Subject: [PATCH 0182/1217] ++changelog --- docs/changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog b/docs/changelog index 364e5ef2..8f414e44 100644 --- a/docs/changelog +++ b/docs/changelog @@ -9,6 +9,7 @@ next: * Type __consul: Add newest versions (Dominique Roux) * Type __user: Remove annoying output, handle state param gracefully, add messages for removal (Thomas Eckert) * Core: Fix checking for conflicting parameters for multiple values parameters (Darko Poljak) + * Documentation: Various fixes (Thomas Eckert) 4.10.3: 2018-09-23 * New global explorer: os_release (Ľubomír Kučera) From a34060d7035e84ff8f70d1e8d5bded7a1bfd71b3 Mon Sep 17 00:00:00 2001 From: sideeffect42 Date: Sat, 3 Nov 2018 19:17:56 +0100 Subject: [PATCH 0183/1217] Improve OpenBSD support (#720) * [type/__timezone] Whitelist OpenBSD OpenBSD ships /etc/localtime and /usr/share/zoneinfo by default. * [type/__postgres_{database,role}] Add explorer support for OpenBSD On OpenBSD the "postgres" user is called "_postgresql". The "postgres" database must me specifically specified as it differs from the user name. * [type/__postgres_{database,role}] Add gencode support for OpenBSD On OpenBSD the "postgres" user is called "_postgresql". The "postgres" database must me specifically specified when using psql as it differs from the user name. * [type/__postgres_role] Query DB if role exists instead of screen scaping * [type/__postgres_database] Query DB if database exists instead * [type/__postgres_{database,role}] Add user for NetBSD * [type/__postgres_extension] Add support for OpenBSD and NetBSD * [__ssh_authorized_key] Add OpenBSD support to entry explorer Make sure to adhere to re_format(7) for OpenBSD compatibility. https://man.openbsd.org/re_format.7 * [type/__start_on_boot] Add support for OpenBSD --- .../type/__postgres_database/explorer/state | 21 +++++++++++++++--- .../type/__postgres_database/gencode-remote | 18 +++++++++++++-- .../type/__postgres_extension/gencode-remote | 20 ++++++++++++++--- .../conf/type/__postgres_role/explorer/state | 21 +++++++++++++++--- .../conf/type/__postgres_role/gencode-remote | 22 +++++++++++++++---- .../type/__ssh_authorized_key/explorer/entry | 5 ++++- .../conf/type/__start_on_boot/explorer/state | 4 ++++ .../conf/type/__start_on_boot/gencode-remote | 5 +++++ cdist/conf/type/__timezone/manifest | 6 ++++- 9 files changed, 105 insertions(+), 17 deletions(-) diff --git a/cdist/conf/type/__postgres_database/explorer/state b/cdist/conf/type/__postgres_database/explorer/state index 54eb768d..652d81e7 100755 --- a/cdist/conf/type/__postgres_database/explorer/state +++ b/cdist/conf/type/__postgres_database/explorer/state @@ -18,10 +18,25 @@ # along with cdist. If not, see . # +case "$("${__explorer}/os")" +in + netbsd) + postgres_user='pgsql' + ;; + openbsd) + postgres_user='_postgresql' + ;; + *) + postgres_user='postgres' + ;; +esac + + name="$__object_id" -if su - postgres -c "echo '\\q' | psql '$name'" 2>/dev/null; then - echo "present" +if test -n "$(su - "$postgres_user" -c "psql postgres -tAc \"SELECT 1 FROM pg_database WHERE datname='$name'\"")" +then + echo 'present' else - echo "absent" + echo 'absent' fi diff --git a/cdist/conf/type/__postgres_database/gencode-remote b/cdist/conf/type/__postgres_database/gencode-remote index 92301fb8..61cfa50d 100755 --- a/cdist/conf/type/__postgres_database/gencode-remote +++ b/cdist/conf/type/__postgres_database/gencode-remote @@ -18,6 +18,20 @@ # along with cdist. If not, see . # +case "$(cat "${__global}/explorer/os")" +in + netbsd) + postgres_user='pgsql' + ;; + openbsd) + postgres_user='_postgresql' + ;; + *) + postgres_user='postgres' + ;; +esac + + name="$__object_id" state_should="$(cat "$__object/parameter/state")" state_is="$(cat "$__object/explorer/state")" @@ -29,10 +43,10 @@ if [ "$state_should" != "$state_is" ]; then if [ -f "$__object/parameter/owner" ]; then owner="-O '$(cat "$__object/parameter/owner")'" fi - echo "su - postgres -c \"createdb $owner '$name'\"" + echo "su - '$postgres_user' -c \"createdb $owner '$name'\"" ;; absent) - echo "su - postgres -c \"dropdb '$name'\"" + echo "su - '$postgres_user' -c \"dropdb '$name'\"" ;; esac fi diff --git a/cdist/conf/type/__postgres_extension/gencode-remote b/cdist/conf/type/__postgres_extension/gencode-remote index 627067c7..af9c97f1 100755 --- a/cdist/conf/type/__postgres_extension/gencode-remote +++ b/cdist/conf/type/__postgres_extension/gencode-remote @@ -22,6 +22,20 @@ # along with cdist. If not, see . # +case "$(cat "${__global}/explorer/os")" +in + netbsd) + postgres_user='pgsql' + ;; + openbsd) + postgres_user='_postgresql' + ;; + *) + postgres_user='postgres' + ;; +esac + + dbname=$( echo "$__object_id" | cut -d":" -f1 ) extension=$( echo "$__object_id" | cut -d":" -f2 ) @@ -30,10 +44,10 @@ state_should=$( cat "$__object/parameter/state" ) case "$state_should" in present) cmd="CREATE EXTENSION IF NOT EXISTS $extension" - echo "su - postgres -c 'psql -c \"$cmd\" \"$dbname\"'" + echo "su - '$postgres_user' -c 'psql -c \"$cmd\" \"$dbname\"'" ;; absent) - cmd="DROP EXTENSION IF EXISTS $extension" - echo "su - postgres -c 'psql -c \"$cmd\" \"$dbname\"'" + cmd="DROP EXTENSION IF EXISTS $extension" + echo "su - '$postgres_user' -c 'psql -c \"$cmd\" \"$dbname\"'" ;; esac diff --git a/cdist/conf/type/__postgres_role/explorer/state b/cdist/conf/type/__postgres_role/explorer/state index 40f64cef..5cc71477 100755 --- a/cdist/conf/type/__postgres_role/explorer/state +++ b/cdist/conf/type/__postgres_role/explorer/state @@ -18,10 +18,25 @@ # along with cdist. If not, see . # +case "$("${__explorer}/os")" +in + netbsd) + postgres_user='pgsql' + ;; + openbsd) + postgres_user='_postgresql' + ;; + *) + postgres_user='postgres' + ;; +esac + + name="$__object_id" -if su - postgres -c "psql -c '\\du' | grep -q '^ *$name *|'"; then - echo "present" +if test -n "$(su - "$postgres_user" -c "psql postgres -tAc \"SELECT 1 FROM pg_roles WHERE rolname='$name'\"")" +then + echo 'present' else - echo "absent" + echo 'absent' fi diff --git a/cdist/conf/type/__postgres_role/gencode-remote b/cdist/conf/type/__postgres_role/gencode-remote index f977e73e..f04b22e7 100755 --- a/cdist/conf/type/__postgres_role/gencode-remote +++ b/cdist/conf/type/__postgres_role/gencode-remote @@ -18,6 +18,20 @@ # along with cdist. If not, see . # +case "$(cat "${__global}/explorer/os")" +in + netbsd) + postgres_user='pgsql' + ;; + openbsd) + postgres_user='_postgresql' + ;; + *) + postgres_user='postgres' + ;; +esac + + name="$__object_id" state_is="$(cat "$__object/explorer/state")" state_should="$(cat "$__object/parameter/state")" @@ -38,12 +52,12 @@ case "$state_should" in booleans="$booleans $upper" done - [ -n "$password" ] && password="PASSWORD '$password'" + [ -n "$password" ] && password="PASSWORD '$password'" - cmd="CREATE ROLE $name WITH $password $booleans" - echo "su - postgres -c \"psql -c \\\"$cmd\\\"\"" + cmd="CREATE ROLE $name WITH $password $booleans" + echo "su - '$postgres_user' -c \"psql postgres -c '$cmd'\"" ;; absent) - echo "su - postgres -c \"dropuser \\\"$name\\\"\"" + echo "su - '$postgres_user' -c \"dropuser '$name'\"" ;; esac diff --git a/cdist/conf/type/__ssh_authorized_key/explorer/entry b/cdist/conf/type/__ssh_authorized_key/explorer/entry index 78efbb48..ccab0afc 100755 --- a/cdist/conf/type/__ssh_authorized_key/explorer/entry +++ b/cdist/conf/type/__ssh_authorized_key/explorer/entry @@ -27,5 +27,8 @@ then file="$(cat "$__object/parameter/file")" # get any entries that match the type and key - grep ".*$type_and_key\\([ \\n]\\|$\\)" "$file" || true + + # NOTE: Do not match from the beginning of the line as there may be options + # preceeding the key. + grep "${type_and_key}\\([ \\n].*\\)*$" "$file" || true fi diff --git a/cdist/conf/type/__start_on_boot/explorer/state b/cdist/conf/type/__start_on_boot/explorer/state index cef9013e..1f99db48 100644 --- a/cdist/conf/type/__start_on_boot/explorer/state +++ b/cdist/conf/type/__start_on_boot/explorer/state @@ -83,6 +83,10 @@ else state="absent" service -e | grep "/$name$" && state="present" ;; + openbsd) + state='absent' + # OpenBSD 5.7 and higher + rcctl ls on | grep "^${name}$" && state='present' *) echo "Unsupported os: $os" >&2 exit 1 diff --git a/cdist/conf/type/__start_on_boot/gencode-remote b/cdist/conf/type/__start_on_boot/gencode-remote index 122692ec..b9346826 100755 --- a/cdist/conf/type/__start_on_boot/gencode-remote +++ b/cdist/conf/type/__start_on_boot/gencode-remote @@ -81,6 +81,11 @@ case "$state_should" in : # handled in manifest ;; + openbsd) + # OpenBSD 5.7 and phigher + echo "rcctl enable '$name'" + ;; + *) echo "Unsupported os: $os" >&2 exit 1 diff --git a/cdist/conf/type/__timezone/manifest b/cdist/conf/type/__timezone/manifest index a20f5d32..c908f087 100755 --- a/cdist/conf/type/__timezone/manifest +++ b/cdist/conf/type/__timezone/manifest @@ -34,7 +34,11 @@ case "$os" in __package timezone export require="__package/timezone" ;; - freebsd|netbsd|coreos) + freebsd|netbsd|openbsd) + # whitelist + : + ;; + coreos) # whitelist : ;; From 0882a0beecf31ba5753d1fc4342234a8aee9bf18 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Sat, 3 Nov 2018 19:17:24 +0100 Subject: [PATCH 0184/1217] ++changelog --- docs/changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog b/docs/changelog index 8f414e44..a794ddb3 100644 --- a/docs/changelog +++ b/docs/changelog @@ -10,6 +10,7 @@ next: * Type __user: Remove annoying output, handle state param gracefully, add messages for removal (Thomas Eckert) * Core: Fix checking for conflicting parameters for multiple values parameters (Darko Poljak) * Documentation: Various fixes (Thomas Eckert) + * Various types: Improve OpenBSD support (sideeffect42) 4.10.3: 2018-09-23 * New global explorer: os_release (Ľubomír Kučera) From d11174f2b7e15fc1d9402226290c749378e21ca9 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Sat, 3 Nov 2018 19:21:20 +0100 Subject: [PATCH 0185/1217] Add missing ;; in case item. --- cdist/conf/type/__start_on_boot/explorer/state | 1 + 1 file changed, 1 insertion(+) diff --git a/cdist/conf/type/__start_on_boot/explorer/state b/cdist/conf/type/__start_on_boot/explorer/state index 1f99db48..19dfc74b 100644 --- a/cdist/conf/type/__start_on_boot/explorer/state +++ b/cdist/conf/type/__start_on_boot/explorer/state @@ -87,6 +87,7 @@ else state='absent' # OpenBSD 5.7 and higher rcctl ls on | grep "^${name}$" && state='present' + ;; *) echo "Unsupported os: $os" >&2 exit 1 From f8fbcdf2a7288d88db6f2afb9377cb53c69a195d Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Sat, 3 Nov 2018 19:22:59 +0100 Subject: [PATCH 0186/1217] Release 4.10.4 --- docs/changelog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/changelog b/docs/changelog index a794ddb3..fd68bed6 100644 --- a/docs/changelog +++ b/docs/changelog @@ -1,7 +1,7 @@ Changelog --------- -next: +4.10.4: 2018-11-03 * Core: Transfer all files of a directory at once instead of calling copy once per file (myeisha) * Core: Add timestamp (optional) to log messages (Darko Poljak) * Explorers and types: Fix shellcheck found problems and encountered bugs (Jonas Weber, Thomas Eckert, Darko Poljak) From 2cae33f6d64ad61f4d9679439605f13650d00bae Mon Sep 17 00:00:00 2001 From: Dimitrios Apostolou Date: Sun, 18 Nov 2018 01:30:40 +0100 Subject: [PATCH 0187/1217] Fix __group type failing with --gid The command `echo -- -g` prints `-- -g` so the generated `groupadd` command was syntactically incorrect and failing. Solution was to remove `--` since echo command does not understand it, and add instead an extra space before `-g` to avoid echo interpreting it as a flag. --- cdist/conf/type/__group/gencode-remote | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cdist/conf/type/__group/gencode-remote b/cdist/conf/type/__group/gencode-remote index 822619d2..6091c548 100755 --- a/cdist/conf/type/__group/gencode-remote +++ b/cdist/conf/type/__group/gencode-remote @@ -30,9 +30,9 @@ state="$(cat "$__object/parameter/state")" # Use short option names for portability shorten_property() { case "$1" in - gid) echo -- "-g";; - password) echo -- "-p";; - system) echo -- "-r";; + gid) echo " -g";; + password) echo " -p";; + system) echo " -r";; esac } From 308be1b6fae2adba6b9c2fb2bd946027f066de29 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Sun, 18 Nov 2018 16:04:24 +0100 Subject: [PATCH 0188/1217] ++changelog --- docs/changelog | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/changelog b/docs/changelog index fd68bed6..f1faf131 100644 --- a/docs/changelog +++ b/docs/changelog @@ -1,6 +1,9 @@ Changelog --------- +next: + * Type __group: Fix/remove '--' from echo command (Dimitrios Apostolou) + 4.10.4: 2018-11-03 * Core: Transfer all files of a directory at once instead of calling copy once per file (myeisha) * Core: Add timestamp (optional) to log messages (Darko Poljak) From 71ceba4ac588efcd995e2ffcdd9a5aea5f014371 Mon Sep 17 00:00:00 2001 From: Olliver Schinagl Date: Mon, 26 Nov 2018 15:49:23 +0100 Subject: [PATCH 0189/1217] type: Add new type __ping When starting with cdist, the documentation and examples can be overwheliming. Further more, sometimes one would only want to do a simple test to see if the basics are working. One such example currently is to create a simple remote file. While this is a nice and simple example, an even simpler example would be to just see if we can 'ping' the host. Other configuration management tools also seem to have this as a basic starting command. This thus allows to do: echo __ping | cdist config --initial-manifest - as the most basic, most simple command to 'test' things with, without having lingering files to boot. Signed-off-by: Olliver Schinagl --- cdist/conf/type/__ping/gencode-remote | 12 ++++++++ cdist/conf/type/__ping/man.rst | 43 +++++++++++++++++++++++++++ cdist/conf/type/__ping/singleton | 0 3 files changed, 55 insertions(+) create mode 100644 cdist/conf/type/__ping/gencode-remote create mode 100644 cdist/conf/type/__ping/man.rst create mode 100644 cdist/conf/type/__ping/singleton diff --git a/cdist/conf/type/__ping/gencode-remote b/cdist/conf/type/__ping/gencode-remote new file mode 100644 index 00000000..1341b954 --- /dev/null +++ b/cdist/conf/type/__ping/gencode-remote @@ -0,0 +1,12 @@ +#!/bin/sh -e +# +# Copyright (C) 2018 Olliver Schinagl +# +# SPDX-License-Identifier: GPL-3.0+ +# + +set -eu + +echo "echo 'pong'" + +exit 0 diff --git a/cdist/conf/type/__ping/man.rst b/cdist/conf/type/__ping/man.rst new file mode 100644 index 00000000..e08643dc --- /dev/null +++ b/cdist/conf/type/__ping/man.rst @@ -0,0 +1,43 @@ +cdist-type__ping(7) +================================== + +NAME +---- +cdist-type__ping - Try to connect to host and return 'pong' on success + + +DESCRIPTION +----------- +A simple type which tries to connect to a remote host and runs a simple command +to ensure everything is working. + + +REQUIRED PARAMETERS +------------------- +None. + + +OPTIONAL PARAMETERS +------------------- +None. + + +EXAMPLES +-------- + +.. code-block:: sh + + __ping + + +AUTHORS +------- +Olliver Schinagl + + +COPYING +------- +Copyright \(C) 2018 Schinagl. 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/__ping/singleton b/cdist/conf/type/__ping/singleton new file mode 100644 index 00000000..e69de29b From 6b95db8fc78a26cb0159be504bc05f3cd90afd00 Mon Sep 17 00:00:00 2001 From: Olliver Schinagl Date: Mon, 26 Nov 2018 20:39:20 +0100 Subject: [PATCH 0190/1217] Update .gitignore to more broadly ignore vim As per https://github.com/github/gitignore/blob/master/Global/Vim.gitignore Signed-off-by: Olliver Schinagl --- .gitignore | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 0c664232..320d150d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,21 @@ # -vim -.*.swp +# Swap +[._]*.s[a-v][a-z] +[._]*.sw[a-p] +[._]s[a-rt-v][a-z] +[._]ss[a-gi-z] +[._]sw[a-p] + +# Session +Session.vim + +# Temporary +.netrwhist +*~ +# Auto-generated tag files +tags +# Persistent undo +[._]*.un~ # Ignore generated manpages docs/src/.marker From a85f2ebdb6d398ea59524d577b69ca44882450b4 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Tue, 27 Nov 2018 10:41:02 +0100 Subject: [PATCH 0191/1217] ++changelog --- docs/changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog b/docs/changelog index f1faf131..20209bca 100644 --- a/docs/changelog +++ b/docs/changelog @@ -3,6 +3,7 @@ Changelog next: * Type __group: Fix/remove '--' from echo command (Dimitrios Apostolou) + * New type: __ping (Olliver Schinagl) 4.10.4: 2018-11-03 * Core: Transfer all files of a directory at once instead of calling copy once per file (myeisha) From c85dfbdb10f11adce29dc9c9b5eaac252a825706 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 5 Dec 2018 13:14:19 +0100 Subject: [PATCH 0192/1217] [__postgres_role] Revert parts of a34060d7035e84ff8f70d1e8d5bded7a1bfd71b3 Broken syntax fixed --- cdist/conf/type/__postgres_role/gencode-remote | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cdist/conf/type/__postgres_role/gencode-remote b/cdist/conf/type/__postgres_role/gencode-remote index f04b22e7..11897306 100755 --- a/cdist/conf/type/__postgres_role/gencode-remote +++ b/cdist/conf/type/__postgres_role/gencode-remote @@ -55,9 +55,9 @@ case "$state_should" in [ -n "$password" ] && password="PASSWORD '$password'" cmd="CREATE ROLE $name WITH $password $booleans" - echo "su - '$postgres_user' -c \"psql postgres -c '$cmd'\"" + echo "su - '$postgres_user' -c \"psql -c \\\"$cmd\\\"\"" ;; absent) - echo "su - '$postgres_user' -c \"dropuser '$name'\"" + echo "su - '$postgres_user' -c \"dropuser \\\"$name\\\"\"" ;; esac From 0491b5b8db3a8d5f36c61e9a4e7ac5b625bcdb58 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Wed, 5 Dec 2018 16:41:22 +0100 Subject: [PATCH 0193/1217] Revert "[__postgres_role] Revert parts of a34060d7035e84ff8f70d1e8d5bded7a1bfd71b3" This reverts commit c85dfbdb10f11adce29dc9c9b5eaac252a825706. --- cdist/conf/type/__postgres_role/gencode-remote | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cdist/conf/type/__postgres_role/gencode-remote b/cdist/conf/type/__postgres_role/gencode-remote index 11897306..f04b22e7 100755 --- a/cdist/conf/type/__postgres_role/gencode-remote +++ b/cdist/conf/type/__postgres_role/gencode-remote @@ -55,9 +55,9 @@ case "$state_should" in [ -n "$password" ] && password="PASSWORD '$password'" cmd="CREATE ROLE $name WITH $password $booleans" - echo "su - '$postgres_user' -c \"psql -c \\\"$cmd\\\"\"" + echo "su - '$postgres_user' -c \"psql postgres -c '$cmd'\"" ;; absent) - echo "su - '$postgres_user' -c \"dropuser \\\"$name\\\"\"" + echo "su - '$postgres_user' -c \"dropuser '$name'\"" ;; esac From 45d10374912ee215650efa622cc3af577a0c19ea Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Wed, 5 Dec 2018 16:51:37 +0100 Subject: [PATCH 0194/1217] [__postgres_role] Revert parts of a34060d7035e84ff8f70d1e8d5bded7a1bfd71b3 Broken syntax fixed --- cdist/conf/type/__postgres_role/gencode-remote | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cdist/conf/type/__postgres_role/gencode-remote b/cdist/conf/type/__postgres_role/gencode-remote index f04b22e7..30d0689c 100755 --- a/cdist/conf/type/__postgres_role/gencode-remote +++ b/cdist/conf/type/__postgres_role/gencode-remote @@ -55,9 +55,9 @@ case "$state_should" in [ -n "$password" ] && password="PASSWORD '$password'" cmd="CREATE ROLE $name WITH $password $booleans" - echo "su - '$postgres_user' -c \"psql postgres -c '$cmd'\"" + echo "su - '$postgres_user' -c \"psql postgres -c \\\"$cmd\\\"\"" ;; absent) - echo "su - '$postgres_user' -c \"dropuser '$name'\"" + echo "su - '$postgres_user' -c \"dropuser \\\"$name\\\"\"" ;; esac From 5014fd23882f883cb154696c7f0fc2b7e90e39b1 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Wed, 5 Dec 2018 16:54:39 +0100 Subject: [PATCH 0195/1217] ++changelog --- docs/changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog b/docs/changelog index 20209bca..cc4bc838 100644 --- a/docs/changelog +++ b/docs/changelog @@ -4,6 +4,7 @@ Changelog next: * Type __group: Fix/remove '--' from echo command (Dimitrios Apostolou) * New type: __ping (Olliver Schinagl) + * Type __postgres_role: Fix broken syntax (Nico Schottelius, Darko Poljak) 4.10.4: 2018-11-03 * Core: Transfer all files of a directory at once instead of calling copy once per file (myeisha) From 7e9dce0ceb5500fe451170bc39705fe4a67c3095 Mon Sep 17 00:00:00 2001 From: Takashi Yoshi Date: Fri, 7 Dec 2018 16:53:21 +0100 Subject: [PATCH 0196/1217] [type/__package_*] Print installed/removed messages Up-/downgraded packages will send an "installed" message. --- cdist/conf/type/__package_emerge/gencode-remote | 2 ++ cdist/conf/type/__package_luarocks/gencode-remote | 2 ++ cdist/conf/type/__package_opkg/gencode-remote | 4 +++- cdist/conf/type/__package_pacman/gencode-remote | 2 ++ cdist/conf/type/__package_pip/gencode-remote | 2 ++ cdist/conf/type/__package_pkg_freebsd/gencode-remote | 5 ++++- cdist/conf/type/__package_pkg_openbsd/gencode-remote | 10 ++++++---- cdist/conf/type/__package_pkgng_freebsd/gencode-remote | 3 +++ cdist/conf/type/__package_rubygem/gencode-remote | 2 ++ cdist/conf/type/__package_yum/gencode-remote | 2 ++ cdist/conf/type/__package_zypper/gencode-remote | 3 +++ 11 files changed, 31 insertions(+), 6 deletions(-) diff --git a/cdist/conf/type/__package_emerge/gencode-remote b/cdist/conf/type/__package_emerge/gencode-remote index 48462bde..c25f2be7 100755 --- a/cdist/conf/type/__package_emerge/gencode-remote +++ b/cdist/conf/type/__package_emerge/gencode-remote @@ -64,9 +64,11 @@ fi case "$state_should" in present) echo "emerge '$name' &>/dev/null || exit 1" + echo "installed" >> "$__messages_out" ;; absent) echo "emerge -C '$name' &>/dev/null || exit 1" + echo "removed" >> "$__messages_out" ;; *) echo "Unknown state: $state_should" >&2 diff --git a/cdist/conf/type/__package_luarocks/gencode-remote b/cdist/conf/type/__package_luarocks/gencode-remote index 60b9bfea..d83b3c3a 100755 --- a/cdist/conf/type/__package_luarocks/gencode-remote +++ b/cdist/conf/type/__package_luarocks/gencode-remote @@ -43,9 +43,11 @@ fi case "$state_should" in present) echo "luarocks install '$name'" + echo "installed" >> "$__messages_out" ;; absent) echo "luarocks remove '$name'" + echo "removed" >> "$__messages_out" ;; *) echo "Unknown state: $state_should" >&2 diff --git a/cdist/conf/type/__package_opkg/gencode-remote b/cdist/conf/type/__package_opkg/gencode-remote index e94ff388..269d5f49 100755 --- a/cdist/conf/type/__package_opkg/gencode-remote +++ b/cdist/conf/type/__package_opkg/gencode-remote @@ -43,12 +43,14 @@ esac case "$state_should" in present) if [ "$present" = "notpresent" ]; then - echo opkg --verbosity=0 update + echo "opkg --verbosity=0 update" fi echo "opkg --verbosity=0 install '$name'" + echo "installed" >> "$__messages_out" ;; absent) echo "opkg --verbosity=0 remove '$name'" + echo "removed" >> "$__messages_out" ;; *) echo "Unknown state: ${state_should}" >&2 diff --git a/cdist/conf/type/__package_pacman/gencode-remote b/cdist/conf/type/__package_pacman/gencode-remote index 7ba85479..2e076ec3 100755 --- a/cdist/conf/type/__package_pacman/gencode-remote +++ b/cdist/conf/type/__package_pacman/gencode-remote @@ -46,9 +46,11 @@ fi case "$state_should" in present) echo "pacman --needed --noconfirm --noprogressbar -S '$name'" + echo "installed" >> "$__messages_out" ;; absent) echo "pacman --noconfirm --noprogressbar -R '$name'" + echo "removed" >> "$__messages_out" ;; *) echo "Unknown state: $state_should" >&2 diff --git a/cdist/conf/type/__package_pip/gencode-remote b/cdist/conf/type/__package_pip/gencode-remote index 33556bec..dcc4fdf9 100755 --- a/cdist/conf/type/__package_pip/gencode-remote +++ b/cdist/conf/type/__package_pip/gencode-remote @@ -57,6 +57,7 @@ case "$state_should" in else echo $pip install -q "$name" fi + echo "installed" >> "$__messages_out" ;; absent) if [ "$runas" ] @@ -65,6 +66,7 @@ case "$state_should" in else echo $pip uninstall -q -y "$name" fi + echo "removed" >> "$__messages_out" ;; *) echo "Unknown state: $state_should" >&2 diff --git a/cdist/conf/type/__package_pkg_freebsd/gencode-remote b/cdist/conf/type/__package_pkg_freebsd/gencode-remote index fd02d939..3f88f6bc 100755 --- a/cdist/conf/type/__package_pkg_freebsd/gencode-remote +++ b/cdist/conf/type/__package_pkg_freebsd/gencode-remote @@ -39,7 +39,7 @@ assert () # If condition false, # shellcheck disable=SC2039 echo "File \"$0\", line $lineno, called by $(caller 0)" exit $E_ASSERT_FAILED - fi + fi } # Debug @@ -89,6 +89,7 @@ if [ -n "$curr_version" ]; then # PKG *is* installed cmd="${rm_cmd} ${name}-${curr_version}" fi execcmd "remove" "${cmd}" + echo "removed" >> "$__messages_out" exit 0 else # Should be installed if [ -n "$version" ]; then # Want a specific version @@ -102,6 +103,7 @@ if [ -n "$curr_version" ]; then # PKG *is* installed execcmd "remove" "${cmd}" cmd="${add_cmd} -r ${name}-${version}" execcmd "add" "${cmd}" + echo "installed" >> "$__messages_out" fi else # Don't care what version to use exit 0 @@ -120,6 +122,7 @@ else # PKG *isn't* installed cmd="${cmd}-${version}" fi execcmd "add" "${cmd}" + echo "installed" >> "$__messages_out" exit 0 fi fi diff --git a/cdist/conf/type/__package_pkg_openbsd/gencode-remote b/cdist/conf/type/__package_pkg_openbsd/gencode-remote index 61383edb..da63626b 100755 --- a/cdist/conf/type/__package_pkg_openbsd/gencode-remote +++ b/cdist/conf/type/__package_pkg_openbsd/gencode-remote @@ -62,15 +62,15 @@ state_should="$(cat "$__object/parameter/state")" pkg_version="$(cat "$__object/explorer/pkg_version")" -if [ -f "$__object/parameter/pkg_path" ]; then - pkg_path="$(cat "$__object/parameter/pkg_path")" +if [ -f "$__object/parameter/pkg_path" ]; then + pkg_path="$(cat "$__object/parameter/pkg_path")" else has_installurl=$(cat "${__object}/explorer/has_installurl") if [ Xyes != X"${has_installurl}" ]; then # there is no default PKG_PATH, try to provide one pkg_path="ftp://ftp.openbsd.org/pub/OpenBSD/$os_version/packages/$machine/" fi -fi +fi if [ "$pkg_version" ]; then state_is="present" @@ -99,11 +99,12 @@ if [ \$? -ne 0 ]; then echo "Error: \$status" exit 1 fi +echo "installed" >> "$__messages_out" eof ;; absent) - # use this because pkg_add doesn't properly handle errors + # use this because pkg_delete doesn't properly handle errors cat << eof status=\$(pkg_delete "$pkgopts" "$pkgid") pkg_info | grep "^${name}.*${version}.*${flavor}" > /dev/null 2>&1 @@ -117,6 +118,7 @@ if [ \$? -eq 0 ]; then echo "Error: \$status" exit 1 fi +echo "removed" >> "$__messages_out" eof ;; *) diff --git a/cdist/conf/type/__package_pkgng_freebsd/gencode-remote b/cdist/conf/type/__package_pkgng_freebsd/gencode-remote index b72544c1..dd36efda 100755 --- a/cdist/conf/type/__package_pkgng_freebsd/gencode-remote +++ b/cdist/conf/type/__package_pkgng_freebsd/gencode-remote @@ -57,12 +57,15 @@ execcmd(){ case "$1" in add) _cmd="${add_cmd} $2" + echo "installed" >> "$__messages_out" ;; rm) _cmd="${rm_cmd} $2" + echo "removed" >> "$__messages_out" ;; upg) _cmd="${upg_cmd} $2" + echo "installed" >> "$__messages_out" ;; *) printf "Error. Don't understand command: %s" "$1" >&2 diff --git a/cdist/conf/type/__package_rubygem/gencode-remote b/cdist/conf/type/__package_rubygem/gencode-remote index ee563ef8..abb40653 100755 --- a/cdist/conf/type/__package_rubygem/gencode-remote +++ b/cdist/conf/type/__package_rubygem/gencode-remote @@ -40,9 +40,11 @@ fi case "$state_should" in present) echo "gem install '$name' --no-ri --no-rdoc" + echo "installed" >> "$__messages_out" ;; absent) echo "gem uninstall '$name'" + echo "removed" >> "$__messages_out" ;; *) echo "Unknown state: $state_should" >&2 diff --git a/cdist/conf/type/__package_yum/gencode-remote b/cdist/conf/type/__package_yum/gencode-remote index 97265827..b52953f6 100755 --- a/cdist/conf/type/__package_yum/gencode-remote +++ b/cdist/conf/type/__package_yum/gencode-remote @@ -61,9 +61,11 @@ fi case "$state_should" in present) echo "yum $opts install '$install_name'" + echo "installed" >> "$__messages_out" ;; absent) echo "yum $opts remove '$name'" + echo "removed" >> "$__messages_out" ;; *) echo "Unknown state: $state_should" >&2 diff --git a/cdist/conf/type/__package_zypper/gencode-remote b/cdist/conf/type/__package_zypper/gencode-remote index 1f15c531..e45dd9ff 100755 --- a/cdist/conf/type/__package_zypper/gencode-remote +++ b/cdist/conf/type/__package_zypper/gencode-remote @@ -62,14 +62,17 @@ case "$state_should" in if [ -z "$version_should" ]; then [ "$state_is" = "present" ] && exit 0 # if state is present, we dont need to do anything echo "zypper $globalopts install --type '$ptype' --auto-agree-with-licenses '$name' >/dev/null" + echo "removed" >> "$__messages_out" else [ "$state_is" = "present" ] && [ "$version_should" = "$version_is" ] && exit 0 # if state is present and version is correct, we dont need to do anything echo "zypper $globalopts install --oldpackage --type '$ptype' --auto-agree-with-licenses '$name' = '$version_should' >/dev/null" + echo "installed" >> "$__messages_out" fi ;; absent) [ "$state_is" = "absent" ] && exit 0 # if state is absent, we dont need to do anything echo "zypper $globalopts remove --type '$ptype' '$name' >/dev/null" + echo "removed" >> "$__messages_out" ;; *) echo "Unknown state: $state_should" >&2 From ccdbf1a31c92681e2f34d7a48acc67f243548520 Mon Sep 17 00:00:00 2001 From: Takashi Yoshi Date: Fri, 7 Dec 2018 16:55:49 +0100 Subject: [PATCH 0197/1217] [type/__package_emerge_dependendencies] Send messages when a dependency is installed --- cdist/conf/type/__package_emerge_dependencies/gencode-remote | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cdist/conf/type/__package_emerge_dependencies/gencode-remote b/cdist/conf/type/__package_emerge_dependencies/gencode-remote index face898a..f3e6f76e 100755 --- a/cdist/conf/type/__package_emerge_dependencies/gencode-remote +++ b/cdist/conf/type/__package_emerge_dependencies/gencode-remote @@ -6,10 +6,11 @@ flaggie_installed="$(cat "$__object/explorer/flaggie_installed")" if [ "${gentoolkit_installed}" != "true" ]; then # emerge app-portage/gentoolkit echo "emerge app-portage/gentoolkit &> /dev/null || exit 1" + echo "installed app-portage/gentoolkit" >> "$__messages_out" fi if [ "${flaggie_installed}" != "true" ]; then # emerge app-portage/flaggie echo "emerge app-portage/flaggie &> /dev/null || exit 1" + echo "installed app-portage/flaggie" >> "$__messages_out" fi - From 8ad93a29c964b623604846ca92ae3a24d45e7e64 Mon Sep 17 00:00:00 2001 From: "jinguk.kwon" Date: Wed, 12 Dec 2018 01:40:39 +0900 Subject: [PATCH 0198/1217] update for debian version 9 --- cdist/conf/type/__consul_agent/manifest | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cdist/conf/type/__consul_agent/manifest b/cdist/conf/type/__consul_agent/manifest index 3951f728..c48bfe85 100755 --- a/cdist/conf/type/__consul_agent/manifest +++ b/cdist/conf/type/__consul_agent/manifest @@ -206,7 +206,7 @@ case "$os" in [567]) init_sysvinit debian ;; - 8) + [89]) init_systemd ;; *) From 49f2d3bf9191f9a8ea06ec5ae566ce744781908e Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 11 Dec 2018 18:48:23 +0100 Subject: [PATCH 0199/1217] ++ changelog --- docs/changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog b/docs/changelog index cc4bc838..536ff674 100644 --- a/docs/changelog +++ b/docs/changelog @@ -5,6 +5,7 @@ next: * Type __group: Fix/remove '--' from echo command (Dimitrios Apostolou) * New type: __ping (Olliver Schinagl) * Type __postgres_role: Fix broken syntax (Nico Schottelius, Darko Poljak) + * Type __consul_agent: Add Debian 9 support (Jin-Guk Kwon) 4.10.4: 2018-11-03 * Core: Transfer all files of a directory at once instead of calling copy once per file (myeisha) From 96a0eaabf1caf912de5b430a655c634981b7122a Mon Sep 17 00:00:00 2001 From: Rage OxR463 <43783393+oxr463@users.noreply.github.com> Date: Wed, 12 Dec 2018 12:12:36 -0500 Subject: [PATCH 0200/1217] Fix broken links. --- docs/web/cdist.mdwn | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/web/cdist.mdwn b/docs/web/cdist.mdwn index 74457fc8..90af20cb 100644 --- a/docs/web/cdist.mdwn +++ b/docs/web/cdist.mdwn @@ -6,10 +6,10 @@ cdist is a usable configuration management system. It adheres to the KISS principle and is being used in small up to enterprise grade environments. cdist is an alternative to other configuration management systems like -[bcfg2](http://trac.mcs.anl.gov/projects/bcfg2), -[chef](http://wiki.opscode.com/display/chef/), -[cfengine](http://www.cfengine.org/) -and [puppet](http://www.puppetlabs.com/). +[bcfg2](http://bcfg2.org/), +[chef](https://www.chef.sh/), +[cfengine](https://cfengine.com/) +and [puppet](https://puppet.com/). * [[Why should I use cdist?|why]] * [[Documentation|documentation]] From f2ef1ef0d688ed24e619fddd2d42a9967f862370 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Thu, 13 Dec 2018 12:32:57 +0100 Subject: [PATCH 0201/1217] ++changelog --- docs/changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog b/docs/changelog index 536ff674..c2bc2001 100644 --- a/docs/changelog +++ b/docs/changelog @@ -6,6 +6,7 @@ next: * New type: __ping (Olliver Schinagl) * Type __postgres_role: Fix broken syntax (Nico Schottelius, Darko Poljak) * Type __consul_agent: Add Debian 9 support (Jin-Guk Kwon) + * Documentation: Fix broken links (Rage ) 4.10.4: 2018-11-03 * Core: Transfer all files of a directory at once instead of calling copy once per file (myeisha) From a7f4c8d7736f961a654f93340439da92ccb1bd7f Mon Sep 17 00:00:00 2001 From: Jonas Weber Date: Thu, 13 Dec 2018 13:23:49 +0100 Subject: [PATCH 0202/1217] Allow installing specific Docker-CE version --- cdist/conf/type/__docker/man.rst | 5 +++++ cdist/conf/type/__docker/manifest | 13 +++++++++++-- cdist/conf/type/__docker/parameter/default/version | 1 + cdist/conf/type/__docker/parameter/optional | 1 + 4 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 cdist/conf/type/__docker/parameter/default/version diff --git a/cdist/conf/type/__docker/man.rst b/cdist/conf/type/__docker/man.rst index 5cb28ee1..718543a8 100644 --- a/cdist/conf/type/__docker/man.rst +++ b/cdist/conf/type/__docker/man.rst @@ -20,6 +20,9 @@ OPTIONAL PARAMETERS ------------------- state 'present' or 'absent', defaults to 'present' +version + The specific version to install. Defaults to the special value 'latest', + meaning the version the package manager will install by default. BOOLEAN PARAMETERS @@ -38,6 +41,8 @@ EXAMPLES # Remove docker __docker --state absent + # Install specific version + __docker --state present --version 18.03.0.ce AUTHORS ------- diff --git a/cdist/conf/type/__docker/manifest b/cdist/conf/type/__docker/manifest index 8f26feec..a893ea15 100755 --- a/cdist/conf/type/__docker/manifest +++ b/cdist/conf/type/__docker/manifest @@ -21,6 +21,7 @@ os=$(cat "$__global/explorer/os") state=$(cat "$__object/parameter/state") +version=$(cat "$__object/parameter/version") case "$os" in centos) @@ -33,7 +34,11 @@ case "$os" in --gpgcheck 1 \ --gpgkey 'https://download.docker.com/linux/centos/gpg' \ --state "${state}" - require="__yum_repo/docker-ce-stable" __package docker-ce --state "${state}" + if [ "$version" != "latest" ]; then + require="__yum_repo/docker-ce-stable" __package docker-ce --version "${version}" --state "${state}" + else + require="__yum_repo/docker-ce-stable" __package docker-ce --state "${state}" + fi else echo "CentOS version 7 is required!" >&2 exit 1 @@ -53,7 +58,11 @@ case "$os" in --distribution "$(cat "$__global/explorer/lsb_codename")" \ --state "${state}" \ --component "stable" - __package docker-ce --state "${state}" + if [ "$version" != "latest" ]; then + __package docker-ce --version "${version}" --state "${state}" + else + __package docker-ce --state "${state}" + fi unset CDIST_ORDER_DEPENDENCY ;; *) diff --git a/cdist/conf/type/__docker/parameter/default/version b/cdist/conf/type/__docker/parameter/default/version new file mode 100644 index 00000000..a0f9a4b4 --- /dev/null +++ b/cdist/conf/type/__docker/parameter/default/version @@ -0,0 +1 @@ +latest diff --git a/cdist/conf/type/__docker/parameter/optional b/cdist/conf/type/__docker/parameter/optional index ff72b5c7..4d595ed7 100644 --- a/cdist/conf/type/__docker/parameter/optional +++ b/cdist/conf/type/__docker/parameter/optional @@ -1 +1,2 @@ state +version From d4bb114468dcd8ea1483edfe20609d2179037f93 Mon Sep 17 00:00:00 2001 From: Jonas Weber Date: Thu, 13 Dec 2018 13:26:40 +0100 Subject: [PATCH 0203/1217] Remove usage of CDIST_ORDER_DEPENDENCY --- cdist/conf/type/__docker/manifest | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/cdist/conf/type/__docker/manifest b/cdist/conf/type/__docker/manifest index a893ea15..04a9ff27 100755 --- a/cdist/conf/type/__docker/manifest +++ b/cdist/conf/type/__docker/manifest @@ -52,18 +52,17 @@ case "$os" in fi __apt_key_uri docker --name "Docker Release (CE deb) " \ --uri "https://download.docker.com/linux/${os}/gpg" --state "${state}" - export CDIST_ORDER_DEPENDENCY=on - __apt_source docker \ + + require="__apt_key_uri/docker" __apt_source docker \ --uri "https://download.docker.com/linux/${os}" \ --distribution "$(cat "$__global/explorer/lsb_codename")" \ --state "${state}" \ --component "stable" if [ "$version" != "latest" ]; then - __package docker-ce --version "${version}" --state "${state}" + require="__apt_source/docker" __package docker-ce --version "${version}" --state "${state}" else - __package docker-ce --state "${state}" + require="__apt_source/docker" __package docker-ce --state "${state}" fi - unset CDIST_ORDER_DEPENDENCY ;; *) echo "Your operating system ($os) is currently not supported by this type (${__type##*/})." >&2 From 75afdd4d695e63fa95fb507a2dfb1cedc08f5e56 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Thu, 13 Dec 2018 20:14:54 +0100 Subject: [PATCH 0204/1217] ++changelog --- docs/changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog b/docs/changelog index c2bc2001..a662eb38 100644 --- a/docs/changelog +++ b/docs/changelog @@ -7,6 +7,7 @@ next: * Type __postgres_role: Fix broken syntax (Nico Schottelius, Darko Poljak) * Type __consul_agent: Add Debian 9 support (Jin-Guk Kwon) * Documentation: Fix broken links (Rage ) + * Type __docker: Add version parameter (Jonas Weber) 4.10.4: 2018-11-03 * Core: Transfer all files of a directory at once instead of calling copy once per file (myeisha) From 183d57d6d2aeb05d37bef3896badd9a20a6c541f Mon Sep 17 00:00:00 2001 From: Takashi Yoshi Date: Fri, 14 Dec 2018 12:43:57 +0100 Subject: [PATCH 0205/1217] [type/__sysctl] Fix spelling of FreeBSD --- cdist/conf/type/__sysctl/gencode-remote | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cdist/conf/type/__sysctl/gencode-remote b/cdist/conf/type/__sysctl/gencode-remote index a7aedb84..888ca117 100755 --- a/cdist/conf/type/__sysctl/gencode-remote +++ b/cdist/conf/type/__sysctl/gencode-remote @@ -31,7 +31,7 @@ case "$os" in redhat|centos|ubuntu|debian|devuan|archlinux|coreos) flag='-w' ;; - frebsd) + freebsd) flag='' ;; esac From b36716ef3619ff9881be98b0fa896ade7456a8e0 Mon Sep 17 00:00:00 2001 From: Takashi Yoshi Date: Fri, 14 Dec 2018 12:44:41 +0100 Subject: [PATCH 0206/1217] [type/__sysctl] Add OpenBSD support --- cdist/conf/type/__sysctl/gencode-remote | 3 ++- cdist/conf/type/__sysctl/manifest | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/cdist/conf/type/__sysctl/gencode-remote b/cdist/conf/type/__sysctl/gencode-remote index 888ca117..76e5f528 100755 --- a/cdist/conf/type/__sysctl/gencode-remote +++ b/cdist/conf/type/__sysctl/gencode-remote @@ -1,6 +1,7 @@ #!/bin/sh -e # # 2014 Steven Armstrong (steven-cdist at armstrong.cc) +# 2018 Takashi Yoshi (takashi at yoshi.email) # # This file is part of cdist. # @@ -31,7 +32,7 @@ case "$os" in redhat|centos|ubuntu|debian|devuan|archlinux|coreos) flag='-w' ;; - freebsd) + freebsd|openbsd) flag='' ;; esac diff --git a/cdist/conf/type/__sysctl/manifest b/cdist/conf/type/__sysctl/manifest index 6e337ccb..43feec04 100755 --- a/cdist/conf/type/__sysctl/manifest +++ b/cdist/conf/type/__sysctl/manifest @@ -1,6 +1,7 @@ #!/bin/sh -e # # 2014 Steven Armstrong (steven-cdist at armstrong.cc) +# 2018 Takashi Yoshi (takashi at yoshi.email) # # This file is part of cdist. # @@ -22,7 +23,7 @@ os=$(cat "$__global/explorer/os") case "$os" in - redhat|centos|ubuntu|debian|devuan|archlinux|coreos|freebsd) + redhat|centos|ubuntu|debian|devuan|archlinux|coreos|freebsd|openbsd) : ;; *) From 566feba5b16b6eb56371fe0fa669d83c1d929bfc Mon Sep 17 00:00:00 2001 From: Takashi Yoshi Date: Fri, 14 Dec 2018 12:55:03 +0100 Subject: [PATCH 0207/1217] [type/__sysctl] Add NetBSD support --- cdist/conf/type/__sysctl/gencode-remote | 2 +- cdist/conf/type/__sysctl/manifest | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/cdist/conf/type/__sysctl/gencode-remote b/cdist/conf/type/__sysctl/gencode-remote index 76e5f528..873932ba 100755 --- a/cdist/conf/type/__sysctl/gencode-remote +++ b/cdist/conf/type/__sysctl/gencode-remote @@ -29,7 +29,7 @@ fi os=$(cat "$__global/explorer/os") case "$os" in - redhat|centos|ubuntu|debian|devuan|archlinux|coreos) + redhat|centos|ubuntu|debian|devuan|archlinux|coreos|netbsd) flag='-w' ;; freebsd|openbsd) diff --git a/cdist/conf/type/__sysctl/manifest b/cdist/conf/type/__sysctl/manifest index 43feec04..df3ff13c 100755 --- a/cdist/conf/type/__sysctl/manifest +++ b/cdist/conf/type/__sysctl/manifest @@ -23,7 +23,12 @@ os=$(cat "$__global/explorer/os") case "$os" in - redhat|centos|ubuntu|debian|devuan|archlinux|coreos|freebsd|openbsd) + # Linux + redhat|centos|ubuntu|debian|devuan|archlinux|coreos) + : + ;; + # BSD + freebsd|netbsd|openbsd) : ;; *) From 45ff67c0f55ece10c4265e8ab187b78ec432f1de Mon Sep 17 00:00:00 2001 From: Takashi Yoshi Date: Fri, 14 Dec 2018 13:06:31 +0100 Subject: [PATCH 0208/1217] [type/__sysctl] Add Mac OS X support --- cdist/conf/type/__sysctl/gencode-remote | 8 +++++++- cdist/conf/type/__sysctl/manifest | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/cdist/conf/type/__sysctl/gencode-remote b/cdist/conf/type/__sysctl/gencode-remote index 873932ba..e17e0659 100755 --- a/cdist/conf/type/__sysctl/gencode-remote +++ b/cdist/conf/type/__sysctl/gencode-remote @@ -31,7 +31,13 @@ os=$(cat "$__global/explorer/os") case "$os" in redhat|centos|ubuntu|debian|devuan|archlinux|coreos|netbsd) flag='-w' - ;; + ;; + macosx) + # NOTE: Older versions of Mac OS X require the -w option. + # Even though the flag is not mentioned in new man pages anymore, + # it still works. + flag='-w' + ;; freebsd|openbsd) flag='' ;; diff --git a/cdist/conf/type/__sysctl/manifest b/cdist/conf/type/__sysctl/manifest index df3ff13c..b4e2e902 100755 --- a/cdist/conf/type/__sysctl/manifest +++ b/cdist/conf/type/__sysctl/manifest @@ -28,7 +28,7 @@ case "$os" in : ;; # BSD - freebsd|netbsd|openbsd) + freebsd|macosx|netbsd|openbsd) : ;; *) From 92610fe76c6875ee4aa6b31bf5b2be23e5149305 Mon Sep 17 00:00:00 2001 From: Takashi Yoshi Date: Fri, 14 Dec 2018 13:45:03 +0100 Subject: [PATCH 0209/1217] [type/__sysctl] Add support for Alpine Linux, Gentoo and OpenWrt --- cdist/conf/type/__sysctl/gencode-remote | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cdist/conf/type/__sysctl/gencode-remote b/cdist/conf/type/__sysctl/gencode-remote index e17e0659..d1da6058 100755 --- a/cdist/conf/type/__sysctl/gencode-remote +++ b/cdist/conf/type/__sysctl/gencode-remote @@ -29,7 +29,7 @@ fi os=$(cat "$__global/explorer/os") case "$os" in - redhat|centos|ubuntu|debian|devuan|archlinux|coreos|netbsd) + redhat|centos|ubuntu|debian|devuan|alpine|archlinux|gentoo|openwrt|coreos|netbsd) flag='-w' ;; macosx) From 9acb9d1f3aa7ffa9c10f4be1d8eb8c3ed6b3e251 Mon Sep 17 00:00:00 2001 From: Takashi Yoshi Date: Fri, 14 Dec 2018 14:12:33 +0100 Subject: [PATCH 0210/1217] [type/__sysctl] Group entries --- cdist/conf/type/__sysctl/gencode-remote | 32 +++++++++++++++---------- 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/cdist/conf/type/__sysctl/gencode-remote b/cdist/conf/type/__sysctl/gencode-remote index d1da6058..711d54e5 100755 --- a/cdist/conf/type/__sysctl/gencode-remote +++ b/cdist/conf/type/__sysctl/gencode-remote @@ -29,18 +29,26 @@ fi os=$(cat "$__global/explorer/os") case "$os" in - redhat|centos|ubuntu|debian|devuan|alpine|archlinux|gentoo|openwrt|coreos|netbsd) - flag='-w' - ;; - macosx) - # NOTE: Older versions of Mac OS X require the -w option. - # Even though the flag is not mentioned in new man pages anymore, - # it still works. - flag='-w' - ;; - freebsd|openbsd) - flag='' - ;; + # Linux + redhat|centos|ubuntu|debian|devuan|archlinux|gentoo|coreos) + flag='-w' + ;; + # BusyBox + alpine|openwrt) + flag='-w' + ;; + macosx) + # NOTE: Older versions of Mac OS X require the -w option. + # Even though the flag is not mentioned in new man pages anymore, + # it still works. + flag='-w' + ;; + netbsd) + flag='-w' + ;; + freebsd|openbsd) + flag='' + ;; esac # set the current runtime value From e3b0cbe8ac4b75e5268d9c6ff1538ca4e809d8fd Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Fri, 14 Dec 2018 15:20:17 +0100 Subject: [PATCH 0211/1217] ++changelog --- docs/changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog b/docs/changelog index a662eb38..e1e3fdb6 100644 --- a/docs/changelog +++ b/docs/changelog @@ -8,6 +8,7 @@ next: * Type __consul_agent: Add Debian 9 support (Jin-Guk Kwon) * Documentation: Fix broken links (Rage ) * Type __docker: Add version parameter (Jonas Weber) + * Type __sysctl: Refactor for better OS support (Takashi Yoshi) 4.10.4: 2018-11-03 * Core: Transfer all files of a directory at once instead of calling copy once per file (myeisha) From c492c53a9867e1218c5a5aba6ac987257e128495 Mon Sep 17 00:00:00 2001 From: Takashi Yoshi Date: Fri, 7 Dec 2018 16:56:36 +0100 Subject: [PATCH 0212/1217] [type/__package_pkg_openbsd] Send error messages to stderr --- cdist/conf/type/__package_pkg_openbsd/gencode-remote | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cdist/conf/type/__package_pkg_openbsd/gencode-remote b/cdist/conf/type/__package_pkg_openbsd/gencode-remote index 61383edb..a189eeac 100755 --- a/cdist/conf/type/__package_pkg_openbsd/gencode-remote +++ b/cdist/conf/type/__package_pkg_openbsd/gencode-remote @@ -96,7 +96,7 @@ if [ \$? -ne 0 ]; then if [ -z "\${status}" ]; then status="Failed to add package, uncaught exception." fi - echo "Error: \$status" + echo "Error: \$status" >&2 exit 1 fi eof @@ -114,7 +114,7 @@ if [ \$? -eq 0 ]; then if [ -z "\${status}" ]; then status="Failed to remove package, uncaught exception." fi - echo "Error: \$status" + echo "Error: \$status" >&2 exit 1 fi eof From 827081f8a280742ff7309515f476002717c18c1b Mon Sep 17 00:00:00 2001 From: Takashi Yoshi Date: Fri, 7 Dec 2018 17:32:43 +0100 Subject: [PATCH 0213/1217] [type/__package_pkg_openbsd/explorer/pkg_version] Fix version extraction The earlier code stripped away all non-numeric parts of the version number. E.g. "5.6.38p0" would be trimmed to "5.6.38" --- .../type/__package_pkg_openbsd/explorer/pkg_version | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/cdist/conf/type/__package_pkg_openbsd/explorer/pkg_version b/cdist/conf/type/__package_pkg_openbsd/explorer/pkg_version index 212f0d96..71fccb42 100755 --- a/cdist/conf/type/__package_pkg_openbsd/explorer/pkg_version +++ b/cdist/conf/type/__package_pkg_openbsd/explorer/pkg_version @@ -19,7 +19,7 @@ # along with cdist. If not, see . # # -# Retrieve the status of a package - parsed dpkg output +# Retrieve the status of a package - parsed pkg_info output # if [ -f "$__object/parameter/name" ]; then @@ -28,5 +28,10 @@ else name="$__object_id" fi -#TODO: Is there a better way? -pkg_info | grep "^$name-[0-9]" | sed 's|.*\(-[0-9][0-9.]*\).*|\1|' | sed 's/-//' +# Extract version number from pkg_info. +# Refer to packages-specs(7) for more information regarding the format. + +# ATTENTION: If $name is just a stem (e.g. "php" or "python"), there may be +# multiple results. pkg_info prints a line for each version. + +pkg_info -q -I "inst:$name" | sed -e 's/^\([^-]*-\)*\([0-9][^-]*\).*$/\2/' From 498628d16a769132fe68c95f259c3bb557aab7e9 Mon Sep 17 00:00:00 2001 From: Takashi Yoshi Date: Fri, 7 Dec 2018 19:02:43 +0100 Subject: [PATCH 0214/1217] [type/__package_pkg_openbsd] Misc. fixes and improvements --- .../__package_pkg_openbsd/explorer/pkg_state | 49 +++++++++++++++++++ .../explorer/pkg_version | 3 +- .../type/__package_pkg_openbsd/gencode-remote | 12 ++--- 3 files changed, 55 insertions(+), 9 deletions(-) create mode 100755 cdist/conf/type/__package_pkg_openbsd/explorer/pkg_state diff --git a/cdist/conf/type/__package_pkg_openbsd/explorer/pkg_state b/cdist/conf/type/__package_pkg_openbsd/explorer/pkg_state new file mode 100755 index 00000000..9cd17787 --- /dev/null +++ b/cdist/conf/type/__package_pkg_openbsd/explorer/pkg_state @@ -0,0 +1,49 @@ +#!/bin/sh +# +# Copyright 2018, Takashi Yoshi +# +# This file is part of cdist. +# +# cdist is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# cdist is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with cdist. If not, see . +# +# +# Retrieve the status of a package - parsed pkg_info output +# + +if [ -f "${__object}/parameter/name" ] +then + pkgid="$(cat "${__object}/parameter/name")" +else + pkgid="${__object_id}" +fi + +if [ -f "${__object}/parameter/version" ] +then + pkgid="${pkgid}-$(cat "${__object}/parameter/version")" +fi + +if [ -f "${__object}/parameter/flavor" ] +then + # If a flavor but no version is given we need to add another -, + # otherwise pkg_info confuses the flavor with the version. + [ -f "${__object}/parameter/version" ] || pkgid="${pkgid}-" + + pkgid="${pkgid}-$(cat "${__object}/parameter/flavor")" +fi + + +pkg_info -q -I "inst:${pkgid}" >/dev/null 2>&1 \ + && echo 'present' || echo 'absent' + +exit 0 diff --git a/cdist/conf/type/__package_pkg_openbsd/explorer/pkg_version b/cdist/conf/type/__package_pkg_openbsd/explorer/pkg_version index 71fccb42..9b51a588 100755 --- a/cdist/conf/type/__package_pkg_openbsd/explorer/pkg_version +++ b/cdist/conf/type/__package_pkg_openbsd/explorer/pkg_version @@ -2,6 +2,7 @@ # # 2011 Andi Brönnimann (andi-cdist at v-net.ch) # Copyright 2017, Philippe Gregoire +# Copyright 2018, Takashi Yoshi # # This file is part of cdist. # @@ -19,7 +20,7 @@ # along with cdist. If not, see . # # -# Retrieve the status of a package - parsed pkg_info output +# Retrieve the version of a package - parsed pkg_info output # if [ -f "$__object/parameter/name" ]; then diff --git a/cdist/conf/type/__package_pkg_openbsd/gencode-remote b/cdist/conf/type/__package_pkg_openbsd/gencode-remote index a189eeac..0a79fca3 100755 --- a/cdist/conf/type/__package_pkg_openbsd/gencode-remote +++ b/cdist/conf/type/__package_pkg_openbsd/gencode-remote @@ -2,6 +2,7 @@ # # 2011 Andi Brönnimann (andi-cdist at v-net.ch) # 2012 Nico Schottelius (nico-cdist at schottelius.org) +# 2018 Takashi Yoshi # # This file is part of cdist. # @@ -72,12 +73,7 @@ else fi fi -if [ "$pkg_version" ]; then - state_is="present" -else - state_is="absent" -fi - +state_is="$(cat "$__object/explorer/pkg_state")" [ "$state_is" = "$state_should" ] && exit 0 case "$state_should" in @@ -88,7 +84,7 @@ if [ X != X"${pkg_path}" ]; then PKG_PATH="${pkg_path}"; export PKG_PATH fi status=\$(pkg_add "$pkgopts" "$pkgid" 2>&1) -pkg_info | grep "^${name}.*${version}.*${flavor}" > /dev/null 2>&1 +pkg_info -q -I "inst:$pkgid" | grep -q "^${name}-${version}.*${flavor}$" 2>/dev/null # We didn't find the package in the list of 'installed packages', so it failed # This is necessary because pkg_add doesn't return properly @@ -106,7 +102,7 @@ eof # use this because pkg_add doesn't properly handle errors cat << eof status=\$(pkg_delete "$pkgopts" "$pkgid") -pkg_info | grep "^${name}.*${version}.*${flavor}" > /dev/null 2>&1 +pkg_info -q -I "inst:$pkgid" | grep -q "^${name}-${version}.*${flavor}" 2>/dev/null # We found the package in the list of 'installed packages' # This would indicate that pkg_delete failed, send the output of pkg_delete From aa456ab6c18754fda8b1cb6c07efb9511acbe236 Mon Sep 17 00:00:00 2001 From: Takashi Yoshi Date: Fri, 14 Dec 2018 12:35:04 +0100 Subject: [PATCH 0215/1217] [type/__package_pkg_openbsd] Clean up code --- .../type/__package_pkg_openbsd/gencode-remote | 150 +++++++++--------- 1 file changed, 74 insertions(+), 76 deletions(-) diff --git a/cdist/conf/type/__package_pkg_openbsd/gencode-remote b/cdist/conf/type/__package_pkg_openbsd/gencode-remote index 0a79fca3..97f9ca46 100755 --- a/cdist/conf/type/__package_pkg_openbsd/gencode-remote +++ b/cdist/conf/type/__package_pkg_openbsd/gencode-remote @@ -23,100 +23,98 @@ # Manage packages with pkg on OpenBSD # -# Debug -# exec >&2 -# set -x +os_version=$(cat "${__global}/explorer/os_version") +machine=$(cat "${__global}/explorer/machine") -os_version="$(cat "$__global/explorer/os_version")" -machine="$(cat "$__global/explorer/machine")" - -if [ -f "$__object/parameter/version" ]; then - version="$(cat "$__object/parameter/version")" +if [ -f "${__object}/parameter/version" ]; then + version=$(cat "${__object}/parameter/version") fi -if [ -f "$__object/parameter/flavor" ]; then - flavor="$(cat "$__object/parameter/flavor")" +if [ -f "${__object}/parameter/flavor" ]; then + flavor=$(cat "${__object}/parameter/flavor") fi -# do not show progress bar -pkgopts="-x" +# Do not show progress bar +pkgopts='-x' -if [ -f "$__object/parameter/name" ]; then - name=$(cat "$__object/parameter/name") +name="${__object_id}" +if [ -f "${__object}/parameter/name" ]; then + name=$(cat "${__object}/parameter/name") +fi + +if [ -n "${version}" ] && [ -n "${flavor}" ]; then + pkgid="${name}-${version}-${flavor}" +elif [ -n "${version}" ]; then + pkgid="${name}-${version}" +elif [ -f "${__object}/parameter/flavor" ]; then + pkgid="${name}--${flavor}" else - name="$__object_id" + pkgid="${name}" fi -if [ -n "$version" ] && [ -n "$flavor" ]; then - pkgid="$name-$version-$flavor" -elif [ -n "$version" ]; then - pkgid="$name-$version" -elif [ -n "$flavor" ]; then - pkgid="$name--$flavor" -elif [ -f "$__object/parameter/flavor" ]; then - pkgid="$name--" +state_should=$(cat "${__object}/parameter/state") + +pkg_version=$(cat "${__object}/explorer/pkg_version") + +if [ -f "${__object}/parameter/pkg_path" ]; then + pkg_path=$(cat "${__object}/parameter/pkg_path") else - pkgid="$name" + has_installurl=$(cat "${__object}/explorer/has_installurl") + if [ 'yes' != "${has_installurl}" ]; then + # There is no default PKG_PATH, try to provide one + pkg_path="ftp://ftp.openbsd.org/pub/OpenBSD/${os_version}/packages/${machine}/" + fi fi -state_should="$(cat "$__object/parameter/state")" +state_is=$(cat "${__object}/explorer/pkg_state") +[ "${state_is}" = "${state_should}" ] && exit 0 -pkg_version="$(cat "$__object/explorer/pkg_version")" +case "${state_should}" in + present) + if [ -n "${pkg_path}" ]; then + echo "export PKG_PATH='${pkg_path}'" + fi -if [ -f "$__object/parameter/pkg_path" ]; then - pkg_path="$(cat "$__object/parameter/pkg_path")" -else - has_installurl=$(cat "${__object}/explorer/has_installurl") - if [ Xyes != X"${has_installurl}" ]; then - # there is no default PKG_PATH, try to provide one - pkg_path="ftp://ftp.openbsd.org/pub/OpenBSD/$os_version/packages/$machine/" - fi -fi + # Use this because pkg_add doesn't properly handle errors + cat << EOF +status=\$(pkg_add ${pkgopts} '${pkgid}' 2>&1 || true) -state_is="$(cat "$__object/explorer/pkg_state")" -[ "$state_is" = "$state_should" ] && exit 0 +if ! pkg_info -q -I 'inst:${pkgid}' | grep -q '^${name}-${version}.*${flavor}$' 2>/dev/null +then + # We didn't find the package in the list of 'installed packages', so it failed. + # This is necessary because pkg_add doesn't return properly -case "$state_should" in - present) - # use this because pkg_add doesn't properly handle errors - cat << eof -if [ X != X"${pkg_path}" ]; then - PKG_PATH="${pkg_path}"; export PKG_PATH + if [ -z "\${status}" ]; then + status='Failed to add package, uncaught exception.' + fi + echo "Error: \${status}" >&2 + exit 1 fi -status=\$(pkg_add "$pkgopts" "$pkgid" 2>&1) -pkg_info -q -I "inst:$pkgid" | grep -q "^${name}-${version}.*${flavor}$" 2>/dev/null +EOF + echo 'installed' >> "${__messages_out}" + ;; -# We didn't find the package in the list of 'installed packages', so it failed -# This is necessary because pkg_add doesn't return properly -if [ \$? -ne 0 ]; then - if [ -z "\${status}" ]; then - status="Failed to add package, uncaught exception." - fi - echo "Error: \$status" >&2 - exit 1 + absent) + # Use this because pkg_delete doesn't properly handle errors + cat << EOF +status=\$(pkg_delete ${pkgopts} '${pkgid}' || true) + +if pkg_info -q -I 'inst:${pkgid}' | grep -q '^${name}-${version}.*${flavor}' 2>/dev/null +then + # We found the package in the list of 'installed packages'. + # This would indicate that pkg_delete failed, send the output of pkg_delete + + if [ -z "\${status}" ]; then + status='Failed to remove package, uncaught exception.' + fi + echo "Error: \${status}" >&2 + exit 1 fi -eof - ;; - - absent) - # use this because pkg_add doesn't properly handle errors - cat << eof -status=\$(pkg_delete "$pkgopts" "$pkgid") -pkg_info -q -I "inst:$pkgid" | grep -q "^${name}-${version}.*${flavor}" 2>/dev/null - -# We found the package in the list of 'installed packages' -# This would indicate that pkg_delete failed, send the output of pkg_delete -if [ \$? -eq 0 ]; then - if [ -z "\${status}" ]; then - status="Failed to remove package, uncaught exception." - fi - echo "Error: \$status" >&2 - exit 1 -fi -eof - ;; - *) - echo "Unknown state: $state_should" >&2 +EOF + echo 'removed' >> "${__messages_out}" + ;; + *) + echo "Unknown state: ${state_should}" >&2 exit 1 - ;; + ;; esac From a7f1eda3280d4919c8da977674d4881ddf883929 Mon Sep 17 00:00:00 2001 From: Takashi Yoshi Date: Fri, 7 Dec 2018 16:56:36 +0100 Subject: [PATCH 0216/1217] [type/__package_emerge] Send error messages to stderr --- cdist/conf/type/__package_emerge/gencode-remote | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cdist/conf/type/__package_emerge/gencode-remote b/cdist/conf/type/__package_emerge/gencode-remote index c25f2be7..b144ede4 100755 --- a/cdist/conf/type/__package_emerge/gencode-remote +++ b/cdist/conf/type/__package_emerge/gencode-remote @@ -39,12 +39,12 @@ pkg_version="$(cat "$__object/explorer/pkg_version")" if [ -z "$pkg_version" ]; then state_is="absent" elif [ -z "$version" ] && [ "$(echo "$pkg_version" | wc -l)" -gt 1 ]; then - echo "Package name is not unique! The following packages are installed:" - echo "$pkg_version" + echo "Package name is not unique! The following packages are installed:" >&2 + echo "$pkg_version" >&2 exit 1 elif [ -n "$version" ] && [ "$(echo "$pkg_version" | cut -d " " -f 1 | sort | uniq | wc -l)" -gt 1 ]; then - echo "Package name is not unique! The following packages are installed:" - echo "$pkg_version" + echo "Package name is not unique! The following packages are installed:" >&2 + echo "$pkg_version" >&2 exit 1 else state_is="present" From 93b0727c3b1eb326edfa7db71926a16f482dabee Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Fri, 14 Dec 2018 16:19:30 +0100 Subject: [PATCH 0217/1217] ++changelog --- docs/changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog b/docs/changelog index e1e3fdb6..1c5e6a05 100644 --- a/docs/changelog +++ b/docs/changelog @@ -9,6 +9,7 @@ next: * Documentation: Fix broken links (Rage ) * Type __docker: Add version parameter (Jonas Weber) * Type __sysctl: Refactor for better OS support (Takashi Yoshi) + * Types __package_*: Add messaging upon installation/removal (Takashi Yoshi) 4.10.4: 2018-11-03 * Core: Transfer all files of a directory at once instead of calling copy once per file (myeisha) From ede076e7c5bba2d5bac06f9fae8dfd54499acf90 Mon Sep 17 00:00:00 2001 From: Takashi Yoshi Date: Fri, 14 Dec 2018 21:20:24 +0100 Subject: [PATCH 0218/1217] [type/__package_pkg_openbsd] Send messages local instead of remote --- cdist/conf/type/__package_pkg_openbsd/gencode-remote | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cdist/conf/type/__package_pkg_openbsd/gencode-remote b/cdist/conf/type/__package_pkg_openbsd/gencode-remote index da63626b..4187a84c 100755 --- a/cdist/conf/type/__package_pkg_openbsd/gencode-remote +++ b/cdist/conf/type/__package_pkg_openbsd/gencode-remote @@ -99,8 +99,8 @@ if [ \$? -ne 0 ]; then echo "Error: \$status" exit 1 fi -echo "installed" >> "$__messages_out" eof +echo "installed" >> "$__messages_out" ;; absent) @@ -118,8 +118,8 @@ if [ \$? -eq 0 ]; then echo "Error: \$status" exit 1 fi -echo "removed" >> "$__messages_out" eof +echo "removed" >> "$__messages_out" ;; *) echo "Unknown state: $state_should" >&2 From 794f20007f1f5bd4c15bab9ae0f0e3329dbaf696 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Wed, 19 Dec 2018 17:14:37 +0100 Subject: [PATCH 0219/1217] ++changelog --- docs/changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog b/docs/changelog index 1c5e6a05..564d187c 100644 --- a/docs/changelog +++ b/docs/changelog @@ -10,6 +10,7 @@ next: * Type __docker: Add version parameter (Jonas Weber) * Type __sysctl: Refactor for better OS support (Takashi Yoshi) * Types __package_*: Add messaging upon installation/removal (Takashi Yoshi) + * Type __package_pkg_openbsd: Reworked (Takashi Yoshi) 4.10.4: 2018-11-03 * Core: Transfer all files of a directory at once instead of calling copy once per file (myeisha) From 0cb3cbae1b1a3dbf05410bc598922c092da89220 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Fri, 21 Dec 2018 22:23:41 +0100 Subject: [PATCH 0220/1217] Remove unused explorer --- .../explorer/pkg_version | 38 ------------------- .../type/__package_pkg_openbsd/gencode-remote | 2 - 2 files changed, 40 deletions(-) delete mode 100755 cdist/conf/type/__package_pkg_openbsd/explorer/pkg_version diff --git a/cdist/conf/type/__package_pkg_openbsd/explorer/pkg_version b/cdist/conf/type/__package_pkg_openbsd/explorer/pkg_version deleted file mode 100755 index 9b51a588..00000000 --- a/cdist/conf/type/__package_pkg_openbsd/explorer/pkg_version +++ /dev/null @@ -1,38 +0,0 @@ -#!/bin/sh -# -# 2011 Andi Brönnimann (andi-cdist at v-net.ch) -# Copyright 2017, Philippe Gregoire -# Copyright 2018, Takashi Yoshi -# -# This file is part of cdist. -# -# cdist is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# cdist is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with cdist. If not, see . -# -# -# Retrieve the version of a package - parsed pkg_info output -# - -if [ -f "$__object/parameter/name" ]; then - name="$(cat "$__object/parameter/name")" -else - name="$__object_id" -fi - -# Extract version number from pkg_info. -# Refer to packages-specs(7) for more information regarding the format. - -# ATTENTION: If $name is just a stem (e.g. "php" or "python"), there may be -# multiple results. pkg_info prints a line for each version. - -pkg_info -q -I "inst:$name" | sed -e 's/^\([^-]*-\)*\([0-9][^-]*\).*$/\2/' diff --git a/cdist/conf/type/__package_pkg_openbsd/gencode-remote b/cdist/conf/type/__package_pkg_openbsd/gencode-remote index 9b9d8fc3..5a21ce12 100755 --- a/cdist/conf/type/__package_pkg_openbsd/gencode-remote +++ b/cdist/conf/type/__package_pkg_openbsd/gencode-remote @@ -54,8 +54,6 @@ fi state_should=$(cat "${__object}/parameter/state") -pkg_version=$(cat "${__object}/explorer/pkg_version") - if [ -f "${__object}/parameter/pkg_path" ]; then pkg_path=$(cat "${__object}/parameter/pkg_path") else From 5d3598b96ea6498d9b5c21e32420aa901f234e7d Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Fri, 21 Dec 2018 22:24:02 +0100 Subject: [PATCH 0221/1217] Release 4.10.5 --- docs/changelog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/changelog b/docs/changelog index 564d187c..5dbf9bb5 100644 --- a/docs/changelog +++ b/docs/changelog @@ -1,7 +1,7 @@ Changelog --------- -next: +4.10.5: 2018-12-21 * Type __group: Fix/remove '--' from echo command (Dimitrios Apostolou) * New type: __ping (Olliver Schinagl) * Type __postgres_role: Fix broken syntax (Nico Schottelius, Darko Poljak) From 0bdd590344ba424602cded5ddbfb34747d83718d Mon Sep 17 00:00:00 2001 From: Daniel Heule Date: Tue, 22 Jan 2019 13:30:06 +0100 Subject: [PATCH 0222/1217] readd the use of echo in my explorers this is nessessary for remove blanks in output (strip) catch exit codes of zypper (for example if no repo is defined at all) --- cdist/conf/type/__zypper_repo/explorer/all_repo_ids | 2 +- cdist/conf/type/__zypper_repo/explorer/enabled_repo_ids | 2 +- cdist/conf/type/__zypper_repo/explorer/repo_id | 2 +- cdist/conf/type/__zypper_service/explorer/repo_ids | 2 +- cdist/conf/type/__zypper_service/explorer/service_id | 2 +- cdist/conf/type/__zypper_service/explorer/service_ids | 2 +- cdist/conf/type/__zypper_service/explorer/service_uri | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/cdist/conf/type/__zypper_repo/explorer/all_repo_ids b/cdist/conf/type/__zypper_repo/explorer/all_repo_ids index dde6d554..b37d8ac5 100644 --- a/cdist/conf/type/__zypper_repo/explorer/all_repo_ids +++ b/cdist/conf/type/__zypper_repo/explorer/all_repo_ids @@ -21,4 +21,4 @@ # Retrieve all repo id nummbers - parsed zypper output # # -zypper lr | cut -d'|' -f 1 | grep -E '^[0-9]' +echo $(zypper lr | cut -d'|' -f 1 | grep -E '^[0-9]') diff --git a/cdist/conf/type/__zypper_repo/explorer/enabled_repo_ids b/cdist/conf/type/__zypper_repo/explorer/enabled_repo_ids index b011c258..2dfb946f 100644 --- a/cdist/conf/type/__zypper_repo/explorer/enabled_repo_ids +++ b/cdist/conf/type/__zypper_repo/explorer/enabled_repo_ids @@ -23,4 +23,4 @@ # # simpler command which works only on SLES11 SP3 or newer: # echo $(zypper lr -E | cut -d'|' -f 1 | grep -E '^[0-9]') -zypper lr | grep -E '^[0-9]([^|]+\|){3,3} Yes' | cut -d'|' -f 1 +echo $(zypper lr | grep -E '^[0-9]([^|]+\|){3,3} Yes' | cut -d'|' -f 1) diff --git a/cdist/conf/type/__zypper_repo/explorer/repo_id b/cdist/conf/type/__zypper_repo/explorer/repo_id index 114c6fe7..93832ceb 100644 --- a/cdist/conf/type/__zypper_repo/explorer/repo_id +++ b/cdist/conf/type/__zypper_repo/explorer/repo_id @@ -26,4 +26,4 @@ if [ -f "$__object/parameter/uri" ]; then else uri="$__object_id" fi -zypper lr -u | grep -F "$uri" | cut -d'|' -f 1 | grep -E '^[0-9]' +echo $(zypper lr -u | grep -F "$uri" | cut -d'|' -f 1 | grep -E '^[0-9]') diff --git a/cdist/conf/type/__zypper_service/explorer/repo_ids b/cdist/conf/type/__zypper_service/explorer/repo_ids index 787e9869..e831b76c 100644 --- a/cdist/conf/type/__zypper_service/explorer/repo_ids +++ b/cdist/conf/type/__zypper_service/explorer/repo_ids @@ -24,4 +24,4 @@ # simpler command which works only on SLES11 SP3 or newer: # echo $(zypper lr -u -E | cut -d'|' -f 1 | grep -E '^[0-9]') # on older systems, zypper doesn't know the parameter -E -zypper lr -u | grep -E '^([^|]+\|){3,3} Yes' | cut -d'|' -f 1 | grep -E '^[0-9]' +echo $(zypper lr -u | grep -E '^([^|]+\|){3,3} Yes' | cut -d'|' -f 1 | grep -E '^[0-9]') diff --git a/cdist/conf/type/__zypper_service/explorer/service_id b/cdist/conf/type/__zypper_service/explorer/service_id index 7161f804..4da8ac01 100644 --- a/cdist/conf/type/__zypper_service/explorer/service_id +++ b/cdist/conf/type/__zypper_service/explorer/service_id @@ -27,4 +27,4 @@ else fi # simpler command which works only on SLES11 SP3 or newer: # echo $(zypper ls -u -E | grep -E "\<$uri\>" | cut -d'|' -f 1 ) -zypper ls -u | grep -E '^([^|]+\|){3,3} Yes' | grep -E "\\<$uri\\>" | cut -d'|' -f 1 +echo $(zypper ls -u | grep -E '^([^|]+\|){3,3} Yes' | grep -E "\\<$uri\\>" | cut -d'|' -f 1) diff --git a/cdist/conf/type/__zypper_service/explorer/service_ids b/cdist/conf/type/__zypper_service/explorer/service_ids index 6491ab90..0f1f4186 100644 --- a/cdist/conf/type/__zypper_service/explorer/service_ids +++ b/cdist/conf/type/__zypper_service/explorer/service_ids @@ -22,4 +22,4 @@ # # simpler command which works only on SLES11 SP3 or newer: # echo $(zypper ls -u -E | cut -d'|' -f 1 | grep -E '^[0-9]') -zypper ls -u | grep -E '^([^|]+\|){3,3} Yes' | cut -d'|' -f 1 | grep -E '^[0-9]' +echo $(zypper ls -u | grep -E '^([^|]+\|){3,3} Yes' | cut -d'|' -f 1 | grep -E '^[0-9]') diff --git a/cdist/conf/type/__zypper_service/explorer/service_uri b/cdist/conf/type/__zypper_service/explorer/service_uri index 2476ab71..06014df8 100644 --- a/cdist/conf/type/__zypper_service/explorer/service_uri +++ b/cdist/conf/type/__zypper_service/explorer/service_uri @@ -25,4 +25,4 @@ if [ -f "$__object/parameter/uri" ]; then else uri="/$__object_id" fi -zypper ls -u | awk 'BEGIN { FS = "[ ]+\\|[ ]+" } ; $4 == "Yes" && $NF == "'"$uri"'" {print $NF}' +echo $(zypper ls -u | awk 'BEGIN { FS = "[ ]+\\|[ ]+" } ; $4 == "Yes" && $NF == "'"$uri"'" {print $NF}') From 67c3c8ca12987a0a69c94775283b66680d0b26e7 Mon Sep 17 00:00:00 2001 From: Dominique Roux Date: Mon, 28 Jan 2019 09:32:02 +0100 Subject: [PATCH 0223/1217] Added a startup flag for prometheus alertmanager aded the flag --cluster.advertise-address since it is needed for startup on a machine which does not provide a private v4 --- cdist/conf/type/__prometheus_alertmanager/manifest | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cdist/conf/type/__prometheus_alertmanager/manifest b/cdist/conf/type/__prometheus_alertmanager/manifest index 64ef76af..8ee818c3 100755 --- a/cdist/conf/type/__prometheus_alertmanager/manifest +++ b/cdist/conf/type/__prometheus_alertmanager/manifest @@ -49,7 +49,7 @@ __key_value alertmanager_fix_init_script --file /etc/init.d/prometheus-alertmana ##### CONFIGURE ############################################################# -FLAGS="--storage.path $storage_path --data.retention $((retention_days*24))h --web.listen-address [::]:9093" +FLAGS="--storage.path $storage_path --data.retention $((retention_days*24))h --web.listen-address [::]:9093 --cluster.advertise-address [::]:9093" require="$require $require_pkg" \ __key_value alertmanager_args --file /etc/default/prometheus-alertmanager \ From a77983aeadc1f5840f9be805b89373bb6d9cfb3e Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Mon, 28 Jan 2019 19:09:36 +0100 Subject: [PATCH 0224/1217] Reorganize parsers right --- cdist/argparse.py | 42 ++++++++++++++++++++--------------------- docs/src/man1/cdist.rst | 32 +++++++++++++++---------------- 2 files changed, 37 insertions(+), 37 deletions(-) diff --git a/cdist/argparse.py b/cdist/argparse.py index 0ee9d7b1..72fc0d0f 100644 --- a/cdist/argparse.py +++ b/cdist/argparse.py @@ -161,6 +161,16 @@ def get_parsers(): # Config parser['config_main'] = argparse.ArgumentParser(add_help=False) + parser['config_main'].add_argument( + '-4', '--force-ipv4', + help=('Force to use IPv4 addresses only. No influence for custom' + ' remote commands.'), + action='store_const', dest='force_ipv', const=4) + parser['config_main'].add_argument( + '-6', '--force-ipv6', + help=('Force to use IPv6 addresses only. No influence for custom' + ' remote commands.'), + action='store_const', dest='force_ipv', const=6) parser['config_main'].add_argument( '-C', '--cache-path-pattern', help=('Specify custom cache path pattern. If ' @@ -191,6 +201,11 @@ def get_parsers(): parser['config_main'].add_argument( '-o', '--out-dir', help='Directory to save cdist output in.', dest="out_path") + parser['config_main'].add_argument( + '-P', '--timestamp', + help=('Timestamp log messages with the current local date and time ' + 'in the format: YYYYMMDDHHMMSS.us.'), + action='store_true', dest='timestamp') parser['config_main'].add_argument( '-R', '--use-archiving', nargs='?', choices=('tar', 'tgz', 'tbz2', 'txz',), @@ -220,19 +235,13 @@ def get_parsers(): '(should behave like ssh).'), action='store', dest='remote_exec', default=None) + parser['config_main'].add_argument( + '-S', '--disable-saving-output-streams', + help='Disable saving output streams.', + action='store_false', dest='save_output_streams', default=True) # Config parser['config_args'] = argparse.ArgumentParser(add_help=False) - parser['config_args'].add_argument( - '-4', '--force-ipv4', - help=('Force to use IPv4 addresses only. No influence for custom' - ' remote commands.'), - action='store_const', dest='force_ipv', const=4) - parser['config_args'].add_argument( - '-6', '--force-ipv6', - help=('Force to use IPv6 addresses only. No influence for custom' - ' remote commands.'), - action='store_const', dest='force_ipv', const=6) parser['config_args'].add_argument( '-A', '--all-tagged', help=('Use all hosts present in tags db. Currently in beta.'), @@ -242,8 +251,6 @@ def get_parsers(): help=('List hosts that have all specified tags, ' 'if -t/--tag is specified.'), action="store_true", dest="has_all_tags", default=False) - parser['config_args'].add_argument( - 'host', nargs='*', help='Host(s) to operate on.') parser['config_args'].add_argument( '-f', '--file', help=('Read specified file for a list of additional hosts to ' @@ -251,11 +258,6 @@ def get_parsers(): 'line). If no host or host file is specified then, by ' 'default, read hosts from stdin.'), dest='hostfile', required=False) - parser['config_args'].add_argument( - '-P', '--timestamp', - help=('Timestamp log messages with the current local date and time ' - 'in the format: YYYYMMDDHHMMSS.us.'), - action='store_true', dest='timestamp') parser['config_args'].add_argument( '-p', '--parallel', nargs='?', metavar='HOST_MAX', type=functools.partial(check_lower_bounded_int, lower_bound=1, @@ -265,10 +267,6 @@ def get_parsers(): 'default.'), action='store', dest='parallel', const=multiprocessing.cpu_count()) - parser['config_args'].add_argument( - '-S', '--disable-saving-output-streams', - help='Disable saving output streams.', - action='store_false', dest='save_output_streams', default=True) parser['config_args'].add_argument( '-s', '--sequential', help='Operate on multiple hosts sequentially (default).', @@ -279,6 +277,8 @@ def get_parsers(): 'list all hosts that contain any of specified tags. ' 'Currently in beta.'), dest='tag', required=False, action="store_true", default=False) + parser['config_args'].add_argument( + 'host', nargs='*', help='Host(s) to operate on.') parser['config'] = parser['sub'].add_parser( 'config', parents=[parser['loglevel'], parser['beta'], parser['common'], diff --git a/docs/src/man1/cdist.rst b/docs/src/man1/cdist.rst index 3a74f1ef..2eb0ce00 100644 --- a/docs/src/man1/cdist.rst +++ b/docs/src/man1/cdist.rst @@ -15,23 +15,23 @@ SYNOPSIS cdist banner [-h] [-l LOGLEVEL] [-q] [-v] - cdist config [-h] [-l LOGLEVEL] [-q] [-v] [-b] [-g CONFIG_FILE] - [-C CACHE_PATH_PATTERN] [-c CONF_DIR] [-i MANIFEST] - [-j [JOBS]] [-n] [-o OUT_PATH] [-R [{tar,tgz,tbz2,txz}]] - [-r REMOTE_OUT_DIR] [--remote-copy REMOTE_COPY] - [--remote-exec REMOTE_EXEC] [-I INVENTORY_DIR] [-4] [-6] - [-A] [-a] [-f HOSTFILE] [-P] [-p [HOST_MAX]] [-S] [-s] - [-t] - [host [host ...]] + cdist config [-h] [-l LOGLEVEL] [-q] [-v] [-b] [-g CONFIG_FILE] [-4] + [-6] [-C CACHE_PATH_PATTERN] [-c CONF_DIR] [-i MANIFEST] + [-j [JOBS]] [-n] [-o OUT_PATH] [-P] + [-R [{tar,tgz,tbz2,txz}]] [-r REMOTE_OUT_PATH] + [--remote-copy REMOTE_COPY] [--remote-exec REMOTE_EXEC] + [-S] [-I INVENTORY_DIR] [-A] [-a] [-f HOSTFILE] + [-p [HOST_MAX]] [-s] [-t] + [host [host ...]] - cdist install [-h] [-l LOGLEVEL] [-q] [-v] [-b] [-g CONFIG_FILE] - [-C CACHE_PATH_PATTERN] [-c CONF_DIR] [-i MANIFEST] - [-j [JOBS]] [-n] [-o OUT_PATH] [-R [{tar,tgz,tbz2,txz}]] - [-r REMOTE_OUT_DIR] [--remote-copy REMOTE_COPY] - [--remote-exec REMOTE_EXEC] [-I INVENTORY_DIR] [-4] [-6] - [-A] [-a] [-f HOSTFILE] [-P] [-p [HOST_MAX]] [-S] [-s] - [-t] - [host [host ...]] + cdist install [-h] [-l LOGLEVEL] [-q] [-v] [-b] [-g CONFIG_FILE] [-4] + [-6] [-C CACHE_PATH_PATTERN] [-c CONF_DIR] [-i MANIFEST] + [-j [JOBS]] [-n] [-o OUT_PATH] [-P] + [-R [{tar,tgz,tbz2,txz}]] [-r REMOTE_OUT_PATH] + [--remote-copy REMOTE_COPY] [--remote-exec REMOTE_EXEC] + [-S] [-I INVENTORY_DIR] [-A] [-a] [-f HOSTFILE] + [-p [HOST_MAX]] [-s] [-t] + [host [host ...]] cdist inventory [-h] {add-host,add-tag,del-host,del-tag,list} ... From 82cfea0f3c06f8dcd1707c051a7ecddf42ed2517 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Mon, 28 Jan 2019 19:14:28 +0100 Subject: [PATCH 0225/1217] ++changelog --- docs/changelog | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/changelog b/docs/changelog index 5dbf9bb5..2449c2ed 100644 --- a/docs/changelog +++ b/docs/changelog @@ -1,6 +1,9 @@ Changelog --------- +next: + * Type __prometheus_alertmanager: Add startup flag (Dominique Roux) + 4.10.5: 2018-12-21 * Type __group: Fix/remove '--' from echo command (Dimitrios Apostolou) * New type: __ping (Olliver Schinagl) From df693b9f471bab051720f557c14d2be617bde9fe Mon Sep 17 00:00:00 2001 From: Daniel Heule Date: Wed, 13 Feb 2019 11:30:55 +0100 Subject: [PATCH 0226/1217] added # shellcheck disable=SC2005 where we need the echo in __zypper explorers --- cdist/conf/type/__zypper_repo/explorer/all_repo_ids | 1 + cdist/conf/type/__zypper_repo/explorer/enabled_repo_ids | 2 ++ cdist/conf/type/__zypper_repo/explorer/repo_id | 1 + cdist/conf/type/__zypper_service/explorer/repo_ids | 2 ++ cdist/conf/type/__zypper_service/explorer/service_id | 2 ++ cdist/conf/type/__zypper_service/explorer/service_ids | 2 ++ cdist/conf/type/__zypper_service/explorer/service_uri | 1 + 7 files changed, 11 insertions(+) diff --git a/cdist/conf/type/__zypper_repo/explorer/all_repo_ids b/cdist/conf/type/__zypper_repo/explorer/all_repo_ids index b37d8ac5..a4fd0368 100644 --- a/cdist/conf/type/__zypper_repo/explorer/all_repo_ids +++ b/cdist/conf/type/__zypper_repo/explorer/all_repo_ids @@ -21,4 +21,5 @@ # Retrieve all repo id nummbers - parsed zypper output # # +# shellcheck disable=SC2005 echo $(zypper lr | cut -d'|' -f 1 | grep -E '^[0-9]') diff --git a/cdist/conf/type/__zypper_repo/explorer/enabled_repo_ids b/cdist/conf/type/__zypper_repo/explorer/enabled_repo_ids index 2dfb946f..b8e9ef3a 100644 --- a/cdist/conf/type/__zypper_repo/explorer/enabled_repo_ids +++ b/cdist/conf/type/__zypper_repo/explorer/enabled_repo_ids @@ -23,4 +23,6 @@ # # simpler command which works only on SLES11 SP3 or newer: # echo $(zypper lr -E | cut -d'|' -f 1 | grep -E '^[0-9]') +# +# shellcheck disable=SC2005 echo $(zypper lr | grep -E '^[0-9]([^|]+\|){3,3} Yes' | cut -d'|' -f 1) diff --git a/cdist/conf/type/__zypper_repo/explorer/repo_id b/cdist/conf/type/__zypper_repo/explorer/repo_id index 93832ceb..43b2f1c0 100644 --- a/cdist/conf/type/__zypper_repo/explorer/repo_id +++ b/cdist/conf/type/__zypper_repo/explorer/repo_id @@ -26,4 +26,5 @@ if [ -f "$__object/parameter/uri" ]; then else uri="$__object_id" fi +# shellcheck disable=SC2005 echo $(zypper lr -u | grep -F "$uri" | cut -d'|' -f 1 | grep -E '^[0-9]') diff --git a/cdist/conf/type/__zypper_service/explorer/repo_ids b/cdist/conf/type/__zypper_service/explorer/repo_ids index e831b76c..b7992402 100644 --- a/cdist/conf/type/__zypper_service/explorer/repo_ids +++ b/cdist/conf/type/__zypper_service/explorer/repo_ids @@ -24,4 +24,6 @@ # simpler command which works only on SLES11 SP3 or newer: # echo $(zypper lr -u -E | cut -d'|' -f 1 | grep -E '^[0-9]') # on older systems, zypper doesn't know the parameter -E +# +# shellcheck disable=SC2005 echo $(zypper lr -u | grep -E '^([^|]+\|){3,3} Yes' | cut -d'|' -f 1 | grep -E '^[0-9]') diff --git a/cdist/conf/type/__zypper_service/explorer/service_id b/cdist/conf/type/__zypper_service/explorer/service_id index 4da8ac01..5a0fc5fa 100644 --- a/cdist/conf/type/__zypper_service/explorer/service_id +++ b/cdist/conf/type/__zypper_service/explorer/service_id @@ -27,4 +27,6 @@ else fi # simpler command which works only on SLES11 SP3 or newer: # echo $(zypper ls -u -E | grep -E "\<$uri\>" | cut -d'|' -f 1 ) +# +# shellcheck disable=SC2005 echo $(zypper ls -u | grep -E '^([^|]+\|){3,3} Yes' | grep -E "\\<$uri\\>" | cut -d'|' -f 1) diff --git a/cdist/conf/type/__zypper_service/explorer/service_ids b/cdist/conf/type/__zypper_service/explorer/service_ids index 0f1f4186..e9c66458 100644 --- a/cdist/conf/type/__zypper_service/explorer/service_ids +++ b/cdist/conf/type/__zypper_service/explorer/service_ids @@ -22,4 +22,6 @@ # # simpler command which works only on SLES11 SP3 or newer: # echo $(zypper ls -u -E | cut -d'|' -f 1 | grep -E '^[0-9]') +# +# shellcheck disable=SC2005 echo $(zypper ls -u | grep -E '^([^|]+\|){3,3} Yes' | cut -d'|' -f 1 | grep -E '^[0-9]') diff --git a/cdist/conf/type/__zypper_service/explorer/service_uri b/cdist/conf/type/__zypper_service/explorer/service_uri index 06014df8..caccf237 100644 --- a/cdist/conf/type/__zypper_service/explorer/service_uri +++ b/cdist/conf/type/__zypper_service/explorer/service_uri @@ -25,4 +25,5 @@ if [ -f "$__object/parameter/uri" ]; then else uri="/$__object_id" fi +# shellcheck disable=SC2005 echo $(zypper ls -u | awk 'BEGIN { FS = "[ ]+\\|[ ]+" } ; $4 == "Yes" && $NF == "'"$uri"'" {print $NF}') From ef9d5494cdfe9ec198b77de6898bd625b26c1952 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Wed, 13 Feb 2019 18:16:59 +0100 Subject: [PATCH 0227/1217] ++changelog --- docs/changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog b/docs/changelog index 2449c2ed..2c9be634 100644 --- a/docs/changelog +++ b/docs/changelog @@ -3,6 +3,7 @@ Changelog next: * Type __prometheus_alertmanager: Add startup flag (Dominique Roux) + * Types __zypper_repo, __zypper_service: Re-add the use of echo in explorers (Daniel Heule) 4.10.5: 2018-12-21 * Type __group: Fix/remove '--' from echo command (Dimitrios Apostolou) From 51fa8af6b7d2b43eaf8610479ac4d3e70feb7116 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Fri, 15 Feb 2019 20:34:45 +0100 Subject: [PATCH 0228/1217] pycodestyle --- cdist/core/cdist_object.py | 11 ++++++++--- cdist/test/inventory/__init__.py | 1 + setup.py | 1 + 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/cdist/core/cdist_object.py b/cdist/core/cdist_object.py index e2cd22a2..237f0ddd 100644 --- a/cdist/core/cdist_object.py +++ b/cdist/core/cdist_object.py @@ -108,7 +108,9 @@ class CdistObject(object): @staticmethod def split_name(object_name): - """split_name('__type_name/the/object_id') -> ('__type_name', 'the/object_id') + """split_name('__type_name/the/object_id') + -> + ('__type_name', 'the/object_id') Split the given object name into it's type and object_id parts. @@ -119,7 +121,9 @@ class CdistObject(object): @staticmethod def join_name(type_name, object_id): - """join_name('__type_name', 'the/object_id') -> __type_name/the/object_id' + """join_name('__type_name', 'the/object_id') + -> + __type_name/the/object_id' Join the given type_name and object_id into an object name. @@ -162,7 +166,8 @@ class CdistObject(object): # (parameters: %s)" % (self.cdist_type.name, self.parameters)) def object_from_name(self, object_name): - """Convenience method for creating an object instance from an object name. + """Convenience method for creating an object instance from an object + name. Mainly intended to create objects when resolving requirements. diff --git a/cdist/test/inventory/__init__.py b/cdist/test/inventory/__init__.py index 4c0dd936..287c855c 100644 --- a/cdist/test/inventory/__init__.py +++ b/cdist/test/inventory/__init__.py @@ -472,5 +472,6 @@ class InventoryTestCase(test.CdistTestCase): self.assertEqual(htags, ()) os.remove(hostfile) + if __name__ == "__main__": unittest.main() diff --git a/setup.py b/setup.py index f29a8998..565b66ad 100644 --- a/setup.py +++ b/setup.py @@ -25,6 +25,7 @@ def data_finder(data_dir): return entries + cur = os.getcwd() os.chdir("cdist") package_data = data_finder("conf") From 867b9cb102f791cd0ecb8e616d2a6be6658703d6 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Fri, 15 Feb 2019 20:40:12 +0100 Subject: [PATCH 0229/1217] shellcheck: SC2236: use -n instead of ! -z --- cdist/conf/type/__package_emerge/gencode-remote | 2 +- cdist/conf/type/__systemd_unit/gencode-remote | 2 +- cdist/conf/type/__zypper_repo/gencode-remote | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cdist/conf/type/__package_emerge/gencode-remote b/cdist/conf/type/__package_emerge/gencode-remote index b144ede4..e1b85ebb 100755 --- a/cdist/conf/type/__package_emerge/gencode-remote +++ b/cdist/conf/type/__package_emerge/gencode-remote @@ -58,7 +58,7 @@ fi # Exit if nothing is needed to be done [ "$state_is" = "$state_should" ] && { [ -z "$version" ] || [ "$installed_version" = "$version" ]; } && exit 0 -[ "$state_should" = "absent" ] && [ ! -z "$version" ] && [ "$installed_version" != "$version" ] && exit 0 +[ "$state_should" = "absent" ] && [ -n "$version" ] && [ "$installed_version" != "$version" ] && exit 0 case "$state_should" in diff --git a/cdist/conf/type/__systemd_unit/gencode-remote b/cdist/conf/type/__systemd_unit/gencode-remote index 60486c52..967a6c87 100644 --- a/cdist/conf/type/__systemd_unit/gencode-remote +++ b/cdist/conf/type/__systemd_unit/gencode-remote @@ -23,7 +23,7 @@ state=$(cat "${__object}/parameter/state") current_enablement_state=$(cat "${__object}/explorer/enablement-state") if [ "${state}" = "absent" ]; then - if [ ! -z "${current_enablement_state}" ]; then + if [ -n "${current_enablement_state}" ]; then echo "systemctl --now disable ${name}" echo "rm -f /etc/systemd/system/${name}" echo "systemctl daemon-reload" diff --git a/cdist/conf/type/__zypper_repo/gencode-remote b/cdist/conf/type/__zypper_repo/gencode-remote index b8eeef0f..336488ae 100755 --- a/cdist/conf/type/__zypper_repo/gencode-remote +++ b/cdist/conf/type/__zypper_repo/gencode-remote @@ -74,19 +74,19 @@ case "$state" in fi ;; absent) - if [ ! -z "$act_id" ]; then + if [ -n "$act_id" ]; then # Repo present (act_id not ""), so we ned to delete it echo "zypper $zypper_def_opts removerepo $act_id" fi ;; enabled) - if [ ! -z "$act_id" ] && [ "$repostate" = "disabled" ]; then + if [ -n "$act_id" ] && [ "$repostate" = "disabled" ]; then # Repo present (act_id not "") and repostate not enabled, so a enable call is needed echo "zypper $zypper_def_opts modifyrepo -e $act_id" fi ;; disabled) - if [ ! -z "$act_id" ] && [ "$repostate" = "enabled" ]; then + if [ -n "$act_id" ] && [ "$repostate" = "enabled" ]; then # Repo present (act_id not "") and repostate enabled, so a disable call is needed echo "zypper $zypper_def_opts modifyrepo -d $act_id" fi From a40a81d36fad5f8856d1d2519ad60db75b800f9e Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Fri, 15 Feb 2019 20:42:46 +0100 Subject: [PATCH 0230/1217] To keep original echo intentionally disable SC2046 too --- cdist/conf/type/__zypper_repo/explorer/all_repo_ids | 2 +- cdist/conf/type/__zypper_repo/explorer/enabled_repo_ids | 2 +- cdist/conf/type/__zypper_repo/explorer/repo_id | 2 +- cdist/conf/type/__zypper_service/explorer/repo_ids | 2 +- cdist/conf/type/__zypper_service/explorer/service_id | 2 +- cdist/conf/type/__zypper_service/explorer/service_ids | 2 +- cdist/conf/type/__zypper_service/explorer/service_uri | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/cdist/conf/type/__zypper_repo/explorer/all_repo_ids b/cdist/conf/type/__zypper_repo/explorer/all_repo_ids index a4fd0368..7953158a 100644 --- a/cdist/conf/type/__zypper_repo/explorer/all_repo_ids +++ b/cdist/conf/type/__zypper_repo/explorer/all_repo_ids @@ -21,5 +21,5 @@ # Retrieve all repo id nummbers - parsed zypper output # # -# shellcheck disable=SC2005 +# shellcheck disable=SC2005,SC2046 echo $(zypper lr | cut -d'|' -f 1 | grep -E '^[0-9]') diff --git a/cdist/conf/type/__zypper_repo/explorer/enabled_repo_ids b/cdist/conf/type/__zypper_repo/explorer/enabled_repo_ids index b8e9ef3a..261d6073 100644 --- a/cdist/conf/type/__zypper_repo/explorer/enabled_repo_ids +++ b/cdist/conf/type/__zypper_repo/explorer/enabled_repo_ids @@ -24,5 +24,5 @@ # simpler command which works only on SLES11 SP3 or newer: # echo $(zypper lr -E | cut -d'|' -f 1 | grep -E '^[0-9]') # -# shellcheck disable=SC2005 +# shellcheck disable=SC2005,SC2046 echo $(zypper lr | grep -E '^[0-9]([^|]+\|){3,3} Yes' | cut -d'|' -f 1) diff --git a/cdist/conf/type/__zypper_repo/explorer/repo_id b/cdist/conf/type/__zypper_repo/explorer/repo_id index 43b2f1c0..d55a5cac 100644 --- a/cdist/conf/type/__zypper_repo/explorer/repo_id +++ b/cdist/conf/type/__zypper_repo/explorer/repo_id @@ -26,5 +26,5 @@ if [ -f "$__object/parameter/uri" ]; then else uri="$__object_id" fi -# shellcheck disable=SC2005 +# shellcheck disable=SC2005,SC2046 echo $(zypper lr -u | grep -F "$uri" | cut -d'|' -f 1 | grep -E '^[0-9]') diff --git a/cdist/conf/type/__zypper_service/explorer/repo_ids b/cdist/conf/type/__zypper_service/explorer/repo_ids index b7992402..da506fea 100644 --- a/cdist/conf/type/__zypper_service/explorer/repo_ids +++ b/cdist/conf/type/__zypper_service/explorer/repo_ids @@ -25,5 +25,5 @@ # echo $(zypper lr -u -E | cut -d'|' -f 1 | grep -E '^[0-9]') # on older systems, zypper doesn't know the parameter -E # -# shellcheck disable=SC2005 +# shellcheck disable=SC2005,SC2046 echo $(zypper lr -u | grep -E '^([^|]+\|){3,3} Yes' | cut -d'|' -f 1 | grep -E '^[0-9]') diff --git a/cdist/conf/type/__zypper_service/explorer/service_id b/cdist/conf/type/__zypper_service/explorer/service_id index 5a0fc5fa..fbb983c8 100644 --- a/cdist/conf/type/__zypper_service/explorer/service_id +++ b/cdist/conf/type/__zypper_service/explorer/service_id @@ -28,5 +28,5 @@ fi # simpler command which works only on SLES11 SP3 or newer: # echo $(zypper ls -u -E | grep -E "\<$uri\>" | cut -d'|' -f 1 ) # -# shellcheck disable=SC2005 +# shellcheck disable=SC2005,SC2046 echo $(zypper ls -u | grep -E '^([^|]+\|){3,3} Yes' | grep -E "\\<$uri\\>" | cut -d'|' -f 1) diff --git a/cdist/conf/type/__zypper_service/explorer/service_ids b/cdist/conf/type/__zypper_service/explorer/service_ids index e9c66458..5a26740e 100644 --- a/cdist/conf/type/__zypper_service/explorer/service_ids +++ b/cdist/conf/type/__zypper_service/explorer/service_ids @@ -23,5 +23,5 @@ # simpler command which works only on SLES11 SP3 or newer: # echo $(zypper ls -u -E | cut -d'|' -f 1 | grep -E '^[0-9]') # -# shellcheck disable=SC2005 +# shellcheck disable=SC2005,SC2046 echo $(zypper ls -u | grep -E '^([^|]+\|){3,3} Yes' | cut -d'|' -f 1 | grep -E '^[0-9]') diff --git a/cdist/conf/type/__zypper_service/explorer/service_uri b/cdist/conf/type/__zypper_service/explorer/service_uri index caccf237..2f3d0f94 100644 --- a/cdist/conf/type/__zypper_service/explorer/service_uri +++ b/cdist/conf/type/__zypper_service/explorer/service_uri @@ -25,5 +25,5 @@ if [ -f "$__object/parameter/uri" ]; then else uri="/$__object_id" fi -# shellcheck disable=SC2005 +# shellcheck disable=SC2005,SC2046 echo $(zypper ls -u | awk 'BEGIN { FS = "[ ]+\\|[ ]+" } ; $4 == "Yes" && $NF == "'"$uri"'" {print $NF}') From afc7ca88b89c17d22ff7f2ed9e655b9000c984e0 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Fri, 15 Feb 2019 20:28:08 +0100 Subject: [PATCH 0231/1217] Release 4.10.6 --- docs/changelog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/changelog b/docs/changelog index 2c9be634..437731bd 100644 --- a/docs/changelog +++ b/docs/changelog @@ -1,7 +1,7 @@ Changelog --------- -next: +4.10.6: 2019-02-15 * Type __prometheus_alertmanager: Add startup flag (Dominique Roux) * Types __zypper_repo, __zypper_service: Re-add the use of echo in explorers (Daniel Heule) From 689f37acf61feb0f7bb3d640a1ca14c63a103e17 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Fri, 15 Feb 2019 21:05:26 +0100 Subject: [PATCH 0232/1217] Migrate from pep8 to pycodestyle --- Makefile | 2 +- bin/build-helper | 12 ++++++------ bin/build-helper.freebsd | 12 ++++++------ docs/changelog | 3 +++ 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/Makefile b/Makefile index 9f81cf06..e140d383 100644 --- a/Makefile +++ b/Makefile @@ -256,7 +256,7 @@ test: test-remote: $(helper) $@ -pep8: +pycodestyle pep8: $(helper) $@ shellcheck-global-explorers: diff --git a/bin/build-helper b/bin/build-helper index 02fa67d6..2179a5ed 100755 --- a/bin/build-helper +++ b/bin/build-helper @@ -249,7 +249,7 @@ eof # First check everything is sane "$0" check-date "$0" check-unittest - "$0" check-pep8 + "$0" check-pycodestyle "$0" shellcheck # Generate version file to be included in packaging @@ -365,13 +365,13 @@ eof python3 -m cdist.test.exec.remote ;; - pep8) - pep8 "${basedir}" "${basedir}/scripts/cdist" | less + pycodestyle|pep8) + pycodestyle "${basedir}" "${basedir}/scripts/cdist" | less ;; - check-pep8) - "$0" pep8 - printf "\\nPlease review pep8 report.\\n" + check-pycodestyle) + "$0" pycodestyle + printf "\\nPlease review pycodestyle report.\\n" while true do echo "Continue (yes/no)?" diff --git a/bin/build-helper.freebsd b/bin/build-helper.freebsd index 081feb54..a2b8dde7 100755 --- a/bin/build-helper.freebsd +++ b/bin/build-helper.freebsd @@ -284,7 +284,7 @@ eof # First check everything is sane "$0" check-date "$0" check-unittest - "$0" check-pep8 + "$0" check-pycodestyle "$0" shellcheck # Generate version file to be included in packaging @@ -427,13 +427,13 @@ eof python3 -m cdist.test.exec.remote ;; - pep8) - pep8 "${basedir}" "${basedir}/scripts/cdist" | less + pycodestyle|pep8) + pycodestyle "${basedir}" "${basedir}/scripts/cdist" | less ;; - check-pep8) - "$0" pep8 - printf "\\nPlease review pep8 report.\\n" + check-pycodestyle) + "$0" pycodestyle + printf "\\nPlease review pycodestyle report.\\n" while true do echo "Continue (yes/no)?" diff --git a/docs/changelog b/docs/changelog index 437731bd..0695a4a0 100644 --- a/docs/changelog +++ b/docs/changelog @@ -1,6 +1,9 @@ Changelog --------- +next: + * Build: Migrate from pep8 to pycodestyle (Darko Poljak) + 4.10.6: 2019-02-15 * Type __prometheus_alertmanager: Add startup flag (Dominique Roux) * Types __zypper_repo, __zypper_service: Re-add the use of echo in explorers (Daniel Heule) From 15ab7c0810ed3ca6e078dcb6c36e81d06e54dc83 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20N=C3=A9ri?= Date: Sat, 16 Mar 2019 17:23:19 +0100 Subject: [PATCH 0233/1217] Implement "__start_on_boot --state absent" for OpenBSD --- cdist/conf/type/__start_on_boot/gencode-remote | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cdist/conf/type/__start_on_boot/gencode-remote b/cdist/conf/type/__start_on_boot/gencode-remote index b9346826..1a3b6ff6 100755 --- a/cdist/conf/type/__start_on_boot/gencode-remote +++ b/cdist/conf/type/__start_on_boot/gencode-remote @@ -82,7 +82,7 @@ case "$state_should" in ;; openbsd) - # OpenBSD 5.7 and phigher + # OpenBSD 5.7 and higher echo "rcctl enable '$name'" ;; @@ -116,6 +116,11 @@ case "$state_should" in openwrt) echo "'/etc/init.d/$name' disable" + ;; + + openbsd) + # OpenBSD 5.7 and higher + echo "rcctl disable '$name'" ;; *) From 73784b04df1c62e6e85eb47728ae7eab644b4318 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Sat, 16 Mar 2019 19:00:14 +0100 Subject: [PATCH 0234/1217] ++changelog --- docs/changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog b/docs/changelog index 0695a4a0..ff878471 100644 --- a/docs/changelog +++ b/docs/changelog @@ -3,6 +3,7 @@ Changelog next: * Build: Migrate from pep8 to pycodestyle (Darko Poljak) + * Type __start_on_boot: Implement state absent for OpenBSD (Daniel Néri) 4.10.6: 2019-02-15 * Type __prometheus_alertmanager: Add startup flag (Dominique Roux) From 0fc64a951c5d8a3394fc2ac8aa1ae0f52402b56e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20N=C3=A9ri?= Date: Tue, 19 Mar 2019 23:09:01 +0100 Subject: [PATCH 0235/1217] explorer/cpu_cores: Add support for OpenBSD --- cdist/conf/explorer/cpu_cores | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cdist/conf/explorer/cpu_cores b/cdist/conf/explorer/cpu_cores index 27cc6800..a52bddac 100755 --- a/cdist/conf/explorer/cpu_cores +++ b/cdist/conf/explorer/cpu_cores @@ -28,6 +28,10 @@ case "$os" in sysctl -n hw.physicalcpu ;; + "openbsd") + sysctl -n hw.ncpuonline + ;; + *) if [ -r /proc/cpuinfo ]; then cores="$(grep "core id" /proc/cpuinfo | sort | uniq | wc -l)" From dbcf7d55432c90bb6be4547d6e49a1e060279a9a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20N=C3=A9ri?= Date: Tue, 19 Mar 2019 23:13:24 +0100 Subject: [PATCH 0236/1217] explorer/disks: Add support for OpenBSD --- cdist/conf/explorer/disks | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/cdist/conf/explorer/disks b/cdist/conf/explorer/disks index 7c60b17a..1780e6d2 100755 --- a/cdist/conf/explorer/disks +++ b/cdist/conf/explorer/disks @@ -1,3 +1,16 @@ -#!/bin/sh -cd /dev || exit 0 -echo sd? hd? vd? +#!/bin/sh -e + +os=$("$__explorer/os") +case "$os" in + openbsd) + IFS=',' disks=$(sysctl -n hw.disknames) + for d in $disks; do + echo "${d%%:*}" + done | sed -n '/^[sw]d[0-9][0-9]*/p' + ;; + + *) + cd /dev || exit 0 + echo sd? hd? vd? + ;; +esac From 825a47b3d94457a7745a71028901e411e1928f31 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Tue, 19 Mar 2019 23:30:34 +0100 Subject: [PATCH 0237/1217] ++changelog --- docs/changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog b/docs/changelog index ff878471..502cb20b 100644 --- a/docs/changelog +++ b/docs/changelog @@ -4,6 +4,7 @@ Changelog next: * Build: Migrate from pep8 to pycodestyle (Darko Poljak) * Type __start_on_boot: Implement state absent for OpenBSD (Daniel Néri) + * Explorers cpu_cores, disks: Add support for OpenBSD (Daniel Néri) 4.10.6: 2019-02-15 * Type __prometheus_alertmanager: Add startup flag (Dominique Roux) From 28e2b058a4562a621b54a59f757764877d6440e1 Mon Sep 17 00:00:00 2001 From: Silas Date: Mon, 25 Mar 2019 18:36:55 -0300 Subject: [PATCH 0238/1217] Use portable -p instead of --tmpdir for mktemp -p is equivalent to --tmpdir, but more portable, since it works across GNU/Linux and *BSDs --- cdist/conf/type/__staged_file/gencode-local | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cdist/conf/type/__staged_file/gencode-local b/cdist/conf/type/__staged_file/gencode-local index e78b50bd..ba9e8798 100755 --- a/cdist/conf/type/__staged_file/gencode-local +++ b/cdist/conf/type/__staged_file/gencode-local @@ -63,7 +63,7 @@ fetch_file() { fetch_and_prepare_file() { # shellcheck disable=SC2016 - printf 'tmpdir="$(mktemp -d --tmpdir="/tmp" "%s")"\n' "${__type##*/}.XXXXXXXXXX" + printf 'tmpdir="$(mktemp -d -p "/tmp" "%s")"\n' "${__type##*/}.XXXXXXXXXX" # shellcheck disable=SC2016 printf 'cd "$tmpdir"\n' # shellcheck disable=SC2059 From 59bff817353adaf12f9173ebadd00a80cdd0b080 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Tue, 26 Mar 2019 19:01:26 +0100 Subject: [PATCH 0239/1217] ++changelog --- docs/changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog b/docs/changelog index 502cb20b..4f1d4474 100644 --- a/docs/changelog +++ b/docs/changelog @@ -5,6 +5,7 @@ next: * Build: Migrate from pep8 to pycodestyle (Darko Poljak) * Type __start_on_boot: Implement state absent for OpenBSD (Daniel Néri) * Explorers cpu_cores, disks: Add support for OpenBSD (Daniel Néri) + * Type __staged_file: Use portable -p instead of --tmpdir for mktemp (Silas Silva) 4.10.6: 2019-02-15 * Type __prometheus_alertmanager: Add startup flag (Dominique Roux) From 0f6fe4764be5d138e1448c50dd19db743f838ab4 Mon Sep 17 00:00:00 2001 From: Ander Punnar Date: Thu, 28 Mar 2019 23:31:38 +0200 Subject: [PATCH 0240/1217] add --onchange to __line --- cdist/conf/type/__line/gencode-remote | 4 ++++ cdist/conf/type/__line/man.rst | 2 ++ cdist/conf/type/__line/parameter/optional | 1 + 3 files changed, 7 insertions(+) diff --git a/cdist/conf/type/__line/gencode-remote b/cdist/conf/type/__line/gencode-remote index 044ebe90..03e90c1b 100755 --- a/cdist/conf/type/__line/gencode-remote +++ b/cdist/conf/type/__line/gencode-remote @@ -122,3 +122,7 @@ END { ' "$file" > "\$tmpfile" mv -f "\$tmpfile" "$file" DONE + +if [ -f "$__object/parameter/onchange" ]; then + cat "$__object/parameter/onchange" +fi diff --git a/cdist/conf/type/__line/man.rst b/cdist/conf/type/__line/man.rst index d651985e..f76cab64 100644 --- a/cdist/conf/type/__line/man.rst +++ b/cdist/conf/type/__line/man.rst @@ -46,6 +46,8 @@ regex state 'present' or 'absent', defaults to 'present' +onchange + The code to run if line is added, removed or updated. BOOLEAN PARAMETERS diff --git a/cdist/conf/type/__line/parameter/optional b/cdist/conf/type/__line/parameter/optional index f89a2115..1c34c699 100644 --- a/cdist/conf/type/__line/parameter/optional +++ b/cdist/conf/type/__line/parameter/optional @@ -4,3 +4,4 @@ file line regex state +onchange From d656058ff45abe7376bd7e9eb3d7e834288099c1 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Fri, 29 Mar 2019 22:15:05 +0100 Subject: [PATCH 0241/1217] ++changelog --- docs/changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog b/docs/changelog index 4f1d4474..4a4f589c 100644 --- a/docs/changelog +++ b/docs/changelog @@ -6,6 +6,7 @@ next: * Type __start_on_boot: Implement state absent for OpenBSD (Daniel Néri) * Explorers cpu_cores, disks: Add support for OpenBSD (Daniel Néri) * Type __staged_file: Use portable -p instead of --tmpdir for mktemp (Silas Silva) + * Type __line: Add onchange parameter (Ander Punnar) 4.10.6: 2019-02-15 * Type __prometheus_alertmanager: Add startup flag (Dominique Roux) From c6fd43da81bbc35b607005b239d4819e453174f6 Mon Sep 17 00:00:00 2001 From: Ander Punnar Date: Fri, 29 Mar 2019 00:38:50 +0200 Subject: [PATCH 0242/1217] add --onchange to __file, because having to use __config_file just for that feels redundant --- cdist/conf/type/__file/gencode-remote | 12 +++++++++++- cdist/conf/type/__file/man.rst | 3 +++ cdist/conf/type/__file/parameter/optional | 1 + 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/cdist/conf/type/__file/gencode-remote b/cdist/conf/type/__file/gencode-remote index e19d428b..a6f35c0b 100755 --- a/cdist/conf/type/__file/gencode-remote +++ b/cdist/conf/type/__file/gencode-remote @@ -23,7 +23,7 @@ destination="/$__object_id" state_should="$(cat "$__object/parameter/state")" type="$(cat "$__object/explorer/type")" stat_file="$__object/explorer/stat" - +fire_onchange='' get_current_value() { if [ -s "$stat_file" ]; then @@ -45,16 +45,19 @@ get_current_value() { set_group() { echo "chgrp '$1' '$destination'" echo "chgrp '$1'" >> "$__messages_out" + fire_onchange=1 } set_owner() { echo "chown '$1' '$destination'" echo "chown '$1'" >> "$__messages_out" + fire_onchange=1 } set_mode() { echo "chmod '$1' '$destination'" echo "chmod '$1'" >> "$__messages_out" + fire_onchange=1 } case "$state_should" in @@ -83,6 +86,7 @@ case "$state_should" in if [ "$type" = "file" ]; then echo "rm -f '$destination'" echo remove >> "$__messages_out" + fire_onchange=1 fi ;; @@ -91,3 +95,9 @@ case "$state_should" in exit 1 ;; esac + +if [ -f "$__object/parameter/onchange" ]; then + if [ -n "$fire_onchange" ]; then + cat "$__object/parameter/onchange" + fi +fi diff --git a/cdist/conf/type/__file/man.rst b/cdist/conf/type/__file/man.rst index a141d70b..7a0603bb 100644 --- a/cdist/conf/type/__file/man.rst +++ b/cdist/conf/type/__file/man.rst @@ -63,6 +63,9 @@ source 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. +onchange + The code to run if file is modified. + MESSAGES -------- chgrp diff --git a/cdist/conf/type/__file/parameter/optional b/cdist/conf/type/__file/parameter/optional index c696d592..9b98352c 100644 --- a/cdist/conf/type/__file/parameter/optional +++ b/cdist/conf/type/__file/parameter/optional @@ -3,3 +3,4 @@ group mode owner source +onchange From 6440faf176ca42ffa90bf0bad05bdab86c8617e0 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Fri, 29 Mar 2019 22:57:52 +0100 Subject: [PATCH 0243/1217] ++ --- docs/changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog b/docs/changelog index 4a4f589c..d7f0c44f 100644 --- a/docs/changelog +++ b/docs/changelog @@ -7,6 +7,7 @@ next: * Explorers cpu_cores, disks: Add support for OpenBSD (Daniel Néri) * Type __staged_file: Use portable -p instead of --tmpdir for mktemp (Silas Silva) * Type __line: Add onchange parameter (Ander Punnar) + * Type __file: Add onchange parameter (Ander Punnar) 4.10.6: 2019-02-15 * Type __prometheus_alertmanager: Add startup flag (Dominique Roux) From 5f76bd5655b4407e831c8978ad5fdc683b85233c Mon Sep 17 00:00:00 2001 From: Ander Punnar Date: Sat, 30 Mar 2019 13:21:13 +0200 Subject: [PATCH 0244/1217] new type: __clean_path --- cdist/conf/type/__clean_path/explorer/list | 39 ++++++++++++ cdist/conf/type/__clean_path/gencode-remote | 48 +++++++++++++++ cdist/conf/type/__clean_path/man.rst | 60 +++++++++++++++++++ .../conf/type/__clean_path/parameter/optional | 2 + .../conf/type/__clean_path/parameter/required | 1 + 5 files changed, 150 insertions(+) create mode 100755 cdist/conf/type/__clean_path/explorer/list create mode 100755 cdist/conf/type/__clean_path/gencode-remote create mode 100644 cdist/conf/type/__clean_path/man.rst create mode 100644 cdist/conf/type/__clean_path/parameter/optional create mode 100644 cdist/conf/type/__clean_path/parameter/required diff --git a/cdist/conf/type/__clean_path/explorer/list b/cdist/conf/type/__clean_path/explorer/list new file mode 100755 index 00000000..ef46887d --- /dev/null +++ b/cdist/conf/type/__clean_path/explorer/list @@ -0,0 +1,39 @@ +#!/bin/sh -e +# +# 2019 Ander Punnar (ander-at-kvlt-dot-ee) +# +# 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 . +# + +path="/$__object_id" + +if [ ! -d "$path" ] +then + echo "$path is not a directory" >&2 + exit 1 +fi + +pattern="$( cat "$__object/parameter/pattern" )" + +if [ -f "$__object/parameter/exclude" ] +then + exclude="$( cat "$__object/parameter/exclude" )" + + find "$path" -mindepth 1 -maxdepth 1 -regex "$pattern" \ + -and -not -regex "$exclude" +else + find "$path" -mindepth 1 -maxdepth 1 -regex "$pattern" +fi diff --git a/cdist/conf/type/__clean_path/gencode-remote b/cdist/conf/type/__clean_path/gencode-remote new file mode 100755 index 00000000..998a70d8 --- /dev/null +++ b/cdist/conf/type/__clean_path/gencode-remote @@ -0,0 +1,48 @@ +#!/bin/sh -e +# +# 2019 Ander Punnar (ander-at-kvlt-dot-ee) +# +# 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 . +# + +[ ! -s "$__object/explorer/list" ] && exit 0 + +path="/$__object_id" + +pattern="$( cat "$__object/parameter/pattern" )" + +if [ -f "$__object/parameter/exclude" ] +then + exclude="$( cat "$__object/parameter/exclude" )" + + echo "find '$path' -mindepth 1 -maxdepth 1 -regex '$pattern'" \ + "-and -not -regex '$exclude'" \ + '-exec rm -rf {} \;' +else + echo "find '$path' -mindepth 1 -maxdepth 1 -regex '$pattern'" \ + '-exec rm -rf {} \;' +fi + +while read -r f +do + echo "removed '$f'" >> "$__messages_out" +done \ +< "$__object/explorer/list" + +if [ -f "$__object/parameter/onchange" ] +then + cat "$__object/parameter/onchange" +fi diff --git a/cdist/conf/type/__clean_path/man.rst b/cdist/conf/type/__clean_path/man.rst new file mode 100644 index 00000000..826f4589 --- /dev/null +++ b/cdist/conf/type/__clean_path/man.rst @@ -0,0 +1,60 @@ +cdist-type__clean_path(7) +========================= + +NAME +---- +cdist-type__clean_path - Remove files and directories which match the pattern. + + +DESCRIPTION +----------- +Remove files and directories which match the pattern. + +Provided path (as __object_id) must be a directory. + +Patterns are passed to ``find``'s ``-regex`` - see ``find(1)`` for more details. + +Look up of files and directories is non-recursive (``-maxdepth 1``). + +Parent directory is excluded (``-mindepth 1``). + +This type is not POSIX compatible (sorry, Solaris users). + + +REQUIRED PARAMETERS +------------------- +pattern + Pattern of files which are removed from path. + + +OPTIONAL PARAMETERS +------------------- +exclude + Pattern of files which are excluded from removal. + +onchange + The code to run if files or directories were removed. + + +EXAMPLES +-------- + +.. code-block:: sh + + __clean_path /etc/apache2/conf-enabled \ + --pattern '.+' \ + --exclude '.+\(charset\.conf\|security\.conf\)' \ + --onchange 'service apache2 restart' + + +AUTHORS +------- +Ander Punnar + + +COPYING +------- +Copyright \(C) 2019 Ander Punnar. 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/__clean_path/parameter/optional b/cdist/conf/type/__clean_path/parameter/optional new file mode 100644 index 00000000..6f313474 --- /dev/null +++ b/cdist/conf/type/__clean_path/parameter/optional @@ -0,0 +1,2 @@ +exclude +onchange diff --git a/cdist/conf/type/__clean_path/parameter/required b/cdist/conf/type/__clean_path/parameter/required new file mode 100644 index 00000000..54774947 --- /dev/null +++ b/cdist/conf/type/__clean_path/parameter/required @@ -0,0 +1 @@ +pattern From cbaf1b6d8e2bec9e3e45cdec61b512e4e9128dcd Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Sat, 30 Mar 2019 12:37:25 +0100 Subject: [PATCH 0245/1217] ++ --- docs/changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog b/docs/changelog index d7f0c44f..f43e7da4 100644 --- a/docs/changelog +++ b/docs/changelog @@ -8,6 +8,7 @@ next: * Type __staged_file: Use portable -p instead of --tmpdir for mktemp (Silas Silva) * Type __line: Add onchange parameter (Ander Punnar) * Type __file: Add onchange parameter (Ander Punnar) + * New type: __clean_path (Ander Punnar) 4.10.6: 2019-02-15 * Type __prometheus_alertmanager: Add startup flag (Dominique Roux) From 001f9023a24dab6db0ec19dde4bf661bbad2667d Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Sat, 30 Mar 2019 19:11:13 +0100 Subject: [PATCH 0246/1217] Release 4.10.7 --- docs/changelog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/changelog b/docs/changelog index f43e7da4..02fab2e4 100644 --- a/docs/changelog +++ b/docs/changelog @@ -1,7 +1,7 @@ Changelog --------- -next: +4.10.7: 2019-03-30 * Build: Migrate from pep8 to pycodestyle (Darko Poljak) * Type __start_on_boot: Implement state absent for OpenBSD (Daniel Néri) * Explorers cpu_cores, disks: Add support for OpenBSD (Daniel Néri) From 668dc836324541a0bb432245dbf9085dcf7caefe Mon Sep 17 00:00:00 2001 From: Ander Punnar Date: Tue, 2 Apr 2019 17:52:00 +0300 Subject: [PATCH 0247/1217] do not exit with non-zero if path does not exist or not directory --- cdist/conf/type/__clean_path/explorer/list | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/cdist/conf/type/__clean_path/explorer/list b/cdist/conf/type/__clean_path/explorer/list index ef46887d..07d38127 100755 --- a/cdist/conf/type/__clean_path/explorer/list +++ b/cdist/conf/type/__clean_path/explorer/list @@ -20,11 +20,7 @@ path="/$__object_id" -if [ ! -d "$path" ] -then - echo "$path is not a directory" >&2 - exit 1 -fi +[ ! -d "$path" ] && exit 0 pattern="$( cat "$__object/parameter/pattern" )" From 033e0611b509926faa4cfe4c0ff8dc160d9d3f34 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Tue, 2 Apr 2019 18:39:05 +0200 Subject: [PATCH 0248/1217] ++changelog --- docs/changelog | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/changelog b/docs/changelog index 02fab2e4..8c7fc337 100644 --- a/docs/changelog +++ b/docs/changelog @@ -1,6 +1,9 @@ Changelog --------- +next: + * Type __clean_path: Fix list explorer exit code if path not directory or does not exist (Ander Punnar) + 4.10.7: 2019-03-30 * Build: Migrate from pep8 to pycodestyle (Darko Poljak) * Type __start_on_boot: Implement state absent for OpenBSD (Daniel Néri) From da6a22c71af46218a38766dc2e23ac8763f252c6 Mon Sep 17 00:00:00 2001 From: Ander Punnar Date: Wed, 3 Apr 2019 01:11:03 +0300 Subject: [PATCH 0249/1217] new type: __check_messages --- .../conf/type/__check_messages/gencode-remote | 27 ++++++++++ cdist/conf/type/__check_messages/man.rst | 52 +++++++++++++++++++ .../type/__check_messages/parameter/required | 2 + 3 files changed, 81 insertions(+) create mode 100755 cdist/conf/type/__check_messages/gencode-remote create mode 100644 cdist/conf/type/__check_messages/man.rst create mode 100644 cdist/conf/type/__check_messages/parameter/required diff --git a/cdist/conf/type/__check_messages/gencode-remote b/cdist/conf/type/__check_messages/gencode-remote new file mode 100755 index 00000000..1b4cf247 --- /dev/null +++ b/cdist/conf/type/__check_messages/gencode-remote @@ -0,0 +1,27 @@ +#!/bin/sh -e +# +# 2019 Ander Punnar (ander-at-kvlt-dot-ee) +# +# This file is part of cdist. +# +# cdist is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# cdist is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with cdist. If not, see . +# + +if grep -Eq \ + "$( cat "$__object/parameter/pattern" )" \ + "$__messages_in" +then + cat "$__object/parameter/execute" \ + | tee "$__messages_out" +fi diff --git a/cdist/conf/type/__check_messages/man.rst b/cdist/conf/type/__check_messages/man.rst new file mode 100644 index 00000000..cb505cea --- /dev/null +++ b/cdist/conf/type/__check_messages/man.rst @@ -0,0 +1,52 @@ +cdist-type__check_messages(7) +============================= + +NAME +---- +cdist-type__check_messages - Check messages for pattern and execute command on match. + + +DESCRIPTION +----------- +Check messages for pattern and execute command on match. + +This type is useful if you chain together multiple related types using +dependencies and want to restart service if at least one type changes +something. + +For more information about messages see `cdist messaging `_. + +For more information about dependencies and execution order see +`cdist manifest `_ documentation. + + +REQUIRED PARAMETERS +------------------- +pattern + Search pattern (passed to ``grep -E``). + +execute + Command to execute on pattern match. + + +EXAMPLES +-------- + +.. code-block:: sh + + __check_messages munin \ + --pattern '^__(file|link|line)/etc/munin/' \ + --execute 'service munin-node restart' + + +AUTHORS +------- +Ander Punnar + + +COPYING +------- +Copyright \(C) 2019 Ander Punnar. 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/__check_messages/parameter/required b/cdist/conf/type/__check_messages/parameter/required new file mode 100644 index 00000000..374363cb --- /dev/null +++ b/cdist/conf/type/__check_messages/parameter/required @@ -0,0 +1,2 @@ +pattern +execute From decd80bf5de84398db266ea688a2f8c4cde1f31c Mon Sep 17 00:00:00 2001 From: Ander Punnar Date: Thu, 4 Apr 2019 00:20:46 +0300 Subject: [PATCH 0250/1217] be more explicit --- cdist/conf/type/__check_messages/man.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cdist/conf/type/__check_messages/man.rst b/cdist/conf/type/__check_messages/man.rst index cb505cea..5c80a0ae 100644 --- a/cdist/conf/type/__check_messages/man.rst +++ b/cdist/conf/type/__check_messages/man.rst @@ -23,7 +23,7 @@ For more information about dependencies and execution order see REQUIRED PARAMETERS ------------------- pattern - Search pattern (passed to ``grep -E``). + Extended regular expression pattern for search (passed to ``grep -E``). execute Command to execute on pattern match. From a5e66bc3f60155410062f891f1fa6d78c86a31a8 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Sat, 6 Apr 2019 10:43:11 +0200 Subject: [PATCH 0251/1217] ++changelog --- docs/changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog b/docs/changelog index 8c7fc337..ee1cd5a0 100644 --- a/docs/changelog +++ b/docs/changelog @@ -3,6 +3,7 @@ Changelog next: * Type __clean_path: Fix list explorer exit code if path not directory or does not exist (Ander Punnar) + * New type: __check_messages (Ander Punnar) 4.10.7: 2019-03-30 * Build: Migrate from pep8 to pycodestyle (Darko Poljak) From b47c6e3fe4ea0c64d359bb9b41736ff4ef2823c7 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Sat, 6 Apr 2019 10:52:23 +0200 Subject: [PATCH 0252/1217] Fix shellcheck SC2002 --- cdist/conf/type/__check_messages/gencode-remote | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cdist/conf/type/__check_messages/gencode-remote b/cdist/conf/type/__check_messages/gencode-remote index 1b4cf247..ec36cecc 100755 --- a/cdist/conf/type/__check_messages/gencode-remote +++ b/cdist/conf/type/__check_messages/gencode-remote @@ -22,6 +22,5 @@ if grep -Eq \ "$( cat "$__object/parameter/pattern" )" \ "$__messages_in" then - cat "$__object/parameter/execute" \ - | tee "$__messages_out" + tee "$__messages_out" < "$__object/parameter/execute" fi From 0583cdff09f7f2aec5c522eea3a29c56d76039b2 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Sat, 6 Apr 2019 10:46:36 +0200 Subject: [PATCH 0253/1217] Release 4.10.8 --- docs/changelog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/changelog b/docs/changelog index ee1cd5a0..70e3070f 100644 --- a/docs/changelog +++ b/docs/changelog @@ -1,7 +1,7 @@ Changelog --------- -next: +4.10.8: 2019-04-06 * Type __clean_path: Fix list explorer exit code if path not directory or does not exist (Ander Punnar) * New type: __check_messages (Ander Punnar) From 88513e669337c4c59efd277d391c99409ba97a3d Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Sun, 7 Apr 2019 12:17:19 +0200 Subject: [PATCH 0254/1217] __ssh_authorized_keys: properly handle multiple --option parameters, fixes #393 Signed-off-by: Steven Armstrong --- cdist/conf/type/__ssh_authorized_keys/manifest | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cdist/conf/type/__ssh_authorized_keys/manifest b/cdist/conf/type/__ssh_authorized_keys/manifest index f6ff74c3..8d702875 100755 --- a/cdist/conf/type/__ssh_authorized_keys/manifest +++ b/cdist/conf/type/__ssh_authorized_keys/manifest @@ -69,7 +69,7 @@ while read -r key; do set -- "$@" --key "$key" set -- "$@" --state "$state" if [ -f "$__object/parameter/option" ]; then - set -- "$@" --option "$(cat "$__object/parameter/option")" + set -- "$@" $(printf -- '--option %s ' $(cat "$__object/parameter/option")) fi if [ -f "$__object/parameter/comment" ]; then set -- "$@" --comment "$(cat "$__object/parameter/comment")" From cabb0be7b645751058e9c0eff7ee6ea686ea90e4 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Mon, 8 Apr 2019 08:25:53 +0200 Subject: [PATCH 0255/1217] ++changelog --- docs/changelog | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/changelog b/docs/changelog index 70e3070f..1b4fceb8 100644 --- a/docs/changelog +++ b/docs/changelog @@ -1,6 +1,9 @@ Changelog --------- +next: + * Type __ssh_authorized_keys: Properly handle multiple --option params (Steven Armstrong) + 4.10.8: 2019-04-06 * Type __clean_path: Fix list explorer exit code if path not directory or does not exist (Ander Punnar) * New type: __check_messages (Ander Punnar) From 9cd95f12dc0d3532c5b69a1038b4ccae42bf9876 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Fri, 5 Apr 2019 12:13:53 +0200 Subject: [PATCH 0256/1217] Add debug dump script --- docs/src/cdist-troubleshooting.rst | 18 ++ scripts/debug-dump.sh | 325 +++++++++++++++++++++++++++++ setup.py | 2 +- 3 files changed, 344 insertions(+), 1 deletion(-) create mode 100755 scripts/debug-dump.sh diff --git a/docs/src/cdist-troubleshooting.rst b/docs/src/cdist-troubleshooting.rst index b016e845..b76f3859 100644 --- a/docs/src/cdist-troubleshooting.rst +++ b/docs/src/cdist-troubleshooting.rst @@ -43,3 +43,21 @@ you write to use the -e flag: % cat ~/.cdist/manifest/special #!/bin/sh -e ... + +Using debug dump helper script +------------------------------ +Since cdist stores data to local cache that can be used for debugging there +is a helper script that dumps data from local cache. + +For more info see: + +.. code-block:: sh + + debug-dump.sh -h + +Or from cdist git cloned directory: + +.. code-block:: sh + + ./scripts/debug-dump.sh -h + diff --git a/scripts/debug-dump.sh b/scripts/debug-dump.sh new file mode 100755 index 00000000..d52273a6 --- /dev/null +++ b/scripts/debug-dump.sh @@ -0,0 +1,325 @@ +#!/bin/sh + +VERSION="0.0.1" +RELEASE="" + +set -u +# set -x + +hosts= +cache_dir=~/.cdist/cache + +do_all=1 +do_global_explorer= +do_type_explorer= +do_script_stdout= +do_script_stderr= +do_gencode= +do_code= +do_messages= +do_parameter= +delimiter=':' +ln= +filename_prefix=1 +verbose=0 + +myname=${0##*/} + +print_version() +{ + printf "%s %s %s\n" "${myname}" "${VERSION}" "${RELEASE}" +} + +usage() +{ + cat << eof +${myname}: [options] [host...] +eof + + print_version + + cat << eof + +Dump data from cache directories. + +host + Dump data for specified hosts. If not specified then all data + from cache directory is dumped. + +Options + -a dump all + -C CACHE-DIR use specified CACHE-DIR (default: ~/.cdist/cache) + -c dump code-* + -d delimiter used for filename and line number prefix (default: ':') + -E dump global explorers + -e dump type explorers + -F disable filename prefix (enabled by default) + -f enable filename prefix (default) + -g dump gencode-* + -h show this help screen and exit + -L disable line number prefix (default) + -l enable line number prefix (disabled by default) + -m dump messages + -o dump executions' stdout + -p dump parameters + -r dump executions' stderr + -V show version and exit + -v increase verbosity +eof +} + +exit_err() +{ + printf "%s\n" "$1" + exit 1 +} + +# parse options +while [ "$#" -ge 1 ] +do + case "$1" in + -a) + do_all=1 + ;; + -C) + if [ "$#" -ge 2 ] + then + case "$2" in + -*) + exit_err "Missing cache directory" + ;; + *) + cache_dir="$2" + shift + ;; + esac + else + exit_err "Missing cache directory" + fi + ;; + -c) + do_code=1 + do_all= + ;; + -d) + if [ "$#" -ge 2 ] + then + case "$2" in + -*) + exit_err "Missing delimiter" + ;; + *) + delimiter="$2" + shift + ;; + esac + else + exit_err "Missing delimiter" + fi + ;; + -E) + do_global_explorer=1 + do_all= + ;; + -e) + do_type_explorer=1 + do_all= + ;; + -F) + filename_prefix= + ;; + -f) + filename_prefix=1 + ;; + -g) + do_gencode=1 + do_all= + ;; + -h) + usage + exit 0 + ;; + -L) + ln= + ;; + -l) + ln=1 + ;; + -m) + do_messages=1 + do_all= + ;; + -o) + do_script_stdout=1 + do_all= + ;; + -p) + do_parameter=1 + do_all= + ;; + -r) + do_script_stderr=1 + do_all= + ;; + -V) + print_version + exit 0 + ;; + -v) + verbose=$((verbose + 1)) + ;; + *) + hosts="${hosts} $1" + break + ;; + esac + shift +done + +if [ "${ln}" = "1" ] +then + ln="NR \"${delimiter}\"" +fi + +if [ "${filename_prefix}" = "1" ] +then + filename_prefix="{}${delimiter}" +fi + +if [ "${do_all}" = "1" ] +then + do_global_explorer=1 + do_type_explorer=1 + do_script_stdout=1 + do_script_stderr=1 + do_gencode=1 + do_code=1 + do_messages=1 + do_parameter=1 +fi + +set -- -size +0 +set -- "$@" \( +or= + +print_verbose() +{ + if [ ${verbose} -ge $1 ] + then + printf "%s\n" "$2" + fi +} + +hor_line() +{ + if [ $# -gt 0 ] + then + c=$1 + else + c='=' + fi + printf "%78s\n" "" | tr ' ' "${c}" +} + +if [ "${do_global_explorer}" ] +then + print_verbose 2 "Dumping global explorers" + set -- "$@" ${or} \( \ + -path "*/explorer/*" -a \ + ! -path "*/conf/*" -a \ + ! -path "*/object/*/explorer/*" \ + \) + or="-o" +fi + +if [ "${do_type_explorer}" ] +then + print_verbose 2 "Dumping type explorers" + set -- "$@" ${or} -path "*/object/*/explorer/*" + or="-o" +fi + +if [ "${do_script_stdout}" ] +then + print_verbose 2 "Dumping execution's stdout" + set -- "$@" ${or} -path "*/stdout/*" + or="-o" +fi + +if [ "${do_script_stderr}" ] +then + print_verbose 2 "Dumping execution's stderr" + set -- "$@" ${or} -path "*/stderr/*" + or="-o" +fi + +if [ "${do_gencode}" ] +then + print_verbose 2 "Dumping gencode-*" + set -- "$@" ${or} \( -name "gencode-*" -a ! -path "*/stdout/*" -a ! -path "*/stderr/*" \) + or="-o" +fi + +if [ "${do_code}" ] +then + print_verbose 2 "Dumping code-*" + set -- "$@" ${or} \( -name "code-*" -a ! -path "*/stdout/*" -a ! -path "*/stderr/*" \) + or="-o" +fi + +if [ "${do_messages}" ] +then + print_verbose 2 "Dumping messages" + set -- "$@" ${or} -name "messages" + or="-o" +fi + +if [ "${do_parameter}" ] +then + print_verbose 2 "Dumping parameters" + set -- "$@" ${or} -path "*/parameter/*" + or="-o" +fi + +set -- "$@" \) +set -- '.' "$@" -exec awk -v prefix="${filename_prefix}" "{print prefix ${ln} \$0}" {} \; + +# printf "+ %s\n" "$*" + +print_verbose 2 "Using cache dir: ${cache_dir}" + +OLD_PWD=$(pwd) +cd "${cache_dir}" + +# If no host is specified then search all. +[ -z "${hosts}" ] && hosts="-" + +for host in ${hosts} +do + [ "${host}" = "-" ] && host= + # find host cache directory + host_dir=$(find . -name target_host -exec grep -l "${host}" {} +) + print_verbose 3 "found host directory files:" + print_verbose 3 "${host_dir}" + + OLD_IFS="${IFS}" + IFS=" + " + + for d in ${host_dir} + do + dir=$(dirname "${d}") + + print_verbose 0 "target host: $(cat ${dir}/target_host), host directory: ${dir}" + hor_line + + PREV_PWD=$(pwd) + cd "${dir}" + # set -x + find "$@" + # set +x + cd "${PREV_PWD}" + done + IFS="${OLD_IFS}" +done +cd "${OLD_PWD}" diff --git a/setup.py b/setup.py index 565b66ad..767f5bf7 100644 --- a/setup.py +++ b/setup.py @@ -36,7 +36,7 @@ setup( name="cdist", packages=["cdist", "cdist.core", "cdist.exec", "cdist.util", ], package_data={'cdist': package_data}, - scripts=["scripts/cdist"], + scripts=["scripts/cdist", "scripts/debug-dump.sh"], version=cdist.version.VERSION, description="A Usable Configuration Management System", author="Nico Schottelius", From 8ee667f57f1479ad3fc147ed22e8f7e1d8e10198 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Tue, 9 Apr 2019 22:08:47 +0200 Subject: [PATCH 0257/1217] ++changelog --- docs/changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog b/docs/changelog index 1b4fceb8..b3f87c1f 100644 --- a/docs/changelog +++ b/docs/changelog @@ -3,6 +3,7 @@ Changelog next: * Type __ssh_authorized_keys: Properly handle multiple --option params (Steven Armstrong) + * Debugging: Add debug dump helper script (Darko Poljak) 4.10.8: 2019-04-06 * Type __clean_path: Fix list explorer exit code if path not directory or does not exist (Ander Punnar) From f6b318bb00e63c2fe5d4fae26c66d0fd48470db8 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Tue, 9 Apr 2019 22:23:21 +0200 Subject: [PATCH 0258/1217] Fire onchange for present and exists states Even if no attribute is changed. Fixes #750. --- cdist/conf/type/__file/gencode-remote | 4 ++++ docs/changelog | 1 + 2 files changed, 5 insertions(+) diff --git a/cdist/conf/type/__file/gencode-remote b/cdist/conf/type/__file/gencode-remote index a6f35c0b..b04c471e 100755 --- a/cdist/conf/type/__file/gencode-remote +++ b/cdist/conf/type/__file/gencode-remote @@ -79,6 +79,10 @@ case "$state_should" in fi fi done + if [ -f "$__object/files/set-attributes" ]; then + # set-attributes is created if file is created or uploaded in gencode-local + fire_onchange=1 + fi ;; diff --git a/docs/changelog b/docs/changelog index b3f87c1f..7f0b4131 100644 --- a/docs/changelog +++ b/docs/changelog @@ -4,6 +4,7 @@ Changelog next: * Type __ssh_authorized_keys: Properly handle multiple --option params (Steven Armstrong) * Debugging: Add debug dump helper script (Darko Poljak) + * Type __file: Bugfix: fire onchange for present and exists states if no attribute is changed (Darko Poljak) 4.10.8: 2019-04-06 * Type __clean_path: Fix list explorer exit code if path not directory or does not exist (Ander Punnar) From 671bb82a46a982ee580c3445339b09c742c6f686 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Tue, 9 Apr 2019 22:44:40 +0200 Subject: [PATCH 0259/1217] Fix shellcheck issues --- Makefile | 5 ++++- cdist/conf/type/__ssh_authorized_keys/manifest | 1 + scripts/debug-dump.sh | 16 ++++++++-------- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index e140d383..4ed97c7b 100644 --- a/Makefile +++ b/Makefile @@ -274,11 +274,14 @@ shellcheck-local-gencodes: shellcheck-remote-gencodes: @find cdist/conf/type -type f -name gencode-remote -exec $(SHELLCHECKCMD) {} + | $(SHELLCHECK_SKIP) || exit 0 +shellcheck-scripts: + @$(SHELLCHECKCMD) scripts/debug-dump.sh || exit 0 + shellcheck-gencodes: shellcheck-local-gencodes shellcheck-remote-gencodes shellcheck-types: shellcheck-type-explorers shellcheck-manifests shellcheck-gencodes -shellcheck: shellcheck-global-explorers shellcheck-types +shellcheck: shellcheck-global-explorers shellcheck-types shellcheck-scripts shellcheck-type-files: @find cdist/conf/type -type f -path "*/files/*" -exec $(SHELLCHECKCMD) {} + | $(SHELLCHECK_SKIP) || exit 0 diff --git a/cdist/conf/type/__ssh_authorized_keys/manifest b/cdist/conf/type/__ssh_authorized_keys/manifest index 8d702875..a8ded2f6 100755 --- a/cdist/conf/type/__ssh_authorized_keys/manifest +++ b/cdist/conf/type/__ssh_authorized_keys/manifest @@ -69,6 +69,7 @@ while read -r key; do set -- "$@" --key "$key" set -- "$@" --state "$state" if [ -f "$__object/parameter/option" ]; then + # shellcheck disable=SC2046 set -- "$@" $(printf -- '--option %s ' $(cat "$__object/parameter/option")) fi if [ -f "$__object/parameter/comment" ]; then diff --git a/scripts/debug-dump.sh b/scripts/debug-dump.sh index d52273a6..ac1190b7 100755 --- a/scripts/debug-dump.sh +++ b/scripts/debug-dump.sh @@ -204,7 +204,7 @@ or= print_verbose() { - if [ ${verbose} -ge $1 ] + if [ "${verbose}" -ge "$1" ] then printf "%s\n" "$2" fi @@ -214,7 +214,7 @@ hor_line() { if [ $# -gt 0 ] then - c=$1 + c="$1" else c='=' fi @@ -289,7 +289,7 @@ set -- '.' "$@" -exec awk -v prefix="${filename_prefix}" "{print prefix ${ln} \$ print_verbose 2 "Using cache dir: ${cache_dir}" OLD_PWD=$(pwd) -cd "${cache_dir}" +cd "${cache_dir}" || exit # If no host is specified then search all. [ -z "${hosts}" ] && hosts="-" @@ -310,16 +310,16 @@ do do dir=$(dirname "${d}") - print_verbose 0 "target host: $(cat ${dir}/target_host), host directory: ${dir}" - hor_line + print_verbose 0 "target host: $(cat "${dir}/target_host"), host directory: ${dir}" + hor_line '=' PREV_PWD=$(pwd) - cd "${dir}" + cd "${dir}" || exit # set -x find "$@" # set +x - cd "${PREV_PWD}" + cd "${PREV_PWD}" || exit done IFS="${OLD_IFS}" done -cd "${OLD_PWD}" +cd "${OLD_PWD}" || exit From e90e29626677c72fdbb47b7437cdffd98fc3b7ac Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Tue, 9 Apr 2019 22:46:03 +0200 Subject: [PATCH 0260/1217] Release 4.10.9 --- docs/changelog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/changelog b/docs/changelog index 7f0b4131..dc6164f3 100644 --- a/docs/changelog +++ b/docs/changelog @@ -1,7 +1,7 @@ Changelog --------- -next: +4.10.9: 2019-04-09 * Type __ssh_authorized_keys: Properly handle multiple --option params (Steven Armstrong) * Debugging: Add debug dump helper script (Darko Poljak) * Type __file: Bugfix: fire onchange for present and exists states if no attribute is changed (Darko Poljak) From 0ce96f0860971898d2956b4d73aa2c54253890c9 Mon Sep 17 00:00:00 2001 From: Mark Polyakov Date: Mon, 1 Apr 2019 16:24:08 -0700 Subject: [PATCH 0261/1217] Added __ufw and __ufw_rule. --- cdist/conf/type/__ufw/gencode-remote | 62 +++++++++++++++++ cdist/conf/type/__ufw/man.rst | 59 ++++++++++++++++ cdist/conf/type/__ufw/manifest | 67 +++++++++++++++++++ cdist/conf/type/__ufw/parameter/default/state | 1 + cdist/conf/type/__ufw/parameter/optional | 5 ++ cdist/conf/type/__ufw/singleton | 0 cdist/conf/type/__ufw_rule/gencode-remote | 45 +++++++++++++ cdist/conf/type/__ufw_rule/man.rst | 53 +++++++++++++++ .../type/__ufw_rule/parameter/default/state | 1 + cdist/conf/type/__ufw_rule/parameter/optional | 2 + 10 files changed, 295 insertions(+) create mode 100644 cdist/conf/type/__ufw/gencode-remote create mode 100644 cdist/conf/type/__ufw/man.rst create mode 100755 cdist/conf/type/__ufw/manifest create mode 100644 cdist/conf/type/__ufw/parameter/default/state create mode 100644 cdist/conf/type/__ufw/parameter/optional create mode 100644 cdist/conf/type/__ufw/singleton create mode 100755 cdist/conf/type/__ufw_rule/gencode-remote create mode 100644 cdist/conf/type/__ufw_rule/man.rst create mode 100644 cdist/conf/type/__ufw_rule/parameter/default/state create mode 100644 cdist/conf/type/__ufw_rule/parameter/optional diff --git a/cdist/conf/type/__ufw/gencode-remote b/cdist/conf/type/__ufw/gencode-remote new file mode 100644 index 00000000..fc62b591 --- /dev/null +++ b/cdist/conf/type/__ufw/gencode-remote @@ -0,0 +1,62 @@ +#!/bin/sh -e +# +# 2019 Mark Polyakov (mark--@--markasoftware.com) +# +# This file is part of cdist. +# +# cdist is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# cdist is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with cdist. If not, see . +# + +state="$(cat "$__object/parameter/state")" + +case "$state" in + enabled) + echo 'ufw --force enable' + ;; + + present) + echo 'ufw --force disable' + ;; + # absent will be uninstalled in manifest +esac + +if [ "$state" != absent ]; then + if [ -f "$__object/parameter/logging" ]; then + logging="$(cat "$__object/parameter/logging")" + case "$logging" in + off|low|medium|high|full) + echo "ufw --force logging $logging" + ;; + *) + echo 'Logging parameter must be off, low, medium, high, or full!' >&2 + exit 1 + ;; + esac + fi + + for direction in incoming outgoing routed; do + if [ -f "$__object/parameter/default_$direction" ]; then + treatment="$(cat "$__object/parameter/default_$direction")" + case "$treatment" in + allow|deny|reject) + echo "ufw --force default $treatment $direction" + ;; + *) + echo 'UFW default policies must be either "allow", "deny", or "reject".' >&2 + exit 1 + ;; + esac + fi + done +fi diff --git a/cdist/conf/type/__ufw/man.rst b/cdist/conf/type/__ufw/man.rst new file mode 100644 index 00000000..cc64fbb5 --- /dev/null +++ b/cdist/conf/type/__ufw/man.rst @@ -0,0 +1,59 @@ +cdist-type__ufw(7) +================== + +NAME +---- +cdist-type__ufw - Install the Uncomplicated FireWall + + +DESCRIPTION +----------- +Installs the Uncomplicated FireWall. Most modern distributions carry UFW in their main repositories, but on CentOS this type will automatically enable the EPEL repository. + +Some global configuration can also be set with this type. + +OPTIONAL PARAMETERS +------------------- +state + Either "enabled", "running", "present", or "absent". Defaults to "enabled", which registers UFW to start on boot. + +logging + Either "off", "low", "medium", "high", or "full". Will be passed to `ufw logging`. If not specified, logging level is not modified. + +default_incoming + Either "allow", "deny", or "reject". The default policy for dealing with ingress packets. + +default_outgoing + Either "allow", "deny", or "reject". The default policy for dealing with egress packets. + +default_routed + Either "allow", "deny", or "reject". The default policy for dealing with routed packets (passing through this machine). + + +EXAMPLES +-------- + +.. code-block:: sh + + # Install UFW + __ufw + # Setup UFW with maximum logging and no restrictions on routed packets. + __ufw --logging full --default_routed allow + + +SEE ALSO +-------- +:strong:`ufw`\ (8) + + +AUTHORS +------- +Mark Polyakov + + +COPYING +------- +Copyright \(C) 2019 Mark Polyakov. 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/__ufw/manifest b/cdist/conf/type/__ufw/manifest new file mode 100755 index 00000000..54309ff5 --- /dev/null +++ b/cdist/conf/type/__ufw/manifest @@ -0,0 +1,67 @@ +#!/bin/sh -e +# +# 2019 Mark Polyakov (mark--@--markasoftware.com) +# +# This file is part of cdist. +# +# cdist is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# cdist is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with cdist. If not, see . +# + +state="$(cat "$__object/parameter/state")" + +case "$state" in + present|enabled) + os="$(cat "$__global/explorer/os")" + + case "$os" in + centos) + # shellcheck source=/dev/null + if (. "$__global/explorer/os_release" && [ "${VERSION_ID}" = "7" ]); then + __package epel-release + require='__package/epel-release' __package ufw + else + echo 'CentOS version 7 is required!' + exit 1 + fi + ;; + *) + __package ufw + ;; + esac + + # ufw expects to always be enabled, then uses a switch in /etc to + # determine whether to "actually start" after the init system calls it. + # So, we have to both enable on bootup through init and run `ufw enable` + + # operators ae left-associative, so if !enabled it will never run + if [ "$(cat "$__global/explorer/os")" != ubuntu ] || \ + [ "$(cat "$__global/explorer/init")" != init ] && \ + [ "$state" = enabled ]; then + # Why don't we disable start_on_boot when state=present|absent? + # Because UFW should always be enabled at boot -- /etc/ufw/ufw.conf + # will stop it from "really" starting + require='__package/ufw' __start_on_boot ufw + fi + ;; + + absent) + __package ufw --state absent + ;; + + *) + echo 'State must be "enabled", "present", or "absent".' + exit 1 + ;; +esac + diff --git a/cdist/conf/type/__ufw/parameter/default/state b/cdist/conf/type/__ufw/parameter/default/state new file mode 100644 index 00000000..26ed6c9b --- /dev/null +++ b/cdist/conf/type/__ufw/parameter/default/state @@ -0,0 +1 @@ +enabled \ No newline at end of file diff --git a/cdist/conf/type/__ufw/parameter/optional b/cdist/conf/type/__ufw/parameter/optional new file mode 100644 index 00000000..0a4dec97 --- /dev/null +++ b/cdist/conf/type/__ufw/parameter/optional @@ -0,0 +1,5 @@ +state +logging +default_incoming +default_outgoing +default_routed \ No newline at end of file diff --git a/cdist/conf/type/__ufw/singleton b/cdist/conf/type/__ufw/singleton new file mode 100644 index 00000000..e69de29b diff --git a/cdist/conf/type/__ufw_rule/gencode-remote b/cdist/conf/type/__ufw_rule/gencode-remote new file mode 100755 index 00000000..4f1bf2c9 --- /dev/null +++ b/cdist/conf/type/__ufw_rule/gencode-remote @@ -0,0 +1,45 @@ +#!/bin/sh -e +# +# 2019 Mark Polyakov (mark@markasoftware.com) +# +# This file is part of cdist. +# +# cdist is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# cdist is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with cdist. If not, see . +# + +# This type does not bother with checking the current state of the rules. +# While it is possible to retrieve the list of rules in a consistent format from +# `ufw status`, it is a completely different format than the one used on the +# command line. I also do not suspect it is any faster. + +ufw='ufw --force rule' + +case "$(cat "$__object/parameter/state")" in + present) ;; + absent) + ufw="$ufw delete" + ;; + *) + echo 'State must be "present" or "absent".' >&2 + exit 1 + ;; +esac + +if [ -f "$__object/parameter/rule" ]; then + ufw="$ufw $(cat "$__object/parameter/rule")" +else + ufw="$ufw allow $__object_id" +fi + +echo "$ufw" diff --git a/cdist/conf/type/__ufw_rule/man.rst b/cdist/conf/type/__ufw_rule/man.rst new file mode 100644 index 00000000..996557f8 --- /dev/null +++ b/cdist/conf/type/__ufw_rule/man.rst @@ -0,0 +1,53 @@ +cdist-type__ufw_rule(7) +======================= + +NAME +---- +cdist-type__ufw_rule - A single UFW rule + + +DESCRIPTION +----------- +Adds or removes a single UFW rule. This type supports adding and deleting rules for port ranges or applications. + +Understanding what is "to" and what is "from" can be confusing. If the rule is ingress (default), then "from" is the remote machine and "to" is the local one. The opposite is true for egress traffic (--out). + +OPTIONAL PARAMETERS +------------------- +state + Either "present" or "absent". Defaults to "present". If "absent", only removes rules that exactly match the rule expected. + +rule + A firewall rule in UFW syntax. This is what you would usually write after `ufw` on the command line. Defaults to "allow" followed by the object ID. You can use either the short syntax (just allow|deny|reject|limit followed by a port or application name) or the full syntax. Do not include `delete` in your command. Set `--state absent` instead. + +EXAMPLES +-------- + +.. code-block:: sh + + # open port 80 (ufw allow 80) + __ufw_rule 80 + # Allow mosh application (if installed) + __ufw_rule mosh + # Allow all traffic from local network (ufw allow from 10.0.0.0/24) + __ufw_rule local --rule 'allow from 10.0.0.0/24' + # Block egress traffic from port 25 to 111.55.55.55 on interface eth0 + __ufw_rule block_smtp --rule 'deny out on eth0 from any port 25 to 111.55.55.55' + + +SEE ALSO +-------- +:strong:`ufw`\ (8) + + +AUTHORS +------- +Mark Polyakov + + +COPYING +------- +Copyright \(C) 2019 Mark Polyakov. 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/__ufw_rule/parameter/default/state b/cdist/conf/type/__ufw_rule/parameter/default/state new file mode 100644 index 00000000..e7f6134f --- /dev/null +++ b/cdist/conf/type/__ufw_rule/parameter/default/state @@ -0,0 +1 @@ +present diff --git a/cdist/conf/type/__ufw_rule/parameter/optional b/cdist/conf/type/__ufw_rule/parameter/optional new file mode 100644 index 00000000..0732d53d --- /dev/null +++ b/cdist/conf/type/__ufw_rule/parameter/optional @@ -0,0 +1,2 @@ +state +rule From 13671c666c5ace5a1401ebdf1edb402981e9b9ce Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Thu, 11 Apr 2019 08:20:52 +0200 Subject: [PATCH 0262/1217] ++changelog --- docs/changelog | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/changelog b/docs/changelog index dc6164f3..40606fb9 100644 --- a/docs/changelog +++ b/docs/changelog @@ -1,6 +1,9 @@ Changelog --------- +next: + * New types: __ufw and __ufw_rule (Mark Polyakov) + 4.10.9: 2019-04-09 * Type __ssh_authorized_keys: Properly handle multiple --option params (Steven Armstrong) * Debugging: Add debug dump helper script (Darko Poljak) From 204a572709054986bc574bf7bf455513cb7bc671 Mon Sep 17 00:00:00 2001 From: Ander Punnar Date: Thu, 11 Apr 2019 13:59:15 +0300 Subject: [PATCH 0263/1217] __link: add messaging --- cdist/conf/type/__link/gencode-remote | 4 ++++ cdist/conf/type/__link/man.rst | 16 ++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/cdist/conf/type/__link/gencode-remote b/cdist/conf/type/__link/gencode-remote index dc7f3193..45c22fcc 100755 --- a/cdist/conf/type/__link/gencode-remote +++ b/cdist/conf/type/__link/gencode-remote @@ -48,21 +48,25 @@ case "$state_should" in if [ "$file_type" = "directory" ]; then # our destination is currently a directory, delete it printf 'rm -rf "%s" &&\n' "$destination" + echo "removed '$destination' (directory)" >> "$__messages_out" else if [ "$state_is" = "wrongsource" ]; then # our destination is a symlink but points to the wrong source, # delete it printf 'rm -f "%s" &&\n' "$destination" + echo "removed '$destination' (wrongsource)" >> "$__messages_out" fi fi # create our link printf 'ln %s -f "%s" "%s"\n' "$lnopt" "$source" "$destination" + echo "created '$destination'" >> "$__messages_out" ;; absent) # only delete if it is a sym/hard link if [ "$file_type" = "symlink" ] || [ "$file_type" = "hardlink" ]; then printf 'rm -f "%s"\n' "$destination" + echo "removed '$destination'" >> "$__messages_out" fi ;; *) diff --git a/cdist/conf/type/__link/man.rst b/cdist/conf/type/__link/man.rst index 9dc4665f..fe0ce425 100644 --- a/cdist/conf/type/__link/man.rst +++ b/cdist/conf/type/__link/man.rst @@ -27,6 +27,22 @@ state 'present' or 'absent', defaults to 'present' +MESSAGES +-------- + +created + Link to destination was created. + +removed + Link to destination was removed. + +removed (directory) + Destination was removed because state is ``present`` and destination was directory. + +removed (wrongsource) + Destination was removed because state is ``present`` and destination link source was wrong. + + EXAMPLES -------- From 540434557dedd51248c7d444ca0fd869bd6a2002 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Thu, 11 Apr 2019 13:43:13 +0200 Subject: [PATCH 0264/1217] ++changelog --- docs/changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog b/docs/changelog index 40606fb9..830d49e0 100644 --- a/docs/changelog +++ b/docs/changelog @@ -2,6 +2,7 @@ Changelog --------- next: + * Type __link: Add messaging (Ander Punnar) * New types: __ufw and __ufw_rule (Mark Polyakov) 4.10.9: 2019-04-09 From d11ac7dda40b10424a765f4aaff7f54821244382 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Thu, 11 Apr 2019 13:52:33 +0200 Subject: [PATCH 0265/1217] Rename debug-dump.sh to cdist-dump --- Makefile | 2 +- docs/changelog | 1 + docs/src/cdist-troubleshooting.rst | 4 ++-- scripts/{debug-dump.sh => cdist-dump} | 0 setup.py | 2 +- 5 files changed, 5 insertions(+), 4 deletions(-) rename scripts/{debug-dump.sh => cdist-dump} (100%) diff --git a/Makefile b/Makefile index 4ed97c7b..5f03997a 100644 --- a/Makefile +++ b/Makefile @@ -275,7 +275,7 @@ shellcheck-remote-gencodes: @find cdist/conf/type -type f -name gencode-remote -exec $(SHELLCHECKCMD) {} + | $(SHELLCHECK_SKIP) || exit 0 shellcheck-scripts: - @$(SHELLCHECKCMD) scripts/debug-dump.sh || exit 0 + @$(SHELLCHECKCMD) scripts/cdist-dump || exit 0 shellcheck-gencodes: shellcheck-local-gencodes shellcheck-remote-gencodes diff --git a/docs/changelog b/docs/changelog index 830d49e0..c06715b7 100644 --- a/docs/changelog +++ b/docs/changelog @@ -2,6 +2,7 @@ Changelog --------- next: + * Debugging: Rename debug-dump.sh to cdist-dump(Darko Poljak) * Type __link: Add messaging (Ander Punnar) * New types: __ufw and __ufw_rule (Mark Polyakov) diff --git a/docs/src/cdist-troubleshooting.rst b/docs/src/cdist-troubleshooting.rst index b76f3859..6b7fb4af 100644 --- a/docs/src/cdist-troubleshooting.rst +++ b/docs/src/cdist-troubleshooting.rst @@ -53,11 +53,11 @@ For more info see: .. code-block:: sh - debug-dump.sh -h + cdist-dump -h Or from cdist git cloned directory: .. code-block:: sh - ./scripts/debug-dump.sh -h + ./scripts/cdist-dump -h diff --git a/scripts/debug-dump.sh b/scripts/cdist-dump similarity index 100% rename from scripts/debug-dump.sh rename to scripts/cdist-dump diff --git a/setup.py b/setup.py index 767f5bf7..d76bbd4b 100644 --- a/setup.py +++ b/setup.py @@ -36,7 +36,7 @@ setup( name="cdist", packages=["cdist", "cdist.core", "cdist.exec", "cdist.util", ], package_data={'cdist': package_data}, - scripts=["scripts/cdist", "scripts/debug-dump.sh"], + scripts=["scripts/cdist", "scripts/cdist-dump"], version=cdist.version.VERSION, description="A Usable Configuration Management System", author="Nico Schottelius", From 7a68df48f185006ec2a9536b272c92e61fa9b692 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Thu, 11 Apr 2019 14:10:18 +0200 Subject: [PATCH 0266/1217] Add missing delimiter argument --- scripts/cdist-dump | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/cdist-dump b/scripts/cdist-dump index ac1190b7..83b09eb8 100755 --- a/scripts/cdist-dump +++ b/scripts/cdist-dump @@ -50,7 +50,7 @@ Options -a dump all -C CACHE-DIR use specified CACHE-DIR (default: ~/.cdist/cache) -c dump code-* - -d delimiter used for filename and line number prefix (default: ':') + -d DELIMITER delimiter used for filename and line number prefix (default: ':') -E dump global explorers -e dump type explorers -F disable filename prefix (enabled by default) From 2ec553b4803095ff05a9cb8f79fdb9c245813a4f Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Thu, 11 Apr 2019 14:30:23 +0200 Subject: [PATCH 0267/1217] Add cdist-dump man page --- docs/changelog | 5 +- docs/src/index.rst | 1 + docs/src/man1/cdist-dump.rst | 110 +++++++++++++++++++++++++++++++++++ 3 files changed, 114 insertions(+), 2 deletions(-) create mode 100644 docs/src/man1/cdist-dump.rst diff --git a/docs/changelog b/docs/changelog index c06715b7..e670ef49 100644 --- a/docs/changelog +++ b/docs/changelog @@ -2,9 +2,10 @@ Changelog --------- next: - * Debugging: Rename debug-dump.sh to cdist-dump(Darko Poljak) - * Type __link: Add messaging (Ander Punnar) * New types: __ufw and __ufw_rule (Mark Polyakov) + * Type __link: Add messaging (Ander Punnar) + * Debugging: Rename debug-dump.sh to cdist-dump (Darko Poljak) + * Documentation: Add cdist-dump man page (Darko Poljak) 4.10.9: 2019-04-09 * Type __ssh_authorized_keys: Properly handle multiple --option params (Steven Armstrong) diff --git a/docs/src/index.rst b/docs/src/index.rst index bef91e1c..af303f5b 100644 --- a/docs/src/index.rst +++ b/docs/src/index.rst @@ -18,6 +18,7 @@ Contents: cdist-quickstart cdist-real-world man1/cdist + man1/cdist-dump cdist-bootstrap cdist-configuration cdist-manifest diff --git a/docs/src/man1/cdist-dump.rst b/docs/src/man1/cdist-dump.rst new file mode 100644 index 00000000..907cd192 --- /dev/null +++ b/docs/src/man1/cdist-dump.rst @@ -0,0 +1,110 @@ +cdist-dump(1) +============= + +NAME +---- +cdist-dump - Dump data from local cdist cache + + +SYNOPSIS +-------- + +:: + + cdist-dump [options] [host...] + + + +DESCRIPTION +----------- +cdist-dump is a helper script that dumps data from local cdist cache for +specified hosts. If host is not specified then all data from cache directory +is dumped. Default cache directory is '~/.cdist/cache'. + +cdist-dump can be used for debugging existing types, host configuration and +new types. + + +OPTIONS +------- +**-a** + dump all + +**-C CACHE-DIR** + use specified CACHE-DIR (default: ~/.cdist/cache) + +**-c** + dump code-* + +**-d DELIMITER** + delimiter used for filename and line number prefix (default: ':') + +**-E** + dump global explorers + +**-e** + dump type explorers + +**-F** + disable filename prefix (enabled by default) + +**-f** + enable filename prefix (default) + +**-g** + dump gencode-* + +**-h** + show this help screen and exit + +**-L** + disable line number prefix (default) + +**-l** + enable line number prefix (disabled by default) + +**-m** + dump messages + +**-o** + dump executions' stdout + +**-p** + dump parameters + +**-r** + dump executions' stderr + +**-V** + show version and exit + +**-v** + increase verbosity + + +EXAMPLES +-------- + +.. code-block:: sh + + # Dump all + % cdist-dump -a + + # Dump only code-* output + % cdist-dump -c + + +SEE ALSO +-------- +:strong:`cdist`\ (1) + + +AUTHORS +------- +Darko Poljak + + +COPYING +------- +Copyright \(C) 2019 Darko Poljak. Free use of this software is +granted under the terms of the GNU General Public License v3 or later (GPLv3+). From a4ed9e4d0ebccdcaac05cd4f6328b56dd1633ffc Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Thu, 11 Apr 2019 14:46:56 +0200 Subject: [PATCH 0268/1217] Release 4.10.10 --- docs/changelog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/changelog b/docs/changelog index e670ef49..67851747 100644 --- a/docs/changelog +++ b/docs/changelog @@ -1,7 +1,7 @@ Changelog --------- -next: +4.10.10: 2019-04-11 * New types: __ufw and __ufw_rule (Mark Polyakov) * Type __link: Add messaging (Ander Punnar) * Debugging: Rename debug-dump.sh to cdist-dump (Darko Poljak) From 279aada5db4b01f8937dcf193012981cbe0b3aa5 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Fri, 12 Apr 2019 09:13:25 +0200 Subject: [PATCH 0269/1217] Fix broken quiet mode Resolves #754 --- cdist/exec/remote.py | 1 + docs/changelog | 3 +++ 2 files changed, 4 insertions(+) diff --git a/cdist/exec/remote.py b/cdist/exec/remote.py index 9e3e279e..e0ef66ec 100644 --- a/cdist/exec/remote.py +++ b/cdist/exec/remote.py @@ -304,6 +304,7 @@ class Remote(object): try: if self.quiet_mode: stderr = subprocess.DEVNULL + close_stderr = False if return_output: output = subprocess.check_output(command, env=os_environ, stderr=stderr).decode() diff --git a/docs/changelog b/docs/changelog index 67851747..fccf2583 100644 --- a/docs/changelog +++ b/docs/changelog @@ -1,6 +1,9 @@ Changelog --------- +next: + * Core: Fix broken quiet mode (Darko Poljak) + 4.10.10: 2019-04-11 * New types: __ufw and __ufw_rule (Mark Polyakov) * Type __link: Add messaging (Ander Punnar) From 20a16fe8539842e9931a9180d93dda6996631d60 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Fri, 12 Apr 2019 19:58:43 +0200 Subject: [PATCH 0270/1217] Add version.py into generated raw source archive Resolves #751 --- bin/build-helper | 9 +++++++-- bin/build-helper.freebsd | 9 +++++++-- docs/changelog | 1 + 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/bin/build-helper b/bin/build-helper index 2179a5ed..de4ced71 100755 --- a/bin/build-helper +++ b/bin/build-helper @@ -195,9 +195,14 @@ eof then archivename="$3" else - archivename="cdist-${tag}.tar.gz" + archivename="cdist-${tag}.tar" git archive --prefix="cdist-${tag}/" -o "${archivename}" "${tag}" \ || exit 1 + # make sure target version is generated + "$0" target-version + tar -r -f "${archivename}" cdist/version.py || exit 1 + gzip "${archivename}" || exit 1 + archivename="${archivename}.gz" fi gpg --armor --detach-sign "${archivename}" || exit 1 @@ -232,7 +237,7 @@ eof || exit 1 # remove generated files (archive and asc) - if [ $# -eq 2] + if [ $# -eq 2 ] then rm -f "${archivename}" fi diff --git a/bin/build-helper.freebsd b/bin/build-helper.freebsd index a2b8dde7..2c5a54a7 100755 --- a/bin/build-helper.freebsd +++ b/bin/build-helper.freebsd @@ -230,9 +230,14 @@ eof then archivename="$3" else - archivename="cdist-${tag}.tar.gz" + archivename="cdist-${tag}.tar" git archive --prefix="cdist-${tag}/" -o "${archivename}" "${tag}" \ || exit 1 + # make sure target version is generated + "$0" target-version + tar -r -f "${archivename}" cdist/version.py || exit 1 + gzip "${archivename}" || exit 1 + archivename="${archivename}.gz" fi gpg --armor --detach-sign "${archivename}" || exit 1 @@ -267,7 +272,7 @@ eof || exit 1 # remove generated files (archive and asc) - if [ $# -eq 2] + if [ $# -eq 2 ] then rm -f "${archivename}" fi diff --git a/docs/changelog b/docs/changelog index fccf2583..3bb5f03d 100644 --- a/docs/changelog +++ b/docs/changelog @@ -3,6 +3,7 @@ Changelog next: * Core: Fix broken quiet mode (Darko Poljak) + * Build: Add version.py into generated raw source archive (Darko Poljak) 4.10.10: 2019-04-11 * New types: __ufw and __ufw_rule (Mark Polyakov) From 1c152f0acbf2f7531fd4c129b04a1658654aa05e Mon Sep 17 00:00:00 2001 From: Ander Punnar <4ND3R@users.noreply.github.com> Date: Fri, 12 Apr 2019 21:41:05 +0300 Subject: [PATCH 0271/1217] fix disks explorer (#753) * fix disks explorer * fix SC2230 * exclude floppies * update comment about excluded floppies * add link to linux documentation about device majors * try to support netbsd * update possible netbsd disk devices --- cdist/conf/explorer/disks | 34 ++++++++++++++++++++++++---------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/cdist/conf/explorer/disks b/cdist/conf/explorer/disks index 1780e6d2..405a273a 100755 --- a/cdist/conf/explorer/disks +++ b/cdist/conf/explorer/disks @@ -1,16 +1,30 @@ #!/bin/sh -e -os=$("$__explorer/os") -case "$os" in - openbsd) - IFS=',' disks=$(sysctl -n hw.disknames) - for d in $disks; do - echo "${d%%:*}" - done | sed -n '/^[sw]d[0-9][0-9]*/p' - ;; +os="$( "$__explorer/os" )" +case "$os" in + freebsd) + sysctl -n kern.disks + ;; + openbsd) + sysctl -n hw.disknames | grep -Eo '[sw]d[0-9]+' | xargs + ;; + netbsd) + sysctl -n hw.disknames | grep -Eo '[lsw]d[0-9]' | xargs + ;; *) - cd /dev || exit 0 - echo sd? hd? vd? + # hopefully everything else is linux + if command -v lsblk > /dev/null + then + # exclude ram disks, floppies and cdroms + # https://www.kernel.org/doc/Documentation/admin-guide/devices.txt + lsblk -e 1,2,11 -dno name | xargs + else + # fallback + find /dev \ + -type b \ + -regex '/dev/\(hd\|sd\|vd\)[a-z]+' \ + -printf '%f ' + fi ;; esac From 4c8037764a3dd6b19548c4fbab8bcb9979bf65fd Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Fri, 12 Apr 2019 20:41:11 +0200 Subject: [PATCH 0272/1217] ++changelog --- docs/changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog b/docs/changelog index 3bb5f03d..7a89dd75 100644 --- a/docs/changelog +++ b/docs/changelog @@ -4,6 +4,7 @@ Changelog next: * Core: Fix broken quiet mode (Darko Poljak) * Build: Add version.py into generated raw source archive (Darko Poljak) + * Explorer disks: Fix detecting disks, fix/add support for BSDs (Ander Punnar) 4.10.10: 2019-04-11 * New types: __ufw and __ufw_rule (Mark Polyakov) From 44c9d09383ca8b3d9fc54fe6574e6fde65e30d83 Mon Sep 17 00:00:00 2001 From: Ander Punnar Date: Fri, 12 Apr 2019 16:03:38 +0300 Subject: [PATCH 0273/1217] fix __(file|directory)/explorer/stat for BSDs --- cdist/conf/type/__directory/explorer/stat | 16 ++++------------ cdist/conf/type/__file/explorer/stat | 16 +++------------- 2 files changed, 7 insertions(+), 25 deletions(-) diff --git a/cdist/conf/type/__directory/explorer/stat b/cdist/conf/type/__directory/explorer/stat index 41bc8b04..3d150a21 100755 --- a/cdist/conf/type/__directory/explorer/stat +++ b/cdist/conf/type/__directory/explorer/stat @@ -25,21 +25,13 @@ destination="/$__object_id" os=$("$__explorer/os") case "$os" in - "freebsd"|"netbsd"|"openbsd") - # FIXME: should be something like this based on man page, but can not test - stat -f "type: %ST + "freebsd"|"netbsd"|"openbsd"|"macosx") + stat -f "type: %HT owner: %Du %Su group: %Dg %Sg -mode: %Op %Sp -" "$destination" +mode: %Lp %Sp +" "$destination" | awk '/^type/ { print tolower($0); next; } { print; }' ;; - "macosx") - stat -f "type: %HT - owner: %Du %Su - group: %Dg %Sg - mode: %Lp %Sp - " "$destination" - ;; *) stat --printf="type: %F owner: %u %U diff --git a/cdist/conf/type/__file/explorer/stat b/cdist/conf/type/__file/explorer/stat index 8a917556..fec0d6f3 100755 --- a/cdist/conf/type/__file/explorer/stat +++ b/cdist/conf/type/__file/explorer/stat @@ -25,24 +25,14 @@ destination="/$__object_id" os=$("$__explorer/os") case "$os" in - "freebsd"|"netbsd"|"openbsd") - # FIXME: should be something like this based on man page, but can not test - stat -f "type: %ST -owner: %Du %Su -group: %Dg %Sg -mode: %Op %Sp -size: %Dz -links: %Dl -" "$destination" - ;; - "macosx") - stat -f "type: %HT + "freebsd"|"netbsd"|"openbsd"|"macosx") + stat -f "type: %HT owner: %Du %Su group: %Dg %Sg mode: %Lp %Sp size: %Dz links: %Dl -" "$destination" +" "$destination" | awk '/^type/ { print tolower($0); next; } { print; }' ;; *) stat --printf="type: %F From 4d9a8d78f7cac887e8589e05aba511941db85117 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Sat, 13 Apr 2019 19:50:44 +0200 Subject: [PATCH 0274/1217] ++changelog --- docs/changelog | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/changelog b/docs/changelog index 7a89dd75..202fa00c 100644 --- a/docs/changelog +++ b/docs/changelog @@ -5,6 +5,8 @@ next: * Core: Fix broken quiet mode (Darko Poljak) * Build: Add version.py into generated raw source archive (Darko Poljak) * Explorer disks: Fix detecting disks, fix/add support for BSDs (Ander Punnar) + * Type __file: Fix stat explorer for BSDs (Ander Punnar) + * Type __directory: Fix stat explorer for BSDs (Ander Punnar) 4.10.10: 2019-04-11 * New types: __ufw and __ufw_rule (Mark Polyakov) From b37b25f57332aaf9fd91b09503a3e88cf213a6fc Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Sat, 13 Apr 2019 19:53:54 +0200 Subject: [PATCH 0275/1217] Release 4.10.11 --- docs/changelog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/changelog b/docs/changelog index 202fa00c..84c59d98 100644 --- a/docs/changelog +++ b/docs/changelog @@ -1,7 +1,7 @@ Changelog --------- -next: +4.10.11: 2019-04-13 * Core: Fix broken quiet mode (Darko Poljak) * Build: Add version.py into generated raw source archive (Darko Poljak) * Explorer disks: Fix detecting disks, fix/add support for BSDs (Ander Punnar) From 51e650423e1075d3a49816c31a6fefee5896517b Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Sat, 13 Apr 2019 20:43:11 +0200 Subject: [PATCH 0276/1217] Fix version.py location inside raw source archive Note that this fix only matters for maintainers using build-helper script. Source archive is generated during release process and uploaded to github, along its signature. For 4.10.11 those files were fixed and uploaded manually after build-helper script process has been finished. In future releases this process will be automatic - no need for manual step that was necessary for 4.10.11. --- bin/build-helper | 5 ++++- bin/build-helper.freebsd | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/bin/build-helper b/bin/build-helper index de4ced71..963f02f9 100755 --- a/bin/build-helper +++ b/bin/build-helper @@ -200,7 +200,10 @@ eof || exit 1 # make sure target version is generated "$0" target-version - tar -r -f "${archivename}" cdist/version.py || exit 1 + tar -x -f "${archivename}" || exit 1 + cp cdist/version.py "cdist-${tag}/cdist/version.py" || exit 1 + tar -c -f "${archivename}" "cdist-${tag}/" || exit 1 + rm -r -f "cdist-${tag}/" gzip "${archivename}" || exit 1 archivename="${archivename}.gz" fi diff --git a/bin/build-helper.freebsd b/bin/build-helper.freebsd index 2c5a54a7..58d985a6 100755 --- a/bin/build-helper.freebsd +++ b/bin/build-helper.freebsd @@ -235,7 +235,10 @@ eof || exit 1 # make sure target version is generated "$0" target-version - tar -r -f "${archivename}" cdist/version.py || exit 1 + tar -x -f "${archivename}" || exit 1 + cp cdist/version.py "cdist-${tag}/cdist/version.py" || exit 1 + tar -c -f "${archivename}" "cdist-${tag}/" || exit 1 + rm -r -f "cdist-${tag}/" gzip "${archivename}" || exit 1 archivename="${archivename}.gz" fi From d18584b4ffd29e295042b0498953ba622adccfd0 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Sat, 13 Apr 2019 20:54:59 +0200 Subject: [PATCH 0277/1217] Update gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 320d150d..460bbf28 100644 --- a/.gitignore +++ b/.gitignore @@ -43,6 +43,7 @@ _build/ docs/dist # Ignore temp files used for signing +cdist-*.tar cdist-*.tar.gz cdist-*.tar.gz.asc From 797522f91eb3e9d928ae26d2e1b78eeb0f02f467 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Sun, 14 Apr 2019 16:54:59 +0200 Subject: [PATCH 0278/1217] Fix circular dep for CDIST_ORDER_DEPENDENCY Fixes #756 --- cdist/emulator.py | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/cdist/emulator.py b/cdist/emulator.py index 65d044d7..5103f1a4 100644 --- a/cdist/emulator.py +++ b/cdist/emulator.py @@ -283,7 +283,8 @@ class Emulator(object): self.object_source))) raise - self.log.debug("Recording requirement: %s", requirement) + self.log.debug("Recording requirement %s for %s", + requirement, self.cdist_object.name) # Save the sanitised version, not the user supplied one # (__file//bar => __file/bar) @@ -305,13 +306,26 @@ class Emulator(object): # get the type created before this one ... try: lastcreatedtype = typecreationorder[-2].strip() - if 'require' in self.env: - self.env['require'] += " " + lastcreatedtype + # __object_name is the name of the object whose type + # manifest is currently executed + __object_name = self.env.get('__object_name', None) + if lastcreatedtype == __object_name: + self.log.debug(("Not injecting require for " + "CDIST_ORDER_DEPENDENCY: %s for %s," + " %s's type manifest is currently" + " being executed"), + lastcreatedtype, + self.cdist_object.name, + lastcreatedtype) else: - self.env['require'] = lastcreatedtype - self.log.debug(("Injecting require for " - "CDIST_ORDER_DEPENDENCY: %s for %s"), - lastcreatedtype, self.cdist_object.name) + if 'require' in self.env: + self.env['require'] += " " + lastcreatedtype + else: + self.env['require'] = lastcreatedtype + self.log.debug(("Injecting require for " + "CDIST_ORDER_DEPENDENCY: %s for %s"), + lastcreatedtype, + self.cdist_object.name) except IndexError: # if no second last line, we are on the first type, # so do not set a requirement @@ -360,4 +374,6 @@ class Emulator(object): # But only if the user hasn't said otherwise. # Must prevent circular dependencies. if parent.name not in current_object.requirements: + self.log.debug("Recording autorequirement %s for %s", + current_object.name, parent.name) parent.autorequire.append(current_object.name) From 3a2041019b5e878a0c81ef78dd719d10db48a6f6 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 15 Apr 2019 16:11:58 +0200 Subject: [PATCH 0279/1217] [alpine] add support for alpine in __package and __package_apk --- cdist/conf/type/__package/manifest | 2 + cdist/conf/type/__package_apk/explorer/state | 36 ++++++++++++ cdist/conf/type/__package_apk/gencode-remote | 49 +++++++++++++++++ cdist/conf/type/__package_apk/man.rst | 55 +++++++++++++++++++ cdist/conf/type/__package_apk/nonparallel | 0 .../__package_apk/parameter/default/state | 1 + .../type/__package_apk/parameter/optional | 2 + 7 files changed, 145 insertions(+) create mode 100755 cdist/conf/type/__package_apk/explorer/state create mode 100755 cdist/conf/type/__package_apk/gencode-remote create mode 100644 cdist/conf/type/__package_apk/man.rst create mode 100644 cdist/conf/type/__package_apk/nonparallel create mode 100644 cdist/conf/type/__package_apk/parameter/default/state create mode 100644 cdist/conf/type/__package_apk/parameter/optional diff --git a/cdist/conf/type/__package/manifest b/cdist/conf/type/__package/manifest index f9de1145..a453c32b 100755 --- a/cdist/conf/type/__package/manifest +++ b/cdist/conf/type/__package/manifest @@ -1,6 +1,7 @@ #!/bin/sh -e # # 2011-2013 Steven Armstrong (steven-cdist at armstrong.cc) +# 2019 Nico Schottelius (nico-cdist at schottelius.org) # # This file is part of cdist. # @@ -44,6 +45,7 @@ else suse) type="zypper" ;; openwrt) type="opkg" ;; openbsd) type="pkg_openbsd" ;; + alpine) type="apk" ;; *) echo "Don't know how to manage packages on: $os" >&2 exit 1 diff --git a/cdist/conf/type/__package_apk/explorer/state b/cdist/conf/type/__package_apk/explorer/state new file mode 100755 index 00000000..3fc405a2 --- /dev/null +++ b/cdist/conf/type/__package_apk/explorer/state @@ -0,0 +1,36 @@ +#!/bin/sh +# +# 2019 Nico Schottelius (nico-cdist at schottelius.org) +# +# This file is part of cdist. +# +# cdist is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# cdist is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with cdist. If not, see . +# +# +# Retrieve the status of a package - parsed dpkg output +# + +if [ -f "$__object/parameter/name" ]; then + name="$(cat "$__object/parameter/name")" +else + name="$__object_id" +fi + +output= + +if [ "$(apk list -I "$name")" ]; then + echo present +else + echo absent +fi diff --git a/cdist/conf/type/__package_apk/gencode-remote b/cdist/conf/type/__package_apk/gencode-remote new file mode 100755 index 00000000..79e3d2b6 --- /dev/null +++ b/cdist/conf/type/__package_apk/gencode-remote @@ -0,0 +1,49 @@ +#!/bin/sh -e +# +# 2019 Nico Schottelius (nico-cdist at schottelius.org) +# +# This file is part of cdist. +# +# cdist is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# cdist is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with cdist. If not, see . +# +# +# Manage packages on Debian and co. +# + +if [ -f "$__object/parameter/name" ]; then + name="$(cat "$__object/parameter/name")" +else + name="$__object_id" +fi + +state_should="$(cat "$__object/parameter/state")" +state_is="$(cat "$__object/explorer/state")" + +# Nothing to be done +[ "$state_is" = "$state_should" ] && exit 0 + +case "$state_should" in + present) + echo "apk add -q '$name'" + echo "installed" >> "$__messages_out" + ;; + absent) + echo "apk del -q '$name'" + echo "removed" >> "$__messages_out" + ;; + *) + echo "Unknown state: $state_should" >&2 + exit 1 + ;; +esac diff --git a/cdist/conf/type/__package_apk/man.rst b/cdist/conf/type/__package_apk/man.rst new file mode 100644 index 00000000..bc2408b4 --- /dev/null +++ b/cdist/conf/type/__package_apk/man.rst @@ -0,0 +1,55 @@ +cdist-type__package_akp(7) +========================== + +NAME +---- +cdist-type__package_akp - Manage packages with akp + + +DESCRIPTION +----------- +apk is usually used on Alpine to manage packages. + + +REQUIRED PARAMETERS +------------------- +None + + +OPTIONAL PARAMETERS +------------------- +name + If supplied, use the name and not the object id as the package name. + +state + Either "present" or "absent", defaults to "present" + + +EXAMPLES +-------- + +.. code-block:: sh + + # Ensure zsh in installed + __package_apk zsh --state present + + # Remove package + __package_apk apache2 --state absent + + +SEE ALSO +-------- +:strong:`cdist-type__package`\ (7) + + +AUTHORS +------- +Nico Schottelius + + +COPYING +------- +Copyright \(C) 2019 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_apk/nonparallel b/cdist/conf/type/__package_apk/nonparallel new file mode 100644 index 00000000..e69de29b diff --git a/cdist/conf/type/__package_apk/parameter/default/state b/cdist/conf/type/__package_apk/parameter/default/state new file mode 100644 index 00000000..e7f6134f --- /dev/null +++ b/cdist/conf/type/__package_apk/parameter/default/state @@ -0,0 +1 @@ +present diff --git a/cdist/conf/type/__package_apk/parameter/optional b/cdist/conf/type/__package_apk/parameter/optional new file mode 100644 index 00000000..1b423dc4 --- /dev/null +++ b/cdist/conf/type/__package_apk/parameter/optional @@ -0,0 +1,2 @@ +name +state From c17f5a7ccde307a16db60224722401a58a69c8c9 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 15 Apr 2019 16:13:25 +0200 Subject: [PATCH 0280/1217] ++changelog --- docs/changelog | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/changelog b/docs/changelog index 7a89dd75..536b99e6 100644 --- a/docs/changelog +++ b/docs/changelog @@ -5,6 +5,8 @@ next: * Core: Fix broken quiet mode (Darko Poljak) * Build: Add version.py into generated raw source archive (Darko Poljak) * Explorer disks: Fix detecting disks, fix/add support for BSDs (Ander Punnar) + * Type __package: Add __package_apk support (Nico Schottelius) + * New type: __package_apk (Nico Schottelius) 4.10.10: 2019-04-11 * New types: __ufw and __ufw_rule (Mark Polyakov) From e32d92c109ac64c9b8b3f48cea007b67ebc3c5c5 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 15 Apr 2019 16:32:54 +0200 Subject: [PATCH 0281/1217] [__start_on_boot] Begin to add alpine support --- cdist/conf/type/__start_on_boot/explorer/state | 5 ++++- cdist/conf/type/__start_on_boot/man.rst | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/cdist/conf/type/__start_on_boot/explorer/state b/cdist/conf/type/__start_on_boot/explorer/state index 19dfc74b..75764979 100644 --- a/cdist/conf/type/__start_on_boot/explorer/state +++ b/cdist/conf/type/__start_on_boot/explorer/state @@ -1,6 +1,6 @@ #!/bin/sh # -# 2012-2015 Nico Schottelius (nico-cdist at schottelius.org) +# 2012-2019 Nico Schottelius (nico-cdist at schottelius.org) # 2013 Daniel Heule (hda at sfs.biz) # # This file is part of cdist. @@ -88,6 +88,9 @@ else # OpenBSD 5.7 and higher rcctl ls on | grep "^${name}$" && state='present' ;; + alpine) + state="absent" + rc-update show | sed 's/ *//' | grep -q "^${name} |" && state="present" *) echo "Unsupported os: $os" >&2 exit 1 diff --git a/cdist/conf/type/__start_on_boot/man.rst b/cdist/conf/type/__start_on_boot/man.rst index 851d1a89..b7c73ab1 100644 --- a/cdist/conf/type/__start_on_boot/man.rst +++ b/cdist/conf/type/__start_on_boot/man.rst @@ -55,7 +55,7 @@ Nico Schottelius COPYING ------- -Copyright \(C) 2012 Nico Schottelius. You can redistribute it +Copyright \(C) 2012-2019 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. From 707426d1f0c513c86019f1e7c7d866fa026619ff Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 15 Apr 2019 16:35:10 +0200 Subject: [PATCH 0282/1217] [__start_on_boot] add code for alpine handling, fix explorer --- cdist/conf/type/__start_on_boot/gencode-remote | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cdist/conf/type/__start_on_boot/gencode-remote b/cdist/conf/type/__start_on_boot/gencode-remote index 1a3b6ff6..56f0dbdb 100755 --- a/cdist/conf/type/__start_on_boot/gencode-remote +++ b/cdist/conf/type/__start_on_boot/gencode-remote @@ -40,6 +40,9 @@ case "$state_should" in echo "systemctl -q enable '$name'" else case "$os" in + alpine) + echo "rc-update -q add '${name}'" + ;; debian) case "$os_version" in [1-7]*) @@ -102,6 +105,9 @@ case "$state_should" in else case "$os" in + alpine) + echo "rc-update -q del '${name}'" + ;; debian|ubuntu|devuan) echo "update-rc.d -f '$name' remove" ;; From dbf29c18c124f4c9b9026180819ec2cfba6c1e16 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 15 Apr 2019 16:41:27 +0200 Subject: [PATCH 0283/1217] [__start_on_boot] alpine fix --- cdist/conf/type/__start_on_boot/explorer/state | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cdist/conf/type/__start_on_boot/explorer/state b/cdist/conf/type/__start_on_boot/explorer/state index 75764979..37f41806 100644 --- a/cdist/conf/type/__start_on_boot/explorer/state +++ b/cdist/conf/type/__start_on_boot/explorer/state @@ -89,8 +89,10 @@ else rcctl ls on | grep "^${name}$" && state='present' ;; alpine) - state="absent" - rc-update show | sed 's/ *//' | grep -q "^${name} |" && state="present" + state="$(rc-update show | sed 's/ *//' | grep -q "^${name} |" && echo present)" + [ "$state" ] || state="absent" + ;; + *) echo "Unsupported os: $os" >&2 exit 1 From ec935353d75a3bfde5f37862668ba18ab0d63181 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 15 Apr 2019 17:02:09 +0200 Subject: [PATCH 0284/1217] [__start_on_boot] Merge alpine and gentoo, update gentoo --- cdist/conf/type/__start_on_boot/explorer/state | 15 ++++++++------- cdist/conf/type/__start_on_boot/gencode-remote | 10 ++-------- docs/changelog | 1 + 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/cdist/conf/type/__start_on_boot/explorer/state b/cdist/conf/type/__start_on_boot/explorer/state index 37f41806..b7a6cf0f 100644 --- a/cdist/conf/type/__start_on_boot/explorer/state +++ b/cdist/conf/type/__start_on_boot/explorer/state @@ -75,9 +75,14 @@ else state=$(chkconfig --check "$name" "$runlevel" || echo absent) [ "$state" ] || state="present" ;; - gentoo) - state="present" - [ -f "/etc/runlevels/${target_runlevel}/${name}" ] || state="absent" + gentoo|alpine) + state="absent" + for d in /etc/runlevels/*; do + if [ -f "/etc/runlevels/${d}/${name}" ];then + state="present" + break + fi + done ;; freebsd) state="absent" @@ -88,10 +93,6 @@ else # OpenBSD 5.7 and higher rcctl ls on | grep "^${name}$" && state='present' ;; - alpine) - state="$(rc-update show | sed 's/ *//' | grep -q "^${name} |" && echo present)" - [ "$state" ] || state="absent" - ;; *) echo "Unsupported os: $os" >&2 diff --git a/cdist/conf/type/__start_on_boot/gencode-remote b/cdist/conf/type/__start_on_boot/gencode-remote index 56f0dbdb..c900933f 100755 --- a/cdist/conf/type/__start_on_boot/gencode-remote +++ b/cdist/conf/type/__start_on_boot/gencode-remote @@ -40,9 +40,6 @@ case "$state_should" in echo "systemctl -q enable '$name'" else case "$os" in - alpine) - echo "rc-update -q add '${name}'" - ;; debian) case "$os_version" in [1-7]*) @@ -61,7 +58,7 @@ case "$state_should" in echo "update-rc.d '$name' defaults >/dev/null" ;; - gentoo) + alpine|gentoo) echo "rc-update add '$name' '$target_runlevel'" ;; @@ -105,14 +102,11 @@ case "$state_should" in else case "$os" in - alpine) - echo "rc-update -q del '${name}'" - ;; debian|ubuntu|devuan) echo "update-rc.d -f '$name' remove" ;; - gentoo) + alpine|gentoo) echo "rc-update del '$name' '$target_runlevel'" ;; diff --git a/docs/changelog b/docs/changelog index da503525..ab239357 100644 --- a/docs/changelog +++ b/docs/changelog @@ -3,6 +3,7 @@ Changelog next: * Type __package: Add __package_apk support (Nico Schottelius) + * Type __start_on_boot: Add alpine support (Nico Schottelius) * New type: __package_apk (Nico Schottelius) 4.10.11: 2019-04-13 From 978aee668ca12be97043026206457847d411ceda Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 15 Apr 2019 17:03:12 +0200 Subject: [PATCH 0285/1217] ++changelog --- docs/changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog b/docs/changelog index ab239357..84507ac4 100644 --- a/docs/changelog +++ b/docs/changelog @@ -4,6 +4,7 @@ Changelog next: * Type __package: Add __package_apk support (Nico Schottelius) * Type __start_on_boot: Add alpine support (Nico Schottelius) + * Type __start_on_boot: gentoo: check all runlevels in explorer (Nico Schottelius) * New type: __package_apk (Nico Schottelius) 4.10.11: 2019-04-13 From 45e9ed441e6271982702e5c0eb25022142c1177a Mon Sep 17 00:00:00 2001 From: Dimitrios Apostolou Date: Mon, 15 Apr 2019 13:04:07 +0200 Subject: [PATCH 0286/1217] Add support for ACL mask. --- cdist/conf/type/__acl/explorer/acl_is | 5 ++++- cdist/conf/type/__acl/gencode-remote | 13 ++++++++++++- cdist/conf/type/__acl/man.rst | 9 ++++++++- cdist/conf/type/__acl/parameter/optional | 1 + 4 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 cdist/conf/type/__acl/parameter/optional diff --git a/cdist/conf/type/__acl/explorer/acl_is b/cdist/conf/type/__acl/explorer/acl_is index 4dc98c51..fbb1be3f 100755 --- a/cdist/conf/type/__acl/explorer/acl_is +++ b/cdist/conf/type/__acl/explorer/acl_is @@ -19,5 +19,8 @@ # if [ -e "/$__object_id" ] -then getfacl "/$__object_id" | grep -E '^((default:|)(user|group)):[a-z]' || true +then + getfacl "/$__object_id" \ + | grep -E '^((default:)?(user|group):[^:]|(default:)?mask::)' \ + || true fi diff --git a/cdist/conf/type/__acl/gencode-remote b/cdist/conf/type/__acl/gencode-remote index a59d49e0..1c1a1b06 100755 --- a/cdist/conf/type/__acl/gencode-remote +++ b/cdist/conf/type/__acl/gencode-remote @@ -37,7 +37,18 @@ do then echo "default:$parameter:$l" fi done < "$__object/parameter/$parameter" -done )" +done +if [ -f "$__object/parameter/mask" ] +then + l=$( cat "$__object/parameter/mask" ) + + echo "mask::$l" + + if [ -f "$__object/parameter/default" ] + then echo "default:mask::$l" + fi +fi +)" setfacl_exec='setfacl' diff --git a/cdist/conf/type/__acl/man.rst b/cdist/conf/type/__acl/man.rst index 39db4d75..c10ee1a0 100644 --- a/cdist/conf/type/__acl/man.rst +++ b/cdist/conf/type/__acl/man.rst @@ -13,6 +13,12 @@ ACL must be defined as 3-symbol combination, using `r`, `w`, `x` and `-`. See setfacl(1) and acl(5) for more details. +OPTIONAL PARAMETERS +------------------- +mask + Add mask ACL entry. + + OPTIONAL MULTIPLE PARAMETERS ---------------------------- user @@ -46,7 +52,8 @@ EXAMPLES --user alice:rwx \ --user bob:r-x \ --group project-group:rwx \ - --group some-other-group:r-x + --group some-other-group:r-x \ + --mask r-x AUTHORS diff --git a/cdist/conf/type/__acl/parameter/optional b/cdist/conf/type/__acl/parameter/optional new file mode 100644 index 00000000..bb4fcf2b --- /dev/null +++ b/cdist/conf/type/__acl/parameter/optional @@ -0,0 +1 @@ +mask From 6062e3557c3e359320c386c356405dd98fbdd5f6 Mon Sep 17 00:00:00 2001 From: Dimitrios Apostolou Date: Mon, 15 Apr 2019 16:32:11 +0200 Subject: [PATCH 0287/1217] Output of grep should be quiet, as we care only for the exit code. --- cdist/conf/type/__acl/gencode-remote | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cdist/conf/type/__acl/gencode-remote b/cdist/conf/type/__acl/gencode-remote index 1c1a1b06..8ab7b566 100755 --- a/cdist/conf/type/__acl/gencode-remote +++ b/cdist/conf/type/__acl/gencode-remote @@ -54,7 +54,7 @@ setfacl_exec='setfacl' if [ -f "$__object/parameter/recursive" ] then - if echo "$os" | grep -E 'macosx|netbsd|freebsd|openbsd' + if echo "$os" | grep -Eq 'macosx|netbsd|freebsd|openbsd' then echo "$os setfacl do not support recursive operations" >&2 else @@ -64,7 +64,7 @@ fi if [ -f "$__object/parameter/remove" ] then - if echo "$os" | grep 'solaris' + if echo "$os" | grep -Fq 'solaris' then # Solaris setfacl behaves differently. # We will not support Solaris for now, because no way to test it. From c801fb4965b6aa7726c5b20cd3db3b02712759b2 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 15 Apr 2019 18:44:30 +0200 Subject: [PATCH 0288/1217] [timezone] + alpine support --- cdist/conf/type/__timezone/gencode-remote | 3 ++- cdist/conf/type/__timezone/manifest | 4 ++-- docs/changelog | 1 + 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/cdist/conf/type/__timezone/gencode-remote b/cdist/conf/type/__timezone/gencode-remote index 1f3f0196..5299f548 100755 --- a/cdist/conf/type/__timezone/gencode-remote +++ b/cdist/conf/type/__timezone/gencode-remote @@ -1,6 +1,7 @@ #!/bin/sh -e # # 2012 Steven Armstrong (steven-cdist at armstrong.cc) +# 2019 Nico Schottelius (nico-cdist at schottelius.org) # # This file is part of cdist. # @@ -29,7 +30,7 @@ if [ "$timezone_is" = "$timezone_should" ]; then fi case "$os" in - ubuntu|debian|devuan|coreos) + ubuntu|debian|devuan|coreos|alpine) echo "echo \"$timezone_should\" > /etc/timezone" ;; esac diff --git a/cdist/conf/type/__timezone/manifest b/cdist/conf/type/__timezone/manifest index c908f087..3d28ccba 100755 --- a/cdist/conf/type/__timezone/manifest +++ b/cdist/conf/type/__timezone/manifest @@ -2,7 +2,7 @@ # # 2011 Ramon Salvadó (rsalvado at gnuine dot com) # 2012-2015 Steven Armstrong (steven-cdist at armstrong.cc) -# 2012 Nico Schottelius (nico-cdist at schottelius.org) +# 2012-2019 Nico Schottelius (nico-cdist at schottelius.org) # # This file is part of cdist. # @@ -26,7 +26,7 @@ timezone="$__object_id" os=$(cat "$__global/explorer/os") case "$os" in - archlinux|debian|ubuntu|devuan) + archlinux|debian|ubuntu|devuan|alpine) __package tzdata export require="__package/tzdata" ;; diff --git a/docs/changelog b/docs/changelog index 84507ac4..2df98118 100644 --- a/docs/changelog +++ b/docs/changelog @@ -4,6 +4,7 @@ Changelog next: * Type __package: Add __package_apk support (Nico Schottelius) * Type __start_on_boot: Add alpine support (Nico Schottelius) + * Type __timezone: Add alpine support (Nico Schottelius) * Type __start_on_boot: gentoo: check all runlevels in explorer (Nico Schottelius) * New type: __package_apk (Nico Schottelius) From f4db6e908efa8b3c79cc6a5f937a148c4d886341 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 15 Apr 2019 18:48:49 +0200 Subject: [PATCH 0289/1217] [hostname] add alpine support --- cdist/conf/type/__hostname/gencode-remote | 4 ++-- cdist/conf/type/__hostname/manifest | 2 +- docs/changelog | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/cdist/conf/type/__hostname/gencode-remote b/cdist/conf/type/__hostname/gencode-remote index 33947f7f..8b5797dd 100755 --- a/cdist/conf/type/__hostname/gencode-remote +++ b/cdist/conf/type/__hostname/gencode-remote @@ -35,7 +35,7 @@ has_hostnamectl=$(cat "$__object/explorer/has_hostnamectl") # If everything is ok -> exit # case "$os" in - archlinux|debian|suse|ubuntu|devuan|coreos) + archlinux|debian|suse|ubuntu|devuan|coreos|alpine) if [ "$name_config" = "$name_should" ] && [ "$name_running" = "$name_should" ]; then exit 0 fi @@ -58,7 +58,7 @@ echo changed >> "$__messages_out" # Use the good old way to set the hostname even on machines running systemd. case "$os" in - archlinux|debian|ubuntu|devuan|centos|coreos) + archlinux|debian|ubuntu|devuan|centos|coreos|alpine) printf "printf '%%s\\\\n' '$name_should' > /etc/hostname\\n" echo "hostname -F /etc/hostname" ;; diff --git a/cdist/conf/type/__hostname/manifest b/cdist/conf/type/__hostname/manifest index c03b2eac..8f1adf12 100755 --- a/cdist/conf/type/__hostname/manifest +++ b/cdist/conf/type/__hostname/manifest @@ -41,7 +41,7 @@ not_supported() { } case "$os" in - archlinux|debian|suse|ubuntu|devuan|coreos) + archlinux|debian|suse|ubuntu|devuan|coreos|alpine) # handled in gencode-remote : ;; diff --git a/docs/changelog b/docs/changelog index 2df98118..55800f25 100644 --- a/docs/changelog +++ b/docs/changelog @@ -5,6 +5,7 @@ next: * Type __package: Add __package_apk support (Nico Schottelius) * Type __start_on_boot: Add alpine support (Nico Schottelius) * Type __timezone: Add alpine support (Nico Schottelius) + * Type __hostname: Add alpine support (Nico Schottelius) * Type __start_on_boot: gentoo: check all runlevels in explorer (Nico Schottelius) * New type: __package_apk (Nico Schottelius) From e290733a00dbf2e6f743f8fce8318b5518f523a1 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 15 Apr 2019 18:54:30 +0200 Subject: [PATCH 0290/1217] [locale] Add alpine support --- cdist/conf/type/__locale/gencode-remote | 2 +- cdist/conf/type/__locale/man.rst | 5 +++-- cdist/conf/type/__locale/manifest | 6 +++--- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/cdist/conf/type/__locale/gencode-remote b/cdist/conf/type/__locale/gencode-remote index 04e48712..db939a2a 100755 --- a/cdist/conf/type/__locale/gencode-remote +++ b/cdist/conf/type/__locale/gencode-remote @@ -1,6 +1,6 @@ #!/bin/sh -e # -# 2013 Nico Schottelius (nico-cdist at schottelius.org) +# 2013-2019 Nico Schottelius (nico-cdist at schottelius.org) # # This file is part of cdist. # diff --git a/cdist/conf/type/__locale/man.rst b/cdist/conf/type/__locale/man.rst index 60a4eacc..e36ab061 100644 --- a/cdist/conf/type/__locale/man.rst +++ b/cdist/conf/type/__locale/man.rst @@ -8,7 +8,8 @@ cdist-type__locale - Configure locales DESCRIPTION ----------- -This cdist type allows you to setup locales. +This cdist type allows you to setup locales. On systems that don't +support locale setting like alpine/musl libc, it is a no-op. OPTIONAL PARAMETERS @@ -44,6 +45,6 @@ Nico Schottelius COPYING ------- -Copyright \(C) 2013-2016 Nico Schottelius. Free use of this software is +Copyright \(C) 2013-2019 Nico Schottelius. 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/__locale/manifest b/cdist/conf/type/__locale/manifest index cacd0b42..9f1e17ac 100755 --- a/cdist/conf/type/__locale/manifest +++ b/cdist/conf/type/__locale/manifest @@ -1,6 +1,6 @@ #!/bin/sh -e # -# 2013-2015 Nico Schottelius (nico-cdist at schottelius.org) +# 2013-2019 Nico Schottelius (nico-cdist at schottelius.org) # 2015 David Hürlimann (david at ungleich.ch) # # This file is part of cdist. @@ -19,7 +19,7 @@ # along with cdist. If not, see . # # -# Install required packages +# Install required packages # os=$(cat "$__global/explorer/os") @@ -30,7 +30,7 @@ case "$os" in # Debian needs a seperate package __package locales --state present ;; - archlinux|suse|ubuntu|scientific|centos) + archlinux|suse|ubuntu|scientific|centos|alpine) : ;; *) From a1cb9ee869f3eea117a2cfb8c16903eac5690e5c Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 15 Apr 2019 18:56:51 +0200 Subject: [PATCH 0291/1217] [locale/alpine] exit 0 in gencode-remote --- cdist/conf/type/__locale/gencode-remote | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/cdist/conf/type/__locale/gencode-remote b/cdist/conf/type/__locale/gencode-remote index db939a2a..1feb9884 100755 --- a/cdist/conf/type/__locale/gencode-remote +++ b/cdist/conf/type/__locale/gencode-remote @@ -37,6 +37,15 @@ locale_remove=$(echo "$locale" | sed 's/UTF-8/utf8/') state=$(cat "$__object/parameter/state") +os=$(cat "$__global/explorer/os") + +# Nothing to be done on alpine +case "$os" in + alpine) + exit 0 + ;; +esac + case "$state" in present) echo localedef -A "$alias" -f "$charmap" -i "$input" "$locale" From 1722fced721e7e61f0b1b3748a3f253502e62574 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 15 Apr 2019 19:13:44 +0200 Subject: [PATCH 0292/1217] [file] add alpine support --- cdist/conf/type/__file/explorer/stat | 15 +++++++++++++-- docs/changelog | 4 +++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/cdist/conf/type/__file/explorer/stat b/cdist/conf/type/__file/explorer/stat index fec0d6f3..a0f35dcc 100755 --- a/cdist/conf/type/__file/explorer/stat +++ b/cdist/conf/type/__file/explorer/stat @@ -1,6 +1,7 @@ #!/bin/sh # # 2013 Steven Armstrong (steven-cdist armstrong.cc) +# 2019 Nico Schottelius (nico-cdist at schottelius.org) # # This file is part of cdist. # @@ -33,7 +34,17 @@ mode: %Lp %Sp size: %Dz links: %Dl " "$destination" | awk '/^type/ { print tolower($0); next; } { print; }' - ;; + ;; + alpine) + # busybox stat + stat -c "type: %F +owner: %u %U +group: %g %G +mode: %a %A +size: %s +links: %h +" "$destination" + ;; *) stat --printf="type: %F owner: %u %U @@ -42,5 +53,5 @@ mode: %a %A size: %s links: %h " "$destination" - ;; + ;; esac diff --git a/docs/changelog b/docs/changelog index 55800f25..a6ad0749 100644 --- a/docs/changelog +++ b/docs/changelog @@ -3,9 +3,11 @@ Changelog next: * Type __package: Add __package_apk support (Nico Schottelius) + * Type __file: Add alpine support (Nico Schottelius) + * Type __hostname: Add alpine support (Nico Schottelius) + * Type __locale: Add alpine support (Nico Schottelius) * Type __start_on_boot: Add alpine support (Nico Schottelius) * Type __timezone: Add alpine support (Nico Schottelius) - * Type __hostname: Add alpine support (Nico Schottelius) * Type __start_on_boot: gentoo: check all runlevels in explorer (Nico Schottelius) * New type: __package_apk (Nico Schottelius) From 63d7499b755a22319a5e0e85ecf1dea7f1225b57 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 15 Apr 2019 19:27:42 +0200 Subject: [PATCH 0293/1217] [directory] add alpine support --- cdist/conf/type/__directory/explorer/stat | 11 +++++++++-- docs/changelog | 1 + 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/cdist/conf/type/__directory/explorer/stat b/cdist/conf/type/__directory/explorer/stat index 3d150a21..db3c149a 100755 --- a/cdist/conf/type/__directory/explorer/stat +++ b/cdist/conf/type/__directory/explorer/stat @@ -31,9 +31,16 @@ owner: %Du %Su group: %Dg %Sg mode: %Lp %Sp " "$destination" | awk '/^type/ { print tolower($0); next; } { print; }' - ;; + ;; + alpine) + stat -c "type: %F +owner: %u %U +group: %g %G +mode: %a %A +" "$destination" + ;; *) - stat --printf="type: %F + stat --printf="type: %F owner: %u %U group: %g %G mode: %a %A diff --git a/docs/changelog b/docs/changelog index a6ad0749..ab824681 100644 --- a/docs/changelog +++ b/docs/changelog @@ -3,6 +3,7 @@ Changelog next: * Type __package: Add __package_apk support (Nico Schottelius) + * Type __directory: Add alpine support (Nico Schottelius) * Type __file: Add alpine support (Nico Schottelius) * Type __hostname: Add alpine support (Nico Schottelius) * Type __locale: Add alpine support (Nico Schottelius) From 437af3a0a381a70ae85b9784a25e24a1794a9e1c Mon Sep 17 00:00:00 2001 From: Dimitrios Apostolou Date: Mon, 15 Apr 2019 20:51:02 +0200 Subject: [PATCH 0294/1217] Silence getfacl otherwise it always prints the message: getfacl: Removing leading '/' from absolute path names --- cdist/conf/type/__acl/explorer/acl_is | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cdist/conf/type/__acl/explorer/acl_is b/cdist/conf/type/__acl/explorer/acl_is index fbb1be3f..e2ae0932 100755 --- a/cdist/conf/type/__acl/explorer/acl_is +++ b/cdist/conf/type/__acl/explorer/acl_is @@ -20,7 +20,7 @@ if [ -e "/$__object_id" ] then - getfacl "/$__object_id" \ + getfacl "/$__object_id" 2>/dev/null \ | grep -E '^((default:)?(user|group):[^:]|(default:)?mask::)' \ || true fi From e997e98a730a97e224bf8f445adb95b8aea161d2 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Tue, 16 Apr 2019 11:02:51 +0200 Subject: [PATCH 0295/1217] ++changelog --- docs/changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog b/docs/changelog index ab824681..eaa11449 100644 --- a/docs/changelog +++ b/docs/changelog @@ -11,6 +11,7 @@ next: * Type __timezone: Add alpine support (Nico Schottelius) * Type __start_on_boot: gentoo: check all runlevels in explorer (Nico Schottelius) * New type: __package_apk (Nico Schottelius) + * Type __acl: Add support for ACL mask (Dimitrios Apostolou) 4.10.11: 2019-04-13 * Core: Fix broken quiet mode (Darko Poljak) From 2cde09648cc9be18a1d857d994c270ca2e1b52c2 Mon Sep 17 00:00:00 2001 From: Ander Punnar Date: Tue, 16 Apr 2019 14:15:48 +0300 Subject: [PATCH 0296/1217] __acl: check if getfacl is available --- cdist/conf/type/__acl/explorer/acl_is | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cdist/conf/type/__acl/explorer/acl_is b/cdist/conf/type/__acl/explorer/acl_is index e2ae0932..bb1db89d 100755 --- a/cdist/conf/type/__acl/explorer/acl_is +++ b/cdist/conf/type/__acl/explorer/acl_is @@ -18,6 +18,12 @@ # along with cdist. If not, see . # +if ! command -v getfacl 2>/dev/null +then + echo 'getfacl not available' >&2 + exit 1 +fi + if [ -e "/$__object_id" ] then getfacl "/$__object_id" 2>/dev/null \ From d71eb3d8bdbd46848bc9c53b2523be050b083410 Mon Sep 17 00:00:00 2001 From: Ander Punnar Date: Tue, 16 Apr 2019 14:20:13 +0300 Subject: [PATCH 0297/1217] __acl: (open|net)bsd do not have (get|set)facl --- cdist/conf/type/__acl/gencode-remote | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cdist/conf/type/__acl/gencode-remote b/cdist/conf/type/__acl/gencode-remote index 8ab7b566..2ea01524 100755 --- a/cdist/conf/type/__acl/gencode-remote +++ b/cdist/conf/type/__acl/gencode-remote @@ -54,7 +54,7 @@ setfacl_exec='setfacl' if [ -f "$__object/parameter/recursive" ] then - if echo "$os" | grep -Eq 'macosx|netbsd|freebsd|openbsd' + if echo "$os" | grep -Eq 'macosx|freebsd' then echo "$os setfacl do not support recursive operations" >&2 else From ef8ff06b5f20a73c744769aecc047ff7c05e5fbb Mon Sep 17 00:00:00 2001 From: Ander Punnar Date: Tue, 16 Apr 2019 14:39:45 +0300 Subject: [PATCH 0298/1217] __acl: only directories can have default ACLs --- cdist/conf/type/__acl/explorer/file_type | 28 ++++++++++++++++++++++++ cdist/conf/type/__acl/gencode-remote | 8 +++++-- 2 files changed, 34 insertions(+), 2 deletions(-) create mode 100755 cdist/conf/type/__acl/explorer/file_type diff --git a/cdist/conf/type/__acl/explorer/file_type b/cdist/conf/type/__acl/explorer/file_type new file mode 100755 index 00000000..0d1edb7d --- /dev/null +++ b/cdist/conf/type/__acl/explorer/file_type @@ -0,0 +1,28 @@ +#!/bin/sh -e +# +# 2018 Ander Punnar (ander-at-kvlt-dot-ee) +# +# This file is part of cdist. +# +# cdist is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# cdist is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with cdist. If not, see . +# + +if [ -e "/$__object_id" ] +then + if [ -d "/$__object_id" ] + then echo d + elif [ -f "/$__object_id" ] + then echo f + fi +fi diff --git a/cdist/conf/type/__acl/gencode-remote b/cdist/conf/type/__acl/gencode-remote index 2ea01524..355cc88e 100755 --- a/cdist/conf/type/__acl/gencode-remote +++ b/cdist/conf/type/__acl/gencode-remote @@ -20,6 +20,8 @@ os="$( cat "$__global/explorer/os" )" +file_type="$( cat "$__object/explorer/file_type" )" + acl_path="/$__object_id" acl_is="$( cat "$__object/explorer/acl_is" )" @@ -33,7 +35,8 @@ do do echo "$parameter:$l" - if [ -f "$__object/parameter/default" ] + if [ -f "$__object/parameter/default" ] \ + && [ "$file_type" = 'd' ] then echo "default:$parameter:$l" fi done < "$__object/parameter/$parameter" @@ -44,7 +47,8 @@ then echo "mask::$l" - if [ -f "$__object/parameter/default" ] + if [ -f "$__object/parameter/default" ] \ + && [ "$file_type" = 'd' ] then echo "default:mask::$l" fi fi From ab954ffbcf285d3d83b7e61070468afc8cab1610 Mon Sep 17 00:00:00 2001 From: Ander Punnar Date: Tue, 16 Apr 2019 14:44:32 +0300 Subject: [PATCH 0299/1217] __acl: always check first if path exists --- cdist/conf/type/__acl/explorer/acl_is | 13 +++++++------ cdist/conf/type/__acl/explorer/file_type | 15 ++++++++------- cdist/conf/type/__acl/gencode-remote | 6 ++++-- 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/cdist/conf/type/__acl/explorer/acl_is b/cdist/conf/type/__acl/explorer/acl_is index bb1db89d..c5d8468d 100755 --- a/cdist/conf/type/__acl/explorer/acl_is +++ b/cdist/conf/type/__acl/explorer/acl_is @@ -18,15 +18,16 @@ # along with cdist. If not, see . # +acl_path="/$__object_id" + +[ ! -e "$acl_path" ] && exit 0 + if ! command -v getfacl 2>/dev/null then echo 'getfacl not available' >&2 exit 1 fi -if [ -e "/$__object_id" ] -then - getfacl "/$__object_id" 2>/dev/null \ - | grep -E '^((default:)?(user|group):[^:]|(default:)?mask::)' \ - || true -fi +getfacl "$acl_path" 2>/dev/null \ + | grep -E '^((default:)?(user|group):[^:]|(default:)?mask::)' \ + || true diff --git a/cdist/conf/type/__acl/explorer/file_type b/cdist/conf/type/__acl/explorer/file_type index 0d1edb7d..f45e302b 100755 --- a/cdist/conf/type/__acl/explorer/file_type +++ b/cdist/conf/type/__acl/explorer/file_type @@ -18,11 +18,12 @@ # along with cdist. If not, see . # -if [ -e "/$__object_id" ] -then - if [ -d "/$__object_id" ] - then echo d - elif [ -f "/$__object_id" ] - then echo f - fi +acl_path="/$__object_id" + +[ ! -e "$acl_path" ] && exit 0 + +if [ -d "$acl_path" ] +then echo d +elif [ -f "$acl_path" ] +then echo f fi diff --git a/cdist/conf/type/__acl/gencode-remote b/cdist/conf/type/__acl/gencode-remote index 355cc88e..88fc8ce0 100755 --- a/cdist/conf/type/__acl/gencode-remote +++ b/cdist/conf/type/__acl/gencode-remote @@ -18,12 +18,14 @@ # along with cdist. If not, see . # +acl_path="/$__object_id" + +[ ! -e "$acl_path" ] && exit 0 + os="$( cat "$__global/explorer/os" )" file_type="$( cat "$__object/explorer/file_type" )" -acl_path="/$__object_id" - acl_is="$( cat "$__object/explorer/acl_is" )" acl_should="$( for parameter in user group From 2b5887bdbd3229d75da48e32dc7e55b29b6abd54 Mon Sep 17 00:00:00 2001 From: Ander Punnar Date: Tue, 16 Apr 2019 14:51:26 +0300 Subject: [PATCH 0300/1217] __acl: we only care whether file is directory --- cdist/conf/type/__acl/explorer/{file_type => is_dir} | 5 ++--- cdist/conf/type/__acl/gencode-remote | 6 +++--- 2 files changed, 5 insertions(+), 6 deletions(-) rename cdist/conf/type/__acl/explorer/{file_type => is_dir} (94%) diff --git a/cdist/conf/type/__acl/explorer/file_type b/cdist/conf/type/__acl/explorer/is_dir similarity index 94% rename from cdist/conf/type/__acl/explorer/file_type rename to cdist/conf/type/__acl/explorer/is_dir index f45e302b..d3080de6 100755 --- a/cdist/conf/type/__acl/explorer/file_type +++ b/cdist/conf/type/__acl/explorer/is_dir @@ -23,7 +23,6 @@ acl_path="/$__object_id" [ ! -e "$acl_path" ] && exit 0 if [ -d "$acl_path" ] -then echo d -elif [ -f "$acl_path" ] -then echo f +then echo 1 +else echo 0 fi diff --git a/cdist/conf/type/__acl/gencode-remote b/cdist/conf/type/__acl/gencode-remote index 88fc8ce0..a50174fa 100755 --- a/cdist/conf/type/__acl/gencode-remote +++ b/cdist/conf/type/__acl/gencode-remote @@ -24,7 +24,7 @@ acl_path="/$__object_id" os="$( cat "$__global/explorer/os" )" -file_type="$( cat "$__object/explorer/file_type" )" +is_dir="$( cat "$__object/explorer/is_dir" )" acl_is="$( cat "$__object/explorer/acl_is" )" @@ -38,7 +38,7 @@ do echo "$parameter:$l" if [ -f "$__object/parameter/default" ] \ - && [ "$file_type" = 'd' ] + && [ "$is_dir" = '1' ] then echo "default:$parameter:$l" fi done < "$__object/parameter/$parameter" @@ -50,7 +50,7 @@ then echo "mask::$l" if [ -f "$__object/parameter/default" ] \ - && [ "$file_type" = 'd' ] + && [ "$is_dir" = '1' ] then echo "default:mask::$l" fi fi From 9e3cd47b9afa0a13276ca5967d689773111f6990 Mon Sep 17 00:00:00 2001 From: Ander Punnar Date: Tue, 16 Apr 2019 15:03:07 +0300 Subject: [PATCH 0301/1217] __acl: command -v stdout to devnull --- cdist/conf/type/__acl/explorer/acl_is | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cdist/conf/type/__acl/explorer/acl_is b/cdist/conf/type/__acl/explorer/acl_is index c5d8468d..f75f4003 100755 --- a/cdist/conf/type/__acl/explorer/acl_is +++ b/cdist/conf/type/__acl/explorer/acl_is @@ -22,7 +22,7 @@ acl_path="/$__object_id" [ ! -e "$acl_path" ] && exit 0 -if ! command -v getfacl 2>/dev/null +if ! command -v getfacl > /dev/null then echo 'getfacl not available' >&2 exit 1 From 731986ef8b417cdc0284ffd3b43c66a9bd851f55 Mon Sep 17 00:00:00 2001 From: Ander Punnar Date: Tue, 16 Apr 2019 15:21:41 +0300 Subject: [PATCH 0302/1217] __acl: trying to understand X --- cdist/conf/type/__acl/gencode-remote | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/cdist/conf/type/__acl/gencode-remote b/cdist/conf/type/__acl/gencode-remote index a50174fa..651bfce0 100755 --- a/cdist/conf/type/__acl/gencode-remote +++ b/cdist/conf/type/__acl/gencode-remote @@ -35,6 +35,16 @@ do fi while read -r l do + if echo "$l" | grep -Fq 'X' + then + if [ "$is_dir" = '1' ] + then + l="$( echo "$l" | sed 's/X/x/' )" + else + l="$( echo "$l" | sed 's/X/-/' )" + fi + fi + echo "$parameter:$l" if [ -f "$__object/parameter/default" ] \ From cea639d1c901de298818c303202b9332d0f20d1a Mon Sep 17 00:00:00 2001 From: Ander Punnar Date: Tue, 16 Apr 2019 15:27:47 +0300 Subject: [PATCH 0303/1217] __acl: we can't remove mask --- cdist/conf/type/__acl/gencode-remote | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cdist/conf/type/__acl/gencode-remote b/cdist/conf/type/__acl/gencode-remote index 651bfce0..47e39e0a 100755 --- a/cdist/conf/type/__acl/gencode-remote +++ b/cdist/conf/type/__acl/gencode-remote @@ -89,7 +89,8 @@ then else echo "$acl_is" | while read -r acl do - if echo "$acl_should" | grep -Fq "$acl" + if echo "$acl_should" | grep -Fq "$acl" \ + || echo "$acl" | grep -Eq '^(default:)?mask' then continue fi From 8b9b2c56ab534d619148e497b2e1342128168d21 Mon Sep 17 00:00:00 2001 From: Ander Punnar Date: Tue, 16 Apr 2019 15:28:25 +0300 Subject: [PATCH 0304/1217] __acl: be more strict because of reasons --- cdist/conf/type/__acl/gencode-remote | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cdist/conf/type/__acl/gencode-remote b/cdist/conf/type/__acl/gencode-remote index 47e39e0a..a989f95f 100755 --- a/cdist/conf/type/__acl/gencode-remote +++ b/cdist/conf/type/__acl/gencode-remote @@ -89,7 +89,7 @@ then else echo "$acl_is" | while read -r acl do - if echo "$acl_should" | grep -Fq "$acl" \ + if echo "$acl_should" | grep -Eq "^$acl" \ || echo "$acl" | grep -Eq '^(default:)?mask' then continue fi From 53c963b2eec3eab529bece57cdc25cd00b5557d3 Mon Sep 17 00:00:00 2001 From: Ander Punnar Date: Tue, 16 Apr 2019 15:35:11 +0300 Subject: [PATCH 0305/1217] __acl: be bit more precise where the X is --- cdist/conf/type/__acl/gencode-remote | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cdist/conf/type/__acl/gencode-remote b/cdist/conf/type/__acl/gencode-remote index a989f95f..7003c26f 100755 --- a/cdist/conf/type/__acl/gencode-remote +++ b/cdist/conf/type/__acl/gencode-remote @@ -39,9 +39,9 @@ do then if [ "$is_dir" = '1' ] then - l="$( echo "$l" | sed 's/X/x/' )" + l="$( echo "$l" | sed 's/X$/x/' )" else - l="$( echo "$l" | sed 's/X/-/' )" + l="$( echo "$l" | sed 's/X$/-/' )" fi fi From e04d647d8e9f1450cdb461b3af4aa14f1d589e24 Mon Sep 17 00:00:00 2001 From: Ander Punnar Date: Tue, 16 Apr 2019 18:09:47 +0300 Subject: [PATCH 0306/1217] __acl: fix always check first if path exists --- cdist/conf/type/__acl/explorer/acl_is | 6 ++---- cdist/conf/type/__acl/explorer/file_exists | 24 ++++++++++++++++++++++ cdist/conf/type/__acl/explorer/is_dir | 6 ++---- cdist/conf/type/__acl/gencode-remote | 6 +++--- 4 files changed, 31 insertions(+), 11 deletions(-) create mode 100755 cdist/conf/type/__acl/explorer/file_exists diff --git a/cdist/conf/type/__acl/explorer/acl_is b/cdist/conf/type/__acl/explorer/acl_is index f75f4003..89da89f1 100755 --- a/cdist/conf/type/__acl/explorer/acl_is +++ b/cdist/conf/type/__acl/explorer/acl_is @@ -18,9 +18,7 @@ # along with cdist. If not, see . # -acl_path="/$__object_id" - -[ ! -e "$acl_path" ] && exit 0 +[ ! -e "/$__object_id" ] && exit 0 if ! command -v getfacl > /dev/null then @@ -28,6 +26,6 @@ then exit 1 fi -getfacl "$acl_path" 2>/dev/null \ +getfacl "/$__object_id" 2>/dev/null \ | grep -E '^((default:)?(user|group):[^:]|(default:)?mask::)' \ || true diff --git a/cdist/conf/type/__acl/explorer/file_exists b/cdist/conf/type/__acl/explorer/file_exists new file mode 100755 index 00000000..998d407c --- /dev/null +++ b/cdist/conf/type/__acl/explorer/file_exists @@ -0,0 +1,24 @@ +#!/bin/sh -e +# +# 2018 Ander Punnar (ander-at-kvlt-dot-ee) +# +# This file is part of cdist. +# +# cdist is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# cdist is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with cdist. If not, see . +# + +if [ -e "/$__object_id" ] +then echo 1 +else echo 0 +fi diff --git a/cdist/conf/type/__acl/explorer/is_dir b/cdist/conf/type/__acl/explorer/is_dir index d3080de6..7c4e2538 100755 --- a/cdist/conf/type/__acl/explorer/is_dir +++ b/cdist/conf/type/__acl/explorer/is_dir @@ -18,11 +18,9 @@ # along with cdist. If not, see . # -acl_path="/$__object_id" +[ ! -e "/$__object_id" ] && exit 0 -[ ! -e "$acl_path" ] && exit 0 - -if [ -d "$acl_path" ] +if [ -d "/$__object_id" ] then echo 1 else echo 0 fi diff --git a/cdist/conf/type/__acl/gencode-remote b/cdist/conf/type/__acl/gencode-remote index 7003c26f..91fb7117 100755 --- a/cdist/conf/type/__acl/gencode-remote +++ b/cdist/conf/type/__acl/gencode-remote @@ -18,9 +18,7 @@ # along with cdist. If not, see . # -acl_path="/$__object_id" - -[ ! -e "$acl_path" ] && exit 0 +[ "$( cat "$__object/explorer/file_exists" )" = '0' ] && exit 0 os="$( cat "$__global/explorer/os" )" @@ -28,6 +26,8 @@ is_dir="$( cat "$__object/explorer/is_dir" )" acl_is="$( cat "$__object/explorer/acl_is" )" +acl_path="/$__object_id" + acl_should="$( for parameter in user group do if [ ! -f "$__object/parameter/$parameter" ] From c1a34caba7c39d3f27f7dd6ba249046e04a83e1c Mon Sep 17 00:00:00 2001 From: Ander Punnar Date: Tue, 16 Apr 2019 19:06:48 +0300 Subject: [PATCH 0307/1217] __acl: add "other" ACL entry support and some comments, remove getfacl's inline comments --- cdist/conf/type/__acl/explorer/acl_is | 5 +++-- cdist/conf/type/__acl/gencode-remote | 21 +++++++++++++++++++-- cdist/conf/type/__acl/man.rst | 6 +++++- cdist/conf/type/__acl/parameter/optional | 1 + 4 files changed, 28 insertions(+), 5 deletions(-) diff --git a/cdist/conf/type/__acl/explorer/acl_is b/cdist/conf/type/__acl/explorer/acl_is index 89da89f1..70e18116 100755 --- a/cdist/conf/type/__acl/explorer/acl_is +++ b/cdist/conf/type/__acl/explorer/acl_is @@ -26,6 +26,7 @@ then exit 1 fi -getfacl "/$__object_id" 2>/dev/null \ - | grep -E '^((default:)?(user|group):[^:]|(default:)?mask::)' \ +getfacl -E "/$__object_id" 2>/dev/null \ + | grep -E '^(default:)?(user|group|(mask|other):):[^:]' \ + | sed -r 's/#.+$//' \ || true diff --git a/cdist/conf/type/__acl/gencode-remote b/cdist/conf/type/__acl/gencode-remote index 91fb7117..ce88afc4 100755 --- a/cdist/conf/type/__acl/gencode-remote +++ b/cdist/conf/type/__acl/gencode-remote @@ -28,7 +28,8 @@ acl_is="$( cat "$__object/explorer/acl_is" )" acl_path="/$__object_id" -acl_should="$( for parameter in user group +acl_should="$( +for parameter in user group do if [ ! -f "$__object/parameter/$parameter" ] then continue @@ -53,6 +54,7 @@ do fi done < "$__object/parameter/$parameter" done + if [ -f "$__object/parameter/mask" ] then l=$( cat "$__object/parameter/mask" ) @@ -64,6 +66,18 @@ then then echo "default:mask::$l" fi fi + +if [ -f "$__object/parameter/other" ] +then + l=$( cat "$__object/parameter/other" ) + + echo "other::$l" + + if [ -f "$__object/parameter/default" ] \ + && [ "$is_dir" = '1' ] + then echo "default:other::$l" + fi +fi )" setfacl_exec='setfacl' @@ -89,8 +103,11 @@ then else echo "$acl_is" | while read -r acl do + # Skip wanted ACL entries which already exist + # and skip mask and other entries, because we + # can't actually remove them, but only change. if echo "$acl_should" | grep -Eq "^$acl" \ - || echo "$acl" | grep -Eq '^(default:)?mask' + || echo "$acl" | grep -Eq '^(default:)?(mask|other)' then continue fi diff --git a/cdist/conf/type/__acl/man.rst b/cdist/conf/type/__acl/man.rst index c10ee1a0..40c3ead4 100644 --- a/cdist/conf/type/__acl/man.rst +++ b/cdist/conf/type/__acl/man.rst @@ -18,6 +18,9 @@ OPTIONAL PARAMETERS mask Add mask ACL entry. +other + Add other ACL entry. + OPTIONAL MULTIPLE PARAMETERS ---------------------------- @@ -53,7 +56,8 @@ EXAMPLES --user bob:r-x \ --group project-group:rwx \ --group some-other-group:r-x \ - --mask r-x + --mask r-x \ + --other r-x AUTHORS diff --git a/cdist/conf/type/__acl/parameter/optional b/cdist/conf/type/__acl/parameter/optional index bb4fcf2b..4b32086b 100644 --- a/cdist/conf/type/__acl/parameter/optional +++ b/cdist/conf/type/__acl/parameter/optional @@ -1 +1,2 @@ mask +other From a1634b3ec0d8797cff33be88bf9e1487532ed12a Mon Sep 17 00:00:00 2001 From: Ander Punnar Date: Tue, 16 Apr 2019 19:24:38 +0300 Subject: [PATCH 0308/1217] __acl: optimize gencode-remote --- cdist/conf/type/__acl/gencode-remote | 57 ++++++++++------------------ 1 file changed, 21 insertions(+), 36 deletions(-) diff --git a/cdist/conf/type/__acl/gencode-remote b/cdist/conf/type/__acl/gencode-remote index ce88afc4..fd763b8f 100755 --- a/cdist/conf/type/__acl/gencode-remote +++ b/cdist/conf/type/__acl/gencode-remote @@ -28,57 +28,42 @@ acl_is="$( cat "$__object/explorer/acl_is" )" acl_path="/$__object_id" -acl_should="$( -for parameter in user group +acl_should="$( for parameter in user group mask other do if [ ! -f "$__object/parameter/$parameter" ] - then continue + then + continue fi - while read -r l + + while read -r acl do - if echo "$l" | grep -Fq 'X' + if echo "$acl" | grep -Fq 'X' then if [ "$is_dir" = '1' ] then - l="$( echo "$l" | sed 's/X$/x/' )" + acl="$( echo "$acl" | sed 's/X$/x/' )" else - l="$( echo "$l" | sed 's/X$/-/' )" + acl="$( echo "$acl" | sed 's/X$/-/' )" fi fi - echo "$parameter:$l" + if echo "$parameter" | grep -Eq '(mask|other)' + then + sep=:: + else + sep=: + fi + + echo "$parameter$sep$acl" if [ -f "$__object/parameter/default" ] \ && [ "$is_dir" = '1' ] - then echo "default:$parameter:$l" + then + echo "default:$parameter$sep$acl" fi - done < "$__object/parameter/$parameter" -done - -if [ -f "$__object/parameter/mask" ] -then - l=$( cat "$__object/parameter/mask" ) - - echo "mask::$l" - - if [ -f "$__object/parameter/default" ] \ - && [ "$is_dir" = '1' ] - then echo "default:mask::$l" - fi -fi - -if [ -f "$__object/parameter/other" ] -then - l=$( cat "$__object/parameter/other" ) - - echo "other::$l" - - if [ -f "$__object/parameter/default" ] \ - && [ "$is_dir" = '1' ] - then echo "default:other::$l" - fi -fi -)" + done \ + < "$__object/parameter/$parameter" +done )" setfacl_exec='setfacl' From 8b3c84dfefc5e44fa4f5ae1daa40b87e46a5076a Mon Sep 17 00:00:00 2001 From: Ander Punnar Date: Tue, 16 Apr 2019 23:15:58 +0300 Subject: [PATCH 0309/1217] __acl: remove whitespace before inline comments too --- cdist/conf/type/__acl/explorer/acl_is | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cdist/conf/type/__acl/explorer/acl_is b/cdist/conf/type/__acl/explorer/acl_is index 70e18116..1c64ffb3 100755 --- a/cdist/conf/type/__acl/explorer/acl_is +++ b/cdist/conf/type/__acl/explorer/acl_is @@ -28,5 +28,5 @@ fi getfacl -E "/$__object_id" 2>/dev/null \ | grep -E '^(default:)?(user|group|(mask|other):):[^:]' \ - | sed -r 's/#.+$//' \ + | sed -r 's/\s*#.+$//' \ || true From 7924c1339cc76bb7f8ab2c4a17cea751be7ef509 Mon Sep 17 00:00:00 2001 From: Ander Punnar Date: Tue, 16 Apr 2019 23:28:30 +0300 Subject: [PATCH 0310/1217] __acl: avoid duplication and safer sed for last occurence replacement --- cdist/conf/type/__acl/gencode-remote | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cdist/conf/type/__acl/gencode-remote b/cdist/conf/type/__acl/gencode-remote index fd763b8f..56c1cbc1 100755 --- a/cdist/conf/type/__acl/gencode-remote +++ b/cdist/conf/type/__acl/gencode-remote @@ -41,10 +41,12 @@ do then if [ "$is_dir" = '1' ] then - acl="$( echo "$acl" | sed 's/X$/x/' )" + rep=x else - acl="$( echo "$acl" | sed 's/X$/-/' )" + rep=- fi + + acl="$( echo "$acl" | sed -r "s/(.*)X/\1$rep/" )" fi if echo "$parameter" | grep -Eq '(mask|other)' From f23099218ab8918efde5798d15d5c025e3a0c5da Mon Sep 17 00:00:00 2001 From: Ander Punnar Date: Tue, 16 Apr 2019 23:29:38 +0300 Subject: [PATCH 0311/1217] __acl: juggle man sections around because user/group are more important parameters --- cdist/conf/type/__acl/man.rst | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/cdist/conf/type/__acl/man.rst b/cdist/conf/type/__acl/man.rst index 40c3ead4..b7e74d59 100644 --- a/cdist/conf/type/__acl/man.rst +++ b/cdist/conf/type/__acl/man.rst @@ -13,15 +13,6 @@ ACL must be defined as 3-symbol combination, using `r`, `w`, `x` and `-`. See setfacl(1) and acl(5) for more details. -OPTIONAL PARAMETERS -------------------- -mask - Add mask ACL entry. - -other - Add other ACL entry. - - OPTIONAL MULTIPLE PARAMETERS ---------------------------- user @@ -31,6 +22,15 @@ group Add group ACL entry. +OPTIONAL PARAMETERS +------------------- +mask + Add mask ACL entry. + +other + Add other ACL entry. + + BOOLEAN PARAMETERS ------------------ recursive From 68f61c35ff89971a93ebd511ab35d13b40dce690 Mon Sep 17 00:00:00 2001 From: Ander Punnar Date: Tue, 16 Apr 2019 23:36:54 +0300 Subject: [PATCH 0312/1217] __acl: check for X after last occurrence of colon --- cdist/conf/type/__acl/gencode-remote | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cdist/conf/type/__acl/gencode-remote b/cdist/conf/type/__acl/gencode-remote index 56c1cbc1..96b4a57c 100755 --- a/cdist/conf/type/__acl/gencode-remote +++ b/cdist/conf/type/__acl/gencode-remote @@ -37,7 +37,7 @@ do while read -r acl do - if echo "$acl" | grep -Fq 'X' + if echo "$acl" | sed -r 's/(.*)://' | grep -Fq 'X' then if [ "$is_dir" = '1' ] then From aba1ae68f073382d7f0488b98c69af3e46b8d26a Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Wed, 17 Apr 2019 20:50:39 +0200 Subject: [PATCH 0313/1217] [explorer] disks: use echo instead of find as fallback Fixes #761 --- cdist/conf/explorer/disks | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/cdist/conf/explorer/disks b/cdist/conf/explorer/disks index 405a273a..ae93efc8 100755 --- a/cdist/conf/explorer/disks +++ b/cdist/conf/explorer/disks @@ -16,15 +16,12 @@ case "$os" in # hopefully everything else is linux if command -v lsblk > /dev/null then - # exclude ram disks, floppies and cdroms + # exclude ram disks, floppies and cdroms # https://www.kernel.org/doc/Documentation/admin-guide/devices.txt lsblk -e 1,2,11 -dno name | xargs else # fallback - find /dev \ - -type b \ - -regex '/dev/\(hd\|sd\|vd\)[a-z]+' \ - -printf '%f ' + cd /dev && echo [vsh]d? fi ;; esac From 82f310f4f8116544d1817203a88eb0c65de10fa9 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Fri, 19 Apr 2019 09:36:24 +0200 Subject: [PATCH 0314/1217] ++changelog --- docs/changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog b/docs/changelog index eaa11449..d0fbb0e8 100644 --- a/docs/changelog +++ b/docs/changelog @@ -12,6 +12,7 @@ next: * Type __start_on_boot: gentoo: check all runlevels in explorer (Nico Schottelius) * New type: __package_apk (Nico Schottelius) * Type __acl: Add support for ACL mask (Dimitrios Apostolou) + * Core: Fix circular dependency for CDIST_ORDER_DEPENDENCY (Darko Poljak) 4.10.11: 2019-04-13 * Core: Fix broken quiet mode (Darko Poljak) From f5d3196dd4f142c4b28c9641126d98cfb7eaaab7 Mon Sep 17 00:00:00 2001 From: Ander Punnar Date: Fri, 19 Apr 2019 11:31:38 +0300 Subject: [PATCH 0315/1217] __acl: getfacl's -E not supported on FreeBSD --- cdist/conf/type/__acl/explorer/acl_is | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cdist/conf/type/__acl/explorer/acl_is b/cdist/conf/type/__acl/explorer/acl_is index 1c64ffb3..9ca30281 100755 --- a/cdist/conf/type/__acl/explorer/acl_is +++ b/cdist/conf/type/__acl/explorer/acl_is @@ -26,7 +26,7 @@ then exit 1 fi -getfacl -E "/$__object_id" 2>/dev/null \ +getfacl "/$__object_id" 2>/dev/null \ | grep -E '^(default:)?(user|group|(mask|other):):[^:]' \ | sed -r 's/\s*#.+$//' \ || true From 0809d89836e633af8da983df3f1333ee281938dc Mon Sep 17 00:00:00 2001 From: Ander Punnar Date: Fri, 19 Apr 2019 12:56:55 +0300 Subject: [PATCH 0316/1217] __acl: replace sed -r where possible or make it portable without -r --- cdist/conf/type/__acl/explorer/acl_is | 3 +-- cdist/conf/type/__acl/gencode-remote | 6 +++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/cdist/conf/type/__acl/explorer/acl_is b/cdist/conf/type/__acl/explorer/acl_is index 9ca30281..a693c023 100755 --- a/cdist/conf/type/__acl/explorer/acl_is +++ b/cdist/conf/type/__acl/explorer/acl_is @@ -27,6 +27,5 @@ then fi getfacl "/$__object_id" 2>/dev/null \ - | grep -E '^(default:)?(user|group|(mask|other):):[^:]' \ - | sed -r 's/\s*#.+$//' \ + | grep -Eo '^(default:)?(user|group|(mask|other):):[^:][[:graph:]]+' \ || true diff --git a/cdist/conf/type/__acl/gencode-remote b/cdist/conf/type/__acl/gencode-remote index 96b4a57c..08ba60ac 100755 --- a/cdist/conf/type/__acl/gencode-remote +++ b/cdist/conf/type/__acl/gencode-remote @@ -37,7 +37,7 @@ do while read -r acl do - if echo "$acl" | sed -r 's/(.*)://' | grep -Fq 'X' + if echo "$acl" | awk -F: '{ print $NF }' | grep -Fq 'X' then if [ "$is_dir" = '1' ] then @@ -46,7 +46,7 @@ do rep=- fi - acl="$( echo "$acl" | sed -r "s/(.*)X/\1$rep/" )" + acl="$( echo "$acl" | sed "s/\(.*\)X/\1$rep/" )" fi if echo "$parameter" | grep -Eq '(mask|other)' @@ -98,7 +98,7 @@ then then continue fi - no_bits="$( echo "$acl" | sed -r 's/:[rwx-]+$//' )" + no_bits="$( echo "$acl" | sed 's/:...$//' )" echo "$setfacl_exec -x \"$no_bits\" \"$acl_path\"" done From 0f3c162696c8c35afc155752f47af276c37b1acf Mon Sep 17 00:00:00 2001 From: Ander Punnar Date: Fri, 19 Apr 2019 13:16:35 +0300 Subject: [PATCH 0317/1217] __acl: setting default ACL in FreeBSD and macOS is currently not supported --- cdist/conf/type/__acl/gencode-remote | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/cdist/conf/type/__acl/gencode-remote b/cdist/conf/type/__acl/gencode-remote index 08ba60ac..9cdcd3be 100755 --- a/cdist/conf/type/__acl/gencode-remote +++ b/cdist/conf/type/__acl/gencode-remote @@ -108,6 +108,13 @@ fi for acl in $acl_should do if ! echo "$acl_is" | grep -Eq "^$acl" - then echo "$setfacl_exec -m \"$acl\" \"$acl_path\"" + then + if echo "$os" | grep -Eq 'macosx|freebsd' \ + && echo "$acl" | grep -Eq '^default:' + then + echo "setting default ACL in $os is currently not supported. sorry :(" >&2 + else + echo "$setfacl_exec -m \"$acl\" \"$acl_path\"" + fi fi done From 86f45db1b9b5bf91ea55e5014e39b2437a06bc70 Mon Sep 17 00:00:00 2001 From: Ander Punnar Date: Fri, 19 Apr 2019 13:30:50 +0300 Subject: [PATCH 0318/1217] __acl: add nice oneliners and move default ACL decision out of the loop --- cdist/conf/type/__acl/gencode-remote | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/cdist/conf/type/__acl/gencode-remote b/cdist/conf/type/__acl/gencode-remote index 9cdcd3be..99c0f7f2 100755 --- a/cdist/conf/type/__acl/gencode-remote +++ b/cdist/conf/type/__acl/gencode-remote @@ -28,6 +28,13 @@ acl_is="$( cat "$__object/explorer/acl_is" )" acl_path="/$__object_id" +if [ -f "$__object/parameter/default" ] && [ "$is_dir" = '1' ] +then + set_default=1 +else + set_default=0 +fi + acl_should="$( for parameter in user group mask other do if [ ! -f "$__object/parameter/$parameter" ] @@ -39,30 +46,16 @@ do do if echo "$acl" | awk -F: '{ print $NF }' | grep -Fq 'X' then - if [ "$is_dir" = '1' ] - then - rep=x - else - rep=- - fi + [ "$is_dir" = '1' ] && rep=x || rep=- acl="$( echo "$acl" | sed "s/\(.*\)X/\1$rep/" )" fi - if echo "$parameter" | grep -Eq '(mask|other)' - then - sep=:: - else - sep=: - fi + echo "$parameter" | grep -Eq '(mask|other)' && sep=:: || sep=: echo "$parameter$sep$acl" - if [ -f "$__object/parameter/default" ] \ - && [ "$is_dir" = '1' ] - then - echo "default:$parameter$sep$acl" - fi + [ "$set_default" = '1' ] && echo "default:$parameter$sep$acl" done \ < "$__object/parameter/$parameter" done )" From 8729e39c215381e9bdffe6269cedfba85d0e0f85 Mon Sep 17 00:00:00 2001 From: Ander Punnar Date: Fri, 19 Apr 2019 13:48:24 +0300 Subject: [PATCH 0319/1217] __acl: combine two explorers into one --- .../__acl/explorer/{file_exists => file_is} | 11 ++++++-- cdist/conf/type/__acl/explorer/is_dir | 26 ------------------- cdist/conf/type/__acl/gencode-remote | 10 +++---- 3 files changed, 14 insertions(+), 33 deletions(-) rename cdist/conf/type/__acl/explorer/{file_exists => file_is} (81%) delete mode 100755 cdist/conf/type/__acl/explorer/is_dir diff --git a/cdist/conf/type/__acl/explorer/file_exists b/cdist/conf/type/__acl/explorer/file_is similarity index 81% rename from cdist/conf/type/__acl/explorer/file_exists rename to cdist/conf/type/__acl/explorer/file_is index 998d407c..096cffd1 100755 --- a/cdist/conf/type/__acl/explorer/file_exists +++ b/cdist/conf/type/__acl/explorer/file_is @@ -19,6 +19,13 @@ # if [ -e "/$__object_id" ] -then echo 1 -else echo 0 +then + if [ -d "/$__object_id" ] + then echo directory + elif [ -f "/$__object_id" ] + then echo regular + else echo other + fi +else + echo missing fi diff --git a/cdist/conf/type/__acl/explorer/is_dir b/cdist/conf/type/__acl/explorer/is_dir deleted file mode 100755 index 7c4e2538..00000000 --- a/cdist/conf/type/__acl/explorer/is_dir +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/sh -e -# -# 2018 Ander Punnar (ander-at-kvlt-dot-ee) -# -# 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 . -# - -[ ! -e "/$__object_id" ] && exit 0 - -if [ -d "/$__object_id" ] -then echo 1 -else echo 0 -fi diff --git a/cdist/conf/type/__acl/gencode-remote b/cdist/conf/type/__acl/gencode-remote index 99c0f7f2..5bb19aa8 100755 --- a/cdist/conf/type/__acl/gencode-remote +++ b/cdist/conf/type/__acl/gencode-remote @@ -18,17 +18,17 @@ # along with cdist. If not, see . # -[ "$( cat "$__object/explorer/file_exists" )" = '0' ] && exit 0 +file_is="$( cat "$__object/explorer/file_is" )" + +[ "$file_is" = 'missing' ] && exit 0 os="$( cat "$__global/explorer/os" )" -is_dir="$( cat "$__object/explorer/is_dir" )" - acl_is="$( cat "$__object/explorer/acl_is" )" acl_path="/$__object_id" -if [ -f "$__object/parameter/default" ] && [ "$is_dir" = '1' ] +if [ -f "$__object/parameter/default" ] && [ "$file_is" = 'directory' ] then set_default=1 else @@ -46,7 +46,7 @@ do do if echo "$acl" | awk -F: '{ print $NF }' | grep -Fq 'X' then - [ "$is_dir" = '1' ] && rep=x || rep=- + [ "$file_is" = 'directory' ] && rep=x || rep=- acl="$( echo "$acl" | sed "s/\(.*\)X/\1$rep/" )" fi From 13df0a2a2b8ac2724821fc72369eaf9f4ca1fe66 Mon Sep 17 00:00:00 2001 From: Ander Punnar Date: Fri, 19 Apr 2019 14:11:29 +0300 Subject: [PATCH 0320/1217] __acl: update man --- cdist/conf/type/__acl/man.rst | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/cdist/conf/type/__acl/man.rst b/cdist/conf/type/__acl/man.rst index b7e74d59..bc71a0cc 100644 --- a/cdist/conf/type/__acl/man.rst +++ b/cdist/conf/type/__acl/man.rst @@ -3,14 +3,16 @@ cdist-type__acl(7) NAME ---- -cdist-type__acl - Basic wrapper around `setfacl` +cdist-type__acl - Set ACL entries DESCRIPTION ----------- -ACL must be defined as 3-symbol combination, using `r`, `w`, `x` and `-`. +ACL must be defined as 3-symbol combination, using ``r``, ``w``, ``x`` and ``-``. -See setfacl(1) and acl(5) for more details. +Fully supported on Linux, partial support for FreeBSD, OSX and Solaris. + +See ``setfacl`` and ``acl`` manpages for more details. OPTIONAL MULTIPLE PARAMETERS @@ -34,13 +36,14 @@ other BOOLEAN PARAMETERS ------------------ recursive - Operate recursively (Linux only). + Make ``setfacl`` recursive (Linux only), but not ``getfacl`` in explorer. default - Add default ACL entries. + Add default ACL entries (FreeBSD not supported). remove Remove undefined ACL entries (Solaris not supported). + ACL entries for ``mask`` and ``other`` can't be removed. EXAMPLES From 6d71ae342ad826aac73dd34d7334e7b4ef97bf41 Mon Sep 17 00:00:00 2001 From: Ander Punnar Date: Fri, 19 Apr 2019 14:47:16 +0300 Subject: [PATCH 0321/1217] __acl: update man more --- cdist/conf/type/__acl/man.rst | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cdist/conf/type/__acl/man.rst b/cdist/conf/type/__acl/man.rst index bc71a0cc..092eb555 100644 --- a/cdist/conf/type/__acl/man.rst +++ b/cdist/conf/type/__acl/man.rst @@ -10,7 +10,11 @@ DESCRIPTION ----------- ACL must be defined as 3-symbol combination, using ``r``, ``w``, ``x`` and ``-``. -Fully supported on Linux, partial support for FreeBSD, OSX and Solaris. +Fully supported on Linux (tested on Debian and CentOS). + +Partial support for FreeBSD, OSX and Solaris. + +OpenBSD and NetBSD support is not possible. See ``setfacl`` and ``acl`` manpages for more details. From 05225352aa7434ec35d2691420adb1f81923d4ec Mon Sep 17 00:00:00 2001 From: Ander Punnar Date: Fri, 19 Apr 2019 14:48:26 +0300 Subject: [PATCH 0322/1217] __acl: check for missing users and groups (common mistake) --- .../type/__acl/explorer/missing_users_groups | 47 +++++++++++++++++++ cdist/conf/type/__acl/gencode-remote | 8 ++++ 2 files changed, 55 insertions(+) create mode 100755 cdist/conf/type/__acl/explorer/missing_users_groups diff --git a/cdist/conf/type/__acl/explorer/missing_users_groups b/cdist/conf/type/__acl/explorer/missing_users_groups new file mode 100755 index 00000000..883fb84d --- /dev/null +++ b/cdist/conf/type/__acl/explorer/missing_users_groups @@ -0,0 +1,47 @@ +#!/bin/sh -e +# +# 2019 Ander Punnar (ander-at-kvlt-dot-ee) +# +# 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 . +# + +[ ! -e "/$__object_id" ] && exit 0 + +for parameter in user group +do + if [ ! -f "$__object/parameter/$parameter" ] + then + continue + fi + + while read -r acl + do + check="$( echo "$acl" | awk -F: '{print $1}' )" + + if [ "$parameter" = 'user' ] + then + getent_db=passwd + else + getent_db="$parameter" + fi + + if ! getent "$getent_db" "$check" > /dev/null + then + echo "missing $parameter '$check'" + fi + done \ + < "$__object/parameter/$parameter" +done diff --git a/cdist/conf/type/__acl/gencode-remote b/cdist/conf/type/__acl/gencode-remote index 5bb19aa8..3dd0aef6 100755 --- a/cdist/conf/type/__acl/gencode-remote +++ b/cdist/conf/type/__acl/gencode-remote @@ -22,6 +22,14 @@ file_is="$( cat "$__object/explorer/file_is" )" [ "$file_is" = 'missing' ] && exit 0 +missing_users_groups="$( cat "$__object/explorer/missing_users_groups" )" + +if [ -n "$missing_users_groups" ] +then + echo "$missing_users_groups" >&2 + exit 1 +fi + os="$( cat "$__global/explorer/os" )" acl_is="$( cat "$__object/explorer/acl_is" )" From c7e6109462eab6201ae4fee5bf1b9baa2d48314c Mon Sep 17 00:00:00 2001 From: Ander Punnar Date: Fri, 19 Apr 2019 14:49:02 +0300 Subject: [PATCH 0323/1217] __acl: tabs vs spaces --- cdist/conf/type/__acl/explorer/missing_users_groups | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cdist/conf/type/__acl/explorer/missing_users_groups b/cdist/conf/type/__acl/explorer/missing_users_groups index 883fb84d..b4af614c 100755 --- a/cdist/conf/type/__acl/explorer/missing_users_groups +++ b/cdist/conf/type/__acl/explorer/missing_users_groups @@ -29,7 +29,7 @@ do while read -r acl do - check="$( echo "$acl" | awk -F: '{print $1}' )" + check="$( echo "$acl" | awk -F: '{print $1}' )" if [ "$parameter" = 'user' ] then @@ -38,10 +38,10 @@ do getent_db="$parameter" fi - if ! getent "$getent_db" "$check" > /dev/null - then - echo "missing $parameter '$check'" - fi + if ! getent "$getent_db" "$check" > /dev/null + then + echo "missing $parameter '$check'" + fi done \ < "$__object/parameter/$parameter" done From 186ce77bb24ddb089b69a28c4c27dd1bfbbd1a71 Mon Sep 17 00:00:00 2001 From: Ander Punnar Date: Fri, 19 Apr 2019 14:58:44 +0300 Subject: [PATCH 0324/1217] __acl: add messaging --- cdist/conf/type/__acl/gencode-remote | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cdist/conf/type/__acl/gencode-remote b/cdist/conf/type/__acl/gencode-remote index 3dd0aef6..c9583520 100755 --- a/cdist/conf/type/__acl/gencode-remote +++ b/cdist/conf/type/__acl/gencode-remote @@ -102,6 +102,7 @@ then no_bits="$( echo "$acl" | sed 's/:...$//' )" echo "$setfacl_exec -x \"$no_bits\" \"$acl_path\"" + echo "removed '$no_bits'" >> "$__messages_out" done fi fi @@ -116,6 +117,7 @@ do echo "setting default ACL in $os is currently not supported. sorry :(" >&2 else echo "$setfacl_exec -m \"$acl\" \"$acl_path\"" + echo "added '$acl'" >> "$__messages_out" fi fi done From 108e46abee03eaca789eb43393aaccf9f699bf7a Mon Sep 17 00:00:00 2001 From: Ander Punnar Date: Fri, 19 Apr 2019 15:04:18 +0300 Subject: [PATCH 0325/1217] __acl: fix removal in freebsd --- cdist/conf/type/__acl/gencode-remote | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/cdist/conf/type/__acl/gencode-remote b/cdist/conf/type/__acl/gencode-remote index c9583520..a0f25a15 100755 --- a/cdist/conf/type/__acl/gencode-remote +++ b/cdist/conf/type/__acl/gencode-remote @@ -99,10 +99,15 @@ then then continue fi - no_bits="$( echo "$acl" | sed 's/:...$//' )" + if echo "$os" | grep -Eq 'macosx|freebsd' + then + remove="$acl" + else + remove="$( echo "$acl" | sed 's/:...$//' )" + fi - echo "$setfacl_exec -x \"$no_bits\" \"$acl_path\"" - echo "removed '$no_bits'" >> "$__messages_out" + echo "$setfacl_exec -x \"$remove\" \"$acl_path\"" + echo "removed '$remove'" >> "$__messages_out" done fi fi From 69fc80ec951deeddb94ff6b396175881e769c78c Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Fri, 19 Apr 2019 17:50:09 +0200 Subject: [PATCH 0326/1217] ++ --- docs/changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog b/docs/changelog index d0fbb0e8..eeb91dc4 100644 --- a/docs/changelog +++ b/docs/changelog @@ -13,6 +13,7 @@ next: * New type: __package_apk (Nico Schottelius) * Type __acl: Add support for ACL mask (Dimitrios Apostolou) * Core: Fix circular dependency for CDIST_ORDER_DEPENDENCY (Darko Poljak) + * Type __acl: Improve the type (Ander Punnar) 4.10.11: 2019-04-13 * Core: Fix broken quiet mode (Darko Poljak) From ab3544d5e8955484c755ce3f6f3d261d6a2f8a0f Mon Sep 17 00:00:00 2001 From: Ander Punnar Date: Sat, 20 Apr 2019 01:59:21 +0300 Subject: [PATCH 0327/1217] global interfaces explorer: only check if we have ip or ifconfig and be more compatible. tests on debian, centos, freebsd, openbsd, netbsd and solaris confirm that this is enough and extra os check is not needed here. --- cdist/conf/explorer/interfaces | 41 +++++++++------------------------- 1 file changed, 10 insertions(+), 31 deletions(-) diff --git a/cdist/conf/explorer/interfaces b/cdist/conf/explorer/interfaces index c1f2a57a..55287971 100755 --- a/cdist/conf/explorer/interfaces +++ b/cdist/conf/explorer/interfaces @@ -1,6 +1,6 @@ -#!/bin/sh +#!/bin/sh -e # -# 2012 Sébastien Gross +# 2019 Ander Punnar (ander-at-kvlt-dot-ee) # # This file is part of cdist. # @@ -17,35 +17,14 @@ # You should have received a copy of the GNU General Public License # along with cdist. If not, see . # -# -# List all network interfaces in explorer/ifaces. One interface per line. -# -# If your OS is not supported please provide a ifconfig output -# -# Use ip, if available -if command -v ip >/dev/null; then +if command -v ip > /dev/null +then ip -o link show | sed -n 's/^[0-9]\+: \(.\+\): <.*/\1/p' - exit 0 + +elif command -v ifconfig > /dev/null +then + ifconfig -a \ + | sed -n -E 's/^(.*)(:[[:space:]]*flags=|Link encap).*/\1/p' \ + | sort -u fi - -if ! command -v ifconfig >/dev/null; then - # no ifconfig, nothing we could do - exit 0 -fi - -uname_s="$(uname -s)" -REGEXP='s/^(.*)(:[[:space:]]*flags=|Link encap).*/\1/p' - -case "$uname_s" in - Darwin) - ifconfig -a | sed -n -E "$REGEXP" - ;; - Linux|*BSD) - ifconfig -a | sed -n -r "$REGEXP" - ;; - *) - echo "Unsupported ifconfig output for $uname_s" >&2 - exit 1 - ;; -esac From 3b3ac95ac3f8cefa897f9b6a443315da7762495c Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Sat, 20 Apr 2019 12:35:42 +0200 Subject: [PATCH 0328/1217] ++changelog --- docs/changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog b/docs/changelog index eeb91dc4..c2e5b941 100644 --- a/docs/changelog +++ b/docs/changelog @@ -14,6 +14,7 @@ next: * Type __acl: Add support for ACL mask (Dimitrios Apostolou) * Core: Fix circular dependency for CDIST_ORDER_DEPENDENCY (Darko Poljak) * Type __acl: Improve the type (Ander Punnar) + * Explorer interfaces: Simplify code, be more compatible (Ander Punnar) 4.10.11: 2019-04-13 * Core: Fix broken quiet mode (Darko Poljak) From 250f3d3fb896c9f7d44ff4eddb6c9368ac221765 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Sat, 20 Apr 2019 12:40:04 +0200 Subject: [PATCH 0329/1217] shellcheck: remove unused var --- cdist/conf/type/__package_apk/explorer/state | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/cdist/conf/type/__package_apk/explorer/state b/cdist/conf/type/__package_apk/explorer/state index 3fc405a2..29ccf3a5 100755 --- a/cdist/conf/type/__package_apk/explorer/state +++ b/cdist/conf/type/__package_apk/explorer/state @@ -18,7 +18,7 @@ # along with cdist. If not, see . # # -# Retrieve the status of a package - parsed dpkg output +# Retrieve the status of a package - parsed apk output # if [ -f "$__object/parameter/name" ]; then @@ -27,8 +27,6 @@ else name="$__object_id" fi -output= - if [ "$(apk list -I "$name")" ]; then echo present else From b5bdb54b7f75d5ff5d935c21730959a57509d0ec Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Fri, 19 Apr 2019 09:44:29 +0200 Subject: [PATCH 0330/1217] Currently support only Linux, FreeBSD, OpenBSD, NetBSD Make no assumptions, but rather output that system is unsupported and ask the user to add support for it. --- cdist/conf/explorer/disks | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/cdist/conf/explorer/disks b/cdist/conf/explorer/disks index ae93efc8..51660e13 100755 --- a/cdist/conf/explorer/disks +++ b/cdist/conf/explorer/disks @@ -1,27 +1,27 @@ #!/bin/sh -e -os="$( "$__explorer/os" )" +uname_s="$(uname -s)" -case "$os" in - freebsd) +case "${uname_s}" in + FreeBSD) sysctl -n kern.disks ;; - openbsd) - sysctl -n hw.disknames | grep -Eo '[sw]d[0-9]+' | xargs + OpenBSD|NetBSD) + sysctl -n hw.disknames | grep -Eo '[lsw]d[0-9]+' | xargs ;; - netbsd) - sysctl -n hw.disknames | grep -Eo '[lsw]d[0-9]' | xargs - ;; - *) - # hopefully everything else is linux + Linux) if command -v lsblk > /dev/null then # exclude ram disks, floppies and cdroms # https://www.kernel.org/doc/Documentation/admin-guide/devices.txt lsblk -e 1,2,11 -dno name | xargs else - # fallback - cd /dev && echo [vsh]d? + printf "%s operating system without lsblk is not supported, if you can please submit a patch\n" "${uname_s}" >&2 + exit 1 fi ;; + *) + printf "%s operating system is not supported, if you can please submit a patch\n" "${uname_s}" >&2 + exit 1 + ;; esac From 087066687cf96690e08863a748a0dd24eed0e7e6 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Sat, 20 Apr 2019 14:26:09 +0200 Subject: [PATCH 0331/1217] Report explorer error better Fixes #766 --- cdist/__init__.py | 41 +++++++++++++++++++++++++++++++++++++++-- cdist/config.py | 9 ++++----- cdist/core/explorer.py | 30 +++++++++++++++++++++++------- 3 files changed, 66 insertions(+), 14 deletions(-) diff --git a/cdist/__init__.py b/cdist/__init__.py index 000a571c..c673b3ba 100644 --- a/cdist/__init__.py +++ b/cdist/__init__.py @@ -181,17 +181,40 @@ class CdistObjectError(CdistEntityError): params, stdout_paths, stderr_paths, subject) +class CdistObjectExplorerError(CdistEntityError): + """ + Something went wrong while working on a specific + cdist object explorer + """ + def __init__(self, cdist_object, explorer_name, explorer_path, + stderr_path, subject=''): + params = [ + ('object name', cdist_object.name, ), + ('object path', cdist_object.absolute_path, ), + ('object source', " ".join(cdist_object.source), ), + ('object type', os.path.realpath( + cdist_object.cdist_type.absolute_path), ), + ('explorer name', explorer_name, ), + ('explorer path', explorer_path, ), + ] + stdout_paths = [] + stderr_paths = [ + ('remote', stderr_path, ), + ] + super().__init__("explorer '{}' of object '{}'".format( + explorer_name, cdist_object.name), params, stdout_paths, + stderr_paths, subject) + + class InitialManifestError(CdistEntityError): """Something went wrong while executing initial manifest""" def __init__(self, initial_manifest, stdout_path, stderr_path, subject=''): params = [ ('path', initial_manifest, ), ] - stdout_paths = [] stdout_paths = [ ('init', stdout_path, ), ] - stderr_paths = [] stderr_paths = [ ('init', stderr_path, ), ] @@ -199,6 +222,20 @@ class InitialManifestError(CdistEntityError): stderr_paths, subject) +class GlobalExplorerError(CdistEntityError): + """Something went wrong while executing global explorer""" + def __init__(self, name, path, stderr_path, subject=''): + params = [ + ('name', name, ), + ('path', path, ), + ] + stderr_paths = [ + ('remote', stderr_path, ), + ] + super().__init__("global explorer '{}'".format(name), + params, [], stderr_paths, subject) + + def file_to_list(filename): """Return list from \n seperated file""" if os.path.isfile(filename): diff --git a/cdist/config.py b/cdist/config.py index 11c433db..fae2ff46 100644 --- a/cdist/config.py +++ b/cdist/config.py @@ -702,12 +702,11 @@ class Config(object): def object_prepare(self, cdist_object, transfer_type_explorers=True): """Prepare object: Run type explorer + manifest""" + self.log.verbose("Preparing object {}".format(cdist_object.name)) + self.log.verbose( + "Running manifest and explorers for " + cdist_object.name) + self.explorer.run_type_explorers(cdist_object, transfer_type_explorers) try: - self.log.verbose("Preparing object {}".format(cdist_object.name)) - self.log.verbose( - "Running manifest and explorers for " + cdist_object.name) - self.explorer.run_type_explorers(cdist_object, - transfer_type_explorers) self.manifest.run_type_manifest(cdist_object) cdist_object.state = core.CdistObject.STATE_PREPARED except cdist.Error as e: diff --git a/cdist/core/explorer.py b/cdist/core/explorer.py index 0b3d7b2e..26b7021a 100644 --- a/cdist/core/explorer.py +++ b/cdist/core/explorer.py @@ -109,10 +109,17 @@ class Explorer(object): self._run_global_explorers_parallel(out_path) def _run_global_explorer(self, explorer, out_path): - output = self.run_global_explorer(explorer) - path = os.path.join(out_path, explorer) - with open(path, 'w') as fd: - fd.write(output) + try: + path = os.path.join(out_path, explorer) + output = self.run_global_explorer(explorer) + with open(path, 'w') as fd: + fd.write(output) + except cdist.Error as e: + local_path = os.path.join(self.local.global_explorer_path, + explorer) + stderr_path = os.path.join(self.local.stderr_base_path, "remote") + raise cdist.GlobalExplorerError(explorer, local_path, stderr_path, + e) def _run_global_explorers_seq(self, out_path): self.log.debug("Running global explorers sequentially") @@ -186,11 +193,20 @@ class Explorer(object): self.log.trace("Transferring object parameters for object: %s", cdist_object.name) self.transfer_object_parameters(cdist_object) - for explorer in self.list_type_explorer_names(cdist_object.cdist_type): - output = self.run_type_explorer(explorer, cdist_object) + cdist_type = cdist_object.cdist_type + for explorer in self.list_type_explorer_names(cdist_type): self.log.trace("Running type explorer '%s' for object '%s'", explorer, cdist_object.name) - cdist_object.explorers[explorer] = output + try: + output = self.run_type_explorer(explorer, cdist_object) + cdist_object.explorers[explorer] = output + except cdist.Error as e: + path = os.path.join(self.local.type_path, + cdist_type.explorer_path, + explorer) + stderr_path = os.path.join(self.local.stderr_base_path, "remote") + raise cdist.CdistObjectExplorerError( + cdist_object, explorer, path, stderr_path, e) def run_type_explorer(self, explorer, cdist_object): """Run the given type explorer for the given object and return From e3a900c1c931d1242543caa4c3947362f1a8cc7e Mon Sep 17 00:00:00 2001 From: Ander Punnar Date: Sat, 20 Apr 2019 12:14:38 +0300 Subject: [PATCH 0332/1217] __ssh_authorized_keys: remove legacy code --- cdist/conf/type/__ssh_authorized_keys/manifest | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/cdist/conf/type/__ssh_authorized_keys/manifest b/cdist/conf/type/__ssh_authorized_keys/manifest index a8ded2f6..b507c7ff 100755 --- a/cdist/conf/type/__ssh_authorized_keys/manifest +++ b/cdist/conf/type/__ssh_authorized_keys/manifest @@ -45,18 +45,6 @@ if [ ! -f "$__object/parameter/noparent" ] || [ ! -f "$__object/parameter/nofile fi fi -# Remove legacy blocks created by old versions of this type -# FIXME: remove me in 3.2+ -__block "$__object_name" \ - --file "$file" \ - --prefix "#cdist:$__object_name" \ - --suffix "#/cdist:$__object_name" \ - --state 'absent' \ - --text - << DONE -remove legacy block -DONE -export require="__block/$__object_name" - _cksum() { echo "$1" | cksum | cut -d' ' -f 1 } From 038524ba30168e0205c4f391d6bf09f7b992fe28 Mon Sep 17 00:00:00 2001 From: Ander Punnar Date: Sat, 20 Apr 2019 16:09:47 +0300 Subject: [PATCH 0333/1217] support solaris in __(file|directory)/explorer/stat --- cdist/conf/type/__directory/explorer/stat | 29 +++++++++++++++++++++ cdist/conf/type/__file/explorer/stat | 31 +++++++++++++++++++++++ 2 files changed, 60 insertions(+) diff --git a/cdist/conf/type/__directory/explorer/stat b/cdist/conf/type/__directory/explorer/stat index db3c149a..03d466ba 100755 --- a/cdist/conf/type/__directory/explorer/stat +++ b/cdist/conf/type/__directory/explorer/stat @@ -39,6 +39,35 @@ group: %g %G mode: %a %A " "$destination" ;; + solaris) + ls1="$( ls -ld "$destination" )" + ls2="$( ls -ldn "$destination" )" + + if [ -f "$__object/parameter/mode" ] + then mode_should="$( cat "$__object/parameter/mode" )" + fi + + # yes, it is ugly hack, but if you know better way... + if [ -z "$( find "$destination" -perm "$mode_should" )" ] + then octets=888 + else octets="$( echo "$mode_should" | sed 's/^0//' )" + fi + + case "$( echo "$ls1" | cut -c1-1 )" in + -) echo 'type: regular file' ;; + d) echo 'type: directory' ;; + esac + + echo "owner: $( echo "$ls2" \ + | awk '{print $3}' ) $( echo "$ls1" \ + | awk '{print $3}' )" + + echo "group: $( echo "$ls2" \ + | awk '{print $4}' ) $( echo "$ls1" \ + | awk '{print $4}' )" + + echo "mode: $octets $( echo "$ls1" | awk '{print $1}' )" + ;; *) stat --printf="type: %F owner: %u %U diff --git a/cdist/conf/type/__file/explorer/stat b/cdist/conf/type/__file/explorer/stat index a0f35dcc..13c1c208 100755 --- a/cdist/conf/type/__file/explorer/stat +++ b/cdist/conf/type/__file/explorer/stat @@ -45,6 +45,37 @@ size: %s links: %h " "$destination" ;; + solaris) + ls1="$( ls -ld "$destination" )" + ls2="$( ls -ldn "$destination" )" + + if [ -f "$__object/parameter/mode" ] + then mode_should="$( cat "$__object/parameter/mode" )" + fi + + # yes, it is ugly hack, but if you know better way... + if [ -z "$( find "$destination" -perm "$mode_should" )" ] + then octets=888 + else octets="$( echo "$mode_should" | sed 's/^0//' )" + fi + + case "$( echo "$ls1" | cut -c1-1 )" in + -) echo 'type: regular file' ;; + d) echo 'type: directory' ;; + esac + + echo "owner: $( echo "$ls2" \ + | awk '{print $3}' ) $( echo "$ls1" \ + | awk '{print $3}' )" + + echo "group: $( echo "$ls2" \ + | awk '{print $4}' ) $( echo "$ls1" \ + | awk '{print $4}' )" + + echo "mode: $octets $( echo "$ls1" | awk '{print $1}' )" + echo "size: $( echo "$ls1" | awk '{print $5}' )" + echo "links: $( echo "$ls1" | awk '{print $2}' )" + ;; *) stat --printf="type: %F owner: %u %U From d08ab628da0252dd5876ca1aded72d53fc7804cf Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Sat, 20 Apr 2019 17:04:34 +0200 Subject: [PATCH 0334/1217] ++ --- docs/changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog b/docs/changelog index c2e5b941..48b0e6ee 100644 --- a/docs/changelog +++ b/docs/changelog @@ -15,6 +15,7 @@ next: * Core: Fix circular dependency for CDIST_ORDER_DEPENDENCY (Darko Poljak) * Type __acl: Improve the type (Ander Punnar) * Explorer interfaces: Simplify code, be more compatible (Ander Punnar) + * Explorer disks: Remove assumable default/fallback, for now explicitly support only Linux and BSDs (Ander Punnar, Darko Poljak) 4.10.11: 2019-04-13 * Core: Fix broken quiet mode (Darko Poljak) From c10074780e4399cbd828726d953efd8b9cfd6559 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Sat, 20 Apr 2019 17:09:26 +0200 Subject: [PATCH 0335/1217] Release 4.11.0 --- docs/changelog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/changelog b/docs/changelog index 48b0e6ee..bb9642ea 100644 --- a/docs/changelog +++ b/docs/changelog @@ -1,7 +1,7 @@ Changelog --------- -next: +4.11.0: 2019-04-20 * Type __package: Add __package_apk support (Nico Schottelius) * Type __directory: Add alpine support (Nico Schottelius) * Type __file: Add alpine support (Nico Schottelius) From b0273af0d4fbadf9151ed97b95026c6399ddb5aa Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Sat, 20 Apr 2019 17:41:07 +0200 Subject: [PATCH 0336/1217] Rm relicts, pypi before web publishing --- bin/build-helper.freebsd | 34 ++++++---------------------------- 1 file changed, 6 insertions(+), 28 deletions(-) diff --git a/bin/build-helper.freebsd b/bin/build-helper.freebsd index 58d985a6..ea16ef42 100755 --- a/bin/build-helper.freebsd +++ b/bin/build-helper.freebsd @@ -372,6 +372,12 @@ eof ;; esac + # Ensure that pypi release has the right version + "$0" version + + # Create and publish package for pypi + make helper=${helper} WEBDIR=${WEBDIR} pypi-release + # publish man, speeches, website if [ "$masterbranch" = yes ]; then make helper=${helper} WEBDIR=${WEBDIR} web-release-all @@ -379,12 +385,6 @@ eof make helper=${helper} WEBDIR=${WEBDIR} web-release-all-no-latest fi - # Ensure that pypi release has the right version - "$0" version - - # Create and publish package for pypi - make helper=${helper} WEBDIR=${WEBDIR} pypi-release - case "$run_as" in freebsd) ;; @@ -396,28 +396,6 @@ eof # Announce change on ML make helper=${helper} WEBDIR=${WEBDIR} ml-release - - cat << eof -Manual steps post release: - - - linkedin - - hackernews - - reddit - - twitter - -eof - - case "$run_as" in - freebsd) - cat < Date: Sun, 21 Apr 2019 07:46:32 +0200 Subject: [PATCH 0337/1217] ++changelog --- docs/changelog | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/changelog b/docs/changelog index bb9642ea..cade2b71 100644 --- a/docs/changelog +++ b/docs/changelog @@ -1,6 +1,9 @@ Changelog --------- +next: + * Core: Improve explorer error reporting (Darko Poljak) + 4.11.0: 2019-04-20 * Type __package: Add __package_apk support (Nico Schottelius) * Type __directory: Add alpine support (Nico Schottelius) From 5314f514c5937875537a37aa98225c771fb4abed Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Mon, 22 Apr 2019 09:12:13 +0200 Subject: [PATCH 0338/1217] Print empty disk list for unsupported OS --- cdist/conf/explorer/disks | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cdist/conf/explorer/disks b/cdist/conf/explorer/disks index 51660e13..87a6b5c6 100755 --- a/cdist/conf/explorer/disks +++ b/cdist/conf/explorer/disks @@ -1,4 +1,4 @@ -#!/bin/sh -e +#!/bin/sh uname_s="$(uname -s)" @@ -16,12 +16,12 @@ case "${uname_s}" in # https://www.kernel.org/doc/Documentation/admin-guide/devices.txt lsblk -e 1,2,11 -dno name | xargs else - printf "%s operating system without lsblk is not supported, if you can please submit a patch\n" "${uname_s}" >&2 - exit 1 + printf "Don't know how to list disks for %s operating system without lsblk, if you can please submit a patch\n" "${uname_s}" >&2 fi ;; *) - printf "%s operating system is not supported, if you can please submit a patch\n" "${uname_s}" >&2 - exit 1 + printf "Don't know how to list disks for %s operating system, if you can please submit a patch\n" "${uname_s}" >&2 ;; esac + +exit 0 From 7ca66b7b6a3229fa87a4e1db649ccaf0b72af282 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Mon, 22 Apr 2019 09:22:52 +0200 Subject: [PATCH 0339/1217] ++changelog --- docs/changelog | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/changelog b/docs/changelog index cade2b71..92c97565 100644 --- a/docs/changelog +++ b/docs/changelog @@ -3,6 +3,9 @@ Changelog next: * Core: Improve explorer error reporting (Darko Poljak) + * Type __directory: explorer stat: add support for Solaris (Ander Punnar) + * Type __file: explorer stat: add support for Solaris (Ander Punnar) + * Type __ssh_authorized_keys: Remove legacy code (Ander Punnar) 4.11.0: 2019-04-20 * Type __package: Add __package_apk support (Nico Schottelius) From 6bd34c74d3a57355b36018edf34717a57bf4c312 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Mon, 22 Apr 2019 21:03:53 +0200 Subject: [PATCH 0340/1217] ++ --- docs/changelog | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/changelog b/docs/changelog index 92c97565..f4b70ae0 100644 --- a/docs/changelog +++ b/docs/changelog @@ -6,6 +6,9 @@ next: * Type __directory: explorer stat: add support for Solaris (Ander Punnar) * Type __file: explorer stat: add support for Solaris (Ander Punnar) * Type __ssh_authorized_keys: Remove legacy code (Ander Punnar) + * Explorer disks: Bugfix: do not break config in case of unsupported OS + which was introduced in 4.11.0, print message to stderr and empty disk list + to stdout instead (Darko Poljak) 4.11.0: 2019-04-20 * Type __package: Add __package_apk support (Nico Schottelius) From 7c0ba0d5bece0a8f6a3b82f0d7476fe3015c2166 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Mon, 22 Apr 2019 21:11:36 +0200 Subject: [PATCH 0341/1217] pycodestyle --- cdist/core/explorer.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cdist/core/explorer.py b/cdist/core/explorer.py index 26b7021a..acceacac 100644 --- a/cdist/core/explorer.py +++ b/cdist/core/explorer.py @@ -204,7 +204,8 @@ class Explorer(object): path = os.path.join(self.local.type_path, cdist_type.explorer_path, explorer) - stderr_path = os.path.join(self.local.stderr_base_path, "remote") + stderr_path = os.path.join(self.local.stderr_base_path, + "remote") raise cdist.CdistObjectExplorerError( cdist_object, explorer, path, stderr_path, e) From 2536cd6f95f519649db84bda50e11934edadb580 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Mon, 22 Apr 2019 21:12:09 +0200 Subject: [PATCH 0342/1217] Release 4.11.1 --- docs/changelog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/changelog b/docs/changelog index f4b70ae0..bf106861 100644 --- a/docs/changelog +++ b/docs/changelog @@ -1,7 +1,7 @@ Changelog --------- -next: +4.11.1: 2019-04-22 * Core: Improve explorer error reporting (Darko Poljak) * Type __directory: explorer stat: add support for Solaris (Ander Punnar) * Type __file: explorer stat: add support for Solaris (Ander Punnar) From a95d4ffefafaf3e7142bacbc33951ab9f2dc3d74 Mon Sep 17 00:00:00 2001 From: Dmitry Bogatov Date: Tue, 23 Apr 2019 12:36:24 +0000 Subject: [PATCH 0343/1217] Fix spelling error in manpage --- cdist/conf/type/__zypper_service/man.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cdist/conf/type/__zypper_service/man.rst b/cdist/conf/type/__zypper_service/man.rst index ea48aebb..e082dc02 100644 --- a/cdist/conf/type/__zypper_service/man.rst +++ b/cdist/conf/type/__zypper_service/man.rst @@ -46,10 +46,10 @@ EXAMPLES # Ensure that internal SLES11 SP3 RIS is in installed and all other services and repos are discarded __zypper_service INTERNAL_SLES11_SP3 --service_desc "Internal SLES11 SP3 RIS" --uri "http://path/to/your/ris/dir" --remove-all-other-services --remove-all-repos - # Ensure that internal SLES11 SP3 RIS is in installed, no changes to ohter services or repos + # Ensure that internal SLES11 SP3 RIS is in installed, no changes to other services or repos __zypper_service INTERNAL_SLES11_SP3 --service_desc "Internal SLES11 SP3 RIS" --uri "http://path/to/your/ris/dir" - # Drop service by uri, no changes to ohter services or repos + # Drop service by uri, no changes to other services or repos __zypper_service INTERNAL_SLES11_SP3 --state absent --uri "http://path/to/your/ris/dir" From 31b9859e08d685032a4bc15eca0ed6f80cfb9fdd Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Tue, 23 Apr 2019 17:22:02 +0200 Subject: [PATCH 0344/1217] ++changelog --- docs/changelog | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/changelog b/docs/changelog index bf106861..c64ca60a 100644 --- a/docs/changelog +++ b/docs/changelog @@ -1,6 +1,9 @@ Changelog --------- +next: + * Type __zypper_service: Fix spelling error in manpage (Dmitry Bogatov) + 4.11.1: 2019-04-22 * Core: Improve explorer error reporting (Darko Poljak) * Type __directory: explorer stat: add support for Solaris (Ander Punnar) From 894311a57200c5bc2094890033d6df0867d52c43 Mon Sep 17 00:00:00 2001 From: Ander Punnar Date: Wed, 24 Apr 2019 00:08:43 +0300 Subject: [PATCH 0345/1217] __acl: if users/groups check fail, log error and exit in explorer --- cdist/conf/type/__acl/explorer/missing_users_groups | 3 ++- cdist/conf/type/__acl/gencode-remote | 8 -------- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/cdist/conf/type/__acl/explorer/missing_users_groups b/cdist/conf/type/__acl/explorer/missing_users_groups index b4af614c..2f3b9e6d 100755 --- a/cdist/conf/type/__acl/explorer/missing_users_groups +++ b/cdist/conf/type/__acl/explorer/missing_users_groups @@ -40,7 +40,8 @@ do if ! getent "$getent_db" "$check" > /dev/null then - echo "missing $parameter '$check'" + echo "missing $parameter '$check'" >&2 + exit 1 fi done \ < "$__object/parameter/$parameter" diff --git a/cdist/conf/type/__acl/gencode-remote b/cdist/conf/type/__acl/gencode-remote index a0f25a15..c0594497 100755 --- a/cdist/conf/type/__acl/gencode-remote +++ b/cdist/conf/type/__acl/gencode-remote @@ -22,14 +22,6 @@ file_is="$( cat "$__object/explorer/file_is" )" [ "$file_is" = 'missing' ] && exit 0 -missing_users_groups="$( cat "$__object/explorer/missing_users_groups" )" - -if [ -n "$missing_users_groups" ] -then - echo "$missing_users_groups" >&2 - exit 1 -fi - os="$( cat "$__global/explorer/os" )" acl_is="$( cat "$__object/explorer/acl_is" )" From d66b6969f31ea2c7690a0b85a41a76d07b7ac3e0 Mon Sep 17 00:00:00 2001 From: Ander Punnar Date: Wed, 24 Apr 2019 00:09:49 +0300 Subject: [PATCH 0346/1217] __acl: rename missing_users_groups explorer to more generic name for future checks --- cdist/conf/type/__acl/explorer/{missing_users_groups => checks} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename cdist/conf/type/__acl/explorer/{missing_users_groups => checks} (100%) diff --git a/cdist/conf/type/__acl/explorer/missing_users_groups b/cdist/conf/type/__acl/explorer/checks similarity index 100% rename from cdist/conf/type/__acl/explorer/missing_users_groups rename to cdist/conf/type/__acl/explorer/checks From f586937614383ebf67e2bcbf061c0ab7b7847620 Mon Sep 17 00:00:00 2001 From: Ander Punnar Date: Wed, 24 Apr 2019 00:36:53 +0300 Subject: [PATCH 0347/1217] __acl: drop Solaris because POSIX-draft ACL specification is not supported --- cdist/conf/type/__acl/gencode-remote | 44 ++++++++++++---------------- cdist/conf/type/__acl/man.rst | 6 ++-- 2 files changed, 20 insertions(+), 30 deletions(-) diff --git a/cdist/conf/type/__acl/gencode-remote b/cdist/conf/type/__acl/gencode-remote index c0594497..61a83c8c 100755 --- a/cdist/conf/type/__acl/gencode-remote +++ b/cdist/conf/type/__acl/gencode-remote @@ -74,34 +74,26 @@ fi if [ -f "$__object/parameter/remove" ] then - if echo "$os" | grep -Fq 'solaris' - then - # Solaris setfacl behaves differently. - # We will not support Solaris for now, because no way to test it. - # But adding support should be easy (use -s instead of -m on modify). - echo "$os setfacl do not support -x flag for ACL remove" >&2 - else - echo "$acl_is" | while read -r acl - do - # Skip wanted ACL entries which already exist - # and skip mask and other entries, because we - # can't actually remove them, but only change. - if echo "$acl_should" | grep -Eq "^$acl" \ - || echo "$acl" | grep -Eq '^(default:)?(mask|other)' - then continue - fi + echo "$acl_is" | while read -r acl + do + # Skip wanted ACL entries which already exist + # and skip mask and other entries, because we + # can't actually remove them, but only change. + if echo "$acl_should" | grep -Eq "^$acl" \ + || echo "$acl" | grep -Eq '^(default:)?(mask|other)' + then continue + fi - if echo "$os" | grep -Eq 'macosx|freebsd' - then - remove="$acl" - else - remove="$( echo "$acl" | sed 's/:...$//' )" - fi + if echo "$os" | grep -Eq 'macosx|freebsd' + then + remove="$acl" + else + remove="$( echo "$acl" | sed 's/:...$//' )" + fi - echo "$setfacl_exec -x \"$remove\" \"$acl_path\"" - echo "removed '$remove'" >> "$__messages_out" - done - fi + echo "$setfacl_exec -x \"$remove\" \"$acl_path\"" + echo "removed '$remove'" >> "$__messages_out" + done fi for acl in $acl_should diff --git a/cdist/conf/type/__acl/man.rst b/cdist/conf/type/__acl/man.rst index 092eb555..e6784c87 100644 --- a/cdist/conf/type/__acl/man.rst +++ b/cdist/conf/type/__acl/man.rst @@ -10,11 +10,9 @@ DESCRIPTION ----------- ACL must be defined as 3-symbol combination, using ``r``, ``w``, ``x`` and ``-``. -Fully supported on Linux (tested on Debian and CentOS). +Fully supported and tested on Linux, partial support for FreeBSD. -Partial support for FreeBSD, OSX and Solaris. - -OpenBSD and NetBSD support is not possible. +OpenBSD, NetBSD and Solaris support is not possible. See ``setfacl`` and ``acl`` manpages for more details. From 4c21983698932e17ca9276873e32a908b4235bf7 Mon Sep 17 00:00:00 2001 From: Ander Punnar Date: Wed, 24 Apr 2019 00:39:54 +0300 Subject: [PATCH 0348/1217] __acl: remove macosx because no way to properly test --- cdist/conf/type/__acl/gencode-remote | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cdist/conf/type/__acl/gencode-remote b/cdist/conf/type/__acl/gencode-remote index 61a83c8c..ef903816 100755 --- a/cdist/conf/type/__acl/gencode-remote +++ b/cdist/conf/type/__acl/gencode-remote @@ -64,7 +64,7 @@ setfacl_exec='setfacl' if [ -f "$__object/parameter/recursive" ] then - if echo "$os" | grep -Eq 'macosx|freebsd' + if echo "$os" | grep -Fq 'freebsd' then echo "$os setfacl do not support recursive operations" >&2 else @@ -84,7 +84,7 @@ then then continue fi - if echo "$os" | grep -Eq 'macosx|freebsd' + if echo "$os" | grep -Fq 'freebsd' then remove="$acl" else @@ -100,7 +100,7 @@ for acl in $acl_should do if ! echo "$acl_is" | grep -Eq "^$acl" then - if echo "$os" | grep -Eq 'macosx|freebsd' \ + if echo "$os" | grep -Fq 'freebsd' \ && echo "$acl" | grep -Eq '^default:' then echo "setting default ACL in $os is currently not supported. sorry :(" >&2 From 510ea220f275caf2667547c55b54f06b55965bf5 Mon Sep 17 00:00:00 2001 From: Takashi Yoshi Date: Wed, 24 Apr 2019 11:02:32 +0200 Subject: [PATCH 0349/1217] [type/__block] Quote prefix and suffix correctly Before prefix and suffix were not allowed to contain " (quotes). --- cdist/conf/type/__block/gencode-remote | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cdist/conf/type/__block/gencode-remote b/cdist/conf/type/__block/gencode-remote index f269c785..1f5cc033 100755 --- a/cdist/conf/type/__block/gencode-remote +++ b/cdist/conf/type/__block/gencode-remote @@ -18,6 +18,11 @@ # along with cdist. If not, see . # +# quote function from http://www.etalabs.net/sh_tricks.html +quote() { + printf '%s\n' "$1" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/'/" +} + file="$(cat "$__object/parameter/file" 2>/dev/null || echo "/$__object_id")" state_should=$(cat "$__object/parameter/state") prefix=$(cat "$__object/parameter/prefix" 2>/dev/null || echo "#cdist:__block/$__object_id") @@ -46,7 +51,7 @@ tmpfile=\$(mktemp ${file}.cdist.XXXXXXXXXX) if [ -f "$file" ]; then cp -p "$file" "\$tmpfile" fi -awk -v prefix="^$prefix\$" -v suffix="^$suffix\$" ' +awk -v prefix=^$(quote "$prefix")\$ -v suffix=^$(quote "$suffix")\$ ' { if (match(\$0,prefix)) { triggered=1 From 6dd5278aded69d62db030a53cfefb4dac1b46023 Mon Sep 17 00:00:00 2001 From: Takashi Yoshi Date: Wed, 24 Apr 2019 11:15:44 +0200 Subject: [PATCH 0350/1217] [explorer/init] Add support for OpenBSD --- cdist/conf/explorer/init | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cdist/conf/explorer/init b/cdist/conf/explorer/init index 43a66a50..a8a7857e 100755 --- a/cdist/conf/explorer/init +++ b/cdist/conf/explorer/init @@ -29,7 +29,7 @@ case "$uname_s" in Linux) (pgrep -P0 -l | awk '/^1[ \t]/ {print $2;}') || true ;; - FreeBSD) + FreeBSD|OpenBSD) ps -o comm= -p 1 || true ;; *) From f7ace88ec25957a71bf621cfefdc2e91db7d7994 Mon Sep 17 00:00:00 2001 From: Takashi Yoshi Date: Wed, 24 Apr 2019 11:36:57 +0200 Subject: [PATCH 0351/1217] [__postgres_{database,role}] Run psql with --no-password (-w) cdist does not work with interactive processes, so it's better to fail when manual password input is required. --- cdist/conf/type/__postgres_database/explorer/state | 2 +- cdist/conf/type/__postgres_role/explorer/state | 2 +- cdist/conf/type/__postgres_role/gencode-remote | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cdist/conf/type/__postgres_database/explorer/state b/cdist/conf/type/__postgres_database/explorer/state index 652d81e7..d68d4120 100755 --- a/cdist/conf/type/__postgres_database/explorer/state +++ b/cdist/conf/type/__postgres_database/explorer/state @@ -34,7 +34,7 @@ esac name="$__object_id" -if test -n "$(su - "$postgres_user" -c "psql postgres -tAc \"SELECT 1 FROM pg_database WHERE datname='$name'\"")" +if test -n "$(su - "$postgres_user" -c "psql postgres -twAc \"SELECT 1 FROM pg_database WHERE datname='$name'\"")" then echo 'present' else diff --git a/cdist/conf/type/__postgres_role/explorer/state b/cdist/conf/type/__postgres_role/explorer/state index 5cc71477..c8e1fa9d 100755 --- a/cdist/conf/type/__postgres_role/explorer/state +++ b/cdist/conf/type/__postgres_role/explorer/state @@ -34,7 +34,7 @@ esac name="$__object_id" -if test -n "$(su - "$postgres_user" -c "psql postgres -tAc \"SELECT 1 FROM pg_roles WHERE rolname='$name'\"")" +if test -n "$(su - "$postgres_user" -c "psql postgres -twAc \"SELECT 1 FROM pg_roles WHERE rolname='$name'\"")" then echo 'present' else diff --git a/cdist/conf/type/__postgres_role/gencode-remote b/cdist/conf/type/__postgres_role/gencode-remote index 30d0689c..fd56e85d 100755 --- a/cdist/conf/type/__postgres_role/gencode-remote +++ b/cdist/conf/type/__postgres_role/gencode-remote @@ -55,7 +55,7 @@ case "$state_should" in [ -n "$password" ] && password="PASSWORD '$password'" cmd="CREATE ROLE $name WITH $password $booleans" - echo "su - '$postgres_user' -c \"psql postgres -c \\\"$cmd\\\"\"" + echo "su - '$postgres_user' -c \"psql postgres -wc \\\"$cmd\\\"\"" ;; absent) echo "su - '$postgres_user' -c \"dropuser \\\"$name\\\"\"" From 3ca337dfe0878a71ca14e550111d31fffa14b461 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Wed, 24 Apr 2019 12:23:37 +0200 Subject: [PATCH 0352/1217] ++changelog --- docs/changelog | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/changelog b/docs/changelog index c64ca60a..ca66a0f0 100644 --- a/docs/changelog +++ b/docs/changelog @@ -3,6 +3,10 @@ Changelog next: * Type __zypper_service: Fix spelling error in manpage (Dmitry Bogatov) + * Explorer init: Add support for OpenBSD (sideeffect42) + * Type __postgres_database: Run psql with -w (no-password) (sideeffect42) + * Type __postgres_role: Run psql with -w (no-password) (sideeffect42) + * Type __block: Quote prefix/suffix - fix when prefix/suffix contains quotes (sideeffect42) 4.11.1: 2019-04-22 * Core: Improve explorer error reporting (Darko Poljak) From 8b93bf0218cf2097976159dab332dcaaff3f5eb4 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Sun, 30 Dec 2018 11:59:34 +0100 Subject: [PATCH 0353/1217] Migrate from github to ungleich gitlab --- bin/build-helper | 49 ++++++++---------- bin/build-helper.freebsd | 48 ++++++++---------- cdist/conf/type/__cdist/man.rst | 4 +- .../type/__cdist/parameter/default/source | 2 +- cdist/conf/type/__git/man.rst | 2 +- docs/dev/github-gitlab-migration/release | 50 +++++++++++++++++++ docs/src/cdist-hacker.rst | 20 ++++---- docs/src/cdist-install.rst | 13 ++--- docs/src/cdist-quickstart.rst | 2 +- 9 files changed, 112 insertions(+), 78 deletions(-) create mode 100755 docs/dev/github-gitlab-migration/release diff --git a/bin/build-helper b/bin/build-helper index 963f02f9..72f683b9 100755 --- a/bin/build-helper +++ b/bin/build-helper @@ -209,35 +209,30 @@ eof fi gpg --armor --detach-sign "${archivename}" || exit 1 - # make github release - curl -H "Authorization: token ${token}" \ - --request POST \ - --data "{ \"tag_name\":\"${tag}\", \ - \"target_commitish\":\"master\", \ - \"name\": \"${tag}\", \ - \"body\":\"${tag}\", \ - \"draft\":false, \ - \"prerelease\": false}" \ - "https://api.github.com/repos/ungleich/cdist/releases" || exit 1 + project="ungleich-public%2Fcdist" + sed_cmd='s/^.*"markdown":"\([^"]*\)".*$/\1/' - # get release ID - repoid=$(curl "https://api.github.com/repos/ungleich/cdist/releases/tags/${tag}" \ - | python3 -c 'import json; import sys; print(json.loads(sys.stdin.read())["id"])') \ + # upload archive + response_archive=$(curl -f -X POST \ + -H "PRIVATE-TOKEN: ${token}" \ + -F "file=@${archivename}" \ + "https://code.ungleich.ch/api/v4/projects/${project}/uploads" \ + | sed "${sed_cmd}") || exit 1 + + # upload archive signature + response_archive_sig=$(curl -f -X POST \ + -H "PRIVATE-TOKEN: ${token}" \ + -F "file=@${archivename}.asc" \ + "https://code.ungleich.ch/api/v4/projects/${project}/uploads" \ + | sed "${sed_cmd}") || exit 1 + + # make release + curl -f -X POST \ + -H "PRIVATE-TOKEN: ${token}" \ + -F "description=Release ${tag}
${response_archive}
${response_archive_sig}" \ + "https://code.ungleich.ch/api/v4/projects/${project}/repository/tags/${tag}/release" \ || exit 1 - # upload archive and then signature - curl -H "Authorization: token ${token}" \ - -H "Accept: application/vnd.github.manifold-preview" \ - -H "Content-Type: application/x-gtar" \ - --data-binary @${archivename} \ - "https://uploads.github.com/repos/ungleich/cdist/releases/${repoid}/assets?name=${archivename}" \ - || exit 1 - curl -H "Authorization: token ${token}" \ - -H "Accept: application/vnd.github.manifold-preview" \ - -H "Content-Type: application/pgp-signature" \ - --data-binary @${archivename}.asc \ - "https://uploads.github.com/repos/ungleich/cdist/releases/${repoid}/assets?name=${archivename}.asc" \ - || exit 1 # remove generated files (archive and asc) if [ $# -eq 2 ] @@ -314,7 +309,7 @@ eof "$0" release-git-tag # sign git tag - printf "Enter github authentication token: " + printf "Enter upstream repository authentication token: " read token "$0" sign-git-release "${target_version}" "${token}" diff --git a/bin/build-helper.freebsd b/bin/build-helper.freebsd index ea16ef42..cb8e5397 100755 --- a/bin/build-helper.freebsd +++ b/bin/build-helper.freebsd @@ -244,34 +244,28 @@ eof fi gpg --armor --detach-sign "${archivename}" || exit 1 - # make github release - curl -H "Authorization: token ${token}" \ - --request POST \ - --data "{ \"tag_name\":\"${tag}\", \ - \"target_commitish\":\"master\", \ - \"name\": \"${tag}\", \ - \"body\":\"${tag}\", \ - \"draft\":false, \ - \"prerelease\": false}" \ - "https://api.github.com/repos/ungleich/cdist/releases" || exit 1 + project="ungleich-public%2Fcdist" + sed_cmd='s/^.*"markdown":"\([^"]*\)".*$/\1/' - # get release ID - repoid=$(curl "https://api.github.com/repos/ungleich/cdist/releases/tags/${tag}" \ - | python3 -c 'import json; import sys; print(json.loads(sys.stdin.read())["id"])') \ - || exit 1 + # upload archive + response_archive=$(curl -f -X POST \ + -H "PRIVATE-TOKEN: ${token}" \ + -F "file=@${archivename}" \ + "https://code.ungleich.ch/api/v4/projects/${project}/uploads" \ + | sed "${sed_cmd}") || exit 1 - # upload archive and then signature - curl -H "Authorization: token ${token}" \ - -H "Accept: application/vnd.github.manifold-preview" \ - -H "Content-Type: application/x-gtar" \ - --data-binary @${archivename} \ - "https://uploads.github.com/repos/ungleich/cdist/releases/${repoid}/assets?name=${archivename}" \ - || exit 1 - curl -H "Authorization: token ${token}" \ - -H "Accept: application/vnd.github.manifold-preview" \ - -H "Content-Type: application/pgp-signature" \ - --data-binary @${archivename}.asc \ - "https://uploads.github.com/repos/ungleich/cdist/releases/${repoid}/assets?name=${archivename}.asc" \ + # upload archive signature + response_archive_sig=$(curl -f -X POST \ + -H "PRIVATE-TOKEN: ${token}" \ + -F "file=@${archivename}.asc" \ + "https://code.ungleich.ch/api/v4/projects/${project}/uploads" \ + | sed "${sed_cmd}") || exit 1 + + # make release + curl -f -X POST \ + -H "PRIVATE-TOKEN: ${token}" \ + -F "description=Release ${tag}
${response_archive}
${response_archive_sig}" \ + "https://code.ungleich.ch/api/v4/projects/${project}/repository/tags/${tag}/release" \ || exit 1 # remove generated files (archive and asc) @@ -349,7 +343,7 @@ eof "$0" release-git-tag # sign git tag - printf "Enter github authentication token: " + printf "Enter upstream repository authentication token: " read token "$0" sign-git-release "${target_version}" "${token}" diff --git a/cdist/conf/type/__cdist/man.rst b/cdist/conf/type/__cdist/man.rst index 9e1c72cb..15c77d7f 100644 --- a/cdist/conf/type/__cdist/man.rst +++ b/cdist/conf/type/__cdist/man.rst @@ -30,7 +30,7 @@ username source Select the source from which to clone cdist from. - Defaults to "git://github.com/ungleich/cdist.git". + Defaults to "git://code.ungleich.ch/ungleich-public/cdist.git". branch @@ -47,7 +47,7 @@ EXAMPLES __cdist /home/cdist/cdist # Use alternative source - __cdist --source "git://github.com/ungleich/cdist" /home/cdist/cdist + __cdist --source "git://code.ungleich.ch/ungleich-public/cdist" /home/cdist/cdist AUTHORS diff --git a/cdist/conf/type/__cdist/parameter/default/source b/cdist/conf/type/__cdist/parameter/default/source index 3f8e31ad..5f44a285 100644 --- a/cdist/conf/type/__cdist/parameter/default/source +++ b/cdist/conf/type/__cdist/parameter/default/source @@ -1 +1 @@ -git://github.com/ungleich/cdist.git +git://code.ungleich.ch/ungleich-public/cdist.git diff --git a/cdist/conf/type/__git/man.rst b/cdist/conf/type/__git/man.rst index 17e9c623..aa704d2b 100644 --- a/cdist/conf/type/__git/man.rst +++ b/cdist/conf/type/__git/man.rst @@ -44,7 +44,7 @@ EXAMPLES __git /home/services/dokuwiki --source git://github.com/splitbrain/dokuwiki.git # Checkout cdist, stay on branch 2.1 - __git /home/nico/cdist --source git://github.com/ungleich/cdist.git --branch 2.1 + __git /home/nico/cdist --source git://code.ungleich.ch/ungleich-public/cdist.git --branch 2.1 AUTHORS diff --git a/docs/dev/github-gitlab-migration/release b/docs/dev/github-gitlab-migration/release new file mode 100755 index 00000000..c973f0f1 --- /dev/null +++ b/docs/dev/github-gitlab-migration/release @@ -0,0 +1,50 @@ +#!/bin/sh -e + +set -x + +printf "Enter tag name: " +read tag +printf "Enter repository authentication token: " +read token + +git tag -d "${tag}" || : + +git tag "${tag}" -m "Release ${tag}" +git push origin "${tag}" + +echo 'foo' > foo +echo 'foo signature' > foo.asc + +archivename="foo" + +project="poljakowski%2Fmy-cdist-testing" +sed_cmd='s/^.*"markdown":"\([^"]*\)".*$/\1/' + +# upload archive +response_archive=$(curl -f -X POST \ + -H "PRIVATE-TOKEN: ${token}" \ + -F "file=@${archivename}" \ + "https://code.ungleich.ch/api/v4/projects/${project}/uploads" \ + | sed "${sed_cmd}") || exit 1 + +# upload archive signature +response_archive_sig=$(curl -f -X POST \ + -H "PRIVATE-TOKEN: ${token}" \ + -F "file=@${archivename}.asc" \ + "https://code.ungleich.ch/api/v4/projects/${project}/uploads" \ + | sed "${sed_cmd}") || exit 1 + +# make release +curl -f -X POST \ + -H "PRIVATE-TOKEN: ${token}" \ + -F "description=Release ${tag}
${response_archive}
${response_archive_sig}" \ + "https://code.ungleich.ch/api/v4/projects/${project}/repository/tags/${tag}/release" \ + || exit 1 + +# get tag +curl -f -X GET \ + -H "PRIVATE-TOKEN: ${token}" \ + "https://code.ungleich.ch/api/v4/projects/${project}/repository/tags/${tag}" \ + || exit 1 + +rm -f foo foo.asc diff --git a/docs/src/cdist-hacker.rst b/docs/src/cdist-hacker.rst index d65c41a6..e4252e19 100644 --- a/docs/src/cdist-hacker.rst +++ b/docs/src/cdist-hacker.rst @@ -16,7 +16,7 @@ Reporting bugs -------------- If you believe you've found a bug and verified that it is in the latest version, drop a mail to the cdist mailing list, -subject prefixed with "[BUG] " or create an issue on github. +subject prefixed with "[BUG] " or create an issue on code.ungleich.ch. Coding conventions (everywhere) @@ -51,7 +51,7 @@ work nor kill the authors brain: As soon as your work meets these requirements, write a mail for inclusion to the mailinglist **cdist-configuration-management at googlegroups.com** -or open a pull request at http://github.com/ungleich/cdist. +or open a merge request at https://code.ungleich.ch/ungleich-public/cdist. How to submit a new type @@ -76,7 +76,7 @@ The following workflow works fine for most developers .. code-block:: sh # get latest upstream master branch - git clone https://github.com/ungleich/cdist.git + git clone https://code.ungleich.ch/ungleich-public/cdist.git # update if already existing cd cdist; git fetch -v; git merge origin/master @@ -88,22 +88,22 @@ The following workflow works fine for most developers # *hack* *hack* - # clone the cdist repository on github if you haven't done so + # clone the cdist repository on code.ungleich.ch if you haven't done so # configure your repo to know about your clone (only once) - git remote add github git@github.com:YOURUSERNAME/cdist.git + git remote add ungleich git@code.ungleich.ch:YOURUSERNAME/cdist.git - # push the new branch to github - git push github documentation_cleanup + # push the new branch to ungleich gitlab + git push ungleich documentation_cleanup # (or everything) - git push --mirror github + git push --mirror ungleich - # create a pull request at github (use a browser) + # create a merge request at ungleich gitlab (use a browser) # *fixthingsbecausequalityassurancefoundissuesinourpatch* *hack* - # push code to github again + # push code to ungleich gitlab again git push ... # like above # add comment that everything should be green now (use a browser) diff --git a/docs/src/cdist-install.rst b/docs/src/cdist-install.rst index afc50016..c05036b0 100644 --- a/docs/src/cdist-install.rst +++ b/docs/src/cdist-install.rst @@ -36,10 +36,13 @@ To install cdist, execute the following commands: .. code-block:: sh - git clone https://github.com/ungleich/cdist.git + git clone https://code.ungleich.ch/ungleich-public/cdist.git cd cdist export PATH=$PATH:$(pwd -P)/bin +From version 4.2.0 cdist tags and releases are signed. +You can get GPG public key used for signing `here <_static/pgp-key-EFD2AE4EC36B6901.asc>`_. + To install cdist with distutils from cloned repository, first you have to create version.py: @@ -74,14 +77,6 @@ So for instance if you want to use and stay with version 4.1, you can use git checkout -b 4.1 origin/4.1 -Git mirrors -^^^^^^^^^^^ - -If the main site is down, you can acquire cdist from one of the following sites: - - * git://github.com/telmich/cdist.git `github `_ - * git://git.code.sf.net/p/cdist/code `sourceforge `_ - Building and using documentation (man and html) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/docs/src/cdist-quickstart.rst b/docs/src/cdist-quickstart.rst index 0020568d..b9220b67 100644 --- a/docs/src/cdist-quickstart.rst +++ b/docs/src/cdist-quickstart.rst @@ -56,7 +56,7 @@ code into your shell to get started and configure localhost:: # Get cdist # Mirrors can be found on # http://www.nico.schottelius.org/software/cdist/install/#index2h4 - git clone git://github.com/ungleich/cdist + git clone git://code.ungleich.ch/ungleich-public/cdist # Create manifest (maps configuration to host(s) cd cdist From 6ad261fdf26466be47d9d49b54f17bc34d6392b7 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Thu, 25 Apr 2019 23:04:38 +0200 Subject: [PATCH 0354/1217] ++changelog --- docs/changelog | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/changelog b/docs/changelog index ca66a0f0..9c87d3f7 100644 --- a/docs/changelog +++ b/docs/changelog @@ -7,6 +7,8 @@ next: * Type __postgres_database: Run psql with -w (no-password) (sideeffect42) * Type __postgres_role: Run psql with -w (no-password) (sideeffect42) * Type __block: Quote prefix/suffix - fix when prefix/suffix contains quotes (sideeffect42) + * Build: Update due to migration to code.ungleich.ch (Darko Poljak) + * Documentation: Update due to migration to code.ungleich.ch (Darko Poljak) 4.11.1: 2019-04-22 * Core: Improve explorer error reporting (Darko Poljak) From 2505023387ea670fa12af1e9c69c503ac5681136 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Wed, 1 May 2019 12:31:30 +0200 Subject: [PATCH 0355/1217] Append requirement only if already not present --- cdist/emulator.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cdist/emulator.py b/cdist/emulator.py index 5103f1a4..3cf82f84 100644 --- a/cdist/emulator.py +++ b/cdist/emulator.py @@ -319,7 +319,9 @@ class Emulator(object): lastcreatedtype) else: if 'require' in self.env: - self.env['require'] += " " + lastcreatedtype + appendix = " " + lastcreatedtype + if appendix not in self.env['require']: + self.env['require'] += appendix else: self.env['require'] = lastcreatedtype self.log.debug(("Injecting require for " From edfaa65d2b37fcb4a7de2280b61dec30dd3a8c5d Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Wed, 1 May 2019 14:18:39 +0200 Subject: [PATCH 0356/1217] Detect dependency cycle as soon as possible --- cdist/config.py | 59 ++++++++++++++++++++++++++++-- cdist/test/config/__init__.py | 68 +++++++++++++++++++++++++++++++++-- 2 files changed, 123 insertions(+), 4 deletions(-) diff --git a/cdist/config.py b/cdist/config.py index fae2ff46..4e226b3a 100644 --- a/cdist/config.py +++ b/cdist/config.py @@ -43,6 +43,33 @@ from cdist import core, inventory from cdist.util.remoteutil import inspect_ssh_mux_opts +def graph_check_cycle(graph): + # Start from each node in the graph and check for cycle starting from it. + for node in graph: + # Cycle path. + path = [node] + has_cycle = _graph_dfs_cycle( graph, node, path) + if has_cycle: + return has_cycle, path + return False, None + + +def _graph_dfs_cycle(graph, node, path): + for neighbour in graph.get(node, ()): + # If node is already in path then this is cycle. + if neighbour in path: + path.append(neighbour) + return True + path.append(neighbour) + rv = _graph_dfs_cycle(graph, neighbour, path) + if rv: + return True + # Remove last item from list - neighbour whose DFS path we have have + # just checked. + del path[-1] + return False + + class Config(object): """Cdist main class to hold arbitrary data""" @@ -254,14 +281,14 @@ class Config(object): cls.onehost(host, host_tags, host_base_path, hostdir, args, parallel=False, configuration=configuration) - except cdist.Error as e: + except cdist.Error: failed_hosts.append(host) if args.parallel and len(process_args) == 1: log.debug("Only 1 host for parallel processing, doing it " "sequentially") try: cls.onehost(*process_args[0]) - except cdist.Error as e: + except cdist.Error: failed_hosts.append(host) elif args.parallel: log.trace("Multiprocessing start method is {}".format( @@ -653,6 +680,28 @@ class Config(object): self.__dict__.update(state) self._open_logger() + def _validate_dependencies(self): + ''' + Build dependency graph for unfinished objects and + check for cycles. + ''' + graph = {} + for cdist_object in self.object_list(): + obj_name = cdist_object.name + if obj_name not in graph: + graph[obj_name] = [] + if cdist_object.state == cdist_object.STATE_DONE: + continue + + for requirement in cdist_object.requirements_unfinished( + cdist_object.requirements): + graph[obj_name].append(requirement.name) + + for requirement in cdist_object.requirements_unfinished( + cdist_object.autorequire): + graph[obj_name].append(requirement.name) + return graph_check_cycle(graph) + def iterate_until_finished(self): """ Go through all objects and solve them @@ -662,6 +711,12 @@ class Config(object): objects_changed = True while objects_changed: + # Check for cycles as early as possible. + has_cycle, path = self._validate_dependencies() + if has_cycle: + raise cdist.UnresolvableRequirementsError( + "Cycle detected in object dependencies:\n{}!".format( + " -> ".join(path))) objects_changed = self.iterate_once() # Check whether all objects have been finished diff --git a/cdist/test/config/__init__.py b/cdist/test/config/__init__.py index 2b0d8b5f..499593e3 100644 --- a/cdist/test/config/__init__.py +++ b/cdist/test/config/__init__.py @@ -23,7 +23,6 @@ import os import shutil -import tempfile from cdist import test from cdist import core @@ -212,7 +211,7 @@ class ConfigRunTestCase(test.CdistTestCase): dryrun.run() # if we are here, dryrun works like expected - def test_desp_resolver(self): + def test_deps_resolver(self): """Test to show dependency resolver warning message.""" local = cdist.exec.local.Local( target_host=self.target_host, @@ -229,6 +228,71 @@ class ConfigRunTestCase(test.CdistTestCase): config = cdist.config.Config(local, self.remote, dry_run=True) config.run() + def test_graph_check_cycle_empty(self): + graph = {} + has_cycle, path = cdist.config.graph_check_cycle(graph) + self.assertFalse(has_cycle) + + def test_graph_check_cycle_1(self): + # + # a -> b -> c + # | + # +--> d -> e + graph = { + 'a': ['b', ], + 'b': ['c', 'd', ], + 'd': ['e', ], + } + has_cycle, path = cdist.config.graph_check_cycle(graph) + self.assertFalse(has_cycle) + + def test_graph_check_cycle_2(self): + # + # a -> b -> c + # /\ | + # \ | + # +-------+ + graph = { + 'a': ['b', ], + 'b': ['c', ], + 'c': ['a', ], + } + has_cycle, path = cdist.config.graph_check_cycle(graph) + self.assertTrue(has_cycle) + self.assertGreater(path.count(path[-1]), 1) + + def test_graph_check_cycle_3(self): + # + # a -> b -> c + # \ \ + # \ +--> g + # \ /\ + # \ /| + # +-> d -> e | + # \ | + # + --> f + # + # h -> i --> j + # | /\ | + # \/ | \/ + # n m <- k + graph = { + 'a': ['b', 'd', ], + 'b': ['c', ], + 'c': ['g', ], + 'd': ['e', 'f', ], + 'e': ['g', ], + 'f': ['g', ], + 'h': ['i', 'n', ], + 'i': ['j', ], + 'j': ['k', ], + 'k': ['m', ], + 'm': ['i', ], + } + has_cycle, path = cdist.config.graph_check_cycle(graph) + self.assertTrue(has_cycle) + self.assertGreater(path.count(path[-1]), 1) + # Currently the resolving code will simply detect that this object does # not exist. It should probably check if the type is a singleton as well From 2a0a24ecccaf555591a560af934843e57f3689a2 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Fri, 3 May 2019 14:38:48 +0200 Subject: [PATCH 0357/1217] ++changelog --- docs/changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog b/docs/changelog index 9c87d3f7..d367ed47 100644 --- a/docs/changelog +++ b/docs/changelog @@ -9,6 +9,7 @@ next: * Type __block: Quote prefix/suffix - fix when prefix/suffix contains quotes (sideeffect42) * Build: Update due to migration to code.ungleich.ch (Darko Poljak) * Documentation: Update due to migration to code.ungleich.ch (Darko Poljak) + * Core: Detect and report dependency cycle as soon as possible (Darko Poljak) 4.11.1: 2019-04-22 * Core: Improve explorer error reporting (Darko Poljak) From 6258e397ed7ee64d394372dc2dd2953a236e04fe Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Fri, 3 May 2019 21:39:25 +0200 Subject: [PATCH 0358/1217] Include changelog in gitlab release --- bin/build-helper | 7 ++++++- bin/build-helper.freebsd | 7 ++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/bin/build-helper b/bin/build-helper index 72f683b9..d72c6cab 100755 --- a/bin/build-helper +++ b/bin/build-helper @@ -227,9 +227,14 @@ eof | sed "${sed_cmd}") || exit 1 # make release + changelog=$("$0" changelog-changes "$1" | sed 's/^[[:space:]]*//') + release_notes=$( + printf "Release %s\n\n%s\n\n%s\n\n**Changelog**\n\n%s\n" \ + "${tag}" "${response_archive}" "${response_archive_sig}" "${changelog}" + ) curl -f -X POST \ -H "PRIVATE-TOKEN: ${token}" \ - -F "description=Release ${tag}
${response_archive}
${response_archive_sig}" \ + -F "description=${release_notes}" \ "https://code.ungleich.ch/api/v4/projects/${project}/repository/tags/${tag}/release" \ || exit 1 diff --git a/bin/build-helper.freebsd b/bin/build-helper.freebsd index cb8e5397..4f393cb0 100755 --- a/bin/build-helper.freebsd +++ b/bin/build-helper.freebsd @@ -262,9 +262,14 @@ eof | sed "${sed_cmd}") || exit 1 # make release + changelog=$("$0" changelog-changes "$1" | sed 's/^[[:space:]]*//') + release_notes=$( + printf "Release %s\n\n%s\n\n%s\n\n**Changelog**\n\n%s\n" \ + "${tag}" "${response_archive}" "${response_archive_sig}" "${changelog}" + ) curl -f -X POST \ -H "PRIVATE-TOKEN: ${token}" \ - -F "description=Release ${tag}
${response_archive}
${response_archive_sig}" \ + -F "description=${release_notes}" \ "https://code.ungleich.ch/api/v4/projects/${project}/repository/tags/${tag}/release" \ || exit 1 From fe833fdfcb466ab460a76123b078a0e778cf924c Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Fri, 3 May 2019 21:46:17 +0200 Subject: [PATCH 0359/1217] Sign git tag as one of the last steps If it fails then the whole release should not fail, signing git tag can be tried again. --- bin/build-helper | 10 +++++----- bin/build-helper.freebsd | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/bin/build-helper b/bin/build-helper index d72c6cab..53dbf5da 100755 --- a/bin/build-helper +++ b/bin/build-helper @@ -313,11 +313,6 @@ eof # Tag the current commit "$0" release-git-tag - # sign git tag - printf "Enter upstream repository authentication token: " - read token - "$0" sign-git-release "${target_version}" "${token}" - # Also merge back the version branch if [ "$masterbranch" = yes ]; then git checkout master @@ -343,6 +338,11 @@ eof # Archlinux release is based on pypi make archlinux-release + # sign git tag + printf "Enter upstream repository authentication token: " + read token + "$0" sign-git-release "${target_version}" "${token}" + # Announce change on ML make ml-release diff --git a/bin/build-helper.freebsd b/bin/build-helper.freebsd index 4f393cb0..f3d1fca1 100755 --- a/bin/build-helper.freebsd +++ b/bin/build-helper.freebsd @@ -347,11 +347,6 @@ eof # Tag the current commit "$0" release-git-tag - # sign git tag - printf "Enter upstream repository authentication token: " - read token - "$0" sign-git-release "${target_version}" "${token}" - # Also merge back the version branch if [ "$masterbranch" = yes ]; then git checkout master @@ -393,6 +388,11 @@ eof ;; esac + # sign git tag + printf "Enter upstream repository authentication token: " + read token + "$0" sign-git-release "${target_version}" "${token}" + # Announce change on ML make helper=${helper} WEBDIR=${WEBDIR} ml-release ;; From 71945ef956a227d9abe33d0e415e2670fa6c0060 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Fri, 3 May 2019 21:55:27 +0200 Subject: [PATCH 0360/1217] Fix copy-paste thing --- bin/build-helper | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/build-helper b/bin/build-helper index 53dbf5da..b5898ae3 100755 --- a/bin/build-helper +++ b/bin/build-helper @@ -400,7 +400,7 @@ eof ;; shellcheck) - make helper=${helper} WEBDIR=${WEBDIR} shellcheck + make shellcheck printf "\\nPlease review shellcheck report.\\n" while true do From bd9884fac4c46c29d4313cadd40020bf8cf542be Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Fri, 3 May 2019 22:16:51 +0200 Subject: [PATCH 0361/1217] Tell curl to use HTTP version 1.1 By default, was getting the following error: curl: (92) HTTP/2 stream 0 was not closed cleanly: PROTOCOL_ERROR (err 1) --- bin/build-helper | 2 ++ bin/build-helper.freebsd | 2 ++ 2 files changed, 4 insertions(+) diff --git a/bin/build-helper b/bin/build-helper index b5898ae3..0fea5071 100755 --- a/bin/build-helper +++ b/bin/build-helper @@ -214,6 +214,7 @@ eof # upload archive response_archive=$(curl -f -X POST \ + --http1.1 \ -H "PRIVATE-TOKEN: ${token}" \ -F "file=@${archivename}" \ "https://code.ungleich.ch/api/v4/projects/${project}/uploads" \ @@ -221,6 +222,7 @@ eof # upload archive signature response_archive_sig=$(curl -f -X POST \ + --http1.1 \ -H "PRIVATE-TOKEN: ${token}" \ -F "file=@${archivename}.asc" \ "https://code.ungleich.ch/api/v4/projects/${project}/uploads" \ diff --git a/bin/build-helper.freebsd b/bin/build-helper.freebsd index f3d1fca1..9823dab5 100755 --- a/bin/build-helper.freebsd +++ b/bin/build-helper.freebsd @@ -249,6 +249,7 @@ eof # upload archive response_archive=$(curl -f -X POST \ + --http1.1 \ -H "PRIVATE-TOKEN: ${token}" \ -F "file=@${archivename}" \ "https://code.ungleich.ch/api/v4/projects/${project}/uploads" \ @@ -256,6 +257,7 @@ eof # upload archive signature response_archive_sig=$(curl -f -X POST \ + --http1.1 \ -H "PRIVATE-TOKEN: ${token}" \ -F "file=@${archivename}.asc" \ "https://code.ungleich.ch/api/v4/projects/${project}/uploads" \ From 0ab43e24055e00324e18852356f8e2b85637df94 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Sat, 13 Apr 2019 21:18:27 +0200 Subject: [PATCH 0362/1217] Release -j/--jobs option, i.e. make it non-beta --- cdist/argparse.py | 5 ++--- docs/src/cdist-parallelization.rst | 7 +++---- docs/src/man1/cdist.rst | 2 +- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/cdist/argparse.py b/cdist/argparse.py index 72fc0d0f..3ebdc138 100644 --- a/cdist/argparse.py +++ b/cdist/argparse.py @@ -11,7 +11,7 @@ import cdist.configuration BETA_COMMANDS = set(('install', 'inventory', )) # set of beta arguments for sub-commands BETA_ARGS = { - 'config': set(('jobs', 'tag', 'all_tagged_hosts', 'use_archiving', )), + 'config': set(('tag', 'all_tagged_hosts', 'use_archiving', )), } EPILOG = "Get cdist at http://www.nico.schottelius.org/software/cdist/" # Parser others can reuse @@ -191,8 +191,7 @@ def get_parsers(): name="positive int"), help=('Operate in parallel in specified maximum number of jobs. ' 'Global explorers, object prepare and object run are ' - 'supported. Without argument CPU count is used by default. ' - 'Currently in beta.'), + 'supported. Without argument CPU count is used by default. '), action='store', dest='jobs', const=multiprocessing.cpu_count()) parser['config_main'].add_argument( diff --git a/docs/src/cdist-parallelization.rst b/docs/src/cdist-parallelization.rst index ed3afae9..d458a128 100644 --- a/docs/src/cdist-parallelization.rst +++ b/docs/src/cdist-parallelization.rst @@ -12,8 +12,7 @@ The other way is to operate in parallel within one host where you specify the number of jobs. This is enabled with :strong:`-j/--jobs` option where you can specify the number of parallel jobs. By default, :strong:`multiprocessing.cpu_count()` is used. For this mode global explorers, -object preparation and object run are supported and this option is still in -:strong:`beta`. +object preparation and object run are supported. You can, of course, use those two options together. This means that each host will be processed by its own process. Within each process cdist will operate @@ -32,11 +31,11 @@ Examples # Configure hosts read from file hosts.file sequentially but using default # number of parallel jobs - $ cdist config -b -j -f hosts.file + $ cdist config -j -f hosts.file # Configure hosts read from file hosts.file in parallel using 16 # parallel jobs - $ cdist config -b -j 16 -p -f hosts.file + $ cdist config -j 16 -p -f hosts.file Caveats diff --git a/docs/src/man1/cdist.rst b/docs/src/man1/cdist.rst index 2eb0ce00..30832f2f 100644 --- a/docs/src/man1/cdist.rst +++ b/docs/src/man1/cdist.rst @@ -165,7 +165,7 @@ Install command is currently in beta. Operate in parallel in specified maximum number of jobs. Global explorers, object prepare and object run are supported. Without argument CPU count is used by - default. Currently in beta. + default. **-n, --dry-run** Do not execute code. From 249ac917d3ed0620be768e27c4baa34e02e962a1 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Tue, 23 Apr 2019 22:39:41 +0200 Subject: [PATCH 0363/1217] Changes due to new website --- .gitignore | 1 + Makefile | 61 +------ README | 3 +- bin/build-helper | 35 +--- bin/build-helper.freebsd | 99 +++-------- docs/src/_static/cdist-logo.jpeg | Bin 0 -> 12560 bytes docs/src/{ => _static}/cdist-logo.png | Bin .../_static}/pgp-key-EFD2AE4EC36B6901.asc | 0 docs/src/cdist-intro.rst | 15 -- docs/src/cdist-os.rst | 23 +-- docs/src/cdist-support.rst | 10 +- .../{cdist-update.rst => cdist-upgrade.rst} | 4 +- docs/src/conf.py | 5 +- docs/src/index.rst | 17 +- docs/web/cdist.mdwn | 21 --- docs/web/cdist/cdist-logo.png | Bin 1542 -> 0 bytes docs/web/cdist/documentation.mdwn | 12 -- docs/web/cdist/features.mdwn | 26 --- docs/web/cdist/install.mdwn | 103 ------------ docs/web/cdist/os.mdwn | 18 -- docs/web/cdist/support.mdwn | 28 ---- docs/web/cdist/update.mdwn | 158 ------------------ docs/web/cdist/update/2.0-to-2.1.mdwn | 118 ------------- docs/web/cdist/why.mdwn | 69 -------- 24 files changed, 62 insertions(+), 764 deletions(-) create mode 100644 docs/src/_static/cdist-logo.jpeg rename docs/src/{ => _static}/cdist-logo.png (100%) rename docs/{web/cdist => src/_static}/pgp-key-EFD2AE4EC36B6901.asc (100%) delete mode 100644 docs/src/cdist-intro.rst rename docs/src/{cdist-update.rst => cdist-upgrade.rst} (99%) delete mode 100644 docs/web/cdist.mdwn delete mode 100644 docs/web/cdist/cdist-logo.png delete mode 100644 docs/web/cdist/documentation.mdwn delete mode 100644 docs/web/cdist/features.mdwn delete mode 100644 docs/web/cdist/install.mdwn delete mode 100644 docs/web/cdist/os.mdwn delete mode 100644 docs/web/cdist/support.mdwn delete mode 100644 docs/web/cdist/update.mdwn delete mode 100644 docs/web/cdist/update/2.0-to-2.1.mdwn delete mode 100644 docs/web/cdist/why.mdwn diff --git a/.gitignore b/.gitignore index 460bbf28..4b80b425 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,7 @@ Session.vim # Temporary .netrwhist *~ +*.tmp # Auto-generated tag files tags # Persistent undo diff --git a/Makefile b/Makefile index 5f03997a..099812e2 100644 --- a/Makefile +++ b/Makefile @@ -24,13 +24,6 @@ DOCS_SRC_DIR=docs/src SPEECHDIR=docs/speeches TYPEDIR=cdist/conf/type -WEBSRCDIR=docs/web - -WEBDIR=$$HOME/vcs/www.nico.schottelius.org -WEBBLOG=$(WEBDIR)/blog -WEBBASE=$(WEBDIR)/software/cdist -WEBPAGE=$(WEBBASE).mdwn - CHANGELOG_VERSION=$(shell $(helper) changelog-version) CHANGELOG_FILE=docs/changelog @@ -47,7 +40,6 @@ SHELLCHECK_SKIP=grep -v ': __.*is referenced but not assigned.*\[SC2154\]' ################################################################################ # Manpages # -MAN1DSTDIR=$(DOCS_SRC_DIR)/man1 MAN7DSTDIR=$(DOCS_SRC_DIR)/man7 # Manpages #1: Types @@ -81,24 +73,6 @@ docs: man html docs-clean: $(SPHINXC) -# Manpages #5: release part -MANWEBDIR=$(WEBBASE)/man/$(CHANGELOG_VERSION) -HTMLBUILDDIR=docs/dist/html - -docs-dist: html - rm -rf "${MANWEBDIR}" - mkdir -p "${MANWEBDIR}" - # mkdir -p "${MANWEBDIR}/man1" "${MANWEBDIR}/man7" - # cp ${MAN1DSTDIR}/*.html ${MAN1DSTDIR}/*.css ${MANWEBDIR}/man1 - # cp ${MAN7DSTDIR}/*.html ${MAN7DSTDIR}/*.css ${MANWEBDIR}/man7 - cp -R ${HTMLBUILDDIR}/* ${MANWEBDIR} - cd ${MANWEBDIR} && git add . && git commit -m "cdist manpages update: $(CHANGELOG_VERSION)" || true - -man-latest-link: web-pub - # Fix ikiwiki, which does not like symlinks for pseudo security - ssh staticweb.ungleich.ch \ - "cd /home/services/www/nico/nico.schottelius.org/www/software/cdist/man/ && rm -f latest && ln -sf "$(CHANGELOG_VERSION)" latest" - # Manpages: .cdist Types DOT_CDIST_PATH=${HOME}/.cdist DOTMAN7DSTDIR=$(MAN7DSTDIR) @@ -111,7 +85,6 @@ DOTMANTYPES=$(subst /man.rst,.rst,$(DOTMANTYPEPREFIX)) $(DOTMAN7DSTDIR)/cdist-type%.rst: $(DOTTYPEDIR)/%/man.rst ln -sf "$^" $@ -# Manpages #3: generic part dotman: $(DOTMANTYPES) $(SPHINXM) @@ -120,7 +93,6 @@ dotman: $(DOTMANTYPES) # SPEECHESOURCES=$(SPEECHDIR)/*.tex SPEECHES=$(SPEECHESOURCES:.tex=.pdf) -SPEECHESWEBDIR=$(WEBBASE)/speeches # Create speeches and ensure Toc is up-to-date $(SPEECHDIR)/%.pdf: $(SPEECHDIR)/%.tex @@ -130,36 +102,6 @@ $(SPEECHDIR)/%.pdf: $(SPEECHDIR)/%.tex speeches: $(SPEECHES) -speeches-dist: speeches - rm -rf "${SPEECHESWEBDIR}" - mkdir -p "${SPEECHESWEBDIR}" - cp ${SPEECHES} "${SPEECHESWEBDIR}" - cd ${SPEECHESWEBDIR} && git add . && git commit -m "cdist speeches updated" || true - -################################################################################ -# Website -# - -BLOGFILE=$(WEBBLOG)/cdist-$(CHANGELOG_VERSION)-released.mdwn - -$(BLOGFILE): $(CHANGELOG_FILE) - $(helper) blog $(CHANGELOG_VERSION) $(BLOGFILE) - -web-blog: $(BLOGFILE) - -web-doc: - # Go to top level, because of cdist.mdwn - rsync -av "$(WEBSRCDIR)/" "${WEBBASE}/.." - cd "${WEBBASE}/.." && git add cdist* && git commit -m "cdist doc update" cdist* || true - -web-dist: web-blog web-doc - -web-pub: web-dist docs-dist speeches-dist - cd "${WEBDIR}" && make pub - -web-release-all: man-latest-link -web-release-all-no-latest: web-pub - ################################################################################ # Release: Mailinglist # @@ -239,6 +181,9 @@ clean: rm -f cdist-*.tar.gz rm -f cdist-*.tar.gz.asc + # Temp files + rm -f *.tmp + distclean: clean rm -f cdist/version.py diff --git a/README b/README index a67e25e3..caf2dac8 100644 --- a/README +++ b/README @@ -3,4 +3,5 @@ cdist cdist is a usable configuration management system. -For the web documentation have a look at docs/web/. +For the web documentation have a look at https://www.cdi.st/ +or at docs/src for reStructuredText manual. diff --git a/bin/build-helper b/bin/build-helper index 0fea5071..04b7621b 100755 --- a/bin/build-helper +++ b/bin/build-helper @@ -76,33 +76,6 @@ case "$option" in "$0" test ;; - blog) - version=$1; shift - blogfile=$1; shift - dir=${blogfile%/*} - file=${blogfile##*/} - - - cat << eof > "$blogfile" -[[!meta title="Cdist $version released"]] - -Here's a short overview about the changes found in version ${version}: - -eof - - $0 changelog-changes "$version" >> "$blogfile" - - cat << eof >> "$blogfile" -For more information visit the [[cdist homepage|software/cdist]]. - -[[!tag cdist config unix]] -eof - cd "$dir" - git add "$file" - # Allow git commit to fail if there are no changes - git commit -m "cdist blog update: $version" "$blogfile" || true - ;; - ml-release) if [ $# -ne 1 ]; then echo "$0 ml-release version" >&2 @@ -324,13 +297,6 @@ eof # Publish git changes make pub - # publish man, speeches, website - if [ "$masterbranch" = yes ]; then - make web-release-all - else - make web-release-all-no-latest - fi - # Ensure that pypi release has the right version "$0" version @@ -351,6 +317,7 @@ eof cat << eof Manual steps post release: + - cdist-web - linkedin - hackernews - reddit diff --git a/bin/build-helper.freebsd b/bin/build-helper.freebsd index 9823dab5..c292280c 100755 --- a/bin/build-helper.freebsd +++ b/bin/build-helper.freebsd @@ -31,30 +31,13 @@ basedir=${0%/*}/../ # .freebsd - run as freebsd basename=${0##*/} run_as=${basename#*.} -case "$run_as" in - freebsd) - to_a=cdist-configuration-management - to_d=googlegroups.com - from_a=darko.poljak - from_d=gmail.com - ml_name="Darko Poljak" - ml_sig_name="Darko" - # vars for make - WEBDIR=../vcs/www.nico.schottelius.org - ;; - *) - to_a=cdist - to_d=l.schottelius.org - from_a=nico-cdist - from_d=schottelius.org - ml_name="Nico -telmich- Schottelius" - ml_sig_name="Nico" - - # vars for make - WEBDIR=$$HOME/vcs/www.nico.schottelius.org - ;; -esac +to_a=cdist-configuration-management +to_d=googlegroups.com +from_a=darko.poljak +from_d=gmail.com +ml_name="Darko Poljak" +ml_sig_name="Darko" # Change to checkout directory cd "$basedir" @@ -66,7 +49,6 @@ option=$1; shift case "$option" in print-make-vars) printf "helper: ${helper}\n" - printf "WEBDIR: ${WEBDIR}\n" ;; print-runas) printf "run_as: $run_as\n" @@ -117,33 +99,6 @@ case "$option" in "$0" test ;; - blog) - version=$1; shift - blogfile=$1; shift - dir=${blogfile%/*} - file=${blogfile##*/} - - - cat << eof > "$blogfile" -[[!meta title="Cdist $version released"]] - -Here's a short overview about the changes found in version ${version}: - -eof - - $0 changelog-changes "$version" >> "$blogfile" - - cat << eof >> "$blogfile" -For more information visit the [[cdist homepage|software/cdist]]. - -[[!tag cdist config unix]] -eof - cd "$dir" - git add "$file" - # Allow git commit to fail if there are no changes - git commit -m "cdist blog update: $version" "$blogfile" || true - ;; - ml-release) if [ $# -ne 1 ]; then echo "$0 ml-release version" >&2 @@ -159,7 +114,7 @@ eof cat << eof From: ${ml_name} <$from> To: cdist mailing list <$to> -Subject: cdist $version released +Subject: cdist $version has been released Hello .*, @@ -177,7 +132,7 @@ ${ml_sig_name} -- Automatisation at its best level. With cdist. eof - ) | /usr/sbin/sendmail -f "$from" "$to" + ) > mailinglist.tmp ;; release-git-tag) @@ -337,11 +292,11 @@ eof # Generate documentation (man and html) # First, clean old generated docs - make helper=${helper} WEBDIR=${WEBDIR} docs-clean - make helper=${helper} WEBDIR=${WEBDIR} docs + make helper=${helper} docs-clean + make helper=${helper} docs # Generate speeches (indirect check if they build) - make helper=${helper} WEBDIR=${WEBDIR} speeches + make helper=${helper} speeches ############################################################# # Everything green, let's do the release @@ -364,7 +319,7 @@ eof git push -u origin "${target_branch}" ;; *) - make helper=${helper} WEBDIR=${WEBDIR} pub + make helper=${helper} pub ;; esac @@ -372,23 +327,7 @@ eof "$0" version # Create and publish package for pypi - make helper=${helper} WEBDIR=${WEBDIR} pypi-release - - # publish man, speeches, website - if [ "$masterbranch" = yes ]; then - make helper=${helper} WEBDIR=${WEBDIR} web-release-all - else - make helper=${helper} WEBDIR=${WEBDIR} web-release-all-no-latest - fi - - case "$run_as" in - freebsd) - ;; - *) - # Archlinux release is based on pypi - make archlinux-release - ;; - esac + make helper=${helper} pypi-release # sign git tag printf "Enter upstream repository authentication token: " @@ -396,7 +335,15 @@ eof "$0" sign-git-release "${target_version}" "${token}" # Announce change on ML - make helper=${helper} WEBDIR=${WEBDIR} ml-release + make helper=${helper} ml-release + + cat << eof +Manual steps post release: + + - cdist-web + - twitter + +eof ;; test) @@ -441,7 +388,7 @@ eof ;; shellcheck) - make helper=${helper} WEBDIR=${WEBDIR} shellcheck + make helper=${helper} shellcheck printf "\\nPlease review shellcheck report.\\n" while true do diff --git a/docs/src/_static/cdist-logo.jpeg b/docs/src/_static/cdist-logo.jpeg new file mode 100644 index 0000000000000000000000000000000000000000..9bfa25298bb427d56cece5b630beb2447b618c31 GIT binary patch literal 12560 zcmeHtdpMNs-u7+R*bg$a!4!&;lugQRNC*j)6fy0QM^cFxbK4}Lc#uS8Y(hm%%BEB% z*`*z_SD2xVy&1+d%suzKmuIbKeQP~E>wVYyj_*B=?~gTy%Q%j?%zgc?-{w4j=XD9X z1)rb`kchDG!Vh?ff*&z)F)>k5F-Z(&k+`&^w6v6@l$4CDf}D)3ysVUzoRXaUVnrMd zCyiBJqNKP)K@q1YBm(A(ib;rxNhr!l$teEYFTqPlUR($gUMV7^4hhQ(iO35H>V)zj zNJvcRw-@x+myj@6-y)2-grt-lBrGH%A}lJhuv#!P0(=IE%8Mzi+-S9EvFjm>dXS=i zR7$S6#@5mr+^$xprorLU(GrqM%1f3mTeVtCd(B!yqfN$}x0qOOv$3_?Ztt*rkK11N zefvF*96fg2$Jg(~nX|#?LPF1n#axKJ7KhtgH@*4T*51+C)!oy}7##ZY_1pL1kx|z4411RIgF81b1d05`9Ps-u z2K}8q^1vQpQBe_5%z`~a!XaRY$cu`t+_*@=$`x}cXtBC}l(^#7l-$x92@Qi?Ox)qq zt&&QbhKyCL1(SZW=wCA^`v1zJzZvv5dj!3ZvO&UmvPL#hUqH-te>=xfp#< z!v$IxBa%#FQn{42;n>9Knv+H46^9RBnYNP34oXSMK0if#F9UC*F`Wg_oB=Tw&%qG+ zGQ%RnCddH)DNHZ4An-F$b8jy8RsT|EA3ye1`tzwX#f?FlkIe2qA9|Y(L2?_TBgWX# zG;x@IpE4b0u|fbnJWdfnc}kI{1KbF>!Fhf$A|rqzD=A329b!Qn(&9^?iv-Y1&t}wt z+MJ**GA}8BqG56ec?JJ|wZe)1)vQe^g(J(dDa97qyX_U$>1!t$%T(AN$9%7uOWxVR zo+XFDHHrf0OCO0SfQ}dlpbfmsZTAK3j;>fn(tj3k)Yh0A-`A1W*mwCZAoN;16%` zN7JNwJk`ub@>#5YQvvC2T05iZC1+8jMR#6a#nYteUY$z^?4|E$+Nmzx{+f{P_|KR2 z-!1#U`3(QA=#POgMYaGD62y%XK!?T#_-eB?E<(gsJ!G)}LU(jA?D$b#0?0ZHJy$#r z%!!7<oM=pT zzA}lJ2cPkmDdR-H_u0|#%)GdKvM*I0z7@PT2BC#W`c)gN%EzrV*Dh+vE|sF#f)+R6kAgMDOs)wzGIPV z{+W3x^6;f7H>=Iiiplekyq~QAFL46-tG!v zTnZ#io*M1C1Eigo0HL=@D+Q2xcDw-c-T)7m-w%7uj6)K_wD_SlU|whW@V|}$Dc9An z9mZKUY0`y==ExC#wS_oIF3aEPOvAOx-V!^R!eM&<&Z5@nqk4#V0yM9bfHbf`6&S0n zxS~mx=LX&x-KV*(_rBU?PladfXT)r`iH)b`Wk*F-#X_5d!$dQBqZE78jOB!gz&x>$P z1(4Vb@W4EQF$1f>!&v$hqTDQi8iz$V9}|$Baj29j>&5CTw_D9rH4jA{<%tfRYSyrT z@gDq4=DFwnYnay(OP;IufogK{o#mI6XJsz`Xz&#|oS>Z}obZmN6<+>HCQv%x zBS8WvhY&+!5(xqbpM(A6pu^JpX`50OHj}85xkN^*W_0@sV-5)cfkMr}rv8*qdy_BC z@&<6+m|dOaOGPW^ue{3$ku5GWOsc;gX>!^bcgs@jr+PXz*GnDFK!J}0&}x5XKKgPD z6!aHR1jYt8cb69myk$?;B)}3p1Swy*KJ; z<#5e}dmUM)jXkF7xwC`fthK{#dx4e8X`O)Mhq28u%_lo%S3!!dJFHDwu%eupN4V!aQHw4C^%X3#-j<=s`wia)Yf_42!|KEqC=XMw&b;+%l^UU{@7<#?{HPyN#-o^lMb(wD~msFUf8CgD;C znERWPG+Ftfo3YO0a|?kCk$YN+@i23amPBAMPto7G8l zJo>aOYyT#@m6rQ2>R1PwY^xePX{`+Q({rII>;&Q9PFswEBy4DVan_f22J$nqSp3d zP$?N!qjl>#!>Na%yOfk=SWS$ks_OVBAXgFL*Z^yf1V{4F#VPQV!9C2&~^c| zcy>UN`_{gNe({r&apw<{J^EYUycsRnXYk~pb@&n0G4`^5T4n!MfoBN47)~71XS{>H z25}oQ-{$EVeWd(xqD)ZudVP&}Q_AiZS$kY3i19`bLam;dzxP^}*vB5$Y98X>iOWJo&iVtz#;=&vhBxj+S5gW7Oof1j4o2{t#;N-OKSo}excC+K6K{8 zxpo3bv$$q}gDDe0tvbYat6*nX9B_&BP*e0Jhcds)SLFT!=fR?StSqvWDO);(#Szz2 z@@7wyv=CgHGb}<13gr01*i`HLlb6A>B1knC9lZ{a=2i-rE z{Rx5jH_8d|0)e@=dCnX!2X`Ad1N)?i&pNo)pz8l3fYMr77=DbQ0OHG)39;@2Vu625 zW7-hrjETwusQaA&ns*W-$98=$LgbxMr>=UCxdsF@&5D?N7P=5Cnijc5vum&jQB32^ zcUtI%Ho9>G=@Gj;u|gwfjLN^(=U)x*IJP_#Xmk2g7X{Glm>!yx8flS9{iZkMgIpu10838)08?MUJJXSR1lXP0 zI7H#e0>U=@BS&`q-#q}^qQ_OALT<*z6UK>Y;D79hWgXnd0!S2OZQ8FaEq>xOJUl$c z$@(ADfM7tQml0KbT9D-oV(ffy&6U}^vPE~-s_l?h*%sGb?TPkueX)rE2q?ClRhMnR ze{6P0;&h8|il?8;%u5Nmb09swgw5%L2T>o;=r@U_gXDG?cbvwOmhBg2GVEtpNVtZq zX-eqE+t%nNGnUXF=Ey2@g83IMbkR2LjB4c;n~b<00RiFeX9E4YZpDe+)@W56s@55A zmVs-q4?KE2>+p($j?osrWqsP|#DHck!mrd0RjuuhTF$=pGIlDvSnFJV>T|DhPQ6KombrVDAaWBT683>H*Nm5?bKlJEH{dx?};ANNwxY7MYPkRbb$* zR@ZizxgRfpl67Ykb_mq(A3M%$58 zk!Ad~%*i;+MG~QKM5$yV;81{SiPOrrI2%a`izm2z8z^XC3A)mgq{Vd`Y+llbn=bR( z6yCBt-y~O?mKcD)0vo8U>L}3QJ3$v`+<$Ppk}2ERI*wK6Lrmt!~C1 z*)OSLkSB90&WNb&zp2VLzR2rDZ$aB7`r}8j1=noN)AuO&PY`2a=638AvdQDj}YrT#?!C%h5KsfvY!|~t-A3Gm$OzeA|(@wDrw+>ZnGqH>0 z_wuNscN{+SOZLkMXG?r~l^r6-Qd)(!b4!}_f_(BPL`JH1d(fCed<>e9l)u2HK!Q~9 z&GRA&8)%Hic`P5N3Vb96=nU&@7x)}Md~CT-y{@H&?8mcDUSlfAVSECZoT0az>rE8p zzV%|V+wQ-sa$|Qo=}WJ>XuRf$Y)?bbzVv=10_4pQO9ZX$qRpF+Mdt|9@`zk5Kq)h+ zuabEpRP^F3GU3j41j(|%YSN6ju7Gd{14_~#X%Rzxh3D${Alb>62;)nOK<33#`$iGK zwWBNGreSUjT9XB%mpmYD=K{j@3~<#c$PH?u02)6I^H)dHwvNrTq2k~lSC0(}Al_2I zaO`uaEg&8NY)60eZ$8A^%=Ot}yVeLRZ+iecxQ~%uI`=Cqi5#GI6S=x|I|ne;YMU{K z#~#JZZkkB`;?Dv-1Do3OiH^S{fc%IFS;VO4248K?hg9vKT5s^xUYhV(ift*?fWp;lQ@nVA*N|ioYjj*8l|~ z%kD#jxHgPtA-}G+(Q{R1i&lo57Jh!a^!Q_0o<|_)#*?<@je^$u#d|ADs6Ch@MMu>7&@P)1v z>obLSlB}00_tsfhZf*!aPSafg*Jl7+^BX7}u@|5gU;(%SN@)X;i@8Kp{8qte_41F@ zz-le8#`9Qe^&<%B;3aPYhn13Rb4cAjU&2q2sL{wQrLz5ifw5>R*@a*-KmR|gcOrAu{IbAhJWe^6 zrg1Z!Wt*!^PkV%I^>5JWf`7rznM_?Ka*R*V=G|7E$3Zwg2=W>OROu6G1OM0O%XY1D zoRZV<&qxiZHQhnp!PnT=#iV|prxiN)boS|zg%FbjBgsStPY#;kUC6<1%lpR#iOk?p zsR-(I(qd+^Pn>5Q3K!3+wMz0jvFF&EYnO!N2%Oemfvn>Hbs2vl)inK5K9de{V@YqM zuk~tf%w-R3ZboA)@ekR+B@1p@7_dGC4}W=rSON`Tb_z`nqZhy6@&wST#z71}jtaBG zyTtyjj^=-jf(S8bh?3T;UH$`)NFF7w878Zr`kz@TGMOKD0rUnRb;%;fAtYYq7AmeMLML}d-4Ggr*giYv!TgvRV@HS+X%+|K63l|PNPx|p=> za0zx$Tg0S_cyT};v1X<<%sVHNbnjSXJQz76asPpwNX%v2!O&wXezl@U+nm|sf*B6Z zK$IR2KHrqGsyT+VCdlLtR=?mC#^M>NHsJ<}KfhhG=v!CjZ}^Sb`tkIX=<{=EeASF)bAIY%rn z&G2}nQo@ebEXZSx!OsF3{(aFzlmOE5VkM#t6Yc`Y;WkyB`U}6}>|H~+_xs@N^LuWT zy2?rjKlye|y7QO8=Q|@M(JX>b1D2`5VC??&tdyD^|C9rIY;1l7$QUxox{{mDQzx0w zE*>)Ec!Z6F9GHIWNzsj(kKN5aWQpJAYNH7K-4L470dV{B;h{llY}fN~f1TH`+%SBf ze6VX=4^irR6#z5S7y{^0ioRi=x4*rLY_x9_zQl+-3(9aBTq7TtpE%fD7jAn{^M*}S zd)Nep!k46N@*kscS5fOt;frv2b6jrqb*m$T+N)Y`U1w}dg<5?^hl>S}a1OSA{_j*U zLZ)*vZTbLt1>7C>8~r`y_Wv!2>&(QUl6HVOj8tI49e%2p7tA-tVrNFPZSubm#h& z6!q@63WoIcFV?J(b65FRy&4d!{WN+!P06Rag>;@dIC*&Fkfz7`gpD8C(|(-MR*gJ% znSY?`%linRiHb(C6tj#cV*Cz2*lX@-^P)T``~1BDHDLKl<<$LZasnvDc^lBYmJrw;oiBdF2HZ4^ zC?1{+C&YTIg`fXgd8P#NSSqPtmT4M8+~?jzWbVSwX`-qCIbH&^*LS~l9j4KdWwNQGcWI)-m;ZhD-K9vvIotZMm0AxkvzGRg-Z*BwJq2jgid$YnXK|xPP8rnL z>YsVh-2B8d@!@CJz4zCK!alFlI*P)dowHTuaPES>#dHdhOhf#q2;9{jv+t)akWQXF zdHku)otKL5HMZcNPNWej9X|$;#nvd;vxT110n16(+sK3&Q(rE|CT^ zcj0>qiMSJKXSQpWJ^uOb*#WhtKb&33)9uJ{r9C%_+Bw;)YQA zj}S!R6X)F{uEWenAskSxgS1(74kBU$2a-ZqqS->@0$@=6E*EaZ>YOcYU7k>iBt+4J)tm~fDUIM2r;ApwqRIED zUo*CK1?x$VR`h14z-J0iZ2F)XJ^68O!oKdaYu{Kcs(!}>a3^+}JH$jkO6i^q&}rNh z1m(^qp3cyOyL{h#;XOPuWr=^`j3l@YQ{N_Y$+EWqhCdh+K#SfApoS5^RAYk|e>khq5jg8rsl0JI^B%n^`KrZ(9G`(7XNATA5bcYw{n*B_ z2O`LKH%31F2|F z|MDl|9=hvaaX8jVl&2d(U97(C0r9_pW=16S=T;BssLJq{tD$Y^%Szh(%CWf%e=cCZ zAxeY&{N+BID(iR7ohJ45+GKC<=3}WcE~3ZXp!7v%kwG_?0eJm6I+Fm#>T$ITGkFKN zWA4l{GPa7@_ccBFQ-0=T=h+nN*khYrtmdLr!@Ih#LVp5Ko#oT+h++(CPl$uZHxSr6 z(!U=kOqQEtE9sOu?T7Fnf9bUH_#DrClvuXDw8U@zT&aJ4MP{JNK$AY9+^HLR80yM?yPA-W&Gk^nWQ)5B$%L&z~@83uvcK&kK z*Qc~{dp0Nd()L$&n$p=pjo*nuo}?gd`1vz3&(#cDzGeID8@i%5v~GMSBx088U-$CR zhIC)sV6tx59Hk^ELxH74%<6n~P;Y!!a<_A6;q2ql0WaD9YGoD;S=?Bct;3>TGI~Nf zRPd?(F7bV6ig`)wuck-WteD09a0)V}EjJS??05DH8PZkg9mQ;XD_z-ItRZ{P%1quH zT^lPovX*Z)PByNcYY4cy=dM{H^3mR*^;=t!-H{msPAvb%tX|JxgsiTeM|me)zO6u} zOc$T=cFr)gn#*t-Y@rOb+$~brzebdp7kw=J}R5Ka>?2^p(~Qa4TTV@EAcL| zA`Vg5J8B9i(u>S4R6De32617EQS0$C`0%kVvX|L8KZD>1M%?zkDYRJ#`$n`s0 zWcD~O$wQBG8fkbhQ0vN0hLs8y}pk)_}v)FYn2UaJMSVHqOE3j4|U-$sW*p z#pQO8oTxYBji9*qN_=0-;k| zfzqklh+GSdqi~=!(CICsZT|Uo614;7s)y9f(VbOEPR}pgHdyN$7XE1Hl&Iqt%#+ub zBCMz%2+>3_#EHclv`C{jOYS%CFNj!yUETKe(>83gVI0@hP7@VL)tT4hE@p<I!Z&N=_qKwwm2tlETc)89la!F>f045^mz`5UO0G9 z#wJ$Zr?;Z_)Yk0DzdLNTM4fhv_{olQ901R8{FSPP*fahsm=oh4y?rx2!6D|wo3_TZ zo%Zp^9t@MWRFnE^jAMqC5%~~wr*$2Lqt^s(`s7o4Payljo-L62*P&@>{TzXPHkjvR zDMm^MzyW&LRA zAQeBM^<|!_9l7a#x78A#DS#H5zxZs$_HS9RD4>?RT7D?(ZF4X8eA3mefAyE}n_WpK zh|F!Y1XqVwwT)!Cr^$~G+_+zJS6v zfYL-yz%SWxNt2Zk)u~^5M)y5qMaYVX>qmJ3J5dn=_kJ{R~yr~u2{#w0yGd~xmUxUTT#-qv}A2MVbBN6LUj!kFs?(wtT zw|u1&*4uAcbuNu~6l_Nlxl4yr)u?E+|WYrd~g%vlWHq_o_+9IrQR3(>{hQ?t)D=rFv7BK`oop?_GJq~ZRMHREO_3kJ5dzP2CF?nP-kh!oaM+(1PP-+ zY3>d8w%`b7mkx@H-tEj~OWGTkiS?-$FP=V% z{L!00C;3M|c1_4A3UL8r{mGk!Od=w`ydh-SWxINsyrGU1^zyagzSU3D<4#E@F2Q{M zK0>6Pb-^ToyN!=BA_>PRQq^hnKEuRkztT>2Oo^vXGLvo$h)50J6Ha#Eto`d@@)PV8 zSok@PXT@C~C>=Uvo4B{_=2Sd7-udx}@b=p(`Qb?~WNku#()4AZj>=WHxMyTvz{J#< zDz|liGbPGCu<>1Zn0rC%{txnZl_iP`gBcrxnMOnLwT{<H-FV_Rao^IzkPBOTA;l)ivqrY68*(Wq`Uz%b z5g5HFK$6^|Isx>911kIFuC6_<{9B;fQ+x?sWFWHTJSF45kP?AwyO?;sjD?l}qE!qa z$6wr_YmLw5k(;xQQ;+10h9wm!6__|{oX}ma|L8%B@?pItv+u(Sa0O;+YL}mmyn07( r46+T%YzaN!z4C)>*UmoGuAQJ}yZcSo{9dvD^ZtL>@E`U9Bk1`r-RKs7 literal 0 HcmV?d00001 diff --git a/docs/src/cdist-logo.png b/docs/src/_static/cdist-logo.png similarity index 100% rename from docs/src/cdist-logo.png rename to docs/src/_static/cdist-logo.png diff --git a/docs/web/cdist/pgp-key-EFD2AE4EC36B6901.asc b/docs/src/_static/pgp-key-EFD2AE4EC36B6901.asc similarity index 100% rename from docs/web/cdist/pgp-key-EFD2AE4EC36B6901.asc rename to docs/src/_static/pgp-key-EFD2AE4EC36B6901.asc diff --git a/docs/src/cdist-intro.rst b/docs/src/cdist-intro.rst deleted file mode 100644 index fad40fe5..00000000 --- a/docs/src/cdist-intro.rst +++ /dev/null @@ -1,15 +0,0 @@ -cdist - usable configuration management -======================================= - -.. image:: cdist-logo.png - :alt: cdist-logo - -cdist is a usable configuration management system. -It adheres to the KISS principle and -is being used in small up to enterprise grade environments. -cdist is an alternative to other configuration management systems like - -* `bcfg2 `_ -* `chef `_ -* `cfengine `_ -* `puppet `_. diff --git a/docs/src/cdist-os.rst b/docs/src/cdist-os.rst index 4f6b4820..a8e31226 100644 --- a/docs/src/cdist-os.rst +++ b/docs/src/cdist-os.rst @@ -1,16 +1,19 @@ -Supported Operating Systems +Supported operating systems =========================== cdist was tested or is know to run on at least -* `Archlinux `_ -* `Debian `_ -* `CentOS `_ -* `Fedora `_ +* `Alpine Linux `_ +* `Archlinux `_ +* `CentOS `_ +* `Debian `_ +* `Devuan `_ +* `Fedora `_ * `FreeBSD `_ -* `Gentoo `_ -* `Mac OS X `_ +* `Gentoo `_ +* `Mac OS X `_ +* `NetBSD `_ * `OpenBSD `_ -* `Redhat `_ -* `Ubuntu `_ -* `XenServer `_ +* `Redhat `_ +* `Ubuntu `_ +* `XenServer `_ diff --git a/docs/src/cdist-support.rst b/docs/src/cdist-support.rst index 2343500e..19afde2f 100644 --- a/docs/src/cdist-support.rst +++ b/docs/src/cdist-support.rst @@ -1,11 +1,9 @@ Support ------- -IRC -~~~ - -You can join the development ***IRC channel*** -`#cstar on irc.freenode.net `_. +Chat +~~~~ +Chat with us: `ungleich chat `_. Mailing list ~~~~~~~~~~~~ @@ -25,4 +23,4 @@ Commercial support ~~~~~~~~~~~~~~~~~~ You can request commercial support for cdist from -`my company `_. +`ungleich `_. diff --git a/docs/src/cdist-update.rst b/docs/src/cdist-upgrade.rst similarity index 99% rename from docs/src/cdist-update.rst rename to docs/src/cdist-upgrade.rst index e810d6e9..e57ed63c 100644 --- a/docs/src/cdist-update.rst +++ b/docs/src/cdist-upgrade.rst @@ -1,5 +1,5 @@ -How to update cdist -=================== +How to upgrade cdist +==================== Update the git installation --------------------------- diff --git a/docs/src/conf.py b/docs/src/conf.py index 8ed48324..78f9842c 100644 --- a/docs/src/conf.py +++ b/docs/src/conf.py @@ -56,7 +56,7 @@ master_doc = 'index' # General information about the project. project = 'cdist' -# copyright = '2016, Darko Poljak' +copyright = 'ungleich GmbH 2019' # author = 'Darko Poljak' # The version info for the project you're documenting, acts as replacement for @@ -138,7 +138,7 @@ html_theme_path = [sphinx_rtd_theme.get_html_theme_path()] # The name of an image file (relative to this directory) to place at the top # of the sidebar. -# html_logo = None +html_logo = '_static/cdist-logo.jpeg' # The name of an image file (relative to this directory) to use as a favicon of # the docs. This file should be a Windows icon file (.ico) @@ -150,6 +150,7 @@ html_theme_path = [sphinx_rtd_theme.get_html_theme_path()] # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". # html_static_path = ['_static'] +html_static_path = ['_static'] # Add any extra paths that contain custom files (such as robots.txt or # .htaccess) here, relative to this directory. These files are copied diff --git a/docs/src/index.rst b/docs/src/index.rst index af303f5b..95e44d52 100644 --- a/docs/src/index.rst +++ b/docs/src/index.rst @@ -1,20 +1,23 @@ -Welcome to cdist documentation -============================== +cdist - usable configuration management +======================================= + +cdist is a usable configuration management system. +It adheres to the KISS principle and +is being used in small up to enterprise grade environments. -Contents: .. toctree:: - :maxdepth: 2 + :maxdepth: 3 :glob: :numbered: + :hidden: - cdist-intro cdist-why + cdist-features cdist-os cdist-install - cdist-update + cdist-upgrade cdist-support - cdist-features cdist-quickstart cdist-real-world man1/cdist diff --git a/docs/web/cdist.mdwn b/docs/web/cdist.mdwn deleted file mode 100644 index 90af20cb..00000000 --- a/docs/web/cdist.mdwn +++ /dev/null @@ -1,21 +0,0 @@ -[[!meta title="cdist - usable configuration management"]] - -![cdist-logo](cdist-logo.png "cdist logo") - -cdist is a usable configuration management system. -It adheres to the KISS principle and -is being used in small up to enterprise grade environments. -cdist is an alternative to other configuration management systems like -[bcfg2](http://bcfg2.org/), -[chef](https://www.chef.sh/), -[cfengine](https://cfengine.com/) -and [puppet](https://puppet.com/). - - * [[Why should I use cdist?|why]] - * [[Documentation|documentation]] - * [[Supported Operating Systems|os]] - * [[Installation|install]] - * [[Update|update]] - * [[Support|support]] - -[[!tag cdist unix]] diff --git a/docs/web/cdist/cdist-logo.png b/docs/web/cdist/cdist-logo.png deleted file mode 100644 index 13c2792728d20511f18ae60df8524d68b8a35cbf..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1542 zcmV+h2Ko7kP)Px#22e~?MF0Q*|NsA`*`M72000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2ipS@ z0U8oZ%R(#w00o9gL_t(o!|j;OOC(1Wz^mIa(<@6fGKU5*AnRX5Vhb0Zp zl-0j^^}hPms}|z_>pi<{At%Dr`U@U4gF4RoGSKpzdV%|9@IftRZLXV9@rE>N@N!C~ zGe!OUp&qdMyVA_e*UFQ*nQ6FwG6UDY#;;ZQdr1m53*5jARMf$*1#sLK#5utjPU&db zU785>|Q;`jcYt&fW8y13Dv?GjzEFS5zgd^L_8Dcpp*UC7%Q|3g| zeW!0Xc2ln5Rr4S=Vw`9rom{QR%eaLoD99VfwGKs%e!wYXuc>Ro!YNg8JEj$j^K%vMI*!X+fZJ61zup&| z_&2@o@#j2c4Ow58Hv--l{9E;X!t)PThohc&SqQ&#?tli zeQ~q`w_7_Q4-|PvJ%@O73;v3uexPskGwxuUxYYml(wYAUI%ek9r9qEY?};s1j`9Ns zws+2%V_kFL`}_%&3B=6YnssgO7v^UEE^rn<`DuRG-WhWykyiNA+NRs7e#(n=#)dSo zC4b`2WX@hcQKUGP1Q;~i_~10#_Lg>}wnLWcfIX@<+++6!>FOsE(lNYg;o!>kuYLrZ zgn0Pmn(d&{8hK&l4S+j!SA~?-kZ(d{hS{KtRyo7mHqy$s_JuIA?hdVknB7 zLmcRLeo>TXD!t|!#KppS^(U1G?uTqIrW6TN&L%q)1U|fh!8$5_6|fyo5;wJD>?Nn8 z7@(SuyO_)`(2ft;4l8l7-_6;9W~(mlmj~#Vqtq{l($Q`rzu?yO%mX=fdC=B&2+U{e4Ydo2tmeVMoEvfXx48|#$#HqW zTvw#rm^=`@-JY`kV#Va)&A7P1?!T;r((*!4!$HtGcXKPzc`S^6g>{Se%ENDB0rpaV z5LWU)8vnI-KXJt}pCil*k@~kQ_nrqXYSH9EMl)|%efJ-1(-zZu5F_WnM!-h{74^xT z;0|clXTjlN%3T{{fFAO-|Ift!@>@-G2m|qxhyoK=0!BZA|iCn43h9NNJLMXkOv16dzyd&)Y5*|k+R=&8w!jnSNv6LK39 saY9X~U}r+kn~+= 3.2 - * SSH client - * Asciidoc and xsltproc (for building the manpages) - -### Target Hosts - - * /bin/sh: A posix like shell (for instance bash, dash, zsh) - * SSH server - -## Install cdist - -You can install cdist either from git or as a python package. - -### From git - -Cloning cdist from git gives you the advantage of having -a version control in place for development of your own stuff -immediately. - -To install cdist, execute the following commands: - - git clone https://github.com/ungleich/cdist.git - cd cdist - export PATH=$PATH:$(pwd -P)/bin - -From version 4.2.0 cdist tags and github releases are signed. -You can get GPG public key used for signing [here](/software/cdist/pgp-key-EFD2AE4EC36B6901.asc). - -#### Available versions in git - - * The active development takes place in the **master** branch - * The current stable version can be found in the **2.0** branch - * The upcoming stable version can be found in the **2.1** branch - -Other branches may be available for features or bugfixes, but they -may vanish at any point. To select a specific branch use - - # Generic code - git checkout -b origin/ - -So for instance if you want to use and stay with version 2.0, you can use - - git checkout -b 2.0 origin/2.0 - -#### Git Mirrors - -If the main site is down, you can acquire cdist from one of the following sites: - - * git://github.com/telmich/cdist.git ([github](https://github.com/telmich/cdist)) - * git://git.code.sf.net/p/cdist/code ([sourceforge](https://sourceforge.net/p/cdist/code)) - -#### Building and using documentation (man and html) - -If you want to build and use the documentation, run: - - make docs - -Documentation comes in two formats, man pages and full HTML -documentation. Documentation is built into distribution's -docs/dist directory. man pages are in docs/dist/man and -HTML documentation in docs/dist/html. - -If you want to use man pages, run: - - export MANPATH=$MANPATH:$(pwd -P)/docs/dist/man - -Or you can move manpages from docs/dist/man directory to some -other directory and add it to MANPATH. - -Full HTML documentation can be accessed at docs/dist/html/index.html. - -You can also build manpages for types in your ~/.cdist directory: - - make dotman - -Built manpages are now in docs/dist/man directory. If you have -some other custom .cdist directory, e.g. /opt/cdist then use: - - DOT_CDIST_PATH=/opt/cdist make dotman - - -### Python Package - -Cdist is available as a python package at -[PyPi](http://pypi.python.org/pypi/cdist/). You can install it using - - pip install cdist - -## Use cdist - -[[Dig into the documentation|documentation]] to get started with cdist! - -[[!tag cdist unix]] diff --git a/docs/web/cdist/os.mdwn b/docs/web/cdist/os.mdwn deleted file mode 100644 index 3677f52c..00000000 --- a/docs/web/cdist/os.mdwn +++ /dev/null @@ -1,18 +0,0 @@ -[[!meta title="Supported Operating Systems"]] - -cdist was tested or is know to run on at least - - * [Archlinux](http://www.archlinux.org/) - * [Debian](http://www.debian.org/) - * [CentOS](http://www.centos.org/) - * [Scientific](https://www.scientificlinux.org/) - * [Fedora](http://fedoraproject.org/) - * [FreeBSD](http://www.freebsd.org) - * [Gentoo](http://www.gentoo.org/) - * [Mac OS X](http://www.apple.com/macosx/) - * [OpenBSD](http://www.openbsd.org) - * [Redhat](http://www.redhat.com/) - * [Ubuntu](http://www.ubuntu.com/) - * [XenServer](http://www.citrix.com/xenserver/) - -[[!tag cdist unix]] diff --git a/docs/web/cdist/support.mdwn b/docs/web/cdist/support.mdwn deleted file mode 100644 index 4f92853b..00000000 --- a/docs/web/cdist/support.mdwn +++ /dev/null @@ -1,28 +0,0 @@ -## Support - -### IRC - -You can join the development ***IRC channel*** -[#cstar on irc.freenode.net](irc://irc.freenode.org/#cstar). - -### Mailing list - -Bug reports, questions, patches, etc. should be send to the -[cdist mailing list](https://groups.google.com/forum/#!forum/cdist-configuration-management). - -### Linkedin - -If you have an account -at [Linked in](http://www.linkedin.com/), -you can join the -[cdist group](http://www.linkedin.com/groups/cdist-configuration-management-3952797). - -### Chat -Chat with us: [ungleich chat](https://chat.ungleich.ch/channel/cdist). - -### Commercial support - -You can request commercial support for cdist from -[my company](http://www.ungleich.ch/english/). - -[[!tag cdist unix]] diff --git a/docs/web/cdist/update.mdwn b/docs/web/cdist/update.mdwn deleted file mode 100644 index df4617bb..00000000 --- a/docs/web/cdist/update.mdwn +++ /dev/null @@ -1,158 +0,0 @@ -[[!meta title="How to update cdist"]] - -## Update The Git Installation - -To upgrade cdist in the current branch use - - git pull - - # Also update the manpages - ./build man - export MANPATH=$MANPATH:$(pwd -P)/doc/man - -If you stay on a version branche (i.e. 1.0, 1.1., ...), nothing should break. -The master branch on the other hand is the development branch and may not be -working, break your setup or eat the tree in your garden. - -### Safely upgrading to new versions - -To upgrade to **any** further cdist version, you can take the -following procedure to do a safe upgrade: - - # Create new branch to try out the update - git checkout -b upgrade_cdist - - # Get latest cdist version in git database - git fetch -v - - # see what will happen on merge - replace - # master with the branch you plan to merge - git diff upgrade_cdist..origin/master - - # Merge the new version - git merge origin/master - -Now you can ensure all custom types work with the new version. -Assume that you need to go back to an older version during -the migration/update, you can do so as follows: - - # commit changes - git commit -m ... - - # go back to original branch - git checkout master - -After that, you can go back and continue the upgrade: - - # git checkout upgrade_cdist - - -## Update The Python Package - -To upgrade to the lastet version do - - pip install --upgrade cdist - -## General Update Instructions - -### Updating from 3.0 to 3.1 - -The type **\_\_ssh_authorized_keys** now also manages existing keys, -not only the ones added by cdist. - -### Updating from 2.3 to 3.0 - -The **changed** attribute of objects has been removed. -Use [messaging](/software/cdist/man/3.0.0/man7/cdist-messaging.html) instead. - -### Updating from 2.2 to 2.3 - -No incompatibilities. - -### Updating from 2.1 to 2.2 - -Starting with 2.2, the syntax for requiring a singleton type changed: -Old format: - - require="__singleton_type/singleton" ... - -New format: - - require="__singleton_type" ... - -Internally the "singleton" object id was dropped to make life more easy. -You can probably fix your configuration by running the following code -snippet (currently untested, please report back if it works for you): - - find ~/.cdist/* -type f -exec sed -i 's,/singleton,,' {} \; - -### Updating from 2.0 to 2.1 - -Have a look at the update guide for [[2.0 to 2.1|2.0-to-2.1]]. - - * Type **\_\_package* and \_\_process** use --state **present** or **absent**. - The states **removed/installed** and **stopped/running** have been removed. - Support for the new states is already present in 2.0. - * Type **\_\_directory**: Parameter --parents and --recursive are now boolean - The old "yes/no" values need to be removed. - * Type **\_\_rvm_ruby**: Parameter --default is now boolean - The old "yes/no" values need to be removed. - * Type **\_\_rvm_gemset**: Parameter --default is now boolean - The old "yes/no" values need to be removed. - * Type **\_\_addifnosuchline** and **\_\_removeline** have been replaced by **\_\_line** - * The **conf** directory is now located at **cdist/conf**. - You need to migrate your types, explorers and manifests - manually to the new location. - * Replace the variable **\_\_self** by **\_\_object_name** - Support for the variable **\_\_object_name** is already present in 2.0. - * The types **\_\_autofs**, **\_\_autofs_map** and **\_\_autofs_reload** have been removed - (no maintainer, no users) - * Type **\_\_user**: Parameter --groups removed (use the new \_\_user_groups type) - * Type **\_\_ssh_authorized_key** has been replaced by more flexible type - **\_\_ssh_authorized_keys** - -### Updating from 1.7 to 2.0 - -* Ensure python (>= 3.2) is installed on the source host -* Use "cdist config host" instead of "cdist-deploy-to host" -* Use "cdist config -p host1 host2" instead of "cdist-mass-deploy" -* Use "cdist banner" for fun -* Use **\_\_object_name** instead of **\_\_self** in manifests - -### Updating from 1.6 to 1.7 - -* If you used the global explorer **hardware_type**, you need to change - your code to use **machine** instead. - -### Updating from 1.5 to 1.6 - -* If you used **\_\_package_apt --preseed**, you need to use the new - type **\_\_debconf_set_selections** instead. -* The **\_\_package** types accepted either --state deinstalled or - --state uninstaaled. Starting with 1.6, it was made consistently - to --state removed. - -### Updating from 1.3 to 1.5 - -No incompatibilities. - -### Updating from 1.2 to 1.3 - -Rename **gencode** of every type to **gencode-remote**. - -### Updating from 1.1 to 1.2 - -No incompatibilities. - -### Updating from 1.0 to 1.1 - -In 1.1 the type **\_\_file** was split into **\_\_directory**, **\_\_file** and -**\_\_link**. The parameter **--type** was removed from **\_\_file**. Thus you -need to replace **\_\_file** calls in your manifests: - - * Remove --type from all \_\_file calls - * If type was symlink, use \_\_link and --type symbolic - * If type was directory, use \_\_directory - - -[[!tag cdist unix]] diff --git a/docs/web/cdist/update/2.0-to-2.1.mdwn b/docs/web/cdist/update/2.0-to-2.1.mdwn deleted file mode 100644 index 3b5f5dc4..00000000 --- a/docs/web/cdist/update/2.0-to-2.1.mdwn +++ /dev/null @@ -1,118 +0,0 @@ -[[!meta title="Update Guide for 2.0 to 2.1"]] - -## Introduction - -When changing your installation from 2.0 to 2.1, there are -a lot of changes coming up. 2.1 is mainly a cleanup release, -which removes long time deprecated behaviour, but also makes -a lot of things more consistent and allows you to split off your types, -explorers and manifest to custom directories. - -This document will guide you to a successful update. - -## Preparation - -As for every software and system you use in production, you should first of -all make a backup of your data. To prevent any breakage, it is -recommended to create a new git branch to do the update on: - - % git checkout -b update_to_2.1 - -This also ensure that whenever you need to do a change in your -2.0 based tree, you can simply go back to that branch, apply the change -and configure your systems - independently of your update progress! - -Next fetch the latest upstream changes, I assume that -origin refers to one of the upstream mirrors (change origin if you use -another remote name for upstream cdist): - - % git fetch -v origin - -## Merge the changes - -Now try to merge upstream into the new branch. - - % git merge origin/2.1 - -Fix any conflicts that may have been occurred due to local changes -and then **git add** and *git commit** those changes. This should seldom -occur and if, it's mostly for people hacking on the cdist core. - -## Move "conf" directory - -One of the biggest changes in cdist 2.1 is that you can have multiple -**conf** directories: Indeed, the new default behaviour of cdist is to -search for conf directories - - * below the python module (cdist/conf in the source tree or in the installed location) - * at ~/.cdist/ (on conf suffix there) - -So you can now choose, where to store your types. - -### Integrate your conf/ back into the tree - -If you choose to store your types together with the upstream types, -you can just move all your stuff below **cdist/conf**: - - % git mv conf/type/* cdist/conf/type - % git mv conf/manifest/* cdist/conf/manifest - % git mv conf/explorer/* cdist/conf/explorer - % git commit -m "Re-Integrate my conf directory into cdist 2.1 tree" - -### Move your conf/ directory to ~/.cdist - -If you want to store your site specific -configuration outside of the cdist tree, you -can move your conf/ directory to your homedirectory ($HOME) under ~/.cdist: - - % mv conf ~/.cdist - % git rm -r conf - % git commit -m "Move my conf directory to ~/.cdist" - -It it still recommended to use a version control system like git in it: - - % cd ~/.cdist - % git init - % git add . - % git commit -m "Create new git repository containing my cdist configuration" - -## Test the migration - -Some of the types shipped with upstream were changed, so you may want to test -the result by running cdist on one of your staging target hosts: - - % ./bin/cdist config -v staging-host - -All incompatibilities are listed on the [[cdist update page|software/cdist/update]], -so you can browse through the list and update your configuration. - -## Final Cleanups - -When everything is tested, there are some cleanups to be done to finalise the update. - -### When continuing to keep conf/ in the tree - -You can then merge back your changes into the master tree and continue to work -as normal. - -### When using ~/.cdist - -If you decided to move your site specific code to ~/.cdist, you can now switch your -**master** branch or version branch to upstream directly. Assumnig you are in the -cdist directory, having your previous branch checked out, you can create a clean -state using the following commands: - - % upstream_branch=2.1 - % current_branch=$(git rev-parse --abbrev-ref HEAD) - % git checkout -b archive_my_own_tree - % git branch -D "$current_branch" - % git checkout -b "$current_branch" "origin/$upstream_branch" - -Afther these commands, your previous main branch is accessible at -**archive_my_own_tree** and your branch is now tracking upstream. - -## Questions? Critics? Hints? - -If you think this manual helped or misses some information, do not -hesitate to contact us on any of the usual ways (irc, mailinglist, -github issue tracker, ...). diff --git a/docs/web/cdist/why.mdwn b/docs/web/cdist/why.mdwn deleted file mode 100644 index f571555c..00000000 --- a/docs/web/cdist/why.mdwn +++ /dev/null @@ -1,69 +0,0 @@ -[[!meta title="Why should I use cdist?"]] - -[[!toc]] - -There are several motivations to use cdist, these -are probably the most popular ones. - -## Known language - -Cdist is being configured in -[shell script](https://en.wikipedia.org/wiki/Shell_script). -Shell script is used by UNIX system engineers for decades. -So when cdist is introduced, your staff does not need to learn a new -[DSL](https://en.wikipedia.org/wiki/Domain-specific_language) -or programming language. - -## Powerful language - -Not only is shell scripting widely known by system engineers, -but it is also a very powerful language. Here are some features -which make daily work easy: - - * Configuration can react dynamicly on explored values - * High level string manipulation (using sed, awk, grep) - * Conditional support (**if, case**) - * Loop support (**for, while**) - * Support for dependencies between cdist types - -## More than shell scripting - -If you compare regular shell scripting with cdist, there is one major -difference: When using cdist types, -the results are -[idempotent](https://en.wikipedia.org/wiki/Idempotence). -In practise that means it does not matter in which order you -call cdist types, the result is always the same. - -## Zero dependency configuration management - -Cdist requires very litte on a target system. Even better, -in almost all cases all dependencies are usually fulfilled. -Cdist does not require an agent or a high level programming -languages on the target host: it will run on any host that -has a **ssh server running** and a posix compatible shell -(**/bin/sh**). Compared to other configuration management systems, -it does not require to open up an additional port. - -## Push based distribution - -Cdist uses the push based model for configuration. In this -scenario, one (or more) computers connect the target hosts -and apply the configuration. That way the source host has -very little requirements: Cdist can even run on a sysadmin -notebook that is loosely connected to the network and has -limited amount of resources. - -Furthermore, from a security point of view, only one machine -needs access to the target hosts. No target hosts will ever -need to connect back to the source host, which contains the -full configuration. - -## Highly scalable - -If at some point you manage more hosts than can be handled from -a single source host, you can simply add more resources: Either -add more cores to one host or add hosts. -Cdist will utilise the given resources in parallel. - -[[!tag cdist unix]] From 2f93320627a996756a0375b2e9178f360ccea73c Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Thu, 2 May 2019 19:37:01 +0200 Subject: [PATCH 0364/1217] Generating speeches is not part of cdist release Speeches should be generated on demand when needed and the cdist website should be updated. --- bin/build-helper | 3 --- bin/build-helper.freebsd | 3 --- 2 files changed, 6 deletions(-) diff --git a/bin/build-helper b/bin/build-helper index 04b7621b..bb5956b8 100755 --- a/bin/build-helper +++ b/bin/build-helper @@ -279,9 +279,6 @@ eof make docs-clean make docs - # Generate speeches (indirect check if they build) - make speeches - ############################################################# # Everything green, let's do the release diff --git a/bin/build-helper.freebsd b/bin/build-helper.freebsd index c292280c..2a71a899 100755 --- a/bin/build-helper.freebsd +++ b/bin/build-helper.freebsd @@ -295,9 +295,6 @@ eof make helper=${helper} docs-clean make helper=${helper} docs - # Generate speeches (indirect check if they build) - make helper=${helper} speeches - ############################################################# # Everything green, let's do the release From d242f1e7588912364c5c5dd6d1595202d24bc42f Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Sat, 4 May 2019 00:31:33 +0200 Subject: [PATCH 0365/1217] Unify build-helper scripts --- bin/build-helper | 89 +++++--- bin/build-helper.darko | 1 + bin/build-helper.freebsd | 427 --------------------------------------- 3 files changed, 63 insertions(+), 454 deletions(-) create mode 120000 bin/build-helper.darko delete mode 100755 bin/build-helper.freebsd diff --git a/bin/build-helper b/bin/build-helper index bb5956b8..0b2d5282 100755 --- a/bin/build-helper +++ b/bin/build-helper @@ -1,6 +1,7 @@ #!/bin/sh # # 2011-2013 Nico Schottelius (nico-cdist at schottelius.org) +# 2016-2019 Darko Poljak (darko.poljak at gmail.com) # # This file is part of cdist. # @@ -18,10 +19,36 @@ # along with cdist. If not, see . # # -# This file contains the heavy lifting found usually in the Makefile +# This file contains the heavy lifting found usually in the Makefile. # +# vars for make +helper=$0 + basedir=${0%/*}/../ +# run_as is used to check how the script is called (by $0 value) +# currently supported sufixes for $0 are: +# .darko - run as darko +basename=${0##*/} +run_as=${basename#*.} + +to_a=cdist-configuration-management +to_d=googlegroups.com +case "$run_as" in + darko) + from_a=darko.poljak + from_d=gmail.com + ml_name="Darko Poljak" + ml_sig_name="Darko" + ;; + *) + from_a=nico.schottelius + from_d=ungleich.ch + ml_name="Nico Schottelius" + ml_sig_name="Nico" + ;; +esac + # Change to checkout directory cd "$basedir" @@ -30,6 +57,12 @@ version=$(git describe) option=$1; shift case "$option" in + print-make-vars) + printf "helper: ${helper}\n" + ;; + print-runas) + printf "run_as: $run_as\n" + ;; changelog-changes) if [ "$#" -eq 1 ]; then start=$1 @@ -84,19 +117,14 @@ case "$option" in version=$1; shift - to_a=cdist - to_d=l.schottelius.org to=${to_a}@${to_d} - - from_a=nico-cdist - from_d=schottelius.org from=${from_a}@${from_d} ( cat << eof -From: Nico -telmich- Schottelius <$from> +From: ${ml_name} <$from> To: cdist mailing list <$to> -Subject: cdist $version released +Subject: cdist $version has been released Hello .*, @@ -108,15 +136,18 @@ eof cat << eof Cheers, - -Nico +${ml_sig_name} -- Automatisation at its best level. With cdist. eof - ) | /usr/sbin/sendmail -f "$from" "$to" - ;; + ) > mailinglist.tmp + if [ "$run_as" = "build-helper" ] + then + /usr/sbin/sendmail -f "$from" "$to" < mailinglist.tmp && rm -f mailinglist.tmp + fi + ;; release-git-tag) target_version=$($0 changelog-version) @@ -213,7 +244,6 @@ eof "https://code.ungleich.ch/api/v4/projects/${project}/repository/tags/${tag}/release" \ || exit 1 - # remove generated files (archive and asc) if [ $# -eq 2 ] then @@ -276,8 +306,8 @@ eof # Generate documentation (man and html) # First, clean old generated docs - make docs-clean - make docs + make helper=${helper} docs-clean + make helper=${helper} docs ############################################################# # Everything green, let's do the release @@ -292,16 +322,27 @@ eof fi # Publish git changes - make pub + if [ "$run_as" = "build-helper" ] + then + make helper=${helper} pub + else + # if we are not Nico :) then just push, no mirror + git push + # push also new branch and set up tracking + git push -u origin "${target_branch}" + fi # Ensure that pypi release has the right version "$0" version # Create and publish package for pypi - make pypi-release + make helper=${helper} pypi-release - # Archlinux release is based on pypi - make archlinux-release + if [ "$run_as" = "build-helper" ] + then + # Archlinux release is based on pypi + make helper=${helper} archlinux-release + fi # sign git tag printf "Enter upstream repository authentication token: " @@ -309,19 +350,13 @@ eof "$0" sign-git-release "${target_version}" "${token}" # Announce change on ML - make ml-release + make helper=${helper} ml-release cat << eof Manual steps post release: - - cdist-web - - linkedin - - hackernews - - reddit - twitter - eof - ;; test) @@ -366,7 +401,7 @@ eof ;; shellcheck) - make shellcheck + make helper=${helper} shellcheck printf "\\nPlease review shellcheck report.\\n" while true do diff --git a/bin/build-helper.darko b/bin/build-helper.darko new file mode 120000 index 00000000..1f3e3384 --- /dev/null +++ b/bin/build-helper.darko @@ -0,0 +1 @@ +build-helper \ No newline at end of file diff --git a/bin/build-helper.freebsd b/bin/build-helper.freebsd deleted file mode 100755 index 2a71a899..00000000 --- a/bin/build-helper.freebsd +++ /dev/null @@ -1,427 +0,0 @@ -#!/bin/sh -# -# 2011-2013 Nico Schottelius (nico-cdist at schottelius.org) -# 2016 Darko Poljak (darko.poljak at gmail.com) -# -# This file is part of cdist. -# -# cdist is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation, either version 3 of the License, or -# (at your option) any later version. -# -# cdist is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with cdist. If not, see . -# -# -# This file contains the heavy lifting found usually in the Makefile -# - -# vars for make -helper=$0 - -basedir=${0%/*}/../ -# run_as is used to check how the script is called (by $0 value) -# currently supported sufixes for $0 are: -# .freebsd - run as freebsd -basename=${0##*/} -run_as=${basename#*.} - -to_a=cdist-configuration-management -to_d=googlegroups.com -from_a=darko.poljak -from_d=gmail.com -ml_name="Darko Poljak" -ml_sig_name="Darko" - -# Change to checkout directory -cd "$basedir" - -version=$(git describe) - -option=$1; shift - -case "$option" in - print-make-vars) - printf "helper: ${helper}\n" - ;; - print-runas) - printf "run_as: $run_as\n" - ;; - changelog-changes) - if [ "$#" -eq 1 ]; then - start=$1 - else - start="[[:digit:]]" - fi - - end="[[:digit:]]" - - awk -F: "BEGIN { start=0 } - { - if(start == 0) { - if (\$0 ~ /^$start/) { - start = 1 - } - } else { - if (\$0 ~ /^$end/) { - exit - } else { - print \$0 - } - } - }" "$basedir/docs/changelog" - ;; - - changelog-version) - # get version from changelog - grep '^[[:digit:]]' "$basedir/docs/changelog" | head -n1 | sed 's/:.*//' - ;; - - check-date) - # verify date in changelog is today - date_today="$(date +%Y-%m-%d)" - date_changelog=$(grep '^[[:digit:]]' "$basedir/docs/changelog" | head -n1 | sed 's/.*: //') - - if [ "$date_today" != "$date_changelog" ]; then - echo "Date in changelog is not today" - echo "Changelog: $date_changelog" - exit 1 - fi - ;; - - check-unittest) - "$0" test - ;; - - ml-release) - if [ $# -ne 1 ]; then - echo "$0 ml-release version" >&2 - exit 1 - fi - - version=$1; shift - - to=${to_a}@${to_d} - from=${from_a}@${from_d} - - ( - cat << eof -From: ${ml_name} <$from> -To: cdist mailing list <$to> -Subject: cdist $version has been released - -Hello .*, - -cdist $version has been released with the following changes: - -eof - - "$0" changelog-changes "$version" - cat << eof - -Cheers, - -${ml_sig_name} - --- -Automatisation at its best level. With cdist. -eof - ) > mailinglist.tmp - ;; - - release-git-tag) - target_version=$($0 changelog-version) - if git rev-parse --verify refs/tags/$target_version 2>/dev/null; then - echo "Tag for $target_version exists, aborting" - exit 1 - fi - printf "Enter tag description for ${target_version}: " - read tagmessage - - # setup for signed tags: - # gpg --fulL-gen-key - # gpg --list-secret-keys --keyid-format LONG - # git config --local user.signingkey - # for exporting pub key: - # gpg --armor --export > pubkey.asc - # gpg --output pubkey.gpg --export - # show tag with signature - # git show - # verify tag signature - # git tag -v - # - # gpg verify signature - # gpg --verify - # gpg --no-default-keyring --keyring --verify - # Ensure gpg-agent is running. - export GPG_TTY=$(tty) - gpg-agent - - git tag -s "$target_version" -m "$tagmessage" - git push --tags - ;; - - sign-git-release) - if [ $# -lt 2 ] - then - printf "usage: $0 sign-git-release TAG TOKEN [ARCHIVE]\n" - printf " if ARCHIVE is not specified then it is created\n" - exit 1 - fi - tag="$1" - if ! git rev-parse -q --verify "${tag}" >/dev/null 2>&1 - then - printf "Tag \"${tag}\" not found.\n" - exit 1 - fi - token="$2" - if [ $# -gt 2 ] - then - archivename="$3" - else - archivename="cdist-${tag}.tar" - git archive --prefix="cdist-${tag}/" -o "${archivename}" "${tag}" \ - || exit 1 - # make sure target version is generated - "$0" target-version - tar -x -f "${archivename}" || exit 1 - cp cdist/version.py "cdist-${tag}/cdist/version.py" || exit 1 - tar -c -f "${archivename}" "cdist-${tag}/" || exit 1 - rm -r -f "cdist-${tag}/" - gzip "${archivename}" || exit 1 - archivename="${archivename}.gz" - fi - gpg --armor --detach-sign "${archivename}" || exit 1 - - project="ungleich-public%2Fcdist" - sed_cmd='s/^.*"markdown":"\([^"]*\)".*$/\1/' - - # upload archive - response_archive=$(curl -f -X POST \ - --http1.1 \ - -H "PRIVATE-TOKEN: ${token}" \ - -F "file=@${archivename}" \ - "https://code.ungleich.ch/api/v4/projects/${project}/uploads" \ - | sed "${sed_cmd}") || exit 1 - - # upload archive signature - response_archive_sig=$(curl -f -X POST \ - --http1.1 \ - -H "PRIVATE-TOKEN: ${token}" \ - -F "file=@${archivename}.asc" \ - "https://code.ungleich.ch/api/v4/projects/${project}/uploads" \ - | sed "${sed_cmd}") || exit 1 - - # make release - changelog=$("$0" changelog-changes "$1" | sed 's/^[[:space:]]*//') - release_notes=$( - printf "Release %s\n\n%s\n\n%s\n\n**Changelog**\n\n%s\n" \ - "${tag}" "${response_archive}" "${response_archive_sig}" "${changelog}" - ) - curl -f -X POST \ - -H "PRIVATE-TOKEN: ${token}" \ - -F "description=${release_notes}" \ - "https://code.ungleich.ch/api/v4/projects/${project}/repository/tags/${tag}/release" \ - || exit 1 - - # remove generated files (archive and asc) - if [ $# -eq 2 ] - then - rm -f "${archivename}" - fi - rm -f "${archivename}.asc" - ;; - - release) - set -e - target_version=$($0 changelog-version) - target_branch=$($0 version-branch) - - echo "Beginning release process for $target_version" - - # First check everything is sane - "$0" check-date - "$0" check-unittest - "$0" check-pycodestyle - "$0" shellcheck - - # Generate version file to be included in packaging - "$0" target-version - - # Ensure the git status is clean, else abort - if ! git diff-index --name-only --exit-code HEAD ; then - echo "Unclean tree, see files above, aborting" - exit 1 - fi - - # Ensure we are on the master branch - masterbranch=yes - if [ "$(git rev-parse --abbrev-ref HEAD)" != "master" ]; then - echo "Releases are happening from the master branch, aborting" - - echo "Enter the magic word to release anyway" - read magicword - - if [ "$magicword" = "iknowwhatido" ]; then - masterbranch=no - else - exit 1 - fi - fi - - if [ "$masterbranch" = yes ]; then - # Ensure version branch exists - if ! git rev-parse --verify refs/heads/$target_branch 2>/dev/null; then - git branch "$target_branch" - fi - - # Merge master branch into version branch - git checkout "$target_branch" - git merge master - fi - - # Verify that after the merge everything works - "$0" check-date - "$0" check-unittest - - # Generate documentation (man and html) - # First, clean old generated docs - make helper=${helper} docs-clean - make helper=${helper} docs - - ############################################################# - # Everything green, let's do the release - - # Tag the current commit - "$0" release-git-tag - - # Also merge back the version branch - if [ "$masterbranch" = yes ]; then - git checkout master - git merge "$target_branch" - fi - - # Publish git changes - case "$run_as" in - freebsd) - # if we are not Nico :) then just push, no mirror - git push - # push also new branch and set up tracking - git push -u origin "${target_branch}" - ;; - *) - make helper=${helper} pub - ;; - esac - - # Ensure that pypi release has the right version - "$0" version - - # Create and publish package for pypi - make helper=${helper} pypi-release - - # sign git tag - printf "Enter upstream repository authentication token: " - read token - "$0" sign-git-release "${target_version}" "${token}" - - # Announce change on ML - make helper=${helper} ml-release - - cat << eof -Manual steps post release: - - - cdist-web - - twitter - -eof - ;; - - test) - export PYTHONPATH="$(pwd -P)" - - if [ $# -lt 1 ]; then - python3 -m cdist.test - else - python3 -m unittest "$@" - fi - ;; - - test-remote) - export PYTHONPATH="$(pwd -P)" - python3 -m cdist.test.exec.remote - ;; - - pycodestyle|pep8) - pycodestyle "${basedir}" "${basedir}/scripts/cdist" | less - ;; - - check-pycodestyle) - "$0" pycodestyle - printf "\\nPlease review pycodestyle report.\\n" - while true - do - echo "Continue (yes/no)?" - any= - read any - case "$any" in - yes) - break - ;; - no) - exit 1 - ;; - *) - echo "Please answer with 'yes' or 'no' explicitly." - ;; - esac - done - ;; - - shellcheck) - make helper=${helper} shellcheck - printf "\\nPlease review shellcheck report.\\n" - while true - do - echo "Continue (yes/no)?" - any= - read any - case "$any" in - yes) - break - ;; - no) - exit 1 - ;; - *) - echo "Please answer with 'yes' or 'no' explicitly." - ;; - esac - done - ;; - - version-branch) - "$0" changelog-version | cut -d. -f '1,2' - ;; - - version) - echo "VERSION = \"$(git describe)\"" > cdist/version.py - ;; - - target-version) - target_version=$($0 changelog-version) - echo "VERSION = \"${target_version}\"" > cdist/version.py - ;; - - *) - echo "Unknown helper target $@ - aborting" - exit 1 - ;; - -esac From 513fde1cc1fcc612514cefaf18fd0822095c92e9 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Sat, 4 May 2019 10:51:10 +0200 Subject: [PATCH 0366/1217] ++changelog --- docs/changelog | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/changelog b/docs/changelog index d367ed47..2e1df3d5 100644 --- a/docs/changelog +++ b/docs/changelog @@ -10,6 +10,9 @@ next: * Build: Update due to migration to code.ungleich.ch (Darko Poljak) * Documentation: Update due to migration to code.ungleich.ch (Darko Poljak) * Core: Detect and report dependency cycle as soon as possible (Darko Poljak) + * Core, documentation: Release -j/--jobs option, i.e. make it non-beta (Darko Poljak) + * Documentation: Update due to new cdist website (Darko Poljak) + * Build: Update due to new cdist website (Darko Poljak) 4.11.1: 2019-04-22 * Core: Improve explorer error reporting (Darko Poljak) From 10a29ca9e6173b5843aab6b45143b4f7c343d401 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Sun, 5 May 2019 00:02:51 +0200 Subject: [PATCH 0367/1217] Fix pycodestyle issue --- cdist/config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cdist/config.py b/cdist/config.py index 4e226b3a..bc05a28c 100644 --- a/cdist/config.py +++ b/cdist/config.py @@ -48,7 +48,7 @@ def graph_check_cycle(graph): for node in graph: # Cycle path. path = [node] - has_cycle = _graph_dfs_cycle( graph, node, path) + has_cycle = _graph_dfs_cycle(graph, node, path) if has_cycle: return has_cycle, path return False, None From aad6c341780669c0c6ce26aae99259669f9f839b Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Sat, 4 May 2019 23:30:50 +0200 Subject: [PATCH 0368/1217] Release 5.0.0 --- docs/changelog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/changelog b/docs/changelog index 2e1df3d5..d6251523 100644 --- a/docs/changelog +++ b/docs/changelog @@ -1,7 +1,7 @@ Changelog --------- -next: +5.0.0: 2019-05-05 * Type __zypper_service: Fix spelling error in manpage (Dmitry Bogatov) * Explorer init: Add support for OpenBSD (sideeffect42) * Type __postgres_database: Run psql with -w (no-password) (sideeffect42) From 4d75a05e3595e2bcfa96c461d8025cc92babf7f3 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Sun, 5 May 2019 10:31:23 +0200 Subject: [PATCH 0369/1217] Rm redundant tag description from rel notes --- bin/build-helper | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/build-helper b/bin/build-helper index 0b2d5282..009e96ff 100755 --- a/bin/build-helper +++ b/bin/build-helper @@ -235,8 +235,8 @@ eof # make release changelog=$("$0" changelog-changes "$1" | sed 's/^[[:space:]]*//') release_notes=$( - printf "Release %s\n\n%s\n\n%s\n\n**Changelog**\n\n%s\n" \ - "${tag}" "${response_archive}" "${response_archive_sig}" "${changelog}" + printf "%s\n\n%s\n\n**Changelog**\n\n%s\n" \ + "${response_archive}" "${response_archive_sig}" "${changelog}" ) curl -f -X POST \ -H "PRIVATE-TOKEN: ${token}" \ From 735f57b3a032fad842c9d4306080b5d7a4c53a38 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Sun, 5 May 2019 17:55:02 +0200 Subject: [PATCH 0370/1217] Add 'Perils of CDIST_ORDER_DEPENDENCY' sub-section --- docs/src/cdist-best-practice.rst | 92 ++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) diff --git a/docs/src/cdist-best-practice.rst b/docs/src/cdist-best-practice.rst index a99ba88e..7a1255d6 100644 --- a/docs/src/cdist-best-practice.rst +++ b/docs/src/cdist-best-practice.rst @@ -224,3 +224,95 @@ in the repository for such content: It allows you to easily distinguish what is used by cdist and what is not and also to store all important files in one repository. + + +Perils of CDIST_ORDER_DEPENDENCY +-------------------------------- +With CDIST_ORDER_DEPENDENCY all types are executed in the order in which they +are created in the manifest. The current created object automatically depends +on the previously created object. + +It essentially helps you to build up blocks of code that build upon each other +(like first creating the directory xyz than the file below the directory). + +This can be helpful, but it can also be the source of *evil*. + +Let's see an example. Suppose you have special init manifest where among other +things you are assuring that remote host has packages `sudo` and `curl` +installed. + +**init1** + +.. code-block:: sh + + CDIST_ORDER_DEPENDENCY=1 + export CDIST_ORDER_DEPENDENCY + + for p in sudo curl + do + __package "${p}" + done + +Then you have some other special init manifest where among other things you are +assuring `sudo` package is installed. + +**init2** + +.. code-block:: sh + + CDIST_ORDER_DEPENDENCY=1 + export CDIST_ORDER_DEPENDENCY + + __package sudo + +Then you have third init manifest where you combine those two init manifests, +by including them: + +**init** + +.. code-block:: sh + + sh -e "$__manifest/init1" + sh -e "$__manifest/init2" + +The resulting init manifest is then equal to: + +.. code-block:: sh + + CDIST_ORDER_DEPENDENCY=1 + export CDIST_ORDER_DEPENDENCY + + for p in sudo curl + do + __package "${p}" + done + + CDIST_ORDER_DEPENDENCY=1 + export CDIST_ORDER_DEPENDENCY + + __package sudo + +In the end you get the following dependencies: + +* `__package/curl` depends on `__package/sudo` +* `__package/sudo` depends on `__package/curl` + +And here you have a circular dependency! + +In the real world manifest can be quite complex, dependencies can become +complicated and circual dependencies are not so obvious. Resolving it can +become cumbersome. + +**Practical solution?** + +Instead of managing complex init manifests you can write custom types. +Each custom type can do one thing, it has well defined dependencies that will +not leak into init manifest. In custom type you can also add special explorers +and gencode. + +Then, in init manifest you combine your complex types. It is: + +* cleaner +* easier to follow +* easier to maintain +* easier to debug. From 28082c710aa02a1861a4396513469ecfa7ef2d4f Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Mon, 6 May 2019 11:11:10 +0200 Subject: [PATCH 0371/1217] Add refs to perils of CDIST_ORDER_DEPENDENCY --- docs/src/cdist-manifest.rst | 2 ++ docs/src/cdist-reference.rst.sh | 1 + 2 files changed, 3 insertions(+) diff --git a/docs/src/cdist-manifest.rst b/docs/src/cdist-manifest.rst index 0e266943..4dd3e74b 100644 --- a/docs/src/cdist-manifest.rst +++ b/docs/src/cdist-manifest.rst @@ -163,6 +163,8 @@ automatically depends on the previously created object. It essentially helps you to build up blocks of code that build upon each other (like first creating the directory xyz than the file below the directory). +Read also about `perils of CDIST_ORDER_DEPENDENCY `_. + Overrides --------- diff --git a/docs/src/cdist-reference.rst.sh b/docs/src/cdist-reference.rst.sh index 59ce018b..2c9c7b40 100755 --- a/docs/src/cdist-reference.rst.sh +++ b/docs/src/cdist-reference.rst.sh @@ -323,6 +323,7 @@ CDIST_OVERRIDE CDIST_ORDER_DEPENDENCY Create dependencies based on the execution order (see \`cdist manifest \`_). + Read also about \`perils of CDIST_ORDER_DEPENDENCY \`_. CDIST_REMOTE_EXEC Use this command for remote execution (should behave like ssh). From 02eb6c75a7979eb2fa1ec2b4921ab9fafe582edd Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Mon, 6 May 2019 17:11:23 +0200 Subject: [PATCH 0372/1217] Add 'CDIST_ORDER_DEPENDENCY kills parallelization' --- docs/src/cdist-best-practice.rst | 45 ++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/docs/src/cdist-best-practice.rst b/docs/src/cdist-best-practice.rst index 7a1255d6..a91f2cc0 100644 --- a/docs/src/cdist-best-practice.rst +++ b/docs/src/cdist-best-practice.rst @@ -237,6 +237,10 @@ It essentially helps you to build up blocks of code that build upon each other This can be helpful, but it can also be the source of *evil*. + +CDIST_ORDER_DEPENDENCY easily causes unobvious dependency cycles +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + Let's see an example. Suppose you have special init manifest where among other things you are assuring that remote host has packages `sudo` and `curl` installed. @@ -316,3 +320,44 @@ Then, in init manifest you combine your complex types. It is: * easier to follow * easier to maintain * easier to debug. + + +CDIST_ORDER_DEPENDENCY kills parallelization +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Suppose you have defined CDIST_ORDER_DEPENDENCY and then, among other things, +you specify creation of three, by nature independent, files. + +**init** + +.. code-block:: sh + + CDIST_ORDER_DEPENDENCY=1 + export CDIST_ORDER_DEPENDENCY + + ... + __file /tmp/file1 + __file /tmp/file2 + __file /tmp/file3 + ... + +Due to defined CDIST_ORDER_DEPENDENCY cdist will execute them in specified order. +It is better to use CDIST_ORDER_DEPENDENCY in well defined blocks: + +**init** + +.. code-block:: sh + + CDIST_ORDER_DEPENDENCY=1 + export CDIST_ORDER_DEPENDENCY + ... + unset CDIST_ORDER_DEPENDENCY + + __file /tmp/file1 + __file /tmp/file2 + __file /tmp/file3 + + CDIST_ORDER_DEPENDENCY=1 + export CDIST_ORDER_DEPENDENCY + ... + unset CDIST_ORDER_DEPENDENCY From d696a55879b74eac091e338c95dbe5b144c8054c Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Mon, 6 May 2019 17:13:36 +0200 Subject: [PATCH 0373/1217] ++changelog --- docs/changelog | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/changelog b/docs/changelog index d6251523..40cb1f83 100644 --- a/docs/changelog +++ b/docs/changelog @@ -1,6 +1,9 @@ Changelog --------- +next: + * Documentation: Add 'Perils of CDIST_ORDER_DEPENDENCY' sub-section (Darko Poljak) + 5.0.0: 2019-05-05 * Type __zypper_service: Fix spelling error in manpage (Dmitry Bogatov) * Explorer init: Add support for OpenBSD (sideeffect42) From 4f40c6ac656413cb6664809c299e1021430d13d0 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Tue, 7 May 2019 18:16:54 +0200 Subject: [PATCH 0374/1217] Re-arrange Makefile and build-helper script Maintainers should use build-helper script. End users should use Makefile, which contains targets that can be run on pure source (without git repository). --- .gitattributes | 2 + Makefile | 158 ++++--------------- README-maintainers | 4 + bin/build-helper | 311 +++++++++++++++++++++++++++++-------- bin/build-helper.darko | 1 - docs/changelog | 1 + docs/src/cdist-install.rst | 19 ++- 7 files changed, 296 insertions(+), 200 deletions(-) create mode 100644 README-maintainers delete mode 120000 bin/build-helper.darko diff --git a/.gitattributes b/.gitattributes index aeaab8b9..45c10d7b 100644 --- a/.gitattributes +++ b/.gitattributes @@ -4,3 +4,5 @@ docs/speeches export-ignore docs/video export-ignore docs/src/man7 export-ignore +bin/build-helper export-ignore +README-maintainers export-ignore diff --git a/Makefile b/Makefile index 099812e2..b739ab1f 100644 --- a/Makefile +++ b/Makefile @@ -18,25 +18,27 @@ # # -helper=./bin/build-helper +.PHONY: help +help: + @echo "Please use \`make ' where is one of" + @echo "man build only man user documentation" + @echo "html build only html user documentation" + @echo "docs build both man and html user documentation" + @echo "dotman build man pages for types in your ~/.cdist directory" + @echo "speeches build speeches pdf files" + @echo "install install in the system site-packages directory" + @echo "install-user install in the user site-packages directory" + @echo "docs-clean clean documentation" + @echo "clean clean" DOCS_SRC_DIR=docs/src SPEECHDIR=docs/speeches TYPEDIR=cdist/conf/type -CHANGELOG_VERSION=$(shell $(helper) changelog-version) -CHANGELOG_FILE=docs/changelog - -PYTHON_VERSION=cdist/version.py - SPHINXM=make -C $(DOCS_SRC_DIR) man SPHINXH=make -C $(DOCS_SRC_DIR) html SPHINXC=make -C $(DOCS_SRC_DIR) clean -SHELLCHECKCMD=shellcheck -s sh -f gcc -x -# Skip SC2154 for variables starting with __ since such variables are cdist -# environment variables. -SHELLCHECK_SKIP=grep -v ': __.*is referenced but not assigned.*\[SC2154\]' ################################################################################ # Manpages # @@ -61,11 +63,16 @@ DOCSREFSH=$(DOCS_SRC_DIR)/cdist-reference.rst.sh $(DOCSREF): $(DOCSREFSH) $(DOCSREFSH) +version: + @[ -f "cdist/version.py" ] || { \ + printf "Missing 'cdist/version.py', please generate it first.\n" && exit 1; \ + } + # Manpages #3: generic part -man: $(MANTYPES) $(DOCSREF) $(PYTHON_VERSION) +man: version $(MANTYPES) $(DOCSREF) $(SPHINXM) -html: $(MANTYPES) $(DOCSREF) $(PYTHON_VERSION) +html: version $(MANTYPES) $(DOCSREF) $(SPHINXH) docs: man html @@ -85,7 +92,7 @@ DOTMANTYPES=$(subst /man.rst,.rst,$(DOTMANTYPEPREFIX)) $(DOTMAN7DSTDIR)/cdist-type%.rst: $(DOTTYPEDIR)/%/man.rst ln -sf "$^" $@ -dotman: $(DOTMANTYPES) +dotman: version $(DOTMANTYPES) $(SPHINXM) ################################################################################ @@ -103,132 +110,25 @@ $(SPEECHDIR)/%.pdf: $(SPEECHDIR)/%.tex speeches: $(SPEECHES) ################################################################################ -# Release: Mailinglist +# Misc # -ML_FILE=.lock-ml - -# Only send mail once - lock until new changelog things happened -$(ML_FILE): $(CHANGELOG_FILE) - $(helper) ml-release $(CHANGELOG_VERSION) - touch $@ - -ml-release: $(ML_FILE) - - -################################################################################ -# pypi -# -PYPI_FILE=.pypi-release -$(PYPI_FILE): man $(PYTHON_VERSION) - python3 setup.py sdist upload - touch $@ - -pypi-release: $(PYPI_FILE) -################################################################################ -# archlinux -# -ARCHLINUX_FILE=.lock-archlinux -ARCHLINUXTAR=cdist-$(CHANGELOG_VERSION)-1.src.tar.gz - -$(ARCHLINUXTAR): PKGBUILD - umask 022; mkaurball - -PKGBUILD: PKGBUILD.in $(PYTHON_VERSION) - ./PKGBUILD.in $(CHANGELOG_VERSION) - -$(ARCHLINUX_FILE): $(ARCHLINUXTAR) $(PYTHON_VERSION) - burp -c system $(ARCHLINUXTAR) - touch $@ - -archlinux-release: $(ARCHLINUX_FILE) - -################################################################################ -# Release -# - -$(PYTHON_VERSION) version: .git/refs/heads/master - $(helper) version - -# Code that is better handled in a shell script -check-%: - $(helper) $@ - -release: - $(helper) $@ - -################################################################################ -# Cleanup -# - -clean: +clean: docs-clean rm -f $(DOCS_SRC_DIR)/cdist-reference.rst find "$(DOCS_SRC_DIR)" -mindepth 2 -type l \ | xargs rm -f - make -C $(DOCS_SRC_DIR) clean - find * -name __pycache__ | xargs rm -rf - # Archlinux - rm -f cdist-*.pkg.tar.xz cdist-*.tar.gz - rm -rf pkg/ src/ - - rm -f MANIFEST PKGBUILD - rm -rf dist/ - - # Signed release - rm -f cdist-*.tar.gz - rm -f cdist-*.tar.gz.asc - - # Temp files - rm -f *.tmp - -distclean: clean - rm -f cdist/version.py + # distutils + rm -rf ./build ################################################################################ -# Misc +# install # -# The pub is Nico's "push to all git remotes" way ("make pub") -pub: - git push --mirror +install: + python3 setup.py install -test: - $(helper) $@ - -test-remote: - $(helper) $@ - -pycodestyle pep8: - $(helper) $@ - -shellcheck-global-explorers: - @find cdist/conf/explorer -type f -exec $(SHELLCHECKCMD) {} + | $(SHELLCHECK_SKIP) || exit 0 - -shellcheck-type-explorers: - @find cdist/conf/type -type f -path "*/explorer/*" -exec $(SHELLCHECKCMD) {} + | $(SHELLCHECK_SKIP) || exit 0 - -shellcheck-manifests: - @find cdist/conf/type -type f -name manifest -exec $(SHELLCHECKCMD) {} + | $(SHELLCHECK_SKIP) || exit 0 - -shellcheck-local-gencodes: - @find cdist/conf/type -type f -name gencode-local -exec $(SHELLCHECKCMD) {} + | $(SHELLCHECK_SKIP) || exit 0 - -shellcheck-remote-gencodes: - @find cdist/conf/type -type f -name gencode-remote -exec $(SHELLCHECKCMD) {} + | $(SHELLCHECK_SKIP) || exit 0 - -shellcheck-scripts: - @$(SHELLCHECKCMD) scripts/cdist-dump || exit 0 - -shellcheck-gencodes: shellcheck-local-gencodes shellcheck-remote-gencodes - -shellcheck-types: shellcheck-type-explorers shellcheck-manifests shellcheck-gencodes - -shellcheck: shellcheck-global-explorers shellcheck-types shellcheck-scripts - -shellcheck-type-files: - @find cdist/conf/type -type f -path "*/files/*" -exec $(SHELLCHECKCMD) {} + | $(SHELLCHECK_SKIP) || exit 0 - -shellcheck-with-files: shellcheck shellcheck-type-files +install-user: + python3 setup.py install --user diff --git a/README-maintainers b/README-maintainers new file mode 100644 index 00000000..af57f475 --- /dev/null +++ b/README-maintainers @@ -0,0 +1,4 @@ +Maintainers should use ./bin/build-helper script. + +Makefile is intended for end users. It can be used for non-maintaining +targets that can be run from pure source (without git repository). diff --git a/bin/build-helper b/bin/build-helper index 009e96ff..bba44ded 100755 --- a/bin/build-helper +++ b/bin/build-helper @@ -22,47 +22,101 @@ # This file contains the heavy lifting found usually in the Makefile. # -# vars for make -helper=$0 +usage() { + printf "usage: %s TARGET [RUN-AS] + Available targets: + print-runas + changelog-changes + changelog-version + check-date + check-unittest + ml-release + archlinux-release + pypi-release + release-git-tag + sign-git-release + release + test + test-remote + pycodestyle + pep8 + check-pycodestyle + shellcheck-global-explorers + shellcheck-type-explorers + shellcheck-manifests + shellcheck-local-gencodes + shellcheck-remote-gencodes + shellcheck-scripts + shellcheck-gencodes + shellcheck-types + shellcheck + shellcheck-type-files + shellcheck-with-files + shellcheck-build-helper + check-shellcheck + version-branch + version + target-version + clean + distclean + Run as: + nico + darko - default, if not specified\n" "$1" +} -basedir=${0%/*}/../ -# run_as is used to check how the script is called (by $0 value) -# currently supported sufixes for $0 are: -# .darko - run as darko -basename=${0##*/} -run_as=${basename#*.} +basename="${0##*/}" + +if [ $# -lt 1 ] +then + usage "${basename}" + exit 1 +fi + +option=$1; shift +if [ $# -ge 1 ] +then + run_as="$1" +else + run_as="darko" +fi -to_a=cdist-configuration-management -to_d=googlegroups.com case "$run_as" in - darko) + nico) + from_a=nico.schottelius + from_d=ungleich.ch + ml_name="Nico Schottelius" + ml_sig_name="Nico" + ;; + darko|'') from_a=darko.poljak from_d=gmail.com ml_name="Darko Poljak" ml_sig_name="Darko" ;; *) - from_a=nico.schottelius - from_d=ungleich.ch - ml_name="Nico Schottelius" - ml_sig_name="Nico" + printf "Unsupported RUN-AS value: '%s'.\n" "${run_as}" >&2 + usage "${basename}" + exit 1 ;; esac +SHELLCHECKCMD="shellcheck -s sh -f gcc -x" +# Skip SC2154 for variables starting with __ since such variables are cdist +# environment variables. +SHELLCHECK_SKIP=': __.*is referenced but not assigned.*\[SC2154\]' + +to_a="cdist-configuration-management" +to_d="googlegroups.com" + # Change to checkout directory +basedir="${0%/*}/../" cd "$basedir" -version=$(git describe) - -option=$1; shift - case "$option" in - print-make-vars) - printf "helper: ${helper}\n" - ;; print-runas) - printf "run_as: $run_as\n" + printf "run_as: '%s'\n" "$run_as" ;; + changelog-changes) if [ "$#" -eq 1 ]; then start=$1 @@ -99,8 +153,8 @@ case "$option" in date_changelog=$(grep '^[[:digit:]]' "$basedir/docs/changelog" | head -n1 | sed 's/.*: //') if [ "$date_today" != "$date_changelog" ]; then - echo "Date in changelog is not today" - echo "Changelog: $date_changelog" + printf "Date in changelog is not today\n" + printf "Changelog date: %s\n" "${date_changelog}" exit 1 fi ;; @@ -111,10 +165,15 @@ case "$option" in ml-release) if [ $# -ne 1 ]; then - echo "$0 ml-release version" >&2 + printf "%s ml-release version\n" "$0" >&2 exit 1 fi + # Send mail only once - lock until new changelog things happened. + [ ! -f .lock-ml ] && touch .lock-ml + x=$(find 'docs' -name changelog -type f -newer .lock-ml) + [ -z "${x}" ] && exit 0 + version=$1; shift to=${to_a}@${to_d} @@ -143,20 +202,45 @@ Automatisation at its best level. With cdist. eof ) > mailinglist.tmp - if [ "$run_as" = "build-helper" ] + if [ "$run_as" = "nico" ] then /usr/sbin/sendmail -f "$from" "$to" < mailinglist.tmp && rm -f mailinglist.tmp fi + + touch .lock-ml + ;; + + archlinux-release) + if [ $# -ne 1 ]; then + printf "%s archlinux-release version\n" "$0" >&2 + exit 1 + fi + version=$1; shift + + ARCHLINUXTAR="cdist-${version}-1.src.tar.gz" + ./PKGBUILD.in "${version}" + umask 022 + mkaurball + burp -c system "${ARCHLINUXTAR}" + ;; + + pypi-release) + # Ensure that pypi release has the right version + "$0" version + + make docs-clean + make docs + python3 setup.py sdist upload ;; release-git-tag) target_version=$($0 changelog-version) - if git rev-parse --verify refs/tags/$target_version 2>/dev/null; then - echo "Tag for $target_version exists, aborting" + if git rev-parse --verify "refs/tags/${target_version}" 2>/dev/null; then + printf "Tag for %s exists, aborting\n" "${target_version}" exit 1 fi - printf "Enter tag description for ${target_version}: " - read tagmessage + printf "Enter tag description for %s: " "${target_version}" + read -r tagmessage # setup for signed tags: # gpg --fulL-gen-key @@ -174,7 +258,8 @@ eof # gpg --verify # gpg --no-default-keyring --keyring --verify # Ensure gpg-agent is running. - export GPG_TTY=$(tty) + GPG_TTY=$(tty) + export GPG_TTY gpg-agent git tag -s "$target_version" -m "$tagmessage" @@ -184,14 +269,14 @@ eof sign-git-release) if [ $# -lt 2 ] then - printf "usage: $0 sign-git-release TAG TOKEN [ARCHIVE]\n" + printf "usage: %s sign-git-release TAG TOKEN [ARCHIVE]\n" "$0" printf " if ARCHIVE is not specified then it is created\n" exit 1 fi tag="$1" if ! git rev-parse -q --verify "${tag}" >/dev/null 2>&1 then - printf "Tag \"${tag}\" not found.\n" + printf "Tag \"%s\" not found.\n" "${tag}" exit 1 fi token="$2" @@ -257,30 +342,30 @@ eof target_version=$($0 changelog-version) target_branch=$($0 version-branch) - echo "Beginning release process for $target_version" + printf "Beginning release process for %s\n" "${target_version}" # First check everything is sane "$0" check-date "$0" check-unittest "$0" check-pycodestyle - "$0" shellcheck + "$0" check-shellcheck # Generate version file to be included in packaging "$0" target-version # Ensure the git status is clean, else abort if ! git diff-index --name-only --exit-code HEAD ; then - echo "Unclean tree, see files above, aborting" + printf "Unclean tree, see files above, aborting.\n" exit 1 fi # Ensure we are on the master branch masterbranch=yes if [ "$(git rev-parse --abbrev-ref HEAD)" != "master" ]; then - echo "Releases are happening from the master branch, aborting" + printf "Releases are happening from the master branch, aborting.\n" - echo "Enter the magic word to release anyway" - read magicword + printf "Enter the magic word to release anyway:" + read -r magicword if [ "$magicword" = "iknowwhatido" ]; then masterbranch=no @@ -291,7 +376,7 @@ eof if [ "$masterbranch" = yes ]; then # Ensure version branch exists - if ! git rev-parse --verify refs/heads/$target_branch 2>/dev/null; then + if ! git rev-parse --verify "refs/heads/${target_branch}" 2>/dev/null; then git branch "$target_branch" fi @@ -306,8 +391,8 @@ eof # Generate documentation (man and html) # First, clean old generated docs - make helper=${helper} docs-clean - make helper=${helper} docs + make docs-clean + make docs ############################################################# # Everything green, let's do the release @@ -322,35 +407,33 @@ eof fi # Publish git changes - if [ "$run_as" = "build-helper" ] - then - make helper=${helper} pub - else + # if you want to have mirror locally then uncomment this support + # if [ "$run_as" = "nico" ] + # then + # git push --mirror + # else # if we are not Nico :) then just push, no mirror git push # push also new branch and set up tracking git push -u origin "${target_branch}" - fi - - # Ensure that pypi release has the right version - "$0" version + # fi # Create and publish package for pypi - make helper=${helper} pypi-release + "$0" pypi-release - if [ "$run_as" = "build-helper" ] + if [ "$run_as" = "nico" ] then # Archlinux release is based on pypi - make helper=${helper} archlinux-release + "$0" archlinux-release fi # sign git tag printf "Enter upstream repository authentication token: " - read token + read -r token "$0" sign-git-release "${target_version}" "${token}" # Announce change on ML - make helper=${helper} ml-release + "$0" ml-release "${target_version}" cat << eof Manual steps post release: @@ -360,7 +443,14 @@ eof ;; test) - export PYTHONPATH="$(pwd -P)" + if [ ! -f "cdist/version.py" ] + then + printf "cdist/version.py is missing, generate it first.\n" + exit 1 + fi + + PYTHONPATH="$(pwd -P)" + export PYTHONPATH if [ $# -lt 1 ]; then python3 -m cdist.test @@ -370,7 +460,15 @@ eof ;; test-remote) - export PYTHONPATH="$(pwd -P)" + if [ ! -f "cdist/version.py" ] + then + printf "cdist/version.py is missing, generate it first.\n" + exit 1 + fi + + PYTHONPATH="$(pwd -P)" + export PYTHONPATH + python3 -m cdist.test.exec.remote ;; @@ -383,9 +481,9 @@ eof printf "\\nPlease review pycodestyle report.\\n" while true do - echo "Continue (yes/no)?" + printf "Continue (yes/no)?\n" any= - read any + read -r any case "$any" in yes) break @@ -394,20 +492,74 @@ eof exit 1 ;; *) - echo "Please answer with 'yes' or 'no' explicitly." + printf "Please answer with 'yes' or 'no' explicitly.\n" ;; esac done ;; + shellcheck-global-explorers) + find cdist/conf/explorer -type f -exec ${SHELLCHECKCMD} {} + | grep -v "${SHELLCHECK_SKIP}" || exit 0 + ;; + + shellcheck-type-explorers) + find cdist/conf/type -type f -path "*/explorer/*" -exec ${SHELLCHECKCMD} {} + | grep -v "${SHELLCHECK_SKIP}" || exit 0 + ;; + + shellcheck-manifests) + find cdist/conf/type -type f -name manifest -exec ${SHELLCHECKCMD} {} + | grep -v "${SHELLCHECK_SKIP}" || exit 0 + ;; + + shellcheck-local-gencodes) + find cdist/conf/type -type f -name gencode-local -exec ${SHELLCHECKCMD} {} + | grep -v "${SHELLCHECK_SKIP}" || exit 0 + ;; + + shellcheck-remote-gencodes) + find cdist/conf/type -type f -name gencode-remote -exec ${SHELLCHECKCMD} {} + | grep -v "${SHELLCHECK_SKIP}" || exit 0 + ;; + + shellcheck-scripts) + ${SHELLCHECKCMD} scripts/cdist-dump || exit 0 + ;; + + shellcheck-gencodes) + "$0" shellcheck-local-gencodes + "$0" shellcheck-remote-gencodes + ;; + + shellcheck-types) + "$0" shellcheck-type-explorers + "$0" shellcheck-manifests + "$0" shellcheck-gencodes + ;; + shellcheck) - make helper=${helper} shellcheck + "$0" shellcheck-global-explorers + "$0" shellcheck-types + "$0" shellcheck-scripts + ;; + + shellcheck-type-files) + find cdist/conf/type -type f -path "*/files/*" -exec ${SHELLCHECKCMD} {} + | grep -v "${SHELLCHECK_SKIP}" || exit 0 + ;; + + shellcheck-with-files) + "$0" shellcheck + "$0" shellcheck-type-files + ;; + + shellcheck-build-helper) + ${SHELLCHECKCMD} ./bin/build-helper + ;; + + check-shellcheck) + "$0" shellcheck printf "\\nPlease review shellcheck report.\\n" while true do - echo "Continue (yes/no)?" + printf "Continue (yes/no)?\n" any= - read any + read -r any case "$any" in yes) break @@ -416,7 +568,7 @@ eof exit 1 ;; *) - echo "Please answer with 'yes' or 'no' explicitly." + printf "Please answer with 'yes' or 'no' explicitly.\n" ;; esac done @@ -427,16 +579,39 @@ eof ;; version) - echo "VERSION = \"$(git describe)\"" > cdist/version.py + printf "VERSION = \"%s\"\n" "$(git describe)" > cdist/version.py ;; target-version) target_version=$($0 changelog-version) - echo "VERSION = \"${target_version}\"" > cdist/version.py + printf "VERSION = \"%s\"\n" "${target_version}" > cdist/version.py ;; + clean) + make clean + + # Archlinux + rm -f cdist-*.pkg.tar.xz cdist-*.tar.gz + rm -rf pkg/ src/ + + rm -f MANIFEST PKGBUILD + rm -rf dist/ + + # Signed release + rm -f cdist-*.tar.gz + rm -f cdist-*.tar.gz.asc + + # Temp files + rm -f ./*.tmp + ;; + + distclean) + "$0" clean + rm -f cdist/version.py + ;; *) - echo "Unknown helper target $@ - aborting" + printf "Unknown target: '%s'.\n" "${option}" >&2 + usage "${basename}" exit 1 ;; diff --git a/bin/build-helper.darko b/bin/build-helper.darko deleted file mode 120000 index 1f3e3384..00000000 --- a/bin/build-helper.darko +++ /dev/null @@ -1 +0,0 @@ -build-helper \ No newline at end of file diff --git a/docs/changelog b/docs/changelog index 40cb1f83..38c59047 100644 --- a/docs/changelog +++ b/docs/changelog @@ -3,6 +3,7 @@ Changelog next: * Documentation: Add 'Perils of CDIST_ORDER_DEPENDENCY' sub-section (Darko Poljak) + * Build: Clean and separate end user targets into Makefile and maintainer targets into build-helper (Darko Poljak) 5.0.0: 2019-05-05 * Type __zypper_service: Fix spelling error in manpage (Dmitry Bogatov) diff --git a/docs/src/cdist-install.rst b/docs/src/cdist-install.rst index c05036b0..4d3df8f8 100644 --- a/docs/src/cdist-install.rst +++ b/docs/src/cdist-install.rst @@ -48,14 +48,29 @@ create version.py: .. code-block:: sh - make version + ./bin/build-helper version -Then, as usual, you execute the following command: +Then you install it with: + +.. code-block:: sh + + make install + +or with: + +.. code-block:: sh + + make install-user + +to install it into user *site-packages* directory. +Or directly with distutils: .. code-block:: sh python setup.py install +Note that `bin/build-helper` script is intended for cdist maintainers. + Available versions in git ^^^^^^^^^^^^^^^^^^^^^^^^^ From 73fd1ffbc142c57d652750aac143fe07a2e58135 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Wed, 8 May 2019 23:38:43 +0200 Subject: [PATCH 0375/1217] Update homepage --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index d76bbd4b..5f14a2f4 100644 --- a/setup.py +++ b/setup.py @@ -41,7 +41,7 @@ setup( description="A Usable Configuration Management System", author="Nico Schottelius", author_email="nico-cdist-pypi@schottelius.org", - url="http://www.nico.schottelius.org/software/cdist/", + url="https://www.cdi.st/", classifiers=[ "Development Status :: 6 - Mature", "Environment :: Console", From 15f01149f96205d17711cbe8abdcabfd37f1087c Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Thu, 9 May 2019 08:26:42 +0200 Subject: [PATCH 0376/1217] Update old homepage residual refs and non working git protocol --- PKGBUILD.in | 2 +- cdist/argparse.py | 2 +- cdist/conf/type/__cdist/man.rst | 4 ++-- cdist/conf/type/__cdist/parameter/default/source | 2 +- cdist/conf/type/__git/man.rst | 2 +- docs/changelog | 3 +++ docs/src/cdist-install.rst | 2 ++ docs/src/cdist-quickstart.rst | 4 +--- 8 files changed, 12 insertions(+), 9 deletions(-) diff --git a/PKGBUILD.in b/PKGBUILD.in index c967249d..c0188e68 100755 --- a/PKGBUILD.in +++ b/PKGBUILD.in @@ -9,7 +9,7 @@ pkgver=$version pkgrel=1 pkgdesc='A Usable Configuration Management System"' arch=('any') -url='http://www.nico.schottelius.org/software/cdist/' +url='https://www.cdi.st/' license=('GPL3') depends=('python>=3.2.0') source=("http://pypi.python.org/packages/source/c/cdist/cdist-\${pkgver}.tar.gz") diff --git a/cdist/argparse.py b/cdist/argparse.py index 3ebdc138..421d1b54 100644 --- a/cdist/argparse.py +++ b/cdist/argparse.py @@ -13,7 +13,7 @@ BETA_COMMANDS = set(('install', 'inventory', )) BETA_ARGS = { 'config': set(('tag', 'all_tagged_hosts', 'use_archiving', )), } -EPILOG = "Get cdist at http://www.nico.schottelius.org/software/cdist/" +EPILOG = "Get cdist at https://code.ungleich.ch/ungleich-public/cdist" # Parser others can reuse parser = None diff --git a/cdist/conf/type/__cdist/man.rst b/cdist/conf/type/__cdist/man.rst index 15c77d7f..be082781 100644 --- a/cdist/conf/type/__cdist/man.rst +++ b/cdist/conf/type/__cdist/man.rst @@ -30,7 +30,7 @@ username source Select the source from which to clone cdist from. - Defaults to "git://code.ungleich.ch/ungleich-public/cdist.git". + Defaults to "git@code.ungleich.ch:ungleich-public/cdist.git". branch @@ -47,7 +47,7 @@ EXAMPLES __cdist /home/cdist/cdist # Use alternative source - __cdist --source "git://code.ungleich.ch/ungleich-public/cdist" /home/cdist/cdist + __cdist --source "git@code.ungleich.ch:ungleich-public/cdist.git" /home/cdist/cdist AUTHORS diff --git a/cdist/conf/type/__cdist/parameter/default/source b/cdist/conf/type/__cdist/parameter/default/source index 5f44a285..1ad3a250 100644 --- a/cdist/conf/type/__cdist/parameter/default/source +++ b/cdist/conf/type/__cdist/parameter/default/source @@ -1 +1 @@ -git://code.ungleich.ch/ungleich-public/cdist.git +git@code.ungleich.ch:ungleich-public/cdist.git diff --git a/cdist/conf/type/__git/man.rst b/cdist/conf/type/__git/man.rst index aa704d2b..130925c8 100644 --- a/cdist/conf/type/__git/man.rst +++ b/cdist/conf/type/__git/man.rst @@ -44,7 +44,7 @@ EXAMPLES __git /home/services/dokuwiki --source git://github.com/splitbrain/dokuwiki.git # Checkout cdist, stay on branch 2.1 - __git /home/nico/cdist --source git://code.ungleich.ch/ungleich-public/cdist.git --branch 2.1 + __git /home/nico/cdist --source git@code.ungleich.ch:ungleich-public/cdist.git --branch 2.1 AUTHORS diff --git a/docs/changelog b/docs/changelog index 38c59047..e3fd9368 100644 --- a/docs/changelog +++ b/docs/changelog @@ -4,6 +4,9 @@ Changelog next: * Documentation: Add 'Perils of CDIST_ORDER_DEPENDENCY' sub-section (Darko Poljak) * Build: Clean and separate end user targets into Makefile and maintainer targets into build-helper (Darko Poljak) + * Core: Update residual references to old cdist homepage (Darko Poljak) + * Documentation: Update residual references to old cdist homepage and git source (Darko Poljak) + * Type __cdist: Fix non working 'git://' protocol source (Darko Poljak) 5.0.0: 2019-05-05 * Type __zypper_service: Fix spelling error in manpage (Dmitry Bogatov) diff --git a/docs/src/cdist-install.rst b/docs/src/cdist-install.rst index 4d3df8f8..a9b7d6b5 100644 --- a/docs/src/cdist-install.rst +++ b/docs/src/cdist-install.rst @@ -43,6 +43,8 @@ To install cdist, execute the following commands: From version 4.2.0 cdist tags and releases are signed. You can get GPG public key used for signing `here <_static/pgp-key-EFD2AE4EC36B6901.asc>`_. +You can also get cdist from `github mirror `_. + To install cdist with distutils from cloned repository, first you have to create version.py: diff --git a/docs/src/cdist-quickstart.rst b/docs/src/cdist-quickstart.rst index b9220b67..99af869f 100644 --- a/docs/src/cdist-quickstart.rst +++ b/docs/src/cdist-quickstart.rst @@ -54,9 +54,7 @@ we can use cdist to configure it. You can copy and paste the following code into your shell to get started and configure localhost:: # Get cdist - # Mirrors can be found on - # http://www.nico.schottelius.org/software/cdist/install/#index2h4 - git clone git://code.ungleich.ch/ungleich-public/cdist + git clone git@code.ungleich.ch:ungleich-public/cdist.git # Create manifest (maps configuration to host(s) cd cdist From a8ee4356efbd15517c90763ea92e59c0faec2a23 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Thu, 9 May 2019 19:11:09 +0200 Subject: [PATCH 0377/1217] Release 5.0.1 --- docs/changelog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/changelog b/docs/changelog index e3fd9368..cd66c649 100644 --- a/docs/changelog +++ b/docs/changelog @@ -1,7 +1,7 @@ Changelog --------- -next: +5.0.1: 2019-05-09 * Documentation: Add 'Perils of CDIST_ORDER_DEPENDENCY' sub-section (Darko Poljak) * Build: Clean and separate end user targets into Makefile and maintainer targets into build-helper (Darko Poljak) * Core: Update residual references to old cdist homepage (Darko Poljak) From afa00a90943d69704aa9aa4c616992bada09c13c Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Thu, 9 May 2019 19:35:52 +0200 Subject: [PATCH 0378/1217] Fix build-helper script --- bin/build-helper | 87 ++++++++++++++++++++++++------------------------ 1 file changed, 43 insertions(+), 44 deletions(-) diff --git a/bin/build-helper b/bin/build-helper index bba44ded..00fe4ec7 100755 --- a/bin/build-helper +++ b/bin/build-helper @@ -23,7 +23,7 @@ # usage() { - printf "usage: %s TARGET [RUN-AS] + printf "usage: %s TARGET RUN-AS Available targets: print-runas changelog-changes @@ -61,24 +61,19 @@ usage() { distclean Run as: nico - darko - default, if not specified\n" "$1" + darko - default, if empty string specified\n" "$1" } basename="${0##*/}" -if [ $# -lt 1 ] +if [ $# -lt 2 ] then usage "${basename}" exit 1 fi option=$1; shift -if [ $# -ge 1 ] -then - run_as="$1" -else - run_as="darko" -fi +run_as="$1"; shift case "$run_as" in nico) @@ -92,6 +87,10 @@ case "$run_as" in from_d=gmail.com ml_name="Darko Poljak" ml_sig_name="Darko" + if [ -z "${run_as}" ] + then + run_as="darko" + fi ;; *) printf "Unsupported RUN-AS value: '%s'.\n" "${run_as}" >&2 @@ -160,7 +159,7 @@ case "$option" in ;; check-unittest) - "$0" test + "$0" test "${run_as}" ;; ml-release) @@ -191,7 +190,7 @@ cdist $version has been released with the following changes: eof - "$0" changelog-changes "$version" + "$0" changelog-changes "${run_as}" "$version" cat << eof Cheers, @@ -226,7 +225,7 @@ eof pypi-release) # Ensure that pypi release has the right version - "$0" version + "$0" version "${run_as}" make docs-clean make docs @@ -234,7 +233,7 @@ eof ;; release-git-tag) - target_version=$($0 changelog-version) + target_version=$($0 changelog-version "${run_as}") if git rev-parse --verify "refs/tags/${target_version}" 2>/dev/null; then printf "Tag for %s exists, aborting\n" "${target_version}" exit 1 @@ -288,7 +287,7 @@ eof git archive --prefix="cdist-${tag}/" -o "${archivename}" "${tag}" \ || exit 1 # make sure target version is generated - "$0" target-version + "$0" target-version "${run_as}" tar -x -f "${archivename}" || exit 1 cp cdist/version.py "cdist-${tag}/cdist/version.py" || exit 1 tar -c -f "${archivename}" "cdist-${tag}/" || exit 1 @@ -318,7 +317,7 @@ eof | sed "${sed_cmd}") || exit 1 # make release - changelog=$("$0" changelog-changes "$1" | sed 's/^[[:space:]]*//') + changelog=$("$0" changelog-changes "${run_as}" "$1" | sed 's/^[[:space:]]*//') release_notes=$( printf "%s\n\n%s\n\n**Changelog**\n\n%s\n" \ "${response_archive}" "${response_archive_sig}" "${changelog}" @@ -339,19 +338,19 @@ eof release) set -e - target_version=$($0 changelog-version) - target_branch=$($0 version-branch) + target_version=$($0 changelog-version "${run_as}") + target_branch=$($0 version-branch "${run_as}") printf "Beginning release process for %s\n" "${target_version}" # First check everything is sane - "$0" check-date - "$0" check-unittest - "$0" check-pycodestyle - "$0" check-shellcheck + "$0" check-date "${run_as}" + "$0" check-unittest "${run_as}" + "$0" check-pycodestyle "${run_as}" + "$0" check-shellcheck "${run_as}" # Generate version file to be included in packaging - "$0" target-version + "$0" target-version "${run_as}" # Ensure the git status is clean, else abort if ! git diff-index --name-only --exit-code HEAD ; then @@ -386,8 +385,8 @@ eof fi # Verify that after the merge everything works - "$0" check-date - "$0" check-unittest + "$0" check-date "${run_as}" + "$0" check-unittest "${run_as}" # Generate documentation (man and html) # First, clean old generated docs @@ -398,7 +397,7 @@ eof # Everything green, let's do the release # Tag the current commit - "$0" release-git-tag + "$0" release-git-tag "${run_as}" # Also merge back the version branch if [ "$masterbranch" = yes ]; then @@ -419,21 +418,21 @@ eof # fi # Create and publish package for pypi - "$0" pypi-release + "$0" pypi-release "${run_as}" if [ "$run_as" = "nico" ] then # Archlinux release is based on pypi - "$0" archlinux-release + "$0" archlinux-release "${run_as}" fi # sign git tag printf "Enter upstream repository authentication token: " read -r token - "$0" sign-git-release "${target_version}" "${token}" + "$0" sign-git-release "${run_as}" "${target_version}" "${token}" # Announce change on ML - "$0" ml-release "${target_version}" + "$0" ml-release "${run_as}" "${target_version}" cat << eof Manual steps post release: @@ -477,7 +476,7 @@ eof ;; check-pycodestyle) - "$0" pycodestyle + "$0" pycodestyle "${run_as}" printf "\\nPlease review pycodestyle report.\\n" while true do @@ -523,20 +522,20 @@ eof ;; shellcheck-gencodes) - "$0" shellcheck-local-gencodes - "$0" shellcheck-remote-gencodes + "$0" shellcheck-local-gencodes "${run_as}" + "$0" shellcheck-remote-gencodes "${run_as}" ;; shellcheck-types) - "$0" shellcheck-type-explorers - "$0" shellcheck-manifests - "$0" shellcheck-gencodes + "$0" shellcheck-type-explorers "${run_as}" + "$0" shellcheck-manifests "${run_as}" + "$0" shellcheck-gencodes "${run_as}" ;; shellcheck) - "$0" shellcheck-global-explorers - "$0" shellcheck-types - "$0" shellcheck-scripts + "$0" shellcheck-global-explorers "${run_as}" + "$0" shellcheck-types "${run_as}" + "$0" shellcheck-scripts "${run_as}" ;; shellcheck-type-files) @@ -544,8 +543,8 @@ eof ;; shellcheck-with-files) - "$0" shellcheck - "$0" shellcheck-type-files + "$0" shellcheck "${run_as}" + "$0" shellcheck-type-files "${run_as}" ;; shellcheck-build-helper) @@ -553,7 +552,7 @@ eof ;; check-shellcheck) - "$0" shellcheck + "$0" shellcheck "${run_as}" printf "\\nPlease review shellcheck report.\\n" while true do @@ -575,7 +574,7 @@ eof ;; version-branch) - "$0" changelog-version | cut -d. -f '1,2' + "$0" changelog-version "${run_as}" | cut -d. -f '1,2' ;; version) @@ -583,7 +582,7 @@ eof ;; target-version) - target_version=$($0 changelog-version) + target_version=$($0 changelog-version "${run_as}") printf "VERSION = \"%s\"\n" "${target_version}" > cdist/version.py ;; @@ -606,7 +605,7 @@ eof ;; distclean) - "$0" clean + "$0" clean "${run_as}" rm -f cdist/version.py ;; *) From 66cdbc5233407d5f926e1db3e4031ffe6ef3a8b2 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Thu, 9 May 2019 21:05:33 +0200 Subject: [PATCH 0379/1217] Simplify maintainer's helper script --- bin/build-helper | 145 +++++++++++++---------------------------------- 1 file changed, 39 insertions(+), 106 deletions(-) diff --git a/bin/build-helper b/bin/build-helper index 00fe4ec7..1698a678 100755 --- a/bin/build-helper +++ b/bin/build-helper @@ -23,9 +23,8 @@ # usage() { - printf "usage: %s TARGET RUN-AS + printf "usage: %s TARGET [TARGET-ARGS...] Available targets: - print-runas changelog-changes changelog-version check-date @@ -58,64 +57,29 @@ usage() { version target-version clean - distclean - Run as: - nico - darko - default, if empty string specified\n" "$1" + distclean\n" "$1" } basename="${0##*/}" -if [ $# -lt 2 ] +if [ $# -lt 1 ] then usage "${basename}" exit 1 fi option=$1; shift -run_as="$1"; shift - -case "$run_as" in - nico) - from_a=nico.schottelius - from_d=ungleich.ch - ml_name="Nico Schottelius" - ml_sig_name="Nico" - ;; - darko|'') - from_a=darko.poljak - from_d=gmail.com - ml_name="Darko Poljak" - ml_sig_name="Darko" - if [ -z "${run_as}" ] - then - run_as="darko" - fi - ;; - *) - printf "Unsupported RUN-AS value: '%s'.\n" "${run_as}" >&2 - usage "${basename}" - exit 1 - ;; -esac SHELLCHECKCMD="shellcheck -s sh -f gcc -x" # Skip SC2154 for variables starting with __ since such variables are cdist # environment variables. SHELLCHECK_SKIP=': __.*is referenced but not assigned.*\[SC2154\]' -to_a="cdist-configuration-management" -to_d="googlegroups.com" - # Change to checkout directory basedir="${0%/*}/../" cd "$basedir" case "$option" in - print-runas) - printf "run_as: '%s'\n" "$run_as" - ;; - changelog-changes) if [ "$#" -eq 1 ]; then start=$1 @@ -159,7 +123,7 @@ case "$option" in ;; check-unittest) - "$0" test "${run_as}" + "$0" test ;; ml-release) @@ -168,20 +132,10 @@ case "$option" in exit 1 fi - # Send mail only once - lock until new changelog things happened. - [ ! -f .lock-ml ] && touch .lock-ml - x=$(find 'docs' -name changelog -type f -newer .lock-ml) - [ -z "${x}" ] && exit 0 - version=$1; shift - to=${to_a}@${to_d} - from=${from_a}@${from_d} - ( cat << eof -From: ${ml_name} <$from> -To: cdist mailing list <$to> Subject: cdist $version has been released Hello .*, @@ -190,23 +144,11 @@ cdist $version has been released with the following changes: eof - "$0" changelog-changes "${run_as}" "$version" + "$0" changelog-changes "$version" cat << eof -Cheers, -${ml_sig_name} - --- -Automatisation at its best level. With cdist. eof ) > mailinglist.tmp - - if [ "$run_as" = "nico" ] - then - /usr/sbin/sendmail -f "$from" "$to" < mailinglist.tmp && rm -f mailinglist.tmp - fi - - touch .lock-ml ;; archlinux-release) @@ -225,7 +167,7 @@ eof pypi-release) # Ensure that pypi release has the right version - "$0" version "${run_as}" + "$0" version make docs-clean make docs @@ -233,7 +175,7 @@ eof ;; release-git-tag) - target_version=$($0 changelog-version "${run_as}") + target_version=$($0 changelog-version) if git rev-parse --verify "refs/tags/${target_version}" 2>/dev/null; then printf "Tag for %s exists, aborting\n" "${target_version}" exit 1 @@ -287,7 +229,7 @@ eof git archive --prefix="cdist-${tag}/" -o "${archivename}" "${tag}" \ || exit 1 # make sure target version is generated - "$0" target-version "${run_as}" + "$0" target-version tar -x -f "${archivename}" || exit 1 cp cdist/version.py "cdist-${tag}/cdist/version.py" || exit 1 tar -c -f "${archivename}" "cdist-${tag}/" || exit 1 @@ -317,7 +259,7 @@ eof | sed "${sed_cmd}") || exit 1 # make release - changelog=$("$0" changelog-changes "${run_as}" "$1" | sed 's/^[[:space:]]*//') + changelog=$("$0" changelog-changes "$1" | sed 's/^[[:space:]]*//') release_notes=$( printf "%s\n\n%s\n\n**Changelog**\n\n%s\n" \ "${response_archive}" "${response_archive_sig}" "${changelog}" @@ -338,19 +280,19 @@ eof release) set -e - target_version=$($0 changelog-version "${run_as}") - target_branch=$($0 version-branch "${run_as}") + target_version=$($0 changelog-version) + target_branch=$($0 version-branch) printf "Beginning release process for %s\n" "${target_version}" # First check everything is sane - "$0" check-date "${run_as}" - "$0" check-unittest "${run_as}" - "$0" check-pycodestyle "${run_as}" - "$0" check-shellcheck "${run_as}" + "$0" check-date + "$0" check-unittest + "$0" check-pycodestyle + "$0" check-shellcheck # Generate version file to be included in packaging - "$0" target-version "${run_as}" + "$0" target-version # Ensure the git status is clean, else abort if ! git diff-index --name-only --exit-code HEAD ; then @@ -385,8 +327,8 @@ eof fi # Verify that after the merge everything works - "$0" check-date "${run_as}" - "$0" check-unittest "${run_as}" + "$0" check-date + "$0" check-unittest # Generate documentation (man and html) # First, clean old generated docs @@ -397,7 +339,7 @@ eof # Everything green, let's do the release # Tag the current commit - "$0" release-git-tag "${run_as}" + "$0" release-git-tag # Also merge back the version branch if [ "$masterbranch" = yes ]; then @@ -406,37 +348,28 @@ eof fi # Publish git changes - # if you want to have mirror locally then uncomment this support - # if [ "$run_as" = "nico" ] - # then + # if you want to have mirror locally then uncomment this and comment below # git push --mirror - # else - # if we are not Nico :) then just push, no mirror git push # push also new branch and set up tracking git push -u origin "${target_branch}" # fi # Create and publish package for pypi - "$0" pypi-release "${run_as}" - - if [ "$run_as" = "nico" ] - then - # Archlinux release is based on pypi - "$0" archlinux-release "${run_as}" - fi + "$0" pypi-release # sign git tag printf "Enter upstream repository authentication token: " read -r token - "$0" sign-git-release "${run_as}" "${target_version}" "${token}" + "$0" sign-git-release "${target_version}" "${token}" # Announce change on ML - "$0" ml-release "${run_as}" "${target_version}" + "$0" ml-release "${target_version}" cat << eof Manual steps post release: - cdist-web + - send mail body generated in mailinglist.tmp and inform Dmitry for deb - twitter eof ;; @@ -476,7 +409,7 @@ eof ;; check-pycodestyle) - "$0" pycodestyle "${run_as}" + "$0" pycodestyle printf "\\nPlease review pycodestyle report.\\n" while true do @@ -522,20 +455,20 @@ eof ;; shellcheck-gencodes) - "$0" shellcheck-local-gencodes "${run_as}" - "$0" shellcheck-remote-gencodes "${run_as}" + "$0" shellcheck-local-gencodes + "$0" shellcheck-remote-gencodes ;; shellcheck-types) - "$0" shellcheck-type-explorers "${run_as}" - "$0" shellcheck-manifests "${run_as}" - "$0" shellcheck-gencodes "${run_as}" + "$0" shellcheck-type-explorers + "$0" shellcheck-manifests + "$0" shellcheck-gencodes ;; shellcheck) - "$0" shellcheck-global-explorers "${run_as}" - "$0" shellcheck-types "${run_as}" - "$0" shellcheck-scripts "${run_as}" + "$0" shellcheck-global-explorers + "$0" shellcheck-types + "$0" shellcheck-scripts ;; shellcheck-type-files) @@ -543,8 +476,8 @@ eof ;; shellcheck-with-files) - "$0" shellcheck "${run_as}" - "$0" shellcheck-type-files "${run_as}" + "$0" shellcheck + "$0" shellcheck-type-files ;; shellcheck-build-helper) @@ -552,7 +485,7 @@ eof ;; check-shellcheck) - "$0" shellcheck "${run_as}" + "$0" shellcheck printf "\\nPlease review shellcheck report.\\n" while true do @@ -574,7 +507,7 @@ eof ;; version-branch) - "$0" changelog-version "${run_as}" | cut -d. -f '1,2' + "$0" changelog-version | cut -d. -f '1,2' ;; version) @@ -582,7 +515,7 @@ eof ;; target-version) - target_version=$($0 changelog-version "${run_as}") + target_version=$($0 changelog-version) printf "VERSION = \"%s\"\n" "${target_version}" > cdist/version.py ;; @@ -605,7 +538,7 @@ eof ;; distclean) - "$0" clean "${run_as}" + "$0" clean rm -f cdist/version.py ;; *) From 569ae29955961cd2901ef6307efff152daa87473 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 14 May 2019 11:47:15 +0200 Subject: [PATCH 0380/1217] [__package_apk] fix / add support for @yrepo syntax --- cdist/conf/type/__package_apk/explorer/state | 4 ++++ docs/changelog | 3 +++ 2 files changed, 7 insertions(+) diff --git a/cdist/conf/type/__package_apk/explorer/state b/cdist/conf/type/__package_apk/explorer/state index 29ccf3a5..b477ca7c 100755 --- a/cdist/conf/type/__package_apk/explorer/state +++ b/cdist/conf/type/__package_apk/explorer/state @@ -27,6 +27,10 @@ else name="$__object_id" fi +# Remove the @.. repo tag for finding out whether it is installed +# f.i. pass@testing => pass +name="$(echo "$name" | sed 's/@.*//')" + if [ "$(apk list -I "$name")" ]; then echo present else diff --git a/docs/changelog b/docs/changelog index cd66c649..af8fef8f 100644 --- a/docs/changelog +++ b/docs/changelog @@ -1,6 +1,9 @@ Changelog --------- +next: + * Type __package_apk: Fix @repo handling in explorer (Nico Schottelius) + 5.0.1: 2019-05-09 * Documentation: Add 'Perils of CDIST_ORDER_DEPENDENCY' sub-section (Darko Poljak) * Build: Clean and separate end user targets into Makefile and maintainer targets into build-helper (Darko Poljak) From ca8bc959ed931734570b2c47d2d99c5b35c754a3 Mon Sep 17 00:00:00 2001 From: Ander Punnar Date: Tue, 14 May 2019 13:27:43 +0300 Subject: [PATCH 0381/1217] __acl: add todo note --- cdist/conf/type/__acl/explorer/checks | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cdist/conf/type/__acl/explorer/checks b/cdist/conf/type/__acl/explorer/checks index 2f3b9e6d..2aae13f6 100755 --- a/cdist/conf/type/__acl/explorer/checks +++ b/cdist/conf/type/__acl/explorer/checks @@ -18,6 +18,8 @@ # along with cdist. If not, see . # +# TODO check if filesystem has ACL turned on etc + [ ! -e "/$__object_id" ] && exit 0 for parameter in user group From 7dfc5bc4736b00e8622555169c65800bb7bf4600 Mon Sep 17 00:00:00 2001 From: Ander Punnar Date: Tue, 14 May 2019 13:41:32 +0300 Subject: [PATCH 0382/1217] __acl: we do not have to check here if file exist --- cdist/conf/type/__acl/explorer/checks | 2 -- 1 file changed, 2 deletions(-) diff --git a/cdist/conf/type/__acl/explorer/checks b/cdist/conf/type/__acl/explorer/checks index 2aae13f6..a2fcf44d 100755 --- a/cdist/conf/type/__acl/explorer/checks +++ b/cdist/conf/type/__acl/explorer/checks @@ -20,8 +20,6 @@ # TODO check if filesystem has ACL turned on etc -[ ! -e "/$__object_id" ] && exit 0 - for parameter in user group do if [ ! -f "$__object/parameter/$parameter" ] From 7a25ec00edb8458c8a11de3971024a9f99d1ba47 Mon Sep 17 00:00:00 2001 From: Ander Punnar Date: Tue, 14 May 2019 13:42:56 +0300 Subject: [PATCH 0383/1217] __acl: add TODO note about dry-run --- cdist/conf/type/__acl/gencode-remote | 1 + 1 file changed, 1 insertion(+) diff --git a/cdist/conf/type/__acl/gencode-remote b/cdist/conf/type/__acl/gencode-remote index ef903816..d47469c1 100755 --- a/cdist/conf/type/__acl/gencode-remote +++ b/cdist/conf/type/__acl/gencode-remote @@ -20,6 +20,7 @@ file_is="$( cat "$__object/explorer/file_is" )" +# TODO this check is not needed with dry-run [ "$file_is" = 'missing' ] && exit 0 os="$( cat "$__global/explorer/os" )" From 5f462d638017c22548176aeb7594098d009af21e Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 14 May 2019 16:49:33 +0200 Subject: [PATCH 0384/1217] ++alpine support --- cdist/conf/type/__postfix/manifest | 3 ++- cdist/conf/type/__postfix_postconf/explorer/value | 2 +- cdist/conf/type/__postfix_postconf/gencode-remote | 3 ++- docs/changelog | 2 ++ 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/cdist/conf/type/__postfix/manifest b/cdist/conf/type/__postfix/manifest index 1aea53a1..f3616979 100755 --- a/cdist/conf/type/__postfix/manifest +++ b/cdist/conf/type/__postfix/manifest @@ -1,6 +1,7 @@ #!/bin/sh -e # # 2012-2014 Steven Armstrong (steven-cdist at armstrong.cc) +# 2019 Nico Schottelius (nico-cdist at schottelius.org) # # This file is part of cdist. # @@ -22,7 +23,7 @@ os=$(cat "$__global/explorer/os") case "$os" in - ubuntu|debian|archlinux|suse|scientific|centos|devuan) + alpine|ubuntu|debian|archlinux|suse|scientific|centos|devuan) __package postfix --state present ;; *) diff --git a/cdist/conf/type/__postfix_postconf/explorer/value b/cdist/conf/type/__postfix_postconf/explorer/value index 17126c94..67dacad8 100755 --- a/cdist/conf/type/__postfix_postconf/explorer/value +++ b/cdist/conf/type/__postfix_postconf/explorer/value @@ -22,7 +22,7 @@ os=$("$__explorer/os") case "$os" in - ubuntu|debian|archlinux|suse|scientific|centos|devuan) + alpine|ubuntu|debian|archlinux|suse|scientific|centos|devuan) : ;; *) diff --git a/cdist/conf/type/__postfix_postconf/gencode-remote b/cdist/conf/type/__postfix_postconf/gencode-remote index 6df0da7f..279dddd4 100755 --- a/cdist/conf/type/__postfix_postconf/gencode-remote +++ b/cdist/conf/type/__postfix_postconf/gencode-remote @@ -1,6 +1,7 @@ #!/bin/sh -e # # 2012-2014 Steven Armstrong (steven-cdist at armstrong.cc) +# 2019 Nico Schottelius (nico-cdist at schottelius.org) # # This file is part of cdist. # @@ -21,7 +22,7 @@ os=$(cat "$__global/explorer/os") case "$os" in - ubuntu|debian|archlinux|suse|scientific|centos|devuan) + alpine|archlinux|centos|debian|devuan|suse|scientific|ubuntu) : ;; *) diff --git a/docs/changelog b/docs/changelog index af8fef8f..556fd42f 100644 --- a/docs/changelog +++ b/docs/changelog @@ -3,6 +3,8 @@ Changelog next: * Type __package_apk: Fix @repo handling in explorer (Nico Schottelius) + * Type __postfix: Add alpine support (Nico Schottelius) + * Type __postfix_postconf: Add alpine support (Nico Schottelius) 5.0.1: 2019-05-09 * Documentation: Add 'Perils of CDIST_ORDER_DEPENDENCY' sub-section (Darko Poljak) From ce52203ba3a84297599f9b0eeb66ae83f967859e Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 14 May 2019 17:10:26 +0200 Subject: [PATCH 0385/1217] __user add alpine support --- cdist/conf/type/__user/manifest | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 cdist/conf/type/__user/manifest diff --git a/cdist/conf/type/__user/manifest b/cdist/conf/type/__user/manifest new file mode 100644 index 00000000..8f10b38c --- /dev/null +++ b/cdist/conf/type/__user/manifest @@ -0,0 +1,32 @@ +#!/bin/sh -e +# +# 2019 Nico Schottelius (nico-cdist at schottelius.org) +# +# This file is part of cdist. +# +# cdist is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# cdist is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with cdist. If not, see . +# +# +# Manage users. + +os=$(cat "$__global/explorer/os") + +case "$os" in + alpine) + __package shadow + ;; + *) + : + ;; +esac From fe643b9092a61f5616624e10ebd0abdf0749823a Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Tue, 14 May 2019 17:10:46 +0200 Subject: [PATCH 0386/1217] ++doc --- docs/changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog b/docs/changelog index 556fd42f..41b0088f 100644 --- a/docs/changelog +++ b/docs/changelog @@ -5,6 +5,7 @@ next: * Type __package_apk: Fix @repo handling in explorer (Nico Schottelius) * Type __postfix: Add alpine support (Nico Schottelius) * Type __postfix_postconf: Add alpine support (Nico Schottelius) + * Type __user: Add alpine support (Nico Schottelius) 5.0.1: 2019-05-09 * Documentation: Add 'Perils of CDIST_ORDER_DEPENDENCY' sub-section (Darko Poljak) From 69622b0fa5f0d29eaf6d4357a0e84f8a6f6b101b Mon Sep 17 00:00:00 2001 From: Ander Punnar Date: Thu, 16 May 2019 21:58:47 +0200 Subject: [PATCH 0387/1217] set __cdist_dry_run env var if dry-run --- cdist/config.py | 9 ++++++--- cdist/core/code.py | 5 ++++- cdist/core/explorer.py | 6 +++++- cdist/core/manifest.py | 5 ++++- docs/src/cdist-reference.rst.sh | 4 ++++ docs/src/cdist-type.rst | 9 +++++++++ 6 files changed, 32 insertions(+), 6 deletions(-) diff --git a/cdist/config.py b/cdist/config.py index bc05a28c..30117382 100644 --- a/cdist/config.py +++ b/cdist/config.py @@ -104,9 +104,12 @@ class Config(object): self.remove_remote_files_dirs = remove_remote_files_dirs self.explorer = core.Explorer(self.local.target_host, self.local, - self.remote, jobs=self.jobs) - self.manifest = core.Manifest(self.local.target_host, self.local) - self.code = core.Code(self.local.target_host, self.local, self.remote) + self.remote, jobs=self.jobs, + dry_run=self.dry_run) + self.manifest = core.Manifest(self.local.target_host, self.local, + dry_run=self.dry_run) + self.code = core.Code(self.local.target_host, self.local, self.remote, + dry_run=self.dry_run) def _init_files_dirs(self): """Prepare files and directories for the run""" diff --git a/cdist/core/code.py b/cdist/core/code.py index 670029ed..1550880a 100644 --- a/cdist/core/code.py +++ b/cdist/core/code.py @@ -97,7 +97,7 @@ class Code(object): """ # target_host is tuple (target_host, target_hostname, target_fqdn) - def __init__(self, target_host, local, remote): + def __init__(self, target_host, local, remote, dry_run=False): self.target_host = target_host self.local = local self.remote = remote @@ -113,6 +113,9 @@ class Code(object): local.log), } + if dry_run: + self.env['__cdist_dry_run'] = '1' + def _run_gencode(self, cdist_object, which): cdist_type = cdist_object.cdist_type script = os.path.join(self.local.type_path, diff --git a/cdist/core/explorer.py b/cdist/core/explorer.py index acceacac..353d7681 100644 --- a/cdist/core/explorer.py +++ b/cdist/core/explorer.py @@ -67,7 +67,7 @@ class Explorer(object): """Executes cdist explorers. """ - def __init__(self, target_host, local, remote, jobs=None): + def __init__(self, target_host, local, remote, jobs=None, dry_run=False): self.target_host = target_host self._open_logger() @@ -84,6 +84,10 @@ class Explorer(object): '__cdist_log_level_name': util.log_level_name_env_var_val( self.log), } + + if dry_run: + self.env['__cdist_dry_run'] = '1' + self._type_explorers_transferred = [] self.jobs = jobs diff --git a/cdist/core/manifest.py b/cdist/core/manifest.py index 938ad8b8..07af0ef8 100644 --- a/cdist/core/manifest.py +++ b/cdist/core/manifest.py @@ -96,7 +96,7 @@ class Manifest(object): """Executes cdist manifests. """ - def __init__(self, target_host, local): + def __init__(self, target_host, local, dry_run=False): self.target_host = target_host self.local = local @@ -117,6 +117,9 @@ class Manifest(object): self.log), } + if dry_run: + self.env['__cdist_dry_run'] = '1' + def _open_logger(self): self.log = logging.getLogger(self.target_host[0]) diff --git a/docs/src/cdist-reference.rst.sh b/docs/src/cdist-reference.rst.sh index 2c9c7b40..f4a37816 100755 --- a/docs/src/cdist-reference.rst.sh +++ b/docs/src/cdist-reference.rst.sh @@ -219,6 +219,10 @@ __cdist_log_level, __cdist_log_level_name | TRACE | 5 | +----------------+-----------------+ + Available for: initial manifest, explorer, type manifest, type explorer, + type gencode. +__cdist_dry_run + Is set only when doing dry run (``-n`` flag). Available for: initial manifest, explorer, type manifest, type explorer, type gencode. __explorer diff --git a/docs/src/cdist-type.rst b/docs/src/cdist-type.rst index 7c0dab8d..7e5e39ef 100644 --- a/docs/src/cdist-type.rst +++ b/docs/src/cdist-type.rst @@ -371,6 +371,15 @@ It is available for initial manifest, explorer, type manifest, type explorer, type gencode. +Detecting dry run +----------------- + +If ``$__cdist_dry_run`` environment variable is set, then it's dry run. + +It is available for initial manifest, explorer, type manifest, +type explorer, type gencode. + + Hints for typewriters ---------------------- It must be assumed that the target is pretty dumb and thus does not have high From 7195b594f302be7742eaa84e1daa0bdc71bbc012 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Thu, 16 May 2019 21:59:30 +0200 Subject: [PATCH 0388/1217] ++changelog --- docs/changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog b/docs/changelog index 41b0088f..47b4b14b 100644 --- a/docs/changelog +++ b/docs/changelog @@ -6,6 +6,7 @@ next: * Type __postfix: Add alpine support (Nico Schottelius) * Type __postfix_postconf: Add alpine support (Nico Schottelius) * Type __user: Add alpine support (Nico Schottelius) + * Core: Set __cdist_dry_run env var (Ander Punnar) 5.0.1: 2019-05-09 * Documentation: Add 'Perils of CDIST_ORDER_DEPENDENCY' sub-section (Darko Poljak) From d604a9db7a080c1cc3782f6e488a2ed6a508fd02 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Fri, 17 May 2019 13:03:46 +0200 Subject: [PATCH 0389/1217] Fix pycodestyle --- cdist/inventory.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cdist/inventory.py b/cdist/inventory.py index 7da306fa..138a2034 100644 --- a/cdist/inventory.py +++ b/cdist/inventory.py @@ -315,7 +315,7 @@ class InventoryHost(Inventory): hostpath = self._host_path(host) self.log.trace("hostpath: {}".format(hostpath)) if self.action == "add" and not os.path.exists(hostpath): - self._new_hostpath(hostpath) + self._new_hostpath(hostpath) else: if not os.path.isfile(hostpath): raise cdist.Error(("Host path \'{}\' is" From 4a5425a95e8b5fce1d2e49064301a4e173f8d003 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Fri, 17 May 2019 13:02:05 +0200 Subject: [PATCH 0390/1217] Release 5.0.2 --- docs/changelog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/changelog b/docs/changelog index 47b4b14b..515f7b69 100644 --- a/docs/changelog +++ b/docs/changelog @@ -1,7 +1,7 @@ Changelog --------- -next: +5.0.2: 2019-05-17 * Type __package_apk: Fix @repo handling in explorer (Nico Schottelius) * Type __postfix: Add alpine support (Nico Schottelius) * Type __postfix_postconf: Add alpine support (Nico Schottelius) From 21a16f5584a08b8f155c01d2cbb78a003fc5725b Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 18 May 2019 23:46:09 +0200 Subject: [PATCH 0391/1217] consul, changelog, consul agent => alpine --- .../type/__consul/files/versions/1.5.0/cksum | 1 + .../type/__consul/files/versions/1.5.0/source | 1 + cdist/conf/type/__consul/gencode-remote | 2 +- cdist/conf/type/__consul/manifest | 3 +- .../__consul_agent/files/consul.sys-openrc | 38 +++++++++++++++ cdist/conf/type/__consul_agent/manifest | 47 +++++++++---------- docs/changelog | 5 ++ 7 files changed, 71 insertions(+), 26 deletions(-) create mode 100644 cdist/conf/type/__consul/files/versions/1.5.0/cksum create mode 100644 cdist/conf/type/__consul/files/versions/1.5.0/source create mode 100644 cdist/conf/type/__consul_agent/files/consul.sys-openrc diff --git a/cdist/conf/type/__consul/files/versions/1.5.0/cksum b/cdist/conf/type/__consul/files/versions/1.5.0/cksum new file mode 100644 index 00000000..efca9caa --- /dev/null +++ b/cdist/conf/type/__consul/files/versions/1.5.0/cksum @@ -0,0 +1 @@ +886614099 103959898 consul diff --git a/cdist/conf/type/__consul/files/versions/1.5.0/source b/cdist/conf/type/__consul/files/versions/1.5.0/source new file mode 100644 index 00000000..cafa9248 --- /dev/null +++ b/cdist/conf/type/__consul/files/versions/1.5.0/source @@ -0,0 +1 @@ +https://releases.hashicorp.com/consul/1.5.0/consul_1.5.0_linux_amd64.zip diff --git a/cdist/conf/type/__consul/gencode-remote b/cdist/conf/type/__consul/gencode-remote index 1d2244ea..2a21054f 100755 --- a/cdist/conf/type/__consul/gencode-remote +++ b/cdist/conf/type/__consul/gencode-remote @@ -42,7 +42,7 @@ source_file_name="${source##*/}" cksum_should=$(cut -d' ' -f1,2 "$version_dir/cksum") cat << eof - tmpdir=\$(mktemp -d --tmpdir="/tmp" "${__type##*/}.XXXXXXXXXX") + tmpdir=\$(mktemp -d -p /tmp "${__type##*/}.XXXXXXXXXX") curl -s -L "$source" > "\$tmpdir/$source_file_name" unzip -p "\$tmpdir/$source_file_name" > "${destination}.tmp" rm -rf "\$tmpdir" diff --git a/cdist/conf/type/__consul/manifest b/cdist/conf/type/__consul/manifest index 0dd50f53..156eb667 100755 --- a/cdist/conf/type/__consul/manifest +++ b/cdist/conf/type/__consul/manifest @@ -24,7 +24,7 @@ os=$(cat "$__global/explorer/os") case "$os" in - scientific|centos|redhat|ubuntu|debian|devuan|archlinux|gentoo) + alpine|scientific|centos|redhat|ubuntu|debian|devuan|archlinux|gentoo) # any linux should work : ;; @@ -47,6 +47,7 @@ fi if [ -f "$__object/parameter/direct" ]; then __package unzip + __package curl else __staged_file /usr/local/bin/consul \ --source "$(cat "$version_dir/source")" \ diff --git a/cdist/conf/type/__consul_agent/files/consul.sys-openrc b/cdist/conf/type/__consul_agent/files/consul.sys-openrc new file mode 100644 index 00000000..1dbe9375 --- /dev/null +++ b/cdist/conf/type/__consul_agent/files/consul.sys-openrc @@ -0,0 +1,38 @@ +#!/sbin/openrc-run +# 2019 Nico Schottelius (nico-cdist at schottelius.org) + +description="consul agent" + +pidfile="${CONSUL_PIDFILE:-"/var/run/$RC_SVCNAME/pidfile"}" +command="${CONSUL_BINARY:-"/usr/local/bin/consul"}" + + +checkconfig() { + if [ ! -d /var/run/consul ] ; then + mkdir -p /var/run/consul || return 1 + chown consul:consul /var/run/$NAME || return 1 + chmod 2770 /var/run/$NAME || return 1 + fi +} + +start() { + need net + + start-stop-daemon --start --quiet --oknodo \ + --pidfile "$pidfile" --background \ + --exec $command -- agent -pid-file="$pidfile" -config-dir /etc/consul/conf.d +} +start_pre() { + checkconfig +} + +stop() { + if [ "${RC_CMD}" = "restart" ] ; then + checkconfig || return 1 + fi + + ebegin "Stopping $RC_SVCNAME" + start-stop-daemon --stop --exec "$command" \ + --pidfile "$pidfile" --quiet + eend $? +} diff --git a/cdist/conf/type/__consul_agent/manifest b/cdist/conf/type/__consul_agent/manifest index c48bfe85..a88d26ed 100755 --- a/cdist/conf/type/__consul_agent/manifest +++ b/cdist/conf/type/__consul_agent/manifest @@ -1,7 +1,7 @@ #!/bin/sh -e # # 2015 Steven Armstrong (steven-cdist at armstrong.cc) -# 2015 Nico Schottelius (nico-cdist at schottelius.org) +# 2015-2019 Nico Schottelius (nico-cdist at schottelius.org) # # This file is part of cdist. # @@ -23,7 +23,7 @@ os=$(cat "$__global/explorer/os") case "$os" in - scientific|centos|debian|devuan|redhat|ubuntu) + alpine|scientific|centos|debian|devuan|redhat|ubuntu) # whitelist safeguard : ;; @@ -181,22 +181,25 @@ init_upstart() # Install init script to start on boot case "$os" in - centos|redhat) - os_version="$(sed 's/[^0-9.]//g' "$__global/explorer/os_version")" - major_version="${os_version%%.*}" - case "$major_version" in - [456]) - init_sysvinit redhat - ;; - 7) - init_systemd - ;; - *) - echo "Unsupported CentOS/Redhat version: $os_version" >&2 - exit 1 - ;; - esac - ;; + alpine|devuan) + init_sysvinit debian + ;; + centos|redhat) + os_version="$(sed 's/[^0-9.]//g' "$__global/explorer/os_version")" + major_version="${os_version%%.*}" + case "$major_version" in + [456]) + init_sysvinit redhat + ;; + 7) + init_systemd + ;; + *) + echo "Unsupported CentOS/Redhat version: $os_version" >&2 + exit 1 + ;; + esac + ;; debian) os_version=$(cat "$__global/explorer/os_version") @@ -214,13 +217,9 @@ case "$os" in exit 1 ;; esac - ;; - - devuan) - init_sysvinit debian - ;; + ;; ubuntu) init_upstart - ;; + ;; esac diff --git a/docs/changelog b/docs/changelog index 515f7b69..b8071ffe 100644 --- a/docs/changelog +++ b/docs/changelog @@ -1,6 +1,11 @@ Changelog --------- +next: + * Type __consul: Add alpine support (Nico Schottelius) + * Type __consul: Add version 1.5.0 (Nico Schottelius) + * Type __consul_agent: Add alpine support (Nico Schottelius) + 5.0.2: 2019-05-17 * Type __package_apk: Fix @repo handling in explorer (Nico Schottelius) * Type __postfix: Add alpine support (Nico Schottelius) From 03f8c3aaed3d106792a05e9e24e14b86f7e0414c Mon Sep 17 00:00:00 2001 From: Ander Punnar Date: Sun, 19 May 2019 23:22:02 +0300 Subject: [PATCH 0392/1217] __acl: don't exit on missing file when dry run --- cdist/conf/type/__acl/gencode-remote | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cdist/conf/type/__acl/gencode-remote b/cdist/conf/type/__acl/gencode-remote index d47469c1..36eca3f8 100755 --- a/cdist/conf/type/__acl/gencode-remote +++ b/cdist/conf/type/__acl/gencode-remote @@ -20,8 +20,7 @@ file_is="$( cat "$__object/explorer/file_is" )" -# TODO this check is not needed with dry-run -[ "$file_is" = 'missing' ] && exit 0 +[ "$file_is" = 'missing' ] && [ -z "$__cdist_dry_run" ] && exit 0 os="$( cat "$__global/explorer/os" )" From 02e10b1ffd1d1fa28586caf234f5e007dfe7e606 Mon Sep 17 00:00:00 2001 From: Ander Punnar Date: Sun, 19 May 2019 23:27:58 +0300 Subject: [PATCH 0393/1217] __acl: fix SC1117 --- cdist/conf/type/__acl/gencode-remote | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cdist/conf/type/__acl/gencode-remote b/cdist/conf/type/__acl/gencode-remote index 36eca3f8..f5b0474f 100755 --- a/cdist/conf/type/__acl/gencode-remote +++ b/cdist/conf/type/__acl/gencode-remote @@ -48,7 +48,7 @@ do then [ "$file_is" = 'directory' ] && rep=x || rep=- - acl="$( echo "$acl" | sed "s/\(.*\)X/\1$rep/" )" + acl="$( echo "$acl" | sed "s/\\(.*\\)X/\\1$rep/" )" fi echo "$parameter" | grep -Eq '(mask|other)' && sep=:: || sep=: From e30d76014accf5e1f0860f504c287c5ed025da9c Mon Sep 17 00:00:00 2001 From: Ander Punnar Date: Sun, 19 May 2019 23:44:20 +0300 Subject: [PATCH 0394/1217] __acl: update man --- cdist/conf/type/__acl/man.rst | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/cdist/conf/type/__acl/man.rst b/cdist/conf/type/__acl/man.rst index e6784c87..d066aae5 100644 --- a/cdist/conf/type/__acl/man.rst +++ b/cdist/conf/type/__acl/man.rst @@ -10,9 +10,7 @@ DESCRIPTION ----------- ACL must be defined as 3-symbol combination, using ``r``, ``w``, ``x`` and ``-``. -Fully supported and tested on Linux, partial support for FreeBSD. - -OpenBSD, NetBSD and Solaris support is not possible. +Fully supported and tested on Linux (ext4 filesystem), partial support for FreeBSD. See ``setfacl`` and ``acl`` manpages for more details. From 34eec3c214b1fbd95246e9243196173b55aee41a Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Sun, 19 May 2019 13:40:24 +0200 Subject: [PATCH 0395/1217] Add cdist-new-type helper scrpt --- bin/build-helper | 2 +- docs/changelog | 1 + docs/src/cdist-troubleshooting.rst | 3 +- docs/src/cdist-type.rst | 3 + docs/src/index.rst | 1 + docs/src/man1/cdist-new-type.rst | 74 ++++++++++++++ scripts/cdist-new-type | 159 +++++++++++++++++++++++++++++ setup.py | 2 +- 8 files changed, 242 insertions(+), 3 deletions(-) create mode 100644 docs/src/man1/cdist-new-type.rst create mode 100755 scripts/cdist-new-type diff --git a/bin/build-helper b/bin/build-helper index 1698a678..9a776491 100755 --- a/bin/build-helper +++ b/bin/build-helper @@ -451,7 +451,7 @@ eof ;; shellcheck-scripts) - ${SHELLCHECKCMD} scripts/cdist-dump || exit 0 + ${SHELLCHECKCMD} scripts/cdist-dump scripts/cdist-new-type || exit 0 ;; shellcheck-gencodes) diff --git a/docs/changelog b/docs/changelog index b8071ffe..acf462f2 100644 --- a/docs/changelog +++ b/docs/changelog @@ -5,6 +5,7 @@ next: * Type __consul: Add alpine support (Nico Schottelius) * Type __consul: Add version 1.5.0 (Nico Schottelius) * Type __consul_agent: Add alpine support (Nico Schottelius) + * New helper script: cdist-new-type (Steven Armstrong, Darko Poljak) 5.0.2: 2019-05-17 * Type __package_apk: Fix @repo handling in explorer (Nico Schottelius) diff --git a/docs/src/cdist-troubleshooting.rst b/docs/src/cdist-troubleshooting.rst index 6b7fb4af..e639aafd 100644 --- a/docs/src/cdist-troubleshooting.rst +++ b/docs/src/cdist-troubleshooting.rst @@ -47,7 +47,8 @@ you write to use the -e flag: Using debug dump helper script ------------------------------ Since cdist stores data to local cache that can be used for debugging there -is a helper script that dumps data from local cache. +is a helper script that dumps data from local cache, +`cdist-dump `_. For more info see: diff --git a/docs/src/cdist-type.rst b/docs/src/cdist-type.rst index 7e5e39ef..880df819 100644 --- a/docs/src/cdist-type.rst +++ b/docs/src/cdist-type.rst @@ -93,6 +93,9 @@ they are written in shell so they are executed using '/bin/sh -e' or 'CDIST_LOCA For executable shell code it is suggested that shebang is '#!/bin/sh -e'. +For creating type skeleton you can use helper script +`cdist-new-type `_. + Defining parameters ------------------- diff --git a/docs/src/index.rst b/docs/src/index.rst index 95e44d52..6cbd938a 100644 --- a/docs/src/index.rst +++ b/docs/src/index.rst @@ -22,6 +22,7 @@ is being used in small up to enterprise grade environments. cdist-real-world man1/cdist man1/cdist-dump + man1/cdist-new-type cdist-bootstrap cdist-configuration cdist-manifest diff --git a/docs/src/man1/cdist-new-type.rst b/docs/src/man1/cdist-new-type.rst new file mode 100644 index 00000000..f1a8b992 --- /dev/null +++ b/docs/src/man1/cdist-new-type.rst @@ -0,0 +1,74 @@ +cdist-new-type(1) +================= + +NAME +---- +cdist-new-type - Create new type skeleton + + +SYNOPSIS +-------- + +:: + + cdist-new-type TYPE-NAME AUTHOR-NAME AUTHOR-EMAIL [TYPE-BASE-PATH] + + + +DESCRIPTION +----------- +cdist-new-type is a helper script that creates new type skeleton. +It is then up to the type author to finish the type. + +It creates skeletons for the following files: + +* man.rst +* manifest +* gencode-remote. + +Upon creation it prints the path to the newly created type directory. + + +ARGUMENTS +--------- +**TYPE-NAME** + Name of the new type. + +**AUTHOR-NAME** + Type author's full name. + +**AUTHOR-NAME** + Type author's email. + +**TYPE-BASE-PATH** + Path to the base directory of the type. If not set it defaults + to '$PWD/type'. + + +EXAMPLES +-------- + +.. code-block:: sh + + # Create new type __foo in ~/.cdist directory. + $ cd ~/.cdist + $ cdist-new-type '__foo' 'Foo Bar' 'foo.bar at foobar.org' + /home/foo/.cdist/type/__foo + + +SEE ALSO +-------- +:strong:`cdist`\ (1) + + +AUTHORS +------- + +| Steven Armstrong +| Darko Poljak + + +COPYING +------- +Copyright \(C) 2019 Steven Armstrong, Darko Poljak. Free use of this software is +granted under the terms of the GNU General Public License v3 or later (GPLv3+). diff --git a/scripts/cdist-new-type b/scripts/cdist-new-type new file mode 100755 index 00000000..79dcfd90 --- /dev/null +++ b/scripts/cdist-new-type @@ -0,0 +1,159 @@ +#!/bin/sh + +basename="${0##*/}" + +if [ $# -lt 3 ] +then + printf "usage: %s TYPE-NAME AUTHOR-NAME AUTHOR-EMAIL [TYPE-BASE-PATH] + TYPE-NAME Name of the type. + AUTHOR-NAME Type author's full name. + AUTHOR-EMAIL Type author's email. + TYPE-BASE-PATH Path to the base directory of the type. If not set it defaults + to '\$PWD/type'.\n" "${basename}" + exit 1 +fi + +type_name="$1" +shift +author_name="$1" +shift +author_email="$1" +shift + +if [ $# -ge 1 ] +then + type_base_path="$1" + shift +else + #type_base_path=~/.cdist/type + type_base_path="$PWD/type" +fi + +error() { + printf "%s\n" "$*" >&2 +} + +die() { + error "$@" + exit 1 +} + +cd "$type_base_path" || die "Could not change to type directory: $type_base_path. +You have to specify type base path or run me from within a cdist conf directory, +e.g. ~/.cdist." + +year=$(date +%Y) +copyright="# $year $author_name ($author_email)" + +license="# This file is part of cdist. +# +# cdist is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# cdist is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with cdist. If not, see . +# +" + +set -e + +mkdir "$type_name" +cd "$type_name" + +### man page +header="cdist-type${type_name}(7)" +header_length="${#header}" +cat >> man.rst << DONE +$header +$(while [ "${header_length}" -gt 0 ]; do printf "="; header_length=$((header_length - 1)); done; printf "\n";) + +NAME +---- +cdist-type${type_name} - TODO + + +DESCRIPTION +----------- +This space intentionally left blank. + + +REQUIRED PARAMETERS +------------------- +None. + + +OPTIONAL PARAMETERS +------------------- +None. + + +BOOLEAN PARAMETERS +------------------ +None. + + +EXAMPLES +-------- + +.. code-block:: sh + + # TODO + ${type_name} + + +SEE ALSO +-------- +:strong:\`TODO\`\\ (7) + + +AUTHORS +------- +$author_name <$author_email> + + +COPYING +------- +Copyright \(C) $year $author_name. 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. +DONE + +### manifest +cat >> manifest << DONE +#!/bin/sh -e +# +${copyright} +# +${license} + +os=\$(cat "\$__global/explorer/os") + +case "\$os" in + *) + printf "Your operating system (%s) is currently not supported by this type (%s)\n" "\$os" "\${__type##*/}" >&2 + printf "Please contribute an implementation for it if you can.\n" >&2 + exit 1 + ;; +esac +DONE +chmod +x manifest + +# gencode-remote +cat >> gencode-remote << DONE +#!/bin/sh -e +# +${copyright} +# +${license} +DONE +chmod +x gencode-remote + +printf "%s/%s\n" "$type_base_path" "$type_name" diff --git a/setup.py b/setup.py index 5f14a2f4..ae651125 100644 --- a/setup.py +++ b/setup.py @@ -36,7 +36,7 @@ setup( name="cdist", packages=["cdist", "cdist.core", "cdist.exec", "cdist.util", ], package_data={'cdist': package_data}, - scripts=["scripts/cdist", "scripts/cdist-dump"], + scripts=["scripts/cdist", "scripts/cdist-dump", "scripts/cdist-new-type"], version=cdist.version.VERSION, description="A Usable Configuration Management System", author="Nico Schottelius", From 4949af894e917ac57fb5365c7ea482770bb1c3ba Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Mon, 20 May 2019 18:50:25 +0200 Subject: [PATCH 0396/1217] Add type deprecation support. --- cdist/config.py | 11 ++++++++ cdist/core/cdist_type.py | 11 ++++++++ cdist/test/cdist_type/__init__.py | 10 ++++++++ .../fixtures/__deprecated/deprecated | 0 docs/changelog | 1 + docs/src/cdist-type.rst | 25 +++++++++++++++++++ 6 files changed, 58 insertions(+) create mode 100644 cdist/test/cdist_type/fixtures/__deprecated/deprecated diff --git a/cdist/config.py b/cdist/config.py index 30117382..1a0ab4d5 100644 --- a/cdist/config.py +++ b/cdist/config.py @@ -758,8 +758,19 @@ class Config(object): ("The requirements of the following objects could not be " "resolved:\n%s") % ("\n".join(info_string))) + def _handle_deprecation(self, cdist_object): + cdist_type = cdist_object.cdist_type + deprecated = cdist_type.deprecated + if deprecated is not None: + if deprecated: + self.log.warning("Type %s is deprecated: %s", cdist_type.name, + deprecated) + else: + self.log.warning("Type %s is deprecated.", cdist_type.name) + def object_prepare(self, cdist_object, transfer_type_explorers=True): """Prepare object: Run type explorer + manifest""" + self._handle_deprecation(cdist_object) self.log.verbose("Preparing object {}".format(cdist_object.name)) self.log.verbose( "Running manifest and explorers for " + cdist_object.name) diff --git a/cdist/core/cdist_type.py b/cdist/core/cdist_type.py index 99e40e70..7cabd72f 100644 --- a/cdist/core/cdist_type.py +++ b/cdist/core/cdist_type.py @@ -133,6 +133,17 @@ class CdistType(object): cannot run in parallel.""" return os.path.isfile(os.path.join(self.absolute_path, "nonparallel")) + @property + def deprecated(self): + """Get type deprecation message. If message is None then type + is not deprecated.""" + deprecated_path = os.path.join(self.absolute_path, "deprecated") + try: + with open(deprecated_path, 'r') as f: + return f.read() + except FileNotFoundError: + return None + @property def explorers(self): """Return a list of available explorers""" diff --git a/cdist/test/cdist_type/__init__.py b/cdist/test/cdist_type/__init__.py index ca961170..ac84d874 100644 --- a/cdist/test/cdist_type/__init__.py +++ b/cdist/test/cdist_type/__init__.py @@ -123,6 +123,16 @@ class TypeTestCase(test.CdistTestCase): cdist_type = core.CdistType(base_path, '__not_nonparallel') self.assertFalse(cdist_type.is_nonparallel) + def test_deprecated(self): + base_path = fixtures + cdist_type = core.CdistType(base_path, '__deprecated') + self.assertIsNotNone(cdist_type.deprecated) + + def test_not_deprecated(self): + base_path = fixtures + cdist_type = core.CdistType(base_path, '__not_deprecated') + self.assertIsNone(cdist_type.deprecated) + def test_install_is_install(self): base_path = fixtures cdist_type = core.CdistType(base_path, '__install') diff --git a/cdist/test/cdist_type/fixtures/__deprecated/deprecated b/cdist/test/cdist_type/fixtures/__deprecated/deprecated new file mode 100644 index 00000000..e69de29b diff --git a/docs/changelog b/docs/changelog index acf462f2..ba092840 100644 --- a/docs/changelog +++ b/docs/changelog @@ -6,6 +6,7 @@ next: * Type __consul: Add version 1.5.0 (Nico Schottelius) * Type __consul_agent: Add alpine support (Nico Schottelius) * New helper script: cdist-new-type (Steven Armstrong, Darko Poljak) + * Core: Add support for deprecated type marker (Darko Poljak) 5.0.2: 2019-05-17 * Type __package_apk: Fix @repo handling in explorer (Nico Schottelius) diff --git a/docs/src/cdist-type.rst b/docs/src/cdist-type.rst index 880df819..dfad6fa0 100644 --- a/docs/src/cdist-type.rst +++ b/docs/src/cdist-type.rst @@ -71,6 +71,31 @@ when using -j option. Example of such a type is __package_dpkg type where dpkg i prevents to be run in more than one instance. +Deprecated types +----------------- +If a type is flagged with 'deprecated' marker then it is considered deprecated. +Upon it's usage cdist writes warning line. If 'deprecated' marker has content +then this content is printed as a deprecation messages, e.g.: + +.. code-block:: sh + + $ ls -l deprecated + -rw-r--r-- 1 darko darko 71 May 20 18:30 deprecated + $ cat deprecated + This type is deprecated. It will be removed in the next minor release. + $ echo '__foo foo' | ./bin/cdist config -i - 185.203.112.26 + WARNING: 185.203.112.26: Type __foo is deprecated: This type is deprecated. It will be removed in the next minor release. + +If 'deprecated' marker has no content then general message is printed, e.g.: + +.. code-block:: sh + + $ ls -l deprecated + -rw-r--r-- 1 darko darko 0 May 20 18:36 deprecated + $ echo '__bar foo' | ./bin/cdist config -i - 185.203.112.26 + WARNING: 185.203.112.26: Type __bar is deprecated. + + How to write a new type ----------------------- A type consists of From c58ae44409b7170ee44187eb3622612baf91ac51 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Wed, 22 May 2019 18:34:31 +0200 Subject: [PATCH 0397/1217] Release 5.1.0 --- docs/changelog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/changelog b/docs/changelog index ba092840..86ac6c9e 100644 --- a/docs/changelog +++ b/docs/changelog @@ -1,7 +1,7 @@ Changelog --------- -next: +5.1.0: 2019-05-22 * Type __consul: Add alpine support (Nico Schottelius) * Type __consul: Add version 1.5.0 (Nico Schottelius) * Type __consul_agent: Add alpine support (Nico Schottelius) From 1d57305d359fd773a540adcec8116d785f51e9db Mon Sep 17 00:00:00 2001 From: Ander Punnar Date: Sat, 25 May 2019 15:58:39 +0200 Subject: [PATCH 0398/1217] Use gpg key, fallback to deprecated apt-key Fixes #762 --- cdist/conf/type/__apt_key/explorer/state | 18 ++++- cdist/conf/type/__apt_key/gencode-remote | 76 ++++++++++++++++++- cdist/conf/type/__apt_key/man.rst | 17 ++++- cdist/conf/type/__apt_key/manifest | 8 ++ .../type/__apt_key/parameter/default/keydir | 1 + cdist/conf/type/__apt_key/parameter/optional | 2 + 6 files changed, 114 insertions(+), 8 deletions(-) create mode 100755 cdist/conf/type/__apt_key/manifest create mode 100644 cdist/conf/type/__apt_key/parameter/default/keydir diff --git a/cdist/conf/type/__apt_key/explorer/state b/cdist/conf/type/__apt_key/explorer/state index f7940741..38f1bd3c 100755 --- a/cdist/conf/type/__apt_key/explorer/state +++ b/cdist/conf/type/__apt_key/explorer/state @@ -27,6 +27,18 @@ else keyid="$__object_id" fi -apt-key export "$keyid" | head -n 1 | grep -Fqe "BEGIN PGP PUBLIC KEY BLOCK" \ - && echo present \ - || echo absent +keydir="$(cat "$__object/parameter/keydir")" +keyfile="$keydir/$__object_id.gpg" + +if [ -d "$keydir" ] +then + if [ -f "$keyfile" ] + then echo present + else echo absent + fi +else + # fallback to deprecated apt-key + apt-key export "$keyid" | head -n 1 | grep -Fqe "BEGIN PGP PUBLIC KEY BLOCK" \ + && echo present \ + || echo absent +fi diff --git a/cdist/conf/type/__apt_key/gencode-remote b/cdist/conf/type/__apt_key/gencode-remote index 9c4fa00c..47c8bb49 100755 --- a/cdist/conf/type/__apt_key/gencode-remote +++ b/cdist/conf/type/__apt_key/gencode-remote @@ -31,12 +31,84 @@ if [ "$state_should" = "$state_is" ]; then exit 0 fi +keydir="$(cat "$__object/parameter/keydir")" +keyfile="$keydir/$__object_id.gpg" + case "$state_should" in present) keyserver="$(cat "$__object/parameter/keyserver")" - echo "apt-key adv --keyserver \"$keyserver\" --recv-keys \"$keyid\"" + + if [ -f "$__object/parameter/uri" ]; then + uri="$(cat "$__object/parameter/uri")" + + if [ -d "$keydir" ]; then + cat << EOF + +curl -s -L \\ + -o "$keyfile" \\ + "$uri" + +if grep -Fq 'BEGIN PGP PUBLIC KEY BLOCK' \\ + "$keyfile" +then + cat "$keyfile" \\ + | gpg --export > "$keyfile" +fi + +EOF + else + # fallback to deprecated apt-key + echo "curl -s -L '$uri' | apt-key add -" + fi + elif [ -d "$keydir" ]; then + tmp='/tmp/cdist_apt_key_tmp' + + # we need to kill gpg after 30 seconds, because gpg + # can get stuck if keyserver is not responding. + # exporting env var and not exit 1, + # because we need to clean up and kill dirmngr. + cat << EOF + +mkdir -m 700 -p "$tmp" + +if timeout 30s \\ + gpg --homedir "$tmp" \\ + --keyserver "$keyserver" \\ + --recv-keys "$keyid" +then + gpg --homedir "$tmp" \\ + --export "$keyid" \\ + > "$keyfile" +else + export GPG_GOT_STUCK=1 +fi + +GNUPGHOME="$tmp" gpgconf --kill dirmngr + +rm -rf "$tmp" + +if [ -n "\$GPG_GOT_STUCK" ] +then + echo "GPG GOT STUCK - no response from keyserver after 30 seconds" >&2 + exit 1 +fi + +EOF + else + # fallback to deprecated apt-key + echo "apt-key adv --keyserver \"$keyserver\" --recv-keys \"$keyid\"" + fi + + echo "added '$keyid'" >> "$__messages_out" ;; absent) - echo "apt-key del \"$keyid\"" + if [ -f "$keyfile" ]; then + echo "rm '$keyfile'" + else + # fallback to deprecated apt-key + echo "apt-key del \"$keyid\"" + fi + + echo "removed '$keyid'" >> "$__messages_out" ;; esac diff --git a/cdist/conf/type/__apt_key/man.rst b/cdist/conf/type/__apt_key/man.rst index 9009877e..234bc715 100644 --- a/cdist/conf/type/__apt_key/man.rst +++ b/cdist/conf/type/__apt_key/man.rst @@ -28,6 +28,12 @@ keyserver the keyserver from which to fetch the key. If omitted the default set in ./parameter/default/keyserver is used. +keydir + key save location, defaults to ``/etc/apt/trusted.pgp.d`` + +uri + the URI from which to download the key + EXAMPLES -------- @@ -47,15 +53,20 @@ EXAMPLES # same thing with other keyserver __apt_key UbuntuArchiveKey --keyid 437D05B5 --keyserver keyserver.ubuntu.com + # download key from the internet + __apt_key rabbitmq \ + --uri http://www.rabbitmq.com/rabbitmq-signing-key-public.asc + AUTHORS ------- Steven Armstrong +Ander Punnar COPYING ------- -Copyright \(C) 2011-2014 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 +Copyright \(C) 2011-2019 Steven Armstrong and Ander Punnar. 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/__apt_key/manifest b/cdist/conf/type/__apt_key/manifest new file mode 100755 index 00000000..010357cd --- /dev/null +++ b/cdist/conf/type/__apt_key/manifest @@ -0,0 +1,8 @@ +#!/bin/sh -e + +__package gnupg + +if [ -f "$__object/parameter/uri" ] +then __package curl +else __package dirmngr +fi diff --git a/cdist/conf/type/__apt_key/parameter/default/keydir b/cdist/conf/type/__apt_key/parameter/default/keydir new file mode 100644 index 00000000..190eb2de --- /dev/null +++ b/cdist/conf/type/__apt_key/parameter/default/keydir @@ -0,0 +1 @@ +/etc/apt/trusted.gpg.d diff --git a/cdist/conf/type/__apt_key/parameter/optional b/cdist/conf/type/__apt_key/parameter/optional index 18cf2586..de647375 100644 --- a/cdist/conf/type/__apt_key/parameter/optional +++ b/cdist/conf/type/__apt_key/parameter/optional @@ -1,3 +1,5 @@ state keyid keyserver +keydir +uri From 520cfeda989fbcaf12706a3540a9267ad23afdee Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Sat, 25 May 2019 16:10:18 +0200 Subject: [PATCH 0399/1217] ++ --- docs/changelog | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/changelog b/docs/changelog index 86ac6c9e..66140bb1 100644 --- a/docs/changelog +++ b/docs/changelog @@ -1,6 +1,10 @@ Changelog --------- +next: + * Type __apt_key: Use gpg key, fallback to deprecated apt-key (Ander Punnar) + * Type __acl: Fix and improve (Ander Punnar) + 5.1.0: 2019-05-22 * Type __consul: Add alpine support (Nico Schottelius) * Type __consul: Add version 1.5.0 (Nico Schottelius) From 68837e45cc768fed8a891d22c60cde4ecb3ed62b Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Sat, 25 May 2019 19:19:47 +0200 Subject: [PATCH 0400/1217] Document type stdin inside loop caveats --- docs/changelog | 1 + docs/src/cdist-type.rst | 67 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 68 insertions(+) diff --git a/docs/changelog b/docs/changelog index 66140bb1..1cded1f9 100644 --- a/docs/changelog +++ b/docs/changelog @@ -4,6 +4,7 @@ Changelog next: * Type __apt_key: Use gpg key, fallback to deprecated apt-key (Ander Punnar) * Type __acl: Fix and improve (Ander Punnar) + * Documentation: Document type stdin inside loop caveats (Darko Poljak) 5.1.0: 2019-05-22 * Type __consul: Add alpine support (Nico Schottelius) diff --git a/docs/src/cdist-type.rst b/docs/src/cdist-type.rst index dfad6fa0..6cf83258 100644 --- a/docs/src/cdist-type.rst +++ b/docs/src/cdist-type.rst @@ -216,6 +216,73 @@ In the __file type, stdin is used as source for the file, if - is used for sourc .... +Stdin inside a loop +~~~~~~~~~~~~~~~~~~~ +Since cdist saves type's stdin content in the object as **$__object/stdin**, +so it can be accessed in manifest and gencode-* scripts, this can lead to +unexpected behavior. For example, suppose you have some type with the following +in its manifest: + +.. code-block:: sh + + if [ -f "$__object/parameter/foo" ] + then + while read -r l + do + __file "$l" + echo "$l" >&2 + done < "$__object/parameter/foo" + fi + +and init manifest: + +.. code-block:: sh + + __foo foo --foo a --foo b --foo c + +You expect that manifest stderr content is: + +.. code-block:: sh + + a + b + c + +and that files *a*, *b* and *c* are created. But all you get in manifest stderr +is: + +.. code-block:: sh + + a + +and only *a* file is created. + +When redirecting parameter *foo* file content to while's stdin that means that all +commands in while body have this same stdin. So when *__file* type gets executed, +cdist saves its stdin which means it gets the remaining content of parameter *foo* +file, i.e.: + +.. code-block:: sh + + b + c + +The solution is to make sure that your types inside such loops get their stdin +from somewhere else, e.g. for the above problem *__file* type can get empty +stdin from */dev/null*: + +.. code-block:: sh + + if [ -f "$__object/parameter/foo" ] + then + while read -r l + do + __file "$l" < /dev/null + echo "$l" >&2 + done < "$__object/parameter/foo" + fi + + Writing the manifest -------------------- In the manifest of a type you can use other types, so your type extends From 8315677ad1fc6dff6e10cb78754cbb5748340811 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Tue, 28 May 2019 17:53:34 +0200 Subject: [PATCH 0401/1217] Release 5.1.1 --- docs/changelog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/changelog b/docs/changelog index 1cded1f9..2f20fd84 100644 --- a/docs/changelog +++ b/docs/changelog @@ -1,7 +1,7 @@ Changelog --------- -next: +5.1.1: 2019-05-28 * Type __apt_key: Use gpg key, fallback to deprecated apt-key (Ander Punnar) * Type __acl: Fix and improve (Ander Punnar) * Documentation: Document type stdin inside loop caveats (Darko Poljak) From 55ba49efacc962d3233e28483b4237059356f887 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Wed, 19 Jun 2019 18:19:32 +0200 Subject: [PATCH 0402/1217] Add support for deprecated type parameters --- cdist/config.py | 5 ++++ cdist/core/cdist_type.py | 21 ++++++++++++++++ cdist/test/cdist_type/__init__.py | 12 ++++++++++ .../__with_deprecated_parameters/deprecated | 0 .../parameter/deprecated | 2 ++ .../parameter/optional | 4 ++++ docs/src/cdist-type.rst | 24 ++++++++++++++++++- 7 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 cdist/test/cdist_type/fixtures/__with_deprecated_parameters/deprecated create mode 100644 cdist/test/cdist_type/fixtures/__with_deprecated_parameters/parameter/deprecated create mode 100644 cdist/test/cdist_type/fixtures/__with_deprecated_parameters/parameter/optional diff --git a/cdist/config.py b/cdist/config.py index 1a0ab4d5..6622823b 100644 --- a/cdist/config.py +++ b/cdist/config.py @@ -767,6 +767,11 @@ class Config(object): deprecated) else: self.log.warning("Type %s is deprecated.", cdist_type.name) + for param in cdist_object.parameters: + if param in cdist_type.deprecated_parameters: + self.log.warning(("%s parameter of type %s is deprecated, " + "see man page for details"), + param, cdist_type.name) def object_prepare(self, cdist_object, transfer_type_explorers=True): """Prepare object: Run type explorer + manifest""" diff --git a/cdist/core/cdist_type.py b/cdist/core/cdist_type.py index 7cabd72f..48926a03 100644 --- a/cdist/core/cdist_type.py +++ b/cdist/core/cdist_type.py @@ -69,6 +69,7 @@ class CdistType(object): self.__optional_multiple_parameters = None self.__boolean_parameters = None self.__parameter_defaults = None + self.__deprecated_parameters = None def __hash__(self): return hash(self.name) @@ -275,3 +276,23 @@ class CdistType(object): finally: self.__parameter_defaults = defaults return self.__parameter_defaults + + @property + def deprecated_parameters(self): + """Return a list of deprecated parameters""" + if not self.__deprecated_parameters: + parameters = [] + try: + with open(os.path.join(self.absolute_path, + "parameter", + "deprecated")) as fd: + for line in fd: + line = line.strip() + if line: + parameters.append(line) + except EnvironmentError: + # error ignored + pass + finally: + self.__deprecated_parameters = parameters + return self.__deprecated_parameters diff --git a/cdist/test/cdist_type/__init__.py b/cdist/test/cdist_type/__init__.py index ac84d874..9eee395c 100644 --- a/cdist/test/cdist_type/__init__.py +++ b/cdist/test/cdist_type/__init__.py @@ -200,3 +200,15 @@ class TypeTestCase(test.CdistTestCase): self.assertEqual( list(sorted(cdist_type.parameter_defaults.keys())), ['bar', 'foo']) + + def test_without_deprecated_parameters(self): + base_path = fixtures + cdist_type = core.CdistType(base_path, + '__without_deprecated_parameters') + self.assertEqual(cdist_type.deprecated_parameters, []) + + def test_with_deprecated_parameters(self): + base_path = fixtures + cdist_type = core.CdistType(base_path, '__with_deprecated_parameters') + self.assertEqual(cdist_type.deprecated_parameters, + ['eggs', 'spam']) diff --git a/cdist/test/cdist_type/fixtures/__with_deprecated_parameters/deprecated b/cdist/test/cdist_type/fixtures/__with_deprecated_parameters/deprecated new file mode 100644 index 00000000..e69de29b diff --git a/cdist/test/cdist_type/fixtures/__with_deprecated_parameters/parameter/deprecated b/cdist/test/cdist_type/fixtures/__with_deprecated_parameters/parameter/deprecated new file mode 100644 index 00000000..81830edb --- /dev/null +++ b/cdist/test/cdist_type/fixtures/__with_deprecated_parameters/parameter/deprecated @@ -0,0 +1,2 @@ +eggs +spam diff --git a/cdist/test/cdist_type/fixtures/__with_deprecated_parameters/parameter/optional b/cdist/test/cdist_type/fixtures/__with_deprecated_parameters/parameter/optional new file mode 100644 index 00000000..7c804d5f --- /dev/null +++ b/cdist/test/cdist_type/fixtures/__with_deprecated_parameters/parameter/optional @@ -0,0 +1,4 @@ +spam +eggs +sausage +spam diff --git a/docs/src/cdist-type.rst b/docs/src/cdist-type.rst index 6cf83258..623ba481 100644 --- a/docs/src/cdist-type.rst +++ b/docs/src/cdist-type.rst @@ -74,7 +74,7 @@ prevents to be run in more than one instance. Deprecated types ----------------- If a type is flagged with 'deprecated' marker then it is considered deprecated. -Upon it's usage cdist writes warning line. If 'deprecated' marker has content +When it is used cdist writes warning line. If 'deprecated' marker has content then this content is printed as a deprecation messages, e.g.: .. code-block:: sh @@ -186,6 +186,28 @@ Example: (e.g. in cdist/conf/type/__nginx_vhost/manifest) fi +Deprecated parameters +--------------------- +To deprecate type parameters one can declare a newline separated file +**parameter/deprecated** where each line contains deprecated parameter. +When it is used cdist writes warning line, e.g.: + +.. code-block:: sh + + $ cat parameter/optional_multiple + foo + spam + eggs + $ cat parameter/deprecated + spam + eggs + $ echo '__foo foo --foo foo --spam spam' | ./bin/cdist config -i - 185.203.112.26 + WARNING: 185.203.112.26: spam parameter of type __foo is deprecated, see man page for details + $ echo '__foo foo --foo foo --eggs eggs --spam spam' | ./bin/cdist config -i - 185.203.112.26 + WARNING: 185.203.112.26: spam parameter of type __foo is deprecated, see man page for details + WARNING: 185.203.112.26: eggs parameter of type __foo is deprecated, see man page for details + + Input from stdin ---------------- Every type can access what has been written on stdin when it has been called. From 3cb4e76175c06370cc7b69a326c9ae1c6c0b0c37 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Wed, 19 Jun 2019 18:19:32 +0200 Subject: [PATCH 0403/1217] Allow custom message for each deprecated parameter --- cdist/config.py | 11 +++++-- cdist/core/cdist_type.py | 24 +++++++------- cdist/test/cdist_type/__init__.py | 9 ++++-- .../parameter/deprecated | 2 -- .../parameter/deprecated/eggs | 1 + .../{deprecated => parameter/deprecated/spam} | 0 .../parameter/optional | 1 - docs/src/cdist-type.rst | 31 ++++++++++--------- 8 files changed, 44 insertions(+), 35 deletions(-) delete mode 100644 cdist/test/cdist_type/fixtures/__with_deprecated_parameters/parameter/deprecated create mode 100644 cdist/test/cdist_type/fixtures/__with_deprecated_parameters/parameter/deprecated/eggs rename cdist/test/cdist_type/fixtures/__with_deprecated_parameters/{deprecated => parameter/deprecated/spam} (100%) diff --git a/cdist/config.py b/cdist/config.py index 6622823b..26d07fc4 100644 --- a/cdist/config.py +++ b/cdist/config.py @@ -769,9 +769,14 @@ class Config(object): self.log.warning("Type %s is deprecated.", cdist_type.name) for param in cdist_object.parameters: if param in cdist_type.deprecated_parameters: - self.log.warning(("%s parameter of type %s is deprecated, " - "see man page for details"), - param, cdist_type.name) + msg = cdist_type.deprecated_parameters[param] + if msg: + format = "%s parameter of type %s is deprecated: %s" + args = [param, cdist_type.name, msg] + else: + format = "%s parameter of type %s is deprecated." + args = [param, cdist_type.name] + self.log.warning(format, *args) def object_prepare(self, cdist_object, transfer_type_explorers=True): """Prepare object: Run type explorer + manifest""" diff --git a/cdist/core/cdist_type.py b/cdist/core/cdist_type.py index 48926a03..4500f50d 100644 --- a/cdist/core/cdist_type.py +++ b/cdist/core/cdist_type.py @@ -279,20 +279,20 @@ class CdistType(object): @property def deprecated_parameters(self): - """Return a list of deprecated parameters""" if not self.__deprecated_parameters: - parameters = [] + deprecated = {} try: - with open(os.path.join(self.absolute_path, - "parameter", - "deprecated")) as fd: - for line in fd: - line = line.strip() - if line: - parameters.append(line) + deprecated_dir = os.path.join(self.absolute_path, + "parameter", + "deprecated") + for name in cdist.core.listdir(deprecated_dir): + try: + with open(os.path.join(deprecated_dir, name)) as fd: + deprecated[name] = fd.read().strip() + except EnvironmentError: + pass # Swallow errors raised by open() or read() except EnvironmentError: - # error ignored - pass + pass # Swallow error raised by os.listdir() finally: - self.__deprecated_parameters = parameters + self.__deprecated_parameters = deprecated return self.__deprecated_parameters diff --git a/cdist/test/cdist_type/__init__.py b/cdist/test/cdist_type/__init__.py index 9eee395c..a51a1e6f 100644 --- a/cdist/test/cdist_type/__init__.py +++ b/cdist/test/cdist_type/__init__.py @@ -205,10 +205,13 @@ class TypeTestCase(test.CdistTestCase): base_path = fixtures cdist_type = core.CdistType(base_path, '__without_deprecated_parameters') - self.assertEqual(cdist_type.deprecated_parameters, []) + self.assertEqual(cdist_type.deprecated_parameters, {}) def test_with_deprecated_parameters(self): base_path = fixtures cdist_type = core.CdistType(base_path, '__with_deprecated_parameters') - self.assertEqual(cdist_type.deprecated_parameters, - ['eggs', 'spam']) + self.assertTrue('eggs' in cdist_type.deprecated_parameters) + self.assertTrue('spam' in cdist_type.deprecated_parameters) + self.assertEqual(cdist_type.deprecated_parameters['eggs'], + 'Deprecated') + self.assertEqual(cdist_type.deprecated_parameters['spam'], '') diff --git a/cdist/test/cdist_type/fixtures/__with_deprecated_parameters/parameter/deprecated b/cdist/test/cdist_type/fixtures/__with_deprecated_parameters/parameter/deprecated deleted file mode 100644 index 81830edb..00000000 --- a/cdist/test/cdist_type/fixtures/__with_deprecated_parameters/parameter/deprecated +++ /dev/null @@ -1,2 +0,0 @@ -eggs -spam diff --git a/cdist/test/cdist_type/fixtures/__with_deprecated_parameters/parameter/deprecated/eggs b/cdist/test/cdist_type/fixtures/__with_deprecated_parameters/parameter/deprecated/eggs new file mode 100644 index 00000000..69d9f456 --- /dev/null +++ b/cdist/test/cdist_type/fixtures/__with_deprecated_parameters/parameter/deprecated/eggs @@ -0,0 +1 @@ +Deprecated diff --git a/cdist/test/cdist_type/fixtures/__with_deprecated_parameters/deprecated b/cdist/test/cdist_type/fixtures/__with_deprecated_parameters/parameter/deprecated/spam similarity index 100% rename from cdist/test/cdist_type/fixtures/__with_deprecated_parameters/deprecated rename to cdist/test/cdist_type/fixtures/__with_deprecated_parameters/parameter/deprecated/spam diff --git a/cdist/test/cdist_type/fixtures/__with_deprecated_parameters/parameter/optional b/cdist/test/cdist_type/fixtures/__with_deprecated_parameters/parameter/optional index 7c804d5f..bfe09199 100644 --- a/cdist/test/cdist_type/fixtures/__with_deprecated_parameters/parameter/optional +++ b/cdist/test/cdist_type/fixtures/__with_deprecated_parameters/parameter/optional @@ -1,4 +1,3 @@ spam eggs sausage -spam diff --git a/docs/src/cdist-type.rst b/docs/src/cdist-type.rst index 623ba481..582c0938 100644 --- a/docs/src/cdist-type.rst +++ b/docs/src/cdist-type.rst @@ -188,24 +188,27 @@ Example: (e.g. in cdist/conf/type/__nginx_vhost/manifest) Deprecated parameters --------------------- -To deprecate type parameters one can declare a newline separated file -**parameter/deprecated** where each line contains deprecated parameter. -When it is used cdist writes warning line, e.g.: +To deprecate type parameters one can declare a file for each deprecated +parameter under **parameter/deprecated** directory. + +When such parameter is used cdist writes warning line with deprecation message. +If such file has content then this content is printed as deprecation message. +If there is no content then generic parameter deprecation message is printed. + +Example: .. code-block:: sh - $ cat parameter/optional_multiple - foo - spam - eggs - $ cat parameter/deprecated - spam - eggs - $ echo '__foo foo --foo foo --spam spam' | ./bin/cdist config -i - 185.203.112.26 - WARNING: 185.203.112.26: spam parameter of type __foo is deprecated, see man page for details + $ ls parameter/deprecated/ + eggs spam + $ cat parameter/deprecated/eggs + eggs parameter is deprecated, please use multiple egg parameter. + $ cat parameter/deprecated/spam + $ echo '__foo foo --foo foo --eggs eggs' | ./bin/cdist config -i - 185.203.112.26 + WARNING: 185.203.112.26: eggs parameter of type __foo is deprecated: eggs parameter is deprecated, please use multiple egg parameter. $ echo '__foo foo --foo foo --eggs eggs --spam spam' | ./bin/cdist config -i - 185.203.112.26 - WARNING: 185.203.112.26: spam parameter of type __foo is deprecated, see man page for details - WARNING: 185.203.112.26: eggs parameter of type __foo is deprecated, see man page for details + WARNING: 185.203.112.26: spam parameter of type __foo is deprecated. + WARNING: 185.203.112.26: eggs parameter of type __foo is deprecated: eggs parameter is deprecated, please use multiple egg parameter. Input from stdin From d723f60673c35b91017319a6699c53e3d0f38425 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Thu, 20 Jun 2019 18:12:50 +0200 Subject: [PATCH 0404/1217] ++changelog --- docs/changelog | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/changelog b/docs/changelog index 2f20fd84..a79b116d 100644 --- a/docs/changelog +++ b/docs/changelog @@ -1,6 +1,9 @@ Changelog --------- +next: + * Core: Add support for type parameters deprecation (Darko Poljak) + 5.1.1: 2019-05-28 * Type __apt_key: Use gpg key, fallback to deprecated apt-key (Ander Punnar) * Type __acl: Fix and improve (Ander Punnar) From 91a6ecc70173638aae928ddadabd93d9d46f097e Mon Sep 17 00:00:00 2001 From: Ander Punnar Date: Thu, 30 May 2019 23:04:46 +0300 Subject: [PATCH 0405/1217] __acl: rewrite --- cdist/conf/type/__acl/explorer/checks | 32 ++++------ cdist/conf/type/__acl/gencode-remote | 54 ++++++++--------- cdist/conf/type/__acl/man.rst | 59 ++++++++++--------- cdist/conf/type/__acl/parameter/optional | 2 - .../type/__acl/parameter/optional_multiple | 2 - .../type/__acl/parameter/required_multiple | 1 + 6 files changed, 66 insertions(+), 84 deletions(-) delete mode 100644 cdist/conf/type/__acl/parameter/optional delete mode 100644 cdist/conf/type/__acl/parameter/optional_multiple create mode 100644 cdist/conf/type/__acl/parameter/required_multiple diff --git a/cdist/conf/type/__acl/explorer/checks b/cdist/conf/type/__acl/explorer/checks index a2fcf44d..5b379a08 100755 --- a/cdist/conf/type/__acl/explorer/checks +++ b/cdist/conf/type/__acl/explorer/checks @@ -20,29 +20,17 @@ # TODO check if filesystem has ACL turned on etc -for parameter in user group +grep -E '^(default:)?(user|group):' "$__object/parameter/acl" \ +| while read -r acl do - if [ ! -f "$__object/parameter/$parameter" ] + param="$( echo "$acl" | awk -F: '{print $(NF-2)}' )" + check="$( echo "$acl" | awk -F: '{print $(NF-1)}' )" + + [ "$param" = 'user' ] && db=passwd || db="$param" + + if ! getent "$db" "$check" > /dev/null then - continue + echo "missing $param '$check'" >&2 + exit 1 fi - - while read -r acl - do - check="$( echo "$acl" | awk -F: '{print $1}' )" - - if [ "$parameter" = 'user' ] - then - getent_db=passwd - else - getent_db="$parameter" - fi - - if ! getent "$getent_db" "$check" > /dev/null - then - echo "missing $parameter '$check'" >&2 - exit 1 - fi - done \ - < "$__object/parameter/$parameter" done diff --git a/cdist/conf/type/__acl/gencode-remote b/cdist/conf/type/__acl/gencode-remote index f5b0474f..3c7085f0 100755 --- a/cdist/conf/type/__acl/gencode-remote +++ b/cdist/conf/type/__acl/gencode-remote @@ -24,41 +24,35 @@ file_is="$( cat "$__object/explorer/file_is" )" os="$( cat "$__global/explorer/os" )" -acl_is="$( cat "$__object/explorer/acl_is" )" - acl_path="/$__object_id" -if [ -f "$__object/parameter/default" ] && [ "$file_is" = 'directory' ] +acl_is="$( cat "$__object/explorer/acl_is" )" + +acl_should="$( cat "$__object/parameter/acl" )" + +if [ -f "$__object/parameter/default" ] then - set_default=1 -else - set_default=0 + acl_should="$( echo "$acl_should" \ + | sed 's/^default://' \ + | sort -u \ + | sed 's/\(.*\)/default:\1\n\1/' )" fi -acl_should="$( for parameter in user group mask other -do - if [ ! -f "$__object/parameter/$parameter" ] - then - continue - fi +if [ "$file_is" = 'regular' ] \ + && echo "$acl_should" | grep -Eq '^default:' +then + # only directories can have default ACLs, + # but instead of error, + # let's just remove default entries + acl_should="$( echo "$acl_should" | grep -Ev '^default:' )" +fi - while read -r acl - do - if echo "$acl" | awk -F: '{ print $NF }' | grep -Fq 'X' - then - [ "$file_is" = 'directory' ] && rep=x || rep=- +if echo "$acl_should" | awk -F: '{ print $NF }' | grep -Fq 'X' +then + [ "$file_is" = 'directory' ] && rep=x || rep=- - acl="$( echo "$acl" | sed "s/\\(.*\\)X/\\1$rep/" )" - fi - - echo "$parameter" | grep -Eq '(mask|other)' && sep=:: || sep=: - - echo "$parameter$sep$acl" - - [ "$set_default" = '1' ] && echo "default:$parameter$sep$acl" - done \ - < "$__object/parameter/$parameter" -done )" + acl_should="$( echo "$acl_should" | sed "s/\\(.*\\)X/\\1$rep/" )" +fi setfacl_exec='setfacl' @@ -76,7 +70,7 @@ if [ -f "$__object/parameter/remove" ] then echo "$acl_is" | while read -r acl do - # Skip wanted ACL entries which already exist + # skip wanted ACL entries which already exist # and skip mask and other entries, because we # can't actually remove them, but only change. if echo "$acl_should" | grep -Eq "^$acl" \ @@ -103,7 +97,7 @@ do if echo "$os" | grep -Fq 'freebsd' \ && echo "$acl" | grep -Eq '^default:' then - echo "setting default ACL in $os is currently not supported. sorry :(" >&2 + echo "setting default ACL in $os is currently not supported" >&2 else echo "$setfacl_exec -m \"$acl\" \"$acl_path\"" echo "added '$acl'" >> "$__messages_out" diff --git a/cdist/conf/type/__acl/man.rst b/cdist/conf/type/__acl/man.rst index d066aae5..a71e0d3c 100644 --- a/cdist/conf/type/__acl/man.rst +++ b/cdist/conf/type/__acl/man.rst @@ -8,42 +8,30 @@ cdist-type__acl - Set ACL entries DESCRIPTION ----------- -ACL must be defined as 3-symbol combination, using ``r``, ``w``, ``x`` and ``-``. - Fully supported and tested on Linux (ext4 filesystem), partial support for FreeBSD. See ``setfacl`` and ``acl`` manpages for more details. -OPTIONAL MULTIPLE PARAMETERS +REQUIRED MULTIPLE PARAMETERS ---------------------------- -user - Add user ACL entry. - -group - Add group ACL entry. - - -OPTIONAL PARAMETERS -------------------- -mask - Add mask ACL entry. - -other - Add other ACL entry. +acl + Set ACL entry following ``getfacl`` output syntax. BOOLEAN PARAMETERS ------------------ +default + Set all ACL entries as default too. + Only directories can have default ACLs. + Setting default ACL in FreeBSD is currently not supported. + recursive Make ``setfacl`` recursive (Linux only), but not ``getfacl`` in explorer. -default - Add default ACL entries (FreeBSD not supported). - remove - Remove undefined ACL entries (Solaris not supported). - ACL entries for ``mask`` and ``other`` can't be removed. + Remove undefined ACL entries. + ``mask`` and ``other`` entries can't be removed, but only changed. EXAMPLES @@ -52,15 +40,30 @@ EXAMPLES .. code-block:: sh __acl /srv/project \ + --default \ --recursive \ + --remove \ + --acl user:alice:rwx \ + --acl user:bob:r-x \ + --acl group:project-group:rwx \ + --acl group:some-other-group:r-x \ + --acl mask::r-x \ + --acl other::r-x + + # give Alice read-only access to subdir, + # but don't allow her to see parent content. + + __acl /srv/project2 \ + --remove \ + --acl default:group:secret-project:rwx \ + --acl group:secret-project:rwx \ + --acl user:alice:--x + + __acl /srv/project2/subdir \ --default \ --remove \ - --user alice:rwx \ - --user bob:r-x \ - --group project-group:rwx \ - --group some-other-group:r-x \ - --mask r-x \ - --other r-x + --acl group:secret-project:rwx \ + --acl user:alice:r-x AUTHORS diff --git a/cdist/conf/type/__acl/parameter/optional b/cdist/conf/type/__acl/parameter/optional deleted file mode 100644 index 4b32086b..00000000 --- a/cdist/conf/type/__acl/parameter/optional +++ /dev/null @@ -1,2 +0,0 @@ -mask -other diff --git a/cdist/conf/type/__acl/parameter/optional_multiple b/cdist/conf/type/__acl/parameter/optional_multiple deleted file mode 100644 index 22f5a52c..00000000 --- a/cdist/conf/type/__acl/parameter/optional_multiple +++ /dev/null @@ -1,2 +0,0 @@ -user -group diff --git a/cdist/conf/type/__acl/parameter/required_multiple b/cdist/conf/type/__acl/parameter/required_multiple new file mode 100644 index 00000000..39fead3b --- /dev/null +++ b/cdist/conf/type/__acl/parameter/required_multiple @@ -0,0 +1 @@ +acl From a5df0badaf1d38bc0f47e3e30bfd9f2e683677d1 Mon Sep 17 00:00:00 2001 From: Ander Punnar Date: Sun, 16 Jun 2019 15:18:39 +0300 Subject: [PATCH 0406/1217] __acl: add compatibility for deprecated parameters --- cdist/conf/type/__acl/explorer/checks | 27 ++++++++++--------- cdist/conf/type/__acl/gencode-remote | 22 ++++++++++++++- cdist/conf/type/__acl/man.rst | 6 +++++ cdist/conf/type/__acl/parameter/optional | 2 ++ .../type/__acl/parameter/optional_multiple | 3 +++ .../type/__acl/parameter/required_multiple | 1 - 6 files changed, 47 insertions(+), 14 deletions(-) create mode 100644 cdist/conf/type/__acl/parameter/optional create mode 100644 cdist/conf/type/__acl/parameter/optional_multiple delete mode 100644 cdist/conf/type/__acl/parameter/required_multiple diff --git a/cdist/conf/type/__acl/explorer/checks b/cdist/conf/type/__acl/explorer/checks index 5b379a08..70bb0412 100755 --- a/cdist/conf/type/__acl/explorer/checks +++ b/cdist/conf/type/__acl/explorer/checks @@ -20,17 +20,20 @@ # TODO check if filesystem has ACL turned on etc -grep -E '^(default:)?(user|group):' "$__object/parameter/acl" \ -| while read -r acl -do - param="$( echo "$acl" | awk -F: '{print $(NF-2)}' )" - check="$( echo "$acl" | awk -F: '{print $(NF-1)}' )" +if [ -f "$__object/parameter/acl" ] +then + grep -E '^(default:)?(user|group):' "$__object/parameter/acl" \ + | while read -r acl + do + param="$( echo "$acl" | awk -F: '{print $(NF-2)}' )" + check="$( echo "$acl" | awk -F: '{print $(NF-1)}' )" - [ "$param" = 'user' ] && db=passwd || db="$param" + [ "$param" = 'user' ] && db=passwd || db="$param" - if ! getent "$db" "$check" > /dev/null - then - echo "missing $param '$check'" >&2 - exit 1 - fi -done + if ! getent "$db" "$check" > /dev/null + then + echo "missing $param '$check'" >&2 + exit 1 + fi + done +fi diff --git a/cdist/conf/type/__acl/gencode-remote b/cdist/conf/type/__acl/gencode-remote index 3c7085f0..6dab4d09 100755 --- a/cdist/conf/type/__acl/gencode-remote +++ b/cdist/conf/type/__acl/gencode-remote @@ -28,7 +28,27 @@ acl_path="/$__object_id" acl_is="$( cat "$__object/explorer/acl_is" )" -acl_should="$( cat "$__object/parameter/acl" )" +if [ -f "$__object/parameter/acl" ] +then + acl_should="$( cat "$__object/parameter/acl" )" +elif + [ -f "$__object/parameter/user" ] \ + || [ -f "$__object/parameter/group" ] \ + || [ -f "$__object/parameter/mask" ] \ + || [ -f "$__object/parameter/other" ] +then + acl_should="$( for param in user group mask other + do + [ ! -f "$__object/parameter/$param" ] && continue + + echo "$param" | grep -Eq 'mask|other' && sep=:: || sep=: + + echo "$param$sep$( cat "$__object/parameter/$param" )" + done )" +else + echo 'no parameters set' >&2 + exit 1 +fi if [ -f "$__object/parameter/default" ] then diff --git a/cdist/conf/type/__acl/man.rst b/cdist/conf/type/__acl/man.rst index a71e0d3c..85e946ce 100644 --- a/cdist/conf/type/__acl/man.rst +++ b/cdist/conf/type/__acl/man.rst @@ -34,6 +34,12 @@ remove ``mask`` and ``other`` entries can't be removed, but only changed. +DEPRECATED PARAMETERS +--------------------- +Parameters ``user``, ``group``, ``mask`` and ``other`` are deprecated and they +will be removed in future versions. Please use ``acl`` parameter instead. + + EXAMPLES -------- diff --git a/cdist/conf/type/__acl/parameter/optional b/cdist/conf/type/__acl/parameter/optional new file mode 100644 index 00000000..4b32086b --- /dev/null +++ b/cdist/conf/type/__acl/parameter/optional @@ -0,0 +1,2 @@ +mask +other diff --git a/cdist/conf/type/__acl/parameter/optional_multiple b/cdist/conf/type/__acl/parameter/optional_multiple new file mode 100644 index 00000000..95c25d55 --- /dev/null +++ b/cdist/conf/type/__acl/parameter/optional_multiple @@ -0,0 +1,3 @@ +acl +user +group diff --git a/cdist/conf/type/__acl/parameter/required_multiple b/cdist/conf/type/__acl/parameter/required_multiple deleted file mode 100644 index 39fead3b..00000000 --- a/cdist/conf/type/__acl/parameter/required_multiple +++ /dev/null @@ -1 +0,0 @@ -acl From a4bc051ad9ecb538d5d239a03990b788acf81d88 Mon Sep 17 00:00:00 2001 From: Ander Punnar Date: Fri, 21 Jun 2019 13:02:44 +0300 Subject: [PATCH 0407/1217] __acl: use type deprecation --- cdist/conf/type/__acl/parameter/deprecated/group | 1 + cdist/conf/type/__acl/parameter/deprecated/mask | 1 + cdist/conf/type/__acl/parameter/deprecated/other | 1 + cdist/conf/type/__acl/parameter/deprecated/user | 1 + 4 files changed, 4 insertions(+) create mode 100644 cdist/conf/type/__acl/parameter/deprecated/group create mode 100644 cdist/conf/type/__acl/parameter/deprecated/mask create mode 100644 cdist/conf/type/__acl/parameter/deprecated/other create mode 100644 cdist/conf/type/__acl/parameter/deprecated/user diff --git a/cdist/conf/type/__acl/parameter/deprecated/group b/cdist/conf/type/__acl/parameter/deprecated/group new file mode 100644 index 00000000..94e14159 --- /dev/null +++ b/cdist/conf/type/__acl/parameter/deprecated/group @@ -0,0 +1 @@ +see manual for details diff --git a/cdist/conf/type/__acl/parameter/deprecated/mask b/cdist/conf/type/__acl/parameter/deprecated/mask new file mode 100644 index 00000000..94e14159 --- /dev/null +++ b/cdist/conf/type/__acl/parameter/deprecated/mask @@ -0,0 +1 @@ +see manual for details diff --git a/cdist/conf/type/__acl/parameter/deprecated/other b/cdist/conf/type/__acl/parameter/deprecated/other new file mode 100644 index 00000000..94e14159 --- /dev/null +++ b/cdist/conf/type/__acl/parameter/deprecated/other @@ -0,0 +1 @@ +see manual for details diff --git a/cdist/conf/type/__acl/parameter/deprecated/user b/cdist/conf/type/__acl/parameter/deprecated/user new file mode 100644 index 00000000..94e14159 --- /dev/null +++ b/cdist/conf/type/__acl/parameter/deprecated/user @@ -0,0 +1 @@ +see manual for details From 8881ff22246afb78e71a7b992fcb032eb4ce1e90 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Fri, 21 Jun 2019 12:55:33 +0200 Subject: [PATCH 0408/1217] ++changelog --- docs/changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog b/docs/changelog index a79b116d..2548b4ce 100644 --- a/docs/changelog +++ b/docs/changelog @@ -3,6 +3,7 @@ Changelog next: * Core: Add support for type parameters deprecation (Darko Poljak) + * Type __acl: Rewrite and improve (Ander Punnar) 5.1.1: 2019-05-28 * Type __apt_key: Use gpg key, fallback to deprecated apt-key (Ander Punnar) From 6915d300153e690e569f3f691d8bdec4952d91a6 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Fri, 21 Jun 2019 14:13:25 +0200 Subject: [PATCH 0409/1217] Release 5.1.2 --- docs/changelog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/changelog b/docs/changelog index 2548b4ce..4952991b 100644 --- a/docs/changelog +++ b/docs/changelog @@ -1,7 +1,7 @@ Changelog --------- -next: +5.1.2: 2019-06-21 * Core: Add support for type parameters deprecation (Darko Poljak) * Type __acl: Rewrite and improve (Ander Punnar) From 5c11c15ae4f7962588f88a9fcdad5bc812d819d0 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Sun, 23 Jun 2019 19:55:37 +0200 Subject: [PATCH 0410/1217] Overcome bash CDPATH issue Thanks to Dmitry Bogatov. --- Makefile | 6 +++--- docs/changelog | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index b739ab1f..fa3327d1 100644 --- a/Makefile +++ b/Makefile @@ -31,9 +31,9 @@ help: @echo "docs-clean clean documentation" @echo "clean clean" -DOCS_SRC_DIR=docs/src -SPEECHDIR=docs/speeches -TYPEDIR=cdist/conf/type +DOCS_SRC_DIR=./docs/src +SPEECHDIR=./docs/speeches +TYPEDIR=./cdist/conf/type SPHINXM=make -C $(DOCS_SRC_DIR) man SPHINXH=make -C $(DOCS_SRC_DIR) html diff --git a/docs/changelog b/docs/changelog index 4952991b..e4e312fd 100644 --- a/docs/changelog +++ b/docs/changelog @@ -1,6 +1,9 @@ Changelog --------- +next: + * Build: Overcome bash CDPATH when building docs (Dmitry Bogatov) + 5.1.2: 2019-06-21 * Core: Add support for type parameters deprecation (Darko Poljak) * Type __acl: Rewrite and improve (Ander Punnar) From 6bb58f882086f5f46c20355f768ee1095540f4d2 Mon Sep 17 00:00:00 2001 From: Dominique Roux Date: Wed, 24 Jul 2019 13:32:39 +0200 Subject: [PATCH 0411/1217] Updated the __grafana_dashboard type for the new package repository - Changed the signing key uri - Changed the repo uri --- cdist/conf/type/__grafana_dashboard/manifest | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cdist/conf/type/__grafana_dashboard/manifest b/cdist/conf/type/__grafana_dashboard/manifest index 9cd1465d..c1fe9416 100755 --- a/cdist/conf/type/__grafana_dashboard/manifest +++ b/cdist/conf/type/__grafana_dashboard/manifest @@ -21,10 +21,10 @@ case $os in __apt_key_uri grafana \ --name 'Grafana Release Signing Key' \ - --uri https://packagecloud.io/gpg.key + --uri https://packages.grafana.com/gpg.key require="$require __apt_key_uri/grafana" __apt_source grafana \ - --uri https://packagecloud.io/grafana/stable/debian/ \ + --uri https://packages.grafana.com/oss/deb \ --distribution $apt_source_distribution \ --component main From a70d2e0af5a7b842d8a1b0ceb03abb90a770e001 Mon Sep 17 00:00:00 2001 From: Dominique Roux Date: Wed, 24 Jul 2019 13:35:46 +0200 Subject: [PATCH 0412/1217] Had to change the apt_source_distribution to stable, since the repository doesn't differ in distributions --- cdist/conf/type/__grafana_dashboard/manifest | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cdist/conf/type/__grafana_dashboard/manifest b/cdist/conf/type/__grafana_dashboard/manifest index c1fe9416..e652202b 100755 --- a/cdist/conf/type/__grafana_dashboard/manifest +++ b/cdist/conf/type/__grafana_dashboard/manifest @@ -8,10 +8,12 @@ case $os in debian|devuan) case $os_version in 8*|jessie) - apt_source_distribution=jessie + # Differntation not needed anymore + apt_source_distribution=stable ;; 9*|ascii/ceres|ascii) - apt_source_distribution=stretch + # Differntation not needed anymore + apt_source_distribution=stable ;; *) echo "Don't know how to install Grafana on $os $os_version. Send us a pull request!" >&2 From f7efde0d0a28cd0e82f6126abcbc7f797a0602b8 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Thu, 25 Jul 2019 08:06:58 +0200 Subject: [PATCH 0413/1217] ++changelog --- docs/changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog b/docs/changelog index e4e312fd..ae2eac8d 100644 --- a/docs/changelog +++ b/docs/changelog @@ -3,6 +3,7 @@ Changelog next: * Build: Overcome bash CDPATH when building docs (Dmitry Bogatov) + * Type __grafana_dashboard: Update distribution name, package signing key URI and repository URI (Dominique Roux) 5.1.2: 2019-06-21 * Core: Add support for type parameters deprecation (Darko Poljak) From 031d59c82ccadb931db70bc3c22a013f1104b8e5 Mon Sep 17 00:00:00 2001 From: Dominique Roux Date: Sun, 4 Aug 2019 21:23:44 +0200 Subject: [PATCH 0414/1217] Added Devuan support for __docker type --- cdist/conf/type/__docker/manifest | 37 +++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/cdist/conf/type/__docker/manifest b/cdist/conf/type/__docker/manifest index 04a9ff27..f20337d7 100755 --- a/cdist/conf/type/__docker/manifest +++ b/cdist/conf/type/__docker/manifest @@ -64,6 +64,43 @@ case "$os" in require="__apt_source/docker" __package docker-ce --state "${state}" fi ;; + devuan) + os_version="$(cat "$__global/explorer/os_version")" + + case "$os_version" in + ascii) + distributione="stretch" + ;; + jessie) + distribution="jessie" + ;; + *) + echo "Your devuan release ($os_version) is currently not supported by this type (${__type##*/}).">&2 + echo "Please contribute an implementation for it if you can." >&2 + exit 1 + ;; + esac + + if [ "${state}" = "present" ]; then + __package apt-transport-https + __package ca-certificates + __package gnupg2 + fi + __apt_key_uri docker --name "Docker Release (CE deb) " \ + --uri "https://download.docker.com/linux/${os}/gpg" --state "${state}" + + require="__apt_key_uri/docker" __apt_source docker \ + --uri "https://download.docker.com/linux/${os}" \ + --distribution "${distribution}" \ + --state "${state}" \ + --component "stable" + if [ "$version" != "latest" ]; then + require="__apt_source/docker" __package docker-ce --version "${version}" --state "${state}" + else + require="__apt_source/docker" __package docker-ce --state "${state}" + fi + + ;; *) echo "Your operating system ($os) is currently not supported by this type (${__type##*/})." >&2 echo "Please contribute an implementation for it if you can." >&2 From c6b739b5b6de870e629d421b140587278777b5de Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Sun, 4 Aug 2019 21:52:59 +0200 Subject: [PATCH 0415/1217] ++changelog --- docs/changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog b/docs/changelog index ae2eac8d..57412999 100644 --- a/docs/changelog +++ b/docs/changelog @@ -4,6 +4,7 @@ Changelog next: * Build: Overcome bash CDPATH when building docs (Dmitry Bogatov) * Type __grafana_dashboard: Update distribution name, package signing key URI and repository URI (Dominique Roux) + * Type __docker: Add devuan support (Dominique Roux) 5.1.2: 2019-06-21 * Core: Add support for type parameters deprecation (Darko Poljak) From 2f7dc5a65d264d7f210ab06834980d8782c4a565 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Sun, 4 Aug 2019 21:54:13 +0200 Subject: [PATCH 0416/1217] Fix variable typo --- cdist/conf/type/__docker/manifest | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cdist/conf/type/__docker/manifest b/cdist/conf/type/__docker/manifest index f20337d7..6a57d85a 100755 --- a/cdist/conf/type/__docker/manifest +++ b/cdist/conf/type/__docker/manifest @@ -69,7 +69,7 @@ case "$os" in case "$os_version" in ascii) - distributione="stretch" + distribution="stretch" ;; jessie) distribution="jessie" From c0aa2214aa5b34ae1a073682fc3bd6545ceacf36 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 15 Aug 2019 14:19:54 +0200 Subject: [PATCH 0417/1217] [letsencrypt] add support for devuan/beowulf --- cdist/conf/type/__letsencrypt_cert/manifest | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cdist/conf/type/__letsencrypt_cert/manifest b/cdist/conf/type/__letsencrypt_cert/manifest index d6892c9b..072fa398 100755 --- a/cdist/conf/type/__letsencrypt_cert/manifest +++ b/cdist/conf/type/__letsencrypt_cert/manifest @@ -67,6 +67,9 @@ if [ -z "${certbot_fullpath}" ]; then require="__apt_source/ascii-backports" __package_apt certbot \ --target-release ascii-backports ;; + bewoulf*) + __package_apt certbot + ;; *) echo "Unsupported OS version: $os_version" >&2 exit 1 From 7182de596891f963c6867c1d0b08a5276450c56f Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 15 Aug 2019 14:20:14 +0200 Subject: [PATCH 0418/1217] ++changes --- docs/changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog b/docs/changelog index ae2eac8d..b13e54fa 100644 --- a/docs/changelog +++ b/docs/changelog @@ -4,6 +4,7 @@ Changelog next: * Build: Overcome bash CDPATH when building docs (Dmitry Bogatov) * Type __grafana_dashboard: Update distribution name, package signing key URI and repository URI (Dominique Roux) + * Type __letsencrypt_cert: Add Devuan Beowulf support (Nico Schottelius) 5.1.2: 2019-06-21 * Core: Add support for type parameters deprecation (Darko Poljak) From a86893889b3a9d84712a71a23da60461671ca0e9 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 15 Aug 2019 14:24:11 +0200 Subject: [PATCH 0419/1217] [letsencrypt] devuan/ascii: only install certbot package It seems python-certbot is gone --- cdist/conf/type/__letsencrypt_cert/manifest | 2 -- 1 file changed, 2 deletions(-) diff --git a/cdist/conf/type/__letsencrypt_cert/manifest b/cdist/conf/type/__letsencrypt_cert/manifest index 072fa398..d598949e 100755 --- a/cdist/conf/type/__letsencrypt_cert/manifest +++ b/cdist/conf/type/__letsencrypt_cert/manifest @@ -62,8 +62,6 @@ if [ -z "${certbot_fullpath}" ]; then --distribution ascii-backports \ --component main - require="__apt_source/ascii-backports" __package_apt python-certbot \ - --target-release ascii-backports require="__apt_source/ascii-backports" __package_apt certbot \ --target-release ascii-backports ;; From 6c780c24c7d1fdf8a316fef98a304c07ffd57d0e Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 15 Aug 2019 14:25:16 +0200 Subject: [PATCH 0420/1217] ++changes --- docs/changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog b/docs/changelog index 6e20c64e..f3b84ba8 100644 --- a/docs/changelog +++ b/docs/changelog @@ -5,6 +5,7 @@ next: * Build: Overcome bash CDPATH when building docs (Dmitry Bogatov) * Type __grafana_dashboard: Update distribution name, package signing key URI and repository URI (Dominique Roux) * Type __letsencrypt_cert: Add Devuan Beowulf support (Nico Schottelius) + * Type __letsencrypt_cert: Fix Devuan Ascii: support (Nico Schottelius) * Type __docker: Add devuan support (Dominique Roux) 5.1.2: 2019-06-21 From 451dfaffe49fc85f8222da19177b7aa05c864f56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=BDubom=C3=ADr=20Ku=C4=8Dera?= Date: Fri, 23 Aug 2019 11:28:13 +0200 Subject: [PATCH 0421/1217] __docker_swarm: Fix for Docker 19.03 --- cdist/conf/type/__docker_swarm/explorer/swarm-state | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cdist/conf/type/__docker_swarm/explorer/swarm-state b/cdist/conf/type/__docker_swarm/explorer/swarm-state index 9c1bc32d..2c9fd598 100755 --- a/cdist/conf/type/__docker_swarm/explorer/swarm-state +++ b/cdist/conf/type/__docker_swarm/explorer/swarm-state @@ -18,4 +18,4 @@ # along with cdist. If not, see . # -docker info 2>/dev/null | grep "^Swarm: " | cut -d " " -f 2- +docker info 2>/dev/null | grep '^ *Swarm: ' | awk '{print $2}' From 65b9e1d00f230ca97ef30546e1490a8b51e83c19 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Thu, 29 Aug 2019 14:40:16 +0200 Subject: [PATCH 0422/1217] ++changelog --- docs/changelog | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog b/docs/changelog index f3b84ba8..b790b983 100644 --- a/docs/changelog +++ b/docs/changelog @@ -7,6 +7,7 @@ next: * Type __letsencrypt_cert: Add Devuan Beowulf support (Nico Schottelius) * Type __letsencrypt_cert: Fix Devuan Ascii: support (Nico Schottelius) * Type __docker: Add devuan support (Dominique Roux) + * Type __docker_swarm: Fix for Docker 19.03 (Ľubomír Kučera) 5.1.2: 2019-06-21 * Core: Add support for type parameters deprecation (Darko Poljak) From 067d0a62e73d89fef35e1f7183a3b376634da5c0 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Fri, 30 Aug 2019 08:51:08 +0200 Subject: [PATCH 0423/1217] Release 5.1.3 --- docs/changelog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/changelog b/docs/changelog index b790b983..7594a6d4 100644 --- a/docs/changelog +++ b/docs/changelog @@ -1,7 +1,7 @@ Changelog --------- -next: +5.1.3: 2019-08-30 * Build: Overcome bash CDPATH when building docs (Dmitry Bogatov) * Type __grafana_dashboard: Update distribution name, package signing key URI and repository URI (Dominique Roux) * Type __letsencrypt_cert: Add Devuan Beowulf support (Nico Schottelius) From 4294ff55e16ae8aba978721f8077605c6157eaf1 Mon Sep 17 00:00:00 2001 From: Dennis Camera Date: Mon, 9 Sep 2019 16:12:16 +0200 Subject: [PATCH 0424/1217] [type/__git] Add --recursive parameter --- cdist/conf/type/__git/gencode-remote | 32 ++++++++++++------------- cdist/conf/type/__git/man.rst | 2 ++ cdist/conf/type/__git/parameter/boolean | 1 + 3 files changed, 19 insertions(+), 16 deletions(-) create mode 100644 cdist/conf/type/__git/parameter/boolean diff --git a/cdist/conf/type/__git/gencode-remote b/cdist/conf/type/__git/gencode-remote index 5a9e23fc..3ba21add 100755 --- a/cdist/conf/type/__git/gencode-remote +++ b/cdist/conf/type/__git/gencode-remote @@ -19,32 +19,31 @@ # # -state_is="$(cat "$__object/explorer/state")" -owner_is="$(cat "$__object/explorer/owner")" -group_is="$(cat "$__object/explorer/group")" +state_is=$(cat "$__object/explorer/state") +owner_is=$(cat "$__object/explorer/owner") +group_is=$(cat "$__object/explorer/group") -state_should="$(cat "$__object/parameter/state")" +state_should=$(cat "$__object/parameter/state") -branch="$(cat "$__object/parameter/branch")" +branch=$(cat "$__object/parameter/branch") -source="$(cat "$__object/parameter/source")" +source=$(cat "$__object/parameter/source") destination="/$__object_id" -owner="$(cat "$__object/parameter/owner")" -group="$(cat "$__object/parameter/group")" -mode="$(cat "$__object/parameter/mode")" +owner=$(cat "$__object/parameter/owner") +group=$(cat "$__object/parameter/group") +mode=$(cat "$__object/parameter/mode") -[ "$state_should" = "$state_is" ] && \ -[ "$owner" = "$owner_is" ] && \ -[ "$group" = "$group_is" ] && \ -[ -n "$mode" ] && exit 0 +[ "$state_should" = "$state_is" ] \ + && [ "$owner" = "$owner_is" ] \ + && [ "$group" = "$group_is" ] \ + && [ -n "$mode" ] && exit 0 case $state_should in present) - if [ "$state_should" != "$state_is" ]; then - echo git clone --quiet --branch "$branch" "$source" "$destination" + echo git clone --quiet $([ -f "$__object/parameter/recursive" ] && echo '--recursive') --branch "$branch" "$source" "$destination" fi if { [ -n "$owner" ] && [ "$owner_is" != "$owner" ]; } || \ { [ -n "$group" ] && [ "$group_is" != "$group" ]; }; then @@ -54,8 +53,9 @@ case $state_should in echo chmod -R "$mode" "$destination" fi ;; - # Handled in manifest + absent) + # Handled in manifest ;; *) diff --git a/cdist/conf/type/__git/man.rst b/cdist/conf/type/__git/man.rst index 130925c8..e4c06c99 100644 --- a/cdist/conf/type/__git/man.rst +++ b/cdist/conf/type/__git/man.rst @@ -35,6 +35,8 @@ mode owner User to chown to. +recursive + Recursive clone... EXAMPLES -------- diff --git a/cdist/conf/type/__git/parameter/boolean b/cdist/conf/type/__git/parameter/boolean new file mode 100644 index 00000000..a633e659 --- /dev/null +++ b/cdist/conf/type/__git/parameter/boolean @@ -0,0 +1 @@ +recursive From 88fe83ed735d533a77c1cd68081893442a1acc1e Mon Sep 17 00:00:00 2001 From: PCoder Date: Sat, 14 Sep 2019 15:24:36 +0530 Subject: [PATCH 0425/1217] Fix beowulf's spelling --- cdist/conf/type/__letsencrypt_cert/manifest | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cdist/conf/type/__letsencrypt_cert/manifest b/cdist/conf/type/__letsencrypt_cert/manifest index d598949e..f736f3f2 100755 --- a/cdist/conf/type/__letsencrypt_cert/manifest +++ b/cdist/conf/type/__letsencrypt_cert/manifest @@ -65,7 +65,7 @@ if [ -z "${certbot_fullpath}" ]; then require="__apt_source/ascii-backports" __package_apt certbot \ --target-release ascii-backports ;; - bewoulf*) + beowulf*) __package_apt certbot ;; *) From eab540bd0fc4a81408890f0dc8f45e8a7f609d06 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Wed, 18 Sep 2019 07:04:41 +0200 Subject: [PATCH 0426/1217] ++ --- docs/changelog | 3 +++ 1 file changed, 3 insertions(+) diff --git a/docs/changelog b/docs/changelog index 7594a6d4..e7e6b182 100644 --- a/docs/changelog +++ b/docs/changelog @@ -1,6 +1,9 @@ Changelog --------- +next: + * Type __letsencrypt_cert: Fix beowulf's spelling (Mondi Ravi) + 5.1.3: 2019-08-30 * Build: Overcome bash CDPATH when building docs (Dmitry Bogatov) * Type __grafana_dashboard: Update distribution name, package signing key URI and repository URI (Dominique Roux) From 799ec7236971fac597ccb3f80a646fae7e4817f5 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Fri, 20 Sep 2019 07:15:37 +0200 Subject: [PATCH 0427/1217] Implement preos --- cdist/argparse.py | 6 +- cdist/preos.py | 101 + cdist/preos/debootstrap/__init__.py | 1 + cdist/preos/debootstrap/debootstrap.py | 240 ++ cdist/preos/debootstrap/files/code | 274 ++ .../files/devuan-debootstrap/Makefile | 18 + .../files/devuan-debootstrap/README | 65 + .../debootstrap/files/devuan-debootstrap/TODO | 11 + .../devuan-debootstrap/debian/.gitignore | 6 + .../debian/README.DevuanSource | 15 + .../files/devuan-debootstrap/debian/changelog | 2655 +++++++++++++++++ .../files/devuan-debootstrap/debian/compat | 1 + .../files/devuan-debootstrap/debian/control | 26 + .../files/devuan-debootstrap/debian/copyright | 30 + .../debian/debootstrap.docs | 1 + .../debian/debootstrap.manpages | 1 + .../files/devuan-debootstrap/debian/gbp.conf | 9 + .../files/devuan-debootstrap/debian/rules | 47 + .../devuan-debootstrap/debian/source/format | 1 + .../files/devuan-debootstrap/debootstrap | 703 +++++ .../files/devuan-debootstrap/debootstrap.8 | 189 ++ .../files/devuan-debootstrap/functions | 1735 +++++++++++ .../files/devuan-debootstrap/scripts/aequorea | 202 ++ .../files/devuan-debootstrap/scripts/ascii | 1 + .../devuan-debootstrap/scripts/bartholomea | 1 + .../files/devuan-debootstrap/scripts/breezy | 163 + .../files/devuan-debootstrap/scripts/bullseye | 1 + .../files/devuan-debootstrap/scripts/buster | 1 + .../files/devuan-debootstrap/scripts/ceres | 218 ++ .../devuan-debootstrap/scripts/chromodoris | 1 + .../files/devuan-debootstrap/scripts/dapper | 168 ++ .../files/devuan-debootstrap/scripts/dasyatis | 1 + .../files/devuan-debootstrap/scripts/edgy | 187 ++ .../files/devuan-debootstrap/scripts/etch | 1 + .../devuan-debootstrap/scripts/etch-m68k | 1 + .../files/devuan-debootstrap/scripts/feisty | 190 ++ .../files/devuan-debootstrap/scripts/gutsy | 230 ++ .../files/devuan-debootstrap/scripts/hardy | 1 + .../files/devuan-debootstrap/scripts/hoary | 179 ++ .../devuan-debootstrap/scripts/hoary.buildd | 159 + .../files/devuan-debootstrap/scripts/intrepid | 1 + .../files/devuan-debootstrap/scripts/jaunty | 1 + .../files/devuan-debootstrap/scripts/jessie | 1 + .../scripts/jessie-kfreebsd | 1 + .../files/devuan-debootstrap/scripts/karmic | 1 + .../files/devuan-debootstrap/scripts/lenny | 1 + .../files/devuan-debootstrap/scripts/lucid | 1 + .../files/devuan-debootstrap/scripts/maverick | 1 + .../files/devuan-debootstrap/scripts/natty | 1 + .../devuan-debootstrap/scripts/oldoldstable | 1 + .../devuan-debootstrap/scripts/oldstable | 1 + .../files/devuan-debootstrap/scripts/oneiric | 1 + .../files/devuan-debootstrap/scripts/potato | 104 + .../files/devuan-debootstrap/scripts/precise | 1 + .../files/devuan-debootstrap/scripts/quantal | 1 + .../files/devuan-debootstrap/scripts/raring | 1 + .../files/devuan-debootstrap/scripts/sarge | 218 ++ .../devuan-debootstrap/scripts/sarge.buildd | 166 ++ .../scripts/sarge.fakechroot | 171 ++ .../files/devuan-debootstrap/scripts/saucy | 1 + .../files/devuan-debootstrap/scripts/sid | 214 ++ .../files/devuan-debootstrap/scripts/squeeze | 1 + .../files/devuan-debootstrap/scripts/stable | 1 + .../files/devuan-debootstrap/scripts/stretch | 1 + .../files/devuan-debootstrap/scripts/testing | 1 + .../files/devuan-debootstrap/scripts/trusty | 1 + .../files/devuan-debootstrap/scripts/unstable | 1 + .../files/devuan-debootstrap/scripts/utopic | 1 + .../files/devuan-debootstrap/scripts/vivid | 1 + .../files/devuan-debootstrap/scripts/warty | 166 ++ .../devuan-debootstrap/scripts/warty.buildd | 159 + .../files/devuan-debootstrap/scripts/wheezy | 1 + .../files/devuan-debootstrap/scripts/wily | 1 + .../files/devuan-debootstrap/scripts/woody | 203 ++ .../devuan-debootstrap/scripts/woody.buildd | 166 ++ .../files/devuan-debootstrap/scripts/xenial | 1 + .../files/devuan-debootstrap/scripts/yakkety | 1 + .../files/devuan-debootstrap/scripts/zesty | 1 + .../debootstrap/files/init-manifest-debian | 39 + .../debootstrap/files/init-manifest-devuan | 39 + .../debootstrap/files/init-manifest-ubuntu | 39 + cdist/preos/debootstrap/files/remote-copy.sh | 8 + cdist/preos/debootstrap/files/remote-exec.sh | 24 + completions/bash/cdist-completion.bash | 2 +- completions/zsh/_cdist | 2 +- docs/changelog | 1 + docs/src/cdist-preos.rst | 137 + docs/src/cdist-reference.rst.sh | 3 + docs/src/index.rst | 1 + docs/src/man1/cdist.rst | 172 +- hacking/preos-sh/init | 32 + hacking/preos-sh/preos.sh | 31 + hacking/preos-sh/remote-copy.sh | 8 + hacking/preos-sh/remote-exec.sh | 24 + scripts/cdist | 3 + 95 files changed, 9997 insertions(+), 4 deletions(-) create mode 100644 cdist/preos.py create mode 100644 cdist/preos/debootstrap/__init__.py create mode 100644 cdist/preos/debootstrap/debootstrap.py create mode 100755 cdist/preos/debootstrap/files/code create mode 100644 cdist/preos/debootstrap/files/devuan-debootstrap/Makefile create mode 100644 cdist/preos/debootstrap/files/devuan-debootstrap/README create mode 100644 cdist/preos/debootstrap/files/devuan-debootstrap/TODO create mode 100644 cdist/preos/debootstrap/files/devuan-debootstrap/debian/.gitignore create mode 100644 cdist/preos/debootstrap/files/devuan-debootstrap/debian/README.DevuanSource create mode 100644 cdist/preos/debootstrap/files/devuan-debootstrap/debian/changelog create mode 100644 cdist/preos/debootstrap/files/devuan-debootstrap/debian/compat create mode 100644 cdist/preos/debootstrap/files/devuan-debootstrap/debian/control create mode 100644 cdist/preos/debootstrap/files/devuan-debootstrap/debian/copyright create mode 100644 cdist/preos/debootstrap/files/devuan-debootstrap/debian/debootstrap.docs create mode 100644 cdist/preos/debootstrap/files/devuan-debootstrap/debian/debootstrap.manpages create mode 100644 cdist/preos/debootstrap/files/devuan-debootstrap/debian/gbp.conf create mode 100755 cdist/preos/debootstrap/files/devuan-debootstrap/debian/rules create mode 100644 cdist/preos/debootstrap/files/devuan-debootstrap/debian/source/format create mode 100755 cdist/preos/debootstrap/files/devuan-debootstrap/debootstrap create mode 100644 cdist/preos/debootstrap/files/devuan-debootstrap/debootstrap.8 create mode 100644 cdist/preos/debootstrap/files/devuan-debootstrap/functions create mode 100644 cdist/preos/debootstrap/files/devuan-debootstrap/scripts/aequorea create mode 120000 cdist/preos/debootstrap/files/devuan-debootstrap/scripts/ascii create mode 120000 cdist/preos/debootstrap/files/devuan-debootstrap/scripts/bartholomea create mode 100644 cdist/preos/debootstrap/files/devuan-debootstrap/scripts/breezy create mode 120000 cdist/preos/debootstrap/files/devuan-debootstrap/scripts/bullseye create mode 120000 cdist/preos/debootstrap/files/devuan-debootstrap/scripts/buster create mode 100644 cdist/preos/debootstrap/files/devuan-debootstrap/scripts/ceres create mode 120000 cdist/preos/debootstrap/files/devuan-debootstrap/scripts/chromodoris create mode 100644 cdist/preos/debootstrap/files/devuan-debootstrap/scripts/dapper create mode 120000 cdist/preos/debootstrap/files/devuan-debootstrap/scripts/dasyatis create mode 100644 cdist/preos/debootstrap/files/devuan-debootstrap/scripts/edgy create mode 120000 cdist/preos/debootstrap/files/devuan-debootstrap/scripts/etch create mode 120000 cdist/preos/debootstrap/files/devuan-debootstrap/scripts/etch-m68k create mode 100644 cdist/preos/debootstrap/files/devuan-debootstrap/scripts/feisty create mode 100644 cdist/preos/debootstrap/files/devuan-debootstrap/scripts/gutsy create mode 120000 cdist/preos/debootstrap/files/devuan-debootstrap/scripts/hardy create mode 100644 cdist/preos/debootstrap/files/devuan-debootstrap/scripts/hoary create mode 100644 cdist/preos/debootstrap/files/devuan-debootstrap/scripts/hoary.buildd create mode 120000 cdist/preos/debootstrap/files/devuan-debootstrap/scripts/intrepid create mode 120000 cdist/preos/debootstrap/files/devuan-debootstrap/scripts/jaunty create mode 120000 cdist/preos/debootstrap/files/devuan-debootstrap/scripts/jessie create mode 120000 cdist/preos/debootstrap/files/devuan-debootstrap/scripts/jessie-kfreebsd create mode 120000 cdist/preos/debootstrap/files/devuan-debootstrap/scripts/karmic create mode 120000 cdist/preos/debootstrap/files/devuan-debootstrap/scripts/lenny create mode 120000 cdist/preos/debootstrap/files/devuan-debootstrap/scripts/lucid create mode 120000 cdist/preos/debootstrap/files/devuan-debootstrap/scripts/maverick create mode 120000 cdist/preos/debootstrap/files/devuan-debootstrap/scripts/natty create mode 120000 cdist/preos/debootstrap/files/devuan-debootstrap/scripts/oldoldstable create mode 120000 cdist/preos/debootstrap/files/devuan-debootstrap/scripts/oldstable create mode 120000 cdist/preos/debootstrap/files/devuan-debootstrap/scripts/oneiric create mode 100644 cdist/preos/debootstrap/files/devuan-debootstrap/scripts/potato create mode 120000 cdist/preos/debootstrap/files/devuan-debootstrap/scripts/precise create mode 120000 cdist/preos/debootstrap/files/devuan-debootstrap/scripts/quantal create mode 120000 cdist/preos/debootstrap/files/devuan-debootstrap/scripts/raring create mode 100644 cdist/preos/debootstrap/files/devuan-debootstrap/scripts/sarge create mode 100644 cdist/preos/debootstrap/files/devuan-debootstrap/scripts/sarge.buildd create mode 100644 cdist/preos/debootstrap/files/devuan-debootstrap/scripts/sarge.fakechroot create mode 120000 cdist/preos/debootstrap/files/devuan-debootstrap/scripts/saucy create mode 100644 cdist/preos/debootstrap/files/devuan-debootstrap/scripts/sid create mode 120000 cdist/preos/debootstrap/files/devuan-debootstrap/scripts/squeeze create mode 120000 cdist/preos/debootstrap/files/devuan-debootstrap/scripts/stable create mode 120000 cdist/preos/debootstrap/files/devuan-debootstrap/scripts/stretch create mode 120000 cdist/preos/debootstrap/files/devuan-debootstrap/scripts/testing create mode 120000 cdist/preos/debootstrap/files/devuan-debootstrap/scripts/trusty create mode 120000 cdist/preos/debootstrap/files/devuan-debootstrap/scripts/unstable create mode 120000 cdist/preos/debootstrap/files/devuan-debootstrap/scripts/utopic create mode 120000 cdist/preos/debootstrap/files/devuan-debootstrap/scripts/vivid create mode 100644 cdist/preos/debootstrap/files/devuan-debootstrap/scripts/warty create mode 100644 cdist/preos/debootstrap/files/devuan-debootstrap/scripts/warty.buildd create mode 120000 cdist/preos/debootstrap/files/devuan-debootstrap/scripts/wheezy create mode 120000 cdist/preos/debootstrap/files/devuan-debootstrap/scripts/wily create mode 100644 cdist/preos/debootstrap/files/devuan-debootstrap/scripts/woody create mode 100644 cdist/preos/debootstrap/files/devuan-debootstrap/scripts/woody.buildd create mode 120000 cdist/preos/debootstrap/files/devuan-debootstrap/scripts/xenial create mode 120000 cdist/preos/debootstrap/files/devuan-debootstrap/scripts/yakkety create mode 120000 cdist/preos/debootstrap/files/devuan-debootstrap/scripts/zesty create mode 100644 cdist/preos/debootstrap/files/init-manifest-debian create mode 100644 cdist/preos/debootstrap/files/init-manifest-devuan create mode 100644 cdist/preos/debootstrap/files/init-manifest-ubuntu create mode 100755 cdist/preos/debootstrap/files/remote-copy.sh create mode 100755 cdist/preos/debootstrap/files/remote-exec.sh create mode 100644 docs/src/cdist-preos.rst create mode 100644 hacking/preos-sh/init create mode 100644 hacking/preos-sh/preos.sh create mode 100644 hacking/preos-sh/remote-copy.sh create mode 100644 hacking/preos-sh/remote-exec.sh diff --git a/cdist/argparse.py b/cdist/argparse.py index 421d1b54..3ccc0545 100644 --- a/cdist/argparse.py +++ b/cdist/argparse.py @@ -5,10 +5,11 @@ import logging import collections import functools import cdist.configuration +import cdist.preos # set of beta sub-commands -BETA_COMMANDS = set(('install', 'inventory', )) +BETA_COMMANDS = set(('install', 'inventory', 'preos', )) # set of beta arguments for sub-commands BETA_ARGS = { 'config': set(('tag', 'all_tagged_hosts', 'use_archiving', )), @@ -422,6 +423,9 @@ def get_parsers(): parser['inventory'].set_defaults( func=cdist.inventory.Inventory.commandline) + # PreOs + parser['preos'] = parser['sub'].add_parser('preos', add_help=False) + # Shell parser['shell'] = parser['sub'].add_parser( 'shell', parents=[parser['loglevel']]) diff --git a/cdist/preos.py b/cdist/preos.py new file mode 100644 index 00000000..46b45554 --- /dev/null +++ b/cdist/preos.py @@ -0,0 +1,101 @@ +import os +import os.path +import sys +import inspect +import argparse +import cdist +import logging + + +_PREOS_CALL = "commandline" +_PREOS_NAME = "_preos_name" +_PREOS_MARKER = "_cdist_preos" +_PLUGINS_DIR = "preos" +_PLUGINS_PATH = [os.path.join(os.path.dirname(__file__), _PLUGINS_DIR), ] +cdist_home = cdist.home_dir() +if cdist_home: + cdist_home_preos = os.path.join(cdist_home, "preos") + if os.path.isdir(cdist_home_preos): + _PLUGINS_PATH.append(cdist_home_preos) +sys.path.extend(_PLUGINS_PATH) + + +log = logging.getLogger("PreOS") + + +def preos_plugin(obj): + """It is preos if _PREOS_MARKER is True and has _PREOS_CALL.""" + if hasattr(obj, _PREOS_MARKER): + is_preos = getattr(obj, _PREOS_MARKER) + else: + is_preos = False + + if is_preos and hasattr(obj, _PREOS_CALL): + yield obj + + +def scan_preos_dir_plugins(dir): + for fname in os.listdir(dir): + if os.path.isfile(os.path.join(dir, fname)): + fname = os.path.splitext(fname)[0] + module_name = fname + try: + module = __import__(module_name) + yield from preos_plugin(module) + clsmembers = inspect.getmembers(module, inspect.isclass) + for cm in clsmembers: + c = cm[1] + yield from preos_plugin(c) + except ImportError as e: + log.warning("Cannot import '{}': {}".format(module_name, e)) + + +def find_preos_plugins(): + for dir in _PLUGINS_PATH: + yield from scan_preos_dir_plugins(dir) + + +def find_preoses(): + preoses = {} + for preos in find_preos_plugins(): + if hasattr(preos, _PREOS_NAME): + preos_name = getattr(preos, _PREOS_NAME) + else: + preos_name = preos.__name__.lower() + preoses[preos_name] = preos + return preoses + + +def check_root(): + if os.geteuid() != 0: + raise cdist.Error("Must be run with root privileges") + + +class PreOS(object): + preoses = None + + @classmethod + def commandline(cls, argv): + + if not cls.preoses: + cls.preoses = find_preoses() + + parser = argparse.ArgumentParser( + description="Create PreOS", prog="cdist preos") + parser.add_argument('preos', help='PreOS to create, one of: {}'.format( + set(cls.preoses))) + args = parser.parse_args(argv[1:2]) + + preos_name = args.preos + if preos_name in cls.preoses: + preos = cls.preoses[preos_name] + func = getattr(preos, _PREOS_CALL) + if inspect.ismodule(preos): + func_args = [preos, argv[2:], ] + else: + func_args = [argv[2:], ] + log.info("Running preos : {}".format(preos_name)) + func(*func_args) + else: + log.error("Unknown preos: {}, available preoses: {}".format( + preos_name, set(cls.preoses.keys()))) diff --git a/cdist/preos/debootstrap/__init__.py b/cdist/preos/debootstrap/__init__.py new file mode 100644 index 00000000..6d340b4a --- /dev/null +++ b/cdist/preos/debootstrap/__init__.py @@ -0,0 +1 @@ +from debootstrap.debootstrap import Debian, Ubuntu, Devuan diff --git a/cdist/preos/debootstrap/debootstrap.py b/cdist/preos/debootstrap/debootstrap.py new file mode 100644 index 00000000..617d280b --- /dev/null +++ b/cdist/preos/debootstrap/debootstrap.py @@ -0,0 +1,240 @@ +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +# +# 2016 Darko Poljak (darko.poljak at ungleich.ch) +# +# This file is part of cdist. +# +# cdist is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# cdist is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with cdist. If not, see . +# +# + +import cdist +import cdist.config +import cdist.core +import cdist.preos +import argparse +import cdist.argparse +import logging +import os +import subprocess + + +class Debian(object): + _preos_name = 'debian' + _cdist_preos = True + + _files_dir = os.path.join(os.path.dirname(__file__), "files") + + @classmethod + def default_args(cls): + default_remote_exec = os.path.join(cls._files_dir, "remote-exec.sh") + default_remote_copy = os.path.join(cls._files_dir, "remote-copy.sh") + default_init_manifest = os.path.join( + cls._files_dir, "init-manifest-{}".format(cls._preos_name)) + + defargs = argparse.Namespace() + defargs.arch = 'amd64' + defargs.bootstrap = False + defargs.configure = False + defargs.cdist_params = '-v' + defargs.rm_bootstrap_dir = False + defargs.suite = 'stable' + defargs.remote_exec = default_remote_exec + defargs.remote_copy = default_remote_copy + defargs.manifest = default_init_manifest + + return defargs + + @classmethod + def get_parser(cls): + defargs = cls.default_args() + cdist_parser = cdist.argparse.get_parsers() + parser = argparse.ArgumentParser( + prog='cdist preos {}'.format(cls._preos_name), + parents=[cdist_parser['loglevel'], cdist_parser['beta']]) + parser.add_argument('target_dir', nargs=1, + help=("target directory where PreOS will be " + "bootstrapped")) + parser.add_argument( + '-a', '--arch', + help="target debootstrap architecture, by default '{}'".format( + defargs.arch), dest='arch', default=defargs.arch) + parser.add_argument( + '-B', '--bootstrap', + help='do bootstrap step', + dest='bootstrap', action='store_true', default=defargs.bootstrap) + parser.add_argument( + '-C', '--configure', + help='do configure step', + dest='configure', action='store_true', default=defargs.configure) + parser.add_argument( + '-c', '--cdist-params', + help=("parameters that will be passed to cdist config, by default" + " '{}' is used".format(defargs.cdist_params)), + dest='cdist_params', default=defargs.cdist_params) + parser.add_argument( + '-D', '--drive-boot', + help='create bootable PreOS on specified drive', + dest='drive') + parser.add_argument( + '-e', '--remote-exec', + help=("remote exec that cdist config will use, by default " + "internal script is used"), + dest='remote_exec', default=defargs.remote_exec) + parser.add_argument( + '-i', '--init-manifest', + help=("init manifest that cdist config will use, by default " + "internal init manifest is used"), + dest='manifest', default=defargs.manifest) + parser.add_argument( + '-k', '--keyfile', action="append", + help=("ssh key files that will be added to cdist config; " + "'__ssh_authorized_keys root ...' type is appended to " + "initial manifest"), + dest='keyfile') + parser.add_argument( + '-m', '--mirror', + help='use specified mirror for debootstrap', + dest='mirror') + parser.add_argument( + '-P', '--root-password', + help='Set specified password for root, generated by default', + dest='root_password') + parser.add_argument('-p', '--pxe-boot-dir', help='PXE boot directory', + dest='pxe_boot_dir') + parser.add_argument( + '-r', '--rm-bootstrap-dir', + help='remove target directory after finishing', + dest='rm_bootstrap_dir', action='store_true', + default=defargs.rm_bootstrap_dir) + parser.add_argument( + '-S', '--script', + help='use specified script for debootstrap', + dest='script') + parser.add_argument('-s', '--suite', + help="suite used for debootstrap, " + "by default '{}'".format(defargs.suite), + dest='suite', default=defargs.suite) + parser.add_argument( + '-y', '--remote-copy', + help=("remote copy that cdist config will use, by default " + "internal script is used"), + dest='remote_copy', default=defargs.remote_copy) + parser.epilog = cdist.argparse.EPILOG + + return parser + + @classmethod + def update_env(cls, env): + pass + + @classmethod + def commandline(cls, argv): + log = logging.getLogger(cls.__name__) + + parser = cls.get_parser() + cdist.argparse.add_beta_command(cls._preos_name) + args = parser.parse_args(argv) + if args.script and not args.mirror: + raise cdist.Error("script option cannot be used without " + "mirror option") + + args.command = cls._preos_name + cdist.argparse.check_beta(vars(args)) + + cdist.preos.check_root() + + args.target_dir = os.path.realpath(args.target_dir[0]) + args.os = cls._preos_name + args.remote_exec = os.path.realpath(args.remote_exec) + args.remote_copy = os.path.realpath(args.remote_copy) + args.manifest = os.path.realpath(args.manifest) + if args.keyfile: + new_keyfile = [os.path.realpath(x) for x in args.keyfile] + args.keyfile = new_keyfile + if args.pxe_boot_dir: + args.pxe_boot_dir = os.path.realpath(args.pxe_boot_dir) + + cdist.argparse.handle_loglevel(args) + log.debug("preos: {}, args: {}".format(cls._preos_name, args)) + try: + env = vars(args) + new_env = {} + for key in env: + if key == 'verbose': + if env[key] >= 3: + new_env['debug'] = "yes" + elif env[key] == 2: + new_env['verbose'] = "yes" + elif not env[key]: + new_env[key] = '' + elif isinstance(env[key], bool) and env[key]: + new_env[key] = "yes" + elif isinstance(env[key], list): + val = env[key] + new_env[key + "_cnt"] = str(len(val)) + for i, v in enumerate(val): + new_env[key + "_" + str(i)] = v + else: + new_env[key] = str(env[key]) + env = new_env + env.update(os.environ) + cls.update_env(env) + log.debug("preos: {} env: {}".format(cls._preos_name, env)) + cmd = os.path.join(cls._files_dir, "code") + info_msg = ["Running preos: {}, suite: {}, arch: {}".format( + cls._preos_name, args.suite, args.arch), ] + if args.mirror: + info_msg.append("mirror: {}".format(args.mirror)) + if args.script: + info_msg.append("script: {}".format(args.script)) + if args.bootstrap: + info_msg.append("bootstrapping") + if args.configure: + info_msg.append("configuring") + if args.pxe_boot_dir: + info_msg.append("creating PXE") + if args.drive: + info_msg.append("creating bootable drive") + log.info(info_msg) + log.debug("cmd={}".format(cmd)) + subprocess.check_call(cmd, env=env, shell=True) + except subprocess.CalledProcessError as e: + log.error("preos {} failed: {}".format(cls._preos_name, e)) + + +class Ubuntu(Debian): + _preos_name = "ubuntu" + + @classmethod + def default_args(cls): + defargs = super().default_args() + defargs.suite = 'xenial' + return defargs + + +class Devuan(Debian): + _preos_name = "devuan" + + @classmethod + def default_args(cls): + defargs = super().default_args() + defargs.suite = 'jessie' + return defargs + + @classmethod + def update_env(cls, env): + env['DEBOOTSTRAP_DIR'] = os.path.join(cls._files_dir, + 'devuan-debootstrap') diff --git a/cdist/preos/debootstrap/files/code b/cdist/preos/debootstrap/files/code new file mode 100755 index 00000000..9e37003b --- /dev/null +++ b/cdist/preos/debootstrap/files/code @@ -0,0 +1,274 @@ +#!/bin/sh +## +## 2016 Darko Poljak (darko.poljak at ungleich.ch) +## +## This file is part of cdist. +## +## cdist is free software: you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published by +## the Free Software Foundation, either version 3 of the License, or +## (at your option) any later version. +## +## cdist is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with cdist. If not, see . + +set -e + +if [ "${debug}" ] +then + set -x + cdist_params="${cdist_params} -d" +fi + +bootstrap_dir="${target_dir}" + +case "${os}" in + ubuntu|debian|devuan) + # nothing, those are valid values + ;; + *) + echo "ERROR: invalid os value: ${os}" >&2 + exit 1 + ;; +esac + +check_bootstrap_dir() { + if [ ! -e "$1" ] + then + echo "ERROR: bootstrap directory $1 does not exist" >&2 + exit 1 + fi +} + +# bootstrap +if [ "${bootstrap}" ] +then + if [ "${DEBOOTSTRAP_DIR}" ] + then + debootstrap_cmd="${DEBOOTSTRAP_DIR}/debootstrap" + else + command -v debootstrap 2>&1 > /dev/null || { + echo "ERROR: debootstrap not found" >&2 + exit 1 + } + debootstrap_cmd="debootstrap" + fi + + # If PreOS on drive then do not check for directory emptiness. + # Partition can at least contain 'lost+found' directory. + if [ ! "${drive}" ] + then + if [ -e "${bootstrap_dir}" ] + then + dir_content=$(ls -A "${bootstrap_dir}" | wc -l) + else + dir_content=0 + fi + if [ "${dir_content}" -ne 0 ] + then + echo "ERROR: "${bootstrap_dir}" not empty " >&2 + exit 1 + fi + fi + + if [ "${verbose}" -o "${debug}" ] + then + echo "bootstrapping..." + fi + mkdir -p "${bootstrap_dir}" + "${debootstrap_cmd}" --include=openssh-server --arch=${arch} ${suite} ${bootstrap_dir} \ + ${mirror} ${script} + if [ "${verbose}" -o "${debug}" ] + then + echo "bootstrap finished" + fi +fi + +chroot_mount() { + mount -t proc none "${bootstrap_dir}/proc" || true + mount -t sysfs none "${bootstrap_dir}/sys" || true + mount -o bind /dev "${bootstrap_dir}/dev" || true + mount -t devpts none "${bootstrap_dir}/dev/pts" || true +} + +chroot_umount() { + umount "${bootstrap_dir}/dev/pts" || true + umount "${bootstrap_dir}/dev" || true + umount "${bootstrap_dir}/sys" || true + umount "${bootstrap_dir}/proc" || true +} + +TRAPFUNC="umount \"${bootstrap_dir}/dev/pts\" || true; \ +umount \"${bootstrap_dir}/dev\" || true; \ +umount \"${bootstrap_dir}/sys\" || true; \ +umount \"${bootstrap_dir}/proc\" || true;" + +# config +if [ "${configure}" ] +then + if [ ! -f "${manifest}" ] + then + echo "ERROR: ${manifest} does not exist" >&2 + exit 1 + fi + if [ ! -f "${remote_exec}" ] + then + echo "ERROR: ${remote_exec} does not exist" >&2 + exit 1 + fi + if [ ! -f "${remote_copy}" ] + then + echo "ERROR: ${remote_copy} does not exist" >&2 + exit 1 + fi + + if [ "${keyfile_cnt}" -a "${keyfile_cnt}" -gt 0 ] + then + i="$((keyfile_cnt - 1))" + keyfiles="" + while [ "${i}" -ge 0 ] + do + kf_var="keyfile_${i}" + eval kf='$'"${kf_var}" + if [ ! -f "${kf}" ] + then + echo "ERROR: ${kf} does not exist" >&2 + exit 1 + fi + key=$(cat "${kf}") + keyfiles="${keyfiles} --key '${key}'" + i=$((i - 1)) + done + ssh_auth_keys_line="__ssh_authorized_keys root ${keyfiles}\n" + else + ssh_auth_keys_line="" + fi + + check_bootstrap_dir "${bootstrap_dir}" + + if [ "${verbose}" -o "${debug}" ] + then + echo "configuring..." + fi + + trap "${TRAPFUNC}" 0 1 2 3 15 + + chroot_mount + + chroot "${bootstrap_dir}" /usr/bin/apt-get update + + if [ "${drive}" ] + then + grub_manifest_line="__package grub-pc --state present\n" + grub_kern_params_line="__line linux_kernel_params \ +--file /etc/default/grub \ +--line 'GRUB_CMDLINE_LINUX_DEFAULT=\"quiet splash net.ifnames=0\"'\n" + else + grub_manifest_line="" + grub_kern_params_line="" + fi + grub_lines="${grub_manifest_line}${grub_kern_params_line}" + + printf "${ssh_auth_keys_line}${grub_lines}" \ + | cat "${manifest}" - |\ + cdist config \ + ${cdist_params} -i - \ + --remote-exec "${remote_exec}" \ + --remote-copy "${remote_copy}" \ + "${bootstrap_dir}" + + # __hostname with systmed uses hostnamectl which needs dbus running + # set hostname explicitly here instead + printf "preos\n" > "${bootstrap_dir}/etc/hostname" + + chroot "${bootstrap_dir}" /usr/bin/apt-get autoclean + chroot "${bootstrap_dir}" /usr/bin/apt-get clean + chroot "${bootstrap_dir}" /usr/bin/apt-get autoremove + + chroot_umount + + trap - 0 1 2 3 15 + + if [ "${verbose}" -o "${debug}" ] + then + echo "configuring finished" + fi +fi + +if [ "${pxe_boot_dir}" ] +then + check_bootstrap_dir "${bootstrap_dir}" + + if [ "${verbose}" -o "${debug}" ] + then + echo "creating pxe..." + fi + + mkdir -p "${pxe_boot_dir}" + cp "${bootstrap_dir}"/boot/vmlinuz-* "${pxe_boot_dir}/kernel" + cd "${bootstrap_dir}" + find . -print0 | cpio --null -o --format=newc | gzip -9 > "${pxe_boot_dir}/initramfs" + + mkdir -p "${pxe_boot_dir}/pxelinux.cfg" + cat < "${pxe_boot_dir}/pxelinux.cfg/default" + DEFAULT preos + LABEL preos + KERNEL kernel + APPEND utf8 load_ramdisk=1 root=/dev/ram nofb initrd=initramfs console=ttyS1,115200 net.ifnames=0 +EOPXEF + + cp "${bootstrap_dir}/usr/lib/PXELINUX/pxelinux.0" "${pxe_boot_dir}/pxelinux.0" + cp "${bootstrap_dir}/usr/lib/syslinux/modules/bios/ldlinux.c32" \ + "${pxe_boot_dir}/ldlinux.c32" + # network boot need all files world readable + chmod -R 644 "${pxe_boot_dir}"/* + + if [ "${verbose}" -o "${debug}" ] + then + echo "pxe creation finished" + fi +fi + +if [ "${drive}" ] +then + trap "${TRAPFUNC}" 0 1 2 3 15 + chroot_mount + chroot "${bootstrap_dir}" grub-install ${drive} + chroot "${bootstrap_dir}" /bin/sh -c "GRUB_DISABLE_OS_PROBER=true update-grub" + # set root password + if [ ! "${root_password}" ] + then + if ! which strings >/dev/null 2>&1 + then + printf "strings is missing\n" >&2 + exit 1 + fi + root_password="$(head -n 1000 /dev/urandom | strings | \ + grep -o '[[:alnum:]]' | head -n 30 | tr -d '\n')" + printf "Generated root password (without quotes):'${root_password}'\n" + fi + chroot "${bootstrap_dir}" /bin/sh -c "echo \"root:${root_password}\" | \ + chpasswd" + # /etc/securetty must not be world writeable. + chmod 644 "${bootstrap_dir}"/etc/securetty + chroot_umount + trap - 0 1 2 3 15 +fi + +if [ "${rm_bootstrap_dir}" ] +then + if [ "${verbose}" -o "${debug}" ] + then + echo "removing bootstrap dir..." + fi + rm -r -f "${bootstrap_dir}" + if [ "${verbose}" -o "${debug}" ] + then + echo "removing bootstrap dir finished" + fi +fi diff --git a/cdist/preos/debootstrap/files/devuan-debootstrap/Makefile b/cdist/preos/debootstrap/files/devuan-debootstrap/Makefile new file mode 100644 index 00000000..85168031 --- /dev/null +++ b/cdist/preos/debootstrap/files/devuan-debootstrap/Makefile @@ -0,0 +1,18 @@ +# avoid dpkg-dev dependency; fish out the version with sed +VERSION := $(shell sed 's/.*(\(.*\)).*/\1/; q' debian/changelog) + +all: + +clean: + +DSDIR=$(DESTDIR)/usr/share/debootstrap +install: + mkdir -p $(DSDIR)/scripts + mkdir -p $(DESTDIR)/usr/sbin + + cp -a scripts/* $(DSDIR)/scripts/ + install -o root -g root -m 0644 functions $(DSDIR)/ + + sed 's/@VERSION@/$(VERSION)/g' debootstrap >$(DESTDIR)/usr/sbin/debootstrap + chown root:root $(DESTDIR)/usr/sbin/debootstrap + chmod 0755 $(DESTDIR)/usr/sbin/debootstrap diff --git a/cdist/preos/debootstrap/files/devuan-debootstrap/README b/cdist/preos/debootstrap/files/devuan-debootstrap/README new file mode 100644 index 00000000..4d8c3049 --- /dev/null +++ b/cdist/preos/debootstrap/files/devuan-debootstrap/README @@ -0,0 +1,65 @@ +README for debootstrap +====================== + +See the manpage for (some) documentation. + +Running debootstrap from source +------------------------------- + +You can run debootstrap from its source tree without installing it. This +can be useful if you want a quick way to make a Debian chroot on another +system, or if you are testing modifications to debootstrap. + +First, get the source. + +* Either by using git + git clone https://anonscm.debian.org/git/d-i/debootstrap.git + +* Or by visiting + and downloading the tar.gz file + +Then in the debootstrap source directory: + + export DEBOOTSTRAP_DIR=`pwd` + sudo ./debootstrap stable my-stable-dir + +If you are running a multi-stage boot strap (for example for a QEMU +rootfs) you don't even need root: + + export DEBOOTSTRAP_DIR=`pwd` + fakeroot ./debootstrap --foreign --arch=armhf testing my-testing-dir http://deb.debian.org/debian + +Of course you will need to execute the second stage as root to finish the bootstrap: + + (on foreign hardware) + /debootstrap/debootstrap --second-stage + + +Future +------ + + * Cross-strap support - so you can bootstrap a filesystem to the + point where it will successfully boot, and finish installing itself + without having to be running the target architecture or OS yourself. + + debootstrap --arch powerpc sarge ./sarge-ppc-chroot ... + + on an i386 system, boot a powerpc box with sarge-ppc-chroot as its + root files system, and have it "work". The cross-hurd package does + something similar, and should be replaced by this feature. + + * There should be some (better) way of telling debootstrap what "base" + packages you want to install -- this varies between making a chroot, + doing an install, and doing a buildd. Also, some installs want + different base packages (to setup networking, or kernels, eg) + + +NMUing +------ + +If there's a problem with debootstrap that you need fixed, feel free to do +an NMU to fix it. Usual rules: try not to break anything, and mail the +patch to the BTS. Don't worry about asking first though. + +However, note that debootstrap is now team maintained. Anyone in d-i can do +a release without the bother of a NMU. diff --git a/cdist/preos/debootstrap/files/devuan-debootstrap/TODO b/cdist/preos/debootstrap/files/devuan-debootstrap/TODO new file mode 100644 index 00000000..e5fde0e4 --- /dev/null +++ b/cdist/preos/debootstrap/files/devuan-debootstrap/TODO @@ -0,0 +1,11 @@ + +Features: + ++ second stage via chroot debootstrap/debootstrap + ++ debootstrap/deb file to record deb destinations/information + + -- configuration file + -- versus command line + -- support for sources (vs mirrors) + -- faux-pinning for packages + + ++ makedev in second stage diff --git a/cdist/preos/debootstrap/files/devuan-debootstrap/debian/.gitignore b/cdist/preos/debootstrap/files/devuan-debootstrap/debian/.gitignore new file mode 100644 index 00000000..39638d97 --- /dev/null +++ b/cdist/preos/debootstrap/files/devuan-debootstrap/debian/.gitignore @@ -0,0 +1,6 @@ +debootstrap +debootstrap-udeb +files +*.debhelper.log +*.substvars + diff --git a/cdist/preos/debootstrap/files/devuan-debootstrap/debian/README.DevuanSource b/cdist/preos/debootstrap/files/devuan-debootstrap/debian/README.DevuanSource new file mode 100644 index 00000000..6446a088 --- /dev/null +++ b/cdist/preos/debootstrap/files/devuan-debootstrap/debian/README.DevuanSource @@ -0,0 +1,15 @@ +To sync up with debians source for inspiration you should run the following: + + `git remote add alioth-git git://anonscm.debian.org/d-i/debootstrap.git` + `git fetch alioth-git` + +After that you can either cherry-pick or merge releases from debian. To +merge a release, it's do: + `git tag` to list the release tags +and + `git merge ` +followed by all the fixups and then commit with an appropriate message like + "Merging Release from debian" + +Copyright 2016 Daniel Reurich + diff --git a/cdist/preos/debootstrap/files/devuan-debootstrap/debian/changelog b/cdist/preos/debootstrap/files/devuan-debootstrap/debian/changelog new file mode 100644 index 00000000..8688197d --- /dev/null +++ b/cdist/preos/debootstrap/files/devuan-debootstrap/debian/changelog @@ -0,0 +1,2655 @@ +debootstrap (1.0.87+devuan1.1) unstable; urgency=medium + + * add git to builddeps + + -- Daniel Reurich Fri, 13 Jan 2017 23:12:50 +1300 + +debootstrap (1.0.87+devuan1.0) unstable; urgency=high + + [ Julien Cristau ] + * Default to split /usr again, as merged-/usr breaks dpkg-shlibdeps + (closes: #844221). + + [ Riku Voipio ] + * remove scratchbox2 support (closes: #796189) + + -- Christian Perrier Wed, 16 Nov 2016 06:47:27 +0100 + +debootstrap (1.0.86+devuan1.0) unstable; urgency=high + + [ Daniel Reurich ] + * Restore Devuan Jessie version + * switch to 3.0 (git) source format + * set git-depth + * Add directions for inspiration from debians source + * removed file so we can build using git source format + * merge 1.0.86 for jessie + + -- Daniel Reurich Fri, 13 Jan 2017 15:58:19 +1300 + +debootstrap (1.0.86) unstable; urgency=high + + * Rework split_inline_sig by using shell built-ins instead of trying to + mix sed and tr together, which might work on regular systems but not + from inside the Debian Installer (Closes: #842591). Thanks to Ansgar + Burchardt for the proof of concept! + + -- Cyril Brulebois Sun, 30 Oct 2016 23:35:45 +0100 + +debootstrap (1.0.85-1+devuan1) unstable; urgency=medium + + * sync with debian upstream package + * add right keyrings with the new schema on devuan-keyring package + + -- Franco (nextime) Lanza Sat, 29 Oct 2016 23:21:57 +0200 + + +debootstrap (1.0.85) unstable; urgency=medium + + [ Julien Cristau ] + * Add support for downloading and validating InRelease files, by splitting + up detached signature from signed data. + * Switch default mirror to deb.debian.org. + + [ Colin Watson ] + * Add (Ubuntu) zesty as a symlink to gutsy. + + [ Ansgar Burchardt ] + * Add jessie-kfreebsd to merged-/usr blacklist. + * No longer Build-Depend on makedev. The code using it was already + removed in debootstrap 1.0.82. + * Do not use `tar -k` for older releases which might have file + conflicts between the packages to be installed. (Closes: #838388) + * Error out when seeing short options. (Closes: #548880) + * Add oldoldstable -> sid script symlink. (Closes: #792734) + * Add buster -> sid and bullseye -> sid script symlinks. + * Only unpack and configure the base system when there are actually + packages to install. (Closes: #825034) + * debootstrap.8: Use stretch instead of wheezy in examples. + + [ Marco d'Itri ] + * Enable merged-/usr by default. (Closes: #839046) + + -- Julien Cristau Fri, 21 Oct 2016 20:22:49 +0200 + +debootstrap (1.0.84) unstable; urgency=medium + + [ Ansgar Burchardt ] + * Add support for xz-compressed Packages indices. (Closes: #837649) + + -- Christian Perrier Thu, 06 Oct 2016 06:59:38 +0200 + +debootstrap (1.0.83) unstable; urgency=medium + + [ Ansgar Burchardt ] + * functions: Validate that the requested suite is listed in the + Release file's Suite or Codename field. (Closes: #837075) + * Add support for merged-/usr, enabled by a new --merged-usr option. + (Closes: #810301) + * Feign install of dpkg in second stage. This avoids problems when + using dpkg-deb together with busybox' tar. (Closes: #837185) + * README: Use https://. + + [ Steve McIntyre ] + * Update Standards-Version to 3.9.8 (no changes needed) + + -- Steve McIntyre <93sam@debian.org> Tue, 13 Sep 2016 13:16:41 +0100 + +debootstrap (1.0.82) unstable; urgency=medium + + [ Alex Bennée ] + * Excise all devices.tar.gz code. Closes: #830869 + + -- Christian Perrier Thu, 08 Sep 2016 07:09:56 +0200 + +debootstrap (1.0.81) unstable; urgency=medium + + [ Luca Falavigna ] + * Add (Ubuntu) yakkety as a symlink to gutsy. + + -- Christian Perrier Tue, 03 May 2016 06:51:57 +0200 + +debootstrap (1.0.80-1+devuan1) unstable; urgency=medium + + * sync with debian upstream package. + + -- Franco (nextime) Lanza Sun, 24 Apr 2016 06:16:29 +0200 + +debootstrap (1.0.80) unstable; urgency=medium + + [ Jon Boden ] + * scripts/gutsy: Support kfreebsd & hurd arches on Ubuntu targets + (closes: #818748) + + -- Christian Perrier Tue, 22 Mar 2016 19:27:45 +0100 + +debootstrap (1.0.79) unstable; urgency=medium + + [ Samuel Thibault ] + * hurd: move setting up dev and servers firmlink to setup_proc stage. Also + firmlink proc there. Thanks Gabriele Giacone for all the investigation! + (Closes: #768102) + + -- Christian Perrier Fri, 19 Feb 2016 07:23:59 +0100 + +debootstrap (1.0.78+nmu1) unstable; urgency=medium + + * Non-maintainer upload. + * Split setup_devices in setup_devices (which now only deals with static + device nodes) and setup_dynamic_devices, and move the calls to + setup_devices from the beginning of the second stage to the end of the + first stage. + setup_dynamic_devices mounts the appropriate filesystems which provide + dynamic device nodes for the architectures which need one in + debootstrap (kfreebsd and hurd). + This fixes a bug in --second-stage introduced in 1.0.34 and exposed + by the devices-related changes of 1.0.76: the second stage debootstrap + runs "dpkg --print-architecture >/dev/null" at the very beginning of + the program when /dev is still empty, so it creates an empty regular + file in place of /dev/null and this will cause mknod to fail later. + (Closes: #813232) + + -- Marco d'Itri Wed, 17 Feb 2016 01:23:23 +0100 + +debootstrap (1.0.78) unstable; urgency=high + + * Use HTTPS for Vcs-* URLs, and link to cgit rather than gitweb. + * Don't call mknod with the --mode option, it's not supported in + busybox. Use -m instead - fixes the broken fix for #812811. + Closes: #813124. Urgency high to get this fix propagated quickly - + it's breaking d-i installs right now. Adding myself to uploaders and + uploading. + + -- Steve McIntyre <93sam@debian.org> Fri, 29 Jan 2016 16:36:00 +0000 + +debootstrap (1.0.77) unstable; urgency=medium + + [ Marco d'Itri ] + * Fix permissions on device nodes (Closes: #812811). + + -- Cyril Brulebois Wed, 27 Jan 2016 20:22:05 +0100 + +debootstrap (1.0.76) unstable; urgency=medium + + [ Marco d'Itri ] + * Stop creating useless device nodes (Closes: #571136). + + -- Cyril Brulebois Sun, 24 Jan 2016 08:55:18 +0100 + +debootstrap (1.0.75-1+devuan1) unstable; urgency=medium + + * sync with debian upstream package + + -- Franco (nextime) Lanza Wed, 02 Dec 2015 04:05:36 +0100 + +debootstrap (1.0.75) unstable; urgency=medium + + * Stop cleaning KEEP_DEBOOTSTRAP_DIR twice, as spotted by Chris Lamb + (Closes: #804415). + * Add Tanglu support (Closes: #771687), thanks to Matthias Klumpp. At + the moment, the following extra suites are recognized: + - aequorea + - bartholomea + - chromodoris + - dasyatis + + -- Cyril Brulebois Wed, 11 Nov 2015 18:49:28 +0100 + +debootstrap (1.0.74) unstable; urgency=medium + + [ Colin Watson ] + * Add (Ubuntu) xenial as a symlink to gutsy. + + -- Christian Perrier Tue, 03 Nov 2015 07:09:23 +0100 + +debootstrap (1.0.73) unstable; urgency=medium + + * Generate a deburis file with (package, version, uri) tuples, similar + to the existing debpaths. + + -- Cyril Brulebois Thu, 22 Oct 2015 12:43:35 +0200 + +debootstrap (1.0.72-1+devuan1) unstable; urgency=medium + + * Rebase on debian 1.0.70 debootstrap version + * Added Daniel Reurich in Uploaders + * Integrating Daniel Reurich patches for d-i + * Updated manpage with Daniel Reurich changes + + -- Franco (nextime) Lanza Thu, 21 May 2015 05:45:36 +0200 + +debootstrap (1.0.72) unstable; urgency=medium + + [ Iain Lane ] + * Add (Ubuntu) wily as a symlink to gutsy (closes: #787117). + + [ Colin Watson ] + * Fix resolve_deps and setup_available to work in the --foreign case + (closes: #757819, LP: #1450980). + + -- Colin Watson Tue, 28 Jul 2015 14:32:19 +0100 + +debootstrap (1.0.71-1+devuan1) unstable; urgency=medium + + * make devuan-baseconf and devuan-keyring requireds packages + * make sure we have sysvinit-core and not systemd in the chroot + + -- Franco (nextime) Lanza Fri, 01 May 2015 02:13:04 +0200 + +debootstrap (1.0.71) unstable; urgency=medium + + * Adjust sed call to render it more portable (missing ';'), making it + work with FreeBSD sed. Thanks to Nikolai Lifanov for the report and + the patch (Closes: #791802). + + -- Cyril Brulebois Fri, 10 Jul 2015 01:29:52 +0200 + +debootstrap (1.0.70-1+devuan1) unstable; urgency=medium + + * Debianization of debootstrap. + * added ceres script and link jessie and ascii to it + + -- Franco (nextime) Lanza Sat, 11 Apr 2015 08:03:36 +0200 + +debootstrap (1.0.70) unstable; urgency=medium + + * Use tr instead of (missing in d-i) xargs (Closes: #785693). Thanks, + Julian Schauder! + + -- Cyril Brulebois Tue, 19 May 2015 11:38:27 +0200 + +debootstrap (1.0.69-1+devuan1) unstable; urgency=medium + + * Fix package description. + + -- Franco (nextime) Lanza Sat, 07 Mar 2015 21:31:07 +0100 + +debootstrap (1.0.69) unstable; urgency=medium + + [ Cyril Brulebois ] + * Make sure to deduplicate package list in download_release to avoid + issues while counting downloaded packages. The failure path could lead + to printing some strange integer (Closes: #709751, #768445, #785276, + #774752). + This was reported to mostly happen whenever --no-resolve-deps is used. + * Add support for --force-check-gpg so that one can programmatically + make sure keyring checks are used and that no fallback to an https + mirror happens (Closes: #661501, #733179, #775454). + * Switch default mirror from ftp.us.debian.org to the new, official + http redirector service: httpredir.debian.org + * Make it possible to override the MAKEDEV variable (Closes: #734743). + Thanks, Wookey! + + [ Christian Perrier ] + * Update Standards to 3.9.6 (checked) + + -- Christian Perrier Mon, 18 May 2015 14:07:43 +0200 + +debootstrap (1.0.68-2+devuan1) unstable; urgency=medium + + * Added missing symlink. + + -- Franco (nextime) Lanza Sat, 07 Mar 2015 21:18:26 +0100 + +debootstrap (1.0.68-1+devuan1) unstable; urgency=medium + + * Added script for ascii. + + -- Franco (nextime) Lanza Sat, 07 Mar 2015 11:47:02 +0100 +debootstrap (1.0.68) unstable; urgency=medium + + [ Steven Chamberlain ] + * Support the jessie-kfreebsd suite, by using the same script as + jessie (a symlink to sid) (Closes: #784927). + + -- Christian Perrier Mon, 11 May 2015 07:46:19 +0200 + +debootstrap (1.0.67-1+devuan2) unstable; urgency=medium + + * Switch to quilt format + + -- Franco (nextime) Lanza Tue, 03 Mar 2015 07:44:11 +0100 + +debootstrap (1.0.67+devuan1) unstable; urgency=medium + + * Applied init freedom patch (debian bug 668001) + * moved to devuan + + -- Franco (nextime) Lanza Tue, 03 Mar 2015 07:09:36 +0100 + +debootstrap (1.0.67) unstable; urgency=medium + + [ Cyril Brulebois ] + * Apply patch by Jérémy Bobbio to support reproducible builds: specify + a modification time on the tar side, and add the -n option to gzip + (Closes: #774069). Thanks, Jérémy! + * Update setup_apt_sources to look at USE_COMPONENTS if COMPONENTS is + empty, fixing the empty sources.list bug with foreign architectures + (Closes: #732255, #773867). + + -- Christian Perrier Wed, 14 Jan 2015 07:03:17 +0100 + +debootstrap (1.0.66) unstable; urgency=low + + [ Cyril Brulebois ] + * Specify gzip compression in debian/source/options to allow for better + portability on other platforms (Closes: #770214). Thanks, Joey Hess! + * Specify gzip compression for debootstrap, and xz for debootstrap-udeb, + to mitigate the need for xz on non-Debian platforms (see: #770217). + + -- Christian Perrier Mon, 24 Nov 2014 09:15:50 +0100 + +debootstrap (1.0.65) unstable; urgency=medium + + [ Julien Cristau ] + * Add support for stretch. + + -- Christian Perrier Mon, 10 Nov 2014 09:24:56 +0100 + +debootstrap (1.0.64) unstable; urgency=medium + + * Add (Ubuntu) vivid as a symlink to gutsy. + + -- Colin Watson Mon, 20 Oct 2014 16:48:49 +0100 + +debootstrap (1.0.63) unstable; urgency=medium + + [ Joey Hess ] + * Move set -e out of shebang line. Closes: #762713 + + -- Christian Perrier Thu, 25 Sep 2014 06:44:16 +0200 + +debootstrap (1.0.62) unstable; urgency=medium + + [ Cyril Brulebois ] + * Fix reporting of package version in retrieval and validation steps + to cope with epochs. + + -- Christian Perrier Mon, 15 Sep 2014 11:40:54 +0200 + +debootstrap (1.0.61) unstable; urgency=medium + + * Fix "possibly the package $pkg is at fault" warnings to account for + changed error output in dpkg 1.17.2. + + -- Colin Watson Sun, 31 Aug 2014 22:07:49 +0100 + +debootstrap (1.0.60) unstable; urgency=medium + + [ Adam Conrad ] + * Add (Ubuntu) utopic as a symlink to gutsy. + + [ Guillem Jover ] + * Sync deb support with latest dpkg-deb (closes: #739136): + - Add uncompressed data.tar deb member support. + - Add uncompressed and xz control.tar deb member support. + + -- Colin Watson Tue, 06 May 2014 09:37:34 +0100 + +debootstrap (1.0.59) unstable; urgency=medium + + * Install ca-certificates as well as apt-transport-https for HTTPS + installations. This makes it possible to copy certificates that were + built into the installer to /usr/local/share/ca-certificates/ and thus + have them continue to be trusted after installation. + + -- Colin Watson Thu, 13 Feb 2014 13:42:54 +0000 + +debootstrap (1.0.58) unstable; urgency=medium + + * Policy version 3.9.5: no changes required. + * Install apt-transport-https if installing from an HTTPS mirror + (LP: #1135163). It may still be necessary to copy certificates into + place, but there's at least a reasonable chance that somebody installing + from HTTPS may want to keep using it, and we have to install + apt-transport-https at this point otherwise they won't be able to do + that end-to-end. + + -- Colin Watson Tue, 11 Feb 2014 17:46:41 +0000 + +debootstrap (1.0.57) unstable; urgency=medium + + * pkgdetails_perl: Only interpret percentages following whitespace, to + cope with GNU wget outputting the local file name (which may contain "%" + due to URL-encoding) after it finishes the download (LP: #1172101). + + -- Colin Watson Fri, 07 Feb 2014 16:12:23 +0000 + +debootstrap (1.0.56) unstable; urgency=low + + [ Tollef Fog Heen ] + * Install base-passwd and base-files in two calls rather than one to + avoid problems with home-built media with different ordering in + Packages. Thanks to Jo Shields for pointing this out and providing + the workaround. Closes: #601670. LP: #1001131. + + [ Joey Hess ] + * When deboostrapping Debian, and the debian-archive-keyring is not + available, switch the default mirror to a https url. This way at + least the CA level of security is available even for users who + have no way to check gpg keys in the WoT. The https mirror is + currently https://mirrors.kernel.org/debian. + * Avoid writing https urls into sources.list, as apt does not support https. + + -- Christian Perrier Mon, 30 Dec 2013 08:00:41 +0100 + +debootstrap (1.0.55) unstable; urgency=low + + [ Matthias Klose ] + * Add (Ubuntu) trusty as a symlink to gutsy. + + -- Christian Perrier Tue, 22 Oct 2013 13:43:23 +0200 + +debootstrap (1.0.53) unstable; urgency=low + + [ Dmitrijs Ledkovs ] + * Set debian source format to '3.0 (native)'. + * Bump debhelper compat level to 9. + * Set Vcs-* to canonical format. + + [ Christian Perrier ] + * Update Standards to 3.9.4 (checked) + + -- Christian Perrier Sun, 14 Jul 2013 13:06:33 +0200 + +debootstrap (1.0.52) unstable; urgency=low + + * scripts/gutsy: Make the fake initctl pass through "initctl version" + calls, used by such things as invoke-rc.d to figure out whether it's + running under Upstart (LP: #1182540). + * scripts/sid, scripts/gutsy: Add a policy-rc.d, matching that in + debian-installer-utils. This is the primary way to disable daemon + startup. + + -- Colin Watson Wed, 22 May 2013 16:55:59 +0100 + +debootstrap (1.0.51) unstable; urgency=low + + [ Scott Kitterman ] + * Add (Ubuntu) saucy as a symlink to gutsy (closes: #706989). + + [ Colin Watson ] + * Clarify location of pkgdetails.c in error message (closes: #708771). + * Resolve mount point symlinks relative to the target chroot before + unmounting them (closes: #702861, #703037, #704744). + + -- Colin Watson Sat, 18 May 2013 23:18:08 +0100 + +debootstrap (1.0.50) unstable; urgency=low + + [ Hector Oron ] + * Report package version information on package retrieve and validation. + Closes: #697675 + + -- Christian Perrier Fri, 17 May 2013 13:34:34 +0200 + +debootstrap (1.0.49) unstable; urgency=medium + + * Add support for jessie. Closes: #706788 + + -- Joey Hess Sat, 04 May 2013 23:37:52 -0400 + +debootstrap (1.0.48) unstable; urgency=low + + * Team upload + + [ Julien Cristau ] + * Disable InRelease support. gpgv won't give us back the signed data, and + full gpg is not available inside d-i (closes: #703889). + * Move extract_release_components to after signature verification. + Suggested by Ansgar Burchardt. + + -- Didier Raboud Thu, 04 Apr 2013 16:17:57 +0200 + +debootstrap (1.0.47) unstable; urgency=low + + * Team upload + * Properly decrypt the InRelease file when downloading from an archive + where InRelease is used. This longstanding bug was masked by former + APT behaviour and was revealed only with recent APT versions + Closes: #703146 + Thanks to Michael Vogt for the analysis and patch + * Add a dependency on gpg because of the above change. + + -- Christian Perrier Wed, 20 Mar 2013 21:34:29 +0100 + +debootstrap (1.0.46) unstable; urgency=low + + * Team upload. + * Use `which` to find out sh only if /bin/sh does not exist. + + -- Samuel Thibault Thu, 27 Dec 2012 15:47:16 +0100 + +debootstrap (1.0.45) unstable; urgency=low + + [ Joey Hess ] + * Better support use on Android by not hardcoding /bin/sh + in a test file that's created, and instead putting in the + actual path to sh. Closes: #694310 Thanks, Shawn Landden + + -- Christian Perrier Sat, 22 Dec 2012 12:56:32 +0100 + +debootstrap (1.0.44) unstable; urgency=low + + * Remove double quotes to fix for loop on GNU/kFreeBSD, thanks to + Oleg Ginzburg (Closes: #693718). + + -- Cyril Brulebois Tue, 20 Nov 2012 23:55:53 +0100 + +debootstrap (1.0.43) unstable; urgency=low + + [ Joey Hess ] + * Fix "arc" typo. Closes: #686680 + + [ Colin Watson ] + * Add (Ubuntu) raring as a symlink to gutsy. + + [ Christian Perrier ] + * Add myself to Uploaders and drop Anthony Towns who is no + longer active in debootstrap maintenance for a few years. Thanks + for your work, Anthony. + * Bump Standards to 3.9.3 (checked) + * Replace XC-Package-Type by Package-Type in debian/control + + -- Christian Perrier Sat, 27 Oct 2012 12:46:46 +0200 + +debootstrap (1.0.42) unstable; urgency=low + + * Downgrade the absence of an InRelease file from a warning to an info + message. For now, debootstrap can cope fine without, and it's possible + there are Debian mirrors that don't have InRelease; Ubuntu doesn't quite + have InRelease support yet either (LP: #1017398). + + -- Colin Watson Tue, 03 Jul 2012 15:34:57 +0100 + +debootstrap (1.0.41) unstable; urgency=low + + [ Mehdi Dogguy ] + * Add support for InRelease files (Closes: #638682) + + -- Joey Hess Thu, 21 Jun 2012 13:16:22 -0400 + +debootstrap (1.0.40) unstable; urgency=low + + [ Joey Hess ] + * When installation or configuration of a package fails, output a message + that points the user to the log file. Attempt to grep out the first + package that dpkg failed on and show its name too. Closes: #472704 + + [ Colin Watson ] + * Add (Ubuntu) quantal as a symlink to gutsy. + + -- Colin Watson Thu, 26 Apr 2012 17:44:44 +0100 + +debootstrap (1.0.39) unstable; urgency=low + + * Retry corrupted downloads rather than carrying on almost regardless. + Patch mostly due to Michael Gilbert, rearranged somewhat by me (closes: + #618920). + * Stop at the end of the retrieval phase if any packages failed to + download. + + -- Colin Watson Tue, 13 Mar 2012 17:21:13 +0000 + +debootstrap (1.0.38) unstable; urgency=low + + [ Joey Hess ] + * Improve error message when a decompressor is not available, + to indicate which package has been built with bzip today. + Closes: #644719 + + [ Otavio Salvador ] + * Fix --print-debs support when using --foreign param. Closes: + #551837. + + [ Colin Watson ] + * pkgdetails_perl: Use the last of a sequence of stanzas for the same + package name, rather than the first (closes: #649319). + + -- Colin Watson Mon, 21 Nov 2011 13:20:53 +0000 + +debootstrap (1.0.37) unstable; urgency=low + + * Add (Ubuntu) precise as a symlink to gutsy. + + -- Colin Watson Wed, 05 Oct 2011 21:58:37 +0100 + +debootstrap (1.0.36) unstable; urgency=low + + * Guess host OS based on uname for non-Debian systems. Closes: #637363 + * Clarify "target" in usage message. + * Fix support for running debootstrap on a FreeBSD host to create a kFreeBSD + chroot or jail. Thanks, Arno Toell. + * Search PATH for programs, rather than checking hardcoded locations. + * Support using md5 and shaN programs, as found on FreeBSD, in addition + to md5sum and shaNsum. + * When FreeBSD (not kfreebsd) is the host, don't chroot to mount special + filesystems. + * When debootstrapping on FreeBSD, warn if necessary modules are not + loaded. Thanks, Arno Toell. + * Workaround for umount bug #634107, which broke pbuilder and "debootstrap ." + Closes: #631087 + + -- Joey Hess Sun, 21 Aug 2011 18:39:26 -0400 + +debootstrap (1.0.35) unstable; urgency=low + + [ Robert Millan ] + * Don't build devices.tar.gz if building on GNU/kFreeBSD (closes: + #637297). + * Don't use --arch when we specifically care about the host architecture + (closes: #637298). + + -- Colin Watson Wed, 10 Aug 2011 13:04:41 +0100 + +debootstrap (1.0.34) unstable; urgency=low + + * Add more information regarding the version and architecture in case + a download fails. Closes: #633625. + * add /usr/sbin and /sbin to PATH for fakechroot variant. Closes: + #588773 + * Move setup_devices to second stage of bootstrap. Closes: #498731, + #531316 + + -- Otavio Salvador Thu, 28 Jul 2011 19:13:10 +0200 + +debootstrap (1.0.33) unstable; urgency=low + + [ Joey Hess ] + * Mention minbase variant in --help. Closes: #632418 + * Use md5sums for sarge, which did not consistently have sha1sums + everywhere. Closes: #633158 + + [ Colin Watson ] + * Improve text of error message when decompression command is not + available. + + -- Otavio Salvador Sun, 24 Jul 2011 10:33:56 +0200 + +debootstrap (1.0.32) unstable; urgency=low + + * Use md5sums for woody and potato, which only had those checksums + in the Packages files. Closes: #627365 + + -- Joey Hess Mon, 30 May 2011 13:57:46 -0400 + +debootstrap (1.0.31) unstable; urgency=low + + [ Mark Hymers ] + * Don't use the Build-Essential: yes field in Debian, use the + build-essential package. Closes: #619700. + + [ Colin Watson ] + * If ubuntu-keyring is installed, check Release signatures against it when + bootstrapping Ubuntu gutsy and later. + * Recommend ubuntu-keyring rather than debian-archive-keyring on + Ubuntu-derived systems. + + -- Colin Watson Fri, 20 May 2011 09:45:48 +0100 + +debootstrap (1.0.30) unstable; urgency=low + + [ Joey Hess ] + * Recommend debian-archive-keyring, and if it is installed, + default to checking gpg signatures of the Release file against it + when bootstrapping sid, squeeze, wheezy, etch, and lenny. + Closes: #560038 + * Add --no-check-gpg option that can be used to disable release file + verification. Closes: #624229 + * Needs base-installer 1.117. + * Add a warning message if the keyring file is not available, and + --no-check-gpg is not specified. + * Clear all global variables used for options, so that unclean + environment doesn't break debootstrap. Closes: #621657 + * Removed the --boot-floppies switch and mode. Assuming this has + not been used in 10 years. + + [ Colin Watson ] + * Resolve dependencies from all requested components (LP: #740167). + + -- Joey Hess Tue, 26 Apr 2011 17:10:00 -0400 + +debootstrap (1.0.29) unstable; urgency=low + + [ Joey Hess ] + * Support bootstrapping oldstable. (Lenny could already be bootstrapped + using that suite name.) + + [ Colin Watson ] + * Add (Ubuntu) oneiric as a symlink to gutsy. + + -- Colin Watson Tue, 22 Mar 2011 10:58:49 +0000 + +debootstrap (1.0.28) unstable; urgency=low + + [ Miguel Figueiredo ] + * Fix for ar usage, thanks to Guillem Jover. Closes: #598729 + + [ Joey Hess ] + * Remove 5 second sleeps when debootstrap finds additional required + dependencies. d-i just got that much faster. + * Use SHA checksums. Defaulting to SHA256, and configurable by + SHA_SIZE environment variable. Closes: #614315 + * If a sha256sum program is not available, fall back to sha1sum. + This is to support debootstrap use on embedded systems, which are more + likely to have the latter. + * Avoid new(?) warning from dpkg about missing Maintainer field when + feigning install of a package. + + -- Joey Hess Mon, 21 Feb 2011 20:48:46 -0400 + +debootstrap (1.0.27) unstable; urgency=low + + [ Miguel Figueiredo ] + * Fix bug and typo on --private-key + Patch by Jonathan Klee. + + [ Jeremie Koenig ] + * Hurd support: + - Use the newer setup-translators script and firmlink + $TARGET/{dev,servers} in setup_devices_hurd; + - Don't attempt to build devices.tar.gz, which is not needed. + + -- Otavio Salvador Mon, 07 Feb 2011 19:40:24 -0200 + +debootstrap (1.0.26) unstable; urgency=low + + [ Christian Perrier ] + * Consistently use tab indenting in scripts/gutsy and scripts/sid + Patch by Karl Goetz. Closes: #601821 + * Fix a typo in the debootstrap script + Patch by Karl Goetz. Closes: #601822 + + [ Joey Hess ] + * sid: Remove old workaround for etch era coreutils/textutils md5sum + diversion problem. (#329394) + + -- Otavio Salvador Fri, 12 Nov 2010 10:07:41 -0200 + +debootstrap (1.0.25) unstable; urgency=low + + * Remove debug statement that slipped in. + * Add test to guard against devices.tar.gz being empty. + * /dev/MAKEDEV cannot be relied on (udev likes to make it a symlink to + true). Always use /sbin/MAKEDEV. Closes: #598080 + + -- Joey Hess Sun, 26 Sep 2010 13:18:31 -0400 + +debootstrap (1.0.24) unstable; urgency=low + + [ Miguel Figueiredo ] + * Apply patches from by Jonathan Klee and Guillaume Chauvel + to add support to https (closes: #521196). + + [ Colin Watson ] + * Add (Ubuntu) natty as a symlink to gutsy. + + [ Joey Hess ] + * Add support for wheezy. Closes: #597461 + + -- Joey Hess Sun, 19 Sep 2010 21:40:00 -0400 + +debootstrap (1.0.23) unstable; urgency=low + + * Add (Ubuntu) maverick as a symlink to gutsy. + * Add ${misc:Depends}. + + -- Colin Watson Wed, 19 May 2010 13:35:34 +0100 + +debootstrap (1.0.22) unstable; urgency=low + + * Redo release since it ended up with testing directory in tar.gz. + + -- Otavio Salvador Mon, 22 Feb 2010 16:52:49 -0300 + +debootstrap (1.0.21) unstable; urgency=low + + [ Otavio Salvador ] + * Apply patch from Clint Adams to add support for + gz/bz2/xz data.tar (closes: #458663). + + [ Guillem Jover ] + * Refactor deb extractors into two new functions. + * Use dpkg-deb if available instead of ar (closes: #557296). + * Add an --extractor option to override the automatic extractor selection. + + [ Otavio Salvador ] + * Document new --extractor option in manpage. + * Apply patch from Vagrant Cascadian not + fail if resolv.conf is a broken symlink (closes: #390647). + + [ Frans Pop ] + * Use tab indentation in scripts/debian/sid to reduce its size (relevant + for Debian Installer). + * Add apt to base packages for the buildd variant as it is no longer marked + Build-Essential. + + [ Otavio Salvador ] + * Apply patch from Andres Salomon to honor + --components when using mirror_style 'main' (closes: #561283). + * Apply patch from Andres Salomon to fix + iteration through components in download_main (closes: #561298). + + [ Joey Hess ] + * Allow the suite to be stable, testing, or unstable when debootstrapping + Debian. Closes: #288109 + * Make scripts directory in source tree look like installed directory, + and add a section to README explaining an easy way to run + debootstrap w/o installing it. Closes: #345762 + * Convert rules file to use dh with overrides. + * Remove binary-basedebs target from debian/rules. + This target has been broken in multiple ways since 2007. While I + accidentially partially fixed it with the above changes, this is evidence + it's dead code that can be safely removed. + + -- Otavio Salvador Sun, 21 Feb 2010 23:11:06 -0300 + +debootstrap (1.0.20) unstable; urgency=low + + * For recent Ubuntu versions, move $TARGET/sbin/initctl aside in the same + way we do start-stop-daemon, so that attempts to control Upstart jobs + won't inadvertently affect jobs in the host system. + * Rename EXAMPLE section in debootstrap(8) to EXAMPLES (closes: #548458). + + -- Colin Watson Sun, 04 Oct 2009 21:23:07 +0100 + +debootstrap (1.0.19) unstable; urgency=low + + * Ignore failures from dpkg --predep-package. It exits 1 if there are no + suitable packages available, which isn't an error for us, but in_target + complains anyway, so just use in_target_nofail; the termination + condition is handled immediately afterwards anyway. + + -- Colin Watson Thu, 24 Sep 2009 19:57:05 +0100 + +debootstrap (1.0.18) unstable; urgency=low + + * Only use dpkg from the chroot, as there is no guarantee dpkg is + available outside of the chroot (d-i installation for example). + + -- Aurelien Jarno Wed, 23 Sep 2009 11:37:01 +0200 + +debootstrap (1.0.17) unstable; urgency=low + + * Remove boneheaded use of sudo left over from testing (closes: #547949). + + -- Colin Watson Tue, 22 Sep 2009 20:10:19 +0100 + +debootstrap (1.0.16) unstable; urgency=low + + [ Colin Watson ] + * Cope with pre-dependencies of included packages that aren't in Priority: + required (closes: #487908). + * Upgrade to debhelper v7. (Override rules get pretty hairy for this + package, so I haven't switched to dh(1).) + * Use ports.ubuntu.com as default mirror on sparc for Ubuntu hardy and + beyond (LP: #431145). + * Add (Ubuntu) lucid as a symlink to gutsy. + + [ Frans Pop ] + * Makefile: remove unused ARCH variable. + + -- Colin Watson Mon, 21 Sep 2009 16:28:40 +0100 + +debootstrap (1.0.15) unstable; urgency=low + + * On Linux, clear out /etc/mtab on exit if it's not a symlink. Should fix + problems Wouter Verhelst and Martin Michlmayr are seeing with + initramfs-tools MODULES=dep, although it probably isn't a perfect + solution. + + -- Colin Watson Thu, 23 Jul 2009 16:45:00 +0100 + +debootstrap (1.0.14) unstable; urgency=low + + * Apply patch from Felix Zielcke to use "dpkg + --print-architecture" to avoid deprecation warning. Closes: #531680. + * Reference squeeze instead of sarge in manpage. Based on a patch from + Geoff Simmons . Closes: #534575. + * Apply patch from Riku Voipio to add support for + scratchbox variant. Closes: #536820. + + -- Otavio Salvador Wed, 22 Jul 2009 12:34:54 -0300 + +debootstrap (1.0.13) unstable; urgency=low + + [ Otavio Salvador ] + * Apply patch from Luca Favatella to improve + coding style. + + [ Colin Watson ] + * Add (Ubuntu) karmic as a symlink to gutsy. + + -- Colin Watson Fri, 24 Apr 2009 20:08:24 +0100 + +debootstrap (1.0.12) unstable; urgency=low + + [ Otavio Salvador ] + * Improve code to choose between libc packages. Thanks to Luca Favatella + for first version of the patch. + + [ Colin Watson ] + * Remove partial support for emitting translated progress messages with + gettext. Don't panic; d-i still has all the support necessary for this. + debootstrap's own support for doing this outside d-i with gettext's + shell bindings has been completely broken ever since it was added in + 2003, though, and nobody has complained. Fixing it would require a big + pile of infrastructure and some non-trivial patches, plus arranging to + copy all the translations over from base-installer, and it just doesn't + seem worth it, so lose the cruft (LP: #188690). + * Export PATH, just to make sure. It isn't necessarily exported by shells + running from init=/bin/sh or similar, and the upstream bash maintainer + is unwilling to export it by default; it's easy enough to do so here + (LP: #320188). + + -- Colin Watson Tue, 17 Mar 2009 16:38:46 +0000 + +debootstrap (1.0.11) unstable; urgency=low + + * Add (Ubuntu) jaunty as a symlink to gutsy. + * Clarify that --second-stage is needed to complete the bootstrapping + process after --foreign. + * Fix --make-tarball= option (closes: #484869). + * Fix old Debian scripts and all Ubuntu scripts to cope with Anthony's + change in 1.0.8 to make --second-stage not bother recalculating required + and base. + * Rename 'repeat' to 'repeatn', since 'repeat' is a reserved word in zsh; + although strictly speaking this seems like an incompatibility in zsh + when linked to /bin/sh (closes: #340058). + * Fix --unpack-tarball= option (thanks, Torsten Landschoff; closes: + #500759). + * Fix handling of relative DEBOOTSTRAP_DIR (thanks, Mikhail Gusarov; + closes: #503460). + * Cope with ancient versions of chroot(8) that don't call chdir() (thanks, + Patrik Arvhult; closes: #350635). + * Recommend gnupg for --keyring option (thanks, Robert Millan; closes: + #467571). + * Note that you can't --include packages with non-required Pre-Depends + (see #487908). + * Mention /sys in EXAMPLE section of manual page, and use "defaults" + rather than "none" as the mount options for /proc (thanks, Raúl Sánchez + Siles; closes: #410787). + * Add /dev/console to devices.tar.gz (after all, MAKEDEV's 'consoleonly' + was added for boot-floppies in the first place; see + https://lists.ubuntu.com/archives/ubuntu-devel/2009-January/027230.html). + * Add support for squeeze (closes: #513488). + + -- Colin Watson Wed, 18 Feb 2009 23:46:12 +0000 + +debootstrap (1.0.10) unstable; urgency=low + + [ Joey Hess ] + * Avoid "broken pipe" errors in bootstrap.log from the the smallyes function. + The errors themselves are inherent to how the function is used, so just + suppress them. Closes: #480560. + + [ Frans Pop ] + * Do not cache Release and Release.gpg files. Closes: #488424. + * Abort if a Packages file failed to verify. + * Update standards version to 3.8.0; no other changes needed. + + -- Frans Pop Wed, 02 Jul 2008 17:44:25 +0200 + +debootstrap (1.0.9) unstable; urgency=low + + [ Frans Pop ] + * Error out on unrecognized options to avoid invalid options to be + recognized as arguments. + + [ Colin Watson ] + * Use 'chown 0:0' in all scripts rather than deprecated 'chown 0.0' + (thanks, Evan Klitzke). + * Add (Ubuntu) intrepid as a symlink to gutsy. + + -- Colin Watson Tue, 29 Apr 2008 19:36:19 +0100 + +debootstrap (1.0.8) unstable; urgency=low + + [ Frans Pop ] + * Change Priority for the udeb to extra in line with overrides file. + + [ Colin Watson ] + * Partially revert r50134; there are people who depend on being able to + use the "upstream" Makefile on non-Debian systems. Create necessary + directories in the Makefile rather than relying on dh_installdirs to do + it (LP: #172645). + * Use ftp.us.debian.org rather than ftp.debian.org + (http://lists.debian.org/debian-devel-announce/2007/12/msg00002.html). + + [ Anthony Towns ] + * Add minbase variant for the sid script that only install apt (and + its dependencies) instead of all of base. (Closes: Bug#351912, + Bug#452654) + * Make --second-stage not bother recalculating required and base as + it's not needed. + * Make --arch and other arguments accept both "--arch i386" and + "--arch=i386" forms of specifying a parameter to avoid the + inconsistency. + + [ Stephen R. Marenka ] + * Allow installation of etch-m68k. (Closes: Bug#458965) + + [ Colin Watson ] + * Add minbase variant for Ubuntu gutsy/hardy; see Anthony's change above. + * Minor manual page formatting improvements. + + -- Colin Watson Tue, 15 Jan 2008 11:19:34 +0000 + +debootstrap (1.0.7) unstable; urgency=low + + * No longer include full devices tarball in udeb. + * Also try 'udpkg --print-architecture' when determining the target + architecture. + * Utility pkgdetails moved from debootstrap-udeb to bootstrap-base so that + the udeb can become 'Architecture: all'. + * Change /usr/lib/debootstrap to /usr/share/debootstrap. Closes: #430615. + * Use tab indentation in debootstrap and functions saving 3kB (relevant for + Debian Installer). + * Fix various inconsistencies in build scripts. + * Fix dpkg-genchanges warning 'missing Priority for source files'. + * Update Standards-Version to 3.7.2. No changes needed. + * Changes in udeb require base-installer 1.85. + + -- Frans Pop Wed, 14 Nov 2007 12:15:45 +0100 + +debootstrap (1.0.6) unstable; urgency=low + + * Ensure that the target directory exists in check_sane_mount. + * Don't ignore 'make clean' errors. (The Makefile is always present.) + + -- Colin Watson Sun, 21 Oct 2007 10:50:59 +0100 + +debootstrap (1.0.5) unstable; urgency=low + + [ Colin Watson ] + * Don't rely on GNU sed's s///I extension (closes: #350583). + + [ Joey Hess ] + * Skip the noexec/nodev test when running --print-debs or other operations + that do not involve building systems. + + -- Joey Hess Sat, 20 Oct 2007 23:10:34 -0400 + +debootstrap (1.0.4) unstable; urgency=low + + [ Neil Williams ] + * Add --second-stage-target option that allows embedded to test for + installations in a chroot on the device (closes: #445157). + + [ Colin Watson ] + * Add (Ubuntu) hardy as a symlink to gutsy. + * Unmount /lib/init/rw on exit (closes: #391604). + * Cope if uncompressed Packages is missing from Release (closes: #402380). + * Don't rely on XSI test(1) extensions. + * Add support for ssh:/// URLs (thanks, Steffen Joeris; closes: #434893). + * Fix Ubuntu hoary and breezy scripts to unmount /dev etc. on exit + (closes: #327708). + * Emit an error if we cannot create working devices or executables on the + target (based on work by Bastian Kleineidam; closes: #233798). + + -- Colin Watson Fri, 19 Oct 2007 14:57:37 +0100 + +debootstrap (1.0.3) unstable; urgency=low + + * Ignore errors when unmounting filesystems, to avoid stopping at the + first one with problems. + + -- Colin Watson Tue, 21 Aug 2007 12:32:37 +0100 + +debootstrap (1.0.2) unstable; urgency=low + + [ Joey Hess ] + * Document --components in man page. + * Update man page, as packages listed in --include should now be auto + dep-resolved by default. + + [ Colin Watson ] + * Extensive quoting fixes, allowing installation to a target containing + spaces (closes: #387673). + * scripts/debian/sid: Handle libc0.3 on hurd-i386 (thanks, Michael Banck; + closes: #314304). + * functions: Stub out /proc setup and add device setup for the Hurd + (thanks, Michael Banck; closes: #314311). + * Add --version option (closes: #294484). + + [ Otavio Salvador ] + * Fix bunzip2 path. Thanks Martín Ferrari by + the patch (closes: #436218). + + -- Otavio Salvador Tue, 07 Aug 2007 20:12:55 -0300 + +debootstrap (1.0.1) unstable; urgency=low + + * scripts/ubuntu/gutsy: Determine buildd variant dynamically using + Build-Essential: yes. + * scripts/ubuntu/gutsy.fakechroot: Remove devmapper postinst hack, no + longer needed. + * scripts/ubuntu/*.fakechroot: Merge into the corresponding main scripts + as variants. + + -- Colin Watson Fri, 20 Jul 2007 11:55:22 +0100 + +debootstrap (1.0.0) unstable; urgency=low + + [ Anthony Towns ] + * Make debootstrap team maintained under the d-i banner. + * Add Joey, Frans and Junichi as uploaders, remove JHM (not in the + d-i group). + * Make pkgdetails.c not need C99 extensions. (Closes: Bug#398977) + * Fix am_doing_phase implementation in debootstrap script. Thanks to + Tero Janka for spotting the problem and the fix. (Closes: Bug#409881) + + [ Joey Hess ] + * Drop support for sarge from the udeb. + * Update README.Debian: + - One todo item is done. (I think cross-strap is too, but unsure.) + - Reword NMU policy to note that it's team-maintained now. + * ACK my prior NMU. Closes: #418600 + * If /dev/MAKEDEV DNE, as on certain s390 machines, use /sbin/MAKEDEV. + Closes: #420908 + Note that /dev/MAKEDEV is still the correct location, and is still tried + first so that building works on all FHS systems, as noted in #190239. + + [ Colin Watson ] + * Add support for Ubuntu dapper (Closes: #342838), edgy, feisty, and + gutsy. Exclude everything but gutsy from the udeb. + * Fix "deboostrap" typo in debootstrap(8) (thanks, Adam Conrad). + * Fix "htp" typo in temporary /etc/apt/sources.list. + * Drop support for woody from the udeb too. + * When removing $TARGET/debootstrap, debootstrap.log is still open as + stdout/stderr and needs to remain so, but after unlinking it some NFS + servers implement this by a temporary file in the same directory, which + makes it impossible to rmdir that directory. Moving it instead works + around the problem (thanks, Steven McCoy; + https://launchpad.net/bugs/65003). + * Fix formatting error in debootstrap(8) (.R is not a macro). + * Reorganise scripts into scripts/debian/ and scripts/ubuntu/ directories + in the source tree to declutter the top level. + * Add default_mirror function; reorganise the debootstrap script a little + so that it works. Set the default mirror for Ubuntu suites to + http://archive.ubuntu.com/ubuntu, and the default mirror for Debian + etch/lenny/sid architectures other than amd64 and i386 to + http://ftp.us.debian.org/debian (per ajt; see bug #363049). + * Add devices created by fd to devices-std.tar.gz, so that + /dev/std{in,out,err} is available conveniently in chroots with /proc and + /dev/pts mounted (thanks, Matthias Klose). + * Document --keyring and --make-tarball. (Closes: #368988) + * Update Ubuntu mirrors: warty/hoary/breezy => old-releases.ubuntu.com, + unsupported architectures => ports.ubuntu.com. + * Add myself to Uploaders. + * Bump to 1.0.0. Nobody uses debootstrap in production, do they? + + [ Joey Hess ] + * Remove the extended package description (aka bloat) from the udeb. + + -- Colin Watson Sat, 23 Jun 2007 02:19:27 +0100 + +debootstrap (0.3.3.3) unstable; urgency=low + + * NMU + * Add support for lenny. + + -- Joey Hess Tue, 10 Apr 2007 15:24:15 -0400 + +debootstrap (0.3.3.2) unstable; urgency=low + + * NMU with maintainer approval + * Remove --force-auto-select option for 'sid' script as it is no longer + supported by dpkg. Closes: #409527. + + -- Frans Pop Fri, 16 Feb 2007 20:43:36 +0100 + +debootstrap (0.3.3.1) unstable; urgency=low + + * NMU with maintainer approval + * functions/get_debs: build list of available packages from all specified + sources; this allows debootstrap to also use e.g. custom versions of base + packages from a source of local packages included on an installation CD. + Closes: #398762. + + -- Frans Pop Thu, 16 Nov 2006 05:30:43 +0100 + +debootstrap (0.3.3) unstable; urgency=low + + * Include kFreeBSD and fakechroot support from 0.3.2.1 and 0.3.2.2 NMUs, + thanks to Otavio Salvador and Piotr Roszatycki. (Closes: Bug#319100, + Bug#328446, Bug#204652, Bug#315044, Bug#Bug#319799) + + * Require target to be specified in all cases; document usage of target + for --print-debs. (Closes: Bug#335922, Bug#337230) + + * Use ln -sf when symlinking awk for woody and sarge. (Closes: Bug#299048) + + -- Anthony Towns Sun, 6 Nov 2005 04:12:39 +1000 + +debootstrap (0.3.2.2) unstable; urgency=low + + * NMU + * Added relicensed fakechroot variant. Closes: #204652. + + -- Piotr Roszatycki Sat, 29 Oct 2005 11:29:00 +0200 + +debootstrap (0.3.2.1) unstable; urgency=low + + * NMU with maintainer approval + * Applied patch from Robert Millan to add support to + Debian GNU/kFreeBSD. Closes: #319799 + + -- Otavio Salvador Fri, 28 Oct 2005 16:14:57 -0200 + +debootstrap (0.3.2) unstable; urgency=low + + * Revert fakechroot NMUs (0.3.1.1, 0.3.1.3, 0.3.1.7) due to incompatible + license requirements (GPL) (Reopens: Bug#204652) + + * Changes from 0.3.1.2 NMU, thanks to Joey Hess: (Closes: Bug#314810) + + Fix incorrect use of "$@" in local. Closes: #314157, #314547 + + Fix fd redirection in download progress code. See #314373 + + Remove md5sums file from udeb. Closes: #314378 + + Fix debian-installer mode warning code. Closes: #314340 + + * Changes from 0.3.1.4 NMU, thanks to Joey Hess: + + Wrap eval statement in exit_function in parens, working around + bug #315444 in busybox sh. Closes: #314373 + + * Changes from 0.3.1.5 NMU, thanks to Anibal Monsalve Salazar: + + Fixed "--variant=buildd option does not work" for pbuilder, + closes: #314858. Patch by Matt Kraai . + + * Changes from 0.3.1.6 NMU, thanks to Joey Hess: + + Patch from Colin to redirect status messages to stderr when running + --print-debs. Closes: #315875 + + Restore logging to stderr in debian-installer mode. Closes: #314160 + + * Changes from 0.3.1.8 NMU, thanks to Petter Reinholdtsen: + + [functions] Mount /sys if it exist and is supported by the kernel. + Patch from Cajus Pollmeier, Colin Watson and Ubuntu. (Closes: #289105) + + [debootstrap] Document --resolve-deps in usage info. (Closes: #328161) + + [etch] Replace libsigc++-1.2-5c102 with libsigc++-1.2-5c2. (Closes: #334506) + + [etch] Remove pppoe from base, and only install + ipchains on m68k. Patch from Sven Luther. (Closes: #239390) + + [sarge] Remove duplicate entries for m68k and amd64. Patch from + Frans Pop. (Workaround for bug #319777) + + [etch] Add support for ppc64. The patch for 'sid' did no longer + apply. Patch from Andreas Jochens. (Closes: #313353) + + [sarge,etch,sid] Set DEBCONF_NONINTERACTIVE_SEEN=true during build, to + avoid questions during upgrade. (Closes: #238301) + + Add script for breezy. Patch from Colin Watson. (Closes: #315940) + + * Changes from 0.3.1.9 NMU, thanks to Joey Hess: + + Replace the etch script with a copy of the sid script, which pulls in + gnupg, so the installed etch system has a usable apt. Closes: #334521 + + * Create /dev/ptmx in minimal devices tarball. (Closes: Bug#317072) + + * Don't create empty available files, since old dpkg and new kernels can't + deal with them. (Closes: Bug#308169, Bug#329468) + + * Bump Standards-Version. Bump debhelper compatability level to 4. + * Cleanup debian/rules, thanks to Joey Hess. (Closes: Bug#314863) + + * Emit error message if no pkgdetails is available. (Closes: Bug#326831) + + * Turn on --resolve-deps by default. Add --no-resolve-deps as an option. + Combined with the previous changes to make the etch script dynamically + determine base, this should resolve all the "can't install " + bugs. (Closes: Bug#280210, Bug#308361, Bug#318281, Bug#323362, + Bug#318254, Bug#313292, Bug#334683, Bug#248578, Bug#289635) + + * md5sum doesn't exist when coreutils is unpacked but not configured; + cp it across so it's available for --second-stage. (Closes: Bug#329394) + + * Catch failures in "dpkg --status-fd" (Closes: Bug#317447, Bug#323661) + + * Make "without" work right for duplicates (Closes: Bug#316884, + Bug#319777) + + * Simplify and correct file descriptor handling and debootstrap.log + behaviour. + + * Delete $TARGET with --print-debs and --make-tarball. (Closes: Bug#328369) + + * Add a --make-tarball option. (Closes: Bug#152845) + + * Create a default sources.list for apt. (Closes: Bug#283234, Bug#315225) + + * Update manpage to talk about woody instead of sarge. (Closes: Bug#315862) + + * Use partial/ directory when downloading. (Closes: Bug#109176) + + -- Anthony Towns Sun, 23 Oct 2005 14:49:08 +1000 + +debootstrap (0.3.1) unstable; urgency=low + + * sid script updated: + - Determine base dynamically (Priority: required for required packages, + Priority: important for base packages, Build-Essential: yes for buildd + variant base). (Closes: Bug#88984, Bug#193134) + - Use fine grained dpkg progress display, thanks again to Colin Watson. + (Closes: Bug#229314, Bug#231109, Bug#244563) + + * dpkg output (etc) goes to /var/log/bootstrap.log in the target, rather + than stdout. This is probably difficult for frontends to capture + at present. + + * Parsing of Packages file sped up. (Yay!) + + * debootstrap.deb now arch: all (Closes: Bug#122465, Bug#131552) + - perl implementation of pkgdetails used by preference + - devices.tar.gz reduced to minimal set of devices; frontends should + setup udev or supply their own devices or similar in future + - /usr/lib/debootstrap/arch not shipped + - none of the above applies to udebs yet; though the devices.tar.gz + change will eventually + + * Support for verifying based on Release.gpg files (--keyring). Thanks + to Colin Watson. (Closes: Bug#313383) + + -- Anthony Towns Tue, 14 Jun 2005 00:22:55 +1000 + +debootstrap (0.3.0) unstable; urgency=low + + * The Gernot Heiser release, dedicated to everyone who drinks enough to + lose their better judgement, and those of us who didn't have any in + the first place. + + * Major update. New features: + + Use $TARGET/debootstrap directory for state info + (--keep-debootstrap-dir) + + Support for cross-strapping (--foreign / --second-stage) + (Closes: Bug#202529) + + Support for resolving dependencies (--resolve-deps) + + Support for Debian etch, and Ubuntu warty and hoary (Closes: Bug#312417) + + Support for handling variants within the main suite script + + Support for other versions of base packages in /v/c/apt/archives + + Initial support for fine-grained dpkg progress display, thanks to + Colin Watson (currently only for warty and hoary) + + Initial support for determining base system dynamically. + + No longer display "debootstrap.invalid" when working with + Release/Packages files. (Closes: Bug#241795, Bug#256255) + + Ignores failures for on_exit cleanup commands. (Closes: Bug#253387, + Bug#253468, Bug#308774) + + Early reporting of unavailable packages. + + More efficient parsing of Packages files. + + Generalised additions and exclusions. (Closes: Bug#191793) + + Handles symlinked configuration files in /etc a little better. + (Closes: Bug#161987, Bug#252907, Bug#272257) + + * Dropped support for slink. + + * Use ln -fs for mawk/awk link. (Closes: Bug#248398, Bug#258524) + + * Dropped mail-transport-agent, and hence mailx and at from sid/etch base. + (Closes: Bug#168473) + * Dropped ipchains for i386 (Closes: Bug#266119) + * Other minor changes to meet dependencies, also. (Closes: Bug#312701) + + * Minor manpage fixes. (Closes: Bug#285777) + * Add check for specifying no components (CloseS: Bug#283810) + + * Include 0.2.45 NMUs, thanks to Steve Langasek. + (Closes: Bug#295571, Bug#283752, Bug#278158) + + -- Anthony Towns Sun, 12 Jun 2005 23:49:58 +1000 + +debootstrap (0.2.45-0.2) unstable; urgency=low + + * Non-maintainer upload. + * [sarge, sid] Replace libparted1.6-0 with libparted1.6-12 for ia64, + to keep up with the ABI changes for that package. (Closes: #295571) + * [sarge, sid] include pciutils on hppa as well, per request of the + hppa folks. (Closes: #283752) + + -- Steve Langasek Fri, 25 Feb 2005 22:23:30 -0800 + +debootstrap (0.2.45-0.1) unstable; urgency=low + + * Non-maintainer upload. + * [sarge, sid] Drop libgnutls10 and libgcrypt7, since they are no + longer needed by exim4. (Closes: #278158). + + -- Steve Langasek Thu, 20 Jan 2005 21:20:22 -0800 + +debootstrap (0.2.45) unstable; urgency=high + + * Acknowledge NMUs. (Closes: #270135) + * [woody.buildd] Corrected ia64 special cases. Patch by Brett Johnson + . (Closes: #271894) + + -- J.H.M. Dassen (Ray) Sat, 18 Sep 2004 13:49:23 +0200 + +debootstrap (0.2.44.2) unstable; urgency=low + + * NMU again, this time using the makedev in unstable instead of the + experimental so devices.tar.gz isn't empty on ia64... oops... /o\ + + -- Bdale Garbee Tue, 14 Sep 2004 20:03:56 -0600 + +debootstrap (0.2.44.1) unstable; urgency=low + + * NMU to resolve d-i inability to install sid on ia64 + * add pciutils to the base package list for ia64, to avoid having to regress + efibootmgr in unstable, closes: #270315, #268490 + + -- Bdale Garbee Mon, 13 Sep 2004 15:11:11 -0500 + +debootstrap (0.2.44) unstable; urgency=high + + * [sarge] Removed "gcc-3.0-base" and "libstdc++3" for HPPA as they have been + removed from sarge as well on that arch. (Closes: #268917) + + -- J.H.M. Dassen (Ray) Mon, 30 Aug 2004 08:53:30 +0200 + +debootstrap (0.2.43) unstable; urgency=high + + * [sarge] Added back libgnutls10 in order not to break d-i testing. + (Closes: #268578, #268663). + + -- J.H.M. Dassen (Ray) Sun, 29 Aug 2004 09:08:48 +0200 + +debootstrap (0.2.42) unstable; urgency=high + + * Acknowledge NMUs. (Closes: #262137, #262165, #262178, #262375) + * [sarge] Switch to libgnutls11 so exim4 can switch. (Closes: #268325) + * [sid] Removed "gcc-3.0-base" and "libstdc++3" for HPPA as they have been + removed from sid. (Closes: #268049) + * [Makefile] Make the regular video devices on all archs. (Closes: #265081) + * [Makefile,debootstrap] Switched away from deprecated chown syntax; + switched away from XSIisms '-a' and '-o'. (Closes: #256098) + * [debootstrap.8] Use '\-' rather than '-' in options. (Closes: #263955) + Confirmed that the "exlude" typo has already been fixed. (Closes: #254108) + Applied patch by Javier Fernández-Sanguino Peña + for "file" URL documentation and a more complete example. (Closes: #226662) + + -- J.H.M. Dassen (Ray) Fri, 27 Aug 2004 15:40:02 +0200 + +debootstrap (0.2.41-0.2) unstable; urgency=low + + * Non-maintainer upload + * [sarge, sid] Add missing libgcrypt11 to base, needed by libgnutls11 + in sid and needed in sarge for opencdk8 to be rebuilt against it + (closes: #262375, #262178). + + -- Steve Langasek Fri, 30 Jul 2004 20:26:57 -0700 + +debootstrap (0.2.41-0.1) unstable; urgency=low + + * Non-maintainer upload with consent of JHM. + * Pull libfribidi0 back out of base, it's opportunistically installed + by d-i now for the locales that need it (closes: #262137). + * Re-add bootloaders on ia64, sparc, mips, hppa, and m68k to base, + because debian-installer isn't ready for this change (closes: #262165). + + -- Steve Langasek Thu, 29 Jul 2004 14:14:33 -0700 + +debootstrap (0.2.41) unstable; urgency=high + + * High urgency upload as per tbm's request. + * [sarge, sid] No longer install setserial, as it causes problems on some + systems (e.g. #212646) and there is a consensus it is no longer needed in + a base environment. + * [sarge, sid] Removed aboot, aboot-base, elilo, efibootmgr, silo, dvhtool, + delo, palo, vmelilo. As per the consensus reached in the thread starting + with http://lists.debian.org/debian-boot/2004/04/msg00634.html, the + installation of boot loaders is now debian-installer's responsibility. + (Closes: #247906) + * [sarge, sid] Added libfribidi0 to base to make debconf localisation into + right to left languages possible. (Closes: #253229) + * [sarge.buildd] Drop libdb4.0 for libdb4.2 as needed by perl. + * [sid] Added libgnutls11 as libgnutls10 is being phased out. + * [Makefile] Include /dev/ida on ia64. (Closes: #258055) + + -- J.H.M. Dassen (Ray) Thu, 29 Jul 2004 20:37:37 +0200 + +debootstrap (0.2.40) unstable; urgency=medium + + * [woody.buildd] Ensure the on_exit umounting of /dev/pts doesn't mess up + an otherwise OK exit status. (Closes: #260699) + * Acknowledge NMUs. (Closes: #258350, #260253) + + -- J.H.M. Dassen (Ray) Thu, 22 Jul 2004 21:53:20 +0200 + +debootstrap (0.2.39.2) unstable; urgency=low + + * Non-maintainer upload. + * [sarge, sid] Drop quik from powerpc, as debian-installer handles this + now (closes: #260253). + + -- Colin Watson Thu, 22 Jul 2004 16:56:19 +0100 + +debootstrap (0.2.39.1) unstable; urgency=low + + * NMU + * add passwd to sid.buildd,sarge.buildd as bash depends on them + + -- Junichi Uekawa Fri, 9 Jul 2004 09:07:28 +0900 + +debootstrap (0.2.39) unstable; urgency=medium + + * [sarge,sid] Dropped libdb2. Thanks Matt Zimmerman. (Closes: #250813) + * [sarge,sid] Dropped libident. Thanks LaMont Jones. (Closes: #251320) + * [sarge,sid] Dropped slang1. Thanks LaMont Jones. (Closes: #251328) + * [woody.buildd] Install libperl5.6. Thanks Rene Engelhard. (Closes: #251702) + * [sarge.buildd] Install libc6.1 rather than libc6 on alpha. Thanks Rene + Engelhard. (Closes: #251703) + + Goswin von Brederlow + * Copy script for sarge to sid + * Add handling for amd64 to sarge/sid scripts + * Dropped gcc-3.2-base. (Closes: #250836) + + -- J.H.M. Dassen (Ray) Sat, 5 Jun 2004 10:02:50 +0200 + +debootstrap (0.2.38.1) unstable; urgency=low + + * NMU. + * [sarge] Add libdb4.2 since apt-utils (0.5.25) depends on this. + + -- Otavio Salvador Thu, 20 May 2004 22:18:41 -0300 + +debootstrap (0.2.38) unstable; urgency=medium + + * [woody.buildd] Readd libgdbmg1 (for perl-modules). + + -- J.H.M. Dassen (Ray) Fri, 7 May 2004 10:55:13 +0200 + +debootstrap (0.2.37) unstable; urgency=medium + + * [debian/control] Bumped makedev build dependency so as not to get pty + permissions problems. (Closes: #246709) + * [sid, sid.buildd] Add/switch to libdb4.2 for the new perl packages. + * Acknowledge NMU 0.2.36.1. (Closes: #246368) + + -- J.H.M. Dassen (Ray) Tue, 4 May 2004 07:58:02 +0200 + +debootstrap (0.2.36.1) unstable; urgency=low + + * Non-maintainer upload with maintainer permission. + * [sarge, sid] Drop yaboot from powerpc, as debian-installer handles this + now (closes: #246368). + + -- Colin Watson Fri, 30 Apr 2004 00:05:02 +0100 + +debootstrap (0.2.36) unstable; urgency=high + + Joey Hess : + * [sid, sarge] Add a subst_package function, and use it to replace libc6 + with libc6.1 on alpha and ia64, to avoid reordering libc in the required + list and work around bug #238963. (Closes: #245680) + + -- J.H.M. Dassen (Ray) Sun, 25 Apr 2004 18:37:42 +0200 + +debootstrap (0.2.35) unstable; urgency=high + + * [sarge, sid] Dropped syslinux. (Closes: #205379) + * [woody, woody.buildd] Removed libgdbmg1. (Closes: #244447) + * [debootstrap, functions] Sync at the end of debootstrap. (Closes: #225742) + + -- J.H.M. Dassen (Ray) Thu, 22 Apr 2004 16:51:49 +0200 + +debootstrap (0.2.34) unstable; urgency=high + + * [sid] Dropped libpci1 and libpci2 as the pciutils dependency change has + been reverted. (Closes: #244344) + + -- J.H.M. Dassen (Ray) Thu, 22 Apr 2004 08:14:28 +0200 + +debootstrap (0.2.33) unstable; urgency=high + + * [sid] Added libpci1 and libpci2 for all archs where pciutils is installed, + as pciutils now depends on them. (Closes: #244344) + + -- J.H.M. Dassen (Ray) Sun, 18 Apr 2004 09:41:23 +0200 + +debootstrap (0.2.32) unstable; urgency=high + + * [sarge, sid] No longer try to filter out console-tools on s390. While + console-tools is basically useless on s390, base-config depends on it. + (Closes: #241727) + + -- J.H.M. Dassen (Ray) Fri, 9 Apr 2004 16:26:23 +0200 + +debootstrap (0.2.31) unstable; urgency=medium + + * [sarge] Exim has changed GnuTLS dependencies. Added libgnutls10, + libgcrypt7, libgpg-error0, libopencdk8, libtasn1-2; dropped libgnutls7, + libgcrypt1, libtasn1-0. + * [sarge] Removed libgnutls7, libgcrypt1, libtasn1-0. + + -- J.H.M. Dassen (Ray) Tue, 23 Mar 2004 22:47:28 +0100 + +debootstrap (0.2.30) unstable; urgency=medium + + * [sarge, sid] aboot needs aboot-base. (Closes: #236368, #239302) + + -- J.H.M. Dassen (Ray) Mon, 22 Mar 2004 21:10:31 +0100 + +debootstrap (0.2.29) unstable; urgency=low + + * NMU with permission of maintainer. + * Added {woody,sarge,sid}.buildd scripts to create build chroots. + Closes: #236418. + * Added --variant=buildd option for convenient access to these scripts. + + -- Daniel Schepler Wed, 10 Mar 2004 02:29:27 -0800 + +debootstrap (0.2.28) unstable; urgency=medium + + * [sid] Exim has changed GnuTLS dependencies. Added libgnutls10, libgcrypt7, + libgpg-error0, libopencdk8, libtasn1-2; dropped libgnutls7, libgcrypt1, + libtasn1-0. + * [sarge,sid] Dropped lilo, mbr, modconf, libdevmapper1.00 as + debian-installer handles the bootloader installation and modules + configuration. (Closes: #232667, #232672, #232673) + + -- J.H.M. Dassen (Ray) Tue, 24 Feb 2004 09:57:35 +0100 + +debootstrap (0.2.27) unstable; urgency=medium + + * [sarge] Lilo now needs libdevmapper1.00; Removed libopencdk8, libgcrypt7, + libgpg-error0. + + -- J.H.M. Dassen (Ray) Sat, 14 Feb 2004 01:19:48 +0100 + +debootstrap (0.2.26) unstable; urgency=medium + + * [sarge] Removed gcc-3.2-base. (Closes: #230697) + * [sid] Lilo now needs libdevmapper1.00 . + + -- J.H.M. Dassen (Ray) Tue, 3 Feb 2004 08:27:54 +0100 + +debootstrap (0.2.25) unstable; urgency=high + + * [functions] Unmount proc/bus/usb, not proc/usb. (Closes: #229122) + + -- J.H.M. Dassen (Ray) Fri, 30 Jan 2004 18:01:29 +0100 + +debootstrap (0.2.24) unstable; urgency=high + + * [functions, sarge, sid] Try to unmount proc/usb, dev/shm, dev/pts on exit; + don't fail when there's nothing to unmount. + (Closes: #229122, #229901, #229907) + * [woody] Don't fail when there's no dev/pts to unmount. + * [sarge, sid] Don't install pcmcia-cs as debian-installer takes care of + that where needed. (Closes: #221907) + * [sid] Removed libopencdk8, libgcrypt7, libgpg-error0. + * [sarge] libopencdk8 (needed for exim4-daemon-light via libgnutls7) + Depends: libgcrypt7, libgpg-error0. (Closes: #229989) + + -- J.H.M. Dassen (Ray) Wed, 28 Jan 2004 18:48:02 +0100 + +debootstrap (0.2.23) unstable; urgency=high + + * [sarge] Dropped libopencdk4 in favour of libopencdk8 as gnutls has switched. + + -- J.H.M. Dassen (Ray) Thu, 1 Jan 2004 01:30:02 +0100 + +debootstrap (0.2.22) unstable; urgency=high + + * [sid] libopencdk8 Depends: libgcrypt7, libgpg-error0. + + -- J.H.M. Dassen (Ray) Wed, 31 Dec 2003 12:35:03 +0100 + +debootstrap (0.2.21) unstable; urgency=high + + * [sarge] Added coreutils' new predependencies libacl1 and libattr1; removed + libsasl2 as it is no longer needed. + + -- J.H.M. Dassen (Ray) Sun, 28 Dec 2003 22:54:08 +0100 + +debootstrap (0.2.20) unstable; urgency=high + + * [sarge] base-config now Depends: aptitude; aptitude Depends: + libsigc++-1.2-5c102. + + -- J.H.M. Dassen (Ray) Sun, 28 Dec 2003 15:11:31 +0100 + +debootstrap (0.2.19) unstable; urgency=high + + * [sid] base-config now Depends: aptitude; aptitude Depends: + libsigc++-1.2-5c102. + + -- J.H.M. Dassen (Ray) Wed, 24 Dec 2003 09:03:44 +0100 + +debootstrap (0.2.18) unstable; urgency=low + + * Thanks to Steinar Gunderson and Matt Kraii for the NMU fixing some + d-i related problems. (Closes: Bug#220150) + * Acknowledge that the problems really are fixed now. (Closes: + Bug#213669, Bug#209273, Bug#210912) + + * Fix downloading of Packages files to retry if bz2 or gz isn't available + on the mirror. (Closes: Bug#194592) + + -- Anthony Towns Sat, 15 Nov 2003 00:13:13 +1000 + +debootstrap (0.2.17.1) unstable; urgency=high + + * NMU + * [sarge,sid] Display only the package name when retrieving packages. + (Closes: #213669, #209273) + * [sarge,sid] Added progress information for downloading package + details. (Closes: #210912) + + -- Steinar H. Gunderson Mon, 10 Nov 2003 15:11:09 +0100 + +debootstrap (0.2.17) unstable; urgency=high + + * [sarge] Fixed typo: libreadlin4 -> libreadline4. (Closes: #219655) + + -- J.H.M. Dassen (Ray) Sat, 8 Nov 2003 23:23:37 +0100 + +debootstrap (0.2.16) unstable; urgency=high + + * [sarge,sid] libreadline4 is required for amiga-fdisk on powerpc. + (Closes: #218533) + * [sarge,sid] Put libreadline4 in required rather than base for ia64. + + -- J.H.M. Dassen (Ray) Wed, 5 Nov 2003 08:09:41 +0100 + +debootstrap (0.2.15) unstable; urgency=high + + * ia64 fixes by Richard Hirst : (Closes: #218533) + * [sarge, sid] Add libreadline4 to base for ia64 as parted needs it. + * [sarge, sid] Remove gcc-2.96-base from required for ia64. + + -- J.H.M. Dassen (Ray) Sat, 1 Nov 2003 12:58:34 +0100 + +debootstrap (0.2.14) unstable; urgency=high + + * [sarge] Made exim4 the default MTA. (Closes: #217657) + * [sarge] Removed libstdc++2.10-glibc2.2, libldap2 . + * [sid] Dropped libopencdk4 in favour of libopencdk8 as gnutls has switched. + + -- J.H.M. Dassen (Ray) Tue, 28 Oct 2003 09:56:27 +0100 + +debootstrap (0.2.13) unstable; urgency=high + + * [sarge] Added libtextwrap1 for tasksel. + + -- J.H.M. Dassen (Ray) Wed, 22 Oct 2003 08:10:37 +0200 + +debootstrap (0.2.12) unstable; urgency=high + + * [sarge, sid] Add libreadline4 to required for m68k as amiga-fdisk needs + it. (Closes: #216617) + + -- J.H.M. Dassen (Ray) Mon, 20 Oct 2003 10:05:09 +0200 + +debootstrap (0.2.11) unstable; urgency=high + + * [sid] Added libc6-sparc64 lib64gcc1 lib64ncurses5 to base for sparc. + (Closes: #215590) + * [sarge, sid] Dropped libreadline as bash no longer depends on it. + * [sid] Dropped libstdc++2.10-glibc2.2 and its associated special cases as + it is no longer needed. + + -- J.H.M. Dassen (Ray) Wed, 15 Oct 2003 19:42:58 +0200 + +debootstrap (0.2.10) unstable; urgency=high + + * [sid] Fixed /usr/sbin/sendmail symlink to point to exim4. (Closes: #213734) + + -- J.H.M. Dassen (Ray) Sat, 4 Oct 2003 15:47:31 +0200 + +debootstrap (0.2.9) unstable; urgency=high + + * [sarge] Added libgdbm3 for man-db. + + -- J.H.M. Dassen (Ray) Thu, 2 Oct 2003 23:57:09 +0200 + +debootstrap (0.2.8) unstable; urgency=high + + * [sid] Added libtextwrap1 for tasksel; removed libsasl2 as it is no longer + needed. + + -- J.H.M. Dassen (Ray) Thu, 2 Oct 2003 07:57:16 +0200 + +debootstrap (0.2.7) unstable; urgency=high (fixes RC d-i bug) + + * [sarge] Reinstated special-case for libperl5.8; it is still needed for + non-i386 until sarge has perl >= 5.8.0-20. (Closes: #213280) + * [debian/control] Updated Standards-Version; fixed removal of slink and + potato scripts from udeb. + * [debian/control] Updated priorities; debootstrap-udeb is required (for + debian-installer). + * [debian/rules] Fixed dpkg-distaddfile accordingly. + + -- J.H.M. Dassen (Ray) Tue, 30 Sep 2003 14:31:57 +0200 + +debootstrap (0.2.6) unstable; urgency=low + + * [sarge] Added e2fslibs, libcomerr2, libss2, libuuid1 for e2fsprogs. + + -- J.H.M. Dassen (Ray) Fri, 26 Sep 2003 13:50:58 +0200 + +debootstrap (0.2.5) unstable; urgency=low + + * [sid] Added libgdbm3 for man-db. + * [sarge, sid] Dropped special-case for libperl5.8 (Closes: #210425). + * [sid] Make exim4 the default MTA as it is configured through debconf. + (Closes: #208047) + * [sid] Removed libldap2 which is no longer needed. + + -- J.H.M. Dassen (Ray) Sun, 21 Sep 2003 13:30:49 +0200 + +debootstrap (0.2.4) unstable; urgency=low + + * [sid] Added coreutils' new predependencies libacl1 and libattr1. + * [debian/README.Debian] Corrected example invocation. (Closes: #206142) + * [debian/README.Debian] Fixed a typo. + + -- J.H.M. Dassen (Ray) Wed, 20 Aug 2003 10:28:49 +0200 + +debootstrap (0.2.3) unstable; urgency=low + + * [sarge] Add new dependencies of debconf: debconf-i18n + liblocale-gettext-perl libtext-wrapi18n-perl libtext-charwidth-perl. + * Acknowledge NMU. (Closes: #203370) + + -- J.H.M. Dassen (Ray) Sat, 16 Aug 2003 20:15:40 +0200 + +debootstrap (0.2.2-0.1) unstable; urgency=low + + * NMU. + * Fix typo in woody script. (Closes: #203370) + + -- Petter Reinholdtsen Tue, 29 Jul 2003 20:29:01 +0200 + +debootstrap (0.2.2) unstable; urgency=low + + * [debian/changelog] Included entries for NMUs 0.1.17.31 through .34 whose + changes were incorporated by aj already. + * [Makefile] Invoke MAKEDEV through its FHS location (noted by Matt + Zimmerman). (Closes: #190239) + * Acknowledge older NMUs whose changes have been incoporated. + (Closes: #135675, #161695, #191849) + + -- J.H.M. Dassen (Ray) Tue, 29 Jul 2003 18:31:49 +0200 + +debootstrap (0.2.1) unstable; urgency=low + + * The Day of the Daffodils release. + + * Accept NMUs up to 0.1.17.30. Thanks guys! (Closes: Bug#148377, + Bug#150161, Bug#150492, Bug#153962, Bug#154463, Bug#155906, + Bug#160879, Bug#161469, Bug#161469, Bug#161722, Bug#163860, + Bug#172118, Bug#176221, Bug#179504, Bug#179725, Bug#185397, + Bug#187893, Bug#188053, Bug#189472, Bug#189551, Bug#190108, + Bug#191288, Bug#193794, Bug#193806, Bug#195012, Bug#195742, + Bug#199333, Bug#201066) + * JHM added to Uploaders. + + * Change the info/error/warning/progress calls to include a unique word + for each string, a printf format string, and any arguments to the + printf string. + * Add support for debian-installer interaction + + * Add some support for l10n. Gettext is used if it's available; no + translations are included as of yet. This support doesn't + affect debian-installer, which has its own stuff for i18n, nor + boot-floppies. (Closes: Bug#125647) + + * Some initial support for cross-bootstrapping in the sid script. + + * Use dpkg --print-installation-architecture instead of + --print-architecture. (Closes: Bug#138526, Bug#159720) + + * Add new dependencies of debconf: debconf-i18n liblocale-gettext-perl + libtext-wrapi18n-perl libtext-charwidth-perl. (Closes: Bug#201066) + * Add new dependencies of libldap2: libgnutls7 libgcrypt1 liblzo1 + libopencdk4 libtasn1-0 zlib1g. (Closes: Bug#201663) + * Remove libgdbmg1. (Closes: Bug#202304) + * Add new dependecies of e2fsprogs: e2fslibs libcomerr2 libss2 libuuid1. + (Closes: Bug#203033) + * Add wget to base. (Closes: Bug#145635) + * Switch from netkit-ping to iputils-ping. + + * Changed the manpage a little. (Closes: Bug#126864) + * Updated README.Debian. + + -- Anthony Towns Tue, 29 Jul 2003 18:15:24 +1000 + +debootstrap (0.1.17.34) unstable; urgency=medium + + * [sid] Added e2fsprogs' new predependencies (e2fslibs, libcomerr2, libss2, + libuuid1). + * [sarge] Removed libgdbmg1 as it is no longer needed. + + -- J.H.M. Dassen (Ray) Sun, 27 Jul 2003 09:20:49 +0200 + +debootstrap (0.1.17.33) unstable; urgency=medium + + * [sid] Removed libgdbmg1 as it is no longer needed. + * [sarge] libldap2 now Depends: libgnutls7, libsasl2; added those and their + dependencies (libgcrypt1 liblzo1 libopencdk4 libtasn1-0 zlib1g). Dropped + libsasl7 in favour of libsasl2. + + -- J.H.M. Dassen (Ray) Mon, 21 Jul 2003 19:00:28 +0200 + +debootstrap (0.1.17.32) unstable; urgency=medium + + * [sid] libldap2 now Depends: libgnutls7; added that and its dependencies + (libgcrypt1 liblzo1 libopencdk4 libtasn1-0 zlib1g); dropped libssl0.9.7 . + + -- J.H.M. Dassen (Ray) Thu, 17 Jul 2003 07:05:09 +0200 + +debootstrap (0.1.17.31) unstable; urgency=medium + + * [sid] Follow debconf changes. debconf now Depends: debconf-i18n | + debconf-english; debconf-i18n having Priority: important and + debconf-english having Priority: extra, so we satisfy the dependency + through debconf-i18n. debconf-i18n in turn pulls in three additional + packages: liblocale-gettext-perl, libtext-wrapi18n-perl, + libtext-charwidth-perl . + + -- J.H.M. Dassen (Ray) Sun, 13 Jul 2003 08:52:55 +0200 + +debootstrap (0.1.17.30) unstable; urgency=medium + + * [sarge] + * Added sysv-rc for /usr/sbin/update-rc.d . + * Added initscripts to satisfy sysvinit's predependency. + * libparted1.6-0 has replaced libparted1.4 on ia64. (Closes: #197957) + + -- J.H.M. Dassen (Ray) Mon, 30 Jun 2003 07:05:22 +0200 + +debootstrap (0.1.17.29) unstable; urgency=medium + + * [sid] libconsole has replaced console-tools-libs. (Closes: #195722) + * [sarge] libperl5.6 has been replaced by libperl5.8 . (Closes: #195588) + + -- J.H.M. Dassen (Ray) Mon, 2 Jun 2003 00:40:54 +0200 + +debootstrap (0.1.17.28) unstable; urgency=medium + + * [sarge] libnewt0.51 has replaced libnewt0; it requires slang1a-utf8. + + -- J.H.M. Dassen (Ray) Wed, 28 May 2003 07:42:14 +0200 + +debootstrap (0.1.17.27) unstable; urgency=medium + + * urgency medium to not hold up .26 with that longer as necessary + * [sarge] added libtext-iconv-perl (this is the second part + from .22) (closes: #184539) + + -- Rene Engelhard Mon, 19 May 2003 00:08:48 +0200 + +debootstrap (0.1.17.26) unstable; urgency=medium + + * [sarge] libpcap0.7 has replaced libpcap0. + + -- J.H.M. Dassen (Ray) Sun, 18 May 2003 23:23:46 +0200 + +debootstrap (0.1.17.25) unstable; urgency=medium + + * [sarge] Added libblkid1 (for e2fsprogs). + + -- J.H.M. Dassen (Ray) Sun, 4 May 2003 12:44:00 +0200 + +debootstrap (0.1.17.24) unstable; urgency=medium + + * [sid] Updates for new whiptail: + * Replaced libnewt0 by libnewt0.51. + * Added slang1a-utf8. + + -- J.H.M. Dassen (Ray) Tue, 29 Apr 2003 19:04:51 +0200 + +debootstrap (0.1.17.23) unstable; urgency=medium + + * [sid] + * Added sysv-rc for /usr/sbin/update-rc.d . + * Added initscripts to satisfy sysvinit's predependency. + * For exim, dropped libsasl7 in favour of libsasl2. + * Added libssl0.9.7 for libsasl2. + + -- J.H.M. Dassen (Ray) Tue, 22 Apr 2003 06:56:25 +0200 + +debootstrap (0.1.17.22) unstable; urgency=low + + * [sid] added libtext-iconv-perl which is needed to display + localized po-debconf templates actually localized. + This needs a second step later for sarge but that only is possible + after libtext-iconv-perl 1.2-2 went into sarge. + + -- Rene Engelhard Fri, 18 Apr 2003 16:25:17 +0200 + +debootstrap (0.1.17.21) unstable; urgency=medium + + * [sarge, sid] Added gcc-3.3-base (as it is needed for current libstdc++5). + + -- J.H.M. Dassen (Ray) Fri, 18 Apr 2003 08:11:55 +0200 + +debootstrap (0.1.17.20) unstable; urgency=medium + + * [woody, sarge, sid] Add devfsd on s390 as that architecture uses devfs by + default. (Closes: #180252) + * [sarge] Removed the dummy fileutils package. + + -- J.H.M. Dassen (Ray) Mon, 7 Apr 2003 19:59:42 +0200 + +debootstrap (0.1.17.19) unstable; urgency=medium + + * [sid] Added libblkid1 (for e2fsprogs). + + -- J.H.M. Dassen (Ray) Sun, 6 Apr 2003 21:43:29 +0200 + +debootstrap (0.1.17.18) unstable; urgency=medium + + * [sarge] Added libgcc1, libstdc++5, gcc-3.2-base; dropped aptitude, + libsigc++0 . + * Debootstrap has depended on binutils since 0.1.17.3. (Closes: #184304) + + -- J.H.M. Dassen (Ray) Wed, 19 Mar 2003 06:55:56 +0100 + +debootstrap (0.1.17.17) unstable; urgency=medium + + * NMU + * Really drop aptitude from the sid script, not just libsigc++0. + + -- J.H.M. Dassen (Ray) Tue, 4 Feb 2003 06:49:36 +0100 + +debootstrap (0.1.17.16) unstable; urgency=medium + + * NMU + * Drop aptitude from the sid script (base-config 1.51 dropped its dependency + on it) and libsigc++0 (which was only needed for aptitude). This makes + "pbuilder create --distribution sid" work again. (Closes: #177221, #177998). + + -- J.H.M. Dassen (Ray) Sun, 2 Feb 2003 20:41:35 +0100 + +debootstrap (0.1.17.15) unstable; urgency=low + + * NMU + * For gcc-transition, libgcc1 and libstdc++5 and gcc-3.2-base + required by groff-base, and potentially other packages compiled with + gcc-3.2. + + -- Junichi Uekawa Mon, 13 Jan 2003 15:39:55 +0900 + +debootstrap (0.1.17.14) unstable; urgency=low + + * NMU + * Remove debootstrap-udeb's dependency on retriever. + + -- Tollef Fog Heen Sat, 7 Dec 2002 14:53:52 +0100 + +debootstrap (0.1.17.13) unstable; urgency=low + + * NMU + * sarge: Removed shellutils, textutils and added coreutils instead. + Verified that the result works for "pbuilder create --distribution sarge" + (Closes: #163789) + Fileutils is still in there for now, due to sarge's debconf versioned + dependency on it. + + -- J.H.M. Dassen (Ray) Tue, 8 Oct 2002 23:17:47 +0200 + +debootstrap (0.1.17.12) unstable; urgency=low + + * NMU + * Fix shell variable quoting problem, to change $10 -> ${10} + (closes: #161468) + + -- Junichi Uekawa Sat, 21 Sep 2002 13:39:47 +0900 + +debootstrap (0.1.17.11) unstable; urgency=low + + * NMU + * sarge: added libdb1-compat. + + -- J.H.M. Dassen (Ray) Sat, 21 Sep 2002 00:37:36 +0200 + +debootstrap (0.1.17.10) unstable; urgency=low + + * NMU + * sid: Removed shellutils, fileutils, and added coreutils for required + target (closes: #161332) + * sid: change libperl5.6 to libperl5.8 (closes: #158606) + + -- Junichi Uekawa Wed, 18 Sep 2002 21:41:36 +0900 + +debootstrap (0.1.17.9) unstable; urgency=low + + * NMU + * Added "libdb1-compat" to sid and verified that the resulting package is + usable for "pbuilder create --distribution sid". + + -- J.H.M. Dassen (Ray) Sat, 14 Sep 2002 15:09:10 +0200 + +debootstrap (0.1.17.8) unstable; urgency=low + + * NMU + * The "it didn't change the way the installer worked" release. + * Makefile: create $(DESTDIR)/usr/share/man/man8 before attempting to + install a file to it (Closes: #139543) + * functions: fix race condition in smallyes() implementation; thanks to Matt + Zimmerman for the analysis. "Sometimes, dpkg finishes executing before + smallyes runs, and it loops forever while echo fails repeatedly due to the + broken pipe." To fix this race, we simply swap the loop condition and + body, so that if the echo fails, smallyes() exits cleanly. I further + changed "true" to ":" to save the expense of an extra process for shells + where "true" is not a built-in. + (Closes: #139529) + + -- Branden Robinson Thu, 29 Aug 2002 12:50:08 -0500 + +debootstrap (0.1.17.7) unstable; urgency=low + + * NMU + * Forked "sid" target from "sarge" target, changed "libcap0" to the now + current "libpcap0.7" and verified that the result works with pbuilder. + (Closes: #156574) + + -- J.H.M. Dassen (Ray) Wed, 21 Aug 2002 11:01:52 +0200 + +debootstrap (0.1.17.6) unstable; urgency=low + + * NMU + * add dselect to required (I found out that it is actually required + for pbuilder create to work) (closes: #154527) + * change DEBIAN_FRONTEND=Noninteractive to "noninteractive" (closes: #154794) + * add sh* patch from Yaegashi (closes: #155142) + + -- Junichi Uekawa Thu, 8 Aug 2002 19:23:04 +0900 + +debootstrap (0.1.17.5) unstable; urgency=low + + * NMU + * mistake in the last upload, sorry aj. + sid points to sarge, not woody. (closes: #149971) + + -- Junichi Uekawa Sat, 27 Jul 2002 17:22:05 +0900 + +debootstrap (0.1.17.4) unstable; urgency=low + + * NMU + * add "sarge" target (closes: #153957) + + -- Junichi Uekawa Tue, 23 Jul 2002 18:03:01 +0900 + +debootstrap (0.1.17.3) unstable; urgency=low + + * NMU + * Depend on binutils (closes: #138489) + * Sleep is optional (closes: #150468) + * POSIXify a bit more (closes: #150487) + * Add support for --components (closes: #116801) + + -- Tollef Fog Heen Thu, 20 Jun 2002 00:13:06 +0200 + +debootstrap (0.1.17.2) unstable; urgency=low + + * NMU + * Make sid script not a symlink from woody script + * add aptitude and libsigc++0 to base for sid. (closes: #149971) + + -- Junichi Uekawa Sat, 15 Jun 2002 12:46:11 +0900 + +debootstrap (0.1.17.1) unstable; urgency=low + + * NMU + * Add udeb support (closes: #143874) + + -- Tollef Fog Heen Tue, 28 May 2002 14:15:41 +0200 + +debootstrap (0.1.17) unstable; urgency=high + + * Includes changes from NMUs. Thanks to Stefan Gybas and Eduard Bloch. + (Closes: Bug#130764, Bug#135676, Bug#134306, Bug#133882, Bug#131768, + Bug#117980, Bug#133298, Bug#130668, Bug#111175, Bug#131147, Bug#95143, + Bug#130482) + + * Don't use PIPESTATUS to work out if wget succeeded, since that's a + bashism and we're seriously not allowed bashisms. Duh. This should + help with all those "Malformed release" problems. Thanks to Phil + Blundell and Chris Tillman for spotting this. (Closes: Bug#136729) + + * Apply patch from Matt Zimmerman to get rid of some irritating warnings + that can show up sometimes due to sed getting it's output stream closed + on it. (Closes: Bug#131478) + + * Don't use "export foo=bar" on a single line since it's a bashism. + (Closes: Bug#138187) + + * Made the "smallyes" usage independent of --boot-floppies. Too much + code duplication otherwise. + + * Install ipchains on arches that have 2.2.x kernels by default, and + iptables on arches that have 2.4.x kernels by default. Some arches + have both. (Closes: Bug#134478) + + * Don't rm malformed Release files, rename them to something obvious + instead so people can have a hope at seeing what's going on. (Closes: + Bug#131756) + + * Error out on missing entries in Release files. (Closes: Bug#136886) + + * Fix basedeb creation to not bother building devices tarball. (Closes: + Bug#137243) + + * Workaround for ldconfig no longer needed, so removed. (Closes: Bug#135819) + * Workaround for /dev/initctl was never needed and stupid, so removed. + + * Make sure devices.tar.gz is gzip -9'ed. (Closes: Bug#136687) + + * Use any "main" components found in Release file, eg "main", + "non-US/main", "local/main". (Closes: Bug#116801) + + * Add parted to base for ia64. (Closes: Bug#138246) + + * Moved the "successful!" message and sleep hack for boot-floppies from + the woody script to the debootstrap script itself. + + -- Anthony Towns Thu, 14 Mar 2002 18:28:24 +1000 + +debootstrap (0.1.16.4) unstable; urgency=low + + * NMU, needed for boot-floppies 3.0.20 + * Added cciss and ataraid device files, closes: #135675 + * Applied the patch from Matt Zimmermann to fix --include, closes: #134306 + * Mail suppression fixed in previous release, closes: #133882 + + -- Eduard Bloch Sun, 3 Mar 2002 12:21:19 +0100 + +debootstrap (0.1.16.3) unstable; urgency=low + + * non-maintainer-upload + * require newer makedev, fixes build problems on m86k and arm + * unsets $TMP, $TEMP and $TMPDIR in the beginning, closes: #131768, #117980 + * added gcc-2.96-base to ia64's required packages list, closes: #133298 + + -- Eduard Bloch Tue, 12 Feb 2002 19:30:47 +0100 + +debootstrap (0.1.16.2) unstable; urgency=low + + * non-maintainer-upload + * added modification suggested by Branden Robinson and Matt Kraai terminate + cat (now tail) better, closes: #130668 + * provides options to install additional packages, or exclude some from the + list. May be needed in boot-floppies soon. Closes: #111175, #131147 + * --verbose option, closes: #95143 + * added additional devices to the device list, especially input and usb + needed for modern device drivers (Joysticks, USB, Scanners) + * added pppoeconf to the packages list, better choice for DSL users + * forced remove of dev/initctl, prevents breaking on re-installation + + -- Eduard Bloch Mon, 28 Jan 2002 19:14:41 +0100 + +debootstrap (0.1.16.1) unstable; urgency=high + + * non-maintainer upload for boot-floppies 3.0.19 + * Fixed list of base and required packages for s390 + * setup_devices(): don't fail if devices.tar.gz is not present and we + are using devfs + * disable handling of /dev/initctl for boot-floppies, closes: #130482 + + -- Stefan Gybas Thu, 24 Jan 2002 15:17:42 +0100 + +debootstrap (0.1.16) unstable; urgency=low + + * Include NMUs 0.1.15.1 - .9, thanks to Adam di Carlo, Ethan Benson and + Bdale Garbee. (Closes: Bug#113265, Bug#119314, Bug#119251) + * Many bugs were fixed in the NMUs. Closes them properly. (Closes: + Bug#89673, Bug#97174, Bug#99229, Bug#105980, Bug#106062, Bug#106102, + Bug#106106, Bug#106134, Bug#106711, Bug#106877, Bug#107262, + Bug#107404, Bug#107447, Bug#109670, Bug#110312, Bug#111001, + Bug#111065, Bug#112778, Bug#112795, Bug#112842, Bug#113444, + Bug#114056, Bug#114653, Bug#115467, Bug#115481, Bug#115557, + Bug#115581, Bug#115699, Bug#116061, Bug#116424, Bug#119769, + Bug#119947, Bug#121724, Bug#123958, Bug#125954, Bug#126018, + Bug#126630, Bug#126799) + + * Informative error for people who type `--boot-floppies' when running + by hand. (Closes: Bug#107548) + * Create dev/initctl in target, and setup a cat process to dump anything + sent to it to /dev/null so that if init is run in the chroot, + it doesn't try doing anything too clever to talk to the real + init. (Closes: Bug#120597) + * Create awk symlink since base-files insists on having it available. + (Closes: Bug#127934) + + * Use DEBOOTSTRAP_DIR to work out where /usr/lib/debootstrap is. + * So, in theory, to create basedeb tarballs, you should be able to unpack + the source and say: + . + fakeroot debian/rules binary-basedebs SUITE=woody VERSION=3.0 \ + MIRROR="http://ftp.debian.org/debian" ARCHES="i386 powerpc" + (Closes: Bug#127546) + + -- Anthony Towns Sun, 20 Jan 2002 21:04:37 +1000 + +debootstrap (0.1.15.9) unstable; urgency=high + + * non-maintainer upload + * debian/rules: new 'basedebs' target that makes basedebs.tgz and 1.44 + split images for base per arch + * functions: better return value handling during wget (wgetprogress) + * repeat() had a useless eval, removed, which simplifies some silly + quoting + * incorrect error message in in_target_msg(), closes: #119769 + * debian/changelog: remove obsolete "local variables" + * additional progress message when validating the release file after + download + * when the downloaded release file is invalid, make sure to delete it + closes: #119947 + * debian/rules: minor fixes and cosmetics + * upgrade wget from Recommends to Depends, closes: #126799 + * depend on binutils, for 'ar', closes: #123958 + + -- Adam Di Carlo Fri, 4 Jan 2002 20:01:58 -0500 + +debootstrap (0.1.15.8) unstable; urgency=high + + * non-maintainer upload + * Fix progress bar hooks to enable proper progress on basedebs.tgz + installation as well as actual base installation and extraction. + * trap signals so cleanup is still performed. + * When in --boot-floppies mode echo a Success info message to stdout, so + it will show up on /dev/tty4, this is so users watching tty4 stop + being confused when things just stop at completion. + * Replace $TARGET/sbin/start-stop-daemon with a shell script instead of + /bin/true, this shell script announces that its a fake noop version so + users will know whats wrong if debootstrap aborts before completion. + + -- Ethan Benson Sat, 3 Nov 2001 23:14:08 -0900 + +debootstrap (0.1.15.7) unstable; urgency=high + + * non-maintainer upload + * when reporting errors in 'in_target', don't chop down to the first + 50 characters + * woody: when in boot-floppies mode, provide more user-friendly warning + messages, using new 'in_target_msg' function + * woody: more info messages for the core/required/base package + installation part + * instead of 'ln -s' we should be using 'ln -sf'; this would prevent + running debootstrap twice in the same target dir; closes: #111065 + * before mounting proc, umount it just in case; normally this shouldn't + be needed if on_exit is working all the time, but I find without this, + sometimes problems are caused + * woody/i386 needs psmisc for pcmcia-cs (critical bug!) + * --download-only mode can be run as non-root; closes: #116424 + * tested some problems which I couldn't reproduce + closes: #115699 + + -- Adam Di Carlo Wed, 24 Oct 2001 16:05:39 -0400 + +debootstrap (0.1.15.6) unstable; urgency=medium + + * non-maintainer upload + * smaller and wiser version of smallyes(), thanks to Herbert Xu + * woody base includes pcmcia-cs for i386 and powerpc (closes: #114653) + * wget progress bar support (closes: #116061) + + -- Adam Di Carlo Thu, 18 Oct 2001 15:14:02 -0400 + +debootstrap (0.1.15.5) unstable; urgency=high + + * From Ethan Benson: + * pipe yes output into dpkg runs inside install_debs() this way on_exit + works in --boot-floppies mode. (Closes: #112842, #115481) + * Add libpcap0 to base, ppp depends on it now. (Closes: #114056) + + * From Adam Di Carlo: + * Potato installation on non-i386 was broken, need libc6 + (closes: #112778); however, there are other ways the Potato base + install doesn't represent quite what Potato boot-floppies would + consider base + * apply patch from Tommi Virtanen which improves the 'smallyes' + function; apparently this fixes a console-tools postinst loop, + although I haven't seen that (closes: #115581) + * get rid of some line continuators in potato and woody scripts, they + were obscuring some problems + + -- Adam Di Carlo Mon, 15 Oct 2001 01:56:16 -0400 + +debootstrap (0.1.15.4) unstable; urgency=high + + * more fixed for the benefits of boot-floppies + * add telnetd on s390; yes, it's gross, but it's needed for + installation, to connect from the line mode console + closes: #112795 + + -- Adam Di Carlo Sun, 23 Sep 2001 16:11:03 -0400 + +debootstrap (0.1.15.3) unstable; urgency=high + + * Fix deficient command line option parsing, optional arguments no + longer have to be declared in a specific order, for example before you + could not put --arch before --download-only, now you can. + * Add --help option and useful help output. + * Stop using dirname, basename, and yes, they are being removed from + busybox. + * Fix many many quoting bugs. + * Fix debootstrap man page (Closes: #107404, #109670) + * Add ftp support (Closes: #110312) + * Don't waste time downloading useless non-free/contrib (Closes: #89673) + * Path cleanup (Closes: #97174) + * Add pppconfig to woody base (Closes: #111001) + * Remove syslinux from base (Closes: #107447) + * Eliminate useless warning about creating exim.conf (Closes: #99229) + * Don't use "here documents" (they create tmp files in /tmp which could + be very well be full on boot-floppies). + * Don't use echo -n it is not portable. + * Set umask to 022. + * All patches from Ethan Benson, I am just the builder! + These have been tested with boot-floppies and work properly. + + -- Adam Di Carlo Sat, 22 Sep 2001 12:30:02 -0400 + +debootstrap (0.1.15.2) unstable; urgency=low + + * quoting required in one place for the new ash (Closes: Bug#106062) + * s390 support (Closes: Bug#107262) + * remove some packages from Woody's base that aren't needed: + - update (not needed with modern kernels, Closes: Bug#106877) + - syslinux (Closes: Bug#107477) + - ldso (should be pulled in by libc6, Closes: Bug#106102) + * kinks in mipsel base worked themselves out (Closes: Bug#106711) + + -- Adam Di Carlo Wed, 8 Aug 2001 12:04:40 -0400 + +debootstrap (0.1.15.1) unstable; urgency=low + + * add efibootmgr on ia64, as per bug 105980. + + -- Bdale Garbee Fri, 3 Aug 2001 14:13:23 -0600 + +debootstrap (0.1.15) unstable; urgency=low + + * Do progress indications (by bytes) for Packages downloads and .deb + downloads. (Closes: Bug#101886) + * Don't use seq. Silly busybox. + * Add pppoe to base. (Closes: Bug#102378) + * No point keeping around the "sid.is-broken" file. + + -- Anthony Towns Wed, 27 Jun 2001 21:29:29 +1000 + +debootstrap (0.1.14) unstable; urgency=low + + * Make in_target_nofail kill stderr. No more "/dev/pts: not mounted" error. + Yay. :) + + * Refactor woody, potato and slink scripts; do away with + woody.debs. Change the way the scripts work. (Now they define + functions which debootstrap calls. Much nicer) + * Support --download-only option. + * Support resuming downloads of Release and Packages files, even gzipped + ones. + * Support null: (Packages files assumed to be named for a debootstrap.invalid + host) + * Always use the deboostrap.invalid name, and use that in + /etc/apt/sources.list. Remove /etc/apt/sources.list after the base + system is build. + * All this should be enough to support basedeb.tgz installs on + debootstrap's behalf. Some more stuff would be useful, but isn't + immediately necessary. (Closes: Bug#102217) + + * Add ia64 support and fix libc6 == libc6.1 problem. (Closes: Bug#101829) + + * Be a little more careful with permissions on devs tarball. Hopefully. + (Closes: Bug#102308) + + * Don't worry if md5sum from stdin adds a " -" after the md5sum. Should + make debootstrap more usable on non-Debian Linuxes. + + -- Anthony Towns Mon, 25 Jun 2001 18:38:35 +1000 + +debootstrap (0.1.13) unstable; urgency=low + + * Add symlink for sid.debs. + * Fix the special casing for hppa. (Closes: Bug#101604) + * Remove groff from base. (Closes: Bug#101173) + * Retry partially successful downloads a couple of times. + (Closes: Bug#101476) + * Minor wording changes wrt downloading Release file (Closes: Bug#101705) + + -- Anthony Towns Thu, 21 Jun 2001 12:08:10 +1000 + +debootstrap (0.1.12) unstable; urgency=high + + * Split determination of base into a separate script to enable further + innovation! Come on, tell me that doesn't excite you! + + * Add groff-base to base. (Closes: Bug#100112, Bug#100123) + * Remove libstdc++2.10 and some other hopefully unnecessary debs + (Closes: Bug#99708) + + * Remove lilo.conf special casing. Change some warnings to info messages. + + -- Anthony Towns Sun, 10 Jun 2001 01:22:12 +1000 + +debootstrap (0.1.11) unstable; urgency=low + + * Add dhcp-client to base. (Closes: Bug#100083) + + -- Anthony Towns Sat, 9 Jun 2001 00:11:26 +1000 + +debootstrap (0.1.10) unstable; urgency=low + + * Don't abort build on devfs systems: the makedev we build-dep on should + be recent enough. (Closes: Bug#97713) + * Check for malformed release files. Thanks to Martin Michlmayr for the + patch. (Closes: Bug#97707) + * Use --force-confold when installing base. That is: if you want the + conffile from the package to be there at the end, don't create a + file in the first place. I'm not convinced this is right. + (Closes: Bug#99025) + + -- Anthony Towns Mon, 28 May 2001 14:43:07 +1000 + +debootstrap (0.1.9) unstable; urgency=low + + * Abort build on devfs systems (MAKEDEV fails for no good reason) + (Closes: Bug#97713) + + * Add support for mips and mipsel (Closes: Bug#97711) + * Add some support for hppa (install palo in base) + + * Don't install ldso (Closes: Bug#97708) + * Don't install libopenldap1 or libopenldap-runtime (replaced by libldap2) + (Closes: Bug#98050) + * Do install libdb3 and libcap1. + * Install klogd too. (But only as part of base. Move sysklogd to base too) + + * Setup a dummy lilo.conf on i386 only. (Closes: Bug#97710, Bug#98052) + + * Trim a trailing / for target and url. + + -- Anthony Towns Sun, 20 May 2001 13:33:34 +1000 + +debootstrap (0.1.8) unstable; urgency=low + + * Add adduser and base-config into base. base-config unfortunately depends + on perl instead of perl-base. (Closes: Bug#96439) + * Force LANG=C. Need to work out how i18n should be handled. + * Kludge potato install so it's noninteractive. Thanks to Colin Watson + for the patch. (Closes: Bug#94441) + * Get rid of dh_testversion. + * Make a sid script (just a symlink to the woody script). + + -- Anthony Towns Wed, 9 May 2001 20:33:00 +1000 + +debootstrap (0.1.7) unstable; urgency=low + + * Don't worry if umounting /dev/pts fails. + * Add debootstrap(8) manpage, thanks to Matt Kraai. (Closes: Bug#86238) + * Add a blank line to the end of the faked /var/lib/dpkg/status. Spotted + by Richard Hirst. + * Added console-tools and console-data into the base system. + * Move /etc/exim.conf to /etc/exim/exim.conf so that sendmail doesn't + give errors, even if debconf tries to use it before exim is + configured. Gack. + * Add fdutils back into base. + + -- Anthony Towns Mon, 30 Apr 2001 15:49:27 +1000 + +debootstrap (0.1.6) unstable; urgency=low + + * Only create stuff in /etc if it hasn't already been created. + + -- Anthony Towns Mon, 23 Apr 2001 18:02:55 +1000 + +debootstrap (0.1.5) unstable; urgency=low + + * Use "head -n X" instead of "head -X" to work with busybox. + (Closes: Bug#94575) + * Use s///I instead of s///i for case insensitivity, again for busybox. + (Closes: Bug#94579) + * Fixed typo that would have stopped debootstrap from falling back to an + uncompressed Packages file. + * Added libsasl7 and libldap2 to woody base, since woody exim now depends + on them. + + -- Anthony Towns Sun, 22 Apr 2001 01:47:00 +1000 + +debootstrap (0.1.4) unstable; urgency=low + + * If we've got a Release file, check that the Packages files we download + have the right md5sums. + * Build-Depend on new makedev, and don't hax0r powerpc devices as much. + (Closes: Bug#93836) + * Hopefully support arm chroots. (Closes: Bug#92592) Declare it to be + Arch: any, and see what dies. There's a chance that nothing will. Not + a *big* chance, but a chance. + * Fiddled with the base system some more. Added apt-utils so + preconfiguration will work. + * Added permission to NMU to the README.Debian. + * Mention file:/ URLs in README.Debian. (Closes: Bug#87099) + * Add a --boot-floppies option that changes the way the I/O happens, in + a way that's hopefully useful for boot-floppies. See README.Debian for + details. + * Also added a bit more output. + + -- Anthony Towns Mon, 26 Mar 2001 22:30:12 +1000 + +debootstrap (0.1.3) unstable; urgency=high + + * Switch from debconf-tiny to debconf, since that's what's now in + woody. (Using debconf-tiny probably makes the package unusable, hence + the urgency) Fixup perl, lilo and console-apt to cope with changes in + the base system in woody. Added ae, left nano and nvi. + * Add support for m68k, sparc and powerpc, based on Christian Steigies + patches and Adam Di Carlo's NMU (Closes: Bug#89883, Bug#91221) + + -- Anthony Towns Sun, 25 Mar 2001 14:29:02 +1000 + +debootstrap (0.1.2) unstable; urgency=low + + * Add support for slink. + * Fix support for woody (no lilo, console-*, different perl) + * Re-download Packages files every time (Closes: Bug#88438) + (Should this be changed to re-download things where the md5 doesn't match?) + + -- Anthony Towns Sun, 4 Mar 2001 19:42:29 +1000 + +debootstrap (0.1.1) unstable; urgency=low + + * Initial Release. (Closes: Bug#82245) + + * Called it debootstrap instead of debchroot, because it's more about + bootstrapping a Debian environment, whether that will end up being + in a chroot, or as a standalone system. Blame Adam di Carlo. :) + + -- Anthony Towns Tue, 30 Jan 2001 10:54:45 +1000 diff --git a/cdist/preos/debootstrap/files/devuan-debootstrap/debian/compat b/cdist/preos/debootstrap/files/devuan-debootstrap/debian/compat new file mode 100644 index 00000000..ec635144 --- /dev/null +++ b/cdist/preos/debootstrap/files/devuan-debootstrap/debian/compat @@ -0,0 +1 @@ +9 diff --git a/cdist/preos/debootstrap/files/devuan-debootstrap/debian/control b/cdist/preos/debootstrap/files/devuan-debootstrap/debian/control new file mode 100644 index 00000000..6925a63c --- /dev/null +++ b/cdist/preos/debootstrap/files/devuan-debootstrap/debian/control @@ -0,0 +1,26 @@ +Source: debootstrap +Section: admin +Priority: extra +Maintainer: Franco (nextime) Lanza +Uploaders: Franco (nextime) Lanza , Daniel Reurich +Build-Depends: debhelper (>= 9), makedev (>= 2.3.1-69) [linux-any], git +Standards-Version: 3.9.8 +Vcs-Browser: https://git.devuan.org/devuan-packages/debootstrap +Vcs-Git: https://git.devuan.org/devuan-packages/debootstrap.git + +Package: debootstrap +Architecture: all +Depends: ${misc:Depends}, wget +Recommends: gnupg, ${keyring}, devuan-keyring +Description: Bootstrap a basic Devuan system + debootstrap is used to create a Devuan base system from scratch, + without requiring the availability of dpkg or apt. It does this by + downloading .deb files from a mirror site, and carefully unpacking them + into a directory which can eventually be chrooted into. + +Package: debootstrap-udeb +Section: debian-installer +Package-Type: udeb +Architecture: all +Depends: ${misc:Depends}, mounted-partitions +Description: Bootstrap the Devuan system diff --git a/cdist/preos/debootstrap/files/devuan-debootstrap/debian/copyright b/cdist/preos/debootstrap/files/devuan-debootstrap/debian/copyright new file mode 100644 index 00000000..b34963b1 --- /dev/null +++ b/cdist/preos/debootstrap/files/devuan-debootstrap/debian/copyright @@ -0,0 +1,30 @@ +This package was debianized by Anthony Towns on +Tue, 30 Jan 2001 10:54:45 +1000. + +It was written from scratch for Debian by Anthony Towns +based loosely on the code for constructing base tarballs as part of the +boot-floppies package. + +Copyright: + +Copyright (c) 2001-2005 Anthony Towns + + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + diff --git a/cdist/preos/debootstrap/files/devuan-debootstrap/debian/debootstrap.docs b/cdist/preos/debootstrap/files/devuan-debootstrap/debian/debootstrap.docs new file mode 100644 index 00000000..e845566c --- /dev/null +++ b/cdist/preos/debootstrap/files/devuan-debootstrap/debian/debootstrap.docs @@ -0,0 +1 @@ +README diff --git a/cdist/preos/debootstrap/files/devuan-debootstrap/debian/debootstrap.manpages b/cdist/preos/debootstrap/files/devuan-debootstrap/debian/debootstrap.manpages new file mode 100644 index 00000000..d6a5e4ac --- /dev/null +++ b/cdist/preos/debootstrap/files/devuan-debootstrap/debian/debootstrap.manpages @@ -0,0 +1 @@ +debootstrap.8 diff --git a/cdist/preos/debootstrap/files/devuan-debootstrap/debian/gbp.conf b/cdist/preos/debootstrap/files/devuan-debootstrap/debian/gbp.conf new file mode 100644 index 00000000..ac8e799c --- /dev/null +++ b/cdist/preos/debootstrap/files/devuan-debootstrap/debian/gbp.conf @@ -0,0 +1,9 @@ +[DEFAULT] +compression = xz +pristine-tar = false +upstream-tag = devuan/1.0.85 + +[git-buildpackage] +upstream-tree = tag +tarball-dir = ../tarballs/ +export-dir = ../build-area/ diff --git a/cdist/preos/debootstrap/files/devuan-debootstrap/debian/rules b/cdist/preos/debootstrap/files/devuan-debootstrap/debian/rules new file mode 100755 index 00000000..23bc4a61 --- /dev/null +++ b/cdist/preos/debootstrap/files/devuan-debootstrap/debian/rules @@ -0,0 +1,47 @@ +#! /usr/bin/make -f + +ifeq (0,$(shell dpkg-vendor --derives-from Ubuntu; echo $$?)) + KEYRING := ubuntu-keyring +else ifeq (0,$(shell dpkg-vendor --derives-from Devuan; echo $$?)) + KEYRING := devuan-keyring +else ifeq (0,$(shell dpkg-vendor --derives-from Tanglu; echo $$?)) + KEYRING := tanglu-archive-keyring +else + KEYRING := debian-archive-keyring +endif + +%: + dh $@ + +# need to be root to make devices, so build is done in install target +override_dh_auto_build: + +override_dh_auto_install: + dh_auto_build + + $(MAKE) install DESTDIR=$(CURDIR)/debian/debootstrap + $(MAKE) install DESTDIR=$(CURDIR)/debian/debootstrap-udeb + + # remove scripts not needed by d-i + -rm -f debian/debootstrap-udeb/usr/share/debootstrap/scripts/potato \ + debian/debootstrap-udeb/usr/share/debootstrap/scripts/woody \ + debian/debootstrap-udeb/usr/share/debootstrap/scripts/sarge \ + debian/debootstrap-udeb/usr/share/debootstrap/scripts/warty \ + debian/debootstrap-udeb/usr/share/debootstrap/scripts/hoary \ + debian/debootstrap-udeb/usr/share/debootstrap/scripts/breezy \ + debian/debootstrap-udeb/usr/share/debootstrap/scripts/dapper \ + debian/debootstrap-udeb/usr/share/debootstrap/scripts/edgy \ + debian/debootstrap-udeb/usr/share/debootstrap/scripts/feisty \ + debian/debootstrap-udeb/usr/share/debootstrap/scripts/*.buildd \ + debian/debootstrap-udeb/usr/share/debootstrap/scripts/*.fakechroot \ + debian/debootstrap-udeb/usr/share/debootstrap/scripts/stable \ + debian/debootstrap-udeb/usr/share/debootstrap/scripts/testing \ + debian/debootstrap-udeb/usr/share/debootstrap/scripts/unstable + +override_dh_gencontrol: + dh_gencontrol -- -Vkeyring=$(KEYRING) + +# Specify gzip to mitigate #770217: +override_dh_builddeb: + dh_builddeb -pdebootstrap -- -Zgzip + dh_builddeb -pdebootstrap-udeb -- -Zxz diff --git a/cdist/preos/debootstrap/files/devuan-debootstrap/debian/source/format b/cdist/preos/debootstrap/files/devuan-debootstrap/debian/source/format new file mode 100644 index 00000000..af745b31 --- /dev/null +++ b/cdist/preos/debootstrap/files/devuan-debootstrap/debian/source/format @@ -0,0 +1 @@ +3.0 (git) diff --git a/cdist/preos/debootstrap/files/devuan-debootstrap/debootstrap b/cdist/preos/debootstrap/files/devuan-debootstrap/debootstrap new file mode 100755 index 00000000..71c70540 --- /dev/null +++ b/cdist/preos/debootstrap/files/devuan-debootstrap/debootstrap @@ -0,0 +1,703 @@ +#!/bin/sh +set -e + +VERSION='@VERSION@' + +unset TMP TEMP TMPDIR || true + +# might not be exported if we're running from init=/bin/sh or similar +export PATH + +########################################################################### + +if [ -z "$DEBOOTSTRAP_DIR" ]; then + if [ -x /debootstrap/debootstrap ]; then + DEBOOTSTRAP_DIR=/debootstrap + else + DEBOOTSTRAP_DIR=/usr/share/debootstrap + fi +fi + +. $DEBOOTSTRAP_DIR/functions +exec 4>&1 + +LANG=C +USE_COMPONENTS=main +KEYRING="" +DISABLE_KEYRING="" +FORCE_KEYRING="" +VARIANT="" +MERGED_USR="no" +ARCH="" +HOST_ARCH="" +HOST_OS="" +KEEP_DEBOOTSTRAP_DIR="" +USE_DEBIANINSTALLER_INTERACTION="" +SECOND_STAGE_ONLY="" +PRINT_DEBS="" +CHROOTDIR="" +MAKE_TARBALL="" +EXTRACTOR_OVERRIDE="" +UNPACK_TARBALL="" +ADDITIONAL="" +EXCLUDE="" +VERBOSE="" +CERTIFICATE="" +CHECKCERTIF="" +PRIVATEKEY="" + + +DEF_MIRROR="http://packages.devuan.org/merged" +DEF_HTTPS_MIRROR="https://packages.devuan.org/merged" + +export LANG USE_COMPONENTS EXCLUDE +umask 022 + +########################################################################### + +## phases: +## finddebs dldebs printdebs first_stage second_stage + +RESOLVE_DEPS=true + +WHAT_TO_DO="finddebs dldebs first_stage second_stage" +am_doing_phase () { + # usage: if am_doing_phase finddebs; then ...; fi + local x; + for x in "$@"; do + if echo " $WHAT_TO_DO " | grep -q " $x "; then return 0; fi + done + return 1 +} + +########################################################################### + +usage_err() +{ + info USAGE1 "usage: [OPTION]... [ [