Skip to content
Snippets Groups Projects
Commit a93bf617 authored by Marin Jankovski's avatar Marin Jankovski
Browse files

Update gitlab cookbook only.

parent 8143f4ec
No related branches found
No related tags found
No related merge requests found
Showing
with 674 additions and 254 deletions
Loading
Loading
@@ -2,4 +2,4 @@ site :opscode
 
metadata
 
cookbook 'magic_shell', git: 'git://github.com/customink-webops/magic_shell.git'
cookbook 'magic_shell', git: 'git://github.com/customink-webops/magic_shell.git', ref: '447b4b67420d3a7a749d2dd3b13a7f9aceb54c36'
Loading
Loading
@@ -12,16 +12,16 @@
"locked_version": "1.7.0"
},
"ulimit": {
"locked_version": "0.3.1"
"locked_version": "0.3.2"
},
"ruby_build": {
"locked_version": "0.8.0"
},
"postgresql": {
"locked_version": "3.1.0"
"locked_version": "3.3.4"
},
"apt": {
"locked_version": "2.2.1"
"locked_version": "2.3.0"
},
"build-essential": {
"locked_version": "1.4.2"
Loading
Loading
@@ -30,22 +30,22 @@
"locked_version": "1.1.0"
},
"mysql": {
"locked_version": "3.0.12"
"locked_version": "2.1.2"
},
"database": {
"locked_version": "1.5.2"
},
"aws": {
"locked_version": "0.101.6"
"locked_version": "1.0.0"
},
"xfs": {
"locked_version": "1.1.0"
},
"postfix": {
"locked_version": "3.0.2"
"locked_version": "3.0.4"
},
"yum": {
"locked_version": "2.3.4"
"locked_version": "2.4.2"
},
"phantomjs": {
"locked_version": "1.0.3"
Loading
Loading
Copyright (c) 2011 Dmitriy Zaporozhets
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
GitLab Cookbook
===============
 
Chef cookbook with recipes to install GitLab.
Chef cookbook with recipes to install GitLab and its dependencies:
 
* GitLab: 6.2
* GitLab Shell: 1.7.4
* Ruby: 2.0.0p247
* GitLab Shell: 1.7.9
* Ruby: 2.0.0p353
* Redis: 2.6.13
* Git: 1.7.12
* Nginx: 1.1.19
* PostgreSQL: 9.1.9
* MySQL: 5.5.31
* MySQL: 5.5.34
 
## Requirements
### Compatible operating systems
 
* [Berkshelf](http://berkshelf.com/)
* [Vagrant](http://www.vagrantup.com/)
### Vagrant Plugin
* [vagrant-berkshelf](https://github.com/RiotGames/vagrant-berkshelf)
* [vagrant-omnibus](https://github.com/schisamo/vagrant-omnibus)
* [vagrant-aws](https://github.com/mitchellh/vagrant-aws)
### Platform:
Cookbook has been tested and it is known to work on:
 
* Ubuntu (12.04, 12.10)
* CentOS (6.4)
* RHEL/CentOS (6.4)
 
## Installation
 
### Vagrant
#### VirtualBox
```bash
$ gem install berkshelf
$ vagrant plugin install vagrant-berkshelf
$ vagrant plugin install vagrant-omnibus
$ git clone git://github.com/gitlabhq/cookbook-gitlab ./gitlab
$ cd ./gitlab/
$ vagrant up
```
#### Amazon Web Services
Creates an AWS instance.
```bash
$ gem install berkshelf
$ vagrant plugin install vagrant-berkshelf
$ vagrant plugin install vagrant-omnibus
$ vagrant plugin install vagrant-aws
$ vagrant box add dummy https://github.com/mitchellh/vagrant-aws/raw/master/dummy.box
$ git clone git://github.com/gitlabhq/cookbook-gitlab ./gitlab
$ cd ./gitlab/
$ cp ./example/Vagrantfile_aws ./Vagrantfile
```
Fill in the AWS credentials under the aws section in Vagrantfile and then run:
* [Development installation on a virtual machine with Vagrant](doc/development.md)
 
```bash
$ vagrant up --provider=aws
```
* [Production installation on Amazon Web Services (AWS) with Vagrant](doc/aws_vagrant.md)
 
HostName setting.
* [Production installation with Chef Solo](doc/production.md)
 
```bash
$ vagrant ssh-config | awk '/HostName/ {print $2}'
$ editor ./Vagrantfile
$ vagrant provision
```
#### AWS OpsWorks
* Create a custom layer or use a predefined `Rails app server` layer.
* Edit the layer
* Under `Custom Chef Recipes` supply the url to the cookbook repository
* Under `Setup` write `gitlab::setup` and press the + sign to add
* Under `Deploy` write `gitlab::deploy` and press the + sign to add
* Save changes made to the layer (Scroll to the bottom of the page for the Save button)
* Go to Instances
* Create a new instance(or use an existing one) and add the previously edited layer
### chef-solo
You can easily install your server even if you don't have chef-server by using chef-solo.
This is useful if you have only one server that you have to maintain so having chef-server would be an overkill.
**Note** Following steps assume that you have git, ruby(> 1.8.7) and rubygems installed.
To get GitLab installed do:
```bash
$ gem install berkshelf
$ cd /tmp
$ curl -LO https://www.opscode.com/chef/install.sh && sudo bash ./install.sh -v 11.4.4
$ git clone https://github.com/gitlabhq/cookbook-gitlab.git /tmp/gitlab
$ cd /tmp/gitlab
$ berks install --path /tmp/cookbooks
$ cat > /tmp/solo.rb << EOF
cookbook_path ["/tmp/cookbooks/", "/tmp/gitlab/"]
log_level :debug
EOF
$ cat > /tmp/solo.json << EOF
{"gitlab": {"host": "HOSTNAME", "url": "http://FQDN:80/"}, "recipes":["gitlab::default"]}
EOF
$ chef-solo -c /tmp/solo.rb -j /tmp/solo.json
```
Chef-solo command should start running and setting up GitLab and it's dependencies.
No errors should be reported and at the end of the run you should be able to navigate to the
`HOSTNAME` you specified using your browser and connect to the GitLab instance.
## Usage
To override default settings of this cookbook you have to supply a json to the node.
```json
{
"postfix": {
"mail_type": "client",
"myhostname": "mail.example.com",
"mydomain": "example.com",
"myorigin": "mail.example.com",
"smtp_use_tls": "no"
},
"postgresql": {
"password": {
"postgres": "psqlpass"
}
},
"mysql": {
"server_root_password": "rootpass",
"server_repl_password": "replpass",
"server_debian_password": "debianpass"
},
"gitlab": {
"host": "example.com",
"url": "http://example.com/",
"email_from": "gitlab@example.com",
"support_email": "support@example.com",
"database_adapter": "postgresql",
"database_password": "datapass"
},
"run_list":[
"postfix",
"gitlab::default"
]
}
```
If you want to do a production installation using AWS Opsworks please see the [cookbook for GitLab on AWS Opsworks repository](https://gitlab.com/gitlab-com/cookbook-gitlab-opsworks/blob/master/README.md).
 
## Database
 
Loading
Loading
@@ -265,28 +145,7 @@ Enables gitlab service and starts GitLab.
 
Creates a GitLab user called `git`.
 
## Done!
`http://localhost:8080/` or your server for your first GitLab login.
```
admin@local.host
5iveL!fe
```
## Development
To use this cookbook to provision a development vagrant box add the following json to the `Vagrantfile` under the `chef.json` section:
```json
***
"gitlab": {
"env": "development",
}
```
## Testing
## Testing the cookbook
 
First install the necessary gems
 
Loading
Loading
@@ -306,26 +165,31 @@ Run tests with:
bundle exec rspec
```
 
## Acknowledgement
## Acknowledgements
This cookbook was based on a [cookbbook by ogom](https://github.com/ogom/cookbook-gitlab). Thank you ogom!
 
This cookbook was based on work by [ogom](https://github.com/ogom/cookbook-gitlab). Thank you ogom!
We would also like to thank Eric G. Wolfe for making the [first cookbook for CentOS](https://github.com/atomic-penguin/cookbook-gitlab). Thank Eric!
 
## Contributing
 
We welcome all contributions.
Proper Merge request must:
 
1. Explain in description what it does
1. Explain which platforms it is run on and which platforms are untested
1. Contain passing `chefspec` tests
 
## Links
 
* [GitLab Installation](https://github.com/gitlabhq/gitlabhq/blob/master/doc/install/installation.md)
* [Qiita Document](http://qiita.com/items/6491a268bfc95d0a5be4)
 
## Authors
* [ogom](https://github.com/ogom)
* [Marin Jankovski](https://github.com/maxlazio)
 
## License
 
* MIT
* [MIT](LICENSE)
# -*- mode: ruby -*-
# vi: set ft=ruby :
 
Vagrant.configure("2") do |config|
# All Vagrant configuration is done here. The most common configuration
# options are documented and commented below. For a complete reference,
# please see the online documentation at vagrantup.com.
config.vm.hostname = "gitlab-berkshelf"
# You can ask for more memory and cores when creating your Vagrant machine:
# GITLAB_VAGRANT_MEMORY=2048 GITLAB_VAGRANT_CORES=4 vagrant up
MEMORY = ENV['GITLAB_VAGRANT_MEMORY'] || '1536'
CORES = ENV['GITLAB_VAGRANT_CORES'] || '2'
 
# Every Vagrant virtual environment requires a box to build off of.
config.vm.box = "opscode-ubuntu-12.04"
Vagrant.configure("2") do |config|
config.vm.hostname = "gitlab-dev"
 
# The url from where the 'config.vm.box' box will be fetched if it
# doesn't already exist on the user's system.
config.vm.box_url = "https://opscode-vm.s3.amazonaws.com/vagrant/opscode_ubuntu-12.04_provisionerless.box"
config.vm.box = "precise64"
config.vm.box_url = "http://files.vagrantup.com/precise64.box"
 
# Assign this VM to a host-only network IP, allowing you to access it
# via the IP. Host-only networks can talk to the host machine as well as
# any other machines on the same network, but cannot be accessed (through this
# network interface) by any external networks.
config.vm.network :private_network, ip: "33.33.33.10"
# Create a public network, which generally matched to bridged network.
# Bridged networks make the machine appear as another physical device on
# your network.
config.vm.network :private_network, ip: "192.168.3.4"
 
# config.vm.network :public_network
# Create a forwarded port mapping which allows access to a specific port
# within the machine from a port on the host machine. In the example below,
# accessing "localhost:8080" will access port 80 on the guest machine.
config.vm.network :forwarded_port, guest: 3000, host: 3000
config.vm.network :forwarded_port, guest: 80, host: 8080
 
# Share an additional folder to the guest VM. The first argument is
# the path on the host to the actual folder. The second argument is
# the path on the guest to mount the folder. And the optional third
# argument is a set of non-required options.
# config.vm.synced_folder "../data", "/vagrant_data"
# We don't need to mount /vagrant directory since we use git user
# Using bindfs to remount synced folder in order to have the correct ownership
config.vm.synced_folder ".", "/vagrant", :disabled => true
config.vm.synced_folder "./home_git", "/git-nfs", :nfs => true
config.bindfs.bind_folder "/git-nfs", "/home/git", :owner => "1111", :group => "1111", :'create-as-user' => true, :perms => "u=rwx:g=rwx:o=rwx", :'create-with-perms' => "u=rwx:g=rwx:o=rwx", :'chown-ignore' => true, :'chgrp-ignore' => true, :'chmod-ignore' => true
 
# Provider-specific configuration so you can fine-tune various
# backing providers for Vagrant. These expose provider-specific options.
# Example for VirtualBox:
config.vm.provider :virtualbox do |vb|
config.vm.provider :virtualbox do |v|
# Use VBoxManage to customize the VM. For example to change memory:
vb.customize ["modifyvm", :id, "--memory", "1024"]
v.customize ["modifyvm", :id, "--memory", MEMORY.to_i]
v.customize ["modifyvm", :id, "--cpus", CORES.to_i]
if CORES.to_i > 1
v.customize ["modifyvm", :id, "--ioapic", "on"]
end
end
 
# View the documentation for the provider you're using for more
# information on available options.
config.vm.provider :vmware_fusion do |v, override|
override.vm.box_url = "http://files.vagrantup.com/precise64_vmware.box"
v.vmx["memsize"] = MEMORY
v.vmx["numvcpus"] = CORES
end
 
# Install the version of Chef by the Vagrant Omnibus
# version is :latest or "11.4.0"
Loading
Loading
@@ -57,24 +50,20 @@ Vagrant.configure("2") do |config|
# AWS OpsWorks supports
config.omnibus.chef_version = "11.4.0"
 
# The path to the Berksfile to use with Vagrant Berkshelf
# config.berkshelf.berksfile_path = "./Berksfile"
# Enabling the Berkshelf plugin. To enable this globally, add this configuration
# option to your ~/.vagrant.d/Vagrantfile file
config.berkshelf.enabled = true
 
# An array of symbols representing groups of cookbook described in the Vagrantfile
# to exclusively install and copy to Vagrant's shelf.
# config.berkshelf.only = []
# An array of symbols representing groups of cookbook described in the Vagrantfile
# to skip installing and copying to Vagrant's shelf.
# config.berkshelf.except = []
config.vm.provision :chef_solo do |chef|
chef.json = {
# Specify attributes you want to override here
"gitlab" => {
"env" => "development",
"user_uid" => 1111,
"user_gid" => 1111
},
"phantomjs" => {
"version" => "1.8.1"
}
}
chef.run_list = [
"apt",
Loading
Loading
@@ -86,3 +75,8 @@ Vagrant.configure("2") do |config|
# chef.arguments = '-l debug'
end
end
# The script will login "git" user right away when doing "vagrant ssh"
Vagrant.configure("2") do |config|
config.vm.provision :shell, :path => "./git_login.sh"
end
Loading
Loading
@@ -9,22 +9,26 @@ else
packages = %w{
build-essential zlib1g-dev libyaml-dev libssl-dev libgdbm-dev libreadline-dev libncurses5-dev libffi-dev
curl openssh-server checkinstall libxml2-dev libxslt-dev libcurl4-openssl-dev libicu-dev python-docutils
logrotate
logrotate vim curl wget checkinstall
}
end
 
default['gitlab']['packages'] = packages
default['gitlab']['ruby'] = "2.0.0-p247"
default['gitlab']['ruby'] = "2.0.0-p353"
 
# GitLab shell
default['gitlab']['shell_repository'] = "https://github.com/gitlabhq/gitlab-shell.git"
default['gitlab']['shell_revision'] = "v1.7.4"
default['gitlab']['shell_revision'] = "v1.7.9"
 
# GitLab hq
default['gitlab']['repository'] = "https://github.com/gitlabhq/gitlabhq.git"
 
# GitLab shell config
default['gitlab']['url'] = "http://localhost:8080/"
if node['gitlab']['env'] == "production"
default['gitlab']['url'] = "http://localhost:8080/"
else
default['gitlab']['url'] = "http://localhost:3000/"
end
default['gitlab']['redis_path'] = "/usr/local/bin/redis-cli"
default['gitlab']['redis_host'] = "127.0.0.1"
default['gitlab']['redis_port'] = "6379"
Loading
Loading
@@ -33,12 +37,16 @@ default['gitlab']['namespace'] = "resque:gitlab"
# GitLab hq config
default['gitlab']['git_path'] = "/usr/local/bin/git"
default['gitlab']['host'] = "localhost"
default['gitlab']['port'] = "80"
if node['gitlab']['env'] == "production"
default['gitlab']['port'] = "80"
else
default['gitlab']['port'] = "3000"
end
default['gitlab']['email_from'] = "gitlab@localhost"
default['gitlab']['support_email'] = "support@localhost"
 
# Gems
default['gitlab']['bundle_install'] = "bundle install --path=.bundle --deployment"
default['gitlab']['bundle_install'] = "SSL_CERT_FILE=/opt/local/etc/certs/cacert.pem bundle install --path=.bundle --deployment"
 
# Assumed defaults
# database: mysql (option: postgresql)
Loading
Loading
@@ -59,3 +67,32 @@ default['postfix']['myhostname'] = "mail.localhost"
default['postfix']['mydomain'] = "localhost"
default['postfix']['myorigin'] = "mail.localhost"
default['postfix']['smtp_use_tls'] = "no"
# User
default['gitlab']['user'] = "git" # Do not change this attribute in production since some code from the GitLab repo such as init.d script assume it is git.
default['gitlab']['group'] = "git"
default['gitlab']['home'] = "/home/git"
# GitLab shell
default['gitlab']['shell_path'] = "/home/git/gitlab-shell"
# GitLab hq
if node['gitlab']['env'] == "production"
default['gitlab']['revision'] = "6-3-stable"
else
default['gitlab']['revision'] = "master"
end
default['gitlab']['path'] = "/home/git/gitlab" # Do not change this attribute in production since some code from the GitLab repo such as init.d assume this path.
# GitLab shell config
default['gitlab']['repos_path'] = "/home/git/repositories"
# GitLab hq config
default['gitlab']['satellites_path'] = "/home/git/gitlab-satellites"
# Setup environments
if node['gitlab']['env'] == "production"
default['gitlab']['environments'] = %w{production}
else
default['gitlab']['environments'] = %w{development test}
end
### Production installation on Amazon Web Services (AWS) with Vagrant
### Requirements
* [VirtualBox](https://www.virtualbox.org)
* [Vagrant 1.3.x](http://vagrantup.com)
Make sure to use Vagrant v1.3.x. Do not install Vagrant via rubygems.org as there exists an old gem which will probably cause errors. Instead, go to [Vagrant download page](http://downloads.vagrantup.com/) and install a version ~> `1.3.0`.
### Installation
Create an AWS instance:
```bash
gem install berkshelf
vagrant plugin install vagrant-berkshelf
vagrant plugin install vagrant-omnibus
vagrant plugin install vagrant-aws
vagrant box add dummy https://github.com/mitchellh/vagrant-aws/raw/master/dummy.box
git clone https://gitlab.com/gitlab-org/cookbook-gitlab.git ./gitlab
cd ./gitlab/
cp ./example/Vagrantfile_aws ./Vagrantfile
```
Fill in the AWS credentials under the aws section in Vagrantfile and then run:
```bash
vagrant up --provider=aws --provision
```
HostName setting:
```bash
vagrant ssh-config | awk '/HostName/ {print $2}'
editor ./Vagrantfile
vagrant provision
```
For more information on how to run the application, the tests and more please see the [Development installation on a virtual machine](doc/development.md).
### Development installation on a virtual machine with Vagrant
### Requirements
* [VirtualBox](https://www.virtualbox.org)
* [Vagrant 1.3.x](http://vagrantup.com)
* The NFS packages for the synced folder of Vagrant. These are already installed if you are using Mac OSX and not necessary if you are using Windows. On Linux install them by running:
```bash
sudo apt-get install nfs-kernel-server nfs-common portmap
```
Make sure to use Vagrant v1.3.x. Do not install Vagrant via rubygems.org as there exists an old gem which will probably cause errors. Instead, go to [Vagrant download page](http://downloads.vagrantup.com/) and install a version ~> `1.3.0`.
On OS X you can also choose to use [the (commercial) Vagrant VMware Fusion plugin](http://www.vagrantup.com/vmware) instead of VirtualBox.
### Installation
`Vagrantfile` already contains the correct attributes so in order use this cookbook in a development environment following steps are needed:
1. Check if you have a gem version of Vagrant installed:
```bash
gem list vagrant
```
If it lists a version of vagrant, remove it with:
```bash
gem uninstall vagrant
```
Next steps are:
```bash
gem install berkshelf
vagrant plugin install vagrant-berkshelf
vagrant plugin install vagrant-omnibus
vagrant plugin install vagrant-bindfs
git clone https://gitlab.com/gitlab-org/cookbook-gitlab.git
cd ./cookbook-gitlab
vagrant up --provision
```
By default the VM uses 1.5GB of memory and 2 CPU cores. If you want to use more memory or cores you can use the GITLAB_VAGRANT_MEMORY and GITLAB_VAGRANT_CORES environment variables:
```bash
GITLAB_VAGRANT_MEMORY=2048 GITLAB_VAGRANT_CORES=4 vagrant up
```
**Note:**
You can't use a vagrant project on an encrypted partition (ie. it won't work if your home directory is encrypted).
You'll be asked for your password to set up NFS shares.
### Running the tests
Once everything is done you can log into the virtual machine to run tests:
```bash
vagrant ssh
sudo su git
cd /home/git/gitlab/
bundle exec rake gitlab:test
```
### Start the Gitlab application
```bash
cd /home/git/gitlab/
bundle exec foreman start
```
You should also configure your own remote since by default it's going to grab
gitlab's master branch.
```bash
git remote add mine git://github.com/me/gitlabhq.git
# or if you prefer set up your origin as your own repository
git remote set-url origin git://github.com/me/gitlabhq.git
```
##### Virtual Machine Management
When done just log out with `^D` and suspend the virtual machine
```bash
vagrant suspend
```
then, resume to hack again
```bash
vagrant resume
```
Run
```bash
vagrant halt
```
to shutdown the virtual machine, and
```bash
vagrant up
```
to boot it again.
You can find out the state of a virtual machine anytime by invoking
```bash
vagrant status
```
Finally, to completely wipe the virtual machine from the disk **destroying all its contents**:
```bash
vagrant destroy # DANGER: all is gone
```
#### Done!
`http://0.0.0.0:3000/` or your server for your first GitLab login.
```
admin@local.host
5iveL!fe
```
### OpenLDAP
If you need to setup OpenLDAP in order to test the functionality you can use the [basic OpenLDAP setup guide](doc/open_LDAP.md)
### Updating
The gitlabhq version is _not_ updated when you rebuild your virtual machine with the following command:
```bash
vagrant destroy && vagrant up
```
You must update it yourself by going to the gitlabhq subdirectory in the gitlab-vagrant-vm repo and pulling the latest changes:
```bash
cd gitlabhq && git pull --ff origin master
```
A bit of background on why this is needed. When you run 'vagrant up' there is a checkout action in the recipe that points to [gitlabhq repo](https://github.com/gitlabhq/gitlabhq). You won't see any difference when running 'git status' in the cookbook-gitlab repo because the cloned directory is in the [.gitignore](https://gitlab.com/gitlab-org/cookbook-gitlab/blob/master/.gitignore). You can update the gitlabhq repo yourself or remove the home_git so the repo is checked out again.
Gitlab-Vagrant-VM OpenLDAP setup
=================
Description
-----------
This guide will help you setup OpenLDAP in case you need an LDAP server in your dev environment for GitLab.
The reason why OpenLDAP is not installed by default in GitLab-Vagrant-VM is that it would extend the time needed for creating the dev box and not everyone needs LDAP.
However, it would be great if somebody could add this as a recipe to the Chef cookbook so it is installed automatically.
# Important notes
This guide is very basic and any improvements are welcome!
**Note:**
During this installation some files will need to be edited manually.
If you are familiar with vim set it as default editor with the commands below.
If you are not familiar with vim please skip this and keep using the default editor.
# Install vim and set as default editor
sudo apt-get install -y vim
sudo update-alternatives --set editor /usr/bin/vim.basic
Setup
-----------
Login to your Vagrant machine
```bash
vagrant ssh
```
Add LDAP domain name to `/etc/hosts`
```bash
sudo editor /etc/hosts
```
and populate it with:
```
192.168.3.14 ldap.gitlab.dev ldap gitlab.dev
```
Update packages:
```bash
sudo apt-get update
```
and install required:
```bash
sudo apt-get install slapd ldap-utils -y
```
This will prompt a setup window so we need to populate it with the correct credentials.
When asked for administrator password use `gitlabldap`.
Repeat the password to confirm it.
We will use the advantage of slapd setup to fully configure LDAP instead of filling in the details by hand in a text file:
```bash
sudo dpkg-reconfigure slapd
```
Answer the following questions:
You will be asked to omit OpenLDAP server configuration: `No`
Under DNS domain name fill in: `gitlab.dev`
Under organization name fill in: `gitlab.dev`
Under administrator password fill in: `gitlabldap`
Repeat password: `gitlabldap
Database backend to use, select: `HDB`
Do you want database to be removed when slapd is purged: `Yes`
Move old database, choose: `Yes`
Allow LDAPv2 protocol, choose: `No`
** If at any point you get the error: **
```
ldap_bind: Invalid credentials (49)
```
configure slapd again.
Next, add index to make lookup easier, create a file index.ldif
```bash
editor index.ldif
```
and populate with the following:
```
dn: olcDatabase={1}hdb,cn=config
changetype: modify
add: olcDbIndex
olcDbIndex: uid eq,pres,sub
```
and add it to ldap database:
```bash
sudo ldapmodify -Q -Y EXTERNAL -H ldapi:/// -f index.ldif
```
This should produce the following output:
```
modifying entry "olcDatabase={1}hdb,cn=config"
```
If this is not the case recheck your steps and try again.
You can verify that all is working:
```bash
sudo ldapsearch -Q -LLL -Y EXTERNAL -H ldapi:/// -b cn=config '(olcDatabase={1}hdb)' olcDbIndex
```
This should produce the following output:
```
dn: olcDatabase={1}hdb,cn=config
olcDbIndex: objectClass eq
olcDbIndex: uid eq,pres,sub
```
If this is not the case recheck your steps and try again.
Next step is to create an ldap user.
Create `base.ldif`
```bash
editor base.ldif
```
and populate with:
```
dn: ou=Users,dc=gitlab,dc=dev
objectClass: organizationalUnit
ou: Users
dn: uid=jsmith,ou=Users,dc=gitlab,dc=dev
objectClass: organizationalPerson
objectClass: person
objectClass: top
objectClass: inetOrgPerson
objectClass: posixAccount
objectClass: shadowAccount
uid: jsmith
sn: Smith
givenName: John
cn: John Smith
displayName: John Smith
uidNumber: 10000
gidNumber: 10000
userPassword: test
gecos: John Smith
loginShell: /bin/bash
homeDirectory: /profiles/jsmith
mail: john.smith@example.com
telephoneNumber: 000-000-0000
st: NY
manager: uid=jsmith,ou=Users,dc=gitlab,dc=dev
shadowExpire: -1
shadowFlag: 0
shadowWarning: 7
shadowMin: 8
shadowMax: 999999
shadowLastChange: 10877
title: System Administrator
```
Add the user to the LDAP database:
```bash
ldapadd -x -D cn=admin,dc=gitlab,dc=dev -w gitlabldap -f base.ldif
```
This should produce the following output:
```
adding new entry "ou=Users,dc=gitlab,dc=dev"
adding new entry "uid=jsmith,ou=Users,dc=gitlab,dc=dev"
```
If this is not the case recheck your steps and try again.
To confirm that the user is in LDAP, use:
```bash
ldapsearch -x -LLL -b dc=gitlab,dc=dev 'uid=jsmith' uid uidNumber displayName
```
and that should produce the output that looks like:
```
dn: uid=jsmith,ou=Users,dc=gitlab,dc=dev
uid: jsmith
displayName: John Smith
uidNumber: 10000
```
This would complete setting up the OpenLDAP server. Only thing that is left to do is to give the correct details to GitLab.
Under `gitlab.yml` there is a LDAP section that should look like this:
```
## LDAP settings
ldap:
enabled: true
host: 'gitlab.dev'
base: 'dc=gitlab,dc=dev'
port: 389
uid: 'uid'
method: 'plain' # "ssl" or "plain"
bind_dn: 'dc=gitlab,dc=dev'
password: 'gitlabldap'
```
Navigate to `/vagrant/gitlabhq/` and start the GitLab instance with:
```
bundle exec foreman start
```
If you now navigate to `http://192.168.3.14:3000/` and fill in the sign in page under the LDAP section with:
`username`: jsmith
`password`: test
you will be authenticated with OpenLDAP server and logged into GitLab.
### Production installation with Chef Solo
This guide details installing a GitLab server with Chef Solo. By using Chef Solo you do not need a decicated Chef Server.
### Requirements
* git
* ruby (>= 1.9.3)
* rubygems installed.
### Installation
To get GitLab installed do:
```bash
gem install berkshelf
cd /tmp
curl -LO https://www.opscode.com/chef/install.sh && sudo bash ./install.sh -v 11.4.4
git clone https://gitlab.com/gitlab-org/cookbook-gitlab.git /tmp/gitlab
cd /tmp/gitlab
berks install --path /tmp/cookbooks
cat > /tmp/solo.rb << EOF
cookbook_path ["/tmp/cookbooks/", "/tmp/gitlab/"]
log_level :debug
EOF
cat > /tmp/solo.json << EOF
{"gitlab": {"host": "HOSTNAME", "url": "http://FQDN:80/"}, "recipes":["gitlab::default"]}
EOF
chef-solo -c /tmp/solo.rb -j /tmp/solo.json
```
Chef-solo command should start running and setting up GitLab and it's dependencies.
No errors should be reported and at the end of the run you should be able to navigate to the
`HOSTNAME` you specified using your browser and connect to the GitLab instance.
### Usage
Add `gitlab::default` to the run list of chef-client.
To override default settings of this cookbook you have to supply a json to the node.
```json
{
"postfix": {
"mail_type": "client",
"myhostname": "mail.example.com",
"mydomain": "example.com",
"myorigin": "mail.example.com",
"smtp_use_tls": "no"
},
"postgresql": {
"password": {
"postgres": "psqlpass"
}
},
"mysql": {
"server_root_password": "rootpass",
"server_repl_password": "replpass",
"server_debian_password": "debianpass"
},
"gitlab": {
"host": "example.com",
"url": "http://example.com/",
"email_from": "gitlab@example.com",
"support_email": "support@example.com",
"database_adapter": "postgresql",
"database_password": "datapass"
},
"run_list":[
"postfix",
"gitlab::default"
]
}
```
#!/bin/sh
if [ ! -f /etc/motd_vagrant ]; then
echo 'You are now logged in as the git user that runs GitLab, to get sudo privileges please exit to become the vagrant user' >> /etc/motd_vagrant
fi
if [ ! -f /etc/motd_git ]; then
echo 'You are now logged in as the vagrant user' >> /etc/motd_git
fi
if [ ! -f /etc/profile.d/message.sh ]; then
echo '#!/bin/sh' >> /etc/profile.d/message.sh
echo 'cat /etc/motd_$USER' >> /etc/profile.d/message.sh
fi
cat /home/vagrant/.bashrc | grep 'sudo su git' || echo 'sudo su git' >> /home/vagrant/.bashrc
Loading
Loading
@@ -4,11 +4,11 @@ maintainer_email 'marin@gitlab.com'
license 'MIT'
description 'Installs/Configures GitLab'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '0.6.2'
version '0.6.3'
 
recipe "gitlab::default", "Installation"
 
%w{ redisio ruby_build postgresql mysql database postfix yum phantomjs magic_shell }.each do |dep|
%w{ redisio ruby_build postgresql mysql database postfix yum phantomjs magic_shell apt}.each do |dep|
depends dep
end
 
Loading
Loading
Loading
Loading
@@ -5,9 +5,6 @@
 
gitlab = node['gitlab']
 
# Merge environmental variables
gitlab = Chef::Mixin::DeepMerge.merge(gitlab,gitlab[gitlab['env']])
# 6. GitLab
## Clone the Source
git gitlab['path'] do
Loading
Loading
Loading
Loading
@@ -6,9 +6,6 @@
mysql = node['mysql']
gitlab = node['gitlab']
 
# Merge environmental variables
gitlab = Chef::Mixin::DeepMerge.merge(gitlab,gitlab[gitlab['env']])
# 5.Database
include_recipe "mysql::server"
include_recipe "database::mysql"
Loading
Loading
@@ -29,6 +26,8 @@ end
## Create the GitLab database & grant all privileges on database
gitlab['environments'].each do |environment|
mysql_database "gitlabhq_#{environment}" do
encoding "utf8"
collation "utf8_unicode_ci"
connection mysql_connection
action :create
end
Loading
Loading
Loading
Loading
@@ -6,9 +6,6 @@
postgresql = node['postgresql']
gitlab = node['gitlab']
 
# Merge environmental variables
gitlab = Chef::Mixin::DeepMerge.merge(gitlab,gitlab[gitlab['env']])
# 5.Database
include_recipe "postgresql::server"
include_recipe "database::postgresql"
Loading
Loading
Loading
Loading
@@ -7,9 +7,6 @@
 
gitlab = node['gitlab']
 
# Merge environmental variables
gitlab = Chef::Mixin::DeepMerge.merge(gitlab,gitlab[gitlab['env']])
# Fetch GitLab shell source code
include_recipe "gitlab::gitlab_shell_clone"
 
Loading
Loading
@@ -25,8 +22,10 @@ include_recipe "gitlab::gems"
# Configure and install GitLab
include_recipe "gitlab::install"
 
# Start GitLab if in production
include_recipe "gitlab::start"
if gitlab['env'] == 'production'
# Start GitLab if in production
include_recipe "gitlab::start"
 
# Setup and configure nginx
include_recipe "gitlab::nginx" if gitlab['env'] == 'production'
# Setup and configure nginx
include_recipe "gitlab::nginx"
end
Loading
Loading
@@ -5,15 +5,34 @@
 
gitlab = node['gitlab']
 
# Merge environmental variables
gitlab = Chef::Mixin::DeepMerge.merge(gitlab,gitlab[gitlab['env']])
# To prevent random failures during bundle install, get the latest ca-bundle and update rubygems
 
## Install Gems
directory "/opt/local/etc/certs/" do
owner gitlab['user']
group gitlab['group']
recursive true
mode 0755
end
remote_file "Fetch the latest ca-bundle" do
source "http://curl.haxx.se/ca/cacert.pem"
path "/opt/local/etc/certs/cacert.pem"
owner gitlab['user']
group gitlab['group']
mode 0755
action :create_if_missing
end
execute "Update rubygems" do
command "gem update --system"
end
## Install Gems without ri and rdoc
template File.join(gitlab['home'], ".gemrc") do
source "gemrc.erb"
user gitlab['user']
group gitlab['group']
notifies :run, "execute[bundle install]", :immediately
action :create_if_missing
end
 
### without
Loading
Loading
@@ -43,5 +62,10 @@ execute "bundle install" do
cwd gitlab['path']
user gitlab['user']
group gitlab['group']
action :nothing
action :run
not_if { File.exists?(File.join(gitlab['home'], ".gitlab_gems_#{gitlab['env']}")) }
end
file File.join(gitlab['home'], ".gitlab_gems_#{gitlab['env']}") do
action :touch
end
Loading
Loading
@@ -5,9 +5,6 @@
 
gitlab = node['gitlab']
 
# Merge environmental variables
gitlab = Chef::Mixin::DeepMerge.merge(gitlab,gitlab[gitlab['env']])
# 4. GitLab shell
## Clone gitlab shell
git gitlab['shell_path'] do
Loading
Loading
Loading
Loading
@@ -5,9 +5,6 @@
 
gitlab = node['gitlab']
 
# Merge environmental variables
gitlab = Chef::Mixin::DeepMerge.merge(gitlab,gitlab[gitlab['env']])
## Edit config and replace gitlab_url
template File.join(gitlab['shell_path'], "config.yml") do
source "gitlab_shell.yml.erb"
Loading
Loading
@@ -36,12 +33,4 @@ execute "gitlab-shell install" do
user gitlab['user']
group gitlab['group']
action :nothing
notifies :create, "link[create symlink for gitlab-shell path for development]", :immediately
end
# Symlink gitlab-shell to vagrant home, so that sidekiq can use gitlab shell commands
link "create symlink for gitlab-shell path for development" do
target_file "#{gitlab['home']}/gitlab-shell"
to gitlab['shell_path']
not_if { gitlab['env'] == "production" }
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment