Initial Chef repository

This commit is contained in:
Greg Karékinian
2015-07-21 19:45:23 +02:00
parent 7e5401fc71
commit ee4079fa85
1151 changed files with 185163 additions and 0 deletions

View File

@@ -0,0 +1,32 @@
#
# Cookbook Name:: nginx
# Recipe:: authorized_ips
#
# Author:: Jamie Winsor (<jamie@vialstudios.com>)
#
# Copyright 2012-2013, Riot Games
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
node.default['nginx']['remote_ip_var'] = 'remote_addr'
node.default['nginx']['authorized_ips'] = ['127.0.0.1/32']
template 'authorized_ip' do
path "#{node['nginx']['dir']}/authorized_ip"
source 'modules/authorized_ip.erb'
owner 'root'
group node['root_group']
mode '0644'
notifies :reload, 'service[nginx]', :delayed
end

View File

@@ -0,0 +1,24 @@
#
# Cookbook Name:: nginx
# Recipe:: commons
#
# Author:: AJ Christensen <aj@junglist.gen.nz>
#
# Copyright 2008-2013, Chef Software, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
include_recipe 'nginx::commons_dir'
include_recipe 'nginx::commons_script'
include_recipe 'nginx::commons_conf'

View File

@@ -0,0 +1,42 @@
#
# Cookbook Name:: nginx
# Recipe:: common/conf
#
# Author:: AJ Christensen <aj@junglist.gen.nz>
#
# Copyright 2008-2013, Chef Software, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
template 'nginx.conf' do
path "#{node['nginx']['dir']}/nginx.conf"
source node['nginx']['conf_template']
cookbook node['nginx']['conf_cookbook']
owner 'root'
group node['root_group']
mode '0644'
notifies :reload, 'service[nginx]', :delayed
end
template "#{node['nginx']['dir']}/sites-available/default" do
source 'default-site.erb'
owner 'root'
group node['root_group']
mode '0644'
notifies :reload, 'service[nginx]', :delayed
end
nginx_site 'default' do
enable node['nginx']['default_site_enabled']
end

View File

@@ -0,0 +1,57 @@
#
# Cookbook Name:: nginx
# Recipe:: common/dir
#
# Author:: AJ Christensen <aj@junglist.gen.nz>
#
# Copyright 2008-2013, Chef Software, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
directory node['nginx']['dir'] do
owner 'root'
group node['root_group']
mode '0755'
recursive true
end
directory node['nginx']['log_dir'] do
mode node['nginx']['log_dir_perm']
owner node['nginx']['user']
action :create
recursive true
end
directory File.dirname(node['nginx']['pid']) do
owner 'root'
group node['root_group']
mode '0755'
recursive true
end
%w(sites-available sites-enabled conf.d).each do |leaf|
directory File.join(node['nginx']['dir'], leaf) do
owner 'root'
group node['root_group']
mode '0755'
end
end
if !node['nginx']['default_site_enabled'] && (node['platform_family'] == 'rhel' || node['platform_family'] == 'fedora')
%w(default.conf example_ssl.conf).each do |config|
file "/etc/nginx/conf.d/#{config}" do
action :delete
end
end
end

View File

@@ -0,0 +1,29 @@
#
# Cookbook Name:: nginx
# Recipe:: common/script
#
# Author:: AJ Christensen <aj@junglist.gen.nz>
#
# Copyright 2008-2013, Chef Software, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
%w(nxensite nxdissite).each do |nxscript|
template "#{node['nginx']['script_dir']}/#{nxscript}" do
source "#{nxscript}.erb"
mode '0755'
owner 'root'
group node['root_group']
end
end

View File

@@ -0,0 +1,31 @@
#
# Cookbook Name:: nginx
# Recipe:: default
#
# Author:: AJ Christensen <aj@junglist.gen.nz>
#
# Copyright 2008-2013, Chef Software, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
include_recipe "nginx::#{node['nginx']['install_method']}"
service 'nginx' do
supports :status => true, :restart => true, :reload => true
action :start
end
node['nginx']['default']['modules'].each do |ngx_module|
include_recipe "nginx::#{ngx_module}"
end

View File

@@ -0,0 +1,50 @@
#
# Cookbook Name:: nginx
# Recipe:: headers_more_module
#
# Author:: Lucas Jandrew (<ljandrew@riotgames.com>)
#
# Copyright 2012-2013, Riot Games
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
tar_location = "#{Chef::Config['file_cache_path']}/headers_more.tar.gz"
module_location = "#{Chef::Config['file_cache_path']}/headers_more/#{node['nginx']['headers_more']['source_checksum']}"
remote_file tar_location do
source node['nginx']['headers_more']['source_url']
checksum node['nginx']['headers_more']['source_checksum']
owner 'root'
group node['root_group']
mode '0644'
end
directory module_location do
owner 'root'
group node['root_group']
mode '0755'
recursive true
action :create
end
bash 'extract_headers_more' do
cwd ::File.dirname(tar_location)
user 'root'
code <<-EOH
tar -zxf #{tar_location} -C #{module_location}
EOH
not_if { ::File.exist?("#{module_location}/headers-more-nginx-module-#{node['nginx']['headers_more']['version']}/config") }
end
node.run_state['nginx_configure_flags'] =
node.run_state['nginx_configure_flags'] | ["--add-module=#{module_location}/headers-more-nginx-module-#{node['nginx']['headers_more']['version']}/"]

