Skip to content

Instantly share code, notes, and snippets.

@sfgov-mikela
Last active August 26, 2024 22:57
Show Gist options
  • Save sfgov-mikela/fc0948c943ce36c2aa783582143fdc19 to your computer and use it in GitHub Desktop.
Save sfgov-mikela/fc0948c943ce36c2aa783582143fdc19 to your computer and use it in GitHub Desktop.
# Set this environment variable using the Circle CI admin
# TOWER_OAUTH_TOKEN="<access token value>"
version: 2.1
jobs:
deploy_to_aws:
docker:
- image: continuumio/miniconda3
steps:
- run:
command: |
export TOWER_HOST="awx.api.sf.gov"
declare -A branch_to_job=( ["production"]="111" ["staging"]="222" ["dev"]="333")
export JOB_ID = ${branch_to_job[${CIRCLE_BRANCH}]}
pip install ansible-tower-cli
tower-cli job launch --job-template=$JOB_ID --extra-vars="" --wait --monitor
workflows:
on_commit:
jobs:
- deploy_to_aws:
filters:
branches:
only:
- production
- staging
- dev
@paulsheldrake
Copy link

paulsheldrake commented Aug 26, 2024

Hey Folks

Here is a video on how to:

  1. Find the job number so your branch builds to the correct template
  2. Generate a token that can be set as an environment variable or in your contexts

https://www.loom.com/share/eb82f71ab86d4d75b438af960c63cf55?sid=4af7eb48-fa86-4414-975c-85235a63937b

Here is a link to my changes to the original gist that sets the Tower environment variable and docker authentication

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment