Merge branch 'master' into preos
This commit is contained in:
commit
28ba493e71
80 changed files with 1387 additions and 165 deletions
0
cdist/conf/type/__cron/explorer/entry
Executable file → Normal file
0
cdist/conf/type/__cron/explorer/entry
Executable file → Normal file
|
@ -2,6 +2,7 @@
|
||||||
#
|
#
|
||||||
# 2011 Steven Armstrong (steven-cdist at armstrong.cc)
|
# 2011 Steven Armstrong (steven-cdist at armstrong.cc)
|
||||||
# 2013 Nico Schottelius (nico-cdist at schottelius.org)
|
# 2013 Nico Schottelius (nico-cdist at schottelius.org)
|
||||||
|
# 2013 Thomas Oettli (otho at sfs.biz)
|
||||||
#
|
#
|
||||||
# This file is part of cdist.
|
# This file is part of cdist.
|
||||||
#
|
#
|
||||||
|
@ -26,6 +27,8 @@ command="$(cat "$__object/parameter/command")"
|
||||||
if [ -f "$__object/parameter/raw" ]; then
|
if [ -f "$__object/parameter/raw" ]; then
|
||||||
raw="$(cat "$__object/parameter/raw")"
|
raw="$(cat "$__object/parameter/raw")"
|
||||||
entry="$raw $command"
|
entry="$raw $command"
|
||||||
|
elif [ -f "$__object/parameter/raw_command" ]; then
|
||||||
|
entry="$command"
|
||||||
else
|
else
|
||||||
minute="$(cat "$__object/parameter/minute" 2>/dev/null || echo "*")"
|
minute="$(cat "$__object/parameter/minute" 2>/dev/null || echo "*")"
|
||||||
hour="$(cat "$__object/parameter/hour" 2>/dev/null || echo "*")"
|
hour="$(cat "$__object/parameter/hour" 2>/dev/null || echo "*")"
|
||||||
|
@ -55,8 +58,9 @@ state_should="$(cat "$__object/parameter/state" 2>/dev/null || echo "present")"
|
||||||
# These are the old markers
|
# These are the old markers
|
||||||
prefix="#cdist:__cron/$__object_id"
|
prefix="#cdist:__cron/$__object_id"
|
||||||
suffix="#/cdist:__cron/$__object_id"
|
suffix="#/cdist:__cron/$__object_id"
|
||||||
|
filter="^# DO NOT EDIT THIS FILE|^# \(.* installed on |^# \(Cron version V"
|
||||||
cat << DONE
|
cat << DONE
|
||||||
crontab -u $user -l | awk -v prefix="$prefix" -v suffix="$suffix" '
|
crontab -u $user -l 2>/dev/null | grep -v -E "$filter" | awk -v prefix="$prefix" -v suffix="$suffix" '
|
||||||
{
|
{
|
||||||
if (index(\$0,prefix)) {
|
if (index(\$0,prefix)) {
|
||||||
triggered=1
|
triggered=1
|
||||||
|
@ -75,12 +79,12 @@ DONE
|
||||||
case "$state_should" in
|
case "$state_should" in
|
||||||
present)
|
present)
|
||||||
echo "("
|
echo "("
|
||||||
echo "crontab -u $user -l 2>/dev/null || true"
|
echo "crontab -u $user -l 2>/dev/null | grep -v -E \"$filter\" 2>/dev/null || true"
|
||||||
echo "echo '$entry'"
|
echo "echo '$entry'"
|
||||||
echo ") | crontab -u $user -"
|
echo ") | crontab -u $user -"
|
||||||
;;
|
;;
|
||||||
absent)
|
absent)
|
||||||
echo "( crontab -u $user -l 2>/dev/null || true ) | \\"
|
echo "( crontab -u $user -l 2>/dev/null | grep -v -E \"$filter\" 2>/dev/null || true ) | \\"
|
||||||
echo "grep -v \"# $name\\$\" | crontab -u $user -"
|
echo "grep -v \"# $name\\$\" | crontab -u $user -"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
|
@ -41,6 +41,10 @@ raw::
|
||||||
Can for example be used to specify cron EXTENSIONS like reboot, yearly etc.
|
Can for example be used to specify cron EXTENSIONS like reboot, yearly etc.
|
||||||
See crontab(5) for the extensions if any that your cron implementation
|
See crontab(5) for the extensions if any that your cron implementation
|
||||||
implements.
|
implements.
|
||||||
|
raw_command::
|
||||||
|
Take whatever the user has given in the commmand and ignore everything else.
|
||||||
|
If given, the command will be added to crontab.
|
||||||
|
Can for example be used to define variables like SHELL or MAILTO.
|
||||||
|
|
||||||
|
|
||||||
EXAMPLES
|
EXAMPLES
|
||||||
|
@ -57,6 +61,10 @@ __cron some-id --user root --command "/path/to/script" \
|
||||||
|
|
||||||
# remove cronjob
|
# remove cronjob
|
||||||
__cron some-id --user root --command "/path/to/script" --state absent
|
__cron some-id --user root --command "/path/to/script" --state absent
|
||||||
|
|
||||||
|
# define default shell
|
||||||
|
__cron some-id --user root --raw_command --command "SHELL=/bin/bash" \
|
||||||
|
--state present
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
|
24
cdist/conf/type/__cron/manifest
Normal file
24
cdist/conf/type/__cron/manifest
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# 2013 Thomas Oettli (otho at sfs.biz)
|
||||||
|
#
|
||||||
|
# This file is part of cdist.
|
||||||
|
#
|
||||||
|
# cdist is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# cdist is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
|
||||||
|
if [ -f "$__object/parameter/raw" ] && [ -f "$__object/parameter/raw_command" ]; then
|
||||||
|
echo "ERROR: both raw and raw_command specified" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
1
cdist/conf/type/__cron/parameter/boolean
Normal file
1
cdist/conf/type/__cron/parameter/boolean
Normal file
|
@ -0,0 +1 @@
|
||||||
|
raw_command
|
|
@ -57,14 +57,17 @@ get_current_value() {
|
||||||
|
|
||||||
set_group() {
|
set_group() {
|
||||||
echo chgrp $recursive \"$1\" \"$destination\"
|
echo chgrp $recursive \"$1\" \"$destination\"
|
||||||
|
echo chgrp $recursive $1 >> "$__messages_out"
|
||||||
}
|
}
|
||||||
|
|
||||||
set_owner() {
|
set_owner() {
|
||||||
echo chown $recursive \"$1\" \"$destination\"
|
echo chown $recursive \"$1\" \"$destination\"
|
||||||
|
echo chown $recursive $1 >> "$__messages_out"
|
||||||
}
|
}
|
||||||
|
|
||||||
set_mode() {
|
set_mode() {
|
||||||
echo chmod $recursive \"$1\" \"$destination\"
|
echo chmod $recursive \"$1\" \"$destination\"
|
||||||
|
echo chmod $recursive $1 >> "$__messages_out"
|
||||||
}
|
}
|
||||||
|
|
||||||
case "$state_should" in
|
case "$state_should" in
|
||||||
|
@ -77,6 +80,7 @@ case "$state_should" in
|
||||||
rm -f "$destination"
|
rm -f "$destination"
|
||||||
mkdir $mkdiropt "$destination"
|
mkdir $mkdiropt "$destination"
|
||||||
DONE
|
DONE
|
||||||
|
echo "remove non directory" >> "$__messages_out"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Note: Mode - needs to happen last as a chown/chgrp can alter mode by
|
# Note: Mode - needs to happen last as a chown/chgrp can alter mode by
|
||||||
|
@ -85,7 +89,13 @@ DONE
|
||||||
if [ -f "$__object/parameter/$attribute" ]; then
|
if [ -f "$__object/parameter/$attribute" ]; then
|
||||||
value_should="$(cat "$__object/parameter/$attribute")"
|
value_should="$(cat "$__object/parameter/$attribute")"
|
||||||
value_is="$(get_current_value "$attribute" "$value_should")"
|
value_is="$(get_current_value "$attribute" "$value_should")"
|
||||||
if [ "$set_attributes" -o "$value_should" != "$value_is" ]; then
|
|
||||||
|
# change 0xxx format to xxx format => same as stat returns
|
||||||
|
if [ "$attribute" = mode ]; then
|
||||||
|
value_should="$(echo $value_should | sed 's/^0\(...\)/\1/')"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$set_attributes" = 1 ] || [ "$value_should" != "$value_is" ]; then
|
||||||
"set_$attribute" "$value_should"
|
"set_$attribute" "$value_should"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -94,6 +104,7 @@ DONE
|
||||||
absent)
|
absent)
|
||||||
if [ "$type" = "directory" ]; then
|
if [ "$type" = "directory" ]; then
|
||||||
echo rm -rf \"$destination\"
|
echo rm -rf \"$destination\"
|
||||||
|
echo remove >> "$__messages_out"
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
|
|
|
@ -58,10 +58,12 @@ if grep -q "^${name}:" "$__object/explorer/group"; then
|
||||||
|
|
||||||
if [ "$new_value" != "$current_value" ]; then
|
if [ "$new_value" != "$current_value" ]; then
|
||||||
set -- "$@" "$proparg" \"$new_value\"
|
set -- "$@" "$proparg" \"$new_value\"
|
||||||
|
echo change $property $new_value $current_value >> "$__messages_out"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ $# -gt 0 ]; then
|
if [ $# -gt 0 ]; then
|
||||||
|
echo mod >> "$__messages_out"
|
||||||
case $os in
|
case $os in
|
||||||
freebsd)
|
freebsd)
|
||||||
echo pw group mod "$@" "$name"
|
echo pw group mod "$@" "$name"
|
||||||
|
@ -72,6 +74,7 @@ if grep -q "^${name}:" "$__object/explorer/group"; then
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
|
echo add >> "$__messages_out"
|
||||||
for property in $(ls .); do
|
for property in $(ls .); do
|
||||||
new_value="$(cat "$property")"
|
new_value="$(cat "$property")"
|
||||||
if [ "$os" = "freebsd" ]; then
|
if [ "$os" = "freebsd" ]; then
|
||||||
|
@ -95,6 +98,7 @@ else
|
||||||
fi
|
fi
|
||||||
|
|
||||||
set -- "$@" "$proparg" \"$new_value\"
|
set -- "$@" "$proparg" \"$new_value\"
|
||||||
|
echo set $property $new_value >> "$__messages_out"
|
||||||
done
|
done
|
||||||
|
|
||||||
case $os in
|
case $os in
|
||||||
|
|
|
@ -26,8 +26,8 @@ state_should=present
|
||||||
|
|
||||||
file="$(cat "$__object/parameter/file")"
|
file="$(cat "$__object/parameter/file")"
|
||||||
delimiter="$(cat "$__object/parameter/delimiter")"
|
delimiter="$(cat "$__object/parameter/delimiter")"
|
||||||
value="$(cat "$__object/parameter/value")"
|
# escape double quotes, as that is what we use ourself below
|
||||||
|
value_escaped="$(cat "$__object/parameter/value" | sed -e "s/\([\"]\)/\\\\\1/g")"
|
||||||
state_is="$(cat "$__object/explorer/state")"
|
state_is="$(cat "$__object/explorer/state")"
|
||||||
|
|
||||||
[ "$state_is" = "$state_should" ] && exit 0
|
[ "$state_is" = "$state_should" ] && exit 0
|
||||||
|
@ -35,20 +35,29 @@ state_is="$(cat "$__object/explorer/state")"
|
||||||
case "$state_should" in
|
case "$state_should" in
|
||||||
absent)
|
absent)
|
||||||
# remove lines starting with key
|
# remove lines starting with key
|
||||||
echo "sed '/^$key\($delimiter\+\)/d' \"$file\" > \"$file.cdist-tmp\""
|
cat << DONE
|
||||||
echo "mv \"$file.cdist-tmp\" \"$file\""
|
tmpfile=\$(mktemp ${file}.cdist.XXXXXXXXXX)
|
||||||
|
# preserve ownership and permissions by copying existing file over tmpfile
|
||||||
|
cp -p "$file" "\$tmpfile"
|
||||||
|
sed '/^$key\($delimiter\+\)/d' "$file" > "\$tmpfile"
|
||||||
|
mv -f "\$tmpfile" "$file"
|
||||||
|
DONE
|
||||||
;;
|
;;
|
||||||
present)
|
present)
|
||||||
case "$state_is" in
|
case "$state_is" in
|
||||||
absent)
|
absent)
|
||||||
# add new key and value
|
# add new key and value
|
||||||
echo "echo \"${key}${delimiter}${value}\" >> \"$file\""
|
printf 'echo "%s%s%s" >> "%s"' "$key" "$delimiter" "$value_escaped" "$file"
|
||||||
;;
|
;;
|
||||||
wrongvalue)
|
wrongvalue)
|
||||||
# change exisiting value
|
# change exisiting value
|
||||||
printf 'sed "s|^%s\(%s\+\).*|%s\\1%s|" "%s" > "%s.cdist-tmp"\n' \
|
cat << DONE
|
||||||
"$key" "$delimiter" "$key" "$value" "$file" "$file"
|
tmpfile=\$(mktemp ${file}.cdist.XXXXXXXXXX)
|
||||||
echo "mv \"$file.cdist-tmp\" \"$file\""
|
# preserve ownership and permissions by copying existing file over tmpfile
|
||||||
|
cp -p "$file" "\$tmpfile"
|
||||||
|
sed "s|^$key\($delimiter\+\).*|$key\\1$value_escaped|" "$file" > "\$tmpfile"
|
||||||
|
mv -f "\$tmpfile" "$file"
|
||||||
|
DONE
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Unknown explorer state: $state_is" >&2
|
echo "Unknown explorer state: $state_is" >&2
|
||||||
|
|
|
@ -49,7 +49,15 @@ case "$state_should" in
|
||||||
# Replace all \ so \t and other combinations are not interpreted
|
# Replace all \ so \t and other combinations are not interpreted
|
||||||
#
|
#
|
||||||
|
|
||||||
line_sanitised=$(cat "$__object/parameter/line" | sed -e "s/'/'\"'\"'/g" -e 's/\\/\\\\/g')
|
|
||||||
|
# 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")
|
||||||
echo "printf '%s\n' '$line_sanitised' >> $file"
|
echo "printf '%s\n' '$line_sanitised' >> $file"
|
||||||
|
|
||||||
;;
|
;;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
#
|
#
|
||||||
# 2011 Steven Armstrong (steven-cdist at armstrong.cc)
|
# 2011-2013 Steven Armstrong (steven-cdist at armstrong.cc)
|
||||||
#
|
#
|
||||||
# This file is part of cdist.
|
# This file is part of cdist.
|
||||||
#
|
#
|
||||||
|
@ -44,10 +44,12 @@ else
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
set -- "$@" "$__object_id"
|
state="$(cat "$__object/parameter/state")"
|
||||||
|
|
||||||
|
set -- "$@" "$__object_id" "--state" "$state"
|
||||||
cd "$__object/parameter"
|
cd "$__object/parameter"
|
||||||
for property in $(ls .); do
|
for property in $(ls .); do
|
||||||
if [ "$property" != "type" ]; then
|
if [ "$property" != "type" -a "$property" != "state" ]; then
|
||||||
set -- "$@" "--$property" "$(cat "$property")"
|
set -- "$@" "--$property" "$(cat "$property")"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
1
cdist/conf/type/__package/parameter/default/state
Normal file
1
cdist/conf/type/__package/parameter/default/state
Normal file
|
@ -0,0 +1 @@
|
||||||
|
present
|
|
@ -3,3 +3,4 @@ version
|
||||||
type
|
type
|
||||||
pkgsite
|
pkgsite
|
||||||
state
|
state
|
||||||
|
ptype
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
#
|
#
|
||||||
# 2011-2012 Nico Schottelius (nico-cdist at schottelius.org)
|
# 2011-2013 Nico Schottelius (nico-cdist at schottelius.org)
|
||||||
#
|
#
|
||||||
# This file is part of cdist.
|
# This file is part of cdist.
|
||||||
#
|
#
|
||||||
|
@ -42,6 +42,8 @@ case "$state_is" in
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
# Hint if we need to avoid questions at some point:
|
||||||
|
# DEBIAN_PRIORITY=critical can reduce the number of questions
|
||||||
aptget="DEBIAN_FRONTEND=noninteractive apt-get --quiet --yes --no-install-recommends -o DPkg::Options::=\"--force-confold\""
|
aptget="DEBIAN_FRONTEND=noninteractive apt-get --quiet --yes --no-install-recommends -o DPkg::Options::=\"--force-confold\""
|
||||||
|
|
||||||
[ "$state_is" = "$state_should" ] && exit 0
|
[ "$state_is" = "$state_should" ] && exit 0
|
||||||
|
|
35
cdist/conf/type/__package_emerge/explorer/pkg_version
Normal file
35
cdist/conf/type/__package_emerge/explorer/pkg_version
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# 2013 Thomas Oettli (otho at sfs.biz)
|
||||||
|
#
|
||||||
|
# This file is part of cdist.
|
||||||
|
#
|
||||||
|
# cdist is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# cdist is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# Retrieve the status of a package
|
||||||
|
#
|
||||||
|
|
||||||
|
if [ ! -x /usr/bin/equery ]; then
|
||||||
|
echo "gentoolkit not installed!" 1>&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -f "$__object/parameter/name" ]; then
|
||||||
|
name="$(cat "$__object/parameter/name")"
|
||||||
|
else
|
||||||
|
name="$__object_id"
|
||||||
|
fi
|
||||||
|
|
||||||
|
equery -q l -F '$cp $fullversion' "$name" || true
|
72
cdist/conf/type/__package_emerge/gencode-remote
Normal file
72
cdist/conf/type/__package_emerge/gencode-remote
Normal file
|
@ -0,0 +1,72 @@
|
||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# 2013 Thomas Oettli (otho at sfs.biz)
|
||||||
|
#
|
||||||
|
# This file is part of cdist.
|
||||||
|
#
|
||||||
|
# cdist is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# cdist is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# Manage packages with Portage (mostly gentoo)
|
||||||
|
#
|
||||||
|
|
||||||
|
if [ -f "$__object/parameter/name" ]; then
|
||||||
|
name="$__object/parameter/name"
|
||||||
|
else
|
||||||
|
name="$__object_id"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -f "$__object/parameter/state" ]; then
|
||||||
|
state_should="$(cat "$__object/parameter/state")"
|
||||||
|
else
|
||||||
|
state_should="present"
|
||||||
|
fi
|
||||||
|
|
||||||
|
pkg_version="$(cat "$__object/explorer/pkg_version")"
|
||||||
|
if [ -z "$pkg_version" ]; then
|
||||||
|
state_is="absent"
|
||||||
|
elif [ $(echo "$pkg_version" | wc -l) -gt 1 ]; then
|
||||||
|
echo "Package name is not unique! The following packages are installed:"
|
||||||
|
echo "$pkg_version"
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
state_is="present"
|
||||||
|
installed_version="$(echo "$pkg_version" | cut -d " " -f 2)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -f "$__object/parameter/version" ]; then
|
||||||
|
version="$(cat "$__object/parameter/version")"
|
||||||
|
if [ ! -z "$version" ]; then
|
||||||
|
name="=$name-$version"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
version=""
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Exit if nothing is needed to be done
|
||||||
|
[ "$state_is" = "$state_should" ] && ( [ -z "$version" ] || [ "$installed_version" = "$version" ] ) && exit 0
|
||||||
|
[ "$state_should" = "absent" ] && [ ! -z "$version" ] && [ "$installed_version" != "$version" ] && exit 0
|
||||||
|
|
||||||
|
case "$state_should" in
|
||||||
|
present)
|
||||||
|
echo "emerge \"$name\" &>/dev/null || exit 1"
|
||||||
|
;;
|
||||||
|
absent)
|
||||||
|
echo "emerge -C \"$name\" &>/dev/null || exit 1"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Unknown state: $state_should" >&2
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
60
cdist/conf/type/__package_emerge/man.text
Normal file
60
cdist/conf/type/__package_emerge/man.text
Normal file
|
@ -0,0 +1,60 @@
|
||||||
|
cdist-type__package_emerge(7)
|
||||||
|
=============================
|
||||||
|
Thomas Oettli <otho--@--sfs.biz>
|
||||||
|
|
||||||
|
|
||||||
|
NAME
|
||||||
|
----
|
||||||
|
cdist-type__package_emerge - Manage packages with portage
|
||||||
|
|
||||||
|
|
||||||
|
DESCRIPTION
|
||||||
|
-----------
|
||||||
|
Portage is usually used on the gentoo distribution to manage packages.
|
||||||
|
This type requires app-portage/gentoolkit installed on the target host.
|
||||||
|
cdist-type__package_emerge_dependencies is supposed to install the needed
|
||||||
|
packages on the target host.
|
||||||
|
|
||||||
|
|
||||||
|
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".
|
||||||
|
|
||||||
|
version::
|
||||||
|
If supplied, use to install or uninstall a specific version of the package named.
|
||||||
|
|
||||||
|
EXAMPLES
|
||||||
|
--------
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
# Ensure sys-devel/gcc is installed
|
||||||
|
__package_emerge sys-devel/gcc --state present
|
||||||
|
|
||||||
|
# If you want a specific version of a package
|
||||||
|
__package_emerge app-portage/gentoolkit --state present --version 0.3.0.8-r2
|
||||||
|
|
||||||
|
# Remove package
|
||||||
|
__package_emerge sys-devel/gcc --state absent
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
SEE ALSO
|
||||||
|
--------
|
||||||
|
- cdist-type(7)
|
||||||
|
- cdist-type__package(7)
|
||||||
|
- cdist-type__package_emerge_dependencies(7)
|
||||||
|
|
||||||
|
|
||||||
|
COPYING
|
||||||
|
-------
|
||||||
|
Copyright \(C) 2013 Thomas Oettli. Free use of this software is
|
||||||
|
granted under the terms of the GNU General Public License version 3 (GPLv3).
|
3
cdist/conf/type/__package_emerge/parameter/optional
Normal file
3
cdist/conf/type/__package_emerge/parameter/optional
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
name
|
||||||
|
state
|
||||||
|
version
|
|
@ -0,0 +1,7 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
if [ -x /usr/bin/flaggie ]; then
|
||||||
|
echo "true"
|
||||||
|
else
|
||||||
|
echo "false"
|
||||||
|
fi
|
|
@ -0,0 +1,7 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
if [ -x /usr/bin/q ]; then
|
||||||
|
echo "true"
|
||||||
|
else
|
||||||
|
echo "false"
|
||||||
|
fi
|
15
cdist/conf/type/__package_emerge_dependencies/gencode-remote
Normal file
15
cdist/conf/type/__package_emerge_dependencies/gencode-remote
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
gentoolkit_installed="$(cat "$__object/explorer/gentoolkit_installed")"
|
||||||
|
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"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "${flaggie_installed}" != "true" ]; then
|
||||||
|
# emerge app-portage/flaggie
|
||||||
|
echo "emerge app-portage/flaggie &> /dev/null || exit 1"
|
||||||
|
fi
|
||||||
|
|
48
cdist/conf/type/__package_emerge_dependencies/man.text
Normal file
48
cdist/conf/type/__package_emerge_dependencies/man.text
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
cdist-type__package_emerge_dependencies(7)
|
||||||
|
==========================================
|
||||||
|
Thomas Oettli <otho--@--sfs.biz>
|
||||||
|
|
||||||
|
|
||||||
|
NAME
|
||||||
|
----
|
||||||
|
cdist-type__package_emerge_dependencies - Install dependencies for __package_emerge
|
||||||
|
|
||||||
|
|
||||||
|
DESCRIPTION
|
||||||
|
-----------
|
||||||
|
Portage is usually used on the gentoo distribution to manage packages.
|
||||||
|
This type installs the following tools which are required by __package_emerge to work:
|
||||||
|
app-portage/flaggie
|
||||||
|
app-portage/gentoolkit
|
||||||
|
|
||||||
|
|
||||||
|
REQUIRED PARAMETERS
|
||||||
|
-------------------
|
||||||
|
None
|
||||||
|
|
||||||
|
|
||||||
|
OPTIONAL PARAMETERS
|
||||||
|
-------------------
|
||||||
|
None
|
||||||
|
|
||||||
|
|
||||||
|
EXAMPLES
|
||||||
|
--------
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
# Ensure app-portage/flaggie and app-portage/gentoolkit are installed
|
||||||
|
__package_emerge_dependencies
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
SEE ALSO
|
||||||
|
--------
|
||||||
|
- cdist-type(7)
|
||||||
|
- cdist-type__package(7)
|
||||||
|
- cdist-type__package_emerge(7)
|
||||||
|
|
||||||
|
|
||||||
|
COPYING
|
||||||
|
-------
|
||||||
|
Copyright \(C) 2013 Thomas Oettli. Free use of this software is
|
||||||
|
granted under the terms of the GNU General Public License version 3 (GPLv3).
|
0
cdist/conf/type/__package_emerge_dependencies/singleton
Normal file
0
cdist/conf/type/__package_emerge_dependencies/singleton
Normal file
|
@ -1,6 +1,7 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
#
|
#
|
||||||
# 2011-2012 Nico Schottelius (nico-cdist at schottelius.org)
|
# 2011-2012 Nico Schottelius (nico-cdist at schottelius.org)
|
||||||
|
# 2013 Daniel Heule (hda at sfs.biz)
|
||||||
#
|
#
|
||||||
# This file is part of cdist.
|
# This file is part of cdist.
|
||||||
#
|
#
|
||||||
|
@ -18,7 +19,7 @@
|
||||||
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
|
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
# Retrieve the status of a package
|
# Retrieve the status of a package of different types
|
||||||
#
|
#
|
||||||
|
|
||||||
if [ -f "$__object/parameter/name" ]; then
|
if [ -f "$__object/parameter/name" ]; then
|
||||||
|
@ -27,4 +28,21 @@ else
|
||||||
name="$__object_id"
|
name="$__object_id"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
rpm -q --whatprovides "$name" | grep -v 'no package provides' || true
|
if [ -f "$__object/parameter/ptype" ]; then
|
||||||
|
ptype="$(cat "$__object/parameter/ptype")"
|
||||||
|
else
|
||||||
|
ptype="package"
|
||||||
|
fi
|
||||||
|
|
||||||
|
case "$ptype" in
|
||||||
|
package)
|
||||||
|
zypper search --details --match-exact --installed-only --type "$ptype" "$name" | grep -E '^i' | cut -d " " -f 3,7 || true
|
||||||
|
;;
|
||||||
|
patch|pattern|product|srcpackage)
|
||||||
|
zypper search --match-exact --installed-only --type "$ptype" "$name" | grep -E '^i' | cut -d " " -f 3 || true
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "unknown ptype in __package_zypper explorer" &>2
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
#
|
#
|
||||||
# 2012 Nico Schottelius (nico-cdist at schottelius.org)
|
# 2012 Nico Schottelius (nico-cdist at schottelius.org)
|
||||||
|
# 2013 Daniel Heule (hda at sfs.biz)
|
||||||
#
|
#
|
||||||
# This file is part of cdist.
|
# This file is part of cdist.
|
||||||
#
|
#
|
||||||
|
@ -39,22 +40,45 @@ else
|
||||||
state_should="present"
|
state_should="present"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -f "$__object/parameter/ptype" ]; then
|
||||||
|
ptype="$(cat "$__object/parameter/ptype")"
|
||||||
|
else
|
||||||
|
ptype="package"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -f "$__object/parameter/version" ]; then
|
||||||
|
version_should="$(cat "$__object/parameter/version")"
|
||||||
|
if [ "$ptype" != "package" ]; then
|
||||||
|
echo "version support only for type package implemented" >&2
|
||||||
|
exit 2
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
version_should=""
|
||||||
|
fi
|
||||||
|
|
||||||
pkg_version="$(cat "$__object/explorer/pkg_version")"
|
pkg_version="$(cat "$__object/explorer/pkg_version")"
|
||||||
if [ -z "$pkg_version" ]; then
|
if [ -z "$pkg_version" ]; then
|
||||||
state_is="absent"
|
state_is="absent"
|
||||||
|
version_is=""
|
||||||
else
|
else
|
||||||
state_is="present"
|
state_is="present"
|
||||||
|
version_is=${pkg_version##* }
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Exit if nothing is needed to be done
|
|
||||||
[ "$state_is" = "$state_should" ] && exit 0
|
|
||||||
|
|
||||||
case "$state_should" in
|
case "$state_should" in
|
||||||
present)
|
present)
|
||||||
echo zypper $globalopts install --auto-agree-with-licenses \"$name\" ">/dev/null"
|
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"
|
||||||
|
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"
|
||||||
|
fi
|
||||||
;;
|
;;
|
||||||
absent)
|
absent)
|
||||||
echo zypper $globalopts remove \"$name\" ">/dev/null"
|
[ "$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 "Unknown state: $state_should" >&2
|
echo "Unknown state: $state_should" >&2
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
cdist-type__package_zypper(7)
|
cdist-type__package_zypper(7)
|
||||||
=============================
|
=============================
|
||||||
Nico Schottelius <nico-cdist--@--schottelius.org>
|
Daniel Heule <hda--@--sfs.biz>
|
||||||
|
|
||||||
|
|
||||||
NAME
|
NAME
|
||||||
|
@ -26,19 +26,33 @@ name::
|
||||||
state::
|
state::
|
||||||
Either "present" or "absent", defaults to "present"
|
Either "present" or "absent", defaults to "present"
|
||||||
|
|
||||||
|
version::
|
||||||
|
The version of the package to install. Default is to install the version
|
||||||
|
choosen by the local package manager. For a list of available versions,
|
||||||
|
have a look at the output of "zypper se -s packagename"
|
||||||
|
|
||||||
|
ptype::
|
||||||
|
Either "package", "patch", "pattern", "product" or "srcpackage", defaults to "package". For a description see man zypper.
|
||||||
|
|
||||||
|
|
||||||
EXAMPLES
|
EXAMPLES
|
||||||
--------
|
--------
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
# Ensure zsh in installed
|
# Ensure zsh is installed
|
||||||
__package_zypper zsh --state present
|
__package_zypper zsh --state present
|
||||||
|
|
||||||
# If you don't want to follow pythonX packages, but always use python
|
# If you don't want to follow pythonX packages, but always use python
|
||||||
__package_zypper python --state present --name python2
|
__package_zypper python --state present --name python2
|
||||||
|
|
||||||
|
# Ensure binutils is installed and the version is forced to be 2.23.1-0.19.2
|
||||||
|
__package_zypper binutils --state present --version 2.23.1-0.19.2
|
||||||
|
|
||||||
# Remove package
|
# Remove package
|
||||||
__package_zypper cfengine --state absent
|
__package_zypper cfengine --state absent
|
||||||
|
|
||||||
|
# install all packages which belongs to pattern x11
|
||||||
|
__package_zypper x11 --ptype pattern --state present
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
@ -50,5 +64,6 @@ SEE ALSO
|
||||||
|
|
||||||
COPYING
|
COPYING
|
||||||
-------
|
-------
|
||||||
Copyright \(C) 2012 Nico Schottelius. Free use of this software is
|
Copyright \(C) 2012 Nico Schottelius.
|
||||||
granted under the terms of the GNU General Public License version 3 (GPLv3).
|
Copyright \(C) 2013 Daniel Heule.
|
||||||
|
Free use of this software is granted under the terms of the GNU General Public License version 3 (GPLv3).
|
||||||
|
|
1
cdist/conf/type/__package_zypper/parameter/default/ptype
Normal file
1
cdist/conf/type/__package_zypper/parameter/default/ptype
Normal file
|
@ -0,0 +1 @@
|
||||||
|
package
|
|
@ -1,2 +1,4 @@
|
||||||
name
|
name
|
||||||
state
|
state
|
||||||
|
ptype
|
||||||
|
version
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
os=$(cat "$__global/explorer/os")
|
os=$(cat "$__global/explorer/os")
|
||||||
|
|
||||||
case "$os" in
|
case "$os" in
|
||||||
ubuntu|debian|archlinux)
|
ubuntu|debian|archlinux|suse)
|
||||||
__package postfix --state present
|
__package postfix --state present
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
#
|
#
|
||||||
# 2012 Steven Armstrong (steven-cdist at armstrong.cc)
|
# 2012 - 2013 Steven Armstrong (steven-cdist at armstrong.cc)
|
||||||
#
|
#
|
||||||
# This file is part of cdist.
|
# This file is part of cdist.
|
||||||
#
|
#
|
||||||
|
@ -32,6 +32,7 @@ case "$os" in
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
__postfix
|
||||||
|
|
||||||
# Default to object_id
|
# Default to object_id
|
||||||
service="$(cat "$__object/parameter/service" 2>/dev/null || echo "$__object_id")"
|
service="$(cat "$__object/parameter/service" 2>/dev/null || echo "$__object_id")"
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
os=$("$__explorer/os")
|
os=$("$__explorer/os")
|
||||||
|
|
||||||
case "$os" in
|
case "$os" in
|
||||||
ubuntu|debian|archlinux)
|
ubuntu|debian|archlinux|suse)
|
||||||
:
|
:
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
|
|
|
@ -21,7 +21,7 @@
|
||||||
os=$(cat "$__global/explorer/os")
|
os=$(cat "$__global/explorer/os")
|
||||||
|
|
||||||
case "$os" in
|
case "$os" in
|
||||||
ubuntu|debian|archlinux)
|
ubuntu|debian|archlinux|suse)
|
||||||
:
|
:
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
|
|
21
cdist/conf/type/__postfix_postconf/manifest
Executable file
21
cdist/conf/type/__postfix_postconf/manifest
Executable file
|
@ -0,0 +1,21 @@
|
||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# 2012 - 2013 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 <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
|
||||||
|
__postfix
|
21
cdist/conf/type/__postfix_postmap/manifest
Executable file
21
cdist/conf/type/__postfix_postmap/manifest
Executable file
|
@ -0,0 +1,21 @@
|
||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# 2012 - 2013 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 <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
|
||||||
|
__postfix
|
21
cdist/conf/type/__postfix_reload/manifest
Executable file
21
cdist/conf/type/__postfix_reload/manifest
Executable file
|
@ -0,0 +1,21 @@
|
||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# 2012 - 2013 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 <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
|
||||||
|
__postfix
|
|
@ -1,6 +1,7 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
#
|
#
|
||||||
# 2012-2013 Nico Schottelius (nico-cdist at schottelius.org)
|
# 2012-2013 Nico Schottelius (nico-cdist at schottelius.org)
|
||||||
|
# 2013 Daniel Heule (hda at sfs.biz)
|
||||||
#
|
#
|
||||||
# This file is part of cdist.
|
# This file is part of cdist.
|
||||||
#
|
#
|
||||||
|
@ -23,9 +24,9 @@
|
||||||
|
|
||||||
os=$("$__explorer/os")
|
os=$("$__explorer/os")
|
||||||
runlevel=$("$__explorer/runlevel")
|
runlevel=$("$__explorer/runlevel")
|
||||||
|
target_runlevel="$(cat "$__object/parameter/target_runlevel")"
|
||||||
name="$__object_id"
|
name="$__object_id"
|
||||||
|
|
||||||
|
|
||||||
case "$os" in
|
case "$os" in
|
||||||
archlinux)
|
archlinux)
|
||||||
state=$(systemctl is-enabled "$name" >/dev/null 2>&1 \
|
state=$(systemctl is-enabled "$name" >/dev/null 2>&1 \
|
||||||
|
@ -38,11 +39,23 @@ case "$os" in
|
||||||
[ -f "/etc/rc$runlevel.d/S"??"$name" ] || state="absent"
|
[ -f "/etc/rc$runlevel.d/S"??"$name" ] || state="absent"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
amazon|centos|fedora|owl|redhat|suse)
|
amazon|centos|fedora|owl|redhat)
|
||||||
state=$(chkconfig --level "$runlevel" "$name" || echo absent)
|
state=$(chkconfig --level "$runlevel" "$name" || echo absent)
|
||||||
[ "$state" ] || state="present"
|
[ "$state" ] || state="present"
|
||||||
;;
|
;;
|
||||||
|
suse)
|
||||||
|
# check for target if set, usable for boot. services in runlevel B
|
||||||
|
if [ "$target_runlevel" != 'default' ]; then
|
||||||
|
runlevel="$target_runlevel"
|
||||||
|
fi
|
||||||
|
# suses chkconfig has the same name, but works different ...
|
||||||
|
state=$(chkconfig --check "$name" "$runlevel" || echo absent)
|
||||||
|
[ "$state" ] || state="present"
|
||||||
|
;;
|
||||||
|
gentoo)
|
||||||
|
state="present"
|
||||||
|
[ -f "/etc/runlevels/${target_runlevel}/${name}" ] || state="absent"
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Unsupported os: $os" >&2
|
echo "Unsupported os: $os" >&2
|
||||||
exit 1
|
exit 1
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
#
|
#
|
||||||
# 2012-2013 Nico Schottelius (nico-cdist at schottelius.org)
|
# 2012-2013 Nico Schottelius (nico-cdist at schottelius.org)
|
||||||
|
# 2013 Daniel Heule (hda at sfs.biz)
|
||||||
#
|
#
|
||||||
# This file is part of cdist.
|
# This file is part of cdist.
|
||||||
#
|
#
|
||||||
|
@ -19,8 +20,9 @@
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
|
|
||||||
state_should="$(cat "$__object/parameter/state" 2>/dev/null || echo present)"
|
state_should="$(cat "$__object/parameter/state")"
|
||||||
state_is=$(cat "$__object/explorer/state")
|
state_is=$(cat "$__object/explorer/state")
|
||||||
|
target_runlevel="$(cat "$__object/parameter/target_runlevel")"
|
||||||
|
|
||||||
# Short circuit if nothing is to be done
|
# Short circuit if nothing is to be done
|
||||||
[ "$state_should" = "$state_is" ] && exit 0
|
[ "$state_should" = "$state_is" ] && exit 0
|
||||||
|
@ -38,10 +40,9 @@ case "$state_should" in
|
||||||
echo "update-rc.d \"$name\" defaults >/dev/null"
|
echo "update-rc.d \"$name\" defaults >/dev/null"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
# FIXME: Disabled until the explorer is checked
|
gentoo)
|
||||||
# gentoo)
|
echo rc-update add \"$name\" \"$target_runlevel\"
|
||||||
# echo rc-update add \"$name\" default
|
;;
|
||||||
# ;;
|
|
||||||
|
|
||||||
amazon|centos|fedora|owl|redhat|suse)
|
amazon|centos|fedora|owl|redhat|suse)
|
||||||
echo chkconfig \"$name\" on
|
echo chkconfig \"$name\" on
|
||||||
|
@ -70,10 +71,9 @@ case "$state_should" in
|
||||||
echo update-rc.d -f \"$name\" remove
|
echo update-rc.d -f \"$name\" remove
|
||||||
;;
|
;;
|
||||||
|
|
||||||
# FIXME: Disabled until the explorer is checked
|
gentoo)
|
||||||
# gentoo)
|
echo rc-update del \"$name\" \"$target_runlevel\"
|
||||||
# echo rc-update del \"$name\"
|
;;
|
||||||
# ;;
|
|
||||||
|
|
||||||
centos|fedora|owl|redhat|suse)
|
centos|fedora|owl|redhat|suse)
|
||||||
echo chkconfig \"$name\" off
|
echo chkconfig \"$name\" off
|
||||||
|
|
|
@ -14,7 +14,7 @@ This cdist type allows you to enable or disable stuff to be started
|
||||||
at boot of your operating system.
|
at boot of your operating system.
|
||||||
|
|
||||||
Warning: This type has not been tested intensively and is not fully
|
Warning: This type has not been tested intensively and is not fully
|
||||||
supported (i.e. gentoo and *bsd are not implemented).
|
supported (i.e. *bsd are not implemented).
|
||||||
|
|
||||||
|
|
||||||
REQUIRED PARAMETERS
|
REQUIRED PARAMETERS
|
||||||
|
@ -25,6 +25,8 @@ OPTIONAL PARAMETERS
|
||||||
-------------------
|
-------------------
|
||||||
state::
|
state::
|
||||||
Either "present" or "absent", defaults to "present"
|
Either "present" or "absent", defaults to "present"
|
||||||
|
target_runlevel::
|
||||||
|
Runlevel which should be modified, defaults to "default" (only used on gentoo systems).
|
||||||
|
|
||||||
|
|
||||||
EXAMPLES
|
EXAMPLES
|
||||||
|
|
1
cdist/conf/type/__start_on_boot/parameter/default/state
Normal file
1
cdist/conf/type/__start_on_boot/parameter/default/state
Normal file
|
@ -0,0 +1 @@
|
||||||
|
present
|
|
@ -0,0 +1 @@
|
||||||
|
default
|
|
@ -1 +1,2 @@
|
||||||
state
|
state
|
||||||
|
target_runlevel
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
- delete users
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#
|
#
|
||||||
# 2011 Steven Armstrong (steven-cdist at armstrong.cc)
|
# 2011 Steven Armstrong (steven-cdist at armstrong.cc)
|
||||||
# 2011 Nico Schottelius (nico-cdist at schottelius.org)
|
# 2011 Nico Schottelius (nico-cdist at schottelius.org)
|
||||||
|
# 2013 Daniel Heule (hda at sfs.biz)
|
||||||
#
|
#
|
||||||
# This file is part of cdist.
|
# This file is part of cdist.
|
||||||
#
|
#
|
||||||
|
@ -21,11 +22,14 @@
|
||||||
#
|
#
|
||||||
# Manage users.
|
# Manage users.
|
||||||
#
|
#
|
||||||
|
#set -x
|
||||||
|
|
||||||
name="$__object_id"
|
name="$__object_id"
|
||||||
|
|
||||||
os="$(cat "$__global/explorer/os")"
|
os="$(cat "$__global/explorer/os")"
|
||||||
|
|
||||||
|
state=$(cat "$__object/parameter/state")
|
||||||
|
|
||||||
# We need to shorten options for both usermod and useradd since on some
|
# We need to shorten options for both usermod and useradd since on some
|
||||||
# systems (such as *BSD, Darwin) those commands do not handle GNU style long
|
# systems (such as *BSD, Darwin) those commands do not handle GNU style long
|
||||||
# options.
|
# options.
|
||||||
|
@ -40,10 +44,12 @@ shorten_property() {
|
||||||
shell) ret="-s";;
|
shell) ret="-s";;
|
||||||
uid) ret="-u";;
|
uid) ret="-u";;
|
||||||
create-home) ret="-m";;
|
create-home) ret="-m";;
|
||||||
|
system) ret="-r";;
|
||||||
esac
|
esac
|
||||||
echo "$ret"
|
echo "$ret"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if [ "$state" = "present" ]; then
|
||||||
cd "$__object/parameter"
|
cd "$__object/parameter"
|
||||||
if grep -q "^${name}:" "$__object/explorer/passwd"; then
|
if grep -q "^${name}:" "$__object/explorer/passwd"; then
|
||||||
for property in $(ls .); do
|
for property in $(ls .); do
|
||||||
|
@ -78,6 +84,9 @@ if grep -q "^${name}:" "$__object/explorer/passwd"; then
|
||||||
shell) field=7 ;;
|
shell) field=7 ;;
|
||||||
uid) field=3 ;;
|
uid) field=3 ;;
|
||||||
create-home) continue;; # Does not apply to user modification
|
create-home) continue;; # Does not apply to user modification
|
||||||
|
system) continue;; # Does not apply to user modification
|
||||||
|
state) continue;; # Does not apply to user modification
|
||||||
|
remove-home) continue;; # Does not apply to user modification
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# If we haven't already set $current_value above, pull it from the
|
# If we haven't already set $current_value above, pull it from the
|
||||||
|
@ -93,6 +102,7 @@ if grep -q "^${name}:" "$__object/explorer/passwd"; then
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ $# -gt 0 ]; then
|
if [ $# -gt 0 ]; then
|
||||||
|
echo mod >> "$__messages_out"
|
||||||
if [ "$os" = "freebsd" ]; then
|
if [ "$os" = "freebsd" ]; then
|
||||||
echo pw usermod "$@" "$name"
|
echo pw usermod "$@" "$name"
|
||||||
else
|
else
|
||||||
|
@ -102,7 +112,10 @@ if grep -q "^${name}:" "$__object/explorer/passwd"; then
|
||||||
true
|
true
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
|
echo add >> "$__messages_out"
|
||||||
for property in $(ls .); do
|
for property in $(ls .); do
|
||||||
|
[ "$property" = "state" ] && continue
|
||||||
|
[ "$property" = "remove-home" ] && continue
|
||||||
new_value="$(cat "$property")"
|
new_value="$(cat "$property")"
|
||||||
if [ -z "$new_value" ];then # Boolean values have no value
|
if [ -z "$new_value" ];then # Boolean values have no value
|
||||||
set -- "$@" "$(shorten_property $property)"
|
set -- "$@" "$(shorten_property $property)"
|
||||||
|
@ -117,3 +130,13 @@ else
|
||||||
echo useradd "$@" "$name"
|
echo useradd "$@" "$name"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
else
|
||||||
|
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}"
|
||||||
|
else
|
||||||
|
echo userdel "${name}"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
|
@ -20,6 +20,8 @@ None.
|
||||||
|
|
||||||
OPTIONAL PARAMETERS
|
OPTIONAL PARAMETERS
|
||||||
-------------------
|
-------------------
|
||||||
|
state::
|
||||||
|
absent or present, defaults to present
|
||||||
comment::
|
comment::
|
||||||
see usermod(8)
|
see usermod(8)
|
||||||
home::
|
home::
|
||||||
|
@ -33,6 +35,14 @@ shell::
|
||||||
uid::
|
uid::
|
||||||
see above
|
see above
|
||||||
|
|
||||||
|
BOOLEAN PARAMETERS
|
||||||
|
------------------
|
||||||
|
system::
|
||||||
|
see useradd(8), apply only on user create
|
||||||
|
create-home::
|
||||||
|
see useradd(8), apply only on user create
|
||||||
|
remove-home::
|
||||||
|
see userdel(8), apply only on user delete
|
||||||
|
|
||||||
EXAMPLES
|
EXAMPLES
|
||||||
--------
|
--------
|
||||||
|
@ -44,8 +54,14 @@ __user foobar
|
||||||
# Same but with a different shell
|
# Same but with a different shell
|
||||||
__user foobar --shell /bin/zsh
|
__user foobar --shell /bin/zsh
|
||||||
|
|
||||||
|
# Same but for a system account
|
||||||
|
__user foobar --system
|
||||||
|
|
||||||
# Set explicit uid and home
|
# Set explicit uid and home
|
||||||
__user foobar --uid 1001 --shell /bin/zsh --home /home/foobar
|
__user foobar --uid 1001 --shell /bin/zsh --home /home/foobar
|
||||||
|
|
||||||
|
# Drop user if exists
|
||||||
|
__user foobar --state absent
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1 +1,3 @@
|
||||||
create-home
|
create-home
|
||||||
|
remove-home
|
||||||
|
system
|
||||||
|
|
1
cdist/conf/type/__user/parameter/default/state
Normal file
1
cdist/conf/type/__user/parameter/default/state
Normal file
|
@ -0,0 +1 @@
|
||||||
|
present
|
|
@ -1,3 +1,4 @@
|
||||||
|
state
|
||||||
comment
|
comment
|
||||||
home
|
home
|
||||||
gid
|
gid
|
||||||
|
|
24
cdist/conf/type/__zypper_repo/explorer/all_repo_ids
Normal file
24
cdist/conf/type/__zypper_repo/explorer/all_repo_ids
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# 2013 Daniel Heule (hda at sfs.biz)
|
||||||
|
#
|
||||||
|
# This file is part of cdist.
|
||||||
|
#
|
||||||
|
# cdist is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# cdist is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# Retrieve all repo id nummbers - parsed zypper output
|
||||||
|
#
|
||||||
|
#
|
||||||
|
echo $(zypper lr | cut -d'|' -f 1 | grep -E '^[0-9]')
|
26
cdist/conf/type/__zypper_repo/explorer/enabled_repo_ids
Normal file
26
cdist/conf/type/__zypper_repo/explorer/enabled_repo_ids
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# 2013 Daniel Heule (hda at sfs.biz)
|
||||||
|
#
|
||||||
|
# This file is part of cdist.
|
||||||
|
#
|
||||||
|
# cdist is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# cdist is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# Retrieve all repo id nummbers from enabled repos - parsed zypper output
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# 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)
|
29
cdist/conf/type/__zypper_repo/explorer/repo_id
Normal file
29
cdist/conf/type/__zypper_repo/explorer/repo_id
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# 2013 Daniel Heule (hda at sfs.biz)
|
||||||
|
#
|
||||||
|
# This file is part of cdist.
|
||||||
|
#
|
||||||
|
# cdist is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# cdist is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# Retrieve the id from the repo with the uri from parameter repo_uri - parsed zypper output
|
||||||
|
#
|
||||||
|
#
|
||||||
|
if [ -f "$__object/parameter/repo_uri" ]; then
|
||||||
|
uri="$(cat "$__object/parameter/repo_uri")"
|
||||||
|
else
|
||||||
|
uri="$__object_id"
|
||||||
|
fi
|
||||||
|
echo $(zypper lr -u | grep -E "\<$uri\>" | cut -d'|' -f 1 | grep -E '^[0-9]' )
|
102
cdist/conf/type/__zypper_repo/gencode-remote
Normal file
102
cdist/conf/type/__zypper_repo/gencode-remote
Normal file
|
@ -0,0 +1,102 @@
|
||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# 2013 Daniel Heule (hda at sfs.biz)
|
||||||
|
#
|
||||||
|
# This file is part of cdist.
|
||||||
|
#
|
||||||
|
# cdist is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# cdist is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# Manage repo services with Zypper (mostly suse)
|
||||||
|
#
|
||||||
|
|
||||||
|
# Debug
|
||||||
|
#exec >&2
|
||||||
|
#set -x
|
||||||
|
|
||||||
|
zypper_def_opts=" -q "
|
||||||
|
|
||||||
|
if [ -f "$__object/parameter/repo_desc" ]; then
|
||||||
|
desc="$(cat "$__object/parameter/repo_desc")"
|
||||||
|
else
|
||||||
|
desc="$__object_id"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -f "$__object/parameter/repo_uri" ]; then
|
||||||
|
uri="$(cat "$__object/parameter/repo_uri")"
|
||||||
|
else
|
||||||
|
uri="$__object_id"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -f "$__object/parameter/repo_id" ]; then
|
||||||
|
id="$(cat "$__object/parameter/repo_id")"
|
||||||
|
else
|
||||||
|
id="$__object_id"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -f "$__object/parameter/state" ]; then
|
||||||
|
state="$(cat "$__object/parameter/state")"
|
||||||
|
else
|
||||||
|
state="present"
|
||||||
|
fi
|
||||||
|
|
||||||
|
repo_id="$(cat "$__object/explorer/repo_id")"
|
||||||
|
|
||||||
|
act_id=""
|
||||||
|
if grep -q "$id" "$__object/explorer/all_repo_ids"; then
|
||||||
|
act_id="$id"
|
||||||
|
elif grep -q "$repo_id" "$__object/explorer/all_repo_ids"; then
|
||||||
|
act_id="$repo_id"
|
||||||
|
fi
|
||||||
|
|
||||||
|
repostate="disabled"
|
||||||
|
if grep -q "$act_id" "$__object/explorer/enabled_repo_ids"; then
|
||||||
|
repostate="enabled"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
case "$state" in
|
||||||
|
present)
|
||||||
|
if [ -z "$desc" ] || [ -z "$uri" ]; then
|
||||||
|
echo "parameter repo_desc and repo_uri for $state needed" >&2
|
||||||
|
exit 4
|
||||||
|
fi
|
||||||
|
if [ -z "$repo_id" ]; then
|
||||||
|
# Repo not present, so we need to create it
|
||||||
|
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"
|
||||||
|
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"
|
||||||
|
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"
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Unknown state: $state" >&2
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
73
cdist/conf/type/__zypper_repo/man.text
Normal file
73
cdist/conf/type/__zypper_repo/man.text
Normal file
|
@ -0,0 +1,73 @@
|
||||||
|
cdist-type__zypper_repo(7)
|
||||||
|
==========================
|
||||||
|
Daniel Heule <hda--@--sfs.biz>
|
||||||
|
|
||||||
|
|
||||||
|
NAME
|
||||||
|
----
|
||||||
|
cdist-type__zypper_repo - repository management with zypper
|
||||||
|
|
||||||
|
|
||||||
|
DESCRIPTION
|
||||||
|
-----------
|
||||||
|
zypper is usually used on the SuSE distribution to manage repositories.
|
||||||
|
|
||||||
|
|
||||||
|
REQUIRED PARAMETERS
|
||||||
|
-------------------
|
||||||
|
None
|
||||||
|
|
||||||
|
|
||||||
|
OPTIONAL PARAMETERS
|
||||||
|
-------------------
|
||||||
|
state::
|
||||||
|
Either "present" or "absent" or "enabled" or "disabled", defaults to "present" +
|
||||||
|
#present# - make sure that the repo is aviable, needs repo_uri and repo_desc +
|
||||||
|
for all following states, the repo can be searched via repo_id or repo_uri +
|
||||||
|
#absent# - drop the repo if found +
|
||||||
|
#enabled# - a repo can have state disabled if installed via zypper service (ris), in this case, you can enable the repo +
|
||||||
|
#disabled# - instead of absent (drop), a repo can also set to disabled, wich makes it inaccessible +
|
||||||
|
|
||||||
|
repo_uri::
|
||||||
|
If supplied, use the uri and not the object id as repo uri.
|
||||||
|
|
||||||
|
repo_desc::
|
||||||
|
If supplied, use the description and not the object id as repo description, only used if the state is present and the repo has to be created
|
||||||
|
|
||||||
|
repo_id::
|
||||||
|
If supplied, use the id and not the object id as repo id, can be used with state absent, enabled and disabled
|
||||||
|
|
||||||
|
|
||||||
|
EXAMPLES
|
||||||
|
--------
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
# Ensure testrepo in installed
|
||||||
|
__zypper_repo testrepo --state present --repo_uri http://url.to.your.repo/with/path
|
||||||
|
|
||||||
|
# Drop repo by repo uri
|
||||||
|
__zypper_repo testrepo --state absent --repo_uri http://url.to.your.repo/with/path
|
||||||
|
|
||||||
|
# Drop repo by id number (attention: repos are always numbered from 1 to max)
|
||||||
|
__zypper_repo testrepo --state absent --repo_id 1
|
||||||
|
|
||||||
|
# enable repo by id
|
||||||
|
__zypper_repo testrepo2 --state enabled --repo_id 2
|
||||||
|
|
||||||
|
# enable repo by uri
|
||||||
|
__zypper_repo testrepo3 --state enabled --repo_uri http://url.to.your.repo/with/path
|
||||||
|
|
||||||
|
# disable a repo works like enabling it
|
||||||
|
__zypper_repo testrepo4 --state disabled --repo_id 4
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
SEE ALSO
|
||||||
|
--------
|
||||||
|
- cdist-type(7)
|
||||||
|
|
||||||
|
|
||||||
|
COPYING
|
||||||
|
-------
|
||||||
|
Copyright \(C) 2013 Daniel Heule. Free use of this software is
|
||||||
|
granted under the terms of the GNU General Public License version 3 (GPLv3).
|
1
cdist/conf/type/__zypper_repo/parameter/default/state
Normal file
1
cdist/conf/type/__zypper_repo/parameter/default/state
Normal file
|
@ -0,0 +1 @@
|
||||||
|
present
|
4
cdist/conf/type/__zypper_repo/parameter/optional
Normal file
4
cdist/conf/type/__zypper_repo/parameter/optional
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
state
|
||||||
|
repo_uri
|
||||||
|
repo_desc
|
||||||
|
repo_id
|
27
cdist/conf/type/__zypper_service/explorer/repo_ids
Normal file
27
cdist/conf/type/__zypper_service/explorer/repo_ids
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# 2013 Daniel Heule (hda at sfs.biz)
|
||||||
|
#
|
||||||
|
# This file is part of cdist.
|
||||||
|
#
|
||||||
|
# cdist is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# cdist is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# Manage services with Zypper (mostly suse)
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# 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]')
|
30
cdist/conf/type/__zypper_service/explorer/service_id
Normal file
30
cdist/conf/type/__zypper_service/explorer/service_id
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# 2013 Daniel Heule (hda at sfs.biz)
|
||||||
|
#
|
||||||
|
# This file is part of cdist.
|
||||||
|
#
|
||||||
|
# cdist is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# cdist is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# Manage services with Zypper (mostly suse)
|
||||||
|
#
|
||||||
|
if [ -f "$__object/parameter/service_uri" ]; then
|
||||||
|
uri="$(cat "$__object/parameter/service_uri")"
|
||||||
|
else
|
||||||
|
uri="/$__object_id"
|
||||||
|
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 )
|
25
cdist/conf/type/__zypper_service/explorer/service_ids
Normal file
25
cdist/conf/type/__zypper_service/explorer/service_ids
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# 2013 Daniel Heule (hda at sfs.biz)
|
||||||
|
#
|
||||||
|
# This file is part of cdist.
|
||||||
|
#
|
||||||
|
# cdist is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# cdist is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# Manage services with Zypper (mostly suse)
|
||||||
|
#
|
||||||
|
# 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]')
|
30
cdist/conf/type/__zypper_service/explorer/service_uri
Normal file
30
cdist/conf/type/__zypper_service/explorer/service_uri
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# 2013 Daniel Heule (hda at sfs.biz)
|
||||||
|
#
|
||||||
|
# This file is part of cdist.
|
||||||
|
#
|
||||||
|
# cdist is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# cdist is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# Manage services with Zypper (mostly suse)
|
||||||
|
#
|
||||||
|
if [ -f "$__object/parameter/service_uri" ]; then
|
||||||
|
uri="$(cat "$__object/parameter/service_uri")"
|
||||||
|
else
|
||||||
|
uri="/$__object_id"
|
||||||
|
fi
|
||||||
|
# simpler command which works only on SLES11 SP3 or newer:
|
||||||
|
# echo $(zypper ls -u -E | grep -E "\<$uri\>" | cut -d'|' -f 7)
|
||||||
|
echo $(zypper ls -u | grep -E '^([^|]+\|){3,3} Yes' | grep -E "\<$uri\>" | cut -d'|' -f 7 )
|
94
cdist/conf/type/__zypper_service/gencode-remote
Normal file
94
cdist/conf/type/__zypper_service/gencode-remote
Normal file
|
@ -0,0 +1,94 @@
|
||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# 2013 Daniel Heule (hda at sfs.biz)
|
||||||
|
#
|
||||||
|
# This file is part of cdist.
|
||||||
|
#
|
||||||
|
# cdist is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# cdist is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# Manage services with Zypper (mostly suse)
|
||||||
|
#
|
||||||
|
|
||||||
|
# Debug
|
||||||
|
#exec >&2
|
||||||
|
#set -x
|
||||||
|
|
||||||
|
zypper_def_opts=" -q "
|
||||||
|
|
||||||
|
if [ -f "$__object/parameter/service_desc" ]; then
|
||||||
|
desc="$(cat "$__object/parameter/service_desc")"
|
||||||
|
else
|
||||||
|
desc="$__object_id"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -f "$__object/parameter/service_uri" ]; then
|
||||||
|
uri="$(cat "$__object/parameter/service_uri")"
|
||||||
|
else
|
||||||
|
uri="$__object_id"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -f "$__object/parameter/state" ]; then
|
||||||
|
state_should="$(cat "$__object/parameter/state")"
|
||||||
|
else
|
||||||
|
state_should="present"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -f "$__object/parameter/type" ]; then
|
||||||
|
stype="$(cat "$__object/parameter/type")"
|
||||||
|
else
|
||||||
|
stype="ris"
|
||||||
|
fi
|
||||||
|
|
||||||
|
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)"
|
||||||
|
|
||||||
|
if [ "$uri" = "$exp_uri" ] ; then
|
||||||
|
state_is="present"
|
||||||
|
else
|
||||||
|
state_is="absent"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# remove all other services if needed ...
|
||||||
|
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"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
echo zypper $zypper_def_opts refs "&>/dev/null"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# Exit if nothing is needed to be done
|
||||||
|
[ "$state_is" = "$state_should" ] && exit 0
|
||||||
|
|
||||||
|
case "$state_should" in
|
||||||
|
present)
|
||||||
|
echo zypper $zypper_def_opts addservice -t "$stype" "$uri" \"$desc\"
|
||||||
|
echo zypper $zypper_def_opts refs
|
||||||
|
;;
|
||||||
|
absent)
|
||||||
|
echo zypper $zypper_def_opts removeservice "$service_id"
|
||||||
|
echo zypper $zypper_def_opts refs
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Unknown state: $state_should" >&2
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
67
cdist/conf/type/__zypper_service/man.text
Normal file
67
cdist/conf/type/__zypper_service/man.text
Normal file
|
@ -0,0 +1,67 @@
|
||||||
|
cdist-type__zypper_service(7)
|
||||||
|
=============================
|
||||||
|
Daniel Heule <hda--@--sfs.biz>
|
||||||
|
|
||||||
|
|
||||||
|
NAME
|
||||||
|
----
|
||||||
|
cdist-type__zypper_service - service management with zypper
|
||||||
|
|
||||||
|
|
||||||
|
DESCRIPTION
|
||||||
|
-----------
|
||||||
|
zypper is usually used on SuSE systems to manage services.
|
||||||
|
|
||||||
|
|
||||||
|
REQUIRED PARAMETERS
|
||||||
|
-------------------
|
||||||
|
service_uri::
|
||||||
|
Uri of the service
|
||||||
|
|
||||||
|
|
||||||
|
OPTIONAL PARAMETERS
|
||||||
|
-------------------
|
||||||
|
service_desc::
|
||||||
|
If supplied, use the service_desc and not the object id as descritpion for the service.
|
||||||
|
|
||||||
|
state::
|
||||||
|
Either "present" or "absent", defaults to "present"
|
||||||
|
|
||||||
|
type::
|
||||||
|
Defaults to "ris", the standard type of services at SLES11. For other values, see manpage of zypper.
|
||||||
|
|
||||||
|
|
||||||
|
BOOLEAN PARAMETERS
|
||||||
|
------------------
|
||||||
|
remove-all-other-services::
|
||||||
|
Drop all other services found on the target host before adding the new one.
|
||||||
|
|
||||||
|
remove-all-repos::
|
||||||
|
If supplied, remove all existing repos prior to setup the new service.
|
||||||
|
|
||||||
|
|
||||||
|
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" --service_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
|
||||||
|
__zypper_service INTERNAL_SLES11_SP3 --service_desc "Internal SLES11 SP3 RIS" --service_uri "http://path/to/your/ris/dir"
|
||||||
|
|
||||||
|
# Drop service by uri, no changes to ohter services or repos
|
||||||
|
__zypper_service INTERNAL_SLES11_SP3 --state absent --service_uri "http://path/to/your/ris/dir"
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
SEE ALSO
|
||||||
|
--------
|
||||||
|
- cdist-type(7)
|
||||||
|
|
||||||
|
|
||||||
|
COPYING
|
||||||
|
-------
|
||||||
|
Copyright \(C) 2013 Daniel Heule. Free use of this software is
|
||||||
|
granted under the terms of the GNU General Public License version 3 (GPLv3).
|
63
cdist/conf/type/__zypper_service/manifest
Normal file
63
cdist/conf/type/__zypper_service/manifest
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# 2013 Daniel Heule (hda at sfs.biz)
|
||||||
|
#
|
||||||
|
# This file is part of cdist.
|
||||||
|
#
|
||||||
|
# cdist is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# cdist is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# Manage services with Zypper (mostly suse)
|
||||||
|
#
|
||||||
|
|
||||||
|
# Debug
|
||||||
|
#exec >&2
|
||||||
|
#set -x
|
||||||
|
|
||||||
|
zypper_def_opts=" -q "
|
||||||
|
|
||||||
|
if [ -f "$__object/parameter/service_uri" ]; then
|
||||||
|
uri="$(cat "$__object/parameter/service_uri")"
|
||||||
|
else
|
||||||
|
uri="$__object_id"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -f "$__object/parameter/state" ]; then
|
||||||
|
state_should="$(cat "$__object/parameter/state")"
|
||||||
|
else
|
||||||
|
state_should="present"
|
||||||
|
fi
|
||||||
|
|
||||||
|
exp_uri="$(cat "$__object/explorer/service_uri")"
|
||||||
|
|
||||||
|
if [ "$uri" = "$exp_uri" ] ; then
|
||||||
|
state_is="present"
|
||||||
|
else
|
||||||
|
state_is="absent"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# Exit if nothing is needed to be done
|
||||||
|
[ "$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)"
|
||||||
|
|
||||||
|
# boolean parameter
|
||||||
|
if [ -f "$__object/parameter/remove-all-repos" ]; then
|
||||||
|
# file exists -> True
|
||||||
|
for i in $exp_repos; do
|
||||||
|
__zypper_repo "droprepo${i}" --state absent --repo_id "${i}"
|
||||||
|
done
|
||||||
|
fi
|
2
cdist/conf/type/__zypper_service/parameter/boolean
Normal file
2
cdist/conf/type/__zypper_service/parameter/boolean
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
remove-all-other-services
|
||||||
|
remove-all-repos
|
1
cdist/conf/type/__zypper_service/parameter/default/state
Normal file
1
cdist/conf/type/__zypper_service/parameter/default/state
Normal file
|
@ -0,0 +1 @@
|
||||||
|
present
|
1
cdist/conf/type/__zypper_service/parameter/default/type
Normal file
1
cdist/conf/type/__zypper_service/parameter/default/type
Normal file
|
@ -0,0 +1 @@
|
||||||
|
ris
|
3
cdist/conf/type/__zypper_service/parameter/optional
Normal file
3
cdist/conf/type/__zypper_service/parameter/optional
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
service_desc
|
||||||
|
state
|
||||||
|
type
|
1
cdist/conf/type/__zypper_service/parameter/required
Normal file
1
cdist/conf/type/__zypper_service/parameter/required
Normal file
|
@ -0,0 +1 @@
|
||||||
|
service_uri
|
|
@ -201,7 +201,6 @@ class CdistObject(object):
|
||||||
autorequire = fsproperty.FileListProperty(lambda obj: os.path.join(obj.absolute_path, 'autorequire'))
|
autorequire = fsproperty.FileListProperty(lambda obj: os.path.join(obj.absolute_path, 'autorequire'))
|
||||||
parameters = fsproperty.DirectoryDictProperty(lambda obj: os.path.join(obj.base_path, obj.parameter_path))
|
parameters = fsproperty.DirectoryDictProperty(lambda obj: os.path.join(obj.base_path, obj.parameter_path))
|
||||||
explorers = fsproperty.DirectoryDictProperty(lambda obj: os.path.join(obj.base_path, obj.explorer_path))
|
explorers = fsproperty.DirectoryDictProperty(lambda obj: os.path.join(obj.base_path, obj.explorer_path))
|
||||||
changed = fsproperty.FileBooleanProperty(lambda obj: os.path.join(obj.absolute_path, "changed"))
|
|
||||||
state = fsproperty.FileStringProperty(lambda obj: os.path.join(obj.absolute_path, "state"))
|
state = fsproperty.FileStringProperty(lambda obj: os.path.join(obj.absolute_path, "state"))
|
||||||
source = fsproperty.FileListProperty(lambda obj: os.path.join(obj.absolute_path, "source"))
|
source = fsproperty.FileListProperty(lambda obj: os.path.join(obj.absolute_path, "source"))
|
||||||
code_local = fsproperty.FileStringProperty(lambda obj: os.path.join(obj.base_path, obj.code_local_path))
|
code_local = fsproperty.FileStringProperty(lambda obj: os.path.join(obj.base_path, obj.code_local_path))
|
||||||
|
|
|
@ -37,6 +37,20 @@ class MissingRequiredEnvironmentVariableError(cdist.Error):
|
||||||
return self.message
|
return self.message
|
||||||
|
|
||||||
|
|
||||||
|
class DefaultList(list):
|
||||||
|
"""Helper class to allow default values for optional_multiple parameters.
|
||||||
|
|
||||||
|
@see https://groups.google.com/forum/#!msg/comp.lang.python/sAUvkJEDpRc/RnRymrzJVDYJ
|
||||||
|
"""
|
||||||
|
def __copy__(self):
|
||||||
|
return []
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def create(cls, initial=None):
|
||||||
|
if initial:
|
||||||
|
return cls(initial.split('\n'))
|
||||||
|
|
||||||
|
|
||||||
class Emulator(object):
|
class Emulator(object):
|
||||||
def __init__(self, argv, stdin=sys.stdin.buffer, env=os.environ):
|
def __init__(self, argv, stdin=sys.stdin.buffer, env=os.environ):
|
||||||
self.argv = argv
|
self.argv = argv
|
||||||
|
@ -101,7 +115,7 @@ class Emulator(object):
|
||||||
for parameter in self.cdist_type.optional_multiple_parameters:
|
for parameter in self.cdist_type.optional_multiple_parameters:
|
||||||
argument = "--" + parameter
|
argument = "--" + parameter
|
||||||
parser.add_argument(argument, dest=parameter, action='append', required=False,
|
parser.add_argument(argument, dest=parameter, action='append', required=False,
|
||||||
default=self.cdist_type.parameter_defaults.get(parameter, None))
|
default=DefaultList.create(self.cdist_type.parameter_defaults.get(parameter, None)))
|
||||||
for parameter in self.cdist_type.boolean_parameters:
|
for parameter in self.cdist_type.boolean_parameters:
|
||||||
argument = "--" + parameter
|
argument = "--" + parameter
|
||||||
parser.add_argument(argument, dest=parameter, action='store_const', const='')
|
parser.add_argument(argument, dest=parameter, action='store_const', const='')
|
||||||
|
@ -128,8 +142,6 @@ class Emulator(object):
|
||||||
self.parameters = {}
|
self.parameters = {}
|
||||||
for key,value in vars(self.args).items():
|
for key,value in vars(self.args).items():
|
||||||
if value is not None:
|
if value is not None:
|
||||||
if isinstance(value, list):
|
|
||||||
value = '\n'.join(value)
|
|
||||||
self.parameters[key] = value
|
self.parameters[key] = value
|
||||||
|
|
||||||
if self.cdist_object.exists:
|
if self.cdist_object.exists:
|
||||||
|
|
|
@ -102,7 +102,6 @@ class ObjectTestCase(test.CdistTestCase):
|
||||||
self.cdist_object = core.CdistObject(self.cdist_type, object_base_path, 'moon')
|
self.cdist_object = core.CdistObject(self.cdist_type, object_base_path, 'moon')
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
self.cdist_object.changed = False
|
|
||||||
self.cdist_object.prepared = False
|
self.cdist_object.prepared = False
|
||||||
self.cdist_object.ran = False
|
self.cdist_object.ran = False
|
||||||
self.cdist_object.source = []
|
self.cdist_object.source = []
|
||||||
|
@ -172,13 +171,6 @@ class ObjectTestCase(test.CdistTestCase):
|
||||||
expected = []
|
expected = []
|
||||||
self.assertEqual(list(self.cdist_object.requirements), expected)
|
self.assertEqual(list(self.cdist_object.requirements), expected)
|
||||||
|
|
||||||
def test_changed(self):
|
|
||||||
self.assertFalse(self.cdist_object.changed)
|
|
||||||
|
|
||||||
def test_changed_after_changing(self):
|
|
||||||
self.cdist_object.changed = True
|
|
||||||
self.assertTrue(self.cdist_object.changed)
|
|
||||||
|
|
||||||
def test_state(self):
|
def test_state(self):
|
||||||
self.assertEqual(self.cdist_object.state, '')
|
self.assertEqual(self.cdist_object.state, '')
|
||||||
|
|
||||||
|
|
|
@ -134,7 +134,11 @@ class DirectoryDict(collections.MutableMapping):
|
||||||
def __setitem__(self, key, value):
|
def __setitem__(self, key, value):
|
||||||
try:
|
try:
|
||||||
with open(os.path.join(self.path, key), "w") as fd:
|
with open(os.path.join(self.path, key), "w") as fd:
|
||||||
if type(value) == type([]):
|
if (not hasattr(value, 'strip') and
|
||||||
|
(hasattr(value, '__getitem__') or
|
||||||
|
hasattr(value, '__iter__'))):
|
||||||
|
# if it looks like a sequence and quacks like a sequence,
|
||||||
|
# it is a sequence
|
||||||
for v in value:
|
for v in value:
|
||||||
fd.write(str(v) + '\n')
|
fd.write(str(v) + '\n')
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -4,11 +4,41 @@ Changelog
|
||||||
* Changes are always commented with their author in (braces)
|
* Changes are always commented with their author in (braces)
|
||||||
* Exception: No braces means author == Nico Schottelius
|
* Exception: No braces means author == Nico Schottelius
|
||||||
|
|
||||||
|
3.0.1:
|
||||||
|
* Type __line: Remove unecessary backslash escape
|
||||||
|
* Type __directory: Add messaging support (Daniel Heule)
|
||||||
|
* Type __directory: Do not generate code if mode is 0xxx ((Daniel Heule)
|
||||||
|
* Type __directory: Add messaging support (Daniel Heule)
|
||||||
|
* Type __package: Fix typo in optional parameter ptype (Daniel Heule)
|
||||||
|
* Type __start_on_boot: Fix for SuSE's chkconfig (Daniel Heule)
|
||||||
|
|
||||||
3.0.0:
|
3.0.0: 2013-12-24
|
||||||
* Core: Messaging support added
|
* Core: Added messaging support
|
||||||
* Type: __iptables_rule: Use default parameter
|
* Core: Removed unused "changed" attribute of objects
|
||||||
|
* Core: Support default values for multiple parameters (Steven Armstrong)
|
||||||
|
* Core: Ensure Object Parameter file contains \n (Steven Armstrong)
|
||||||
|
* New Type: __zypper_repo (Daniel Heule)
|
||||||
|
* New Type: __zypper_service (Daniel Heule)
|
||||||
|
* New Type: __package_emerge (Daniel Heule)
|
||||||
|
* New Type: __package_emerge_dependencies (Daniel Heule)
|
||||||
|
* Type __cron: Add support for raw lines (Daniel Heule)
|
||||||
|
* Type __cron: Suppress stderr output from crontab (Daniel Heule)
|
||||||
|
* Type __cron: Fix quoting issue (Daniel Heule)
|
||||||
* Type __file: Do not generate code if mode is 0xxx
|
* Type __file: Do not generate code if mode is 0xxx
|
||||||
|
* Type __iptables_rule: Use default parameter
|
||||||
|
* Type __key_value: Fix quoting issue (Steven Armstrong)
|
||||||
|
* Type __package: Use state --present by default (Steven Armstrong)
|
||||||
|
* Type __package_zypper: Support non packages as well (Daniel Heule)
|
||||||
|
* Type __package_zypper: Support package versions (Daniel Heule)
|
||||||
|
* Type __postfix_*: Depend on __postfix Type (Steven Armstrong)
|
||||||
|
* Type __postfix_postconf: Enable support for SuSE (Daniel Heule)
|
||||||
|
* Type __postfix: Enable support for SuSE (Daniel Heule)
|
||||||
|
* Type __start_on_boot: Use default parameter state
|
||||||
|
* Type __start_on_boot: Add support for gentoo (Daniel Heule)
|
||||||
|
* Type __user: Add support for state parameter (Daniel Heule)
|
||||||
|
* Type __user: Add support for system users (Daniel Heule)
|
||||||
|
* Type __user: Add messaging support (Steven Armstrong)
|
||||||
|
* Type __zypper_service: Support older SuSE releases (Daniel Heule)
|
||||||
|
|
||||||
2.3.7: 2013-12-02
|
2.3.7: 2013-12-02
|
||||||
* Type __file: Secure the file transfer by using mktemp (Steven Armstrong)
|
* Type __file: Secure the file transfer by using mktemp (Steven Armstrong)
|
||||||
|
|
|
@ -1,10 +0,0 @@
|
||||||
Changelog
|
|
||||||
---------
|
|
||||||
|
|
||||||
* Changes are always commented with their author in (braces)
|
|
||||||
* Exception: No braces means author == Nico Schottelius
|
|
||||||
|
|
||||||
future (maybe 3.x?):
|
|
||||||
* Type __cron: Dropped support for old internal format
|
|
||||||
Using this version prior to running cdist 2.1.2 will
|
|
||||||
break add the cron entries twice.
|
|
BIN
docs/dev/factsheet.odt
Normal file
BIN
docs/dev/factsheet.odt
Normal file
Binary file not shown.
BIN
docs/dev/factsheet.pdf
Normal file
BIN
docs/dev/factsheet.pdf
Normal file
Binary file not shown.
BIN
docs/dev/logs/2011-11-16.workflow-example.dia
Normal file
BIN
docs/dev/logs/2011-11-16.workflow-example.dia
Normal file
Binary file not shown.
BIN
docs/dev/logs/2011-11-16.workflow-example.png
Normal file
BIN
docs/dev/logs/2011-11-16.workflow-example.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 20 KiB |
BIN
docs/dev/logs/2011-11-17.workflow-example.dia
Normal file
BIN
docs/dev/logs/2011-11-17.workflow-example.dia
Normal file
Binary file not shown.
BIN
docs/dev/logs/2013-08-27-notifications.xoj
Normal file
BIN
docs/dev/logs/2013-08-27-notifications.xoj
Normal file
Binary file not shown.
6
docs/dev/logs/2013-12-12.discussion
Normal file
6
docs/dev/logs/2013-12-12.discussion
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
With Steven
|
||||||
|
|
||||||
|
- Implement environments
|
||||||
|
- for configuring "anything" including switches
|
||||||
|
- can disable / use other global explorers
|
||||||
|
- 98% of our framework is generic and can be used for any applikation
|
|
@ -33,7 +33,6 @@ nearby, so grepping for FIXME gives all positions that need to be fixed.
|
||||||
|
|
||||||
Indention is 4 spaces (welcome to the python world).
|
Indention is 4 spaces (welcome to the python world).
|
||||||
|
|
||||||
|
|
||||||
HOW TO SUBMIT STUFF FOR INCLUSION INTO UPSTREAM CDIST
|
HOW TO SUBMIT STUFF FOR INCLUSION INTO UPSTREAM CDIST
|
||||||
-----------------------------------------------------
|
-----------------------------------------------------
|
||||||
If you did some cool changes to cdist, which you value as a benefit for
|
If you did some cool changes to cdist, which you value as a benefit for
|
||||||
|
@ -75,14 +74,91 @@ code and thus such a type introduces redundant functionality that is given by
|
||||||
core cdist already.
|
core cdist already.
|
||||||
|
|
||||||
|
|
||||||
|
EXAMPLE GIT WORKFLOW
|
||||||
|
---------------------
|
||||||
|
The following workflow works fine for most developers:
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
# get latest upstream master branch
|
||||||
|
git clone https://github.com/telmich/cdist.git
|
||||||
|
|
||||||
|
# update if already existing
|
||||||
|
cd cdist; git fetch -v; git merge origin/master
|
||||||
|
|
||||||
|
# create a new branch for your feature/bugfix
|
||||||
|
cd cdist # if you haven't done before
|
||||||
|
git checkout -b documentation_cleanup
|
||||||
|
|
||||||
|
# *hack*
|
||||||
|
*hack*
|
||||||
|
|
||||||
|
# clone the cdist repository on github 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
|
||||||
|
|
||||||
|
# push the new branch to github
|
||||||
|
git push github documentation_cleanup
|
||||||
|
|
||||||
|
# (or everything)
|
||||||
|
git push --mirror github
|
||||||
|
|
||||||
|
# create a pull request at github (use a browser)
|
||||||
|
# *fixthingsbecausequalityassurancefoundissuesinourpatch*
|
||||||
|
*hack*
|
||||||
|
|
||||||
|
# push code to github again
|
||||||
|
git push ... # like above
|
||||||
|
|
||||||
|
# add comment that everything should be green now (use a browser)
|
||||||
|
|
||||||
|
# go back to master branch
|
||||||
|
git checkout master
|
||||||
|
|
||||||
|
# update master branch that includes your changes now
|
||||||
|
git fetch -v origin
|
||||||
|
git diff master..origin/master
|
||||||
|
git merge origin/master
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
If at any point you want to go back to the original master branch, you can
|
||||||
|
use **git stash** to stash your changes away:
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
# assume you are on documentation_cleanup
|
||||||
|
git stash
|
||||||
|
|
||||||
|
# change to master and update to most recent upstream version
|
||||||
|
git checkout master
|
||||||
|
git fetch -v origin
|
||||||
|
git merge origin/master
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Similar when you want to develop another new feature, you go back
|
||||||
|
to the master branch and create another branch based on it:
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
# change to master and update to most recent upstream version
|
||||||
|
git checkout master
|
||||||
|
git fetch -v origin
|
||||||
|
git merge origin/master
|
||||||
|
|
||||||
|
git checkout -b another_feature
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
(you can repeat the code above for as many features as you want to develop
|
||||||
|
in parallel)
|
||||||
|
|
||||||
|
|
||||||
SEE ALSO
|
SEE ALSO
|
||||||
--------
|
--------
|
||||||
- cdist(7)
|
- cdist(7)
|
||||||
|
- git(1)
|
||||||
|
- git-checkout(1)
|
||||||
|
- git-stash(1)
|
||||||
|
|
||||||
|
|
||||||
COPYING
|
COPYING
|
||||||
-------
|
-------
|
||||||
Copyright \(C) 2011-2012 Nico Schottelius. Free use of this software is
|
Copyright \(C) 2011-2013 Nico Schottelius. Free use of this software is
|
||||||
granted under the terms of the GNU General Public License version 3 (GPLv3).
|
granted under the terms of the GNU General Public License version 3 (GPLv3).
|
||||||
|
|
|
@ -55,6 +55,11 @@ To upgrade to the lastet version do
|
||||||
|
|
||||||
## General Update Instructions
|
## General Update Instructions
|
||||||
|
|
||||||
|
### 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
|
### Updating from 2.2 to 2.3
|
||||||
|
|
||||||
No incompatiblities.
|
No incompatiblities.
|
||||||
|
|
Loading…
Reference in a new issue