Ansible DebOps and how to move Gitlab to it

erstellt von Steffen Lindner zuletzt geändert: 2015-03-24T14:09:17+01:00
Comments
This howto shows how to move a non-debops Gitlab installation to a debops-managed installation (and let debops do upgrades).

For some time we manage our infrastructure with Ansible, mainly we plugged together several roles from the Ansible Galaxy (the pypi of Ansible roles). It helped us get our servers into a better state without that much effort. Portknox.net our ownCloud Hosting benefits a lot from this move.

In search for a Jenkins role, we discovered Debops. DebOps is "a collection of Ansible playbooks, scalable from one container to an entire data center." It does not have a Jenkins role yet (we are working on it), but it really shines in Debian/Ansible best-practices and well developed and integrated Playbooks. Maciej Delmanowski the inital creator of DebOps is outstanding helpful and constantly pushing new features and roles.

Recently we transfered two Gitlab installations (and updated it). Here is how we did it:

You need a working debops gitlab install on a new server. See Getting started and debops.gitlab.

To be able to import a backup both Gitlab Installations need be the same version (and same database):

On the old server:

$ su git
$ cd gitlab
$ git rev-parse --verify HEAD
$ 1660aa23e3f6bea8e0de54a420e29953f6bd194f #Save the hash
$ cd gitlab-shell
$ git rev-parse --verify HEAD
$ a3b54457b1cd188981d4d0775fc7acf2fd6aa128 #Save the hash
# Do the backup
$ bundle exec rake gitlab:backup:create RAILS_ENV=production
# Omnibus install
$ gitlab-rake gitlab:backup:create

Transfer the backup from gitlab/tmp/backups/1423229329_gitlab_backup.tar to the new server /var/backups/gitlab.

On the new server:

$ su git
$ cd gitlab
$ GIT_WORK_TREE=/var/local/git/gitlab git checkout -f 1660aa23e3f6bea8e0de54a420e29953f6bd194f
$ cd gitlab-shell
$ GIT_WORK_TREE=/var/local/git/gitlab-shell git checkout -f a3b54457b1cd188981d4d0775fc7acf2fd6aa128
$ cd gitlab
$ mysql # Login into mysql shell
# Drop the fresh gitlab db from newly installed gitlab
$ drop database gitlabhq_production;
$ bundle install
$ bundle exec rake gitlab:backup:restore RAILS_ENV=production BACKUP=1423229329 #With backup timestamp
# Omnibus install
# gitlab-rake gitlab:backup:restore
$ /etc/init.d/gitlab restart
# Check if gitlab is working and your data is there
$ /etc/init.d/gitlab stop
$ cd src/gitlab.com/gitlab-org/gitlab-shell
$ GIT_WORK_TREE=/var/local/git/gitlab-shell git checkout master
$ cd src/gitlab.com/gitlab-org/gitlab
$ GIT_WORK_TREE=/var/local/git/gitlab git checkout master
# Run debops against the host to let it upgrade
$ debops -l <hostname> -t gitlab

Lean back and let DebOps help you with coming upgrades of Gitlab.

Useful links:

Kommentare unterstützt durch Disqus