Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Gitlab Cookbook

You're reading from   Gitlab Cookbook Over 60 hands-on recipes to efficiently self-host your own Git repository using GitLab

Arrow left icon
Product type Paperback
Published in Dec 2014
Publisher
ISBN-13 9781783986842
Length 172 pages
Edition 1st Edition
Arrow right icon
Author (1):
Arrow left icon
Jeroen van Baarsen Jeroen van Baarsen
Author Profile Icon Jeroen van Baarsen
Jeroen van Baarsen
Arrow right icon
View More author details
Toc

Table of Contents (11) Chapters Close

Preface 1. Introduction and Installation FREE CHAPTER 2. Explaining Git 3. Managing Users, Groups, and Permissions 4. Issue Tracker and Wiki 5. Maintaining Your GitLab Instance 6. Webhooks, External Services, and the API 7. Using LDAP and OmniAuth Providers 8. GitLab CI A. Tips and Tricks Index

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…

  1. We start with downloading some server dependencies:
    sudo apt-get update && sudo apt-get install -y build-essential git curl
    
  2. Download the chef-solo file:
    curl -o /tmp/solo.json https://gitlab.com/gitlab-org/cookbook-gitlab/raw/master/solo.json.production_example
    
  3. We have to edit the file we just downloaded so that it fits our needs:
    vi /tmp/solo.json
    
  4. 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"
      ]
    }
  5. 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
    
  6. Now, we download the GitLab source from gitlab.com:
    git clone https://gitlab.com/gitlab-org/cookbook-gitlab.git /tmp/cookbook-gitlab
    
  7. Install all the GitLab-specific dependencies:
    cd /tmp/cookbook-gitlab; /opt/chef/embedded/bin/berks vendor /tmp/cookbooks
    
  8. We need to create one more Chef config file:
    vi /tmp/solo.rb
    
  9. Add the following content to the preceding config file:
    cookbook_path    ["/tmp/cookbooks/"]
    log_level        :debug
  10. Save the file.
  11. 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.

You have been reading a chapter from
Gitlab Cookbook
Published in: Dec 2014
Publisher:
ISBN-13: 9781783986842
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image