forked from ungleich-public/cdist
first attempt to make this type actually work
Signed-off-by: Steven Armstrong <steven@icarus.ethz.ch>
This commit is contained in:
parent
66ad275212
commit
44d57497e0
8 changed files with 33 additions and 50 deletions
1
cdist/conf/type/__consul/files/versions/0.4.1/cksum
Normal file
1
cdist/conf/type/__consul/files/versions/0.4.1/cksum
Normal file
|
@ -0,0 +1 @@
|
|||
428915666 15738724 consul
|
1
cdist/conf/type/__consul/files/versions/0.5.0/cksum
Normal file
1
cdist/conf/type/__consul/files/versions/0.5.0/cksum
Normal file
|
@ -0,0 +1 @@
|
|||
131560372 17734417 consul
|
1
cdist/conf/type/__consul/files/versions/0.5.0/source
Normal file
1
cdist/conf/type/__consul/files/versions/0.5.0/source
Normal file
|
@ -0,0 +1 @@
|
|||
https://dl.bintray.com/mitchellh/consul/0.5.0_linux_amd64.zip
|
|
@ -10,34 +10,28 @@ cdist-type__consul - install consul
|
|||
|
||||
DESCRIPTION
|
||||
-----------
|
||||
Quick and dirty installation of the consul binary.
|
||||
Note that the consul binary is downloaded on the server and then deployed using
|
||||
the __file type.
|
||||
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.
|
||||
|
||||
Future ideas:
|
||||
- get latest version info from https://checkpoint-api.hashicorp.com/v1/check/consul
|
||||
- then download from
|
||||
https://dl.bintray.com/mitchellh/consul/${current_version}_${os}_${arch}.zip
|
||||
- install from given path to binary
|
||||
- download from given url
|
||||
- install from packet
|
||||
|
||||
REQUIRED PARAMETERS
|
||||
-------------------
|
||||
None.
|
||||
|
||||
|
||||
OPTIONAL PARAMETERS
|
||||
-------------------
|
||||
install-from::
|
||||
uri from where to download consul. This can be anything that curl understands.
|
||||
If install-uri ends with .zip the downloaded file will be unziped and the
|
||||
contained file deployed as the consul binary. If install-uri does not end in .zip
|
||||
it is assumed to be the consul binary and will be deployed as is.
|
||||
|
||||
install-to::
|
||||
where to install the binary. Defaults to /usr/local/bin/consul
|
||||
|
||||
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
|
||||
--------
|
||||
|
@ -46,13 +40,9 @@ EXAMPLES
|
|||
# just install using defaults
|
||||
__consul
|
||||
|
||||
# download on the machine running cdist, then unzip, then upload to the target host
|
||||
# specific version
|
||||
__consul \
|
||||
--install-from https://dl.bintray.com/mitchellh/consul/0.4.1_linux_amd64.zip
|
||||
|
||||
# take binary from local folder on the machine running cdist
|
||||
__consul \
|
||||
--install-from file:///cluster/adm/software/consul/bin/consul
|
||||
--version 0.4.1
|
||||
|
||||
# install the consul binary to a specific location
|
||||
__consul \
|
||||
|
|
|
@ -33,33 +33,22 @@ case "$os" in
|
|||
;;
|
||||
esac
|
||||
|
||||
versions_dir="$__type/files/versions"
|
||||
version="$(cat "$__object/parameter/version")"
|
||||
version_dir="$versions_dir/$version"
|
||||
|
||||
state="$(cat "$__object/parameter/state")"
|
||||
install_from="$(cat "$__object/parameter/install-from")"
|
||||
install_to="$(cat "$__object/parameter/install-to")"
|
||||
|
||||
if [ "$state" = "absent" ]; then
|
||||
__file "$install_to" \
|
||||
--state absent
|
||||
exit 0
|
||||
if [ ! -d "$version_dir" ]; then
|
||||
echo "Unknown consul version '$version'. Expected one of:" >&2
|
||||
ls "$versions_dir" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
case "$install_from" in
|
||||
/*|file://*)
|
||||
source="${install_from#*file://}"
|
||||
;;
|
||||
*.zip)
|
||||
mkdir "$__object/files"
|
||||
source="$__object/files/consul"
|
||||
# FIXME: need some persistent place to cache downloaded files
|
||||
curl -s "$install_from" | unzip -p > "$source"
|
||||
;;
|
||||
*)
|
||||
echo "Do not know how to install from: $install_from" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
__file "$install_to" \
|
||||
--owner root --group root --mode 755 \
|
||||
--source "$source"
|
||||
__staged_file "$(cat "$__object/parameter/install-to")" \
|
||||
--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
|
||||
|
|
1
cdist/conf/type/__consul/parameter/default/version
Normal file
1
cdist/conf/type/__consul/parameter/default/version
Normal file
|
@ -0,0 +1 @@
|
|||
0.5.0
|
|
@ -1,3 +1,3 @@
|
|||
install-from
|
||||
install-to
|
||||
state
|
||||
version
|
||||
|
|
Loading…
Reference in a new issue