Once a pull request is merged that change is now part of the main codebase. However, it isn't running live on the actual application until it's deployed. Most PUL projects use Capistrano for deployment. Capistrano uses SSH to pull the latest code onto an application server, prep a fresh version of the application (by, for example, building a new javascript deliverable, and clearing the cache), and then restarting the application web server (usually passenger) and any other services running the application, like sidekiq workers or queue-subscribing processes.
Capistrano can be run on a command line from within a project on your local machine. But we prefer to run it via ansible-tower to ensure greater visibility of deploys (via standardized slack and github integrations) and easier pairing to troubleshoot when deploys fail.
- ask ansible-tower to deploy your code
- ansible-tower runs the deployment appdeploy.princeton.edu
- You are notifed via slack when the deployment completes
- To deploy code using Ansible Tower: Go to https://ansible-tower.princeton.edu/ and log in using CAS.
- Go to Resources -> Templates in the left sidebar.
- To the right of "Capistrano deploy", click on the little rocket ship to Launch the template. (Alternatively, click on “Capistrano deploy” and then click the "Launch" button at the bottom of the page.)
- On the next screen, pick the verbosity you want (it defaults to ‘normal’ but you can use this to debug).
- On the next screen, select your options:
- use the dropdown to pick the repository you want to deploy
- (optional) if you are not deploying the “main” branch, replace “main” with the name of your branch
- (optional) if you are not deploying to the “staging” environment, use the dropdown to pick the environment you want
- (optional) if you want slack alerts for this job to go to a channel other than “ansible-alerts”, use the dropdown to pick the slack channel
- Click Next to reach the review screen.
- Click Launch to launch the job.
- Refresh the page periodically to watch progress or click on
Back to jobs
(or onJobs
in the left sidebar) , click on a job to see details.
- In Slack, add the TowerNotifications bot to the channel
- in the channel, type
@TowerNotifications
- if the bot is not in that channel yet, it should show a ‘Not in channel’ message to the right of the bot name - enter your message to the bot to invite the bot into the channel
- in the channel, type
- In Ansible Tower, add the slack channel to the Capistrano deploy template’s Survey question
- Go to
Resources => Templates
and selectCapistrano deploy
- Select the Survey pane on the far right
- Click on the question ‘What slack channel do you want alerts to go to?’ to edit it
- Click at the end of the last entry under ‘Multiple Choice Options’ and hit ‘Enter’ to open a new line
- Click on the new line and enter the value you want to add - every slack channel must begin with ‘#’
- Go to
- In Ansible Tower, add the new repository to the Capistrano deploy template’s Survey question
- Go to
Resources => Templates
and selectCapistrano deploy
- Select the Survey pane on the far right
- Click on the question ‘Which repo do you want to deploy?’ to edit it
- Click at the end of the last entry under ‘Multiple Choice Options’ and hit ‘Enter’ to open a new line
- Click on the new line and enter the value you want to add - the repository name here must match the repository name in GitHub
- Go to
The connection from Tower to Slack (including the auth token) is configured in the PUL slack org: https://api.slack.com/apps.
- Add the gem to the list of gems here
- Generate a PR for your change in priceton ansible
- Run the towerdeploy playbook from princeton ansible
ansible-playbook playbooks/towerdeploy
- verify the PR fixed your issue and request for it to be merged
Ping the #infrastructure
channel to be added to the ansible tower group