Created
October 13, 2017 06:17
-
-
Save iintothewind/7440eb10c2a3b147f1cd06a624803945 to your computer and use it in GitHub Desktop.
Revisions
-
Ivar Chen created this gist
Oct 13, 2017 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,93 @@ #!/usr/bin/env bash set -e set -u if [[ $director_name == "" ]]; then export director_name = "Bosh Lite Director" fi if [[ $internal_ip == "" ]]; then export internal_ip = "192.168.50.6" fi if [[ $internal_gw == "" ]]; then export internal_gw = "192.168.50.1" fi if [[ $internal_cidr == "" ]]; then export internal_cidr = "192.168.50.0/24" fi if [[ $outbound_network_name == "" ]]; then export outbound_network_name = "NatNetwork" fi if [[ $env_alias == "" ]]; then export env_alias = "vbox" fi if [[ $deployment_name == "" ]]; then export deployment_name = "redis" fi if [[ $stemcell_url == "" ]]; then export stemcell_url = "https://s3.amazonaws.com/bosh-core-stemcells/warden/bosh-stemcell-3468-warden-boshlite-ubuntu-trusty-go_agent.tgz" fi if [[ $deployment_url == "" ]]; then export deployment_url = "https://github.com/cloudfoundry-community/redis-boshrelease.git" fi # remove folder ~/workspace/bosh-deployment rm -rf ~/workspace/bosh-deployment # clone bosh-deployment git clone https://github.com/cloudfoundry/bosh-deployment ~/workspace/bosh-deployment # mk & cd vbox mkdir -p ~/deployments/vbox && cd ~/deployments/vbox # create env bosh create-env ~/workspace/bosh-deployment/bosh.yml \ --state ./state.json \ -o ~/workspace/bosh-deployment/virtualbox/cpi.yml \ -o ~/workspace/bosh-deployment/virtualbox/outbound-network.yml \ -o ~/workspace/bosh-deployment/bosh-lite.yml \ -o ~/workspace/bosh-deployment/bosh-lite-runc.yml \ -o ~/workspace/bosh-deployment/jumpbox-user.yml \ --vars-store ./creds.yml \ -v director_name="$director_name" \ -v internal_ip="$internal_ip" \ -v internal_gw="$internal_gw" \ -v internal_cidr="$internal_ip" \ -v outbound_network_name="$outbound_network_name" # login director bosh alias-env "$env_alias" -e "$internal_ip" --ca-cert <(bosh int ./creds.yml --path /director_ssl/ca) export BOSH_CLIENT=admin export BOSH_CLIENT_SECRET=`bosh int ./creds.yml --path /admin_password` # env info bosh -e "$env_alias" env # update cloud config bosh -e "$env_alias" update-cloud-config ~/workspace/bosh-deployment/warden/cloud-config.yml # download stemcell wget --content-disposition "$stemcell_url" -o stemcell.tgz # upload stemcell bosh -e "$env_alias" upload-stemcell stemcell.tgz # clone deployment git clone "$deployment_url" # deploy bosh -e "$env_alias" -d "$deployment_name" deploy "$deployment_name.yml" --vars-store creds.yml # list vms bosh -e "$env_alias" -d "$deployment_name" vms # update status to consul curl -i -H "Accept:application/json" -X PUT "http://consul.chinanorth.cloudapp.chinacloudapi.cn/v1/kv/bosh/$env_alias/$deployment_name" -H "Content-Type: application/json" -d "$(bosh -e $env_alias -d $deployment_name vms --json)"