Follow this procedure to setup a bootstrap instance of concourse and deploy minimal components to bring up a permanant instance of concourse deployed by a bosh director.
- Clone this repository:
git clone https://github.com/cloud-gov/cg-provision
- Get the rest of the necessary repositories:
./cg-provision/scripts/bootstrap/setup-bootstrap.sh
cd cg-provision
- Make a copy of
env.example.sh
and populate with AWS credentials, etc. (cp env.example.sh env.sh
)- An example
TERRAFORM_PROVISION_CREDENTIALS_FILE
can be found inci/credentials.example.yml
. Make a copy and place in your${WORKSPACE_DIR}
fromenv.sh
. toolingbosh
andconcourse
currently need pre-populated, encrypted secrets files:tooling-bosh-main.yml
,tooling-bosh-external.yml
,concourse-tooling-prod.yml
.- Populate these and encrypt with
../cg-pipeline-tasks/encrypt.sh
, upload to${VARZ_BUCKET}
with the aws cli, and set the respective passphrases inenv.sh
. - TODO: generate all secrets for bosh & concourse / pull values from tf.
- Populate these and encrypt with
source env.sh
- If the above step fails, you may have to comment out the
TF_STATE_BUCKET
line.
- An example
- Create bootstrap terraform stack:
./scripts/bootstrap/01-bootstrap-terraform.sh
- Note the
public_ip
output. This is the address of your bootstrap concourse instance.
- Note the
- Make sure you are on the GSA network, either via VPN, or being in a GSA office.
- Deploy a bootstrap concourse instance:
./scripts/bootstrap/02-bootstrap-concourse.sh
- If, for some reason, this fails, and you want to start this step over, you can use the
./scripts/bootstrap/destroy-02-bootstrap-concourse.sh
script to do this, as there is a volume that persists otherwise. - Login to the web ui at
https://public-ip:4443
,bootstrap
/password in${WORKSPACE_DIR}/bootstrap-concourse-creds.yml
. - If you commented out
TF_STATE_BUCKET
above:- Create the
${WORKSPACE_DIR}/cg-provision.yml
file, if you haven't already. - uncomment it and
source env.sh
again.
- Create the
- If, for some reason, this fails, and you want to start this step over, you can use the
- Deploy main terraform:
./scripts/bootstrap/03-main-terraform.sh
- Inspect the terraform plan, then run
terraform-provision/bootstrap-tooling
from the web ui. - If you don't have a
star-fr-cloud-gov
certificate in the account, upload it to aws. - The
init-bosh-db
task will fail because we haven't setup peering yet.
- Inspect the terraform plan, then run
- Update cloud.gov DNS records for the
tooling-bosh-uaa
andtooling-Concourse
ELBs created by terraform.- Look at the DNS names of these ELBs in the AWS console and plug those into https://github.com/18F/cg-provision/blob/master/terraform/stacks/dns/stack.tf For the new dev env, you can edit the entries that have
dev2
in the name. Be sure to leave thedualstack.
on the front of the A record. - Eventually you'll need to update records for all newly created ELBs.
- TODO: automate DNS updates
- Look at the DNS names of these ELBs in the AWS console and plug those into https://github.com/18F/cg-provision/blob/master/terraform/stacks/dns/stack.tf For the new dev env, you can edit the entries that have
- Setup peering between bootstrap and main tooling:
./scripts/bootstrap/04-bootstrap-terraform-peering.sh
- If terraform fails with
InvalidGroup.NotFound: You have specified two resources that belong to different networks
, re-run the bootstrap job. Peering isn't consistently complete before security groups across VPCs are added. - Run
terraform-provision/bootstrap-tooling
again to runinit-bosh-db
. - Run the development, or staging and produ to
address your specific situation.ction plan and bootstrap jobs.
init-bosh-db
andinit-cf-db
will fail. This is fine, you'll run again in main concourse.
- If terraform fails with
- Generate secrets for bosh and concourse:
./scripts/bootstrap/05-generate-secrets.sh
- Deploy master bosh:
./scripts/bootstrap/06-deploy-bosh.sh
- Upload custom bosh releases to
${BOSH_RELEASES_BUCKET}
with aws cli. Get the latest release of each type fromcloud-gov-bosh-releases
if you are building out a dev environment.- TODO: bootstrap custom bosh releases
- This might help:
mkdir -p /tmp/releases awk '/-[0-9]*.tgz$/ {print $4}' /tmp/releases.out | \ sed 's/\(.*\)-[0-9.]*.tgz/\1/' | \ sort -u | \ while read line ; do sort -n /tmp/releases.out | \ awk '{print $4}' | egrep "^${line}.*tgz" | \ tail -1 done | \ while read release ; do echo aws s3 cp s3://cloud-gov-bosh-releases/"${release}" /tmp/releases/ done <set up your AWS creds for the new account> aws s3 sync /tmp/releases s3://cloud-gov-bosh-releases-dev --sse AES256
- Run
deploy-bosh/common-releases-master
anddeploy-bosh/deploy-tooling-bosh
- If you get a "x509: certificate signed by unknown authority" error, you will need to add the root CA cert generated to the
tmp/concourse-environment.yml
file in thecommon_ca_cert_store
section. You can get the root cert by looking atecho "" |openssl s_client -connect opslogin.<domain>:443 -showcerts
. After you add it, rerun the 06 deploy script.
- Upload custom bosh releases to
- Deploy permanent concourse:
./scripts/bootstrap/07-deploy-concourse.sh
- Verify main concourse comes up.
- The hostname can be found in
terraform/stacks/dns/stack.tf
Search for:cloud_gov_ci_dev2_cloud_gov_a
in there for the dev env, for example. - The username/pw can be found by getting the
CONCOURSE_SECRETS_PASSPHRASE
fromenv.sh
and using it like so:INPUT_FILE=/tmp/concourse-tooling-prod.yml OUTPUT_FILE=/tmp/concourse-tooling-prod-decrypted.yml PASSPHRASE=XXX ../cg-pipeline-tasks/decrypt.sh grep basic_auth /tmp/concourse-tooling-prod-decrypted.yml rm /tmp/concourse-tooling-prod-decrypted.yml /tmp/concourse-tooling-prod.yml
- Teardown bootstrap and terraform stack:
./scripts/bootstrap/teardown.sh
- From the permanent concourse: Fly
cg-provision/ci/pipeline.yml
with the credentials you used to log into the concourse UI above.fly --target TARGET login --concourse-url=https://HOSTNAME/ --ca-cert tmp/realconcourse-cacrt.pem --username USERNAME --password XXX
fly -t TARGET set-pipeline -p terraform-provision -c ci/pipeline<maybe -development>.yml -l ci/concourse-defaults.yml -l tmp/cg-provision.yml
- Select and unpause the
terraform-provision
pipeline in the UI. - Run the
plan-bootstrap-tooling
job and verify there are no changes. - Run the development, or staging and production plan and bootstrap jobs and verify they complete successfully.
- Iteratively stand up the rest of the infrastructure in the same way, starting with
cg-deploy-bosh
and continuing with additional Concourse pipelines as necessary in the appropriatecg-
GitHub repositories:- Update secrets for the environment and encrypt/upload to secrets bucket.
- Update and upload the concourse pipeline credentials.
- Fly the pipeline.
- Verify the pipeline runs successfully.
- Delete all deployments managed by bosh: (development or staging and production, tooling, master)
- Run
bosh -d ${deployment_name} delete-deployment
for all deployments inbosh deployments
- Run
- Bring up a bootstrap concourse instance as described above:
- Run
01-bootstrap-terraform.sh
,02-bootstrap-concourse.sh
,03-main-terraform.sh
- If your bootstrap concourse already has peering to tooling VPC, run
01-bootstrap-terraform.sh
again to disable.
- Run
- From the web UI in your bootstrap concourse, run
terraform-provision/destroy-*
for development, or staging and production. - Run
destroy-tooling
in theterraform-provision
pipeline. - Teardown bootstrap concourse and terraform stack:
./scripts/bootstrap/teardown.sh
- Delete the
${TF_STATE_BUCKET}
,${VARZ_BUCKET}
,${SEMVER_BUCKET}
, and${BOSH_RELEASES_BLOBSTORE_BUCKET}
through the AWS console.