Updating the Staging and Production Servers - DDMAL/CantusDB GitHub Wiki
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-dbrepository. Make a pull request that adds the new user to theroles/users/vars/main.ymlfile 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 theserver-setup.ymlplaybook according to the ansible repo README. - To remove a user, remove them from the
roles/users/vars/main.ymlfile. 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 theuserdelcommand).
Updating the application
- In your local terminal, navigate to your clone of the
ansible.cantus-dbrepository. - Ensure you have set up your local ansible environment according to the instructions in the
ansible.cantus-dbREADME. 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 theansible.cantus-dbREADME. - Run the
server-setup.ymlplaybook 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.orgfor Production orstaging.cantusdatabase.orgfor 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 thehttps://version of the same website. - If you just updated Production, try to visit
mass.cantusdatabase.organd ensure it redirects tocantusdatabase.org. Ensure thatwww.cantusdatabase.orgalso redirects tocantusdatabase.org - If you just updated Staging, try to visit
staging-alias.cantusdatabase.organd ensure it redirects tostaging.cantusdatabase.org
- SSH into the remote machine. In the terminal, run
sudo crontab -u cantusdb -lto list current cron jobs for usercantusdb, 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!