Commit bcaca9c2 authored by Nico Schottelius's avatar Nico Schottelius

Merge branch 'preos' into 4.0-pre-not-stable

Signed-off-by: default avatarNico Schottelius <nico@wurzel.schottelius.org>
parents 494b6cbb 56c74314
......@@ -109,8 +109,8 @@ man-dist: man check-date
man-latest-link: web-pub
# Fix ikiwiki, which does not like symlinks for pseudo security
ssh tee.schottelius.org \
"cd /home/services/www/nico/www.nico.schottelius.org/www/software/cdist/man && rm -f latest && ln -sf "$(CHANGELOG_VERSION)" latest"
ssh staticweb.ungleich.ch \
"cd /home/services/www/nico/nico.schottelius.org/www/software/cdist/man/ && rm -f latest && ln -sf "$(CHANGELOG_VERSION)" latest"
################################################################################
# Speeches
......@@ -243,10 +243,7 @@ distclean: clean
# The pub is Nico's "push to all git remotes" way ("make pub")
pub:
for remote in "" github sf; do \
echo "Pushing to $$remote"; \
git push --mirror $$remote; \
done
git push --mirror
test:
$(helper) $@
......@@ -27,11 +27,9 @@ if [ -f "$__object/parameter/distribution" ]; then
else
distribution="$(cat "$__global/explorer/lsb_codename")"
fi
if [ -f "$__object/parameter/component" ]; then
component="$(cat "$__object/parameter/component")"
else
component=""
fi
component="$(cat "$__object/parameter/component")"
if [ -f "$__object/parameter/arch" ]; then
forcedarch="[arch=$(cat "$__object/parameter/arch")]"
else
......
cdist-type__cdist_preos(7)
==========================
Nico Schottelius <nico-cdist--@--schottelius.org>
NAME
----
cdist-type__cdist - Manage cdist installations
DESCRIPTION
-----------
This cdist type creates a directory containing an operating
suitable for installation using cdist.
REQUIRED PARAMETERS
-------------------
OPTIONAL PARAMETERS
-------------------
EXAMPLES
--------
--------------------------------------------------------------------------------
__cdist_preos /tmp/random_name_for_packaging
--------------------------------------------------------------------------------
SEE ALSO
--------
- cdist-type(7)
- cdist-type__cdist(7)
COPYING
-------
Copyright \(C) 2015 Nico Schottelius. Free use of this software is
granted under the terms of the GNU General Public License version 3 (GPLv3).
#!/bin/sh
#
# 2015 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/>.
#
#
destination="/$__object_id"
os=$(cat "$__global/explorer/os")
case "$os" in
archlinux)
kernel=/boot/vmlinuz-linux
initramfs=/boot/initramfs-linux-fallback.img
required_pkg="cdrkit syslinux"
;;
*)
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
# Our root
__directory "$destination" \
--mode 0755
for rootdir in boot bin etc lib; do
require="__directory/$destination" __directory "$destination/$rootdir" \
--mode 0755
done
require="__directory/$destination/etc" __cdistmarker \
--destination "$destination/etc/cdist-configured"
for pkg in $required_pkg; do
__package "$pkg" --state present
done
# Create full dependency chain, because we don't know which file depends on which package
export CDIST_ORDER_DEPENDENCY=1
require="__directory/$destination/boot" __file "$destination/boot/linux" \
--source "$kernel" --mode 0644
require="__directory/$destination/boot" __file "$destination/boot/initramfs" \
--source "$initramfs" --mode 0644
require="__directory/$destination/boot" __file "$destination/boot/syslinux.cfg" \
PROMPT 1
TIMEOUT 50
DEFAULT arch
LABEL arch
LINUX ../vmlinuz-linux
APPEND root=/dev/sda2 rw
INITRD ../initramfs-linux.img
LABEL archfallback
LINUX ../vmlinuz-linux
APPEND root=/dev/sda2 rw
INITRD ../initramfs-linux-fallback.img
......@@ -19,19 +19,11 @@
#
# The marker file is established in the docs, but it isn't obligatory.
if [ -f "$__object/parameter/destination" ]; then
destination="$(cat "$__object/parameter/destination")"
else
destination='/etc/cdist-configured'
fi
destination="$(cat "$__object/parameter/destination")"
# The basic output of date is usually good enough, but variety is the
# spice of life...
if [ -f "$__object/parameter/format" ]; then
format="$(cat "$__object/parameter/format")"
else
format='-u'
fi
format="$(cat "$__object/parameter/format")"
# Dump the timestamp in UTC to the marker
echo "date $format > $destination"
#!/bin/sh
#
# 2015 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/>.
#
destination="$__object_id"
state="$(cat "$__object/parameter/state")"
if [ "$state" = "absent" ]; then
# nothing to do
exit 0
fi
if [ -f "$__object/parameter/onchange" ]; then
if grep -q "^__file/${destination}" "$__messages_in"; then
cat "$__object/parameter/onchange"
fi
fi
cdist-type__config_file(7)
==========================
Steven Armstrong <steven-cdist--@--armstrong.cc>
NAME
----
cdist-type__config_file - manages config files
DESCRIPTION
-----------
Deploy config files using the file type.
Run the given code if the files changes.
REQUIRED PARAMETERS
-------------------
None.
OPTIONAL PARAMETERS
-------------------
group::
see cdist-type__file
mode::
see cdist-type__file
onchange::
the code to run if the file changes
owner::
see cdist-type__file
source::
Path to the config file.
If source is '-' (dash), take what was written to stdin as the config file content.
state::
see cdist-type__file
EXAMPLES
--------
--------------------------------------------------------------------------------
__config_file /etc/consul/conf.d/watch_foo.json \
--owner root --group consul --mode 640 \
--source "$__type/files/watch_foo.json" \
--state present \
--onchange 'service consul status >/dev/null && service consul reload || true'
--------------------------------------------------------------------------------
SEE ALSO
--------
- cdist-type(7)
- cdist-type__file(7)
COPYING
-------
Copyright \(C) 2015 Steven Armstrong. Free use of this software is
granted under the terms of the GNU General Public License version 3 (GPLv3).
#!/bin/sh
#
# 2015 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/>.
#
set -- "/${__object_id}"
for param in $(ls "$__object/parameter/"); do
case "$param" in
source)
source="$(cat "$__object/parameter/source")"
if [ "$source" = "-" ]; then
source="$__object/stdin"
fi
set -- "$@" --source "$source"
;;
owner|group|mode|state)
set -- "$@" "--${param}" "$(cat "$__object/parameter/$param")"
;;
*)
# ignore unknown parameters
:
;;
esac
done
__file "$@"
group
mode
onchange
owner
source
state
https://dl.bintray.com/mitchellh/consul/0.4.1_linux_amd64.zip
https://dl.bintray.com/mitchellh/consul/0.5.0_linux_amd64.zip
cdist-type__consul(7)
=====================
Steven Armstrong <steven-cdist--@--armstrong.cc>
NAME
----
cdist-type__consul - install consul
DESCRIPTION
-----------
Downloads and installs the consul binary from https://dl.bintray.com/mitchellh/consul.
Note that the consul binary is downloaded on the server (the machine running
cdist) and then deployed to the target host using the __file type.
REQUIRED PARAMETERS
-------------------
None.
OPTIONAL PARAMETERS
-------------------
state::
either 'present' or 'absent'. Defaults to 'present'
version::
which version of consul to install. See ./files/versions for a list of
supported versions. Defaults to the latest known version.
EXAMPLES
--------
--------------------------------------------------------------------------------
# just install using defaults
__consul
# specific version
__consul \
--version 0.4.1
--------------------------------------------------------------------------------
SEE ALSO
--------
- cdist-type(7)
COPYING
-------
Copyright \(C) 2015 Steven Armstrong. Free use of this software is
granted under the terms of the GNU General Public License version 3 (GPLv3).
#!/bin/sh
#
# 2015 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")
case "$os" in
centos|redhat|ubuntu|debian|archlinux|gentoo)
# any linux should work
:
;;
*)
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
versions_dir="$__type/files/versions"
version="$(cat "$__object/parameter/version")"
version_dir="$versions_dir/$version"
if [ ! -d "$version_dir" ]; then
echo "Unknown consul version '$version'. Expected one of:" >&2
ls "$versions_dir" >&2
exit 1
fi
__staged_file /usr/local/bin/consul \
--source "$(cat "$version_dir/source")" \
--cksum "$(cat "$version_dir/cksum")" \
--fetch-command 'curl -s -L "%s"' \
--prepare-command 'unzip -p "%s"' \
--state "$(cat "$__object/parameter/state")" \
--group root \
--owner root \
--mode 755
[Unit]
Description=Consul Agent
Wants=basic.target
After=basic.target network.target
[Service]
User=consul
Group=consul
Environment="GOMAXPROCS=2"
ExecStart=/usr/local/bin/consul agent -config-dir /etc/consul/conf.d
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=on-failure
RestartSec=42s
[Install]
WantedBy=multi-user.target
#!/bin/sh
#
# 2015 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/>.
#
if [ -f "/etc/default/consul" ]; then
. /etc/default/consul
fi
. /lib/lsb/init-functions
NAME=consul
CONSUL=/usr/local/bin/consul
CONFIG=/etc/$NAME/conf.d
PID_FILE=/var/run/$NAME/pidfile
export PATH="${PATH:+$PATH:}/usr/sbin:/sbin"
case "$1" in
start)
log_daemon_msg "Starting consul agent" "consul" || true
if start-stop-daemon --start --quiet --oknodo \
--pidfile "$PID_FILE" --background \
--exec $CONSUL -- agent -pid-file="$PID_FILE" -config-dir "$CONFIG"; then
log_end_msg 0 || true
else
log_end_msg 1 || true
fi
;;
stop)
log_daemon_msg "Stopping consul agent" "consul" || true
if start-stop-daemon --stop --quiet --oknodo --pidfile $PID_FILE; then
log_end_msg 0 || true
else
log_end_msg 1 || true
fi
;;
reload)
log_daemon_msg "Reloading consul agent" "consul" || true
if start-stop-daemon --stop --signal HUP --quiet --oknodo --pidfile $PID_FILE --exec $CONSUL; then
log_end_msg 0 || true
else
log_end_msg 1 || true
fi
;;
restart)
$0 stop && $0 start
;;
status)
status_of_proc -p $PID_FILE $CONSUL consul && exit 0 || exit $?
;;