diff options
-rwxr-xr-x | hack/build-images.sh | 87 | ||||
-rwxr-xr-x | hack/push-release.sh | 55 | ||||
-rw-r--r-- | roles/openshift_excluder/defaults/main.yml | 2 | ||||
-rw-r--r-- | roles/openshift_excluder/tasks/init.yml | 4 |
4 files changed, 146 insertions, 2 deletions
diff --git a/hack/build-images.sh b/hack/build-images.sh new file mode 100755 index 000000000..f6210e239 --- /dev/null +++ b/hack/build-images.sh @@ -0,0 +1,87 @@ +#!/bin/bash + +set -o errexit +set -o nounset +set -o pipefail + +STARTTIME=$(date +%s) +source_root=$(dirname "${0}")/.. + +prefix="openshift/openshift-ansible" +version="latest" +verbose=false +options="" +help=false + +for args in "$@" +do + case $args in + --prefix=*) + prefix="${args#*=}" + ;; + --version=*) + version="${args#*=}" + ;; + --no-cache) + options="${options} --no-cache" + ;; + --verbose) + verbose=true + ;; + --help) + help=true + ;; + esac +done + +# allow ENV to take precedent over switches +prefix="${PREFIX:-$prefix}" +version="${OS_TAG:-$version}" + +if [ "$help" = true ]; then + echo "Builds the docker images for openshift-ansible" + echo + echo "Options: " + echo " --prefix=PREFIX" + echo " The prefix to use for the image names." + echo " default: openshift/openshift-ansible" + echo + echo " --version=VERSION" + echo " The version used to tag the image" + echo " default: latest" + echo + echo " --no-cache" + echo " If set will perform the build without a cache." + echo + echo " --verbose" + echo " Enables printing of the commands as they run." + echo + echo " --help" + echo " Prints this help message" + echo + exit 0 +fi + +if [ "$verbose" = true ]; then + set -x +fi + +BUILD_STARTTIME=$(date +%s) +comp_path=$source_root/ +docker_tag=${prefix}:${version} +echo +echo +echo "--- Building component '$comp_path' with docker tag '$docker_tag' ---" +docker build ${options} -t $docker_tag $comp_path +BUILD_ENDTIME=$(date +%s); echo "--- $docker_tag took $(($BUILD_ENDTIME - $BUILD_STARTTIME)) seconds ---" +echo +echo + +echo +echo +echo "++ Active images" +docker images | grep ${prefix} | grep ${version} | sort +echo + + +ret=$?; ENDTIME=$(date +%s); echo "$0 took $(($ENDTIME - $STARTTIME)) seconds"; exit "$ret" diff --git a/hack/push-release.sh b/hack/push-release.sh new file mode 100755 index 000000000..8639143af --- /dev/null +++ b/hack/push-release.sh @@ -0,0 +1,55 @@ +#!/bin/bash + +# This script pushes all of the built images to a registry. +# +# Set OS_PUSH_BASE_REGISTRY to prefix the destination images +# + +set -o errexit +set -o nounset +set -o pipefail + +STARTTIME=$(date +%s) +OS_ROOT=$(dirname "${BASH_SOURCE}")/.. + +PREFIX="${PREFIX:-openshift/openshift-ansible}" + +# Go to the top of the tree. +cd "${OS_ROOT}" + +# Allow a release to be repushed with a tag +tag="${OS_PUSH_TAG:-}" +if [[ -n "${tag}" ]]; then + tag=":${tag}" +else + tag=":latest" +fi + +# Source tag +source_tag="${OS_TAG:-}" +if [[ -z "${source_tag}" ]]; then + source_tag="latest" +fi + +images=( + ${PREFIX} +) + +PUSH_OPTS="" +if docker push --help | grep -q force; then + PUSH_OPTS="--force" +fi + +if [[ "${OS_PUSH_BASE_REGISTRY-}" != "" || "${tag}" != "" ]]; then + set -e + for image in "${images[@]}"; do + docker tag "${image}:${source_tag}" "${OS_PUSH_BASE_REGISTRY-}${image}${tag}" + done + set +e +fi + +for image in "${images[@]}"; do + docker push ${PUSH_OPTS} "${OS_PUSH_BASE_REGISTRY-}${image}${tag}" +done + +ret=$?; ENDTIME=$(date +%s); echo "$0 took $(($ENDTIME - $STARTTIME)) seconds"; exit "$ret" diff --git a/roles/openshift_excluder/defaults/main.yml b/roles/openshift_excluder/defaults/main.yml index 0d275e954..7c3ae2a86 100644 --- a/roles/openshift_excluder/defaults/main.yml +++ b/roles/openshift_excluder/defaults/main.yml @@ -2,3 +2,5 @@ # keep the 'current' package or update to 'latest' if available? openshift_excluder_package_state: present docker_excluder_package_state: present + +enable_excluders: true diff --git a/roles/openshift_excluder/tasks/init.yml b/roles/openshift_excluder/tasks/init.yml index dee779925..1ea18f363 100644 --- a/roles/openshift_excluder/tasks/init.yml +++ b/roles/openshift_excluder/tasks/init.yml @@ -1,12 +1,12 @@ --- - name: Evalute if docker excluder is to be enabled set_fact: - docker_excluder_on: "{{ enable_docker_excluder | default(enable_excluders | default(false)) | bool }}" + docker_excluder_on: "{{ enable_docker_excluder | default(enable_excluders) | bool }}" - debug: var=docker_excluder_on - name: Evalute if openshift excluder is to be enabled set_fact: - openshift_excluder_on: "{{ enable_openshift_excluder | default(enable_excluders | default(false)) | bool }}" + openshift_excluder_on: "{{ enable_openshift_excluder | default(enable_excluders) | bool }}" - debug: var=openshift_excluder_on |