Skip to content

Updating the Staging and Production Servers

Dylan Hillerbrand edited this page Oct 11, 2024 · 52 revisions

Deployment to remote servers is done through ansible playbooks. Do not deploy on these servers manually; if you need to make a change to the deployment procedures, make those changes in the ansible playbooks so the remote environment is documented!

Modifying VM users

  • Add users to the staging and production machines through the ansible.cantus-db repository. Make a pull request that adds the new user to the roles/users/vars/main.yml file in the model of those entries that are already listed. Be sure that you paste you public ssh key here. Never post your private ssh key. Run the server-setup.yml playbook according to the ansible repo README.
  • To remove a user, remove them from the roles/users/vars/main.yml file. This will stop creation of this user on future runs, but will not actually remove the user from the VM. For the time being, removal of a user is done manually (ssh into server, and use the userdel command).

Updating the application

  • In your local terminal, navigate to your clone of the ansible.cantus-db repository.
  • Ensure you have set up your local ansible environment according to the instructions in the ansible.cantus-db README. If you are updating an existing server, that server should be properly set up already; if you are deploying to a new server, ensure it has been set up according to the instructions in the ansible.cantus-db README.
  • Run the server-setup.yml playbook as detailed in Deployment section of the README.

At this point, the app is running, and you should be able to visit it in the browser. Do so, and visit a few different pages to ensure everything is running properly.

NOTE: If you are deploying to a new server, you'll need to populate the new server with data. See the Populating the database section for instructions.

Testing the changes

At this point, you should do the following to ensure nothing subtle has broken to run the tests just to ensure that nothing subtle has broken:

  • In a browser, visit the website, either cantusdatabase.org for Production or staging.cantusdatabase.org for Staging.
    • If you haven't already, click through a few pages and ensure everything is loading properly.
    • Try logging out and logging in again.
    • Find a test source, make a small edit to it, and save. Make sure it saves as expected.
    • visit the login page and initiate an update-password request. In the email you receive, ensure that the details of the website (its domain and its name) are correct. (If you have recently taken a database dump from Production and plugged it into Staging, for example, this might have broken)
    • Try visiting the http:// version of the site in question. Ensure it redirects to the https:// version of the same website.
    • If you just updated Production, try to visit mass.cantusdatabase.org and ensure it redirects to cantusdatabase.org. Ensure that www.cantusdatabase.org also redirects to cantusdatabase.org
    • If you just updated Staging, try to visit staging-alias.cantusdatabase.org and ensure it redirects to staging.cantusdatabase.org
  • SSH into the remote machine. In the terminal, run sudo crontab -u cantusdb -l to list current cron jobs for user cantusdb, and make sure desired cron jobs are present

If you just updated the Production server, make sure the changelog is up-to-date with the time the new code went live. Congratulations - you've just updated the staging or production server!