### Example BATs Specification File for AWS Source: https://context7.com/cloudfoundry/bosh-cpi-certification/llms.txt This YAML file configures the BOSH CPI Certification tests for AWS infrastructure. It specifies CPI details, network properties, SSH keys, stemcell information, and availability zone settings. ```yaml --- cpi: aws properties: vip: ((bats_eip)) second_static_ip: ((network_static_ip_2)) pool_size: 1 ssh_key_pair: public_key: ((ssh_public_key)) private_key: ((ssh_private_key)) stemcell: name: ((stemcell_name)) version: latest instances: 1 availability_zone: ((az)) key_name: ((default_key_name)) networks: - name: default static_ip: ((network_static_ip_1)) type: manual cidr: ((internal_cidr)) reserved: [((reserved_range))] static: [((static_range))] gateway: ((internal_gw)) subnet: ((subnet_id)) security_groups: ((default_security_groups)) ``` -------------------------------- ### Initialize BOSH Environment Source: https://context7.com/cloudfoundry/bosh-cpi-certification/llms.txt Prepares the output directory, deploys the BOSH director, and generates an environment file for subsequent tasks. ```bash cp ${input_dir}/* ${output_dir} mkdir -p ${output_dir}/{stemcell,bosh-release,cpi-release} cp ${stemcell_dir}/*.tgz ${output_dir}/stemcell/ cp ${bosh_dir}/*.tgz ${output_dir}/bosh-release/ cp ${cpi_dir}/*.tgz ${output_dir}/cpi-release/ # Deploy BOSH director pushd ${output_dir} > /dev/null bosh create-env \ --vars-store "${output_dir}/creds.yml" \ director.yml popd > /dev/null # Generate environment file for subsequent tasks director_ip=$( state_path "/instance_groups/name=bosh/networks/name=${NETWORK_NAME}/static_ips/0" ) ssh_private_key=$( creds_path /jumpbox_ssh/private_key | sed 's/$/\\n/' | tr -d '\n' ) cat > "${output_dir}/director.env" < \${private_key_path} export BOSH_ALL_PROXY="ssh+socks5://jumpbox@${director_ip}:22?private-key=\${private_key_path}" EOF ``` -------------------------------- ### Create Test Deployment Source: https://context7.com/cloudfoundry/bosh-cpi-certification/llms.txt Generates a manifest, builds a release, and deploys a workload to verify upgrade scenarios. ```bash #!/usr/bin/env bash set -e # Required environment variables : ${INFRASTRUCTURE:?} : ${DEPLOYMENT_NAME:?} # e.g., "certification" : ${RELEASE_NAME:?} # e.g., "certification" : ${STEMCELL_NAME:?} # e.g., "bosh-aws-xen-hvm-ubuntu-xenial-go_agent" source pipelines/shared/utils.sh # Generate deployment manifest bosh int pipelines/shared/assets/certification-release/certification.yml \ -v "deployment_name=${DEPLOYMENT_NAME}" \ -v "release_name=${RELEASE_NAME}" \ -v "stemcell_name=${STEMCELL_NAME}" \ -l environment/metadata > /tmp/deployment.yml source director-state/director.env # Create and upload certification release pushd pipelines/shared/assets/certification-release bosh -n create-release --force --name ${RELEASE_NAME} bosh -n upload-release popd # Deploy certification workload bosh -n upload-stemcell $( realpath stemcell/*.tgz ) bosh -n deploy -d ${DEPLOYMENT_NAME} /tmp/deployment.yml ``` -------------------------------- ### Deploy BOSH director Source: https://context7.com/cloudfoundry/bosh-cpi-certification/llms.txt Initializes directory paths and prepares the environment for BOSH director deployment. ```bash #!/usr/bin/env bash set -euo pipefail source pipelines/shared/utils.sh # Set up directories input_dir=$(realpath director-config/) stemcell_dir=$(realpath stemcell/) bosh_dir=$(realpath bosh-release/) cpi_dir=$(realpath cpi-release/) output_dir=$(realpath director-state/) ``` -------------------------------- ### Prepare BOSH director deployment manifest Source: https://context7.com/cloudfoundry/bosh-cpi-certification/llms.txt Interpolates infrastructure-specific configurations and release paths to generate a deployment manifest. ```bash #!/usr/bin/env bash set -e # Required environment variables : ${DIRECTOR_VARS_FILE:?} : ${INFRASTRUCTURE:?} # aws, gcp, azure, vsphere, alicloud source pipelines/shared/utils.sh # Generate director deployment manifest bosh int \ -o bosh-deployment/${INFRASTRUCTURE}/cpi.yml \ -o bosh-deployment/jumpbox-user.yml \ -o pipelines/shared/assets/ops/custom-releases.yml \ -o pipelines/${INFRASTRUCTURE}/assets/ops/custom-cpi-release.yml \ $( echo ${OPTIONAL_OPS_FILE} ) \ -v bosh_release_uri="file://$(echo bosh-release/*.tgz)" \ -v cpi_release_uri="file://$(echo cpi-release/*.tgz)" \ -v stemcell_uri="file://$(echo stemcell/*.tgz)" \ -v director_name=bosh \ -l <( echo "${DIRECTOR_VARS_FILE}" ) \ -l <( pipelines/${INFRASTRUCTURE}/assets/director-vars ) \ bosh-deployment/bosh.yml > director-config/director.yml ``` -------------------------------- ### Test BOSH Director Upgrade Source: https://context7.com/cloudfoundry/bosh-cpi-certification/llms.txt Tests BOSH director upgrade by deploying an older version, creating a workload, upgrading to the new version, and recreating the deployment. Ensure DEPLOYMENT_NAME is set. ```bash #!/usr/bin/env bash set -e source pipelines/shared/utils.sh : ${DEPLOYMENT_NAME:?} # e.g., "certification" # Set up directories output_dir=$(realpath new-director-state/) # Copy old state and new configuration cp -r new-director-config/director.yml ${output_dir} cp -r old-director-state/*-state.json ${output_dir} cp old-director-state/creds.yml ${output_dir} cp old-director-state/director.env ${output_dir} source old-director-state/director.env # Copy new releases mkdir -p ${output_dir}/{stemcell,bosh-release,cpi-release} cp stemcell/*.tgz ${output_dir}/stemcell/ cp bosh-release/*.tgz ${output_dir}/bosh-release/ cp cpi-release/*.tgz ${output_dir}/cpi-release/ # Upgrade existing BOSH Director VM echo "Upgrading existing BOSH Director VM..." pushd ${output_dir} > /dev/null bosh create-env --state "${output_dir}/director-state.json" \ --vars-store "${output_dir}/creds.yml" \ -v director_name=bosh \ director.yml popd > /dev/null # Recreate existing BOSH deployment to verify compatibility echo "Recreating existing BOSH Deployment..." bosh -n -d ${DEPLOYMENT_NAME} recreate # Test passes if both upgrade and recreate succeed ``` -------------------------------- ### Generate certification receipt JSON Source: https://context7.com/cloudfoundry/bosh-cpi-certification/llms.txt Creates a JSON document summarizing the validated BOSH release, CPI release, and stemcell versions. ```bash #!/usr/bin/env bash source pipelines/shared/utils.sh # Generate certification receipt JSON certify_artifacts() { local bosh_release_name=${1?Usage: certify_artifacts BOSH_RELEASE_NAME VERSION CPI_NAME CPI_VERSION STEMCELL_NAME STEMCELL_VERSION} local bosh_release_version=${2} local cpi_release_name=${3} local cpi_release_version=${4} local stemcell_name=${5} local stemcell_version=${6} cat < bats-config/bats-config.yml # Set up environment and run tests source director-state/director.env export BAT_STEMCELL=$(realpath stemcell/*.tgz) export BAT_DEPLOYMENT_SPEC=$(realpath bats-config/bats-config.yml) export BAT_BOSH_CLI=$(which bosh) pushd bats bundle install bundle exec rspec spec $BAT_RSPEC_FLAGS popd ``` -------------------------------- ### Generate Certification Receipt Source: https://context7.com/cloudfoundry/bosh-cpi-certification/llms.txt Generates a certification receipt JSON file documenting the validated combination of releases and stemcells. Requires CPI_RELEASE_NAME and STEMCELL_NAME environment variables. ```bash #!/usr/bin/env bash set -e source pipelines/shared/utils.sh # Required environment variables : ${CPI_RELEASE_NAME:?} # e.g., "bosh-aws-cpi" : ${STEMCELL_NAME:?} # e.g., "bosh-aws-xen-hvm-ubuntu-xenial-go_agent" # Extract versions from release artifacts BOSH_RELEASE_VERSION=$(cat bosh-release/version) CPI_RELEASE_VERSION=$(cat cpi-release/version) STEMCELL_VERSION=$(cat stemcell/version) # Generate unique filename with timestamp and content hash timestamp="$(date -u +%Y%m%d%H%M%S)" contents_hash=$(echo bosh-${BOSH_RELEASE_VERSION}-${CPI_RELEASE_NAME}-${CPI_RELEASE_VERSION}-${STEMCELL_NAME}-${STEMCELL_VERSION} | md5sum | cut -f1 -d ' ') # Create certification receipt certify_artifacts \ bosh $BOSH_RELEASE_VERSION \ $CPI_RELEASE_NAME $CPI_RELEASE_VERSION \ $STEMCELL_NAME $STEMCELL_VERSION \ > certification/${contents_hash}-${timestamp}-receipt.json # Example output filename: a1b2c3d4e5f6-20231115143022-receipt.json # Example receipt content: # { # "releases": [ # {"name": "bosh", "version": "271.2.0"}, # {"name": "bosh-aws-cpi", "version": "83"} # ], # "stemcell": { # "name": "bosh-aws-xen-hvm-ubuntu-xenial-go_agent", # "version": "621.74" # } # } ``` -------------------------------- ### Custom CPI Release Configuration Source: https://github.com/cloudfoundry/bosh-cpi-certification/blob/master/README.md This YAML snippet is used within the certification pipeline to specify a particular BOSH CPI release version. It allows for defining the release name and its source URL. ```yaml - type: replace path: /releases/name=bosh--cpi value: name: bosh--cpi url: ((cpi_release_uri)) ``` -------------------------------- ### Concourse Pipeline Configuration for GCP CPI Certification Source: https://context7.com/cloudfoundry/bosh-cpi-certification/llms.txt A Concourse pipeline configuration written in YAML, designed to automate BOSH CPI certification tests, including BATs and upgrade tests on GCP. It defines groups, shared tasks, jobs, and resources. ```yaml --- groups: - name: certify-gcp jobs: - bats-centos-7 - bats-ubuntu-xenial - test-stemcell-ubuntu-xenial - test-upgrade - certify-centos-7 - certify-ubuntu-xenial shared: - &prepare-director task: prepare-director file: pipelines/shared/tasks/prepare-director.yml image: bosh-integration-registry-image params: &prepare-director-params INFRASTRUCTURE: gcp DIRECTOR_VARS_FILE: {{gcp_director_vars_file}} OPTIONAL_OPS_FILE: | -o bosh-deployment/external-ip-not-recommended.yml - &deploy-director task: deploy-director file: pipelines/shared/tasks/deploy-director.yml image: bosh-integration-registry-image - &run-bats task: run-bats file: pipelines/shared/tasks/run-bats.yml image: bosh-integration-registry-image params: &run-bats-params INFRASTRUCTURE: gcp BAT_INFRASTRUCTURE: gcp - &teardown task: teardown file: pipelines/shared/tasks/teardown.yml image: bosh-integration-registry-image jobs: - name: bats-ubuntu-xenial serial: true plan: - aggregate: - {get: bosh-release, trigger: true} - {get: cpi-release, trigger: true} - {get: stemcell, trigger: true, resource: ubuntu-xenial-stemcell} - {get: pipelines, trigger: false} - {get: bosh-deployment, trigger: false} - put: environment params: env_name: certify-gcp-bats-ubuntu-xenial delete_on_failure: true generate_random_name: true terraform_source: pipelines/gcp/assets/terraform - <<: *prepare-director - do: - <<: *deploy-director - <<: *run-bats params: <<: *run-bats-params STEMCELL_NAME: bosh-google-kvm-ubuntu-xenial-go_agent BAT_RSPEC_FLAGS: "--tag ~multiple_manual_networks" ensure: do: - <<: *teardown - put: environment params: action: destroy env_name_file: environment/name terraform_source: pipelines/gcp/assets/terraform - name: certify-ubuntu-xenial serial: true plan: - aggregate: - {get: bosh-release, trigger: true, passed: [bats-ubuntu-xenial]} - {get: cpi-release, trigger: true, passed: [bats-ubuntu-xenial]} - {get: stemcell, trigger: true, passed: [bats-ubuntu-xenial], resource: ubuntu-xenial-stemcell} - task: generate file: pipelines/shared/tasks/generate-receipt.yml params: CPI_RELEASE_NAME: bosh-google-cpi STEMCELL_NAME: bosh-google-kvm-ubuntu-xenial-go_agent - {put: receipt, params: {file: certification/*-receipt.json}} resources: - name: bosh-release type: bosh-io-release source: repository: cloudfoundry/bosh - name: cpi-release type: bosh-io-release source: repository: cloudfoundry-incubator/bosh-google-cpi-release - name: ubuntu-xenial-stemcell type: bosh-io-stemcell source: name: bosh-google-kvm-ubuntu-xenial-go_agent - name: environment type: terraform_type source: vars: google_project: {{google_project_id}} google_region: {{google_region}} google_json_key_data: {{google_json_key_data}} ``` -------------------------------- ### Extract BOSH director state and credentials Source: https://context7.com/cloudfoundry/bosh-cpi-certification/llms.txt Helper functions to retrieve specific values from YAML files using the bosh int command. ```bash #!/usr/bin/env bash # Extract values from director state and credentials files state_path() { bosh int director-state/director.yml --path="$1" ; } creds_path() { bosh int director-state/creds.yml --path="$1" ; } # Usage examples: # Get director IP from state director_ip=$( state_path "/instance_groups/name=bosh/networks/name=default/static_ips/0" ) echo "Director IP: ${director_ip}" # Get admin password from credentials admin_password=$( creds_path /admin_password ) echo "Admin password retrieved" # Get SSH private key for jumpbox access ssh_private_key=$( creds_path /jumpbox_ssh/private_key | sed 's/$/\\n/' | tr -d '\n' ) # Get director SSL CA certificate ca_cert=$( creds_path /director_ssl/ca ) ``` -------------------------------- ### Teardown BOSH Director and Deployments Source: https://context7.com/cloudfoundry/bosh-cpi-certification/llms.txt Cleans up BOSH director and all deployments after test completion. Skips if director-state.json does not exist. Restores compiled packages cache if available. ```bash #!/usr/bin/env bash set -euo pipefail source pipelines/shared/utils.sh # Skip if no director state exists if [ ! -e director-state/director-state.json ]; then echo "director-state.json does not exist, skipping..." exit 0 fi # Restore compiled packages cache if available if [ -d "director-state/.bosh" ]; then cp -r director-state/.bosh $HOME/ fi pushd director-state > /dev/null set +e source director.env # Delete all deployments echo "Deleting all deployments..." bosh deployments | awk '{print $1}' | xargs --no-run-if-empty -n 1 bosh -n delete-deployment --force -d # Clean up BOSH artifacts echo "Cleaning up BOSH Director..." bosh -n clean-up --all set -e # Delete BOSH Director VM echo "Deleting existing BOSH Director VM..." bosh -n delete-env --vars-store creds.yml -v director_name=bosh director.yml popd ``` -------------------------------- ### Terraform GCP Provider Configuration Source: https://context7.com/cloudfoundry/bosh-cpi-certification/llms.txt Terraform configuration for provisioning GCP infrastructure required for BOSH certification testing. Defines variables for environment name, project, region, zone, and JSON key data. ```hcl variable "env_name" { type = string } variable "google_project" { type = string } variable "google_region" { default = "us-central1" } variable "google_zone" { default = "us-central1-a" } variable "google_json_key_data" { type = string } provider "google" { credentials = var.google_json_key_data project = var.google_project region = var.google_region } # Static IP addresses for director and BATs resource "google_compute_address" "director" { name = "${var.env_name}-director-ubuntu" } resource "google_compute_address" "bats" { name = "${var.env_name}-bats-ubuntu" } # Custom VPC network resource "google_compute_network" "network" { name = "${var.env_name}-custom" auto_create_subnetworks = false } resource "google_compute_subnetwork" "subnetwork" { name = "${var.env_name}-${var.google_region}" ip_cidr_range = "10.0.0.0/24" network = google_compute_network.network.self_link } ``` -------------------------------- ### GCP Output Variables for Pipeline Consumption Source: https://context7.com/cloudfoundry/bosh-cpi-certification/llms.txt Defines output variables for Terraform, providing essential network and IP address information needed by CI/CD pipelines for BOSH CPI deployment and management. ```hcl output "external_ip" { value = google_compute_address.director.address } output "internal_ip" { value = cidrhost(google_compute_subnetwork.subnetwork.ip_cidr_range, 6) } output "internal_gw" { value = cidrhost(google_compute_subnetwork.subnetwork.ip_cidr_range, 1) } output "network" { value = google_compute_network.network.name } output "subnetwork" { value = google_compute_subnetwork.subnetwork.name } output "internal_cidr" { value = google_compute_subnetwork.subnetwork.ip_cidr_range } ``` -------------------------------- ### GCP Firewall Rule for External Traffic Source: https://context7.com/cloudfoundry/bosh-cpi-certification/llms.txt Configures a Google Compute Engine firewall rule to permit specific TCP ports (22, 443, etc.) and UDP port 53 for external access to BOSH CPI services. It applies to resources tagged with the environment name. ```hcl resource "google_compute_firewall" "external" { name = "${var.env_name}-external" network = google_compute_network.network.name description = "BOSH CI External traffic" allow { protocol = "tcp" ports = ["22", "443", "4222", "6868", "25250", "25555", "25777"] } allow { protocol = "udp" ports = ["53"] } target_tags = ["${var.env_name}-external"] } ``` -------------------------------- ### GCP Firewall Rule for Internal Traffic Source: https://context7.com/cloudfoundry/bosh-cpi-certification/llms.txt Defines a Google Compute Engine firewall rule to allow ICMP, TCP, and UDP traffic for internal BOSH CPI components. It uses source and target tags for network segmentation. ```hcl resource "google_compute_firewall" "internal" { name = "${var.env_name}-internal" network = google_compute_network.network.name description = "BOSH CI Internal traffic" allow { protocol = "icmp" } allow { protocol = "tcp" } allow { protocol = "udp" } source_tags = ["${var.env_name}-internal"] target_tags = ["${var.env_name}-internal"] } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.