Merge branches 'preos' and 'install_integration' into 4.0-pre-not-stable
This commit is contained in:
commit
5f9eef3bbb
55 changed files with 765 additions and 182 deletions
8
Makefile
8
Makefile
|
@ -20,6 +20,13 @@
|
||||||
|
|
||||||
A2XM=a2x -f manpage --no-xmllint -a encoding=UTF-8
|
A2XM=a2x -f manpage --no-xmllint -a encoding=UTF-8
|
||||||
A2XH=a2x -f xhtml --no-xmllint -a encoding=UTF-8
|
A2XH=a2x -f xhtml --no-xmllint -a encoding=UTF-8
|
||||||
|
# Create cross-links in html man pages
|
||||||
|
# We look for something like "cdist-type(7)" and make a href out of it
|
||||||
|
# The first matching group is the man page name and the second group
|
||||||
|
# is the man page section (1 or 7). The first three lines of the input
|
||||||
|
# (xml, DOCTYPE, head tags) are ignored, since the head tags contains
|
||||||
|
# the title of the page and should not contain a href.
|
||||||
|
CROSSLINK=sed --in-place '1,3!s/\([[:alnum:]_-]*\)(\([17]\))/<a href="..\/man\2\/\1.html">&<\/a>/g'
|
||||||
helper=./bin/build-helper
|
helper=./bin/build-helper
|
||||||
|
|
||||||
MANDIR=docs/man
|
MANDIR=docs/man
|
||||||
|
@ -86,6 +93,7 @@ MANSTATICALL=$(MANSTATICMAN) $(MANSTATICHTML)
|
||||||
# Creating the type html page
|
# Creating the type html page
|
||||||
%.html: %.text
|
%.html: %.text
|
||||||
$(A2XH) $^
|
$(A2XH) $^
|
||||||
|
$(CROSSLINK) $@
|
||||||
|
|
||||||
man: $(MANTYPEALL) $(MANREFALL) $(MANSTATICALL)
|
man: $(MANTYPEALL) $(MANREFALL) $(MANSTATICALL)
|
||||||
|
|
||||||
|
|
|
@ -104,6 +104,11 @@ eof
|
||||||
;;
|
;;
|
||||||
|
|
||||||
ml-release)
|
ml-release)
|
||||||
|
if [ $# -ne 1 ]; then
|
||||||
|
echo "$0 ml-release version" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
version=$1; shift
|
version=$1; shift
|
||||||
|
|
||||||
to_a=cdist
|
to_a=cdist
|
||||||
|
@ -142,35 +147,17 @@ eof
|
||||||
|
|
||||||
freecode-release)
|
freecode-release)
|
||||||
version=$1; shift
|
version=$1; shift
|
||||||
api_token=$(awk '/machine freecode login/ { print $8 }' ~/.netrc)
|
|
||||||
|
|
||||||
printf "Enter tag list for freecode release %s> " "$version"
|
printf "Enter tag list for freecode release %s> " "$version"
|
||||||
read taglist
|
read taglist
|
||||||
|
|
||||||
printf "Enter changelog for freecode release %s> " "$version"
|
printf "Enter changelog for freecode release %s> " "$version"
|
||||||
read changelog
|
read changelog
|
||||||
|
|
||||||
echo "Submit preview"
|
echo "Submitting to freecode ..."
|
||||||
cat << eof
|
python2 ~/p/foreign/freecode-submit-2.7/freecode-submit -P cdist \
|
||||||
tag_list = $taglist
|
-v "$version" -c "$changelog" \
|
||||||
changelog = $changelog
|
-t "$taglist" \
|
||||||
version = $version
|
-n
|
||||||
eof
|
|
||||||
printf "Press enter to submit to freecode> "
|
|
||||||
read dummy
|
|
||||||
|
|
||||||
cat << eof | cfreecode-api release-add cdist
|
|
||||||
{
|
|
||||||
"auth_code": "$api_token",
|
|
||||||
"release": {
|
|
||||||
"tag_list": "$taglist",
|
|
||||||
"version": "$version",
|
|
||||||
"changelog": "$changelog",
|
|
||||||
"hidden_from_frontpage": false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
eof
|
|
||||||
|
|
||||||
;;
|
;;
|
||||||
|
|
||||||
release-git-tag)
|
release-git-tag)
|
||||||
|
|
|
@ -24,12 +24,12 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
# Use ip, if available
|
# Use ip, if available
|
||||||
if command -v ip; then
|
if command -v ip >/dev/null; then
|
||||||
ip -o link show | sed -n 's/^[0-9]\+: \(.\+\): <.*/\1/p'
|
ip -o link show | sed -n 's/^[0-9]\+: \(.\+\): <.*/\1/p'
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! command -v ifconfig; then
|
if ! command -v ifconfig >/dev/null; then
|
||||||
# no ifconfig, nothing we could do
|
# no ifconfig, nothing we could do
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -25,7 +25,7 @@ destination="/$__object_id"
|
||||||
|
|
||||||
os=$("$__explorer/os")
|
os=$("$__explorer/os")
|
||||||
case "$os" in
|
case "$os" in
|
||||||
"freebsd")
|
"freebsd"|"openbsd")
|
||||||
# FIXME: should be something like this based on man page, but can not test
|
# FIXME: should be something like this based on man page, but can not test
|
||||||
stat -f "type: %ST
|
stat -f "type: %ST
|
||||||
owner: %Du %Su
|
owner: %Du %Su
|
||||||
|
@ -35,6 +35,15 @@ size: %Dz
|
||||||
links: %Dl
|
links: %Dl
|
||||||
" "$destination"
|
" "$destination"
|
||||||
;;
|
;;
|
||||||
|
"macosx")
|
||||||
|
stat -f "type: %HT
|
||||||
|
owner: %Du %Su
|
||||||
|
group: %Dg %Sg
|
||||||
|
mode: %Lp %Sp
|
||||||
|
size: %Dz
|
||||||
|
links: %Dl
|
||||||
|
" "$destination"
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
stat --printf="type: %F
|
stat --printf="type: %F
|
||||||
owner: %u %U
|
owner: %u %U
|
||||||
|
|
|
@ -25,7 +25,7 @@ destination="/$__object_id"
|
||||||
|
|
||||||
os=$("$__explorer/os")
|
os=$("$__explorer/os")
|
||||||
case "$os" in
|
case "$os" in
|
||||||
"freebsd")
|
"freebsd"|"openbsd")
|
||||||
# FIXME: should be something like this based on man page, but can not test
|
# FIXME: should be something like this based on man page, but can not test
|
||||||
stat -f "type: %ST
|
stat -f "type: %ST
|
||||||
owner: %Du %Su
|
owner: %Du %Su
|
||||||
|
@ -33,6 +33,13 @@ group: %Dg %Sg
|
||||||
mode: %Op %Sp
|
mode: %Op %Sp
|
||||||
" "$destination"
|
" "$destination"
|
||||||
;;
|
;;
|
||||||
|
"macosx")
|
||||||
|
stat -f "type: %HT
|
||||||
|
owner: %Du %Su
|
||||||
|
group: %Dg %Sg
|
||||||
|
mode: %Lp %Sp
|
||||||
|
" "$destination"
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
stat --printf="type: %F
|
stat --printf="type: %F
|
||||||
owner: %u %U
|
owner: %u %U
|
||||||
|
|
|
@ -33,6 +33,15 @@ group: %Dg %Sg
|
||||||
mode: %Op %Sp
|
mode: %Op %Sp
|
||||||
size: %Dz
|
size: %Dz
|
||||||
links: %Dl
|
links: %Dl
|
||||||
|
" "$destination"
|
||||||
|
;;
|
||||||
|
"macosx")
|
||||||
|
stat -f "type: %HT
|
||||||
|
owner: %Du %Su
|
||||||
|
group: %Dg %Sg
|
||||||
|
mode: %Lp %Sp
|
||||||
|
size: %Dz
|
||||||
|
links: %Dl
|
||||||
" "$destination"
|
" "$destination"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
|
|
|
@ -21,6 +21,10 @@
|
||||||
# Retrieve the contents of /etc/hostname
|
# Retrieve the contents of /etc/hostname
|
||||||
#
|
#
|
||||||
|
|
||||||
|
# Almost any distribution
|
||||||
if [ -f /etc/hostname ]; then
|
if [ -f /etc/hostname ]; then
|
||||||
cat /etc/hostname
|
cat /etc/hostname
|
||||||
|
# SuSE
|
||||||
|
elif [ -f /etc/HOSTNAME ]; then
|
||||||
|
cat /etc/HOSTNAME
|
||||||
fi
|
fi
|
||||||
|
|
26
cdist/conf/type/__hostname/explorer/hostname_sysconfig
Executable file
26
cdist/conf/type/__hostname/explorer/hostname_sysconfig
Executable file
|
@ -0,0 +1,26 @@
|
||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# 2014 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 <http://www.gnu.org/licenses/>.
|
||||||
|
#
|
||||||
|
#
|
||||||
|
# Retrieve the contents of /etc/hostname
|
||||||
|
#
|
||||||
|
|
||||||
|
if [ -f /etc/sysconfig/network ]; then
|
||||||
|
awk -F= '/^HOSTNAME=/ { print $2 }' /etc/sysconfig/network
|
||||||
|
fi
|
|
@ -28,14 +28,28 @@ fi
|
||||||
os=$(cat "$__global/explorer/os")
|
os=$(cat "$__global/explorer/os")
|
||||||
name_running=$(cat "$__global/explorer/hostname")
|
name_running=$(cat "$__global/explorer/hostname")
|
||||||
name_config=$(cat "$__object/explorer/hostname_file")
|
name_config=$(cat "$__object/explorer/hostname_file")
|
||||||
|
name_sysconfig=$(cat "$__object/explorer/hostname_sysconfig")
|
||||||
has_hostnamectl=$(cat "$__object/explorer/has_hostnamectl")
|
has_hostnamectl=$(cat "$__object/explorer/has_hostnamectl")
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# If everything is ok -> exit
|
# If everything is ok -> exit
|
||||||
#
|
#
|
||||||
if [ "$name_config" = "$name_should" -a "$name_running" = "$name_should" ]; then
|
case "$os" in
|
||||||
exit 0
|
archlinux|debian|suse|ubuntu)
|
||||||
fi
|
if [ "$name_config" = "$name_should" -a "$name_running" = "$name_should" ]; then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
centos)
|
||||||
|
if [ "$name_sysconfig" = "$name_should" -a "$name_running" = "$name_should" ]; then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Unsupported os: $os" >&2
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# Setup hostname
|
# Setup hostname
|
||||||
|
@ -45,6 +59,17 @@ echo changed >> "$__messages_out"
|
||||||
if [ "$has_hostnamectl" ]; then
|
if [ "$has_hostnamectl" ]; then
|
||||||
echo "hostnamectl set-hostname '$name_should'"
|
echo "hostnamectl set-hostname '$name_should'"
|
||||||
else
|
else
|
||||||
echo "hostname '$name_should'"
|
case "$os" in
|
||||||
echo "printf '%s\n' '$name_should' > /etc/hostname"
|
archlinux|debian|ubuntu)
|
||||||
|
echo "hostname '$name_should'"
|
||||||
|
echo "printf '%s\n' '$name_should' > /etc/hostname"
|
||||||
|
;;
|
||||||
|
centos)
|
||||||
|
echo "hostname '$name_should'"
|
||||||
|
;;
|
||||||
|
suse)
|
||||||
|
echo "hostname '$name_should'"
|
||||||
|
echo "printf '%s\n' '$name_should' > /etc/HOSTNAME"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -20,6 +20,12 @@
|
||||||
#
|
#
|
||||||
|
|
||||||
os=$(cat "$__global/explorer/os")
|
os=$(cat "$__global/explorer/os")
|
||||||
|
if [ -f "$__object/parameter/name" ]; then
|
||||||
|
name_should="$(cat "$__object/parameter/name")"
|
||||||
|
else
|
||||||
|
name_should="$(echo "${__target_host%%.*}")"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
not_supported() {
|
not_supported() {
|
||||||
echo "Your operating system ($os) is currently not supported by this type (${__type##*/})." >&2
|
echo "Your operating system ($os) is currently not supported by this type (${__type##*/})." >&2
|
||||||
|
@ -28,11 +34,18 @@ not_supported() {
|
||||||
}
|
}
|
||||||
|
|
||||||
case "$os" in
|
case "$os" in
|
||||||
archlinux|debian|ubuntu)
|
archlinux|debian|suse|ubuntu)
|
||||||
# handled in gencode-remote
|
# handled in gencode-remote
|
||||||
:
|
:
|
||||||
;;
|
;;
|
||||||
*)
|
centos)
|
||||||
not_supported
|
__key_value sysconfig-hostname \
|
||||||
;;
|
--file /etc/sysconfig/network \
|
||||||
|
--delimiter '=' \
|
||||||
|
--key HOSTNAME \
|
||||||
|
--value "$name_should" --exact_delimiter
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
not_supported
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
|
@ -39,7 +39,7 @@ fi
|
||||||
# backslash-escaped $jaildir
|
# backslash-escaped $jaildir
|
||||||
sjaildir="$(echo ${jaildir} | sed 's#/#\\/#g')"
|
sjaildir="$(echo ${jaildir} | sed 's#/#\\/#g')"
|
||||||
|
|
||||||
jls_output="$(jls | grep "[ ^I]${sjaildir}\/${name}\$")" || true
|
jls_output="$(jls | grep "[ ]${sjaildir}\/${name}\$")" || true
|
||||||
|
|
||||||
if [ -n "${jls_output}" ]; then
|
if [ -n "${jls_output}" ]; then
|
||||||
echo "STARTED"
|
echo "STARTED"
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
#
|
#
|
||||||
# 2012 Jake Guffey (jake.guffey at eprotex.com)
|
# 2012,2014 Jake Guffey (jake.guffey at eprotex.com)
|
||||||
#
|
#
|
||||||
# This file is part of cdist.
|
# This file is part of cdist.
|
||||||
#
|
#
|
||||||
|
@ -104,6 +104,7 @@ stopJail() {
|
||||||
# Check $status before issuing command
|
# Check $status before issuing command
|
||||||
if [ "$status" = "STARTED" ]; then
|
if [ "$status" = "STARTED" ]; then
|
||||||
echo "/etc/rc.d/jail stop ${name}"
|
echo "/etc/rc.d/jail stop ${name}"
|
||||||
|
echo "stop" >> "$__messages_out"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,6 +112,7 @@ startJail() {
|
||||||
# Check $status before issuing command
|
# Check $status before issuing command
|
||||||
if [ "$status" = "NOTSTART" ]; then
|
if [ "$status" = "NOTSTART" ]; then
|
||||||
echo "/etc/rc.d/jail start ${name}"
|
echo "/etc/rc.d/jail start ${name}"
|
||||||
|
echo "start" >> "$__messages_out"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -162,6 +164,7 @@ EOF
|
||||||
rm -f /etc/rc.conf.bak
|
rm -f /etc/rc.conf.bak
|
||||||
fi
|
fi
|
||||||
EOF
|
EOF
|
||||||
|
echo "delete" >> "$__messages_out"
|
||||||
}
|
}
|
||||||
|
|
||||||
createJail() {
|
createJail() {
|
||||||
|
@ -215,6 +218,7 @@ cat <<EOF
|
||||||
fi
|
fi
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
|
echo "create" >> "$__messages_out"
|
||||||
|
|
||||||
# Create the ro+rw mountpoint entries in fstab
|
# Create the ro+rw mountpoint entries in fstab
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
|
@ -310,6 +314,7 @@ if [ "$onboot" = "yes" ]; then
|
||||||
fi
|
fi
|
||||||
unset jail_list
|
unset jail_list
|
||||||
EOF
|
EOF
|
||||||
|
echo "onboot" >> "$__messages_out"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Add the normal entries into the jail's rc.conf
|
# Add the normal entries into the jail's rc.conf
|
||||||
|
|
|
@ -67,6 +67,19 @@ be removed then re-added with the correct IP address/netmask or the appropriate
|
||||||
line (jail_<name>_ip="...") modified within rc.conf through some alternate
|
line (jail_<name>_ip="...") modified within rc.conf through some alternate
|
||||||
means.
|
means.
|
||||||
|
|
||||||
|
MESSAGES
|
||||||
|
--------
|
||||||
|
start::
|
||||||
|
The jail was started
|
||||||
|
stop::
|
||||||
|
The jail was stopped
|
||||||
|
create:
|
||||||
|
The jail was created
|
||||||
|
delete::
|
||||||
|
The jail was deleted
|
||||||
|
onboot::
|
||||||
|
The jail was configured to start on boot
|
||||||
|
|
||||||
EXAMPLES
|
EXAMPLES
|
||||||
--------
|
--------
|
||||||
|
|
||||||
|
|
|
@ -29,8 +29,8 @@
|
||||||
# Can only be used on FreeBSD
|
# Can only be used on FreeBSD
|
||||||
os="$(cat "$__global/explorer/os")"
|
os="$(cat "$__global/explorer/os")"
|
||||||
if [ ! "$os" = "freebsd" ]; then
|
if [ ! "$os" = "freebsd" ]; then
|
||||||
echo "__jail can only be used on FreeBSD targets!" >&2
|
echo "__jail can only be used on FreeBSD targets!" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
jaildir="$(cat "$__object/parameter/jaildir")"
|
jaildir="$(cat "$__object/parameter/jaildir")"
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
#
|
#
|
||||||
# 2011 Steven Armstrong (steven-cdist at armstrong.cc)
|
# 2011 Steven Armstrong (steven-cdist at armstrong.cc)
|
||||||
|
# 2014 Daniel Heule (hda at sfs.biz)
|
||||||
#
|
#
|
||||||
# This file is part of cdist.
|
# This file is part of cdist.
|
||||||
#
|
#
|
||||||
|
@ -18,36 +19,85 @@
|
||||||
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
|
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
|
|
||||||
key="$(cat "$__object/parameter/key" 2>/dev/null \
|
export key="$(cat "$__object/parameter/key" 2>/dev/null \
|
||||||
|| echo "$__object_id")"
|
|| echo "$__object_id")"
|
||||||
state="$(cat "$__object/parameter/state" 2>/dev/null \
|
export state="$(cat "$__object/parameter/state")"
|
||||||
|| echo "present")"
|
|
||||||
file="$(cat "$__object/parameter/file")"
|
|
||||||
delimiter="$(cat "$__object/parameter/delimiter")"
|
|
||||||
value="$(cat "$__object/parameter/value" 2>/dev/null \
|
|
||||||
|| echo "__CDIST_NOTSET__")"
|
|
||||||
|
|
||||||
case "$state" in
|
file="$(cat "$__object/parameter/file")"
|
||||||
absent)
|
|
||||||
if grep -q -E "^$key$delimiter+" "$file"; then
|
if [ ! -f "$file" ]; then
|
||||||
# if the key exists, with whatever value, we will have to remove it
|
echo "nosuchfile"
|
||||||
# so report it as present
|
exit
|
||||||
echo present
|
fi
|
||||||
else
|
|
||||||
# key does not exist
|
export delimiter="$(cat "$__object/parameter/delimiter")"
|
||||||
echo absent
|
export value="$(cat "$__object/parameter/value" 2>/dev/null \
|
||||||
fi
|
|| echo "__CDIST_NOTSET__")"
|
||||||
;;
|
if [ -f "$__object/parameter/exact_delimiter" ]; then
|
||||||
present)
|
export exact_delimiter=1
|
||||||
if grep -q -E "^$key$delimiter+$value$" "$file"; then
|
else
|
||||||
# key exists and value is same
|
export exact_delimiter=0
|
||||||
echo present
|
fi
|
||||||
elif grep -q -E "^$key$delimiter+" "$file"; then
|
|
||||||
# key exists, but value is empty or different
|
awk -f - "$file" <<"AWK_EOF"
|
||||||
echo wrongvalue
|
BEGIN {
|
||||||
else
|
state=ENVIRON["state"]
|
||||||
# key does not exist
|
key=ENVIRON["key"]
|
||||||
echo absent
|
delimiter=ENVIRON["delimiter"]
|
||||||
fi
|
value=ENVIRON["value"]
|
||||||
;;
|
exact_delimiter=ENVIRON["exact_delimiter"]
|
||||||
esac
|
found=0
|
||||||
|
}
|
||||||
|
# enter the main loop
|
||||||
|
{
|
||||||
|
i = index($0,key)
|
||||||
|
if(i == 1) {
|
||||||
|
delval = substr($0,length(key)+1)
|
||||||
|
delpos = index(delval,delimiter)
|
||||||
|
if(delpos == 0) {
|
||||||
|
# in this case, the delimiter was not found
|
||||||
|
next
|
||||||
|
}
|
||||||
|
if(delpos > 1) {
|
||||||
|
spaces = substr(delval,1,delpos-1)
|
||||||
|
sub(/[ \t]*/,"",spaces)
|
||||||
|
if( length(spaces) > 0 ) {
|
||||||
|
# if there are not only spaces between key and delimiter,
|
||||||
|
# continue since we we are on the wrong line
|
||||||
|
next
|
||||||
|
}
|
||||||
|
if( exact_delimiter == 1) {
|
||||||
|
# we have key and delimiter, but since additional spaces are not alowed
|
||||||
|
# return wrongformat
|
||||||
|
found=1
|
||||||
|
print "wrongformat"
|
||||||
|
exit
|
||||||
|
}
|
||||||
|
}
|
||||||
|
found=1
|
||||||
|
if(state == "absent") {
|
||||||
|
# on state absent, only the ocurance is relevant, so exit here
|
||||||
|
print "present"
|
||||||
|
exit
|
||||||
|
}
|
||||||
|
linevalue=substr(delval,delpos + length(delimiter))
|
||||||
|
if(exact_delimiter == 0){
|
||||||
|
#ok, now strip tabs and whitespaces at the beginning of the value
|
||||||
|
sub(/[ \t]*/,"",linevalue)
|
||||||
|
}
|
||||||
|
# Key with separator found
|
||||||
|
if(linevalue == value) {
|
||||||
|
# exact match found, so state is present
|
||||||
|
print "present"
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
print "wrongvalue"
|
||||||
|
}
|
||||||
|
exit
|
||||||
|
}
|
||||||
|
}
|
||||||
|
END {
|
||||||
|
if(found == 0)
|
||||||
|
print "absent"
|
||||||
|
}
|
||||||
|
AWK_EOF
|
||||||
|
|
102
cdist/conf/type/__key_value/files/remote_script.sh
Normal file
102
cdist/conf/type/__key_value/files/remote_script.sh
Normal file
|
@ -0,0 +1,102 @@
|
||||||
|
export key="$(cat "$__object/parameter/key" 2>/dev/null \
|
||||||
|
|| echo "$__object_id")"
|
||||||
|
export 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 \
|
||||||
|
|| echo "__CDIST_NOTSET__")"
|
||||||
|
if [ -f "$__object/parameter/exact_delimiter" ]; then
|
||||||
|
export exact_delimiter=1
|
||||||
|
else
|
||||||
|
export exact_delimiter=0
|
||||||
|
fi
|
||||||
|
|
||||||
|
tmpfile=$(mktemp "${file}.cdist.XXXXXXXXXX")
|
||||||
|
# preserve ownership and permissions by copying existing file over tmpfile
|
||||||
|
if [ -f "$file" ]; then
|
||||||
|
cp -p "$file" "$tmpfile"
|
||||||
|
else
|
||||||
|
touch "$file"
|
||||||
|
fi
|
||||||
|
awk -f - "$file" >"$tmpfile" <<"AWK_EOF"
|
||||||
|
BEGIN {
|
||||||
|
# import variables in a secure way ..
|
||||||
|
state=ENVIRON["state"]
|
||||||
|
key=ENVIRON["key"]
|
||||||
|
delimiter=ENVIRON["delimiter"]
|
||||||
|
value=ENVIRON["value"]
|
||||||
|
comment=ENVIRON["comment"]
|
||||||
|
exact_delimiter=ENVIRON["exact_delimiter"]
|
||||||
|
inserted=0
|
||||||
|
lastline=""
|
||||||
|
lastlinepopulated=0
|
||||||
|
line=key delimiter value
|
||||||
|
}
|
||||||
|
# enter the main loop
|
||||||
|
{
|
||||||
|
# I dont use regex, this is by design, so we can match against every value without special meanings of chars ...
|
||||||
|
i = index($0,key)
|
||||||
|
if(i == 1) {
|
||||||
|
delval = substr($0,length(key)+1)
|
||||||
|
delpos = index(delval,delimiter)
|
||||||
|
if(delpos > 1) {
|
||||||
|
spaces = substr(delval,1,delpos-1)
|
||||||
|
sub(/[ \t]*/,"",spaces)
|
||||||
|
if( length(spaces) > 0 ) {
|
||||||
|
# if there are not only spaces between key and delimiter,
|
||||||
|
# continue since we we are on the wrong line
|
||||||
|
if(lastlinepopulated == 1) {
|
||||||
|
print lastline
|
||||||
|
}
|
||||||
|
lastline=$0
|
||||||
|
lastlinepopulated=1
|
||||||
|
next
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(state == "absent") {
|
||||||
|
if(lastline == comment) {
|
||||||
|
# if comment is present, clear lastlinepopulated flag
|
||||||
|
lastlinepopulated=0
|
||||||
|
}
|
||||||
|
# if absent, simple yump over this line
|
||||||
|
next
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
# if comment is present and not present in last line
|
||||||
|
if (lastlinepopulated == 1) {
|
||||||
|
print lastline
|
||||||
|
if( comment != "" && lastline != comment) {
|
||||||
|
print comment
|
||||||
|
}
|
||||||
|
lastlinepopulated=0
|
||||||
|
}
|
||||||
|
inserted=1
|
||||||
|
# state is present, so insert correct line here
|
||||||
|
print line
|
||||||
|
lastline=line
|
||||||
|
next
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if(lastlinepopulated == 1) {
|
||||||
|
print lastline
|
||||||
|
}
|
||||||
|
lastline=$0
|
||||||
|
lastlinepopulated=1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
END {
|
||||||
|
if(lastlinepopulated == 1) {
|
||||||
|
print lastline
|
||||||
|
}
|
||||||
|
if(inserted == 0 && state == "present" ) {
|
||||||
|
if(comment != "" && lastline != comment){
|
||||||
|
print comment
|
||||||
|
}
|
||||||
|
print line
|
||||||
|
}
|
||||||
|
}
|
||||||
|
AWK_EOF
|
||||||
|
mv -f "$tmpfile" "$file"
|
|
@ -2,6 +2,7 @@
|
||||||
#
|
#
|
||||||
# 2011 Steven Armstrong (steven-cdist at armstrong.cc)
|
# 2011 Steven Armstrong (steven-cdist at armstrong.cc)
|
||||||
# 2012-2014 Nico Schottelius (nico-cdist at schottelius.org)
|
# 2012-2014 Nico Schottelius (nico-cdist at schottelius.org)
|
||||||
|
# 2014 Daniel Heule (hda at sfs.biz)
|
||||||
#
|
#
|
||||||
# This file is part of cdist.
|
# This file is part of cdist.
|
||||||
#
|
#
|
||||||
|
@ -19,55 +20,56 @@
|
||||||
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
|
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
|
|
||||||
key="$__object_id"
|
|
||||||
[ -f "$__object/parameter/key" ] && key="$(cat "$__object/parameter/key")"
|
|
||||||
|
|
||||||
state_should="$(cat "$__object/parameter/state")"
|
state_should="$(cat "$__object/parameter/state")"
|
||||||
|
|
||||||
file="$(cat "$__object/parameter/file")"
|
|
||||||
delimiter="$(cat "$__object/parameter/delimiter")"
|
|
||||||
# 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
|
if [ "$state_is" = "$state_should" ]; then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# here we check only if the states are valid,
|
||||||
|
# emmit messages and
|
||||||
|
# let awk do the work ...
|
||||||
case "$state_should" in
|
case "$state_should" in
|
||||||
absent)
|
absent)
|
||||||
# remove lines starting with key
|
|
||||||
cat << DONE
|
|
||||||
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
|
|
||||||
echo "remove" >> "$__messages_out"
|
|
||||||
;;
|
|
||||||
present)
|
|
||||||
case "$state_is" in
|
case "$state_is" in
|
||||||
absent)
|
absent|nosuchfile)
|
||||||
# add new key and value
|
# nothing to do
|
||||||
printf 'echo "%s%s%s" >> "%s"' "$key" "$delimiter" "$value_escaped" "$file"
|
|
||||||
echo "add" >> "$__messages_out"
|
|
||||||
;;
|
;;
|
||||||
wrongvalue)
|
wrongformat|wrongvalue|present)
|
||||||
# change exisiting value
|
echo "remove" >> "$__messages_out"
|
||||||
cat << DONE
|
|
||||||
tmpfile=\$(mktemp ${file}.cdist.XXXXXXXXXX)
|
|
||||||
# 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 "changevalue" >> "$__messages_out"
|
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Unknown explorer state: $state_is" >&2
|
echo "Unknown explorer state: $state_is" >&2
|
||||||
exit 1
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
present)
|
||||||
|
case "$state_is" in
|
||||||
|
nosuchfile)
|
||||||
|
echo "create" >> "$__messages_out"
|
||||||
|
;;
|
||||||
|
absent)
|
||||||
|
echo "insert" >> "$__messages_out"
|
||||||
|
;;
|
||||||
|
wrongformated|wrongvalue)
|
||||||
|
echo "change" >> "$__messages_out"
|
||||||
|
;;
|
||||||
|
present)
|
||||||
|
# nothing to do
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
echo "Unknown explorer state: $state_is" >&2
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Unknown state: $state_should" >&2
|
echo "Unknown state: $state_should" >&2
|
||||||
exit 1
|
exit 1
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
cat "$__type/files/remote_script.sh"
|
||||||
|
|
|
@ -25,21 +25,36 @@ delimiter::
|
||||||
OPTIONAL PARAMETERS
|
OPTIONAL PARAMETERS
|
||||||
-------------------
|
-------------------
|
||||||
state::
|
state::
|
||||||
present or absent, defaults to present. If present, sets the key to value,
|
present or absent, defaults to present. If present, sets the key to value,
|
||||||
if absent, removes the key from the file.
|
if absent, removes the key from the file.
|
||||||
key::
|
key::
|
||||||
The key to change. Defaults to object_id.
|
The key to change. Defaults to object_id.
|
||||||
value::
|
value::
|
||||||
The value for the key. Optional if state=absent, required otherwise.
|
The value for the key. Optional if state=absent, required otherwise.
|
||||||
|
comment::
|
||||||
|
If supplied, the value will be inserted before the line with the key,
|
||||||
|
but only if the key or value must be changed.
|
||||||
|
You need to ensure yourself that the line is prefixed with the correct
|
||||||
|
comment sign. (for example # or ; or wathever ..)
|
||||||
|
|
||||||
|
|
||||||
|
BOOLEAN PARAMETERS
|
||||||
|
------------------
|
||||||
|
exact_delimiter::
|
||||||
|
If supplied, treat additional whitespaces between key, delimiter and value
|
||||||
|
as wrong value.
|
||||||
|
|
||||||
|
|
||||||
MESSAGES
|
MESSAGES
|
||||||
--------
|
--------
|
||||||
create::
|
remove::
|
||||||
|
Removed existing key and value
|
||||||
|
insert::
|
||||||
Added key and value
|
Added key and value
|
||||||
change::
|
change::
|
||||||
Changed value of existing key
|
Changed value of existing key
|
||||||
remove::
|
create::
|
||||||
Removed existing key and value
|
A new line was inserted in a new file
|
||||||
|
|
||||||
|
|
||||||
EXAMPLES
|
EXAMPLES
|
||||||
|
@ -55,13 +70,19 @@ __key_value my-fancy-id --file /etc/login.defs --key SYS_UID_MAX --value 666 \
|
||||||
|
|
||||||
# Enable packet forwarding
|
# Enable packet forwarding
|
||||||
__key_value net.ipv4.ip_forward --file /etc/sysctl.conf --value 1 \
|
__key_value net.ipv4.ip_forward --file /etc/sysctl.conf --value 1 \
|
||||||
--delimiter '='
|
--delimiter ' = ' --comment '# my linux kernel should act as a router'
|
||||||
|
|
||||||
# Remove existing key/value
|
# Remove existing key/value
|
||||||
__key_value LEGACY_KEY --file /etc/somefile --state absent --delimiter '='
|
__key_value LEGACY_KEY --file /etc/somefile --state absent --delimiter '='
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
MORE INFORMATION
|
||||||
|
----------------
|
||||||
|
This type try to handle as many values as possible, so it doesn't use regexes.
|
||||||
|
So you need to exactly specify the key and delimiter. Delimiter can be of any lenght.
|
||||||
|
|
||||||
|
|
||||||
SEE ALSO
|
SEE ALSO
|
||||||
--------
|
--------
|
||||||
- cdist-type(7)
|
- cdist-type(7)
|
||||||
|
|
1
cdist/conf/type/__key_value/parameter/boolean
Normal file
1
cdist/conf/type/__key_value/parameter/boolean
Normal file
|
@ -0,0 +1 @@
|
||||||
|
exact_delimiter
|
1
cdist/conf/type/__key_value/parameter/default/comment
Normal file
1
cdist/conf/type/__key_value/parameter/default/comment
Normal file
|
@ -0,0 +1 @@
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
key
|
key
|
||||||
value
|
value
|
||||||
state
|
state
|
||||||
|
comment
|
||||||
|
|
|
@ -29,6 +29,9 @@ case "$os" in
|
||||||
# Debian needs a seperate package
|
# Debian needs a seperate package
|
||||||
__package locales --state present
|
__package locales --state present
|
||||||
;;
|
;;
|
||||||
|
suse)
|
||||||
|
:
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Sorry, do not know how to handle os: $os" >&2
|
echo "Sorry, do not know how to handle os: $os" >&2
|
||||||
echo "Please edit the type ${__type##*/} to fix this." >&2
|
echo "Please edit the type ${__type##*/} to fix this." >&2
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
#
|
#
|
||||||
# 2011 Nico Schottelius (nico-cdist at schottelius.org)
|
# 2011-2014 Nico Schottelius (nico-cdist at schottelius.org)
|
||||||
#
|
#
|
||||||
# This file is part of cdist.
|
# This file is part of cdist.
|
||||||
#
|
#
|
||||||
|
@ -27,6 +27,14 @@ else
|
||||||
name="$__object_id"
|
name="$__object_id"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Support installing from an URL
|
||||||
|
if [ -f "$__object/parameter/url" ]; then
|
||||||
|
install_name="$(cat "$__object/parameter/url")"
|
||||||
|
else
|
||||||
|
install_name="$name"
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
state_should="$(cat "$__object/parameter/state")"
|
state_should="$(cat "$__object/parameter/state")"
|
||||||
|
|
||||||
if grep -q -E "(centos|redhat|amazon)" "$__global/explorer/os"; then
|
if grep -q -E "(centos|redhat|amazon)" "$__global/explorer/os"; then
|
||||||
|
@ -47,7 +55,7 @@ fi
|
||||||
|
|
||||||
case "$state_should" in
|
case "$state_should" in
|
||||||
present)
|
present)
|
||||||
echo yum $opts install \"$name\"
|
echo yum $opts install \"$install_name\"
|
||||||
;;
|
;;
|
||||||
absent)
|
absent)
|
||||||
echo yum $opts remove \"$name\"
|
echo yum $opts remove \"$name\"
|
||||||
|
|
|
@ -27,6 +27,8 @@ name::
|
||||||
|
|
||||||
state::
|
state::
|
||||||
Either "present" or "absent", defaults to "present"
|
Either "present" or "absent", defaults to "present"
|
||||||
|
url::
|
||||||
|
URL to use for the package
|
||||||
|
|
||||||
|
|
||||||
EXAMPLES
|
EXAMPLES
|
||||||
|
@ -41,6 +43,9 @@ __package_yum python --state present --name python2
|
||||||
|
|
||||||
# Remove obsolete package
|
# Remove obsolete package
|
||||||
__package_yum puppet --state absent
|
__package_yum puppet --state absent
|
||||||
|
|
||||||
|
__package epel-release-6-8 \
|
||||||
|
--url http://mirror.switch.ch/ftp/mirror/epel/6/i386/epel-release-6-8.noarch.rpm
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,2 +1,3 @@
|
||||||
name
|
name
|
||||||
state
|
state
|
||||||
|
url
|
||||||
|
|
|
@ -27,13 +27,18 @@ os=$(cat "$__global/explorer/os")
|
||||||
|
|
||||||
case "$os" in
|
case "$os" in
|
||||||
archlinux|debian|ubuntu)
|
archlinux|debian|ubuntu)
|
||||||
__package tzdata --state present
|
package=tzdata
|
||||||
require="__package/tzdata" __link /etc/localtime \
|
;;
|
||||||
--source "/usr/share/zoneinfo/${timezone}" \
|
suse)
|
||||||
--type symbolic
|
package=timezone
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Unsupported OS $os" >&2
|
echo "Unsupported OS $os" >&2
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
__package "$package" --state present
|
||||||
|
require="__package/$package" __link /etc/localtime \
|
||||||
|
--source "/usr/share/zoneinfo/${timezone}" \
|
||||||
|
--type symbolic
|
||||||
|
|
61
cdist/conf/type/__yum_repo/files/repo.template
Executable file
61
cdist/conf/type/__yum_repo/files/repo.template
Executable file
|
@ -0,0 +1,61 @@
|
||||||
|
#!/bin/sh
|
||||||
|
set -u
|
||||||
|
cat << DONE
|
||||||
|
# Created by cdist ${__type##*/}
|
||||||
|
# Do not change. Changes will be overwritten.
|
||||||
|
#
|
||||||
|
[$repo_name]
|
||||||
|
DONE
|
||||||
|
# single value properties
|
||||||
|
single_value='name
|
||||||
|
metalink
|
||||||
|
mirrorlist
|
||||||
|
gpgcakey
|
||||||
|
gpgcheck
|
||||||
|
exclude
|
||||||
|
includepkgs
|
||||||
|
failovermethod
|
||||||
|
timeout
|
||||||
|
http_caching
|
||||||
|
retries
|
||||||
|
throttle
|
||||||
|
bandwidth
|
||||||
|
sslcacert
|
||||||
|
sslverify
|
||||||
|
sslclientcert
|
||||||
|
sslclientkey
|
||||||
|
ssl_check_cert_permissions
|
||||||
|
metadata_expire
|
||||||
|
mirrorlist_expire
|
||||||
|
proxy
|
||||||
|
proxy_username
|
||||||
|
proxy_password
|
||||||
|
username
|
||||||
|
password
|
||||||
|
cost'
|
||||||
|
for key in $single_value; do
|
||||||
|
if [ -f "$__object/parameter/$key" ]; then
|
||||||
|
printf '%s=%s\n' "$key" "$(cat "$__object/parameter/$key")"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
# multi value properties
|
||||||
|
for key in baseurl gpgkey; do
|
||||||
|
if [ -f "$__object/parameter/$key" ]; then
|
||||||
|
printf '%s=' "$key"
|
||||||
|
prefix=''
|
||||||
|
while read line; do
|
||||||
|
printf '%s%s\n' "$prefix" "$line"
|
||||||
|
prefix=' '
|
||||||
|
done < "$__object/parameter/$key"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
# boolean properties
|
||||||
|
for key in enabled repo_gpgcheck keepalive skip_if_unavailable; do
|
||||||
|
if [ -f "$__object/parameter/$key" ]; then
|
||||||
|
printf '%s=1\n' "$key"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
# special cases
|
||||||
|
if [ -f "$__object/parameter/disablegroups" ]; then
|
||||||
|
printf 'enablegroups=0\n'
|
||||||
|
fi
|
91
cdist/conf/type/__yum_repo/man.text
Normal file
91
cdist/conf/type/__yum_repo/man.text
Normal file
|
@ -0,0 +1,91 @@
|
||||||
|
cdist-type__yum_repo(7)
|
||||||
|
=======================
|
||||||
|
Steven Armstrong <steven-cdist--@--armstrong.cc>
|
||||||
|
|
||||||
|
|
||||||
|
NAME
|
||||||
|
----
|
||||||
|
cdist-type__yum_repo - manage yum repositories
|
||||||
|
|
||||||
|
|
||||||
|
DESCRIPTION
|
||||||
|
-----------
|
||||||
|
For all undocumented parameters see yum.conf(5).
|
||||||
|
|
||||||
|
|
||||||
|
REQUIRED PARAMETERS
|
||||||
|
-------------------
|
||||||
|
None.
|
||||||
|
|
||||||
|
|
||||||
|
OPTIONAL PARAMETERS
|
||||||
|
-------------------
|
||||||
|
state::
|
||||||
|
'present' or 'absent'. Defaults to 'present'
|
||||||
|
repositoryid::
|
||||||
|
Defaults to __object_id.
|
||||||
|
name::
|
||||||
|
baseurl::
|
||||||
|
Can be specified multiple times.
|
||||||
|
metalink::
|
||||||
|
mirrorlist::
|
||||||
|
gpgkey::
|
||||||
|
Can be specified multiple times.
|
||||||
|
gpgcakey::
|
||||||
|
gpgcheck::
|
||||||
|
exclude::
|
||||||
|
includepkgs::
|
||||||
|
failovermethod::
|
||||||
|
timeout::
|
||||||
|
http_caching::
|
||||||
|
retries::
|
||||||
|
throttle::
|
||||||
|
bandwidth::
|
||||||
|
sslcacert::
|
||||||
|
sslverify::
|
||||||
|
sslclientcert::
|
||||||
|
sslclientkey::
|
||||||
|
ssl_check_cert_permissions::
|
||||||
|
metadata_expire::
|
||||||
|
mirrorlist_expire::
|
||||||
|
proxy::
|
||||||
|
proxy_username::
|
||||||
|
proxy_password::
|
||||||
|
username::
|
||||||
|
password::
|
||||||
|
cost::
|
||||||
|
|
||||||
|
|
||||||
|
BOOLEAN PARAMETERS
|
||||||
|
------------------
|
||||||
|
enabled::
|
||||||
|
repo_gpgcheck::
|
||||||
|
disablegroups::
|
||||||
|
! enablegroups
|
||||||
|
keepalive::
|
||||||
|
skip_if_unavailable::
|
||||||
|
|
||||||
|
|
||||||
|
EXAMPLES
|
||||||
|
--------
|
||||||
|
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
__yum_repo epel \
|
||||||
|
--name 'Extra Packages for Enterprise Linux 6 - $basearch' \
|
||||||
|
--mirrorlist 'https://mirrors.fedoraproject.org/metalink?repo=epel-$releasever&arch=$basearch' \
|
||||||
|
--failovermethod priority \
|
||||||
|
--enabled \
|
||||||
|
--gpgcheck 1 \
|
||||||
|
--gpgkey https://fedoraproject.org/static/0608B895.txt
|
||||||
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
SEE ALSO
|
||||||
|
--------
|
||||||
|
- cdist-type(7)
|
||||||
|
|
||||||
|
|
||||||
|
COPYING
|
||||||
|
-------
|
||||||
|
Copyright \(C) 2014 Steven Armstrong. Free use of this software is
|
||||||
|
granted under the terms of the GNU General Public License version 3 (GPLv3).
|
40
cdist/conf/type/__yum_repo/manifest
Executable file
40
cdist/conf/type/__yum_repo/manifest
Executable file
|
@ -0,0 +1,40 @@
|
||||||
|
#!/bin/sh
|
||||||
|
#
|
||||||
|
# 2014 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/>.
|
||||||
|
#
|
||||||
|
|
||||||
|
os=$(cat "$__global/explorer/os")
|
||||||
|
state="$(cat "$__object/parameter/state")"
|
||||||
|
|
||||||
|
case "$os" in
|
||||||
|
centos)
|
||||||
|
repo_name="$__object_id"
|
||||||
|
export repo_name
|
||||||
|
repo_file="/etc/yum.repos.d/${repo_name}.repo"
|
||||||
|
"$__type/files/repo.template" | \
|
||||||
|
__file "$repo_file" \
|
||||||
|
--owner root --group root --mode 644 \
|
||||||
|
--state "$state" \
|
||||||
|
--source -
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
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
|
3
cdist/conf/type/__yum_repo/notes
Normal file
3
cdist/conf/type/__yum_repo/notes
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
https://access.redhat.com/site/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Deployment_Guide/sec-Configuring_Yum_and_Yum_Repositories.html
|
||||||
|
https://access.redhat.com/site/documentation/en-US/Red_Hat_Enterprise_Linux_OpenStack_Platform/2/html/Getting_Started_Guide/sect-Configuring_Software_Repositories.html
|
||||||
|
http://docs.puppetlabs.com/references/latest/type.html#yumrepo
|
5
cdist/conf/type/__yum_repo/parameter/boolean
Normal file
5
cdist/conf/type/__yum_repo/parameter/boolean
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
enabled
|
||||||
|
repo_gpgcheck
|
||||||
|
disablegroups
|
||||||
|
keepalive
|
||||||
|
skip_if_unavailable
|
1
cdist/conf/type/__yum_repo/parameter/default/state
Normal file
1
cdist/conf/type/__yum_repo/parameter/default/state
Normal file
|
@ -0,0 +1 @@
|
||||||
|
present
|
27
cdist/conf/type/__yum_repo/parameter/optional
Normal file
27
cdist/conf/type/__yum_repo/parameter/optional
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
bandwidth
|
||||||
|
cost
|
||||||
|
exclude
|
||||||
|
failovermethod
|
||||||
|
gpgcakey
|
||||||
|
gpgcheck
|
||||||
|
http_caching
|
||||||
|
includepkgs
|
||||||
|
metadata_expire
|
||||||
|
mirrorlist
|
||||||
|
mirrorlist_expire
|
||||||
|
name
|
||||||
|
password
|
||||||
|
proxy
|
||||||
|
proxy_password
|
||||||
|
proxy_username
|
||||||
|
repositoryid
|
||||||
|
retries
|
||||||
|
sslcacert
|
||||||
|
ssl_check_cert_permissions
|
||||||
|
sslclientcert
|
||||||
|
sslclientkey
|
||||||
|
sslverify
|
||||||
|
state
|
||||||
|
throttle
|
||||||
|
timeout
|
||||||
|
username
|
2
cdist/conf/type/__yum_repo/parameter/optional_multiple
Normal file
2
cdist/conf/type/__yum_repo/parameter/optional_multiple
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
baseurl
|
||||||
|
gpgkey
|
|
@ -18,11 +18,11 @@
|
||||||
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
|
# 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
|
# Retrieve the id from the repo with the uri from parameter uri - parsed zypper output
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
if [ -f "$__object/parameter/repo_uri" ]; then
|
if [ -f "$__object/parameter/uri" ]; then
|
||||||
uri="$(cat "$__object/parameter/repo_uri")"
|
uri="$(cat "$__object/parameter/uri")"
|
||||||
else
|
else
|
||||||
uri="$__object_id"
|
uri="$__object_id"
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
#exec >&2
|
#exec >&2
|
||||||
#set -x
|
#set -x
|
||||||
|
|
||||||
zypper_def_opts=" -q "
|
zypper_def_opts=" -q --non-interactive --gpg-auto-import-keys "
|
||||||
|
|
||||||
if [ -f "$__object/parameter/repo_desc" ]; then
|
if [ -f "$__object/parameter/repo_desc" ]; then
|
||||||
desc="$(cat "$__object/parameter/repo_desc")"
|
desc="$(cat "$__object/parameter/repo_desc")"
|
||||||
|
@ -33,8 +33,8 @@ else
|
||||||
desc="$__object_id"
|
desc="$__object_id"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -f "$__object/parameter/repo_uri" ]; then
|
if [ -f "$__object/parameter/uri" ]; then
|
||||||
uri="$(cat "$__object/parameter/repo_uri")"
|
uri="$(cat "$__object/parameter/uri")"
|
||||||
else
|
else
|
||||||
uri="$__object_id"
|
uri="$__object_id"
|
||||||
fi
|
fi
|
||||||
|
@ -65,7 +65,7 @@ fi
|
||||||
case "$state" in
|
case "$state" in
|
||||||
present)
|
present)
|
||||||
if [ -z "$desc" ] || [ -z "$uri" ]; then
|
if [ -z "$desc" ] || [ -z "$uri" ]; then
|
||||||
echo "parameter repo_desc and repo_uri for $state needed" >&2
|
echo "parameter repo_desc and uri for $state needed" >&2
|
||||||
exit 4
|
exit 4
|
||||||
fi
|
fi
|
||||||
if [ -z "$repo_id" ]; then
|
if [ -z "$repo_id" ]; then
|
||||||
|
|
|
@ -22,13 +22,13 @@ OPTIONAL PARAMETERS
|
||||||
-------------------
|
-------------------
|
||||||
state::
|
state::
|
||||||
Either "present" or "absent" or "enabled" or "disabled", defaults to "present" +
|
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 +
|
#present# - make sure that the repo is aviable, needs uri and repo_desc +
|
||||||
for all following states, the repo can be searched via repo_id or repo_uri +
|
for all following states, the repo can be searched via repo_id or uri +
|
||||||
#absent# - drop the repo if found +
|
#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 +
|
#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 +
|
#disabled# - instead of absent (drop), a repo can also set to disabled, wich makes it inaccessible +
|
||||||
|
|
||||||
repo_uri::
|
uri::
|
||||||
If supplied, use the uri and not the object id as repo uri.
|
If supplied, use the uri and not the object id as repo uri.
|
||||||
|
|
||||||
repo_desc::
|
repo_desc::
|
||||||
|
@ -43,10 +43,10 @@ EXAMPLES
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
# Ensure testrepo in installed
|
# Ensure testrepo in installed
|
||||||
__zypper_repo testrepo --state present --repo_uri http://url.to.your.repo/with/path
|
__zypper_repo testrepo --state present --uri http://url.to.your.repo/with/path
|
||||||
|
|
||||||
# Drop repo by repo uri
|
# Drop repo by repo uri
|
||||||
__zypper_repo testrepo --state absent --repo_uri http://url.to.your.repo/with/path
|
__zypper_repo testrepo --state absent --uri http://url.to.your.repo/with/path
|
||||||
|
|
||||||
# Drop repo by id number (attention: repos are always numbered from 1 to max)
|
# Drop repo by id number (attention: repos are always numbered from 1 to max)
|
||||||
__zypper_repo testrepo --state absent --repo_id 1
|
__zypper_repo testrepo --state absent --repo_id 1
|
||||||
|
@ -55,7 +55,7 @@ __zypper_repo testrepo --state absent --repo_id 1
|
||||||
__zypper_repo testrepo2 --state enabled --repo_id 2
|
__zypper_repo testrepo2 --state enabled --repo_id 2
|
||||||
|
|
||||||
# enable repo by uri
|
# enable repo by uri
|
||||||
__zypper_repo testrepo3 --state enabled --repo_uri http://url.to.your.repo/with/path
|
__zypper_repo testrepo3 --state enabled --uri http://url.to.your.repo/with/path
|
||||||
|
|
||||||
# disable a repo works like enabling it
|
# disable a repo works like enabling it
|
||||||
__zypper_repo testrepo4 --state disabled --repo_id 4
|
__zypper_repo testrepo4 --state disabled --repo_id 4
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
state
|
state
|
||||||
repo_uri
|
uri
|
||||||
repo_desc
|
repo_desc
|
||||||
repo_id
|
repo_id
|
||||||
|
|
|
@ -20,8 +20,8 @@
|
||||||
#
|
#
|
||||||
# Manage services with Zypper (mostly suse)
|
# Manage services with Zypper (mostly suse)
|
||||||
#
|
#
|
||||||
if [ -f "$__object/parameter/service_uri" ]; then
|
if [ -f "$__object/parameter/uri" ]; then
|
||||||
uri="$(cat "$__object/parameter/service_uri")"
|
uri="$(cat "$__object/parameter/uri")"
|
||||||
else
|
else
|
||||||
uri="/$__object_id"
|
uri="/$__object_id"
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -20,8 +20,8 @@
|
||||||
#
|
#
|
||||||
# Manage services with Zypper (mostly suse)
|
# Manage services with Zypper (mostly suse)
|
||||||
#
|
#
|
||||||
if [ -f "$__object/parameter/service_uri" ]; then
|
if [ -f "$__object/parameter/uri" ]; then
|
||||||
uri="$(cat "$__object/parameter/service_uri")"
|
uri="$(cat "$__object/parameter/uri")"
|
||||||
else
|
else
|
||||||
uri="/$__object_id"
|
uri="/$__object_id"
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -25,7 +25,7 @@
|
||||||
#exec >&2
|
#exec >&2
|
||||||
#set -x
|
#set -x
|
||||||
|
|
||||||
zypper_def_opts=" -q "
|
zypper_def_opts=" -q --non-interactive --gpg-auto-import-keys "
|
||||||
|
|
||||||
if [ -f "$__object/parameter/service_desc" ]; then
|
if [ -f "$__object/parameter/service_desc" ]; then
|
||||||
desc="$(cat "$__object/parameter/service_desc")"
|
desc="$(cat "$__object/parameter/service_desc")"
|
||||||
|
@ -33,8 +33,8 @@ else
|
||||||
desc="$__object_id"
|
desc="$__object_id"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -f "$__object/parameter/service_uri" ]; then
|
if [ -f "$__object/parameter/uri" ]; then
|
||||||
uri="$(cat "$__object/parameter/service_uri")"
|
uri="$(cat "$__object/parameter/uri")"
|
||||||
else
|
else
|
||||||
uri="$__object_id"
|
uri="$__object_id"
|
||||||
fi
|
fi
|
||||||
|
@ -73,10 +73,12 @@ case "$state_should" in
|
||||||
present)
|
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 refs
|
||||||
|
echo zypper $zypper_def_opts ref
|
||||||
;;
|
;;
|
||||||
absent)
|
absent)
|
||||||
echo zypper $zypper_def_opts removeservice "$service_id"
|
echo zypper $zypper_def_opts removeservice "$service_id"
|
||||||
echo zypper $zypper_def_opts refs
|
echo zypper $zypper_def_opts refs
|
||||||
|
echo zypper $zypper_def_opts ref
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Unknown state: $state_should" >&2
|
echo "Unknown state: $state_should" >&2
|
||||||
|
|
|
@ -15,7 +15,7 @@ zypper is usually used on SuSE systems to manage services.
|
||||||
|
|
||||||
REQUIRED PARAMETERS
|
REQUIRED PARAMETERS
|
||||||
-------------------
|
-------------------
|
||||||
service_uri::
|
uri::
|
||||||
Uri of the service
|
Uri of the service
|
||||||
|
|
||||||
|
|
||||||
|
@ -45,13 +45,13 @@ EXAMPLES
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
# Ensure that internal SLES11 SP3 RIS is in installed and all other services and repos are discarded
|
# 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
|
__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 ohter services or repos
|
||||||
__zypper_service INTERNAL_SLES11_SP3 --service_desc "Internal SLES11 SP3 RIS" --service_uri "http://path/to/your/ris/dir"
|
__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 ohter services or repos
|
||||||
__zypper_service INTERNAL_SLES11_SP3 --state absent --service_uri "http://path/to/your/ris/dir"
|
__zypper_service INTERNAL_SLES11_SP3 --state absent --uri "http://path/to/your/ris/dir"
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
|
@ -25,10 +25,9 @@
|
||||||
#exec >&2
|
#exec >&2
|
||||||
#set -x
|
#set -x
|
||||||
|
|
||||||
zypper_def_opts=" -q "
|
|
||||||
|
|
||||||
if [ -f "$__object/parameter/service_uri" ]; then
|
if [ -f "$__object/parameter/uri" ]; then
|
||||||
uri="$(cat "$__object/parameter/service_uri")"
|
uri="$(cat "$__object/parameter/uri")"
|
||||||
else
|
else
|
||||||
uri="$__object_id"
|
uri="$__object_id"
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
service_uri
|
uri
|
||||||
|
|
|
@ -143,6 +143,9 @@ class DirectoryDict(collections.MutableMapping):
|
||||||
fd.write(str(v) + '\n')
|
fd.write(str(v) + '\n')
|
||||||
else:
|
else:
|
||||||
fd.write(str(value))
|
fd.write(str(value))
|
||||||
|
# ensure file ends with a single newline
|
||||||
|
if value and value[-1] != '\n':
|
||||||
|
fd.write('\n')
|
||||||
except EnvironmentError as e:
|
except EnvironmentError as e:
|
||||||
raise cdist.Error(str(e))
|
raise cdist.Error(str(e))
|
||||||
|
|
||||||
|
@ -281,7 +284,7 @@ class FileStringProperty(FileBasedProperty):
|
||||||
value = ""
|
value = ""
|
||||||
try:
|
try:
|
||||||
with open(path, "r") as fd:
|
with open(path, "r") as fd:
|
||||||
value = fd.read()
|
value = fd.read().rstrip('\n')
|
||||||
except EnvironmentError:
|
except EnvironmentError:
|
||||||
pass
|
pass
|
||||||
return value
|
return value
|
||||||
|
@ -292,6 +295,9 @@ class FileStringProperty(FileBasedProperty):
|
||||||
try:
|
try:
|
||||||
with open(path, "w") as fd:
|
with open(path, "w") as fd:
|
||||||
fd.write(str(value))
|
fd.write(str(value))
|
||||||
|
# ensure file ends with a single newline
|
||||||
|
if value[-1] != '\n':
|
||||||
|
fd.write('\n')
|
||||||
except EnvironmentError as e:
|
except EnvironmentError as e:
|
||||||
raise cdist.Error(str(e))
|
raise cdist.Error(str(e))
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -12,8 +12,31 @@ Changelog
|
||||||
* Core: Integrate initial preos support
|
* Core: Integrate initial preos support
|
||||||
|
|
||||||
|
|
||||||
3.1.2:
|
3.1.6:
|
||||||
|
* Type __package_yum: Support retrieving package via URL
|
||||||
|
* Type __hostname: Support SuSE and have CentOS use sysconfig value
|
||||||
|
* Type __locale: Support SuSE
|
||||||
|
* Type __timezone: Support SuSE
|
||||||
|
* Type __file: Support MacOS X (Manuel Hutter)
|
||||||
|
|
||||||
|
3.1.5: 2014-05-05
|
||||||
|
* Type __zypper_repo: Automatically import gpg keys (Daniel Heule)
|
||||||
|
* Type __zypper_service: Automatically import gpg keys (Daniel Heule)
|
||||||
|
|
||||||
|
3.1.4: 2014-05-04
|
||||||
|
* Core: Ensure all created files end in \n (Steven Armstrong)
|
||||||
|
* Documentation: Cleanup up, added HTML links (Tomas Pospisek)
|
||||||
|
* Explorer interfaces: Remove test output (Daniel Heule)
|
||||||
|
* Type __jail: Add messaging support (Jake Guffey)
|
||||||
|
|
||||||
|
3.1.3: 2014-04-29
|
||||||
|
* New Type: __yum_repo (Steven Armstrong)
|
||||||
|
* Type __hostname: Add support for CentOS
|
||||||
|
|
||||||
|
3.1.2: 2014-04-12
|
||||||
|
* Documentation: Add missing environment variables to reference
|
||||||
* Type __qemu_img: size is optional, if state is not present
|
* Type __qemu_img: size is optional, if state is not present
|
||||||
|
* Type __key_value: Rewrite using awk (Daniel Heule)
|
||||||
* New Type: __dog_vdi
|
* New Type: __dog_vdi
|
||||||
|
|
||||||
3.1.1: 2014-03-26
|
3.1.1: 2014-03-26
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
#
|
#
|
||||||
# 2010-2013 Nico Schottelius (nico-cdist at schottelius.org)
|
# 2010-2014 Nico Schottelius (nico-cdist at schottelius.org)
|
||||||
# 2014 Daniel Heule (hda at sfs.biz)
|
# 2014 Daniel Heule (hda at sfs.biz)
|
||||||
#
|
#
|
||||||
# This file is part of cdist.
|
# This file is part of cdist.
|
||||||
|
@ -237,6 +237,12 @@ The following environment variables influence the behaviour of cdist:
|
||||||
require::
|
require::
|
||||||
Setup dependencies between objects (see cdist-manifest(7))
|
Setup dependencies between objects (see cdist-manifest(7))
|
||||||
|
|
||||||
|
CDIST_LOCAL_SHELL::
|
||||||
|
Use this shell locally instead of /bin/sh to execute scripts
|
||||||
|
|
||||||
|
CDIST_REMOTE_SHELL::
|
||||||
|
Use this shell remotely instead of /bin/sh to execute scripts
|
||||||
|
|
||||||
CDIST_OVERRIDE::
|
CDIST_OVERRIDE::
|
||||||
Allow overwriting type parameters (see cdist-manifest(7))
|
Allow overwriting type parameters (see cdist-manifest(7))
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ cdist supports different subcommands as explained below.
|
||||||
|
|
||||||
GENERAL
|
GENERAL
|
||||||
-------
|
-------
|
||||||
All commands except the following options:
|
All commands accept the following options:
|
||||||
|
|
||||||
-d, --debug::
|
-d, --debug::
|
||||||
Set log level to debug
|
Set log level to debug
|
||||||
|
@ -34,7 +34,7 @@ All commands except the following options:
|
||||||
-h, --help::
|
-h, --help::
|
||||||
Show the help screen
|
Show the help screen
|
||||||
|
|
||||||
-v, --verbose:
|
-v, --verbose::
|
||||||
Set log level to info, be more verbose
|
Set log level to info, be more verbose
|
||||||
|
|
||||||
-V, --version::
|
-V, --version::
|
||||||
|
@ -72,10 +72,10 @@ Configure one or more hosts
|
||||||
-s, --sequential::
|
-s, --sequential::
|
||||||
Operate on multiple hosts sequentially
|
Operate on multiple hosts sequentially
|
||||||
|
|
||||||
--remote-copy REMOTE_COPY:
|
--remote-copy REMOTE_COPY::
|
||||||
Command to use for remote copy (should behave like scp)
|
Command to use for remote copy (should behave like scp)
|
||||||
|
|
||||||
--remote-exec REMOTE_EXEC:
|
--remote-exec REMOTE_EXEC::
|
||||||
Command to use for remote execution (should behave like ssh)
|
Command to use for remote execution (should behave like ssh)
|
||||||
|
|
||||||
SHELL
|
SHELL
|
||||||
|
|
|
@ -25,7 +25,7 @@ location.
|
||||||
For starters, having cdist (which includes the configuration database) on
|
For starters, having cdist (which includes the configuration database) on
|
||||||
your notebook should be fine.
|
your notebook should be fine.
|
||||||
Additionally an external copy of the git repository the configuration
|
Additionally an external copy of the git repository the configuration
|
||||||
relies in is recommended, for use as backup as well to allow easy collaboration
|
relies on is recommended, for use as backup as well as to allow easy collaboration
|
||||||
with others.
|
with others.
|
||||||
|
|
||||||
For more sophisticated setups developing cdist configurations with multiple
|
For more sophisticated setups developing cdist configurations with multiple
|
||||||
|
|
|
@ -13,7 +13,7 @@ DESCRIPTION
|
||||||
Manifests are used to define which objects to create.
|
Manifests are used to define which objects to create.
|
||||||
Objects are instances of **types**, like in object oriented programming languages.
|
Objects are instances of **types**, like in object oriented programming languages.
|
||||||
An object is represented by the combination of
|
An object is represented by the combination of
|
||||||
**type + slash + object name**: **__file/etc/cdist-configured** is an
|
**type + slash + object name**: **\__file/etc/cdist-configured** is an
|
||||||
object of the type ***__file*** with the name ***etc/cdist-configured***.
|
object of the type ***__file*** with the name ***etc/cdist-configured***.
|
||||||
|
|
||||||
All available types can be found in the **cdist/conf/type/** directory,
|
All available types can be found in the **cdist/conf/type/** directory,
|
||||||
|
@ -29,7 +29,7 @@ at an example:
|
||||||
__package apache2 --state absent
|
__package apache2 --state absent
|
||||||
|
|
||||||
# Same with the __directory type
|
# Same with the __directory type
|
||||||
__directory /tmp/cdist --state present
|
__directory /tmp/cdist --state present
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
These two lines create objects, which will later be used to realise the
|
These two lines create objects, which will later be used to realise the
|
||||||
|
@ -89,7 +89,7 @@ SPLITTING UP THE INITIAL MANIFEST
|
||||||
---------------------------------
|
---------------------------------
|
||||||
If you want to split up your initial manifest, you can create other shell
|
If you want to split up your initial manifest, you can create other shell
|
||||||
scripts in **cdist/conf/manifest/** and include them in **cdist/conf/manifest/init**.
|
scripts in **cdist/conf/manifest/** and include them in **cdist/conf/manifest/init**.
|
||||||
Cdist provides the environment variable ***__manifest*** to reference to
|
Cdist provides the environment variable ***__manifest*** to reference
|
||||||
the directory containing the initial manifest (see cdist-reference(7)).
|
the directory containing the initial manifest (see cdist-reference(7)).
|
||||||
|
|
||||||
The following example would include every file with a **.sh** suffix:
|
The following example would include every file with a **.sh** suffix:
|
||||||
|
@ -110,24 +110,39 @@ setup the variable "require" to contain the requirements. Multiple
|
||||||
requirements can be added white space separated.
|
requirements can be added white space separated.
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
# No dependency
|
1 # No dependency
|
||||||
__file /etc/cdist-configured
|
2 __file /etc/cdist-configured
|
||||||
|
3
|
||||||
# Require above object
|
4 # Require above object
|
||||||
require="__file/etc/cdist-configured" __link /tmp/cdist-testfile \
|
5 require="__file/etc/cdist-configured" __link /tmp/cdist-testfile \
|
||||||
--source /etc/cdist-configured --type symbolic
|
6 --source /etc/cdist-configured --type symbolic
|
||||||
|
7
|
||||||
# Require two objects
|
8 # Require two objects
|
||||||
require="__file/etc/cdist-configured __link/tmp/cdist-testfile" \
|
9 require="__file/etc/cdist-configured __link/tmp/cdist-testfile" \
|
||||||
__file /tmp/cdist-another-testfile
|
10 __file /tmp/cdist-another-testfile
|
||||||
|
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
Above the "require" variable is only set for the command that is
|
||||||
|
immediately following it. Dependencies should allways be declared that way.
|
||||||
|
|
||||||
|
On line 4 you can see that the instantion of a type "__link" object needs
|
||||||
|
the object "__file/etc/cdist-configured" to be present, before it can proceed.
|
||||||
|
|
||||||
|
This also means that the "__link" command must make sure, that either
|
||||||
|
"__file/etc/cdist-configured" allready is present, or, if it's not, it needs
|
||||||
|
to be created. The task of cdist is to make sure, that the dependency will be
|
||||||
|
resolved appropriately and thus "__file/etc/cdist-configured" be created
|
||||||
|
if necessary before "__link" proceeds (or to abort execution with an error).
|
||||||
|
|
||||||
All objects that are created in a type manifest are automatically required
|
All objects that are created in a type manifest are automatically required
|
||||||
from the type that is calling them. This is called "autorequirement" in
|
from the type that is calling them. This is called "autorequirement" in
|
||||||
cdist jargon.
|
cdist jargon.
|
||||||
|
|
||||||
|
You can find an more in depth description of the flow execution of manifests
|
||||||
|
in cdist-stages(7) and of how types work in cdist-type(7).
|
||||||
|
|
||||||
CREATE DEPENDENCIES FROM EXECUTION ORDER
|
CREATE DEPENDENCIES FROM EXECUTION ORDER
|
||||||
-----------------------------------------
|
-----------------------------------------
|
||||||
You can tell cdist to execute all types in the order in which they are created
|
You can tell cdist to execute all types in the order in which they are created
|
||||||
|
@ -138,8 +153,6 @@ automatically depends on the previously created object.
|
||||||
It essentially helps you to build up blocks of code that build upon each other
|
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).
|
(like first creating the directory xyz than the file below the directory).
|
||||||
|
|
||||||
THIS IS A BETA FEATURE AND MAY BE REMOVED OR CHANGED AT ANY TIME.
|
|
||||||
|
|
||||||
|
|
||||||
OVERRIDES
|
OVERRIDES
|
||||||
---------
|
---------
|
||||||
|
@ -149,15 +162,13 @@ If you whish, you can setup the environment variable CDIST_OVERRIDE
|
||||||
(any value or even empty is ok) to tell cdist, that this object override is
|
(any value or even empty is ok) to tell cdist, that this object override is
|
||||||
wanted and should be accepted.
|
wanted and should be accepted.
|
||||||
ATTENTION: Only use this feature if you are 100% sure in which order
|
ATTENTION: Only use this feature if you are 100% sure in which order
|
||||||
cdist encounter the affected objects, otherwhise this results
|
cdist encounters the affected objects, otherwhise this results
|
||||||
into an undefined situation.
|
in an undefined situation.
|
||||||
|
|
||||||
If CDIST_OVERRIDE and CDIST_ORDER_DEPENDENCY is set for an object,
|
If CDIST_OVERRIDE and CDIST_ORDER_DEPENDENCY are set for an object,
|
||||||
CDIST_ORDER_DEPENDENCY will be ignored, because adding a dependency in case of
|
CDIST_ORDER_DEPENDENCY will be ignored, because adding a dependency in case of
|
||||||
overrides would result in circular dependencies, which is an error.
|
overrides would result in circular dependencies, which is an error.
|
||||||
|
|
||||||
THIS IS A BETA FEATURE AND MAY BE REMOVED OR CHANGED AT ANY TIME.
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -198,7 +209,7 @@ How to override objects:
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
# for example in the inital manifest
|
# for example in the inital manifest
|
||||||
|
|
||||||
# reate user account foobar with some hash for password
|
# create user account foobar with some hash for password
|
||||||
__user foobar --password 'some_fancy_hash' --home /home/foobarexample
|
__user foobar --password 'some_fancy_hash' --home /home/foobarexample
|
||||||
|
|
||||||
# ... many statements and includes in the manifest later ...
|
# ... many statements and includes in the manifest later ...
|
||||||
|
@ -210,8 +221,8 @@ __user foobar --password 'some_other_hash'
|
||||||
|
|
||||||
# this tells cdist, that you know that this is an override and should be accepted
|
# this tells cdist, that you know that this is an override and should be accepted
|
||||||
CDIST_OVERRIDE=yes __user foobar --password 'some_other_hash'
|
CDIST_OVERRIDE=yes __user foobar --password 'some_other_hash'
|
||||||
# its only an override, means the parameter --home is not touched
|
# it's only an override, means the parameter --home is not touched
|
||||||
# and stay at the original value of /home/foobarexample
|
# and stays at the original value of /home/foobarexample
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
Dependencies defined by execution order work as following:
|
Dependencies defined by execution order work as following:
|
||||||
|
|
|
@ -25,7 +25,7 @@ to use.
|
||||||
HOW TO USE A TYPE
|
HOW TO USE A TYPE
|
||||||
-----------------
|
-----------------
|
||||||
You can use types from the initial manifest or the type manifest like a
|
You can use types from the initial manifest or the type manifest like a
|
||||||
normal command:
|
normal shell command:
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
# Creates empty file /etc/cdist-configured
|
# Creates empty file /etc/cdist-configured
|
||||||
|
|
BIN
docs/speeches/2014-05-08_linuxtag_berlin.odp
Normal file
BIN
docs/speeches/2014-05-08_linuxtag_berlin.odp
Normal file
Binary file not shown.
BIN
docs/speeches/2014-05-08_linuxtag_berlin.pdf
Normal file
BIN
docs/speeches/2014-05-08_linuxtag_berlin.pdf
Normal file
Binary file not shown.
BIN
docs/speeches/2014-05-19_cdi.st-zkb_linux_erfa.odp
Normal file
BIN
docs/speeches/2014-05-19_cdi.st-zkb_linux_erfa.odp
Normal file
Binary file not shown.
BIN
docs/speeches/2014-05-19_cdi.st-zkb_linux_erfa.pdf
Normal file
BIN
docs/speeches/2014-05-19_cdi.st-zkb_linux_erfa.pdf
Normal file
Binary file not shown.
Loading…
Reference in a new issue