This repository contains code and documentation for configuring infrastructure managed by the NYC Planning Labs team. The parts that get modified most frequently:
playbooks/
: Ansible playbooks to configure DigitalOcean Droplets. Explanations of the playbooks below.roles/internal/
: Custom Ansible roles for code shared across playbooksrequirements.yml
: List of third-party Ansible roles, which get installed to roles/external/
.circleci/config.yml
: Configuration for continuous integration/deployment with CircleCIInstall dependencies.
Python 3
NOTE: You may need to install certificates to avoid an SSL error:
sudo /Applications/Python\ 3.6/Install\ Certificates.command
Install Ansible and its dependencies.
pipenv install
pipenv run ansible-galaxy install -p roles/external -r requirements.yml
To run against a live server:
Do the one-time credential setup.
Save your token to a digital_ocean.ini
configuration file.
[digital_ocean]
api_token=TOKEN
Enable the virtualenv.
pipenv shell
Set the Digital Ocean environment variable. _This is required because Digital Ocean modules can't read from the digital_ocean.ini
file._
export $(./digital_ocean.py --env)
Run one of the playbooks. You will use root
as the USER
on the first run and your GitHub username on subsequent runs, as root
access gets removed.
Any of these can be done as a "dry run" by adding --check
to the end of the command.
Examples of running playbooks for different scenarios:
Test connectivity to the Droplets tagged with labs
.
ansible labs -i digital_ocean.py -u USER -m command --args uptime
Configure a Droplet with the real Ansible playbook.
ansible-playbook -i digital_ocean.py -u USER -l DROPLET_NAME playbooks/base.yml
Configure all labs
Droplets with the real Ansible playbook.
ansible-playbook -i digital_ocean.py -u USER -l labs playbooks/base.yml
users
variable in the variables file.users
to former_users
variable in the variables file.Every server/Droplet should:
labs
*.planning.nyc.gov
domain is going to be pointed at itcommon
roleBe careful not to check secrets into this repository.