forked from ungleich-public/cdist
Add option for directly downloading on target host.
This commit is contained in:
parent
7d06a3e7d1
commit
9a832d88b5
7 changed files with 90 additions and 12 deletions
1
cdist/conf/type/__consul/files/versions/1.0.6/cksum
Normal file
1
cdist/conf/type/__consul/files/versions/1.0.6/cksum
Normal file
|
@ -0,0 +1 @@
|
|||
4120550353 48801129 consul
|
1
cdist/conf/type/__consul/files/versions/1.0.6/source
Normal file
1
cdist/conf/type/__consul/files/versions/1.0.6/source
Normal file
|
@ -0,0 +1 @@
|
|||
https://releases.hashicorp.com/consul/1.0.6/consul_1.0.6_linux_amd64.zip
|
59
cdist/conf/type/__consul/gencode-remote
Executable file
59
cdist/conf/type/__consul/gencode-remote
Executable file
|
@ -0,0 +1,59 @@
|
|||
#!/bin/sh -e
|
||||
#
|
||||
# 2018 Darko Poljak (darko.poljak at gmail.com)
|
||||
#
|
||||
# This file is part of cdist.
|
||||
#
|
||||
# cdist is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# cdist is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
|
||||
#set -x
|
||||
|
||||
if [ ! -f "$__object/parameter/direct" ]; then
|
||||
# Nothing here, staged file is used.
|
||||
exit 0
|
||||
fi
|
||||
|
||||
state=$(cat "$__object/parameter/state")
|
||||
destination="/usr/local/bin/consul"
|
||||
|
||||
if [ "$state" = "absent" ]; then
|
||||
printf 'rm -f "%s"' "$destination"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
versions_dir="$__type/files/versions"
|
||||
version="$(cat "$__object/parameter/version")"
|
||||
version_dir="$versions_dir/$version"
|
||||
|
||||
source=$(cat "$version_dir/source")
|
||||
source_file_name="${source##*/}"
|
||||
cksum_should=$(cat "$version_dir/cksum" | cut -d' ' -f1,2)
|
||||
|
||||
cat << eof
|
||||
tmpdir=\$(mktemp -d --tmpdir="/tmp" "${__type##*/}.XXXXXXXXXX")
|
||||
curl -s -L "$source" > "\$tmpdir/$source_file_name"
|
||||
unzip -p "\$tmpdir/$source_file_name" > "$destination"
|
||||
rm -rf "\$tmpdir"
|
||||
|
||||
cksum_is=\$(cksum "$destination" | cut -d' ' -f1,2)
|
||||
if [ "\$cksum_is" = "$cksum_should" ]; then
|
||||
chown root:root "$destination"
|
||||
chmod 755 "$destination"
|
||||
else
|
||||
rm -f "$destination"
|
||||
echo "Failed to verify checksum for $__object_name" >&2
|
||||
exit 1
|
||||
fi
|
||||
eof
|
|
@ -10,7 +10,8 @@ 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.
|
||||
cdist) and then deployed to the target host using the __file type unless --direct
|
||||
parameter is used.
|
||||
|
||||
|
||||
REQUIRED PARAMETERS
|
||||
|
@ -28,6 +29,12 @@ version
|
|||
supported versions. Defaults to the latest known version.
|
||||
|
||||
|
||||
BOOLEAN PARAMETERS
|
||||
------------------
|
||||
direct
|
||||
Download and deploy consul binary directly on the target machine.
|
||||
|
||||
|
||||
EXAMPLES
|
||||
--------
|
||||
|
||||
|
@ -36,6 +43,9 @@ EXAMPLES
|
|||
# just install using defaults
|
||||
__consul
|
||||
|
||||
# install by downloading consul binary directly on the target machine
|
||||
__consul --direct
|
||||
|
||||
# specific version
|
||||
__consul \
|
||||
--version 0.4.1
|
||||
|
@ -43,7 +53,8 @@ EXAMPLES
|
|||
|
||||
AUTHORS
|
||||
-------
|
||||
Steven Armstrong <steven-cdist--@--armstrong.cc>
|
||||
| Steven Armstrong <steven-cdist--@--armstrong.cc>
|
||||
| Darko Poljak <darko.poljak--@--gmail.com>
|
||||
|
||||
|
||||
COPYING
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#
|
||||
# 2015 Steven Armstrong (steven-cdist at armstrong.cc)
|
||||
# 2016 Nico Schottelius (nico-cdist at schottelius.org)
|
||||
# 2018 Darko Poljak (darko.poljak at gmail.com)
|
||||
#
|
||||
# This file is part of cdist.
|
||||
#
|
||||
|
@ -44,12 +45,16 @@ if [ ! -d "$version_dir" ]; then
|
|||
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
|
||||
if [ -f "$__object/parameter/direct" ]; then
|
||||
__package unzip
|
||||
else
|
||||
__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
|
||||
fi
|
||||
|
|
1
cdist/conf/type/__consul/parameter/boolean
Normal file
1
cdist/conf/type/__consul/parameter/boolean
Normal file
|
@ -0,0 +1 @@
|
|||
direct
|
|
@ -1 +1 @@
|
|||
0.6.4
|
||||
1.0.6
|
||||
|
|
Loading…
Reference in a new issue