Add document pull functionality to deploy job

This change introduces airshipctl's document pull functionality to the
Treasuremap gate runner job. This enables Treasuremap maintainers to pin
to a version of airshipctl deployment scripts and manifests that are
known to be compatible with Treasuremap's v2 branch.

In order to ensure that the deployment scripts and manifests come from
the same version of airshipctl, this change introduces a playbook that
checks out the referenced version of airhsipctl after it is cloned by
Zuul. It also checks out the known version a second time in the
deployment scripts for operators invoking the scripts in a non-Zuul
environment.

To update the pinned version of Treasuremap using Zuul, change the Zuul
variable airshipctl_ref. To update the pinned version in a non-Zuul
environment, use the environment variable AIRSHIPCTL_REF.

Change-Id: I300f545efcdd024b689a96ee99e502de7fdd1b83
Signed-off-by: Drew Walters <andrew.walters@att.com>
This commit is contained in:
Drew Walters 2020-10-23 20:13:31 +00:00
parent c4d185bba6
commit 8547656a68
7 changed files with 82 additions and 35 deletions

View File

@ -1,13 +0,0 @@
- op: replace
path: /providers/0/versions/v0.3.2
value: ../airshipctl/manifests/function/capm3/v0.3.2
- op: replace
path: /providers/1/versions/v0.3.7
value: ../airshipctl/manifests/function/cabpk/v0.3.7
- op: replace
path: /providers/2/versions/v0.3.7
value: ../airshipctl/manifests/function/capi/v0.3.7
- op: replace
path: /providers/3/versions/v0.3.7
value: ../airshipctl/manifests/function/cacpk/v0.3.7

View File

@ -1,9 +1,2 @@
resources: resources:
- ../../../../airshipctl/manifests/function/clusterctl - ../../../../airshipctl/manifests/function/clusterctl
patchesJson6902:
- target:
group: airshipit.org
version: v1alpha1
kind: Clusterctl
name: clusterctl_init
path: clusterctl-patch.yaml

View File

@ -0,0 +1,25 @@
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Ensure that Treasuremap uses the same airshipctl reference for setup scripts
# as well as the manifests cloned in document pull.
- hosts: primary
tasks:
- name: Checkout version
shell: git checkout "{{ airshipctl_ref | default('HEAD') }}"
args:
chdir: "{{ zuul.projects['opendev.org/airship/airshipctl'].src_dir }}"
- name: Print version
shell: echo "Using airshipctl ref $(git rev-parse HEAD)"
args:
chdir: "{{ zuul.projects['opendev.org/airship/airshipctl'].src_dir }}"

View File

@ -25,8 +25,14 @@
- ./tools/deployment/30_deploy_controlplane.sh - ./tools/deployment/30_deploy_controlplane.sh
- name: "Run gate scripts" - name: "Run gate scripts"
include_role: shell: |
name: airshipctl-run-script {{ gate_script_path }}
args:
chdir: "{{ zuul.project.src_dir }}"
environment:
AIRSHIPCTL_REF: "{{ airshipctl_ref | default('') }}"
AIRSHIPCTL_REPO_URL: "https://opendev.org/airship/airshipctl.git"
TREASUREMAP_PROJECT: "{{ ansible_user_dir }}/{{ zuul.project.src_dir }}"
vars: vars:
gate_script_path: "{{ item }}" gate_script_path: "{{ item }}"
with_items: "{{ gate_scripts | default(gate_scripts_default) }}" with_items: "{{ gate_scripts | default(gate_scripts_default) }}"

View File

