Skip to content

Commit

Permalink
Initial ansible proof of concept
Browse files Browse the repository at this point in the history
  • Loading branch information
ventifus committed Jun 11, 2024
1 parent 24f43d8 commit 9e35cd3
Show file tree
Hide file tree
Showing 94 changed files with 635 additions and 1 deletion.
44 changes: 44 additions & 0 deletions Dockerfile.smoketest
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
ARG REGISTRY
ARG VERSION

###############################################################################
# final is our slim image with minimal layers and tools
###############################################################################
# FROM ${REGISTRY}/ubi9/python-312:1-10
FROM ${REGISTRY}/ubi9/python-311:1-62 AS final
ARG PIPX_VERSION=1.5.0 \
ANSIBLE_VERSION=9.5.1 \
AZURE_CLI_VERSION=2.60.0 \
ANSIBLE_AZCOLLECTION_VERSION=2.3.0

# Cause Ansible to print task timing information
ENV ANSIBLE_CALLBACKS_ENABLED=profile_tasks
USER root
WORKDIR /smoketest

COPY smoketest /smoketest

# Using pipx here because ansible and azure-cli have differing required core Azure modules
# They each need a separate venv to avoid collisions
RUN ${APP_ROOT}/bin/pip install "pipx==${PIPX_VERSION}" && \
${APP_ROOT}/bin/pipx install "azure-cli==${AZURE_CLI_VERSION}" && \
${APP_ROOT}/bin/pipx install "ansible==${ANSIBLE_VERSION}" --include-deps && \
${APP_ROOT}/bin/pipx runpip ansible install -r "/smoketest/ansible-requirements.txt" && \
${HOME}/.local/bin/ansible-galaxy collection install "azure.azcollection==${ANSIBLE_AZCOLLECTION_VERSION}" && \
${APP_ROOT}/bin/pipx runpip ansible install -r "${HOME}/.ansible/collections/ansible_collections/azure/azcollection/requirements-azure.txt" && \
${APP_ROOT}/bin/pipx list

###############################################################################
# linter takes the final image and injects ansible-lint. Ansible-lint needs
# ansible itself and all ansible modules and python modules installed to correctly lint
###############################################################################
FROM final AS linter
RUN ${APP_ROOT}/bin/pipx inject ansible --include-apps ansible-lint && \
${HOME}/.local/bin/ansible-lint -v -c /smoketest/.ansible_lint.yaml --project-dir /smoketest --format sarif | tee /smoketest/sarif.txt

###############################################################################
# Re-FROM final so that it's the output container
###############################################################################
FROM final
COPY --from=linter /smoketest/sarif.txt /sarif.txt
ENTRYPOINT ["/opt/app-root/src/.local/bin/ansible-playbook"]
26 changes: 25 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ ARO_IMAGE_BASE = ${RP_IMAGE_ACR}.azurecr.io/aro
E2E_FLAGS ?= -test.v --ginkgo.v --ginkgo.timeout 180m --ginkgo.flake-attempts=2 --ginkgo.junit-report=e2e-report.xml
GO_FLAGS ?= -tags=containers_image_openpgp,exclude_graphdriver_btrfs,exclude_graphdriver_devicemapper
NO_CACHE ?= true
PODMAN_VOLUME_OVERLAY=$(shell if [[ $$(getenforce) == "Enforcing" ]]; then echo ":O"; else echo ""; fi 2>/dev/null)

export GOFLAGS=$(GO_FLAGS)

Expand Down Expand Up @@ -282,4 +283,27 @@ vendor:
install-go-tools:
go install ${GOTESTSUM}

.PHONY: admin.kubeconfig aks.kubeconfig aro az ci-portal ci-rp clean client deploy dev-config.yaml discoverycache fix-macos-vendor generate image-aro-multistage image-fluentbit image-proxy init-contrib lint-go runlocal-rp proxy publish-image-aro-multistage publish-image-fluentbit publish-image-proxy secrets secrets-update e2e.test tunnel test-e2e test-go test-python vendor build-all validate-go unit-test-go coverage-go validate-fips install-go-tools
smoketest-image:
# IMAGE_EXISTS = $(shell podman image exists aro-smoketest:$(VERSION))
docker image exists aro-smoketest:$(VERSION) || docker build . -f Dockerfile.smoketest --build-arg REGISTRY=$(REGISTRY) --build-arg VERSION=$(VERSION) --no-cache=$(NO_CACHE) --tag aro-smoketest:$(VERSION)

