Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Daniel McNevin
committed
Dec 6, 2011
1 parent
6ddf2a3
commit b319913
Showing
9 changed files
with
203 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
.vagrant | ||
gitlab/config/gitlab.yml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
template "#{node[:nginx][:conf_d]}/gitlab.conf" do | ||
source "nginx.gitlab.conf.erb" | ||
variables( | ||
:base_port => 3000, | ||
:server_count => 1, | ||
:hostname => node[:gitlab][:hostname] | ||
) | ||
action :create | ||
notifies :restart, "service[nginx]" | ||
end |
18 changes: 18 additions & 0 deletions
18
chef/cookbooks/gitlab/templates/default/nginx.gitlab.conf.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
upstream gitlab-web { | ||
<% (@base_port..(@base_port + (@server_count - 1))).each do |port| %> | ||
server 127.0.0.1:<%= port %>; | ||
<% end %> | ||
} | ||
|
||
## HTTP Server | ||
server { | ||
server_name <%= @hostname %>; | ||
listen 80; | ||
|
||
location / { | ||
proxy_pass http://gitlab-web; | ||
proxy_buffering off; | ||
proxy_buffer_size 16k; | ||
proxy_buffers 8 16k; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
= DESCRIPTION: | ||
|
||
= REQUIREMENTS: | ||
|
||
= ATTRIBUTES: | ||
|
||
= USAGE: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
default[:nginx][:install_path] = "/usr/local/nginx" | ||
default[:nginx][:version] = '1.0.9' | ||
default[:nginx][:url] = "http://nginx.org/download/nginx-#{nginx[:version]}.tar.gz" | ||
# default[:nginx][:mam_path] = "/home/mam/src/mam" | ||
default[:nginx][:conf_d] = "#{nginx[:install_path]}/conf.d" | ||
|
||
default[:nginx][:nginx_name] = "nginx" | ||
default[:nginx][:base_path] = "/usr/local/nginx" | ||
default[:nginx][:log_path] = "#{nginx[:base_path]}/logs" | ||
# default[:nginx][:proxy_cache_path] = "#{nginx[:base_path]}/proxy_cache_path" | ||
# default[:nginx][:proxy_temp_path] = "#{nginx[:base_path]}/proxy_temp_path" | ||
default[:nginx][:pid_path] = "/var/run" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
# | ||
# Cookbook Name:: nginx | ||
# Recipe:: default | ||
# | ||
# Copyright 2011, Gobbler | ||
# | ||
# All rights reserved - Do Not Redistribute | ||
# | ||
|
||
packages = value_for_platform( | ||
["centos","redhat","fedora"] => {'default' => ['pcre-devel', 'openssl-devel']}, | ||
"default" => ['libpcre3', 'libpcre3-dev', 'libssl-dev'] | ||
) | ||
|
||
packages.each do |devpkg| | ||
package devpkg | ||
end | ||
|
||
tar_file = "nginx-#{node[:nginx][:version]}.tar.gz" | ||
|
||
remote_file "/tmp/#{tar_file}" do | ||
source "#{node[:nginx][:url]}" | ||
not_if { ::File.exists?("/tmp/#{tar_file}") } | ||
end | ||
|
||
bash "Install Nginx" do | ||
cwd "/tmp" | ||
code <<-EOH | ||
tar zxf #{tar_file} | ||
cd nginx-#{node[:nginx][:version]} | ||
./configure --prefix=#{node[:nginx][:install_path]} | ||
make install | ||
EOH | ||
not_if do | ||
::File.exists?("#{node[:nginx][:install_path]}/sbin/nginx") && | ||
system("#{node[:nginx][:install_path]}/sbin/nginx -v 2>&1 | grep -q '#{node[:nginx][:version]}$'") | ||
end | ||
end | ||
|
||
base_path = node[:nginx][:base_path] | ||
|
||
directory node[:nginx][:log_path] do | ||
owner "root" | ||
group "root" | ||
mode "0755" | ||
recursive true | ||
action :create | ||
end | ||
|
||
directory node[:nginx][:conf_d] do | ||
owner "root" | ||
group "root" | ||
mode "0755" | ||
action :create | ||
end | ||
|
||
template "/etc/init/nginx.conf" do | ||
source "upstart.nginx.conf.erb" | ||
owner "root" | ||
group "root" | ||
mode "0755" | ||
variables( | ||
:path => node[:nginx][:install_path], | ||
:pid_path => node[:nginx][:pid_path] | ||
) | ||
action :create | ||
end | ||
|
||
template "#{node[:nginx][:install_path]}/conf/nginx.conf" do | ||
source "nginx.conf.erb" | ||
owner "root" | ||
group "root" | ||
mode "0644" | ||
variables( | ||
:log_path => node[:nginx][:log_path], | ||
:pid_path => node[:nginx][:pid_path], | ||
:conf_d => node[:nginx][:conf_d] | ||
) | ||
action :create | ||
notifies :restart, "service[nginx]" | ||
end | ||
|
||
service "nginx" do | ||
provider Chef::Provider::Service::Upstart | ||
supports :start => true, :restart => true, :stop => true | ||
action [:enable, :start] | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#user nobody; | ||
worker_processes 1; | ||
|
||
error_log <%= @log_path %>/error.log; | ||
#error_log logs/error.log notice; | ||
#error_log logs/error.log info; | ||
|
||
pid <%= @pid_path %>/nginx.pid; | ||
|
||
|
||
events { | ||
worker_connections 1024; | ||
} | ||
|
||
|
||
http { | ||
|
||
include mime.types; | ||
default_type application/octet-stream; | ||
|
||
#log_format main '$remote_addr - $remote_user [$time_local] "$request" ' | ||
# '$status $body_bytes_sent "$http_referer" ' | ||
# '"$http_user_agent" "$http_x_forwarded_for"'; | ||
|
||
#access_log logs/access.log main; | ||
|
||
# sendfile on; | ||
# tcp_nopush on; | ||
|
||
#keepalive_timeout 0; | ||
keepalive_timeout 65; | ||
|
||
#gzip on; | ||
|
||
## Include all sub-configs | ||
include <%= @conf_d %>/*.conf; | ||
|
||
|
||
|
||
} |
26 changes: 26 additions & 0 deletions
26
chef/cookbooks/nginx/templates/default/upstart.nginx.conf.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# nginx | ||
|
||
description "nginx http daemon" | ||
author "George Shammas <georgyo@gmail.com>" | ||
|
||
start on (filesystem and net-device-up IFACE=lo) | ||
stop on runlevel [!2345] | ||
|
||
env DAEMON=<%= @path %>/sbin/nginx | ||
env PID=<%= @pid_path %>/nginx.pid | ||
|
||
expect fork | ||
respawn | ||
|
||
pre-start script | ||
$DAEMON -t | ||
if [ $? -ne 0 ] | ||
then exit $? | ||
fi | ||
end script | ||
|
||
post-stop script | ||
start-stop-daemon --stop --pidfile $PID --name nginx --exec $DAEMON --signal TERM | ||
end script | ||
|
||
exec $DAEMON |