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

Recipe naming overhaul

parent 111a71f2
No related branches found
No related tags found
No related merge requests found
Showing
with 1479 additions and 181 deletions
Loading
Loading
@@ -40,7 +40,7 @@
"locked_version": "3.0.2"
},
"yum": {
"locked_version": "2.3.4"
"locked_version": "2.4.0"
},
"phantomjs": {
"locked_version": "1.0.3"
Loading
Loading
Loading
Loading
@@ -79,7 +79,7 @@ Vagrant.configure("2") do |config|
chef.run_list = [
"apt",
"postfix",
"gitlab::install"
"gitlab::default"
]
# In case chef-solo run is failing silently
# uncomment the line below to enable debug log level.
Loading
Loading
#
# Cookbook Name:: gitlab
# Recipe:: clone
#
gitlab = node['gitlab']
# Merge environmental variables
gitlab = Chef::Mixin::DeepMerge.merge(gitlab,gitlab[gitlab['env']])
# 6. GitLab
## Clone the Source
git gitlab['path'] do
repository gitlab['repository']
revision gitlab['revision']
user gitlab['user']
group gitlab['group']
action :sync
end
#
# Cookbook Name:: gitlab
# Recipe:: default
#
# Does the setup of various GitLab dependencies
include_recipe "gitlab::setup"
# Does the configuration and install of GitLab
include_recipe "gitlab::deploy"
\ No newline at end of file
#
# Cookbook Name:: gitlab
# Recipe:: deploy
#
# This recipe is used for AWS OpsWorks deploy section
# Any change must be tested against AWS OpsWorks stack
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"
# Configure and install GitLab shell
include_recipe "gitlab::gitlab_shell_install"
# Fetch GitLab source code
include_recipe "gitlab::clone"
# Install required gems
include_recipe "gitlab::gems"
# Configure and install GitLab
include_recipe "gitlab::install"
# Start GitLab if in production
include_recipe "gitlab::start"
# Setup and configure nginx
include_recipe "gitlab::nginx" if gitlab['env'] == 'production'
#
# Cookbook Name:: gitlab
# Recipe:: gitlab_shell_clone
#
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
repository gitlab['shell_repository']
revision gitlab['shell_revision']
user gitlab['user']
group gitlab['group']
action :sync
end
#
# Cookbook Name:: gitlab
# Recipe:: gitlab_shell_install
#
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"
user gitlab['user']
group gitlab['group']
variables({
:user => gitlab['user'],
:home => gitlab['home'],
:url => gitlab['url'],
:repos_path => gitlab['repos_path'],
:redis_path => gitlab['redis_path'],
:redis_host => gitlab['redis_host'],
:redis_port => gitlab['redis_port'],
:namespace => gitlab['namespace']
})
notifies :run, "execute[gitlab-shell install]", :immediately
end
## Do setup
execute "gitlab-shell install" do
command <<-EOS
PATH="/usr/local/bin:$PATH"
./bin/install
EOS
cwd gitlab['shell_path']
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
Loading
Loading
@@ -8,29 +8,255 @@ gitlab = node['gitlab']
# Merge environmental variables
gitlab = Chef::Mixin::DeepMerge.merge(gitlab,gitlab[gitlab['env']])
 
# Setup all package, user, etc. requirements of GitLab
include_recipe "gitlab::initial"
### Copy the example GitLab config
template File.join(gitlab['path'], 'config', 'gitlab.yml') do
source "gitlab.yml.erb"
user gitlab['user']
group gitlab['group']
variables({
:host => gitlab['host'],
:port => gitlab['port'],
:user => gitlab['user'],
:email_from => gitlab['email_from'],
:support_email => gitlab['support_email'],
:satellites_path => gitlab['satellites_path'],
:repos_path => gitlab['repos_path'],
:shell_path => gitlab['shell_path']
})
notifies :run, "bash[git config]", :immediately
end
 
# Fetch GitLab shell source code
include_recipe "gitlab::gitlab_shell_source"
### Make sure GitLab can write to the log/ and tmp/ directories
### Create directories for sockets/pids
### Create public/uploads directory otherwise backup will fail
%w{log tmp tmp/pids tmp/sockets public/uploads}.each do |path|
directory File.join(gitlab['path'], path) do
owner gitlab['user']
group gitlab['group']
mode 0755
end
end
 
# Configure GitLab shell
include_recipe "gitlab::gitlab_shell"
### Create directory for satellites
directory gitlab['satellites_path'] do
owner gitlab['user']
group gitlab['group']
end
 
# Setup chosen database
include_recipe "gitlab::database_#{gitlab['database_adapter']}"
### Copy the example Unicorn config
# Creating the file this way for the following reasons
# 1. Chef 11.4.0 must be used to keep support for AWS OpsWorks
# 2. Using file resource is not an option because it is ran at compilation time
# and at that point the file doesn't exist
# 3. Using cookbook_file resource is not an option because we do not want to include the file
# in the cookbook for maintenance reasons. Same for template resource.
# 4. Using remote_file resource is not an option because Chef 11.4.0 connects to remote URI
# see https://github.com/opscode/chef/blob/11.4.4/lib/chef/resource/remote_file.rb#L63
# 5 Using bash and execute resource is not an option because they would run at every chef run
# and supplying a restriction in the form of "not_if" would prevent an update of a file
# if there is any
# Ruby block is compiled at compilation time but only executed during execution time
# allowing us to create a resource.
 
# Fetch GitLab source code
include_recipe "gitlab::gitlab_source"
ruby_block "Copy unicorn config file from example" do
block do
resource = Chef::Resource::File.new("unicorn.rb", run_context)
resource.path File.join(gitlab['path'], 'config', 'unicorn.rb')
resource.content IO.read(File.join(gitlab['path'], 'config', 'unicorn.rb.example'))
resource.owner gitlab['user']
resource.group gitlab['group']
resource.run_action :create
end
end
 
# Install required gems
include_recipe "gitlab::gems"
### Enable Rack attack
# Creating the file this way for the following reasons
# 1. Chef 11.4.0 must be used to keep support for AWS OpsWorks
# 2. Using file resource is not an option because it is ran at compilation time
# and at that point the file doesn't exist
# 3. Using cookbook_file resource is not an option because we do not want to include the file
# in the cookbook for maintenance reasons. Same for template resource.
# 4. Using remote_file resource is not an option because Chef 11.4.0 connects to remote URI
# see https://github.com/opscode/chef/blob/11.4.4/lib/chef/resource/remote_file.rb#L63
# 5 Using bash and execute resource is not an option because they would run at every chef run
# and supplying a restriction in the form of "not_if" would prevent an update of a file
# if there is any
# Ruby block is compiled at compilation time but only executed during execution time
# allowing us to create a resource.
 
# Configure GitLab
include_recipe "gitlab::gitlab"
ruby_block "Copy from example rack attack config" do
block do
resource = Chef::Resource::File.new("rack_attack.rb", run_context)
resource.path File.join(gitlab['path'], 'config', 'initializers', 'rack_attack.rb')
resource.content IO.read(File.join(gitlab['path'], 'config', 'initializers', 'rack_attack.rb.example'))
resource.owner gitlab['user']
resource.group gitlab['group']
resource.mode 0644
resource.run_action :create
if resource.updated?
self.notifies :run, resources(:bash => "Enable rack attack in application.rb"), :immediately
end
end
end
 
# Start GitLab if in production
include_recipe "gitlab::start"
bash "Enable rack attack in application.rb" do
code <<-EOS
sed -i "/# config.middleware.use Rack::Attack/ s/# *//" "#{File.join(gitlab['path'], "config", "application.rb")}"
EOS
user gitlab['user']
group gitlab['group']
action :nothing
end
 
# Setup and configure nginx
include_recipe "gitlab::nginx" if gitlab['env'] == 'production'
### Configure Git global settings for git user, useful when editing via web
bash "git config" do
code <<-EOS
git config --global user.name "GitLab"
git config --global user.email "gitlab@#{gitlab['host']}"
git config --global core.autocrlf input
EOS
user gitlab['user']
group gitlab['group']
environment('HOME' => gitlab['home'])
action :nothing
end
## Configure GitLab DB settings
template File.join(gitlab['path'], "config", "database.yml") do
source "database.yml.#{gitlab['database_adapter']}.erb"
user gitlab['user']
group gitlab['group']
variables({
:user => gitlab['user'],
:password => gitlab['database_password']
})
end
### db:setup
gitlab['environments'].each do |environment|
### db:setup
file_setup = File.join(gitlab['home'], ".gitlab_setup_#{environment}")
file_setup_old = File.join(gitlab['home'], ".gitlab_setup")
execute "rake db:setup" do
command <<-EOS
PATH="/usr/local/bin:$PATH"
bundle exec rake db:setup RAILS_ENV=#{environment}
EOS
cwd gitlab['path']
user gitlab['user']
group gitlab['group']
not_if {File.exists?(file_setup) || File.exists?(file_setup_old)}
end
file file_setup do
owner gitlab['user']
group gitlab['group']
action :create
end
### db:migrate
file_migrate = File.join(gitlab['home'], ".gitlab_migrate_#{environment}")
file_migrate_old = File.join(gitlab['home'], ".gitlab_migrate")
execute "rake db:migrate" do
command <<-EOS
PATH="/usr/local/bin:$PATH"
bundle exec rake db:migrate RAILS_ENV=#{environment}
EOS
cwd gitlab['path']
user gitlab['user']
group gitlab['group']
not_if {File.exists?(file_migrate) || File.exists?(file_migrate_old)}
end
file file_migrate do
owner gitlab['user']
group gitlab['group']
action :create
end
### db:seed_fu
file_seed = File.join(gitlab['home'], ".gitlab_seed_#{environment}")
file_seed_old = File.join(gitlab['home'], ".gitlab_seed")
execute "rake db:seed_fu" do
command <<-EOS
PATH="/usr/local/bin:$PATH"
bundle exec rake db:seed_fu RAILS_ENV=#{environment}
EOS
cwd gitlab['path']
user gitlab['user']
group gitlab['group']
not_if {File.exists?(file_seed) || File.exists?(file_seed_old)}
end
file file_seed do
owner gitlab['user']
group gitlab['group']
action :create
end
end
case gitlab['env']
when 'production'
## Setup Init Script
# Creating the file this way for the following reasons
# 1. Chef 11.4.0 must be used to keep support for AWS OpsWorks
# 2. Using file resource is not an option because it is ran at compilation time
# and at that point the file doesn't exist
# 3. Using cookbook_file resource is not an option because we do not want to include the file
# in the cookbook for maintenance reasons. Same for template resource.
# 4. Using remote_file resource is not an option because Chef 11.4.0 connects to remote URI
# see https://github.com/opscode/chef/blob/11.4.4/lib/chef/resource/remote_file.rb#L63
# 5 Using bash and execute resource is not an option because they would run at every chef run
# and supplying a restriction in the form of "not_if" would prevent an update of a file
# if there is any
# Ruby block is compiled at compilation time but only executed during execution time
# allowing us to create a resource.
ruby_block "Copy from example gitlab init config" do
block do
resource = Chef::Resource::File.new("gitlab_init", run_context)
resource.path "/etc/init.d/gitlab"
resource.content IO.read(File.join(gitlab['path'], "lib", "support", "init.d", "gitlab"))
resource.mode 0755
resource.run_action :create
if resource.updated?
self.notifies :run, resources(:execute => "set gitlab to start on boot"), :immediately
end
end
end
# 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"
action :nothing
end
## Setup logrotate
# Creating the file this way for the following reasons
# 1. Chef 11.4.0 must be used to keep support for AWS OpsWorks
# 2. Using file resource is not an option because it is ran at compilation time
# and at that point the file doesn't exist
# 3. Using cookbook_file resource is not an option because we do not want to include the file
# in the cookbook for maintenance reasons. Same for template resource.
# 4. Using remote_file resource is not an option because Chef 11.4.0 connects to remote URI
# see https://github.com/opscode/chef/blob/11.4.4/lib/chef/resource/remote_file.rb#L63
# 5 Using bash and execute resource is not an option because they would run at every chef run
# and supplying a restriction in the form of "not_if" would prevent an update of a file
# if there is any
# Ruby block is compiled at compilation time but only executed during execution time
# allowing us to create a resource.
ruby_block "Copy from example logrotate config" do
block do
resource = Chef::Resource::File.new("logrotate", run_context)
resource.path "/etc/logrotate.d/gitlab"
resource.content IO.read(File.join(gitlab['path'], "lib", "support", "logrotate", "gitlab"))
resource.mode 0644
resource.run_action :create
end
end
else
## For execute javascript test
include_recipe "phantomjs"
end
#
# Cookbook Name:: gitlab
# Recipe:: packages
#
gitlab = node['gitlab']
# Merge environmental variables
gitlab = Chef::Mixin::DeepMerge.merge(gitlab,gitlab[gitlab['env']])
# 0. Initial Change
directory "/tmp" do
mode 0777
end
# 1. Packages / Dependencies
include_recipe "apt" if platform?("ubuntu", "debian")
include_recipe "yum::epel" if platform?("centos")
include_recipe "gitlab::git"
include_recipe "redisio::install"
include_recipe "redisio::enable"
## Install the required packages.
gitlab['packages'].each do |pkg|
package pkg
end
#
# Cookbook Name:: gitlab
# Recipe:: ruby
#
gitlab = node['gitlab']
# Merge environmental variables
gitlab = Chef::Mixin::DeepMerge.merge(gitlab,gitlab[gitlab['env']])
# 2. Ruby
# Do not rely on system installed ruby packages
include_recipe "ruby_build"
## Download and compile it:
ruby_build_ruby gitlab['ruby'] do
prefix_path "/usr/local/"
end
## Install the Bundler Gem:
gem_package "bundler" do
gem_binary "/usr/local/bin/gem"
options "--no-ri --no-rdoc"
end
#
# Cookbook Name:: gitlab
# Recipe:: setup
#
# This recipe is used for AWS OpsWorks setup section
# Any change must be tested against AWS OpsWorks stack
gitlab = node['gitlab']
# Merge environmental variables
gitlab = Chef::Mixin::DeepMerge.merge(gitlab,gitlab[gitlab['env']])
# Install GitLab required packages
include_recipe "gitlab::packages"
# Compile ruby
include_recipe "gitlab::ruby"
# Setup GitLab user
include_recipe "gitlab::users"
# Setup chosen database
include_recipe "gitlab::database_#{gitlab['database_adapter']}"
\ No newline at end of file
require 'spec_helper'
describe "gitlab::clone" do
let(:chef_run) { ChefSpec::Runner.new.converge("gitlab::clone") }
describe "under ubuntu" do
["12.04", "10.04"].each do |version|
let(:chef_run) do
runner = ChefSpec::Runner.new(platform: "ubuntu", version: version)
runner.node.set['gitlab']['env'] = "production"
runner.converge("gitlab::clone")
end
it "clones the gitlab repository" do
expect(chef_run).to sync_git('/home/git/gitlab').with(
repository: 'https://github.com/gitlabhq/gitlabhq.git',
revision: '6-2-stable',
user: 'git',
group: 'git'
)
end
describe "in development" do
let(:chef_run) do
runner = ChefSpec::Runner.new(platform: "ubuntu", version: version)
runner.node.set['gitlab']['env'] = "development"
runner.converge("gitlab::clone")
end
it "clones the gitlab repository" do
expect(chef_run).to sync_git('/vagrant/gitlab').with(
repository: 'https://github.com/gitlabhq/gitlabhq.git',
revision: 'master',
user: 'vagrant',
group: 'vagrant'
)
end
end
end
end
describe "under centos" do
["5.8", "6.4"].each do |version|
let(:chef_run) do
runner = ChefSpec::Runner.new(platform: "centos", version: version)
runner.node.set['gitlab']['env'] = "production"
runner.converge("gitlab::clone")
end
it "clones the gitlab repository" do
expect(chef_run).to sync_git('/home/git/gitlab').with(
repository: 'https://github.com/gitlabhq/gitlabhq.git',
revision: '6-2-stable',
user: 'git',
group: 'git'
)
end
describe "in development" do
let(:chef_run) do
runner = ChefSpec::Runner.new(platform: "centos", version: version)
runner.node.set['gitlab']['env'] = "development"
runner.converge("gitlab::clone")
end
it "clones the gitlab repository" do
expect(chef_run).to sync_git('/vagrant/gitlab').with(
repository: 'https://github.com/gitlabhq/gitlabhq.git',
revision: 'master',
user: 'vagrant',
group: 'vagrant'
)
end
end
end
end
end
\ No newline at end of file
require 'spec_helper'
describe "gitlab::default" do
let(:chef_run) { ChefSpec::Runner.new.converge("gitlab::default") }
describe "under ubuntu" do
["12.04", "10.04"].each do |version|
let(:chef_run) do
runner = ChefSpec::Runner.new(platform: "ubuntu", version: version)
runner.node.set['gitlab']['env'] = "production"
runner.converge("gitlab::default")
end
before do
# stubbing commands because real commands are disabled
stub_command("test -f /var/chef/cache/git-1.7.12.4.zip").and_return(true)
stub_command("git --version | grep 1.7.12.4").and_return(true)
stub_command("git --version >/dev/null").and_return(true)
stub_command("\"/usr/bin/mysql\" -u root -e 'show databases;'").and_return(true)
end
it "includes recipes from external cookbooks" do
expect(chef_run).to include_recipe("gitlab::setup")
expect(chef_run).to include_recipe("gitlab::deploy")
end
describe "when in development environment" do
let(:chef_run) do
runner = ChefSpec::Runner.new(platform: "ubuntu", version: version)
runner.node.set['gitlab']['env'] = "development"
runner.converge("gitlab::default")
end
it "includes recipes from external cookbooks" do
expect(chef_run).to include_recipe("gitlab::setup")
expect(chef_run).to include_recipe("gitlab::deploy")
end
end
end
end
describe "under centos" do
["5.8", "6.4"].each do |version|
let(:chef_run) do
runner = ChefSpec::Runner.new(platform: "centos", version: version)
runner.node.set['gitlab']['env'] = "production"
runner.converge("gitlab::default")
end
before do
# stubbing commands because real commands are disabled
stub_command("test -f /var/chef/cache/git-1.7.12.4.zip").and_return(true)
stub_command("git --version | grep 1.7.12.4").and_return(true)
stub_command("git --version >/dev/null").and_return(true)
stub_command("\"/usr/bin/mysql\" -u root -e 'show databases;'").and_return(true)
end
it "includes recipes from external cookbooks" do
expect(chef_run).to include_recipe("gitlab::setup")
expect(chef_run).to include_recipe("gitlab::deploy")
end
describe "when in development environment" do
let(:chef_run) do
runner = ChefSpec::Runner.new(platform: "centos", version: version)
runner.node.set['gitlab']['env'] = "development"
runner.converge("gitlab::default")
end
it "includes recipes from external cookbooks" do
expect(chef_run).to include_recipe("gitlab::setup")
expect(chef_run).to include_recipe("gitlab::deploy")
end
end
end
end
end
require 'spec_helper'
describe "gitlab::deploy" do
let(:chef_run) { ChefSpec::Runner.new.converge("gitlab::deploy") }
describe "under ubuntu" do
["12.04", "10.04"].each do |version|
let(:chef_run) do
runner = ChefSpec::Runner.new(platform: "ubuntu", version: version)
runner.node.set['gitlab']['env'] = "production"
runner.converge("gitlab::deploy")
end
it "includes recipes from external cookbooks" do
expect(chef_run).to include_recipe("gitlab::gitlab_shell_clone")
expect(chef_run).to include_recipe("gitlab::gitlab_shell_install")
expect(chef_run).to include_recipe("gitlab::clone")
expect(chef_run).to include_recipe("gitlab::gems")
expect(chef_run).to include_recipe("gitlab::install")
expect(chef_run).to include_recipe("gitlab::nginx")
end
describe "when in development environment" do
let(:chef_run) do
runner = ChefSpec::Runner.new(platform: "ubuntu", version: version)
runner.node.set['gitlab']['env'] = "development"
runner.converge("gitlab::deploy")
end
it "includes recipes from external cookbooks" do
expect(chef_run).to include_recipe("gitlab::gitlab_shell_clone")
expect(chef_run).to include_recipe("gitlab::gitlab_shell_install")
expect(chef_run).to include_recipe("gitlab::clone")
expect(chef_run).to include_recipe("gitlab::gems")
expect(chef_run).to include_recipe("gitlab::install")
expect(chef_run).to_not include_recipe("gitlab::nginx")
end
end
end
end
describe "under centos" do
["5.8", "6.4"].each do |version|
let(:chef_run) do
runner = ChefSpec::Runner.new(platform: "centos", version: version)
runner.node.set['gitlab']['env'] = "production"
runner.converge("gitlab::deploy")
end
it "includes recipes from external cookbooks" do
expect(chef_run).to include_recipe("gitlab::gitlab_shell_clone")
expect(chef_run).to include_recipe("gitlab::gitlab_shell_install")
expect(chef_run).to include_recipe("gitlab::clone")
expect(chef_run).to include_recipe("gitlab::gems")
expect(chef_run).to include_recipe("gitlab::install")
expect(chef_run).to include_recipe("gitlab::nginx")
end
describe "when in development environment" do
let(:chef_run) do
runner = ChefSpec::Runner.new(platform: "centos", version: version)
runner.node.set['gitlab']['env'] = "development"
runner.converge("gitlab::deploy")
end
it "includes recipes from external cookbooks" do
expect(chef_run).to include_recipe("gitlab::gitlab_shell_clone")
expect(chef_run).to include_recipe("gitlab::gitlab_shell_install")
expect(chef_run).to include_recipe("gitlab::clone")
expect(chef_run).to include_recipe("gitlab::gems")
expect(chef_run).to include_recipe("gitlab::install")
expect(chef_run).to_not include_recipe("gitlab::nginx")
end
end
end
end
end
Loading
Loading
@@ -37,7 +37,7 @@ describe "gitlab::gems" do
 
it 'executes bundle without development and test' do
resource = chef_run.find_resource(:execute, 'bundle install')
expect(resource.command).to eq(" PATH=\"/usr/local/bin:$PATH\"\n bundle install --path=.bundle --deployment --without development test\n")
expect(resource.command).to eq(" PATH=\"/usr/local/bin:$PATH\"\n bundle install --path=.bundle --deployment --without postgres aws development test\n")
expect(resource.user).to eq("git")
expect(resource.group).to eq("git")
expect(resource.cwd).to eq("/home/git/gitlab")
Loading
Loading
@@ -52,7 +52,7 @@ describe "gitlab::gems" do
 
it 'executes bundle without production' do
resource = chef_run.find_resource(:execute, 'bundle install')
expect(resource.command).to eq(" PATH=\"/usr/local/bin:$PATH\"\n bundle install --path=.bundle --deployment --without production\n")
expect(resource.command).to eq(" PATH=\"/usr/local/bin:$PATH\"\n bundle install --path=.bundle --deployment --without postgres aws production\n")
expect(resource.user).to eq("vagrant")
expect(resource.group).to eq("vagrant")
expect(resource.cwd).to eq("/vagrant/gitlab")
Loading
Loading
@@ -135,7 +135,7 @@ describe "gitlab::gems" do
 
it 'executes bundle without development and test' do
resource = chef_run.find_resource(:execute, 'bundle install')
expect(resource.command).to eq(" PATH=\"/usr/local/bin:$PATH\"\n bundle install --path=.bundle --deployment --without development test\n")
expect(resource.command).to eq(" PATH=\"/usr/local/bin:$PATH\"\n bundle install --path=.bundle --deployment --without postgres aws development test\n")
expect(resource.user).to eq("git")
expect(resource.group).to eq("git")
expect(resource.cwd).to eq("/home/git/gitlab")
Loading
Loading
@@ -150,7 +150,7 @@ describe "gitlab::gems" do
 
it 'executes bundle without production' do
resource = chef_run.find_resource(:execute, 'bundle install')
expect(resource.command).to eq(" PATH=\"/usr/local/bin:$PATH\"\n bundle install --path=.bundle --deployment --without production\n")
expect(resource.command).to eq(" PATH=\"/usr/local/bin:$PATH\"\n bundle install --path=.bundle --deployment --without postgres aws production\n")
expect(resource.user).to eq("vagrant")
expect(resource.group).to eq("vagrant")
expect(resource.cwd).to eq("/vagrant/gitlab")
Loading
Loading
require 'spec_helper'
describe "gitlab::gitlab_shell_clone" do
let(:chef_run) { ChefSpec::Runner.new.converge("gitlab::gitlab_shell_clone") }
describe "under ubuntu" do
["12.04", "10.04"].each do |version|
let(:chef_run) do
runner = ChefSpec::Runner.new(platform: "ubuntu", version: version)
runner.node.set['gitlab']['env'] = "production"
runner.converge("gitlab::gitlab_shell_clone")
end
it "clones the gitlab-shell repository" do
expect(chef_run).to sync_git('/home/git/gitlab-shell').with(
repository: 'https://github.com/gitlabhq/gitlab-shell.git',
revision: "v1.7.4",
user: 'git',
group: 'git'
)
end
describe "in development" do
let(:chef_run) do
runner = ChefSpec::Runner.new(platform: "ubuntu", version: version)
runner.node.set['gitlab']['env'] = "development"
runner.converge("gitlab::gitlab_shell_clone")
end
it "clones the gitlab-shell repository" do
expect(chef_run).to sync_git('/vagrant/gitlab-shell').with(
repository: 'https://github.com/gitlabhq/gitlab-shell.git',
revision: "v1.7.4",
user: 'vagrant',
group: 'vagrant'
)
end
end
end
end
describe "under centos" do
["5.8", "6.4"].each do |version|
let(:chef_run) do
runner = ChefSpec::Runner.new(platform: "centos", version: version)
runner.node.set['gitlab']['env'] = "production"
runner.converge("gitlab::gitlab_shell_clone")
end
it "clones the gitlab-shell repository" do
expect(chef_run).to sync_git('/home/git/gitlab-shell').with(
repository: 'https://github.com/gitlabhq/gitlab-shell.git',
revision: "v1.7.4",
user: 'git',
group: 'git'
)
end
describe "in development" do
let(:chef_run) do
runner = ChefSpec::Runner.new(platform: "centos", version: version)
runner.node.set['gitlab']['env'] = "development"
runner.converge("gitlab::gitlab_shell_clone")
end
it "clones the gitlab-shell repository" do
expect(chef_run).to sync_git('/vagrant/gitlab-shell').with(
repository: 'https://github.com/gitlabhq/gitlab-shell.git',
revision: "v1.7.4",
user: 'vagrant',
group: 'vagrant'
)
end
end
end
end
end
\ No newline at end of file
require 'spec_helper'
describe "gitlab::gitlab_shell_install" do
let(:chef_run) { ChefSpec::Runner.new.converge("gitlab::gitlab_shell_install") }
describe "under ubuntu" do
["12.04", "10.04"].each do |version|
let(:chef_run) do
runner = ChefSpec::Runner.new(platform: "ubuntu", version: version)
runner.node.set['gitlab']['env'] = "production"
runner.converge("gitlab::gitlab_shell_install")
end
it 'creates a gitlab shell config' do
expect(chef_run).to create_template('/home/git/gitlab-shell/config.yml').with(
source: 'gitlab_shell.yml.erb',
variables: {
user: "git",
home: "/home/git",
url: "http://localhost:8080/",
repos_path: "/home/git/repositories",
redis_path: "/usr/local/bin/redis-cli",
redis_host: "127.0.0.1",
redis_port: "6379",
namespace: "resque:gitlab"
}
)
end
describe "creating gitlab-shell config" do
let(:template) { chef_run.template('/home/git/gitlab-shell/config.yml') }
it 'triggers install' do
expect(template).to notify('execute[gitlab-shell install]').to(:run).immediately
end
it 'executes with correct info' do
resource = chef_run.find_resource(:execute, 'gitlab-shell install')
expect(resource.command).to eq(" PATH=\"/usr/local/bin:$PATH\"\n ./bin/install\n")
expect(resource.user).to eq("git")
expect(resource.group).to eq("git")
expect(resource.cwd).to eq("/home/git/gitlab-shell")
end
end
it 'does not run a execute to install gitlab shell on its own' do
expect(chef_run).to_not run_execute('gitlab-shell install')
end
it 'symlinks gitlab-shell directory' do
expect(chef_run).to_not create_link('/home/git/gitlab-shell').with(to: '/home/git/gitlab-shell')
end
describe "for development" do
let(:chef_run) do
runner = ChefSpec::Runner.new(platform: "ubuntu", version: version)
runner.node.set['gitlab']['env'] = "development"
runner.converge("gitlab::gitlab_shell_install")
end
it 'symlinks gitlab-shell directory' do
expect(chef_run).to create_link('/home/vagrant/gitlab-shell').with(to: '/vagrant/gitlab-shell')
end
end
end
end
describe "under centos" do
["5.8", "6.4"].each do |version|
let(:chef_run) do
runner = ChefSpec::Runner.new(platform: "centos", version: version)
runner.node.set['gitlab']['env'] = "production"
runner.converge("gitlab::gitlab_shell_install")
end
it 'creates a gitlab shell config' do
expect(chef_run).to create_template('/home/git/gitlab-shell/config.yml').with(
source: 'gitlab_shell.yml.erb',
variables: {
user: "git",
home: "/home/git",
url: "http://localhost:8080/",
repos_path: "/home/git/repositories",
redis_path: "/usr/local/bin/redis-cli",
redis_host: "127.0.0.1",
redis_port: "6379",
namespace: "resque:gitlab"
}
)
end
describe "creating gitlab-shell config" do
let(:template) { chef_run.template('/home/git/gitlab-shell/config.yml') }
it 'triggers install' do
expect(template).to notify('execute[gitlab-shell install]').to(:run).immediately
end
it 'executes with correct info' do
resource = chef_run.find_resource(:execute, 'gitlab-shell install')
expect(resource.command).to eq(" PATH=\"/usr/local/bin:$PATH\"\n ./bin/install\n")
expect(resource.user).to eq("git")
expect(resource.group).to eq("git")
expect(resource.cwd).to eq("/home/git/gitlab-shell")
end
end
it 'does not run a execute to install gitlab shell on its own' do
expect(chef_run).to_not run_execute('gitlab-shell install')
end
describe "for development" do
let(:chef_run) do
runner = ChefSpec::Runner.new(platform: "centos", version: version)
runner.node.set['gitlab']['env'] = "development"
runner.converge("gitlab::gitlab_shell_install")
end
it 'symlinks gitlab-shell directory' do
expect(chef_run).to create_link('/home/vagrant/gitlab-shell').with(to: '/vagrant/gitlab-shell')
end
end
end
end
end
This diff is collapsed.
require 'spec_helper'
describe "gitlab::packages" do
let(:chef_run) { ChefSpec::Runner.new.converge("gitlab::packages") }
describe "under ubuntu" do
["12.04", "10.04"].each do |version|
let(:chef_run) { ChefSpec::Runner.new(platform: "ubuntu", version: version).converge("gitlab::packages") }
before do
# stubbing git commands because packages recipe requires gitlab::git
stub_command("test -f /var/chef/cache/git-1.7.12.4.zip").and_return(true)
stub_command("git --version | grep 1.7.12.4").and_return(true)
stub_command("git --version >/dev/null").and_return(true)
end
it "includes recipes from external cookbooks" do
expect(chef_run).to include_recipe("apt::default")
expect(chef_run).to_not include_recipe("yum::epel")
expect(chef_run).to include_recipe("gitlab::git")
expect(chef_run).to include_recipe("redisio::install")
expect(chef_run).to include_recipe("redisio::enable")
end
it "installs all default packages" do
packages = chef_run.node['gitlab']['packages']
packages.each do |pkg|
expect(chef_run).to install_package(pkg)
end
end
end
end
describe "under centos" do
["5.8", "6.4"].each do |version|
let(:chef_run) { ChefSpec::Runner.new(platform: "centos", version: version).converge("gitlab::packages") }
before do
# stubbing git commands because packages recipe requires gitlab::git
stub_command("test -f /var/chef/cache/git-1.7.12.4.zip").and_return(true)
stub_command("git --version | grep 1.7.12.4").and_return(true)
stub_command("git --version >/dev/null").and_return(true)
end
it "includes recipes from external cookbooks" do
expect(chef_run).to_not include_recipe("apt::default")
expect(chef_run).to include_recipe("yum::epel")
expect(chef_run).to include_recipe("gitlab::git")
expect(chef_run).to include_recipe("redisio::install")
expect(chef_run).to include_recipe("redisio::enable")
end
it "installs all default packages" do
packages = chef_run.node['gitlab']['packages']
packages.each do |pkg|
expect(chef_run).to install_package(pkg)
end
end
end
end
end
require 'spec_helper'
describe "gitlab::ruby" do
let(:chef_run) { ChefSpec::Runner.new.converge("gitlab::ruby") }
describe "under ubuntu" do
["12.04", "10.04"].each do |version|
let(:chef_run) { ChefSpec::Runner.new(platform: "ubuntu", version: version).converge("gitlab::ruby") }
before do
stub_command("git --version >/dev/null").and_return(true)
end
it "includes recipes from external cookbooks" do
expect(chef_run).to include_recipe("ruby_build::default")
end
it "installs bundler gem" do
expect(chef_run).to install_gem_package("bundler")
end
end
end
describe "under centos" do
["5.8", "6.4"].each do |version|
let(:chef_run) { ChefSpec::Runner.new(platform: "centos", version: version).converge("gitlab::ruby") }
before do
stub_command("git --version >/dev/null").and_return(true)
end
it "includes recipes from external cookbooks" do
expect(chef_run).to include_recipe("ruby_build::default")
end
it "installs bundler gem" do
expect(chef_run).to install_gem_package("bundler")
end
end
end
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