first attempt to make this type actually work

Signed-off-by: Steven Armstrong <steven@icarus.ethz.ch>
This commit is contained in:
Steven Armstrong 2015-02-24 23:05:25 +01:00
parent 66ad275212
commit 44d57497e0
8 changed files with 33 additions and 50 deletions

View file

@ -0,0 +1 @@
428915666 15738724 consul

View file

@ -0,0 +1 @@
131560372 17734417 consul

View file

@ -0,0 +1 @@
https://dl.bintray.com/mitchellh/consul/0.5.0_linux_amd64.zip

View file

@ -10,34 +10,28 @@ cdist-type__consul - install consul
DESCRIPTION DESCRIPTION
----------- -----------
Quick and dirty installation of the consul binary. Downloads and installs the consul binary from https://dl.bintray.com/mitchellh/consul.
Note that the consul binary is downloaded on the server and then deployed using Note that the consul binary is downloaded on the server (the machine running
the __file type. 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 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:: install-to::
where to install the binary. Defaults to /usr/local/bin/consul where to install the binary. Defaults to /usr/local/bin/consul
state:: state::
either 'present' or 'absent'. Defaults to 'present' 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 EXAMPLES
-------- --------
@ -46,13 +40,9 @@ EXAMPLES
# just install using defaults # just install using defaults
__consul __consul
# download on the machine running cdist, then unzip, then upload to the target host # specific version
__consul \ __consul \
--install-from https://dl.bintray.com/mitchellh/consul/0.4.1_linux_amd64.zip --version 0.4.1
# take binary from local folder on the machine running cdist
__consul \
--install-from file:///cluster/adm/software/consul/bin/consul
# install the consul binary to a specific location # install the consul binary to a specific location
__consul \ __consul \

View file

@ -33,33 +33,22 @@ case "$os" in
;; ;;
esac esac
versions_dir="$__type/files/versions"
version="$(cat "$__object/parameter/version")"
version_dir="$versions_dir/$version"
state="$(cat "$__object/parameter/state")" if [ ! -d "$version_dir" ]; then
install_from="$(cat "$__object/parameter/install-from")" echo "Unknown consul version '$version'. Expected one of:" >&2
install_to="$(cat "$__object/parameter/install-to")" ls "$versions_dir" >&2
exit 1
if [ "$state" = "absent" ]; then
__file "$install_to" \
--state absent
exit 0
fi fi
case "$install_from" in __staged_file "$(cat "$__object/parameter/install-to")" \
/*|file://*) --source "$(cat "$version_dir/source")" \
source="${install_from#*file://}" --cksum "$(cat "$version_dir/cksum")" \
;; --fetch-command 'curl -s -L "%s"' \
*.zip) --prepare-command 'unzip -p "%s"' \
mkdir "$__object/files" --state "$(cat "$__object/parameter/state")" \
source="$__object/files/consul" --group root \
# FIXME: need some persistent place to cache downloaded files --owner root \
curl -s "$install_from" | unzip -p > "$source" --mode 755
;;
*)
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"

View file

@ -0,0 +1 @@
0.5.0

View file

@ -1,3 +1,3 @@
install-from
install-to install-to
state state
version