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

Modified gitlab, added magic_shell.

parent 38b324fb
No related branches found
No related tags found
No related merge requests found
Showing
with 352 additions and 72 deletions
site :opscode
 
metadata
cookbook 'magic_shell', git: 'git://github.com/customink-webops/magic_shell.git'
Loading
Loading
@@ -3,6 +3,11 @@
"gitlab": {
"path": "."
},
"magic_shell": {
"locked_version": "0.3.2",
"git": "git://github.com/customink-webops/magic_shell.git",
"ref": "447b4b67420d3a7a749d2dd3b13a7f9aceb54c36"
},
"redisio": {
"locked_version": "1.7.0"
},
Loading
Loading
@@ -40,7 +45,7 @@
"locked_version": "3.0.2"
},
"yum": {
"locked_version": "2.4.0"
"locked_version": "2.3.4"
},
"phantomjs": {
"locked_version": "1.0.3"
Loading
Loading
Loading
Loading
@@ -3,9 +3,9 @@ GitLab Cookbook
 
Chef cookbook with recipes to install GitLab.
 
* GitLab: 6.2.0
* GitLab Shell: 1.7.1
* Ruby: 2.0.0
* GitLab: 6.2
* GitLab Shell: 1.7.4
* Ruby: 2.0.0p247
* Redis: 2.6.13
* Git: 1.7.12
* Nginx: 1.1.19
Loading
Loading
@@ -30,18 +30,6 @@ Chef cookbook with recipes to install GitLab.
* CentOS (6.4)
 
 
## Attributes
* Package
* User
* GitLab shell
* GitLab shell config
* GitLab hq
* GitLab hq config
* Gems
* Git
## Installation
 
### Vagrant
Loading
Loading
@@ -52,14 +40,14 @@ Chef cookbook with recipes to install GitLab.
$ gem install berkshelf
$ vagrant plugin install vagrant-berkshelf
$ vagrant plugin install vagrant-omnibus
$ git clone git://github.com/ogom/cookbook-gitlab ./gitlab
$ git clone git://github.com/gitlabhq/cookbook-gitlab ./gitlab
$ cd ./gitlab/
$ vagrant up
```
 
#### Amazon Web Services
 
Create instance.
Creates an AWS instance.
 
```bash
$ gem install berkshelf
Loading
Loading
@@ -67,9 +55,13 @@ $ 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/ogom/cookbook-gitlab ./gitlab
$ 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:
```bash
$ vagrant up --provider=aws
```
 
Loading
Loading
@@ -81,25 +73,47 @@ $ editor ./Vagrantfile
$ vagrant provision
```
 
### knife-solo
#### 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
$ gem install knife-solo
$ knife configure
$ knife solo init ./chef-repo
$ cd ./chef-repo/
$ echo 'cookbook "gitlab", github: "ogom/cookbook-gitlab"' >> ./Berksfile
$ berks install --path ./cookbooks
$ knife solo prepare vagrant@127.0.0.1 -p 2222 -i ~/.vagrant.d/insecure_private_key
$ editor ./nodes/127.0.0.1.json
$ knife solo cook vagrant@127.0.0.1 -p 2222 -i ~/.vagrant.d/insecure_private_key --no-chef-check
$ 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
 
Example of node config.
To override default settings of this cookbook you have to supply a json to the node.
 
```json
{
Loading
Loading
@@ -130,40 +144,128 @@ Example of node config.
},
"run_list":[
"postfix",
"gitlab::initial",
"gitlab::install"
"gitlab::default"
]
}
```
 
### Database use mysql.
## Database
 
Set `mysql` to `database_adapter`.
Default database for this cookbook is `mysql`.
To override default credentials for the database supply the following json to the node:
 
```json
{
...
"mysql": {
"server_root_password": "rootpass",
"server_repl_password": "replpass",
"server_debian_password": "debianpass"
},
"gitlab": {
"database_adapter": "mysql"
"database_password": "datapass"
}
}
```
 
### GitLab Update
Add `gitlab::update` to `run_list`.
To use `postgresql` override default credentials by supplying the following json to the node:
 
```json
{
...
"run_list":[
"gitlab::update",
"gitlab::initial",
"gitlab::install"
]
"posgtresql": {
"password": {
"postgres": "psqlpass"
}
},
"gitlab": {
"database_adapter": "postgresql",
"database_password": "datapass",
}
}
```
 
## Recipes
### clone
Clones the GitLab repository. Recipe uses the attributes in `attributes/default.rb` and, depending on the environment set,
`attributes/development.rb` or `attributes/production.rb`.
### database_mysql
Use to setup mysql database. Available attributes are listed in `attributes/default.rb`.
### database_posgresql
Use to setup postgresql database. Available attributes are listed in `attributes/default.rb`.
### default
Default recipe, it includes two recipes: `setup` and `deploy`. Default recipe is being used to do the complete GitLab installation.
### deploy
Used to clone, configure, setup and start a GitLab instance. `deploy` recipe can be used with AWS OpsWorks to deploy GitLab to an instance.
To use with AWS OpsWorks:
1. Use a preset `Rails App Server` layer or create a custom one
1. Edit the layer
1. Under section `Custom Chef Recipes` and `Deploy` fill in `gitlab::deploy` and save
NOTE: Must be used in combination with `gitlab::setup` recipe.
### gems
This recipe decides what will be included and what will be ommited from the bundle install command and then it runs the bundle install.
Inclusion or exclusion is decided based on the database selected and environment, using attributes in `attributes/default.rb`
### git
Installs packages required for git and compiles it from source. Uses attributes provided in `attributes/git.rb`.
### gitlab_shell_clone
Clones the gitlab-shell repository. Recipe uses the attributes in `attributes/default.rb` and, depending on the environment set,
`attributes/development.rb` or `attributes/production.rb`.
### gitlab_shell_install
Creates a gitlab-shell config.yml from attributes in `attributes/default.rb` and, depending on the environment set,
`attributes/development.rb` or `attributes/production.rb`. Runs `gitlab-shell` install script and install it.
### install
Creates a gitlab config.yml, database.yml from attributes in `attributes/default.rb` and, depending on the environment set,
`attributes/development.rb` or `attributes/production.rb`. Creates GitLab required directories and sets permissions. Copies the example files
to their locations. Runs `db:setup`, `db:migrate`, `db:seed_fu` to prepare selected database for GitLab.
### nginx
Installs and configures nginx for usage.
### packages
Installs all GitLab dependency packages supplied in `attributes/default.rb`.
### ruby
Compiles ruby from source based on attributes in `attributes/default.rb`.
### setup
Includes `packages`, `ruby`, `users` and database recipes to prepare the server for GitLab.
`setup` recipe can be used with AWS OpsWorks to setup requirements for GitLab.
To use with AWS OpsWorks:
1. Use a preset `Rails App Server` layer or create a custom one
1. Edit the layer
1. Under section `Custom Chef Recipes` and `Setup` fill in `gitlab::setup` and save
NOTE: Must be used in combination with `gitlab::deploy` recipe.
### start
Enables gitlab service and starts GitLab.
### users
Creates a GitLab user called `git`.
## Done!
 
`http://localhost:8080/` or your server for your first GitLab login.
Loading
Loading
@@ -173,20 +275,29 @@ admin@local.host
5iveL!fe
```
 
## Testing the cookbook
## 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
 
First install the necessary gems
 
```bash
bundle install
```
To check for syntax errors run foodcritic:
 
```bash
foodcritic .
```
assuming that you are inside cookbook-gitlab directory.
 
Run tests with:
Loading
Loading
@@ -196,14 +307,25 @@ bundle exec rspec
```
 
## Acknowledgement
This cookbook was based on work by [ogom](https://github.com/ogom/cookbook-gitlab). Thank you ogom!
 
## 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)
 
 
## License
## License
 
* MIT
# Package
if platform_family?("rhel")
packages = %w{
libicu-devel
libicu-devel libxslt-devel libyaml-devel libxml2-devel gdbm-devel libffi-devel zlib-devel openssl-devel
libyaml-devel readline-devel curl-devel openssl-devel pcre-devel git memcached-devel valgrind-devel mysql-devel gcc-c++
ImageMagick-devel ImageMagick
}
else
packages = %w{
Loading
Loading
Loading
Loading
@@ -6,13 +6,12 @@ description 'Installs/Configures GitLab'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '0.6.2'
 
recipe "gitlab::initial", "Setting the initial"
recipe "gitlab::install", "Installation"
recipe "gitlab::default", "Installation"
 
%w{redisio ruby_build postgresql mysql database postfix yum phantomjs}.each do |dep|
%w{ redisio ruby_build postgresql mysql database postfix yum phantomjs magic_shell }.each do |dep|
depends dep
end
 
%w{debian ubuntu centos}.each do |os|
%w{ debian ubuntu centos }.each do |os|
supports os
end
Loading
Loading
@@ -7,4 +7,4 @@
include_recipe "gitlab::setup"
 
# Does the configuration and install of GitLab
include_recipe "gitlab::deploy"
\ No newline at end of file
include_recipe "gitlab::deploy"
Loading
Loading
@@ -9,11 +9,6 @@ gitlab = node['gitlab']
gitlab = Chef::Mixin::DeepMerge.merge(gitlab,gitlab[gitlab['env']])
 
## Install Gems
gem_package "charlock_holmes" do
version "0.6.9.4"
options "--no-ri --no-rdoc"
end
template File.join(gitlab['home'], ".gemrc") do
source "gemrc.erb"
user gitlab['user']
Loading
Loading
Loading
Loading
@@ -228,7 +228,11 @@ when 'production'
 
# Updates defaults so gitlab can boot on start. As per man pages of update-rc.d runs only if links do not exist
execute "set gitlab to start on boot" do
command "update-rc.d gitlab defaults 21"
if platform_family?("debian")
command "update-rc.d gitlab defaults 21"
else
command "chkconfig --level 21 gitlab on"
end
action :nothing
end
 
Loading
Loading
Loading
Loading
@@ -30,6 +30,12 @@ if platform_family?("rhel")
directory gitlab['home'] do
mode 0755
end
%w( default.conf ssl.conf virtual.conf ).each do |conf|
file "/etc/nginx/conf.d/#{conf}" do
action :delete
end
end
else
link "/etc/nginx/sites-enabled/gitlab" do
to "/etc/nginx/sites-available/gitlab"
Loading
Loading
Loading
Loading
@@ -13,6 +13,11 @@ directory "/tmp" do
mode 0777
end
 
# Make sure we have all common paths included in our environment
magic_shell_environment 'PATH' do
value '/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin'
end
# 1. Packages / Dependencies
include_recipe "apt" if platform?("ubuntu", "debian")
include_recipe "yum::epel" if platform?("centos")
Loading
Loading
Loading
Loading
@@ -20,4 +20,4 @@ include_recipe "gitlab::ruby"
include_recipe "gitlab::users"
 
# Setup chosen database
include_recipe "gitlab::database_#{gitlab['database_adapter']}"
\ No newline at end of file
include_recipe "gitlab::database_#{gitlab['database_adapter']}"
Loading
Loading
@@ -12,10 +12,6 @@ describe "gitlab::gems" do
runner.converge("gitlab::gems")
end
 
it 'installs charlock holmes with a specific version' do
expect(chef_run).to install_gem_package('charlock_holmes').with(version: '0.6.9.4', options: "--no-ri --no-rdoc")
end
it 'creates a gemrc from template' do
expect(chef_run).to create_template('/home/git/.gemrc').with(
source: "gemrc.erb",
Loading
Loading
@@ -110,10 +106,6 @@ describe "gitlab::gems" do
runner.converge("gitlab::gems")
end
 
it 'installs charlock holmes with a specific version' do
expect(chef_run).to install_gem_package('charlock_holmes').with(version: '0.6.9.4', options: "--no-ri --no-rdoc")
end
it 'creates a gemrc from template' do
expect(chef_run).to create_template('/home/git/.gemrc').with(
source: "gemrc.erb",
Loading
Loading
Loading
Loading
@@ -99,4 +99,4 @@ describe "gitlab::start" do
end
end
end
end
\ No newline at end of file
end
magic_shell CHANGELOG
=====================
0.3.1, 0.3.2
-----------
* **No changes** - chefigonre with `knife cookbook site share` was being ignored, so unnecessary artifacts were uploaded
0.3.0
----
* Full test suite
* Test with strainer
* Support for cross-Chef version default_action
0.2.0
----
* Add `magic_shell_environment`
0.1.5
----
* The default action for the alias resource is now :add
0.1.4
-----
* The default action for the alias resource is now :create
* Formatting changes to the metadata, README, and CHANGELOG
0.1.3
-----
* Address FC0016 - specify a default action
* Add integration with Travis CI
0.1.2
-----
* Update the README to indicate that you need to specify an action (:add or :remove)
0.1.1
-----
* Rename the resource and provider files
0.1.0
-----
* Initial release of magic_shell
source 'https://rubygems.org'
gem 'chef', ENV['CHEF_VERSION'] || '>= 10.0'
group :test do
gem 'chefspec', '~> 1.0.0'
gem 'foodcritic', '~> 2.1.0'
gem 'strainer', '~> 2.0.0'
end
magic_shell Cookbook
====================
[![Build Status](https://secure.travis-ci.org/customink-webops/magic_shell.png)](http://travis-ci.org/customink-webops/magic_shell)
Provides utility for adding some syntactic sugar to your shell.
Requirements
------------
None
Attributes
----------
None
Usage
-----
Update the `metadata.rb` for your cookbook to depend on magic_shell
```ruby
depends 'magic_shell'
```
Use the `magic_shell_alias` resource to create a command alias.
```ruby
magic_shell_alias 'myrailsapp' do
command 'cd /opt/myrailsapp/current'
end
```
This will alias `myrailsapp` to `cd /opt/myrailsapp/current`.
You can also remove aliases:
```ruby
magic_shell_alias 'myrailsapp' do
action :remove
end
```
Use the `magic_shell_environment` resource to create a shell environment variable.
```ruby
magic_shell_environment 'EDITOR' do
value 'vim'
end
```
This will export an `EDITOR` environment variable with a value of `vim`.
You can also remove environment variables:
```ruby
magic_shell_environment 'EDITOR' do
action :remove
end
```
Contributing
------------
1. Fork the repo
2. Create a feature branch
3. Code, document, write specs, test
4. Submit a PR
License and Authors
-------------------
Author: [Nathen Harvey](https://github.com/nathenharvey) ([@nathenharvey](https://twitter.com/nathenharvey))
Copyright 2012, CustomInk, LLC
knife: bundle exec knife cookbook test $COOKBOOK
foodcritic: bundle exec foodcritic $SANDBOX/$COOKBOOK
rspec: (cd $COOKBOOK && bundle exec rspec --color --format documentation)
default['magic_shell']['environment'] = {}
spec/
.gitignore
.rspec
.travis.yml
Gemfile
Gemfile.lock
Strainerfile
maintainer 'CustomInk, LLC'
name 'magic_shell'
maintainer_email 'webops@customink.com'
license 'Apache 2.0'
description 'Installs/Configures command_alias'
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version '0.3.2'
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