REGION := eastus
CLUSTERPREFIX := smoketest
CLUSTERPATTERN := smoketest-basic*
CLEANUP := True
# Delete the cluster after success unless it's disabled with `make smoketest CLEANUP=False`
ifeq ($(CLEANUP),False)
CLEANUP_ARG = -e CLEANUP=False
else
CLEANUP_ARG =
endif
smoketest: smoketest-image
docker run --rm -t -v $${AZURE_CONFIG_DIR:-~/.azure}:/opt/app-root/src/.azure$(PODMAN_VOLUME_OVERLAY) aro-smoketest:$(VERSION) -i regions/$(REGION) -l $(CLUSTERPATTERN) -e CLUSTERPREFIX=$(CLUSTERPREFIX) $(CLEANUP_ARG) smoketest.yaml

smoketest-dev: smoketest-image
docker run --rm -it -v $${AZURE_CONFIG_DIR:-~/.azure}:/opt/app-root/src/.azure$(PODMAN_VOLUME_OVERLAY) -v ./smoketest:/smoketest$(PODMAN_VOLUME_OVERLAY) aro-smoketest:$(VERSION) -i regions/$(REGION) -l $(CLUSTERPATTERN) -e CLUSTERPREFIX=$(CLUSTERPREFIX) $(CLEANUP_ARG) smoketest.yaml

lint-ansible:
cd smoketest; ansible-lint -c .ansible_lint.yaml

