From a7f4c8d7736f961a654f93340439da92ccb1bd7f Mon Sep 17 00:00:00 2001 From: Jonas Weber Date: Thu, 13 Dec 2018 13:23:49 +0100 Subject: [PATCH 1/2] Allow installing specific Docker-CE version --- cdist/conf/type/__docker/man.rst | 5 +++++ cdist/conf/type/__docker/manifest | 13 +++++++++++-- cdist/conf/type/__docker/parameter/default/version | 1 + cdist/conf/type/__docker/parameter/optional | 1 + 4 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 cdist/conf/type/__docker/parameter/default/version diff --git a/cdist/conf/type/__docker/man.rst b/cdist/conf/type/__docker/man.rst index 5cb28ee1..718543a8 100644 --- a/cdist/conf/type/__docker/man.rst +++ b/cdist/conf/type/__docker/man.rst @@ -20,6 +20,9 @@ OPTIONAL PARAMETERS ------------------- state 'present' or 'absent', defaults to 'present' +version + The specific version to install. Defaults to the special value 'latest', + meaning the version the package manager will install by default. BOOLEAN PARAMETERS @@ -38,6 +41,8 @@ EXAMPLES # Remove docker __docker --state absent + # Install specific version + __docker --state present --version 18.03.0.ce AUTHORS ------- diff --git a/cdist/conf/type/__docker/manifest b/cdist/conf/type/__docker/manifest index 8f26feec..a893ea15 100755 --- a/cdist/conf/type/__docker/manifest +++ b/cdist/conf/type/__docker/manifest @@ -21,6 +21,7 @@ os=$(cat "$__global/explorer/os") state=$(cat "$__object/parameter/state") +version=$(cat "$__object/parameter/version") case "$os" in centos) @@ -33,7 +34,11 @@ case "$os" in --gpgcheck 1 \ --gpgkey 'https://download.docker.com/linux/centos/gpg' \ --state "${state}" - require="__yum_repo/docker-ce-stable" __package docker-ce --state "${state}" + if [ "$version" != "latest" ]; then + require="__yum_repo/docker-ce-stable" __package docker-ce --version "${version}" --state "${state}" + else + require="__yum_repo/docker-ce-stable" __package docker-ce --state "${state}" + fi else echo "CentOS version 7 is required!" >&2 exit 1 @@ -53,7 +58,11 @@ case "$os" in --distribution "$(cat "$__global/explorer/lsb_codename")" \ --state "${state}" \ --component "stable" - __package docker-ce --state "${state}" + if [ "$version" != "latest" ]; then + __package docker-ce --version "${version}" --state "${state}" + else + __package docker-ce --state "${state}" + fi unset CDIST_ORDER_DEPENDENCY ;; *) diff --git a/cdist/conf/type/__docker/parameter/default/version b/cdist/conf/type/__docker/parameter/default/version new file mode 100644 index 00000000..a0f9a4b4 --- /dev/null +++ b/cdist/conf/type/__docker/parameter/default/version @@ -0,0 +1 @@ +latest diff --git a/cdist/conf/type/__docker/parameter/optional b/cdist/conf/type/__docker/parameter/optional index ff72b5c7..4d595ed7 100644 --- a/cdist/conf/type/__docker/parameter/optional +++ b/cdist/conf/type/__docker/parameter/optional @@ -1 +1,2 @@ state +version From d4bb114468dcd8ea1483edfe20609d2179037f93 Mon Sep 17 00:00:00 2001 From: Jonas Weber Date: Thu, 13 Dec 2018 13:26:40 +0100 Subject: [PATCH 2/2] Remove usage of CDIST_ORDER_DEPENDENCY --- cdist/conf/type/__docker/manifest | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/cdist/conf/type/__docker/manifest b/cdist/conf/type/__docker/manifest index a893ea15..04a9ff27 100755 --- a/cdist/conf/type/__docker/manifest +++ b/cdist/conf/type/__docker/manifest @@ -52,18 +52,17 @@ case "$os" in fi __apt_key_uri docker --name "Docker Release (CE deb) " \ --uri "https://download.docker.com/linux/${os}/gpg" --state "${state}" - export CDIST_ORDER_DEPENDENCY=on - __apt_source docker \ + + require="__apt_key_uri/docker" __apt_source docker \ --uri "https://download.docker.com/linux/${os}" \ --distribution "$(cat "$__global/explorer/lsb_codename")" \ --state "${state}" \ --component "stable" if [ "$version" != "latest" ]; then - __package docker-ce --version "${version}" --state "${state}" + require="__apt_source/docker" __package docker-ce --version "${version}" --state "${state}" else - __package docker-ce --state "${state}" + require="__apt_source/docker" __package docker-ce --state "${state}" fi - unset CDIST_ORDER_DEPENDENCY ;; *) echo "Your operating system ($os) is currently not supported by this type (${__type##*/})." >&2