Merge pull request #510 from greendeath/f/docker_absent

F/docker absent
This commit is contained in:
Darko Poljak 2017-01-06 22:06:27 +01:00 committed by GitHub
commit f9d1d2abb3
9 changed files with 69 additions and 35 deletions

View file

@ -26,17 +26,24 @@ BOOLEAN PARAMETERS
experimental experimental
Install the experimental docker-engine package instead of the latest stable release. Install the experimental docker-engine package instead of the latest stable release.
state
'present' or 'absent', defaults to 'present'
EXAMPLES EXAMPLES
-------- --------
.. code-block:: sh .. code-block:: sh
# Install docker
__docker __docker
# experimental # Install experimental
__docker --experimental __docker --experimental
# Remove docker
__docker --state absent
AUTHORS AUTHORS
------- -------

View file

@ -20,6 +20,7 @@
os=$(cat "$__global/explorer/os") os=$(cat "$__global/explorer/os")
state=$(cat "$__object/parameter/state")
case "$os" in case "$os" in
centos) centos)
@ -27,31 +28,31 @@ case "$os" in
if [ -f "$__object/parameter/experimental" ]; then if [ -f "$__object/parameter/experimental" ]; then
component="experimental" component="experimental"
fi fi
export CDIST_ORDER_DEPENDENCY=on
__yum_repo docker \ __yum_repo docker \
--name 'Docker Repository' \ --name 'Docker Repository' \
--baseurl "https://yum.dockerproject.org/repo/$component/centos/\$releasever/" \ --baseurl "https://yum.dockerproject.org/repo/$component/centos/\$releasever/" \
--enabled \ --enabled \
--gpgcheck \ --gpgcheck 1 \
--gpgkey 'https://yum.dockerproject.org/gpg' --gpgkey 'https://yum.dockerproject.org/gpg' \
__package docker-engine --state ${state}
unset CDIST_ORDER_DEPENDENCY require="__yum_repo/docker" __package docker-engine --state ${state}
;; ;;
ubuntu) ubuntu)
component="main" component="main"
if [ -f "$__object/parameter/experimental" ]; then if [ -f "$__object/parameter/experimental" ]; then
component="experimental" component="experimental"
fi fi
__package apparmor __package apparmor --state ${state}
__package ca-certificates __package ca-certificates --state ${state}
__package apt-transport-https __package apt-transport-https --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 "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
;; ;;

View file

@ -0,0 +1 @@
present

View file

@ -0,0 +1 @@
state

View file

@ -20,9 +20,12 @@
# Variables # Variables
version="$(cat "$__object/parameter/version")" version="$(cat "$__object/parameter/version")"
state="$(cat "$__object/parameter/state")"
if [ ${state} = "present" ]; then
# Download docker-compose file # Download docker-compose file
echo 'curl -L "https://github.com/docker/compose/releases/download/'${version}'/docker-compose-$(uname -s)-$(uname -m)" -o /tmp/docker-compose' echo 'curl -L "https://github.com/docker/compose/releases/download/'${version}'/docker-compose-$(uname -s)-$(uname -m)" -o /tmp/docker-compose'
echo 'mv /tmp/docker-compose /usr/local/bin/docker-compose' echo 'mv /tmp/docker-compose /usr/local/bin/docker-compose'
# Change permissions # Change permissions
echo 'chmod +x /usr/local/bin/docker-compose' echo 'chmod +x /usr/local/bin/docker-compose'
fi

View file

@ -9,6 +9,8 @@ cdist-type__docker_compose - install docker-compose
DESCRIPTION DESCRIPTION
----------- -----------
Installs docker-compose package. Installs docker-compose package.
State 'absent' will not remove docker binary itself,
only docker-compose binary will be removed
REQUIRED PARAMETERS REQUIRED PARAMETERS
@ -21,6 +23,9 @@ OPTIONAL PARAMETERS
version version
Define docker_compose version, defaults to "1.9.0" Define docker_compose version, defaults to "1.9.0"
state
'present' or 'absent', defaults to 'present'
BOOLEAN PARAMETERS BOOLEAN PARAMETERS
------------------ ------------------
@ -32,11 +37,15 @@ EXAMPLES
.. code-block:: sh .. code-block:: sh
# Install docker-compose
__docker_compose __docker_compose
# Install version 1.9.0-rc4 # Install version 1.9.0-rc4
__docker_compose --version 1.9.0-rc4 __docker_compose --version 1.9.0-rc4
# Remove docker-compose
__docker_compose --state absent
AUTHORS AUTHORS
------- -------

View file

@ -19,6 +19,15 @@
# #
# #
state="$(cat "$__object/parameter/state")"
# Needed packages # Needed packages
if [ ${state} = "present" ]; then
__docker __docker
__package curl __package curl
elif [ ${state} = "absent" ]; then
__file /usr/local/bin/docker-compose --state absent
else
echo "Unknown state: ${state}" >&2
exit 1
fi

View file

@ -0,0 +1 @@
present

View file

@ -1 +1,2 @@
state
version version