Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 28 additions & 52 deletions Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ ARG DNF_TO_REMOVE="dejavu-sans-fonts langpacks-core-font-en langpacks-core-en la
ARG RPM_TO_FORCEFULLY_REMOVE="cracklib-dicts"
# Versions
ARG OPENSHIFT_CLIENT_VERSION="4.20.14"
ARG HYPERSHIFT_VERSION="2.7.2-1"
ARG HELM_VERSION="3.19.5"
ARG ARGOCD_VERSION="3.1.12"
ARG TKN_CLI_VERSION="0.35.2"
ARG YQ_VERSION="4.40.7"
ARG TEA_VERSION="0.9.2"
ARG SOPS_VERSION="3.11.0"
Expand All @@ -53,41 +50,15 @@ ARG EXTRARPMS

USER root

ENV HELM_PLUGINS=/etc/helm-plugins

ADD https://cli.github.com/packages/rpm/gh-cli.repo /etc/yum.repos.d/gh-cli.repo

# 'pip' is expected to be the pip resolved by 'python3 pip' AKA the one we install with PYTHON_VERSION
RUN microdnf --disableplugin=subscription-manager install -y ${PYTHON_PKGS} && microdnf --disableplugin=subscription-manager clean all
RUN alternatives --install /usr/bin/python3 python3 /usr/bin/python${PYTHON_VERSION} 0

# Add requirements.yml file for ansible collections
COPY requirements.yml /tmp/requirements.yml

