|
| 1 | +- hosts: all |
| 2 | + become: yes |
| 3 | + roles: |
| 4 | + - role: export-cloud-openrc |
| 5 | + vars: |
| 6 | + cloud_name: 'opentelekomcloud' |
| 7 | + tasks: |
| 8 | + - name: Install bosh and run bosh acceptance tests |
| 9 | + shell: |
| 10 | + cmd: | |
| 11 | + set -x |
| 12 | + set -e |
| 13 | + set -o pipefail |
| 14 | +
|
| 15 | + # Cloud provider specific variables |
| 16 | + NET_ID="134ca339-24dc-44f5-ae6a-cf0404216ed2" |
| 17 | + SUBNET_ID="3d6e9157-655f-42ec-9778-94d455730e5c" |
| 18 | + SMALL_FLAVOR="s2.medium.1" #1U1G |
| 19 | + MEDIUM_FLAVOR="s2.large.1" #2U2G |
| 20 | + LARGE_FLAVOR="s2.2xlarge.1" #8U8G |
| 21 | + BUILD_ID="{{ zuul.build }}" |
| 22 | +
|
| 23 | + pip install python-openstackclient |
| 24 | + curl -Lo ./bosh https://s3.amazonaws.com/bosh-cli-artifacts/bosh-cli-3.0.1-linux-amd64 |
| 25 | + chmod +x ./bosh |
| 26 | + cp ./bosh /usr/local/bin/bosh |
| 27 | + bosh -v |
| 28 | + apt-get install -y build-essential zlibc zlib1g-dev ruby ruby-dev openssl libxslt-dev libxml2-dev libssl-dev libreadline6 libreadline6-dev libyaml-dev libsqlite3-dev sqlite3 |
| 29 | +
|
| 30 | + mkdir bosh-1 && cd bosh-1 |
| 31 | + git clone https://github.com/cloudfoundry/bosh-deployment.git |
| 32 | + openstack keypair create microbosh-${BUILD_ID} > microbosh.pem |
| 33 | + openstack security group create bosh-${BUILD_ID} --description 'BOSH Security Group' |
| 34 | + openstack security group rule create --protocol tcp --ingress bosh-${BUILD_ID} |
| 35 | + openstack security group rule create --protocol icmp --ingress bosh-${BUILD_ID} |
| 36 | +
|
| 37 | + wget --content-disposition https://bosh.io/d/stemcells/bosh-openstack-kvm-ubuntu-trusty-go_agent -O bosh-openstack-kvm-ubuntu-trusty-go_agent.tgz |
| 38 | + sed -i 's|https://bosh.io/d/stemcells/.*$|file://{{ ansible_user_dir }}/bosh-1/bosh-openstack-kvm-ubuntu-trusty-go_agent.tgz|' bosh-deployment/openstack/cpi.yml |
| 39 | + sed -i "s/m1.small/${SMALL_FLAVOR}/g" `grep m1.small -rl bosh-deployment/openstack` |
| 40 | + sed -i "s/m1.xlarge/${LARGE_FLAVOR}/g" `grep m1.xlarge -rl bosh-deployment/openstack` |
| 41 | + sed -i '/^.*human_readable_vm_names.*$/ a\ \ \ \ state_timeout: 300000' bosh-deployment/openstack/cpi.yml |
| 42 | +
|
| 43 | + # NOTE: We need an available ip for bosh deployment, so following port creation and deletion actions are just |
| 44 | + # used to reserve an available ip address for bosh deployment |
| 45 | + _port_id=$(openstack port create --network ${NET_ID} bosh-port -f value -c id) |
| 46 | + bosh_ip=$(openstack port show ${_port_id} -f value -c fixed_ips | grep -Eo '([0-9]+\.){3}[0-9]+') |
| 47 | + openstack port delete ${_port_id} |
| 48 | +
|
| 49 | + set +x |
| 50 | + bosh create-env bosh-deployment/bosh.yml \ |
| 51 | + --state=state.json \ |
| 52 | + --vars-store=creds.yml \ |
| 53 | + -o bosh-deployment/openstack/cpi.yml \ |
| 54 | + -v director_name=bosh-1 \ |
| 55 | + -v internal_cidr=$(openstack subnet show ${SUBNET_ID} -f value -c cidr) \ |
| 56 | + -v internal_gw=$(openstack subnet show ${SUBNET_ID} -f value -c gateway_ip) \ |
| 57 | + -v internal_ip=${bosh_ip} \ |
| 58 | + -v auth_url=${OS_AUTH_URL} \ |
| 59 | + -v az=${OS_AVAILABILITY_ZONE} \ |
| 60 | + -v default_key_name=microbosh-${BUILD_ID} \ |
| 61 | + -v default_security_groups=[bosh-${BUILD_ID}] \ |
| 62 | + -v net_id=${NET_ID} \ |
| 63 | + -v openstack_password=${OS_PASSWORD} \ |
| 64 | + -v openstack_username=${OS_USERNAME} \ |
| 65 | + -v openstack_domain=${OS_DOMAIN_NAME} \ |
| 66 | + -v openstack_project=${OS_TENANT_NAME} \ |
| 67 | + -v private_key="{{ ansible_user_dir }}/bosh-1/microbosh.pem" \ |
| 68 | + -v region=${OS_REGION_NAME} |
| 69 | + set -x |
| 70 | +
|
| 71 | + bosh alias-env bosh-1 -e ${bosh_ip} --ca-cert <(bosh int ./creds.yml --path /director_ssl/ca) |
| 72 | + export BOSH_CLIENT=admin |
| 73 | + export BOSH_CLIENT_SECRET=`bosh int ./creds.yml --path /admin_password` |
| 74 | + bosh -e bosh-1 env |
| 75 | +
|
| 76 | + # path to the stemcell you want to use for testing |
| 77 | + export BAT_STEMCELL="{{ ansible_user_dir }}/bosh-1/bosh-openstack-kvm-ubuntu-trusty-go_agent.tgz" |
| 78 | +
|
| 79 | + # path to the bat yaml file which is used to generate the deployment manifest (see below `bat.yml`) |
| 80 | + export BAT_DEPLOYMENT_SPEC="{{ ansible_user_dir }}/bosh-1/bat.yml" |
| 81 | +
|
| 82 | + # BOSH CLI executable path |
| 83 | + export BAT_BOSH_CLI=bosh |
| 84 | +
|
| 85 | + # DNS host or IP where BOSH-controlled PowerDNS server is running, which is required for the DNS tests. For example, if BAT is being run against a MicroBOSH then this value will be the same as BAT_DIRECTOR |
| 86 | + export BAT_DNS_HOST=8.8.8.8 |
| 87 | +
|
| 88 | + # the name of infrastructure that is used by bosh deployment. Examples: aws, vsphere, openstack, warden, oci. |
| 89 | + export BAT_INFRASTRUCTURE=openstack |
| 90 | +
|
| 91 | + # the type of networking being used: `dynamic` or `manual`. |
| 92 | + export BAT_NETWORKING=dynamic |
| 93 | +
|
| 94 | + # the path to ssh key, used by OS specs to ssh into BOSH VMs |
| 95 | + export BAT_PRIVATE_KEY="{{ ansible_user_dir }}/bosh-1/microbosh.pem" |
| 96 | +
|
| 97 | + # Run tests with --fail-fast and skip cleanup in case of failure (optional) |
| 98 | + export BAT_DEBUG_MODE=true |
| 99 | +
|
| 100 | + export BOSH_OS_BATS=true |
| 101 | +
|
| 102 | + export BOSH_ENVIRONMENT=bosh-1 |
| 103 | + # export BOSH_CLIENT=<director username> |
| 104 | + # export BOSH_CLIENT_SECRET=<director password> |
| 105 | + # export BOSH_CA_CERT=<director ca cert content or path> |
| 106 | + cat << EOF >> bat.yml |
| 107 | + --- |
| 108 | + cpi: openstack |
| 109 | + properties: |
| 110 | + stemcell: |
| 111 | + name: bosh-openstack-kvm-ubuntu-trusty-go_agent |
| 112 | + version: latest |
| 113 | + pool_size: 1 |
| 114 | + instances: 1 |
| 115 | + instance_type: ${SMALL_FLAVOR} |
| 116 | + availability_zone: ${OS_AVAILABILITY_ZONE} |
| 117 | + flavor_with_no_ephemeral_disk: ${MEDIUM_FLAVOR} |
| 118 | + vip: 0.0.0.43 # Virtual (public/floating) IP assigned to the bat-release job vm, for ssh testing |
| 119 | + networks: |
| 120 | + - name: default |
| 121 | + type: dynamic |
| 122 | + cloud_properties: |
| 123 | + net_id: ${NET_ID} # Network ID |
| 124 | + security_groups: [bosh-${BUILD_ID}] # security groups assigned to deployed VMs |
| 125 | + key_name: microbosh-${BUILD_ID} # (optional) SSH keypair name |
| 126 | + EOF |
| 127 | +
|
| 128 | + pushd '{{ ansible_user_dir }}/{{ zuul.project.src_dir }}' |
| 129 | + gem install bundler |
| 130 | + bundle install |
| 131 | + cp '{{ ansible_user_dir }}/bosh' /usr/local/bin/bosh |
| 132 | + bundle exec rspec spec --tag ~raw_ephemeral_storage |
| 133 | + popd |
| 134 | +
|
| 135 | + executable: /bin/bash |
| 136 | + chdir: '{{ ansible_user_dir }}' |
| 137 | + environment: '{{ golang_env }}' |
0 commit comments