Skip to content

Instantly share code, notes, and snippets.

@jasonnerothin
Created April 29, 2018 14:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasonnerothin/54f63d110da5e31189b306a90b65f79e to your computer and use it in GitHub Desktop.
Save jasonnerothin/54f63d110da5e31189b306a90b65f79e to your computer and use it in GitHub Desktop.
bosh / cf install script
#!/bin/bash -x
readonly HERE=$(pwd)
readonly BASEDIR=~/scratch
readonly BOSHINSTALLNAME='bosh0'
# SETUP
readonly BOSHDIR="${BASEDIR}/${BOSHINSTALLNAME}"
echo "Setting up deployment in ${BOSHDIR}..."
# rm -rf ${BOSHDIR} && mkdir ${BOSHDIR} && cd ${BOSHDIR}
echo 'Verifying Bosh-lite readiness...'
bosh -v
if [ $? -ne 0 ];
then
echo "XXXX ERROR executing bosh. Exiting... XXXX"
exit $?
fi
echo 'Verifying bbl readiness...'
bosh -v
if [ $? -ne 0 ];
then
echo "XXXX ERROR executing bbl. Exiting... XXXX"
exit $?
fi
readonly AWSKEY="XXXX"
readonly AWSSECRET="XXXXX"
bye() {
echo "bbl down [Y*]?"
read input
if [ "${input}" -eq "Y" ];
then
echo "bye"
bbl down \
--aws-access-key-id "${AWSKEY}" \
--aws-secret-access-key "${AWSSECRET}" ;
fi
cd ${HERE}
sleep 1
exit 0
}
# BOSH DIRECTOR INSTALL
echo "Generating security credentials..."
CERT_NAME="${BASEDIR}/${BOSHINSTALLNAME}-cert.pem"
KEY_NAME="${BASEDIR}/${BOSHINSTALLNAME}-key.pem"
export BBL_AWS_ACCESS_KEY_ID="${AWSKEY}"
export BBL_AWS_SECRET_ACCESS_KEY="${AWSSECRET}"
export BBL_AWS_REGION="us-east-1"
# openssl req -x509 -newkey rsa:2048 -keyout ${KEY_NAME} -out ${CERT_NAME} -nodes
cd "${BOSHDIR}" ;
bbl up --iaas "aws" ;
# target & upload stemcell
bosh -e $(bbl director-address) --ca-cert <(bbl director-ca-cert) alias-env "${BOSHINSTALLNAME}"
bosh -e ${BOSHINSTALLNAME} login --client $(bbl director-username) --client-secret $(bbl director-password)
wget https://bosh.io/d/stemcells/bosh-warden-boshlite-ubuntu-trusty-go_agent
bosh -e ${BOSHINSTALLNAME} upload-stemcell ./bosh-warden-boshlite-ubuntu-trusty-go_agent
# stdout-verify...
bosh cpi-config
cat bbl-state.json
bye
# CLOUD FOUNDRY INSTALL
echo "Installing Cloud Foundry..."
cd ${BASEDIR}
readonly CFDEPLOYREPO="https://github.com/jasonnerothin/cf-deployment"
git clone ${CFDEPLOYREPO}
readonly CFDIR="${BASEDIR}/cf-deployment"
if [ ! -d ${CFDIR} ];
then
echo "XXXX cf-deployment directory does not exist. Exiting... XXXX"
exit $?
fi
readonly SYSTEMDOMAIN=jasonnerothin.com
bosh -e ${BOSHINSTALLNAME} \
-d cf deploy ${CFDIR}/cf-deployment.yml \
-o ${CFDIR}/operations/bosh-lite.yml \
--vars-store ${deployment-vars.yml \
-v system-domain=${SYSTEMDOMAIN}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment