Skip to content

Commit

Permalink
Gitlab v0.3.0
Browse files Browse the repository at this point in the history
* Missing bracket
* Change single-quote variable to symbol notation
* install python and symlink redis-cli so hooks work
* HTTPS options for nginx
* Ubuntu/Debian platform compatibility fixes
* [FC035](http://acrmp.github.com/foodcritic/#FC035): Template uses node attribute directly

Signed-off-by: Eric G. Wolfe <[email protected]>
  • Loading branch information
Eric G. Wolfe committed Aug 26, 2012
1 parent 1afbc93 commit f942512
Show file tree
Hide file tree
Showing 17 changed files with 106 additions and 56 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
metadata.json
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
## v0.3.0

* Missing bracket
* Change single-quote variable to symbol notation
* install python and symlink redis-cli so hooks work
* HTTPS options for nginx
* Ubuntu/Debian platform compatibility fixes
* [FC035](http://acrmp.github.com/foodcritic/#FC035): Template uses node attribute directly

## v0.2.1

Thanks to Fletcher Nichol for the feedback and fixes :)
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ Much kudos to everyone who added indirectly to the epicness of this cookbook.

* Opscode, Inc cookbooks
- [git](http://ckbk.it/git)
- [sqlite](http://ckbk.it/sqlite)
- [build-essential](http://ckbk.it/build-essential)
- [python::pip](http://ckbk.it/python)
- [sudo](http://ckbk.it/sudo)
Expand Down
26 changes: 9 additions & 17 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,27 +1,19 @@
#!/usr/bin/env rake
require 'rake/testtask'

Rake::TestTask.new do |t|
t.libs.push "lib"
t.test_files = FileList['test/**/*_spec.rb']
t.verbose = true
end

desc "Runs foodcritic linter"
task :foodcritic do
if Gem::Version.new("1.9.2") <= Gem::Version.new(RUBY_VERSION.dup)
sandbox = File.join(File.dirname(__FILE__), %w{tmp foodcritic cookbook})
prepare_foodcritic_sandbox(sandbox)

sh "foodcritic --epic-fail any #{File.dirname(sandbox)}"
sh "foodcritic --epic-fail any ."
else
puts "WARN: foodcritic run is skipped as Ruby #{RUBY_VERSION} is < 1.9.2."
end
end

task :default => 'foodcritic'

private

def prepare_foodcritic_sandbox(sandbox)
files = %w{*.md *.rb attributes definitions files providers
recipes resources templates}

rm_rf sandbox
mkdir_p sandbox
cp_r Dir.glob("{#{files.join(',')}}"), sandbox
puts "\n\n"
end
task :default => [ 'test', 'foodcritic' ]
14 changes: 14 additions & 0 deletions chefignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Put files/directories that should be ignored in this file.
# Lines that start with '# ' are comments.

# gitignore
\.gitignore

# emacs
*~

# vim
*.sw[a-z]

# subversion
*/.svn/*
4 changes: 2 additions & 2 deletions metadata.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
license "Apache 2.0"
description "Installs/Configures gitlab"
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version "0.2.1"
version "0.3.0"
%w{ gitolite nginx }.each do |cb_conflict|
conflicts cb_conflict
end
%w{ ruby_build chef_gem git sqlite redisio build-essential python readline sudo openssh perl xml zlib}.each do |cb_depend|
%w{ ruby_build git redisio build-essential python readline sudo openssh perl xml zlib}.each do |cb_depend|
depends cb_depend
end
%w{ redhat centos scientific amazon debian ubuntu }.each do |os|
Expand Down
34 changes: 33 additions & 1 deletion recipes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
# Include cookbook dependencies
%w{ ruby_build gitlab::gitolite build-essential
readline sudo openssh xml zlib python::package python::pip
redisio::install redisio::enable sqlite }.each do |requirement|
redisio::install redisio::enable }.each do |requirement|
include_recipe requirement
end

Expand All @@ -40,6 +40,10 @@
owner "root"
group "root"
mode 0755
variables(
:fqdn => node['fqdn'],
:install_ruby => node['gitlab']['install_ruby']
)
end

# Set PATH for remainder of recipe.
Expand Down Expand Up @@ -126,6 +130,9 @@
owner node['gitlab']['user']
group node['gitlab']['group']
mode 0644
variables(
:public_key => node['gitlab']['public_key']
)
end

# Render public key template for gitolite user
Expand All @@ -142,6 +149,10 @@
owner node['gitlab']['user']
group node['gitlab']['group']
mode 0644
variables(
:fqdn => node['fqdn'],
:trust_local_sshkeys => node['gitlab']['trust_local_sshkeys']
)
end

# Sorry for this ugliness.
Expand Down Expand Up @@ -175,6 +186,12 @@
owner node['gitlab']['user']
group node['gitlab']['group']
mode 0644
variables(
:fqdn => node['fqdn'],
:https_boolean => node['gitlab']['https'],
:git_user => node['gitlab']['git_user'],
:git_home => node['gitlab']['git_home']
)
end

# Link sqlite example config file to database.yml
Expand Down Expand Up @@ -209,6 +226,10 @@
owner node['gitlab']['user']
group node['gitlab']['group']
mode 0644
variables(
:fqdn => node['fqdn'],
:gitlab_app_home => node['gitlab']['app_home']
)
end

# Render unicorn_rails init script
Expand All @@ -217,6 +238,10 @@
group "root"
mode 0755
source "unicorn_rails.init.erb"
variables(
:fqdn => node['fqdn'],
:gitlab_app_home => node['gitlab']['app_home']
)
end

# Start unicorn_rails and nginx service
Expand Down Expand Up @@ -248,4 +273,11 @@
mode 0644
source "nginx.default.conf.erb"
notifies :restart, "service[nginx]"
variables(
:hostname => node['hostname'],
:gitlab_app_home => node['gitlab']['app_home'],
:https_boolean => node['gitlab']['https'],
:ssl_certificate => node['gitlab']['ssl_certificate'],
:ssl_certificate_key => node['gitlab']['ssl_certificate_key']
)
end
5 changes: 4 additions & 1 deletion recipes/gitolite.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,8 @@
source "gitolite.rc.erb"
owner node['gitlab']['git_user']
group node['gitlab']['git_group']
mode 0644
mode 0644
variables(
:gitolite_umask => node['gitlab']['gitolite_umask']
)
end
4 changes: 2 additions & 2 deletions templates/default/gitlab.sh.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash
# Generated by Chef for <%= node["fqdn"] %>
# Generated by Chef for <%= @fqdn %>
# Local modifications will be overwritten.
RUBY_DIR="/usr/local/ruby/<%= node['gitlab']['install_ruby'] %>"
RUBY_DIR="/usr/local/ruby/<%= @install_ruby %>"
if ! echo ${PATH} | /bin/grep -q $RUBY_DIR/bin ; then
PATH=$RUBY_DIR/bin:${PATH}
fi
22 changes: 11 additions & 11 deletions templates/default/gitlab.yml.erb
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
# Generated by Chef for <%= node['fqdn'] %>
# Generated by Chef for <%= @fqdn %>
# Local modifications will be overwritten.

# Gitlab application config file

# Web application specific settings
web:
host: <%= node['fqdn'] %>
port: <%= node['gitlab']['https'] ? 443 : 80 %>
https: <%= node['gitlab']['https'] %>
host: <%= @fqdn %>
port: <%= @https_boolean ? 443 : 80 %>
https: <%= @https_boolean %>

# Email used for notification
# about new issues, comments
email:
from: gitlab@<%= node['fqdn'] %>
host: <%= node['fqdn'] %>
from: gitlab@<%= @fqdn %>
host: <%= @fqdn %>

# Protocol used for links in email letters
# Value can be http or https
protocol: <%= node['gitlab']['https'] ? "https" : "http" %>
protocol: <%= @https_boolean ? "https" : "http" %>

# Application specific settings
# Like default project limit for user etc
Expand All @@ -29,10 +29,10 @@ app:
# Git Hosting congiguration
git_host:
system: gitolite
admin_uri: <%= node['gitlab']['git_user'] %>@localhost:gitolite-admin
base_path: <%= node['gitlab']['git_home'] %>/repositories
host: <%= node['fqdn'] %>
git_user: <%= node['gitlab']['git_user'] %>
admin_uri: <%= @git_user %>@localhost:gitolite-admin
base_path: <%= @git_home %>/repositories
host: <%= @fqdn %>
git_user: <%= @git_user %>
# port: 22

# Git settings
Expand Down
2 changes: 1 addition & 1 deletion templates/default/gitolite.rc.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
%RC = (
UMASK => <%= node['gitlab']['gitolite_umask'] -%>,
UMASK => <%= @gitolite_umask -%>,
GIT_CONFIG_KEYS => '',
LOG_EXTRA => 1,
ROLES =>
Expand Down
2 changes: 1 addition & 1 deletion templates/default/id_rsa.pub.erb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<%= node['gitlab']['public_key'] %>
<%= @public_key %>
18 changes: 9 additions & 9 deletions templates/default/nginx.default.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ upstream unicorn_rails {
# single worker for timing out).

# for UNIX domain socket setups:
server unix:<%= node['gitlab']['app_home'] %>/tmp/sockets/gitlab.socket fail_timeout=0;
server unix:<%= @gitlab_app_home %>/tmp/sockets/gitlab.socket fail_timeout=0;

# for TCP setups, point these to your backend servers
# server 192.168.0.7:8080 fail_timeout=0;
Expand All @@ -13,20 +13,20 @@ upstream unicorn_rails {
}

server {
listen <%= node['gitlab']['https'] ? 443 : 80 %>;
listen <%= @https_boolean ? 443 : 80 %>;
client_max_body_size 4G;
server_name _;
<% if node['gitlab']['https'] %>
<% if @https_boolean %>
ssl on;
ssl_certificate <%= node['gitlab']['ssl_certificate'] %>;
ssl_certificate_key <%= node['gitlab']['ssl_certificate_key'] %>;
ssl_certificate <%= @ssl_certificate %>;
ssl_certificate_key <%= @ssl_certificate_key %>;
<% end %>


access_log /var/log/nginx/<%= node['hostname'] %>.access.log combined;
access_log /var/log/nginx/<%= @hostname %>.access.log combined;

# path for static files
root <%= node['gitlab']['app_home'] %>/public;
root <%= @gitlab_app_home %>/public;

# Prefer to serve static files directly from nginx to avoid unnecessary
# data copies from the application server.
Expand All @@ -39,7 +39,7 @@ server {

location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto <%= node['gitlab']['https'] ? "https" : "http" %>;
proxy_set_header X-Forwarded-Proto <%= @https_boolean ? "https" : "http" %>;
proxy_set_header Host $http_host;
proxy_redirect off;

Expand All @@ -52,7 +52,7 @@ server {
# Rails error pages
error_page 500 502 503 504 /500.html;
location = /500.html {
root <%= node['gitlab']['app_home'] %>/public;
root <%= @gitlab_app_home %>/public;
}

}
4 changes: 2 additions & 2 deletions templates/default/ssh_config.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Generated by Chef for <%= node['fqdn'] %>
# Generated by Chef for <%= @fqdn %>
# Local modifications will be overwritten.
NoHostAuthenticationForLocalhost <%= node['gitlab']['trust_local_sshkeys'] -%>
NoHostAuthenticationForLocalhost <%= @trust_local_sshkeys -%>
4 changes: 2 additions & 2 deletions templates/default/unicorn.rb.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Generated by Chef for <%= node['fqdn'] %>
# Generated by Chef for <%= @fqdn %>
# Local modifications will be overwritten.
app_dir = "<%= node['gitlab']['app_home'] %>"
app_dir = "<%= @gitlab_app_home %>"
worker_processes 2
working_directory app_dir

Expand Down
10 changes: 5 additions & 5 deletions templates/default/unicorn_rails.init.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#! /bin/bash

# Generated by Chef for <%= node['fqdn'] %>
# Generated by Chef for <%= @fqdn %>
# Local modifications will be overwritten.

# unicorn_rails init script for Linux
Expand All @@ -19,16 +19,16 @@
# Description: unicorn_rails init script as shipped with gitlab cookbook
### END INIT INFO

DAEMON_OPTS="-c <%= node['gitlab']['app_home'] %>/config/unicorn.rb -E production -D"
DAEMON_OPTS="-c <%= @gitlab_app_home %>/config/unicorn.rb -E production -D"
NAME=unicorn_rails
DESC=gitlab
PID=<%= node['gitlab']['app_home'] %>/tmp/pids/unicorn.pid
RESQUE_PID=<%= node['gitlab']['app_home'] %>/tmp/pids/resque_worker.pid
PID=<%= @gitlab_app_home %>/tmp/pids/unicorn.pid
RESQUE_PID=<%= @gitlab_app_home %>/tmp/pids/resque_worker.pid

case "$1" in
start)
. /etc/profile.d/gitlab.sh || exit 1
CD_TO_APP_DIR="cd <%= node['gitlab']['app_home'] %>"
CD_TO_APP_DIR="cd <%= @gitlab_app_home %>"
START_DAEMON_PROCESS="bundle exec unicorn_rails $DAEMON_OPTS"
START_RESQUE_PROCESS="./resque.sh"

Expand Down
2 changes: 1 addition & 1 deletion test/support/Gemfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
source "https://rubygems.org"

gem 'rake'
gem 'foodcritic', :platforms => :ruby_19
gem 'foodcritic'

0 comments on commit f942512

Please sign in to comment.