View File

@@ -0,0 +1,52 @@
#
# Cookbook Name:: nginx
# Recipe:: http_auth_request_module
#
# Author:: David Radcliffe (<radcliffe.david@gmail.com>)
#
# Copyright 2013, David Radcliffe
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Documentation:
# http://nginx.org/en/docs/http/ngx_http_auth_request_module.html
if node['nginx']['source']['version'] >= '1.5.4'
node.run_state['nginx_configure_flags'] =
node.run_state['nginx_configure_flags'] | ['--with-http_auth_request_module']
else
arm_src_filename = ::File.basename(node['nginx']['auth_request']['url'])
arm_src_filepath = "#{Chef::Config['file_cache_path']}/#{arm_src_filename}"
arm_extract_path = "#{Chef::Config['file_cache_path']}/nginx_auth_request/#{node['nginx']['auth_request']['checksum']}"
remote_file arm_src_filepath do
source node['nginx']['auth_request']['url']
checksum node['nginx']['auth_request']['checksum']
owner 'root'
group node['root_group']
mode '0644'
end
bash 'extract_auth_request_module' do
cwd ::File.dirname(arm_src_filepath)
code <<-EOH
mkdir -p #{arm_extract_path}
tar xzf #{arm_src_filename} -C #{arm_extract_path}
mv #{arm_extract_path}/*/* #{arm_extract_path}/
EOH
not_if { ::File.exist?(arm_extract_path) }
end
node.run_state['nginx_configure_flags'] =
node.run_state['nginx_configure_flags'] | ["--add-module=#{arm_extract_path}"]
end

View File

@@ -0,0 +1,46 @@
#
# Cookbook Name:: nginx
# Recipe:: http_echo_module
#
# Author:: Danial Pearce (<danial@cushycms.com>)
#
# Copyright 2012-2013, CushyCMS
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
echo_src_filename = "echo-nginx-module-v#{node['nginx']['echo']['version']}.tar.gz"
echo_src_filepath = "#{Chef::Config['file_cache_path']}/#{echo_src_filename}"
echo_extract_path = "#{Chef::Config['file_cache_path']}/nginx_echo_module/#{node['nginx']['echo']['checksum']}"
remote_file echo_src_filepath do
source node['nginx']['echo']['url']
checksum node['nginx']['echo']['checksum']
owner 'root'
group node['root_group']
mode '0644'
end
bash 'extract_http_echo_module' do
cwd ::File.dirname(echo_src_filepath)
code <<-EOH
mkdir -p #{echo_extract_path}
tar xzf #{echo_src_filename} -C #{echo_extract_path}
mv #{echo_extract_path}/*/* #{echo_extract_path}/
EOH
not_if { ::File.exist?(echo_extract_path) }
end
node.run_state['nginx_configure_flags'] =
node.run_state['nginx_configure_flags'] | ["--add-module=#{echo_extract_path}"]

View File

@@ -0,0 +1,113 @@
#
# Cookbook Name:: nginx
# Recipe:: http_geoip_module
#
# Author:: Jamie Winsor (<jamie@vialstudios.com>)
#
# Copyright 2012-2013, Riot Games
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
country_dat = "#{node['nginx']['geoip']['path']}/GeoIP.dat"
country_src_filename = ::File.basename(node['nginx']['geoip']['country_dat_url'])
country_src_filepath = "#{Chef::Config['file_cache_path']}/#{country_src_filename}"
city_dat = nil
city_src_filename = ::File.basename(node['nginx']['geoip']['city_dat_url'])
city_src_filepath = "#{Chef::Config['file_cache_path']}/#{city_src_filename}"
geolib_filename = ::File.basename(node['nginx']['geoip']['lib_url'])
geolib_filepath = "#{Chef::Config['file_cache_path']}/#{geolib_filename}"
remote_file geolib_filepath do
source node['nginx']['geoip']['lib_url']
checksum node['nginx']['geoip']['lib_checksum']
owner 'root'
group node['root_group']
mode '0644'
end
bash 'extract_geolib' do
cwd ::File.dirname(geolib_filepath)
code <<-EOH
tar xzvf #{geolib_filepath} -C #{::File.dirname(geolib_filepath)}
cd GeoIP-#{node['nginx']['geoip']['lib_version']}
./configure
make && make install
EOH
environment('echo' => 'echo') if node['platform_family'] == 'rhel' && node['platform_version'].to_f < 6
creates "/usr/local/lib/libGeoIP.so.#{node['nginx']['geoip']['lib_version']}"
subscribes :run, "remote_file[#{geolib_filepath}]"
end
directory node['nginx']['geoip']['path'] do
owner 'root'
group node['root_group']
mode '0755'
recursive true
end
remote_file country_src_filepath do
not_if do
File.exist?(country_src_filepath) &&
File.mtime(country_src_filepath) > Time.now - 86_400
end
source node['nginx']['geoip']['country_dat_url']
checksum node['nginx']['geoip']['country_dat_checksum']
owner 'root'
group node['root_group']
mode '0644'
end
bash 'gunzip_geo_lite_country_dat' do
code <<-EOH
gunzip -c "#{country_src_filepath}" > #{country_dat}
EOH
creates country_dat
end
if node['nginx']['geoip']['enable_city']
city_dat = "#{node['nginx']['geoip']['path']}/GeoLiteCity.dat"
remote_file city_src_filepath do
not_if do
File.exist?(city_src_filepath) &&
File.mtime(city_src_filepath) > Time.now - 86_400
end
source node['nginx']['geoip']['city_dat_url']
checksum node['nginx']['geoip']['city_dat_checksum']
owner 'root'
group node['root_group']
mode '0644'
end
bash 'gunzip_geo_lite_city_dat' do
code <<-EOH
gunzip -c "#{city_src_filepath}" > #{city_dat}
EOH
creates city_dat
end
end
template "#{node['nginx']['dir']}/conf.d/http_geoip.conf" do
source 'modules/http_geoip.conf.erb'
owner 'root'
group node['root_group']
mode '0644'
variables(
:country_dat => country_dat,
:city_dat => city_dat
)
end
node.run_state['nginx_configure_flags'] =
node.run_state['nginx_configure_flags'] | ['--with-http_geoip_module', "--with-ld-opt='-Wl,-R,/usr/local/lib -L /usr/local/lib'"]

View File

@@ -0,0 +1,30 @@
#
# Cookbook Name:: nginx
# Recipe:: http_gzip_static_module
#
# Author:: Jamie Winsor (<jamie@vialstudios.com>)
#
# Copyright 2012-2013, Riot Games
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
template "#{node['nginx']['dir']}/conf.d/http_gzip_static.conf" do
source 'modules/http_gzip_static.conf.erb'
owner 'root'
group node['root_group']
mode '0644'
end
node.run_state['nginx_configure_flags'] =
node.run_state['nginx_configure_flags'] | ['--with-http_gzip_static_module']

View File

@@ -0,0 +1,2 @@
node.run_state['nginx_configure_flags'] =
node.run_state['nginx_configure_flags'] | ['--with-http_mp4_module']

View File

@@ -0,0 +1,23 @@
#
# Cookbook Name:: nginx
# Recipe:: http_perl_module
#
# Author:: Akzhan Abdulin (<akzhan.abdulin@gmail.com>)
#
# Copyright 2012-2013, REG.RU
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
node.run_state['nginx_configure_flags'] =
node.run_state['nginx_configure_flags'] | ['--with-http_perl_module']

View File

@@ -0,0 +1,38 @@
#
# Cookbook Name:: nginx
# Recipe:: http_realip_module
#
# Author:: Jamie Winsor (<jamie@vialstudios.com>)
#
# Copyright 2012-2013, Riot Games
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# Documentation: http://wiki.nginx.org/HttpRealIpModule
# Currently only accepts X-Forwarded-For or X-Real-IP
node.default['nginx']['realip']['header'] = 'X-Forwarded-For'
node.default['nginx']['realip']['addresses'] = ['127.0.0.1']
node.default['nginx']['realip']['real_ip_recursive'] = 'off'
template "#{node['nginx']['dir']}/conf.d/http_realip.conf" do
source 'modules/http_realip.conf.erb'
owner 'root'
group node['root_group']
mode '0644'
notifies :reload, 'service[nginx]', :delayed
end
node.run_state['nginx_configure_flags'] =
node.run_state['nginx_configure_flags'] | ['--with-http_realip_module']

View File

@@ -0,0 +1,23 @@
#
# Cookbook Name:: nginx
# Recipe:: http_spdy_module
#
# Author:: Christoph Buente (<christoph@meinekleinefarm.org>)
#
# Copyright 2013, MeinekleineFarm.org
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
node.run_state['nginx_configure_flags'] =
node.run_state['nginx_configure_flags'] | ['--with-http_spdy_module']

View File

@@ -0,0 +1,23 @@
#
# Cookbook Name:: nginx
# Recipe:: http_ssl_module
#
# Author:: Jamie Winsor (<jamie@vialstudios.com>)
#
# Copyright 2012-2013, Riot Games
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
node.run_state['nginx_configure_flags'] =
node.run_state['nginx_configure_flags'] | ['--with-http_ssl_module']

View File

@@ -0,0 +1,36 @@
#
# Cookbook Name:: nginx
# Recipe:: http_stub_status_module
#
# Author:: Jamie Winsor (<jamie@vialstudios.com>)
#
# Copyright 2012-2013, Riot Games
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
include_recipe 'nginx::authorized_ips'
template 'nginx_status' do
path "#{node['nginx']['dir']}/sites-available/nginx_status"
source 'modules/nginx_status.erb'
owner 'root'
group node['root_group']
mode '0644'
notifies :reload, 'service[nginx]', :delayed
end
nginx_site 'nginx_status'
node.run_state['nginx_configure_flags'] =
node.run_state['nginx_configure_flags'] | ['--with-http_stub_status_module']

View File

@@ -0,0 +1,23 @@
#
# Cookbook Name:: nginx
# Recipe:: ipv6
#
# Author:: Alan Harper (alan@sct.com.au)
#
# Copyright 2013 Alan Harper
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
node.run_state['nginx_configure_flags'] =
node.run_state['nginx_configure_flags'] | ['--with-ipv6']

View File

@@ -0,0 +1,47 @@
#
# Cookbook Name:: nginx
# Recipe:: default
#
# Copyright 2013, Chef Software, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
luajit_src_filename = ::File.basename(node['nginx']['luajit']['url'])
luajit_src_filepath = "#{Chef::Config['file_cache_path']}/#{luajit_src_filename}"
luajit_extract_path = "#{Chef::Config['file_cache_path']}/luajit-#{node['nginx']['luajit']['version']}"
remote_file luajit_src_filepath do
source node['nginx']['luajit']['url']
checksum node['nginx']['luajit']['checksum']
owner 'root'
group node['root_group']
mode '0644'
end
bash 'extract_luajit' do
cwd ::File.dirname(luajit_src_filepath)
code <<-EOH
mkdir -p #{luajit_extract_path}
tar xzf #{luajit_src_filename} -C #{luajit_extract_path}
cd luajit-#{node['nginx']['luajit']['version']}/LuaJIT-#{node['nginx']['luajit']['version']}
make && make install
export LUAJIT_INC="/usr/local/include/luajit-2.0"
export LUAJIT_LIB="usr/local/lib"
EOH
not_if { ::File.exist?(luajit_extract_path) }
end
package 'lua-devel' do
action :install
end

View File

@@ -0,0 +1,52 @@
#
# Cookbook Name:: nginx
# Recipe:: naxsi_module
#
# Author:: Artiom Lunev (<artiom.lunev@gmail.com>)
#
# Copyright 2012-2013, Artiom Lunev
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
cookbook_file "#{node['nginx']['dir']}/naxsi_core.rules" do
source 'naxsi_core.rules'
owner 'root'
group node['root_group']
mode '0644'
notifies :reload, 'service[nginx]', :delayed
end
naxsi_src_filename = ::File.basename(node['nginx']['naxsi']['url'])
naxsi_src_filepath = "#{Chef::Config['file_cache_path']}/#{naxsi_src_filename}"
naxsi_extract_path = "#{Chef::Config['file_cache_path']}/nginx-naxsi-#{node['nginx']['naxsi']['version']}"
remote_file naxsi_src_filepath do
source node['nginx']['naxsi']['url']
checksum node['nginx']['naxsi']['checksum']
owner 'root'
group node['root_group']
mode '0644'
end
bash 'extract_naxsi_module' do
cwd ::File.dirname(naxsi_src_filepath)
code <<-EOH
mkdir -p #{naxsi_extract_path}
tar xzf #{naxsi_src_filename} -C #{naxsi_extract_path}
EOH
not_if { ::File.exist?(naxsi_extract_path) }
end
node.run_state['nginx_configure_flags'] =
node.run_state['nginx_configure_flags'] | ["--add-module=#{naxsi_extract_path}/naxsi-#{node['nginx']['naxsi']['version']}/naxsi_src"]

View File

@@ -0,0 +1,44 @@
#
# Cookbook Name:: nginx
# Recipes:: devel
#
# Author:: Arthur Freyman (<afreyman@riotgames.com>)
#
# Copyright 2013, Riot Games
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
devel_src_filename = ::File.basename(node['nginx']['devel']['url'])
devel_src_filepath = "#{Chef::Config['file_cache_path']}/#{devel_src_filename}"
devel_extract_path = "#{Chef::Config['file_cache_path']}/nginx-devel-#{node['nginx']['devel']['version']}"
remote_file devel_src_filepath do
source node['nginx']['devel']['url']
checksum node['nginx']['devel']['checksum']
owner 'root'
group node['root_group']
mode '0644'
end
bash 'extract_devel_module' do
cwd ::File.dirname(devel_src_filepath)
code <<-EOH
mkdir -p #{devel_extract_path}
tar xzf #{devel_src_filename} -C #{devel_extract_path}
EOH
not_if { ::File.exist?(devel_extract_path) }
end
node.run_state['nginx_configure_flags'] =
node.run_state['nginx_configure_flags'] | ["--add-module=#{devel_extract_path}/ngx_devel_kit-#{node['nginx']['devel']['version']}"]

View File

@@ -0,0 +1,47 @@
#
# Cookbook Name:: nginx
# Recipes:: lua
#
# Author:: Arthur Freyman (<afreyman@riotgames.com>)
#
# Copyright 2013, Riot Games
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
lua_src_filename = ::File.basename(node['nginx']['lua']['url'])
lua_src_filepath = "#{Chef::Config['file_cache_path']}/#{lua_src_filename}"
lua_extract_path = "#{Chef::Config['file_cache_path']}/nginx-lua-#{node['nginx']['lua']['version']}"
remote_file lua_src_filepath do
source node['nginx']['lua']['url']
checksum node['nginx']['lua']['checksum']
owner 'root'
group node['root_group']
mode '0644'
end
bash 'extract_lua_module' do
cwd ::File.dirname(lua_src_filepath)
code <<-EOH
mkdir -p #{lua_extract_path}
tar xzf #{lua_src_filename} -C #{lua_extract_path}
EOH
not_if { ::File.exist?(lua_extract_path) }
end
node.run_state['nginx_configure_flags'] =
node.run_state['nginx_configure_flags'] | ["--add-module=#{lua_extract_path}/lua-nginx-module-#{node['nginx']['lua']['version']}"]
include_recipe 'nginx::lua'
include_recipe 'nginx::ngx_devel_module'

View File

@@ -0,0 +1,35 @@
#
# Cookbook Name:: nginx
# Recipe:: ohai_plugin
#
# Author:: Jamie Winsor (<jamie@vialstudios.com>)
#
# Copyright 2012-2013, Riot Games
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
ohai 'reload_nginx' do
plugin 'nginx'
action :nothing
end
template "#{node['ohai']['plugin_path']}/nginx.rb" do
source 'plugins/nginx.rb.erb'
owner 'root'
group node['root_group']
mode '0755'
notifies :reload, 'ohai[reload_nginx]', :immediately
end
include_recipe 'ohai::default'

View File

@@ -0,0 +1,45 @@
#
# Cookbook Name:: nginx
# Recipe:: openssl_source
#
# Author:: David Radcliffe (<radcliffe.david@gmail.com>)
#
# Copyright 2013, David Radcliffe
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
src_filename = ::File.basename(node['nginx']['openssl_source']['url'])
src_filepath = "#{Chef::Config['file_cache_path']}/#{src_filename}"
extract_path = "#{Chef::Config['file_cache_path']}/openssl-#{node['nginx']['openssl_source']['version']}"
remote_file src_filepath do
source node['nginx']['openssl_source']['url']
owner 'root'
group node['root_group']
mode '0644'
not_if { ::File.exist?(src_filepath) }
end
bash 'extract_openssl' do
cwd ::File.dirname(src_filepath)
code <<-EOH
mkdir -p #{extract_path}
tar xzf #{src_filename} -C #{extract_path}
mv #{extract_path}/*/* #{extract_path}/
EOH
not_if { ::File.exist?(extract_path) }
end
node.run_state['nginx_configure_flags'] =
node.run_state['nginx_configure_flags'] | ["--with-openssl=#{extract_path}"]

View File

@@ -0,0 +1,52 @@
#
# Cookbook Name:: nginx
# Recipe:: package
# Author:: AJ Christensen <aj@junglist.gen.nz>
#
# Copyright 2008-2013, Chef Software, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
include_recipe 'nginx::ohai_plugin'
if platform_family?('rhel')
if node['nginx']['repo_source'] == 'epel'
include_recipe 'yum-epel'
elsif node['nginx']['repo_source'] == 'nginx'
include_recipe 'nginx::repo'
package_install_opts = '--disablerepo=* --enablerepo=nginx'
elsif node['nginx']['repo_source'].to_s.empty?
log "node['nginx']['repo_source'] was not set, no additional yum repositories will be installed." do
level :debug
end
else
fail ArgumentError, "Unknown value '#{node['nginx']['repo_source']}' was passed to the nginx cookbook."
end
elsif platform_family?('debian')
include_recipe 'nginx::repo_passenger' if node['nginx']['repo_source'] == 'passenger'
include_recipe 'nginx::repo' if node['nginx']['repo_source'] == 'nginx'
end
package node['nginx']['package_name'] do
options package_install_opts
notifies :reload, 'ohai[reload_nginx]', :immediately
not_if 'which nginx'
end
service 'nginx' do
supports :status => true, :restart => true, :reload => true
action :enable
end
include_recipe 'nginx::commons'

View File

@@ -0,0 +1,62 @@
#
# Cookbook Name:: nginx
# Recipe:: pagespeed_module
#
src_filename = ::File.basename(node['nginx']['pagespeed']['url'])
src_filepath = "#{Chef::Config['file_cache_path']}/#{src_filename}"
extract_path = "#{Chef::Config['file_cache_path']}/nginx_pagespeed-#{node['nginx']['pagespeed']['version']}"
remote_file src_filepath do
source node['nginx']['pagespeed']['url']
owner 'root'
group node['root_group']
mode '0644'
not_if { ::File.exist?(src_filepath) }
end
psol_src_filename = "psol-#{::File.basename(node['nginx']['psol']['url'])}"
psol_src_filepath = "#{Chef::Config['file_cache_path']}/#{psol_src_filename}"
psol_extract_path = "#{Chef::Config['file_cache_path']}/nginx_pagespeed-#{node['nginx']['pagespeed']['version']}/psol"
remote_file psol_src_filepath do
source node['nginx']['psol']['url']
owner 'root'
group node['root_group']
mode '0644'
not_if { ::File.exist?(psol_src_filepath) }
end
packages = value_for_platform_family(
%w(rhel) => node['nginx']['pagespeed']['packages']['rhel'],
%w(debian) => node['nginx']['pagespeed']['packages']['debian']
)
unless packages.empty?
packages.each do |name|
package name
end
end
bash 'extract_pagespeed' do
cwd ::File.dirname(src_filepath)
code <<-EOH
mkdir -p #{extract_path}
tar xzf #{src_filename} -C #{extract_path}
mv #{extract_path}/*/* #{extract_path}/
EOH
not_if { ::File.exist?(extract_path) }
end
bash 'extract_psol' do
cwd ::File.dirname(psol_src_filepath)
code <<-EOH
mkdir -p #{psol_extract_path}
tar xzf #{psol_src_filename} -C #{psol_extract_path}
mv #{psol_extract_path}/*/* #{psol_extract_path}/
EOH
not_if { ::File.exist?(psol_extract_path) }
end
node.run_state['nginx_configure_flags'] =
node.run_state['nginx_configure_flags'] | ["--add-module=#{extract_path}"]

View File

@@ -0,0 +1,56 @@
#
# Cookbook Name:: nginx
# Recipe:: Passenger
#
# Copyright 2013, Chef Software, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
packages = value_for_platform_family(
%w(rhel) => node['nginx']['passenger']['packages']['rhel'],
%w(fedora) => node['nginx']['passenger']['packages']['fedora'],
%w(debian) => node['nginx']['passenger']['packages']['debian']
)
unless packages.empty?
packages.each do |name|
package name
end
end
gem_package 'rake' if node['nginx']['passenger']['install_rake']
if node['nginx']['passenger']['install_method'] == 'package'
package node['nginx']['package_name']
package 'passenger'
elsif node['nginx']['passenger']['install_method'] == 'source'
gem_package 'passenger' do
action :install
version node['nginx']['passenger']['version']
gem_binary node['nginx']['passenger']['gem_binary'] if node['nginx']['passenger']['gem_binary']
end
node.run_state['nginx_configure_flags'] =
node.run_state['nginx_configure_flags'] | ["--add-module=#{node['nginx']['passenger']['root']}/ext/nginx"]
end
template "#{node['nginx']['dir']}/conf.d/passenger.conf" do
source 'modules/passenger.conf.erb'
owner 'root'
group node['root_group']
mode '0644'
notifies :reload, 'service[nginx]', :delayed
end

View File

@@ -0,0 +1,41 @@
#
# Cookbook Name:: nginx
# Recipe:: repo
# Author:: Nick Rycar <nrycar@bluebox.net>
#
# Copyright 2008-2013, Chef Software, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
case node['platform_family']
when 'rhel', 'fedora'
yum_repository 'nginx' do
description 'Nginx.org Repository'
baseurl node['nginx']['upstream_repository']
gpgkey 'http://nginx.org/keys/nginx_signing.key'
action :create
end
when 'debian'
include_recipe 'apt::default'
apt_repository 'nginx' do
uri node['nginx']['upstream_repository']
distribution node['lsb']['codename']
components %w(nginx)
deb_src true
key 'http://nginx.org/keys/nginx_signing.key'
end
end

View File

@@ -0,0 +1,39 @@
# Cookbook Name:: nginx
# Recipe:: repo_passenger
# Author:: Jose Alberto Suarez Lopez <ja@josealberto.org>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
case node['platform_family']
when 'rhel', 'fedora'
log 'There is not official phusion passenger repo for redhat based systems.' do
level :info
end
when 'debian'
include_recipe 'apt::default'
package 'apt-transport-https'
apt_repository 'phusionpassenger' do
uri 'https://oss-binaries.phusionpassenger.com/apt/passenger'
distribution node['lsb']['codename']
components %w(main)
deb_src true
keyserver 'keyserver.ubuntu.com'
key '561F9B9CAC40B2F7'
end
include_recipe 'nginx::passenger'
end

View File

@@ -0,0 +1,30 @@
#
# Cookbook Name:: nginx
# Recipes:: set_misc
#
set_misc_src_filename = ::File.basename(node['nginx']['set_misc']['url'])
set_misc_src_filepath = "#{Chef::Config['file_cache_path']}/#{set_misc_src_filename}"
set_misc_extract_path = "#{Chef::Config['file_cache_path']}/nginx-set_misc-#{node['nginx']['set_misc']['version']}"
remote_file set_misc_src_filepath do
source node['nginx']['set_misc']['url']
checksum node['nginx']['set_misc']['checksum']
owner 'root'
group 'root'
mode '0644'
end
bash 'extract_set_misc_module' do
cwd ::File.dirname(set_misc_src_filepath)
code <<-EOH
mkdir -p #{set_misc_extract_path}
tar xzf #{set_misc_src_filename} -C #{set_misc_extract_path}
EOH
not_if { ::File.exist?(set_misc_extract_path) }
end
node.run_state['nginx_configure_flags'] =
node.run_state['nginx_configure_flags'] | ["--add-module=#{set_misc_extract_path}/set-misc-nginx-module-#{node['nginx']['set_misc']['version']}"]
include_recipe 'nginx::ngx_devel_module'

View File

@@ -0,0 +1,26 @@
include_recipe 'nginx::commons_dir'
directory node['nginx']['socketproxy']['root'] do
owner node['nginx']['socketproxy']['app_owner']
group node['nginx']['socketproxy']['app_owner']
mode 00755
action :create
end
context_names = node['nginx']['socketproxy']['apps'].map do |_app, app_conf|
app_conf['context_name']
end
fail 'More than one app has the same context_name configured.' if context_names.uniq.length != context_names.length
template node['nginx']['dir'] + '/sites-available/socketproxy.conf' do
source 'modules/socketproxy.conf.erb'
owner 'root'
group 'root'
mode 00644
notifies :reload, 'service[nginx]', :delayed
end
link node['nginx']['dir'] + '/sites-enabled/socketproxy.conf' do
to node['nginx']['dir'] + '/sites-available/socketproxy.conf'
end

View File

@@ -0,0 +1,205 @@
#
# Cookbook Name:: nginx
# Recipe:: source
#
# Author:: Adam Jacob (<adam@chef.io>)
# Author:: Joshua Timberman (<joshua@chef.io>)
# Author:: Jamie Winsor (<jamie@vialstudios.com>)
#
# Copyright 2009-2013, Chef Software, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# This is for Chef 10 and earlier where attributes aren't loaded
# deterministically (resolved in Chef 11).
node.load_attribute_by_short_filename('source', 'nginx') if node.respond_to?(:load_attribute_by_short_filename)
nginx_url = node['nginx']['source']['url'] ||
"http://nginx.org/download/nginx-#{node['nginx']['source']['version']}.tar.gz"
node.set['nginx']['binary'] = node['nginx']['source']['sbin_path']
node.set['nginx']['daemon_disable'] = true
unless node['nginx']['source']['use_existing_user']
user node['nginx']['user'] do
system true
shell '/bin/false'
home '/var/www'
end
end
include_recipe 'nginx::ohai_plugin'
include_recipe 'nginx::commons_dir'
include_recipe 'nginx::commons_script'
include_recipe 'build-essential::default'
src_filepath = "#{Chef::Config['file_cache_path'] || '/tmp'}/nginx-#{node['nginx']['source']['version']}.tar.gz"
packages = value_for_platform_family(
%w(rhel fedora suse) => %w(pcre-devel openssl-devel),
%w(gentoo) => [],
%w(default) => %w(libpcre3 libpcre3-dev libssl-dev)
)
packages.each do |name|
package name
end
remote_file nginx_url do
source nginx_url
checksum node['nginx']['source']['checksum']
path src_filepath
backup false
end
node.run_state['nginx_force_recompile'] = false
node.run_state['nginx_configure_flags'] =
node['nginx']['source']['default_configure_flags'] | node['nginx']['configure_flags']
include_recipe 'nginx::commons_conf'
cookbook_file "#{node['nginx']['dir']}/mime.types" do
source 'mime.types'
owner 'root'
group node['root_group']
mode '0644'
notifies :reload, 'service[nginx]', :delayed
end
# source install depends on the existence of the `tar` package
package 'tar'
# Unpack downloaded source so we could apply nginx patches
# in custom modules - example http://yaoweibin.github.io/nginx_tcp_proxy_module/
# patch -p1 < /path/to/nginx_tcp_proxy_module/tcp.patch
bash 'unarchive_source' do
cwd ::File.dirname(src_filepath)
code <<-EOH
tar zxf #{::File.basename(src_filepath)} -C #{::File.dirname(src_filepath)}
EOH
not_if { ::File.directory?("#{Chef::Config['file_cache_path'] || '/tmp'}/nginx-#{node['nginx']['source']['version']}") }
end
node['nginx']['source']['modules'].each do |ngx_module|
include_recipe ngx_module
end
configure_flags = node.run_state['nginx_configure_flags']
nginx_force_recompile = node.run_state['nginx_force_recompile']
bash 'compile_nginx_source' do
cwd ::File.dirname(src_filepath)
code <<-EOH
cd nginx-#{node['nginx']['source']['version']} &&
./configure #{node.run_state['nginx_configure_flags'].join(' ')} &&
make && make install
EOH
not_if do
nginx_force_recompile == false &&
node.automatic_attrs['nginx'] &&
node.automatic_attrs['nginx']['version'] == node['nginx']['source']['version'] &&
node.automatic_attrs['nginx']['configure_arguments'].sort == configure_flags.sort
end
notifies :restart, 'service[nginx]'
notifies :reload, 'ohai[reload_nginx]', :immediately
end
case node['nginx']['init_style']
when 'runit'
node.set['nginx']['src_binary'] = node['nginx']['binary']
include_recipe 'runit::default'
runit_service 'nginx'
service 'nginx' do
supports :status => true, :restart => true, :reload => true
reload_command "#{node['runit']['sv_bin']} hup #{node['runit']['service_dir']}/nginx"
end
when 'bluepill'
include_recipe 'bluepill::default'
template "#{node['bluepill']['conf_dir']}/nginx.pill" do
source 'nginx.pill.erb'
mode '0644'
end
bluepill_service 'nginx' do
action [:enable, :load]
end
service 'nginx' do
supports :status => true, :restart => true, :reload => true
reload_command "[[ -f #{node['nginx']['pid']} ]] && kill -HUP `cat #{node['nginx']['pid']}` || true"
action :nothing
end
when 'upstart'
# we rely on this to set up nginx.conf with daemon disable instead of doing
# it in the upstart init script.
node.set['nginx']['daemon_disable'] = node['nginx']['upstart']['foreground']
template '/etc/init/nginx.conf' do
source 'nginx-upstart.conf.erb'
owner 'root'
group node['root_group']
mode '0644'
end
service 'nginx' do
provider Chef::Provider::Service::Upstart
supports :status => true, :restart => true, :reload => true
action :nothing
end
else
node.set['nginx']['daemon_disable'] = false
generate_init = true
case node['platform']
when 'gentoo'
generate_template = false
when 'debian', 'ubuntu'
generate_template = true
defaults_path = '/etc/default/nginx'
when 'freebsd'
generate_init = false
else
generate_template = true
defaults_path = '/etc/sysconfig/nginx'
end
template '/etc/init.d/nginx' do
source 'nginx.init.erb'
owner 'root'
group node['root_group']
mode '0755'
end if generate_init
if generate_template
template defaults_path do
source 'nginx.sysconfig.erb'
owner 'root'
group node['root_group']
mode '0644'
end
end
service 'nginx' do
supports :status => true, :restart => true, :reload => true
action :enable
end
end
node.run_state.delete('nginx_configure_flags')
node.run_state.delete('nginx_force_recompile')

View File

@@ -0,0 +1,69 @@
#
# Cookbook Name:: nginx
# Recipe:: syslog_module
#
# Author:: Bob Ziuchkovski (<bob@bz-technology.com>)
#
# Copyright 2014, UserTesting
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
nginx_src = "#{Chef::Config['file_cache_path']}/nginx-#{node['nginx']['source']['version']}"
nginx_syslog_src = "#{Chef::Config['file_cache_path']}/nginx_syslog_module"
major, minor, patch = node['nginx']['source']['version'].split('.').map { |s| Integer(s) }
fail 'Unsupported nginx version' if major != 1
case minor
when 2
case patch
when 0..6
syslog_patch = 'syslog_1.2.0.patch'
else
syslog_patch = 'syslog_1.2.7.patch'
end
when 3
case patch
when 0..9
syslog_patch = 'syslog_1.2.0.patch'
when 10..13
syslog_patch = 'syslog_1.3.11.patch'
else
syslog_patch = 'syslog_1.3.14.patch'
end
when 4
syslog_patch = 'syslog_1.4.0.patch'
when 5..6
syslog_patch = 'syslog_1.5.6.patch'
when 7
syslog_patch = 'syslog_1.7.0.patch'
else
fail 'Unsupported nginx version'
end
git nginx_syslog_src do
repository node['nginx']['syslog']['git_repo']
revision node['nginx']['syslog']['git_revision']
action :sync
user 'root'
group 'root'
end
execute 'apply_nginx_syslog_patch' do
cwd nginx_src
command "patch -p1 < #{nginx_syslog_src}/#{syslog_patch}"
not_if "patch -p1 --dry-run --reverse --silent < #{nginx_syslog_src}/#{syslog_patch}", :cwd => nginx_src
end
node.run_state['nginx_configure_flags'] =
node.run_state['nginx_configure_flags'] | ["--add-module=#{nginx_syslog_src}"]

View File

@@ -0,0 +1,53 @@
#
# Cookbook Name:: nginx
# Recipe:: upload_progress_module
#
# Author:: Jamie Winsor (<jamie@vialstudios.com>)
#
# Copyright 2012-2013, Riot Games
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
upm_src_filename = ::File.basename(node['nginx']['upload_progress']['url'])
upm_src_filepath = "#{Chef::Config['file_cache_path']}/#{upm_src_filename}"
upm_extract_path = "#{Chef::Config['file_cache_path']}/nginx_upload_progress/#{node['nginx']['upload_progress']['checksum']}"
remote_file upm_src_filepath do
source node['nginx']['upload_progress']['url']
checksum node['nginx']['upload_progress']['checksum']
owner 'root'
group node['root_group']
mode '0644'
end
template "#{node['nginx']['dir']}/conf.d/upload_progress.conf" do
source 'modules/upload_progress.erb'
owner 'root'
group node['root_group']
mode '0644'
notifies :reload, 'service[nginx]', :delayed
end
bash 'extract_upload_progress_module' do
cwd ::File.dirname(upm_src_filepath)
code <<-EOH
mkdir -p #{upm_extract_path}
tar xzf #{upm_src_filename} -C #{upm_extract_path}
mv #{upm_extract_path}/*/* #{upm_extract_path}/
EOH
not_if { ::File.exist?(upm_extract_path) }
end
node.run_state['nginx_configure_flags'] =
node.run_state['nginx_configure_flags'] | ["--add-module=#{upm_extract_path}"]