forked from ungleich-public/cdist
Added --state absent functionality to docker types
Changed types: __docker __docker_compose
This commit is contained in:
parent
b444697f33
commit
95b92627aa
7 changed files with 51 additions and 33 deletions
|
@ -20,38 +20,39 @@
|
||||||
|
|
||||||
|
|
||||||
os=$(cat "$__global/explorer/os")
|
os=$(cat "$__global/explorer/os")
|
||||||
|
state=$(cat "$__object/parameter/state")
|
||||||
|
|
||||||
case "$os" in
|
case "$os" in
|
||||||
centos)
|
centos)
|
||||||
component="main"
|
component="main"
|
||||||
|
if [ -f "$__object/parameter/experimental" ]; then
|
||||||
|
component="experimental"
|
||||||
|
fi
|
||||||
|
__yum_repo docker \
|
||||||
|
--name 'Docker Repository' \
|
||||||
|
--baseurl "https://yum.dockerproject.org/repo/$component/centos/\$releasever/" \
|
||||||
|
--enabled \
|
||||||
|
--gpgcheck 1 \
|
||||||
|
--gpgkey 'https://yum.dockerproject.org/gpg' \
|
||||||
|
--state ${state}
|
||||||
|
require="__yum_repo/docker" __package docker-engine --state ${state}
|
||||||
|
;;
|
||||||
|
ubuntu)
|
||||||
|
component="main"
|
||||||
if [ -f "$__object/parameter/experimental" ]; then
|
if [ -f "$__object/parameter/experimental" ]; then
|
||||||
component="experimental"
|
component="experimental"
|
||||||
fi
|
fi
|
||||||
export CDIST_ORDER_DEPENDENCY=on
|
__package apparmor --state ${state}
|
||||||
__yum_repo docker \
|
__package ca-certificates --state ${state}
|
||||||
--name 'Docker Repository' \
|
__package apt-transport-https --state ${state}
|
||||||
--baseurl "https://yum.dockerproject.org/repo/$component/centos/\$releasever/" \
|
__apt_key docker --keyid 58118E89F3A912897C070ADBF76221572C52609D --state ${state}
|
||||||
--enabled \
|
|
||||||
--gpgcheck \
|
|
||||||
--gpgkey 'https://yum.dockerproject.org/gpg'
|
|
||||||
__package docker-engine
|
|
||||||
unset CDIST_ORDER_DEPENDENCY
|
|
||||||
;;
|
|
||||||
ubuntu)
|
|
||||||
component="main"
|
|
||||||
if [ -f "$__object/parameter/experimental" ]; then
|
|
||||||
component="experimental"
|
|
||||||
fi
|
|
||||||
__package apparmor
|
|
||||||
__package ca-certificates
|
|
||||||
__package apt-transport-https
|
|
||||||
__apt_key docker --keyid 58118E89F3A912897C070ADBF76221572C52609D
|
|
||||||
export CDIST_ORDER_DEPENDENCY=on
|
export CDIST_ORDER_DEPENDENCY=on
|
||||||
__apt_source docker \
|
__apt_source docker \
|
||||||
--uri https://apt.dockerproject.org/repo \
|
--uri https://apt.dockerproject.org/repo \
|
||||||
--distribution "ubuntu-$(cat "$__global/explorer/lsb_codename")" \
|
--distribution "ubuntu-$(cat "$__global/explorer/lsb_codename")" \
|
||||||
|
--state ${state} \
|
||||||
--component "$component"
|
--component "$component"
|
||||||
__package docker-engine
|
__package docker-engine --state ${state}
|
||||||
unset CDIST_ORDER_DEPENDENCY
|
unset CDIST_ORDER_DEPENDENCY
|
||||||
;;
|
;;
|
||||||
debian)
|
debian)
|
||||||
|
@ -60,16 +61,17 @@ case "$os" in
|
||||||
component="experimental"
|
component="experimental"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
__package apt-transport-https
|
__package apt-transport-https --state ${state}
|
||||||
__package ca-certificates
|
__package ca-certificates --state ${state}
|
||||||
__package gnupg2
|
__package gnupg2 --state ${state}
|
||||||
__apt_key docker --keyid 58118E89F3A912897C070ADBF76221572C52609D
|
__apt_key docker --keyid 58118E89F3A912897C070ADBF76221572C52609D --state ${state}
|
||||||
export CDIST_ORDER_DEPENDENCY=on
|
export CDIST_ORDER_DEPENDENCY=on
|
||||||
__apt_source docker \
|
__apt_source docker \
|
||||||
--uri https://apt.dockerproject.org/repo \
|
--uri https://apt.dockerproject.org/repo \
|
||||||
--distribution "debian-$(cat "$__global/explorer/lsb_codename")" \
|
--distribution "debian-$(cat "$__global/explorer/lsb_codename")" \
|
||||||
|
--state ${state} \
|
||||||
--component "$component"
|
--component "$component"
|
||||||
__package docker-engine
|
__package docker-engine --state ${state}
|
||||||
unset CDIST_ORDER_DEPENDENCY
|
unset CDIST_ORDER_DEPENDENCY
|
||||||
|
|
||||||
;;
|
;;
|
||||||
|
|
1
cdist/conf/type/__docker/parameter/default/state
Normal file
1
cdist/conf/type/__docker/parameter/default/state
Normal file
|
@ -0,0 +1 @@
|
||||||
|
present
|
1
cdist/conf/type/__docker/parameter/optional
Normal file
1
cdist/conf/type/__docker/parameter/optional
Normal file
|
@ -0,0 +1 @@
|
||||||
|
state
|
|
@ -20,9 +20,12 @@
|
||||||
|
|
||||||
# Variables
|
# Variables
|
||||||
version="$(cat "$__object/parameter/version")"
|
version="$(cat "$__object/parameter/version")"
|
||||||
|
state="$(cat "$__object/parameter/state")"
|
||||||
|
|
||||||
# Download docker-compose file
|
if [ ${state} = "present" ]; then
|
||||||
echo 'curl -L "https://github.com/docker/compose/releases/download/'${version}'/docker-compose-$(uname -s)-$(uname -m)" -o /tmp/docker-compose'
|
# Download docker-compose file
|
||||||
echo 'mv /tmp/docker-compose /usr/local/bin/docker-compose'
|
echo 'curl -L "https://github.com/docker/compose/releases/download/'${version}'/docker-compose-$(uname -s)-$(uname -m)" -o /tmp/docker-compose'
|
||||||
# Change permissions
|
echo 'mv /tmp/docker-compose /usr/local/bin/docker-compose'
|
||||||
echo 'chmod +x /usr/local/bin/docker-compose'
|
# Change permissions
|
||||||
|
echo 'chmod +x /usr/local/bin/docker-compose'
|
||||||
|
fi
|
||||||
|
|
|
@ -19,6 +19,15 @@
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
|
|
||||||
|
state="$(cat "$__object/parameter/state")"
|
||||||
|
|
||||||
# Needed packages
|
# Needed packages
|
||||||
__docker
|
__docker --state ${state}
|
||||||
__package curl
|
__package curl
|
||||||
|
|
||||||
|
if [ ${state} = "absent" ]; then
|
||||||
|
__file /usr/local/bin/docker-compose --state absent
|
||||||
|
elif [ ${state} != "present" -a ${state} != "absent" ]; then
|
||||||
|
echo "Unknown state: $state_should" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
1
cdist/conf/type/__docker_compose/parameter/default/state
Normal file
1
cdist/conf/type/__docker_compose/parameter/default/state
Normal file
|
@ -0,0 +1 @@
|
||||||
|
present
|
|
@ -1 +1,2 @@
|
||||||
|
state
|
||||||
version
|
version
|
||||||
|
|
Loading…
Reference in a new issue