Using Chef and GitLab Cookbook
You can install GitLab using chef-solo. It allows you to install a server and all of its dependencies through a pre-programmed script. GitLab Cookbook is also used as the base for the Omnibus Package.
If you want more information on Chef, please take a look at www.getchef.com.
For this recipe, we are going to use a Ubuntu-based installation.
Getting ready
Before we start installing, you need to have a server installed with Ubuntu and have SSH access to the server. Your server needs to have at least 2 GB of RAM to compile all the requirements.
How to do it…
- We start with downloading some server dependencies:
sudo apt-get update && sudo apt-get install -y build-essential git curl
- Download the chef-solo file:
curl -o /tmp/solo.json https://gitlab.com/gitlab-org/cookbook-gitlab/raw/master/solo.json.production_example
- We have to edit the file we just downloaded so that it fits our needs:
vi /tmp/solo.json
- As we will be using PostgreSQL, you can remove the MySQL part. Also, make sure you change the revision to the latest stable branch, 7.3 at time of writing. After you are done, your file should look like the following code, but with your own host and e-mail addresses:
"gitlab": { "host": "gitlab.example.com", "url": "http://gitlab.example.com/", "email_from": "gitlab@example.com", "support_email": "support@gitlab.example.com", "database_adapter": "postgresql", "database_password": "super-secure-password", "revision": "6-9-stable" }, "postgresql": { "password": { "postgres": "psqlpass" } }, "postfix": { "mail_type": "client", "myhostname": "gitlab.example.com", "mydomain": "mydomain.com", "myorigin": "gitlab.example.com", "smtp_use_tls": "no" }, "run_list": [ "postfix", "gitlab::default" ] }
- Next, we download and install Chef to our server:
cd /tmp; curl -LO https://www.opscode.com/chef/install.sh; sudo bash ./install.sh -v 11.4.4; sudo /opt/chef/embedded/bin/gem install berkshelf --no-ri --no-rdoc
- Now, we download the GitLab source from gitlab.com:
git clone https://gitlab.com/gitlab-org/cookbook-gitlab.git /tmp/cookbook-gitlab
- Install all the GitLab-specific dependencies:
cd /tmp/cookbook-gitlab; /opt/chef/embedded/bin/berks vendor /tmp/cookbooks
- We need to create one more Chef config file:
vi /tmp/solo.rb
- Add the following content to the preceding config file:
cookbook_path ["/tmp/cookbooks/"] log_level :debug
- Save the file.
- We are done with configuring everything and now let's install GitLab!
sudo chef-solo -c /tmp/solo.rb -j /tmp/solo.json
How it works…
We just installed GitLab via the Chef cookbook. This way of installation is a little more automated than the installation from source, but it still gives you a bit more control over your installation in comparison to the Omnibus package.
Let's go through the steps that we took to install GitLab in this way.
First, we had to install some server dependencies that were needed to install Chef, and we also cloned the code from GitLab. The dependencies included Curl and Git. We used Curl to download the chef.json
file, and in step 4, to download the check installation file. Git was needed to clone the source of GitLab, and to make sure that GitLab, when installed, is able to serve your repositories.
Next, we had to download the config.json
file. This JSON file keeps the configuration information for GitLab in order to install itself. You can compare this to the gitlab.yml
file from the Installing GitLab from source recipe.
In this recipe, we installed GitLab using PostgreSQL. If you'd prefer to install it with MySQL, that's possible. Just keep in mind that PostgreSQL is the recommended way of running GitLab.
The next step was to download the GitLab source and to install the GitLab dependencies. After we had done that, we created the solo.rb
file. This file is used by chef-solo to know where GitLab Cookbook is located.
The last step was to install GitLab itself. This step took a while because the command also downloaded and compiled Ruby for you.