.PHONY: admin.kubeconfig aks.kubeconfig build-all build-portal check-release ci-portal clean deploy dev-config.yaml discoverycache e2e.test e2etools extract-aro-docker fix-macos-vendor generate generate-guardrails generate-kiota generate-operator-apiclient image-aro-multistage image-autorest image-e2e image-fluentbit image-gatekeeper image-proxy init-contrib install-go-tools lint-admin-portal lint-ansible lint-go proxy pyenv runlocal-rp run-portal secrets secrets-update shared-cluster-create shared-cluster-delete shared-cluster-login smoketest-image tunnel unit-test-go unit-test-go-coverpkg unit-test-python validate-fips validate-go validate-go-action vendor
10 changes: 10 additions & 0 deletions smoketest/.ansible_lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
profile: production
exclude_paths: []
use_default_rules: true
skip_list:
- no-changed-when
enable_list:
- args
- empty-string-compare
- no-same-owner
- name[prefix]
1 change: 1 addition & 0 deletions smoketest/ansible-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
kubernetes==29.0.0
1 change: 1 addition & 0 deletions smoketest/regions/australiacentral/group_vars/all.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
location: australiacentral
1 change: 1 addition & 0 deletions smoketest/regions/australiacentral/hosts.yaml
1 change: 1 addition & 0 deletions smoketest/regions/australiacentral2/group_vars/all.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
location: australiacentral2
1 change: 1 addition & 0 deletions smoketest/regions/australiacentral2/hosts.yaml
1 change: 1 addition & 0 deletions smoketest/regions/australiaeast/group_vars/all.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
location: australiaeast
1 change: 1 addition & 0 deletions smoketest/regions/australiaeast/hosts.yaml
1 change: 1 addition & 0 deletions smoketest/regions/australiasoutheast/group_vars/all.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
location: australiasoutheast
1 change: 1 addition & 0 deletions smoketest/regions/australiasoutheast/hosts.yaml
1 change: 1 addition & 0 deletions smoketest/regions/brazilsouth/group_vars/all.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
location: brazilsouth
1 change: 1 addition & 0 deletions smoketest/regions/brazilsouth/hosts.yaml
1 change: 1 addition & 0 deletions smoketest/regions/brazilsoutheast/group_vars/all.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
location: brazilsoutheast
1 change: 1 addition & 0 deletions smoketest/regions/brazilsoutheast/hosts.yaml
1 change: 1 addition & 0 deletions smoketest/regions/canadacentral/group_vars/all.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
location: canadacentral
1 change: 1 addition & 0 deletions smoketest/regions/canadacentral/hosts.yaml
1 change: 1 addition & 0 deletions smoketest/regions/canadaeast/group_vars/all.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
location: canadaeast
1 change: 1 addition & 0 deletions smoketest/regions/canadaeast/hosts.yaml
1 change: 1 addition & 0 deletions smoketest/regions/centralindia/group_vars/all.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
location: centralindia
1 change: 1 addition & 0 deletions smoketest/regions/centralindia/hosts.yaml
1 change: 1 addition & 0 deletions smoketest/regions/centralus/group_vars/all.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
location: centralus
1 change: 1 addition & 0 deletions smoketest/regions/centralus/hosts.yaml
1 change: 1 addition & 0 deletions smoketest/regions/eastasia/group_vars/all.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
location: eastasia
1 change: 1 addition & 0 deletions smoketest/regions/eastasia/hosts.yaml
1 change: 1 addition & 0 deletions smoketest/regions/eastus/group_vars/all.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
location: eastus
1 change: 1 addition & 0 deletions smoketest/regions/eastus/hosts.yaml
1 change: 1 addition & 0 deletions smoketest/regions/eastus2/group_vars/all.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
location: eastus2
1 change: 1 addition & 0 deletions smoketest/regions/eastus2/hosts.yaml
1 change: 1 addition & 0 deletions smoketest/regions/francecentral/group_vars/all.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
location: francecentral
1 change: 1 addition & 0 deletions smoketest/regions/francecentral/hosts.yaml
1 change: 1 addition & 0 deletions smoketest/regions/germanywestcentral/group_vars/all.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
location: germanywestcentral
1 change: 1 addition & 0 deletions smoketest/regions/germanywestcentral/hosts.yaml
72 changes: 72 additions & 0 deletions smoketest/regions/hosts.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
---
simple_clusters:
hosts:
smoketest-basic:
# Basic cluster
name: aro-default
resource_group: "{{ CLUSTERPREFIX }}-basic-{{ location }}"
network_prefix_cidr: 10.0.0.0/22
master_cidr: 10.0.0.0/23
worker_cidr: 10.0.2.0/23
smoketest-private:
# Private cluster
name: aro-default
resource_group: "{{ CLUSTERPREFIX }}-private-{{ location }}"
network_prefix_cidr: 10.0.0.0/22
master_cidr: 10.0.0.0/23
worker_cidr: 10.0.2.0/23
apiserver_visibility: Private
ingress_visibility: Private
smoketest-enc:
# Basic cluster with encryption-at-host enabled
name: aro-414
resource_group: "{{ CLUSTERPREFIX }}-enc-{{ location }}-414"
version: 4.14.16
network_prefix_cidr: 10.0.0.0/22
master_cidr: 10.0.0.0/23
master_size: Standard_E8s_v5
master_encryption_at_host: true
worker_cidr: 10.0.2.0/23
worker_size: Standard_D4s_v5
worker_encryption_at_host: true
smoketest-udr414:
name: aro-414
resource_group: "{{ CLUSTERPREFIX }}-udr-{{ location }}-414"
version: "{{ CLUSTERVERSION | default('4.14.16') }}"
network_prefix_cidr: 10.0.0.0/22
master_cidr: 10.0.0.0/23
worker_cidr: 10.0.2.0/23
apiserver_visibility: Private
ingress_visibility: Private
outbound_type: UserDefinedRouting
routes:
- name: Blackhole
address_prefix: 0.0.0.0/0
next_hop_type: none
smoketest-udr413:
name: aro-413
resource_group: "{{ CLUSTERPREFIX }}-udr-{{ location }}-413"
version: "4.13.23"
network_prefix_cidr: 10.0.0.0/22
master_cidr: 10.0.0.0/23
worker_cidr: 10.0.2.0/23
apiserver_visibility: Private
ingress_visibility: Private
outbound_type: UserDefinedRouting
routes:
- name: Blackhole
address_prefix: 0.0.0.0/0
next_hop_type: none
byok_clusters:
hosts:
smoketest-byok:
# Cluster with customer-managed disk encryption key
# https://learn.microsoft.com/en-us/azure/openshift/howto-byok
name: aro-414
resource_group: "{{ CLUSTERPREFIX }}-byok-{{ location }}-414"
version: 4.14.16
network_prefix_cidr: 10.0.0.0/22
master_cidr: 10.0.0.0/23
master_size: Standard_E8s_v5
worker_cidr: 10.0.2.0/23
worker_size: Standard_D4s_v5
1 change: 1 addition & 0 deletions smoketest/regions/italynorth/group_vars/all.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
location: italynorth
1 change: 1 addition & 0 deletions smoketest/regions/italynorth/hosts.yaml
1 change: 1 addition & 0 deletions smoketest/regions/japaneast/group_vars/all.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
location: japaneast
1 change: 1 addition & 0 deletions smoketest/regions/japaneast/hosts.yaml
1 change: 1 addition & 0 deletions smoketest/regions/japanwest/group_vars/all.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
location: japanwest
1 change: 1 addition & 0 deletions smoketest/regions/japanwest/hosts.yaml
1 change: 1 addition & 0 deletions smoketest/regions/koreacentral/group_vars/all.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
location: koreacentral
1 change: 1 addition & 0 deletions smoketest/regions/koreacentral/hosts.yaml
1 change: 1 addition & 0 deletions smoketest/regions/northcentralus/group_vars/all.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
location: northcentralus
1 change: 1 addition & 0 deletions smoketest/regions/northcentralus/hosts.yaml
1 change: 1 addition & 0 deletions smoketest/regions/northeurope/group_vars/all.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
location: northeurope
1 change: 1 addition & 0 deletions smoketest/regions/northeurope/hosts.yaml
1 change: 1 addition & 0 deletions smoketest/regions/norwayeast/group_vars/all.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
location: norwayeast
1 change: 1 addition & 0 deletions smoketest/regions/norwayeast/hosts.yaml
1 change: 1 addition & 0 deletions smoketest/regions/norwaywest/group_vars/all.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
location: norwaywest
1 change: 1 addition & 0 deletions smoketest/regions/norwaywest/hosts.yaml
1 change: 1 addition & 0 deletions smoketest/regions/qatarcentral/group_vars/all.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
location: qatarcentral
1 change: 1 addition & 0 deletions smoketest/regions/qatarcentral/hosts.yaml
1 change: 1 addition & 0 deletions smoketest/regions/southafricanorth/group_vars/all.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
location: southafricanorth
1 change: 1 addition & 0 deletions smoketest/regions/southafricanorth/hosts.yaml
1 change: 1 addition & 0 deletions smoketest/regions/southcentralus/group_vars/all.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
location: southcentralus
1 change: 1 addition & 0 deletions smoketest/regions/southcentralus/hosts.yaml
1 change: 1 addition & 0 deletions smoketest/regions/southeastasia/group_vars/all.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
location: southeastasia
1 change: 1 addition & 0 deletions smoketest/regions/southeastasia/hosts.yaml
1 change: 1 addition & 0 deletions smoketest/regions/southindia/group_vars/all.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
location: southindia
1 change: 1 addition & 0 deletions smoketest/regions/southindia/hosts.yaml
1 change: 1 addition & 0 deletions smoketest/regions/swedencentral/group_vars/all.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
location: swedencentral
1 change: 1 addition & 0 deletions smoketest/regions/swedencentral/hosts.yaml
1 change: 1 addition & 0 deletions smoketest/regions/switzerlandnorth/group_vars/all.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
location: switzerlandnorth
1 change: 1 addition & 0 deletions smoketest/regions/switzerlandnorth/hosts.yaml
1 change: 1 addition & 0 deletions smoketest/regions/switzerlandwest/group_vars/all.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
location: switzerlandwest
1 change: 1 addition & 0 deletions smoketest/regions/switzerlandwest/hosts.yaml
1 change: 1 addition & 0 deletions smoketest/regions/uaenorth/group_vars/all.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
location: uaenorth
1 change: 1 addition & 0 deletions smoketest/regions/uaenorth/hosts.yaml
1 change: 1 addition & 0 deletions smoketest/regions/uksouth/group_vars/all.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
location: uksouth
1 change: 1 addition & 0 deletions smoketest/regions/uksouth/hosts.yaml
1 change: 1 addition & 0 deletions smoketest/regions/ukwest/group_vars/all.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
location: ukwest
1 change: 1 addition & 0 deletions smoketest/regions/ukwest/hosts.yaml
1 change: 1 addition & 0 deletions smoketest/regions/westcentralus/group_vars/all.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
location: westcentralus
1 change: 1 addition & 0 deletions smoketest/regions/westcentralus/hosts.yaml
1 change: 1 addition & 0 deletions smoketest/regions/westeurope/group_vars/all.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
location: westeurope
1 change: 1 addition & 0 deletions smoketest/regions/westeurope/hosts.yaml
1 change: 1 addition & 0 deletions smoketest/regions/westus/group_vars/all.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
location: westus
1 change: 1 addition & 0 deletions smoketest/regions/westus/hosts.yaml
1 change: 1 addition & 0 deletions smoketest/regions/westus2/group_vars/all.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
location: westus2
1 change: 1 addition & 0 deletions smoketest/regions/westus2/hosts.yaml
1 change: 1 addition & 0 deletions smoketest/regions/westus3/group_vars/all.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
location: westus3
1 change: 1 addition & 0 deletions smoketest/regions/westus3/hosts.yaml
Loading

0 comments on commit 9e35cd3

Please sign in to comment.