Build the docker image
docker-compose build --no-cache
cp docker-compose.override.yml.example docker-compose.override.yml
and set it up.
You should need to do this only once...
-
Check that your VPN is working and you can access the reference server.
-
Set the correct SSH hostname in inventory/production.yml.
-
Set the correct credentials and information regarding the GitHub Deployments in .env
cp .env.template .env vi .env
-
Run the container (this opens a shell):
docker-compose run --rm ansible-obs
-
Check the diff of the changes you are going to introduce
bin/obs_deploy check-diff
-
Check if there is a
monkey patch
in the server and act accordingly. Check the content of/etc/motd
. -
Deploy using the correct playbook, they are described below.
ansible-playbook -i inventory/production.yml $playbook
-
Or check out the other things you can do with
obs_deploy
andogd
bin/obs_deploy -h ... bin/ogd --help
Depending on what you deploy, we have some different playbooks...
Most of our deployments only contain code changes that don't introduce any changes on the database schema, data or require downtime for any other reasons.
ansible-playbook -i inventory/production.yml deploy_without_migration.yml
If we detect that there is any schema or data migration in the deployment, this will abort. If that is the case, check the other options below.
Many database/data migrations are non-disruptive and therefore don't cause downtimes. This playbook will not put the OBS into maintenance mode and apply the migrations online.
ansible-playbook -i inventory/production.yml deploy_with_migration_without_downtime.yml
In many cases, database migrations require to stop all interactions of the application with the database while they are getting executed. Therefore causing downtime.
ansible-playbook -i inventory/production.yml deploy_with_migration.yml
If shit has hit the fan, see our production page in the developer wiki
https://github.com/openSUSE/open-build-service/wiki/build.opensuse.org
As far as possible, when you find a bug, act as usual: create a Pull Request, wait for it to be reviewed and merged and then wait until the changes can be deployed.
If you can't wait that long (the bug is destroying data, blocking many users' work or even killing the whole application) then you might need to monkey-patch some fix:
- Block the deployment until you have a proper fix
Note: you can have ogd set up on your machine but it's also ready to be used inside the ansible-obs docker container.
ogd lock --reason "There is a monkey patch in app/blah/blubb.rb"
- Change the code on production (apply the patch)
- Restart passenger
touch ~/api/tmp/restart.txt
to make the server run with the new code - Whatever you patched, open a draft PR with it and attach the monkey patch label
- Point to the PR in
/etc/motd
on productionAPPLIED MONKEY PATCHES ---------------------- Henne: https://github.com/openSUSE/open-build-service/pull/12798
- Once the PR is merged, unblock the deployment
ogd unlock
- Remove things from
/etc/motd
on production