RUN microdnf --disableplugin=subscription-manager install -y make git-core tar vi jq which findutils diffutils sshpass gzip gh $EXTRARPMS && \
microdnf remove -y $DNF_TO_REMOVE && \
rpm -e --nodeps $RPM_TO_FORCEFULLY_REMOVE && \
microdnf clean all && \
rm -rf /var/cache/dnf && \
curl -sSfL https://github.com/argoproj/argo-cd/releases/download/v${ARGOCD_VERSION}/argocd-linux-${TARGETARCH} -o /usr/local/bin/argocd && \
curl -sSfL https://get.helm.sh/helm-v${HELM_VERSION}-linux-${TARGETARCH}.tar.gz | tar xzf - --strip-components=1 -C /usr/local/bin linux-${TARGETARCH}/helm && \
curl -sSfL https://github.com/tektoncd/cli/releases/download/v${TKN_CLI_VERSION}/tkn_${TKN_CLI_VERSION}_Linux_${ALTTARGETARCH}.tar.gz | tar xzf - -C /usr/local/bin tkn && \
curl -sSfL https://developers.redhat.com/content-gateway/file/pub/mce/clients/hcp-cli/${HYPERSHIFT_VERSION}/hcp-cli-${HYPERSHIFT_VERSION}-linux-${TARGETARCH}.tar.gz | tar xzf - -C /usr/local/bin ./hcp && \
curl -sSfL https://mirror.openshift.com/pub/openshift-v4/clients/ocp/${OPENSHIFT_CLIENT_VERSION}/openshift-client-linux-${OPTTARGETARCH}${OPENSHIFT_CLIENT_VERSION}.tar.gz | tar xzf - -C /usr/local/bin oc && ln -sf /usr/local/bin/oc /usr/local/bin/kubectl && \
curl -sSfL https://github.com/mikefarah/yq/releases/download/v${YQ_VERSION}/yq_linux_${TARGETARCH} -o /usr/local/bin/yq && \
curl -sSfL https://gitea.com/gitea/tea/releases/download/v${TEA_VERSION}/tea-${TEA_VERSION}-linux-${TARGETARCH} -o /usr/local/bin/tea && \
curl -sSfL https://github.com/getsops/sops/releases/download/v${SOPS_VERSION}/sops-v${SOPS_VERSION}.linux.${TARGETARCH} -o /usr/local/bin/sops && \
curl -sSfL https://github.com/FiloSottile/age/releases/download/v${AGE_VERSION}/age-v${AGE_VERSION}-linux-${TARGETARCH}.tar.gz | tar xzf - --strip-components=1 -C /usr/local/bin age/age* && \
mkdir -p "${HELM_PLUGINS}" && \
curl -sSfL https://github.com/jkroepke/helm-secrets/releases/download/v${HELM_SECRETS_VERSION}/helm-secrets.tar.gz | tar xzf - -C "${HELM_PLUGINS}" && \
chown root:root /usr/local/bin/* && chmod 755 /usr/local/bin/* && \
rm -rf /root/anaconda* /root/original-ks.cfg /usr/local/README
COPY requirements.yml requirements.txt ansible-playbook-wrapper.sh /tmp/
COPY default-cmd.sh /usr/local/bin

# The hypershift cli is downloaded directly from the cluster.
# This could change when HCP goes GA - the alternative would
# be to compile our own, so this seemed the logical choice.
# Adding python scripts to start, stop and retrieve status of hostedcluster instances
ADD --chmod=755 https://raw.githubusercontent.com/validatedpatterns/utilities/main/aws-tools/start-instances.py \
https://raw.githubusercontent.com/validatedpatterns/utilities/main/aws-tools/stop-instances.py \
https://raw.githubusercontent.com/validatedpatterns/utilities/main/aws-tools/status-instances.py /usr/local/bin/

# humanize is only needed for the trimming of the container
# See https://github.com/Azure/azure-sdk-for-python/issues/11149
# and https://github.com/Azure/azure-sdk-for-python/issues/17801
# The size of the azure sdk is ridiculous because they keep old (and unused
Expand All @@ -111,33 +82,38 @@ ENV ANSIBLE_LOCAL_TMP=/pattern-home/.ansible/tmp
ENV ANSIBLE_LOCALHOST_WARNING=False
ENV PIP_BREAK_SYSTEM_PACKAGES=1

# Add requirements.yml file for ansible collections
COPY requirements.yml /tmp/requirements.yml
COPY requirements.txt /tmp/requirements.txt
COPY ansible-playbook-wrapper.sh /tmp/ansible-playbook-wrapper.sh
ENV HELM_PLUGINS=/etc/helm-plugins

RUN pip install --no-cache-dir -r /tmp/requirements.txt && \
RUN microdnf --disableplugin=subscription-manager install -y make git-core tar vi jq which findutils diffutils sshpass gzip ${PYTHON_PKGS} $EXTRARPMS && \
microdnf remove -y $DNF_TO_REMOVE && \
rpm -e --nodeps $RPM_TO_FORCEFULLY_REMOVE && \
microdnf clean all && \
rm -rf /var/cache/dnf && \
alternatives --install /usr/bin/python3 python3 /usr/bin/python${PYTHON_VERSION} 0 && \
curl -sSfL https://get.helm.sh/helm-v${HELM_VERSION}-linux-${TARGETARCH}.tar.gz | tar xzf - --strip-components=1 -C /usr/local/bin linux-${TARGETARCH}/helm && \
curl -sSfL https://mirror.openshift.com/pub/openshift-v4/clients/ocp/${OPENSHIFT_CLIENT_VERSION}/openshift-client-linux-${OPTTARGETARCH}${OPENSHIFT_CLIENT_VERSION}.tar.gz | tar xzf - -C /usr/local/bin oc && ln -sf /usr/local/bin/oc /usr/local/bin/kubectl && \
curl -sSfL https://github.com/mikefarah/yq/releases/download/v${YQ_VERSION}/yq_linux_${TARGETARCH} -o /usr/local/bin/yq && \
curl -sSfL https://gitea.com/gitea/tea/releases/download/v${TEA_VERSION}/tea-${TEA_VERSION}-linux-${TARGETARCH} -o /usr/local/bin/tea && \
curl -sSfL https://github.com/getsops/sops/releases/download/v${SOPS_VERSION}/sops-v${SOPS_VERSION}.linux.${TARGETARCH} -o /usr/local/bin/sops && \
curl -sSfL https://github.com/FiloSottile/age/releases/download/v${AGE_VERSION}/age-v${AGE_VERSION}-linux-${TARGETARCH}.tar.gz | tar xzf - --strip-components=1 -C /usr/local/bin age/age* && \
mkdir -p "${HELM_PLUGINS}" && \
curl -sSfL https://github.com/jkroepke/helm-secrets/releases/download/v${HELM_SECRETS_VERSION}/helm-secrets.tar.gz | tar xzf - -C "${HELM_PLUGINS}" && \
chown root:root /usr/local/bin/* && chmod 755 /usr/local/bin/* && \
rm -rf /root/anaconda* /root/original-ks.cfg /usr/local/README && \
pip install --no-cache-dir --no-compile -r /tmp/requirements.txt && \
ansible-galaxy collection install --collections-path /usr/share/ansible/collections -r /tmp/requirements.yml && \
# Create ansible-playbook wrapper that sets ANSIBLE_STDOUT_CALLBACK to rhvp.cluster_utils.readable when it's "null" \
mv /usr/local/bin/ansible-playbook /usr/local/bin/ansible-playbook.orig && \
cp /tmp/ansible-playbook-wrapper.sh /usr/local/bin/ansible-playbook && \
mv /tmp/ansible-playbook-wrapper.sh /usr/local/bin/ansible-playbook && \
chmod +x /usr/local/bin/ansible-playbook && \
rm -rf /usr/local/lib/python${PYTHON_VERSION}/site-packages/ansible_collections/$COLLECTIONS_TO_REMOVE && \
curl -sSfL -O https://raw.githubusercontent.com/clumio-code/azure-sdk-trim/main/azure_sdk_trim/azure_sdk_trim.py && \
python3 azure_sdk_trim.py && rm azure_sdk_trim.py && pip uninstall -y humanize && \
pip install --no-cache-dir --no-compile azure-sdk-trim && \
azure-sdk-trim && pip uninstall -y azure-sdk-trim && \
rm -rf /usr/share/doc /usr/share/man && \
if [ -n "$EXTRARPMS" ]; then microdnf remove -y $EXTRARPMS; fi && \
mkdir -p /pattern/.ansible/tmp /pattern-home/.ansible/tmp && \
find /pattern/.ansible -type d -exec chmod 770 "{}" \; && \
find /pattern-home/.ansible -type d -exec chmod 770 "{}" \;


# Adding python scripts to start, stop and retrieve status of hostedcluster instances
ADD https://raw.githubusercontent.com/validatedpatterns/utilities/main/aws-tools/start-instances.py \
https://raw.githubusercontent.com/validatedpatterns/utilities/main/aws-tools/stop-instances.py \
https://raw.githubusercontent.com/validatedpatterns/utilities/main/aws-tools/status-instances.py /usr/local/bin/

RUN chmod 755 /usr/local/bin/start-instances.py /usr/local/bin/stop-instances.py /usr/local/bin/status-instances.py

COPY default-cmd.sh /usr/local/bin
WORKDIR /pattern
CMD ["/usr/local/bin/default-cmd.sh"]
18 changes: 0 additions & 18 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,11 @@ CONTAINER ?= $(NAME):$(TAG)
REGISTRY ?= localhost
UPLOADREGISTRY ?= quay.io/validatedpatterns
TESTCOMMAND := "set -e; echo '* Helm: '; helm version; \
echo '* ArgoCD: '; argocd version --client ; \
echo '* Tekton: '; tkn version ; \
echo '* oc: '; oc version ; \
echo '* yq: '; yq --version ; \
echo '* gh: '; gh version ; \
echo '* Python: '; python --version ; \
echo '* Ansible: '; ansible --version ; \
echo '* kubernetes.core: '; ansible-galaxy collection list | grep kubernetes.core ; \
echo '* redhat_cop.controller_configuration: '; ansible-galaxy collection list | grep redhat_cop.controller_configuration ; \
echo '* infra.controller_configuration: '; ansible-galaxy collection list | grep infra.controller_configuration ; \
echo '* infra.eda_configuration: '; ansible-galaxy collection list | grep infra.eda_configuration ; \
echo '* infra.ah_configuration: '; ansible-galaxy collection list | grep infra.ah_configuration ; \
echo '* awx.awx: '; ansible-galaxy collection list | grep awx.awx ; \
echo '* community.general: '; ansible-galaxy collection list | grep community.general ; \
echo '* ansible.posix: '; ansible-galaxy collection list | grep ansible.posix ; \
echo '* ansible.utils: '; ansible-galaxy collection list | grep ansible.utils ; \
Expand Down Expand Up @@ -101,16 +93,12 @@ versions: ## Print all the versions of software in the locally-built container
echo -n \"|make package \"; rpm -q --qf '%{VERSION}' make; echo \" \"; \
echo -n \"|python package \"; /usr/bin/python3 --version | sed -e s'/Python //' | tr -d '\n'; echo \" \"; \
echo -n \"|jq package \"; rpm -q --qf '%{VERSION}' jq; echo \" \"; \
echo -n \"|gh package \"; rpm -q --qf '%{VERSION}' gh; echo \" \"; \
echo -n \"|age binary \"; age --version |tr -d '\n'; echo \" \"; \
echo -n \"|argocd binary \"; argocd version --client -o json | jq -j '.client.Version'; echo \" \"; \
echo -n \"|helm binary \"; helm version --template '{{ .Version }}'; echo \" \"; \
echo -n \"|helmsecrets binary \"; helm plugin list |grep ^secrets | tr '[:blank:]' ' '| cut -f2 -d\ | tr -d '\n'; echo \" \"; \
echo -n \"|tea binary \"; tea --version | sed -e 's/Version: //' | sed -e 's/golang.*//' | tr -d '\t' | tr -d '\n'; echo \" \"; \
echo -n \"|tekton binary \"; tkn version --component client | tr -d '\n'; echo \" \"; \
echo -n \"|openshift binary \"; oc version --client -o json | jq -j '.releaseClientVersion'; echo \" \"; \
echo -n \"|kustomize binary \"; oc version --client -o json | jq -j '.kustomizeVersion'; echo \" \"; \
echo -n \"|hcp binary \"; hcp version --client-only | cut -f4 -d: | tr -d '\n'; echo \" \"; \
echo -n \"|pytest pip \"; pip show pytest | grep ^Version | cut -f2 -d\ |tr -d '\n'; echo \" \"; \
echo -n \"|ansible pip \"; ansible --version -o json | grep core | cut -f3 -d\ | tr -d '\n]'; echo \" \"; \
echo -n \"|kubernetes pip \"; pip show kubernetes |grep ^Version: | cut -f2 -d\ | tr -d '\n'; echo \" \"; \
Expand All @@ -119,21 +107,15 @@ versions: ## Print all the versions of software in the locally-built container
echo -n \"|awscli pip \"; pip show awscli | grep ^Version: | cut -f2 -d\ |tr -d '\n'; echo \" \"; \
echo -n \"|azure-cli pip \"; pip show azure-cli | grep ^Version: | cut -f2 -d\ | tr -d '\n'; echo \" \"; \
echo -n \"|gcloud pip \"; pip show gcloud| grep ^Version: | cut -f2 -d\ |tr -d '\n'; echo \" \"; \
echo -n \"|awxkit pip \"; pip show awxkit| grep ^Version: | cut -f2 -d\ |tr -d '\n'; echo \" \"; \
echo -n \"|jmespath pip \"; pip show jmespath| grep ^Version: | cut -f2 -d\ |tr -d '\n'; echo \" \"; \
echo -n \"|ansible-runner pip \"; pip show ansible-runner| grep ^Version: | cut -f2 -d\ |tr -d '\n'; echo \" \"; \
echo -n \"|vp-qe-test-common pip \"; pip show vp-qe-test-common | grep ^Version: | cut -f2 -d\ | tr -d '\n'; echo \" \"; \
echo -n \"|kubernetes.core collection \"; ansible-galaxy collection list kubernetes.core |grep ^kubernetes.core | cut -f2 -d\ |tr -d '\n'; echo \" \"; \
echo -n \"|community.okd collection \"; ansible-galaxy collection list community.okd |grep ^community.okd | cut -f2 -d\ |tr -d '\n'; echo \" \"; \
echo -n \"|community.general collection \"; ansible-galaxy collection list community.general |grep ^community.general | cut -f2 -d\ |tr -d '\n'; echo \" \"; \
echo -n \"|awx.awx collection \"; ansible-galaxy collection list awx.awx |grep ^awx.awx | tr -s ' ' | cut -f2 -d ' ' |tr -d '\n'; echo \" \"; \
echo -n \"|ansible.posix collection \"; ansible-galaxy collection list ansible.posix |grep ^ansible.posix | cut -f2 -d\ |tr -d '\n'; echo \" \"; \
echo -n \"|ansible.utils collection \"; ansible-galaxy collection list ansible.utils |grep ^ansible.utils | cut -f2 -d\ |tr -d '\n'; echo \" \"; \
echo -n \"|rhvp.cluster_utils collection \"; ansible-galaxy collection list rhvp.cluster_utils |grep ^rhvp.cluster_utils | cut -f2 -d\ |tr -d '\n'; echo \" \"; \
echo -n \"|redhat_cop.controller_configuration collection \"; ansible-galaxy collection list redhat_cop.controller_configuration |grep ^redhat_cop.controller_configuration | cut -f2 -d\ | tr -d '\n'; echo \" \"; \
echo -n \"|infra.controller_configuration collection \"; ansible-galaxy collection list infra.controller_configuration |grep ^infra.controller_configuration | cut -f2 -d\ | tr -d '\n'; echo \" \"; \
echo -n \"|infra.eda_configuration collection \"; ansible-galaxy collection list infra.eda_configuration |grep ^infra.eda_configuration | cut -f2 -d\ | tr -d '\n'; echo \" \"; \
echo -n \"|infra.ah_configuration collection \"; ansible-galaxy collection list infra.ah_configuration |grep ^infra.ah_configuration | cut -f2 -d\ | tr -d '\n'; echo \" \"; \
" | sort | column --table -o '|'

.PHONY: run
Expand Down
4 changes: 0 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
ansible-core==2.18.*
ansible-runner
awxkit
kubernetes
openshift
boto3>=1.21
botocore>=1.24
awscli>=1.22
azure-cli>=2.34
gcloud
humanize
pytz
pytest
junitparser
vp-qe-test-common @ git+https://github.com/validatedpatterns/vp-qe-test-common.git@v1#egg=vp-qe-test-common
10 changes: 4 additions & 6 deletions requirements.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,9 @@ collections:
- name: ansible.utils
- name: kubernetes.core
- name: community.okd
- name: redhat_cop.controller_configuration
- name: infra.controller_configuration
- name: infra.eda_configuration
- name: infra.ah_configuration
- name: community.general
- name: awx.awx
- name: amazon.aws
- name: git+https://github.com/validatedpatterns/rhvp.cluster_utils.git,v1
- name: rhvp.cluster_utils
source: https://github.com/validatedpatterns/rhvp.cluster_utils.git
type: git
version: v1