Skip to content

CivCloud: Deploying a Project

James Lott edited this page Aug 5, 2020 · 2 revisions

New Project

Each new project deployment will require or accept the following parameters:

  • PROJECT_GIT_URL (required): A URL to the git repository of the project
  • PROJECT_GIT_REF (required): The git ref to be deployed
  • PROJECT_NAME (defaults to repository name): The name of the project
  • COMPOSE_FILE (defaults to docker-compose.yml): The subpath within the repo at which an annotated docker-compose file can be found

These parameters should be specified via the environment, then the project-intake.yml playbook should be executed.

unset  PROJECT_GIT_URL
unset  PROJECT_GIT_REF
export PROJECT_GIT_URL='https://github.com/lottspot/prevention-point.git'
export PROJECT_GIT_REF=platform-testing
cd $OPS_REPO_DIR/ansible
../script/console ansible-playbook project-intake.yml

This will clone the project locally into the ansible/projects/[PROJECT_NAME]/repo directory, consume the specified docker-compose file (sample annotated docker-compose.yml), and produce project resource definitions in ansible/projects/[PROJECT_NAME]/resources.

Once project-intake.yml has executed, the next step is to configure placement information for the project, including which node to place the project on and how many replicas of each service to deploy on the node.

# ansible/inventory/hostvars/prevention-point.yml
project_placement:
  - { node: docker-965f, svc_counts: {db: 1, app: 1, client: 1} }

Once the intake playbook has been run, and the project has been placed, the next step is to execute projects-deploy.yml.

cd $OPS_REPO_DIR/ansible
../script/console ansible-playbook projects-deploy.yml -l 'prevention-point.*' # We add the extra -l to limit actions to a specific project

Deploy New Project Version

The steps are virtually identical to new project deployment, but without having to place the project.

cd $OPS_REPO_DIR/ansible
PROJECT_GIT_URL='https://github.com/lottspot/prevention-point.git' PROJECT_GIT_REF=updated-version ../script/console ./project-intake.yml
../script/console ansible-playbook projects-deploy.yml -l 'prevention-point.*'

Pipelining the Workflow

The ingest->deployment process is intentionally multi-step to allow different pipelines to be run which will handle each step. This allows for a pipeline to be run which can create and commit project resources into a source control repository, and a second separate pipeline to consume source-controlled results and perform the actual project deployment.

Clone this wiki locally