@ -17,22 +17,31 @@ set -xe
: ${AIRSHIPCTL_PROJECT:="../airshipctl"} : ${AIRSHIPCTL_PROJECT:="../airshipctl"}
: ${TREASUREMAP_PROJECT:="$(pwd)"} : ${TREASUREMAP_PROJECT:="$(pwd)"}
export AIRSHIPCTL_WS=${AIRSHIPCTL_WS:-$AIRSHIPCTL_PROJECT} export AIRSHIP_SITE_NAME=${AIRSHIP_SITE_NAME:-"test-site"}
export AIRSHIP_CONFIG_MANIFEST_DIRECTORY=${AIRSHIP_CONFIG_MANIFEST_DIRECTORY:-$TREASUREMAP_PROJECT} export AIRSHIP_CONFIG_METADATA_PATH=${AIRSHIP_CONFIG_METADATA_PATH:-"treasuremap/manifests/site/$AIRSHIP_SITE_NAME/metadata.yaml"}
export AIRSHIP_SITE_NAME=${AIRSHIP_SITE_NAME:-"manifests/site/test-site"}
export AIRSHIP_CONFIG_METADATA_PATH=${AIRSHIP_CONFIG_METADATA_PATH:-"$AIRSHIP_SITE_NAME/metadata.yaml"} # Primary repo options
export AIRSHIP_CONFIG_PRIMARY_REPO_URL=${AIRSHIP_CONFIG_PRIMARY_REPO_URL:-"${TREASUREMAP_PROJECT}"}
export AIRSHIPCTL_REPO_URL=${AIRSHIPCTL_REPO_URL:-"https://opendev.org/airship/airshipctl.git"}
export TREASUREMAP_REF=${TREASUREMAP_REF:-"$(git rev-parse HEAD)"}
cd ${AIRSHIPCTL_PROJECT} cd ${AIRSHIPCTL_PROJECT}
# NOTE(drewwalters96): Override $AIRSHIPCTL_REF to pin airshipctl to a specific
# git commit. Defaults to cloned version.
export AIRSHIPCTL_REF=${AIRSHIPCTL_REF:-"$(git rev-parse HEAD)"}
./tools/deployment/22_test_configs.sh ./tools/deployment/22_test_configs.sh
# TODO: may not need/want this since treasuremap repo is already present, # Add the airshipctl manifest defintion
# and branch checkout seems not to be working anyway for some reason? airshipctl config set-manifest treasuremap_ci \
--repo airshipctl \
--url "${AIRSHIPCTL_REPO_URL}" \
--commithash "${AIRSHIPCTL_REF}"
# Add the manifest defintion for Treasuremap airshipctl config set-manifest treasuremap_ci \
#airshipctl config set-manifest dummy_manifest \ --repo primary \
# --repo treasuremap \ --url "${AIRSHIP_CONFIG_PRIMARY_REPO_URL}" \
# --url https://opendev.org/airship/treasuremap \ --commithash "${TREASUREMAP_REF}" \
# --branch v2 \
# --primary
airshipctl config set-context ephemeral-cluster --manifest treasuremap_ci
airshipctl config set-context target-cluster --manifest treasuremap_ci

View File

@ -0,0 +1,23 @@
#!/usr/bin/env bash
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
set -xe
# TODO(drewwalters96): The document pull command is not invoked from a script
# in airshipctl since it uses the -n (no checkout) option. This enables the
# Treasuremap repository to use a pinned version of airshipctl.
#
# When airshipctl removes the -n from its document pull script, that script can
# be invoked here.
airshipctl document pull --debug

View File

@ -55,16 +55,21 @@
roles: roles:
- zuul: airship/airshipctl - zuul: airship/airshipctl
pre-run: pre-run:
- playbooks/airship-treasuremap-ensure-checkout.yaml
- playbooks/airship-treasuremap-deploy-docker.yaml - playbooks/airship-treasuremap-deploy-docker.yaml
- playbooks/airship-treasuremap-build-gate.yaml - playbooks/airship-treasuremap-build-gate.yaml
post-run: playbooks/airship-collect-logs.yaml post-run: playbooks/airship-collect-logs.yaml
run: playbooks/airship-treasuremap-gate-runner.yaml run: playbooks/airship-treasuremap-gate-runner.yaml
nodeset: airship-treasuremap-single-16GB-bionic-node nodeset: airship-treasuremap-single-16GB-bionic-node
vars: vars:
# NOTE(drewwalters96): Set airshipctl_ref to a commit SHA in order to pin
# the cloned version of airshipctl to a known/compatible reference.
# airshipctl_ref: ""
site_name: test-site site_name: test-site
gate_scripts: gate_scripts:
- ./tools/deployment/01_install_kubectl.sh - ./tools/deployment/01_install_kubectl.sh
- ./tools/deployment/22_test_configs.sh - ./tools/deployment/22_test_configs.sh
- ./tools/deployment/23_pull_documents.sh
- ./tools/deployment/24_build_ephemeral_iso.sh - ./tools/deployment/24_build_ephemeral_iso.sh
- ./tools/deployment/25_deploy_ephemeral_node.sh - ./tools/deployment/25_deploy_ephemeral_node.sh
- ./tools/deployment/26_deploy_metal3_capi_ephemeral_node.sh - ./tools/deployment/26_deploy_metal3_capi_ephemeral_node.sh
@ -74,7 +79,6 @@
- ./tools/deployment/33_cluster_move_target_node.sh - ./tools/deployment/33_cluster_move_target_node.sh
- ./tools/deployment/34_deploy_worker_node.sh - ./tools/deployment/34_deploy_worker_node.sh
- ./tools/deployment/35_deploy_workload.sh - ./tools/deployment/35_deploy_workload.sh
serve_dir: /srv/iso serve_dir: /srv/iso
serve_port: 8099 serve_port: 8099
voting: false voting: false